. // It's licensed under the AFFERO GENERAL PUBLIC LICENSE unless stated otherwise. // You can get copies of the licenses here: // http://www.affero.org/oagpl.html // AFFERO GENERAL PUBLIC LICENSE is also included in the file called "COPYING". include('config.php'); include(mnminclude.'html1.php'); include(mnminclude.'link.php'); include(mnminclude.'tags.php'); force_authentication(); do_header(_("editar noticia"), "post"); do_banner_top(); echo '
' . "\n"; echo '
'."\n"; if (!empty($_REQUEST['id']) && is_numeric($_REQUEST['id'])) { $linkres=new Link; $linkres->id=$link_id = intval($_REQUEST['id']); $linkres->read(); if (!$linkres->is_editable() || intval($_GET['user'] != $current_user->user_id)) { echo '
  '._("noticia no modificable").'
'."\n"; return; } if ($_POST['phase'] == "1") { do_save(); fork("backend/send_pingbacks.php?id=$linkres->id"); } else { do_edit(); } } else { echo '
  '._("¿duh?").'
'; } echo "
"; do_footer(); function do_edit() { global $linkres, $dblang, $db, $current_user; $link_title = trim($linkres->title); $link_content = trim($linkres->content); $link_tags = htmlspecialchars(trim($linkres->tags)); $link_url = $linkres->url; echo '

'._('editar noticia').'

'."\n"; echo '
'."\n"; echo '
'."\n"; $now = time(); echo ''."\n"; echo ''."\n"; echo ''."\n"; echo ''."\n"; echo '
'._('detalles de la noticia').''."\n"; if($current_user->user_level == 'admin' || $current_user->user_level == 'god') { echo ''."\n"; echo '

'._('url de la noticia.').''."\n"; echo '

'."\n"; } echo ''."\n"; echo '

'._('título de la noticia. máximo: 120 caracteres').''."\n"; echo '
'; // Allow to change the status if ($linkres->votes > 0 && $linkres->status != 'published' && (($linkres->status != 'discard' && $current_user->user_id == $linkres->author) || $current_user->user_level == 'admin' || $current_user->user_level == 'god')) { echo '    '; echo ''; } echo '

'."\n"; echo ''."\n"; echo '

'._('pocas palabras, genéricas, cortas y separadas por "," (coma)').' Ejemplo: web, programación, software libre'."\n"; echo '

'."\n"; echo '
'; print_simpleformat_buttons('bodytext'); echo '
'; echo '

'."\n"; echo '
'._('describe la noticia con tus palabras. entre dos y cinco frases es suficiente. sé cuidadoso.').''."\n"; echo '
'."\n"; $body_left = 550 - mb_strlen(html_entity_decode($link_content, ENT_COMPAT, 'UTF-8'), 'UTF-8'); echo '
' . _('caracteres libres') . ''; echo '

'."\n"; print_categories_form($linkres->category); echo ''."\n"; echo '
'."\n"; echo '
'."\n"; echo '
'."\n"; } function do_save() { global $linkres, $dblang, $current_user; $linkres->category=intval($_POST['category']); if (!empty($_POST['url']) && ($current_user->user_level == 'admin' || $current_user->user_level == 'god')) { $linkres->url = clean_input_url($_POST['url']); } $linkres->title = clean_text($_POST['title'], 40); $linkres->content = clean_text($_POST['bodytext']); $linkres->tags = tags_normalize_string(clean_text($_POST['tags'])); // change the status if ($linkres->status != 'published' && ($_POST['status'] == 'queued' || $_POST['status'] == 'discard')) { if ($linkres->status != 'discard' && $_POST['status'] == 'discard') { // Insert a log entry if the link has been manually discarded $insert_discard_log = true; } $linkres->status = $_POST['status']; } if (!link_edit_errors($linkres)) { if (empty($linkres->uri)) $linkres->get_uri(); $linkres->store(); tags_insert_string($linkres->id, $dblang, $linkres->tags, $linkres->date); // Insert edit log/event require_once(mnminclude.'log.php'); if ($insert_discard_log) { // Insert always a link and discard event if the status has been changed to discard log_insert('link_discard', $linkres->id, $current_user->user_id); log_insert('link_edit', $linkres->id, $current_user->user_id); } else { log_conditional_insert('link_edit', $linkres->id, $current_user->user_id, 60); } echo '
  '._("noticia actualizada").'
'."\n"; } $linkres->read(); echo '
'."\n"; $linkres->print_summary('preview'); echo '
'."\n"; echo '
'; echo ''."\n"; echo '  '."\n";; echo ''."\n"; echo '
'. "\n"; } function link_edit_errors($linkres) { global $current_user; $error = false; // only checks if the user is not special or god if(!$linkres->check_url($linkres->url, false) && $current_user->user_level != 'admin' && $current_user->user_level != 'god') { echo '
  '._('url incorrecto').'
'; $error = true; } if($_POST['key'] !== md5($_POST['timestamp'].$linkres->randkey)) { echo '
  '._('Clave incorrecta').'
'; $error = true; } if(time() - $_POST['timestamp'] > 900) { echo '
  '._('Tiempo excedido').'
'; $error = true; } if(strlen($linkres->title) < 10 || strlen($linkres->content) < 30 ) { //echo '
'; echo '
  '._("Título o texto incompletos").'
'; $error = true; } if(mb_strlen(html_entity_decode($linkres->title, ENT_COMPAT, 'UTF-8'), 'UTF-8') > 120 || mb_strlen(html_entity_decode($linkres->content, ENT_COMPAT, 'UTF-8'), 'UTF-8') > 550 ) { echo '
  '._("Título o texto demasiado largos").'
'; $error = true; } if(strlen($linkres->tags) < 3 ) { echo '
  '._("No has puesto etiquetas").'
'; $error = true; } if(preg_match('/.*http:\//', $linkres->title)) { //echo '
'; echo '
  '._("Por favor, no pongas URLs en el título, no ofrece información").'
'; $error = true; } if(!$linkres->category > 0) { //echo '
'; echo '
  '._("Categoría no seleccionada").'
'; $error = true; } return $error; } ?>