includes/pageutils.php
changeset 15 ad5986a53197
parent 1 fe660c52c48f
child 16 64e0d3d4cf14
equal deleted inserted replaced
14:ce6053bb48d8 15:ad5986a53197
  1192     $pname = $paths->nslist[$namespace] . $page_id;
  1192     $pname = $paths->nslist[$namespace] . $page_id;
  1193     
  1193     
  1194     $prot = ( ( $paths->pages[$pname]['protected'] == 2 && $session->user_logged_in && $session->reg_time + 60*60*24*4 < time() ) || $paths->pages[$pname]['protected'] == 1) ? true : false;
  1194     $prot = ( ( $paths->pages[$pname]['protected'] == 2 && $session->user_logged_in && $session->reg_time + 60*60*24*4 < time() ) || $paths->pages[$pname]['protected'] == 1) ? true : false;
  1195     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
  1195     $wiki = ( ( $paths->pages[$pname]['wiki_mode'] == 2 && getConfig('wiki_mode') == '1') || $paths->pages[$pname]['wiki_mode'] == 1) ? true : false;
  1196     
  1196     
  1197     if( empty($name)) die('Name is too short');
  1197     if( empty($name)) 
  1198     if( ( $session->get_permissions('rename') && ( ( $prot && $session->get_permissions('even_when_protected') ) || !$prot ) ) && ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' )) {
  1198     {
  1199       $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author,edit_summary) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'rename\', \''.$paths->cpage['urlname_nons'].'\', \''.$paths->namespace.'\', \''.$session->username.'\', \''.$paths->cpage['name'].'\')');
  1199       die('Name is too short');
  1200       if(!$e) $db->_die('The page title could not be updated.');
  1200     }
  1201       $e = $db->sql_query('UPDATE '.table_prefix.'pages SET name=\''.$db->escape($name).'\' WHERE urlname=\''.$page_id.'\' AND namespace=\''.$namespace.'\';');
  1201     if( ( $session->get_permissions('rename') && ( ( $prot && $session->get_permissions('even_when_protected') ) || !$prot ) ) && ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ))
  1202       if(!$e) $db->_die('The page title could not be updated.');
  1202     {
  1203       else return('The page "'.$paths->pages[$pname]['name'].'" has been renamed to "'.$name.'". You are encouraged to leave a comment explaining your action.
  1203       $e = $db->sql_query('INSERT INTO '.table_prefix.'logs(time_id,date_string,log_type,action,page_id,namespace,author,edit_summary) VALUES('.time().', \''.date('d M Y h:i a').'\', \'page\', \'rename\', \''.$db->escape($paths->cpage['urlname_nons']).'\', \''.$paths->namespace.'\', \''.$db->escape($session->username).'\', \''.$db->escape($paths->cpage['name']).'\')');
  1204 
  1204       if ( !$e )
  1205 You will see the change take effect the next time you reload this page.');
  1205       {
  1206     } else {
  1206         $db->_die('The page title could not be updated.');
       
  1207       }
       
  1208       $e = $db->sql_query('UPDATE '.table_prefix.'pages SET name=\''.$db->escape($name).'\' WHERE urlname=\''.$db->escape($page_id).'\' AND namespace=\''.$db->escape($namespace).'\';');
       
  1209       if ( !$e )
       
  1210       {
       
  1211         $db->_die('The page title could not be updated.');
       
  1212       }
       
  1213       else
       
  1214       {
       
  1215         return('The page "'.$paths->pages[$pname]['name'].'" has been renamed to "'.$name.'". You are encouraged to leave a comment explaining your action.' . "\n\n" . 'You will see the change take effect the next time you reload this page.');
       
  1216       }
       
  1217     }
       
  1218     else
       
  1219     {
  1207       return('Access is denied.');
  1220       return('Access is denied.');
  1208     }
  1221     }
  1209   }
  1222   }
  1210   
  1223   
  1211   /**
  1224   /**