includes/pageutils.php
changeset 326 ab66d6d1f1f4
parent 304 e2cb5f1432c8
parent 322 5f1cd51bf1be
child 328 dc838fd61a06
equal deleted inserted replaced
314:474f8be55943 326:ab66d6d1f1f4
   201                <p>You have requested a page that doesn\'t exist yet.';
   201                <p>You have requested a page that doesn\'t exist yet.';
   202         if($session->get_permissions('create_page')) echo ' You can <a href="'.makeUrl($paths->page, 'do=edit', true).'" onclick="ajaxEditor(); return false;">create this page</a>, or return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.';
   202         if($session->get_permissions('create_page')) echo ' You can <a href="'.makeUrl($paths->page, 'do=edit', true).'" onclick="ajaxEditor(); return false;">create this page</a>, or return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.';
   203         else echo ' Return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.</p>';
   203         else echo ' Return to the <a href="'.makeUrl(getConfig('main_page')).'">homepage</a>.</p>';
   204         if ( $session->get_permissions('history_rollback') )
   204         if ( $session->get_permissions('history_rollback') )
   205         {
   205         {
   206           $e = $db->sql_query('SELECT * FROM ' . table_prefix.'logs WHERE action=\'delete\' AND page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $pid[1] . '\' ORDER BY time_id DESC;');
   206           $e = $db->sql_query('SELECT * FROM ' . table_prefix.'logs WHERE action=\'delete\' AND page_id=\'' . $paths->page_id . '\' AND namespace=\'' . $pid[1] . '\' ORDER BY time_id DESC;');
   207           if ( !$e )
   207           if ( !$e )
   208           {
   208           {
   209             $db->_die('The deletion log could not be selected.');
   209             $db->_die('The deletion log could not be selected.');
   210           }
   210           }
   211           if ($db->numrows() > 0 )
   211           if ($db->numrows() > 0 )
   377     // Strip potentially harmful tags and PHP from the message, dependent upon permissions settings
   377     // Strip potentially harmful tags and PHP from the message, dependent upon permissions settings
   378     $message = RenderMan::preprocess_text($message, false, false);
   378     $message = RenderMan::preprocess_text($message, false, false);
   379     
   379     
   380     $msg = $db->escape($message);
   380     $msg = $db->escape($message);
   381     
   381     
   382     $minor = $minor ? 'true' : 'false';
   382     $minor = $minor ? ENANO_SQL_BOOLEAN_TRUE : ENANO_SQL_BOOLEAN_FALSE;
   383     $q='INSERT INTO ' . table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $paths->cpage['urlname_nons'] . '\', \'' . $paths->namespace . '\', \'' . $msg . '\', \'' . $uid . '\', \'' . $session->username . '\', \'' . $db->escape(htmlspecialchars($summary)) . '\', ' . $minor . ');';
   383     $q='INSERT INTO ' . table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $paths->page_id . '\', \'' . $paths->namespace . '\', ' . ENANO_SQL_MULTISTRING_PRFIX . '\'' . $msg . '\', \'' . $uid . '\', \'' . $session->username . '\', \'' . $db->escape(htmlspecialchars($summary)) . '\', ' . $minor . ');';
   384     if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.');
   384     if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.');
   385     
   385     
   386     $q = 'UPDATE ' . table_prefix.'page_text SET page_text=\'' . $msg . '\',char_tag=\'' . $uid . '\' WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';';
   386     $q = 'UPDATE ' . table_prefix.'page_text SET page_text=' . ENANO_SQL_MULTISTRING_PRFIX . '\'' . $msg . '\',char_tag=\'' . $uid . '\' WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';';
   387     $e = $db->sql_query($q);
   387     $e = $db->sql_query($q);
   388     if(!$e) $db->_die('Enano was unable to save the page contents. Your changes have been lost <tt>:\'(</tt>.');
   388     if(!$e) $db->_die('Enano was unable to save the page contents. Your changes have been lost <tt>:\'(</tt>.');
   389       
   389       
   390     $paths->rebuild_page_index($page_id, $namespace);
   390     $paths->rebuild_page_index($page_id, $namespace);
   391       
   391       
   442     $page_id = dirtify_page_id($page_id);
   442     $page_id = dirtify_page_id($page_id);
   443     
   443     
   444     if ( !$name )
   444     if ( !$name )
   445       $name = str_replace('_', ' ', $page_id);
   445       $name = str_replace('_', ' ', $page_id);
   446     $regex = '#^([A-z0-9 _\-\.\/\!\@\(\)]*)$#is';
   446     $regex = '#^([A-z0-9 _\-\.\/\!\@\(\)]*)$#is';
   447     if(!preg_match($regex, $page))
   447     if(!preg_match($regex, $name))
   448     {
   448     {
   449       //echo '<b>Notice:</b> PageUtils::createPage: Name contains invalid characters<br />';
   449       //echo '<b>Notice:</b> PageUtils::createPage: Name contains invalid characters<br />';
   450       return 'Name contains invalid characters';
   450       return 'Name contains invalid characters';
   451     }
   451     }
   452     
   452     
   662             </form>
   662             </form>
   663             <script type="text/javascript">if ( !KILL_SWITCH ) { buildDiffList(); }</script>';
   663             <script type="text/javascript">if ( !KILL_SWITCH ) { buildDiffList(); }</script>';
   664     }
   664     }
   665     $db->free_result();
   665     $db->free_result();
   666     echo '<h3>' . $lang->get('history_heading_other') . '</h3>';
   666     echo '<h3>' . $lang->get('history_heading_other') . '</h3>';
   667     $q = 'SELECT time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action!=\'edit\' AND page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $paths->namespace . '\' ORDER BY time_id DESC;';
   667     $q = 'SELECT time_id,action,date_string,page_id,namespace,author,edit_summary,minor_edit FROM ' . table_prefix.'logs WHERE log_type=\'page\' AND action!=\'edit\' AND page_id=\'' . $paths->page_id . '\' AND namespace=\'' . $paths->namespace . '\' ORDER BY time_id DESC;';
   668     if ( !$db->sql_query($q) )
   668     if ( !$db->sql_query($q) )
   669     {
   669     {
   670       $db->_die('The history data for the page "' . htmlspecialchars($paths->cpage['name']) . '" could not be selected.');
   670       $db->_die('The history data for the page "' . htmlspecialchars($paths->cpage['name']) . '" could not be selected.');
   671     }
   671     }
   672     if ( $db->numrows() < 1 )
   672     if ( $db->numrows() < 1 )
  1401     {
  1401     {
  1402       return($lang->get('ajax_rename_too_short'));
  1402       return($lang->get('ajax_rename_too_short'));
  1403     }
  1403     }
  1404     if( ( $session->get_permissions('rename') && ( ( $prot && $session->get_permissions('even_when_protected') ) || !$prot ) ) && ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ))
  1404     if( ( $session->get_permissions('rename') && ( ( $prot && $session->get_permissions('even_when_protected') ) || !$prot ) ) && ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' ))
  1405     {
  1405     {
  1406       $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']) . '\')');
  1406       $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->page_id) . '\', \'' . $paths->namespace . '\', \'' . $db->escape($session->username) . '\', \'' . $db->escape($paths->cpage['name']) . '\')');
  1407       if ( !$e )
  1407       if ( !$e )
  1408       {
  1408       {
  1409         $db->_die('The page title could not be updated.');
  1409         $db->_die('The page title could not be updated.');
  1410       }
  1410       }
  1411       $e = $db->sql_query('UPDATE ' . table_prefix.'pages SET name=\'' . $db->escape($name) . '\' WHERE urlname=\'' . $db->escape($page_id) . '\' AND namespace=\'' . $db->escape($namespace) . '\';');
  1411       $e = $db->sql_query('UPDATE ' . table_prefix.'pages SET name=\'' . $db->escape($name) . '\' WHERE urlname=\'' . $db->escape($page_id) . '\' AND namespace=\'' . $db->escape($namespace) . '\';');
  1457     {
  1457     {
  1458       $e = $db->sql_query('SELECT page_text,char_tag FROM ' . table_prefix.'page_text WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';');
  1458       $e = $db->sql_query('SELECT page_text,char_tag FROM ' . table_prefix.'page_text WHERE page_id=\'' . $page_id . '\' AND namespace=\'' . $namespace . '\';');
  1459       if(!$e) $db->_die('The current page text could not be selected; as a result, creating the backup of the page failed. Please make a backup copy of the page by clicking Edit this page and then clicking Save Changes.');
  1459       if(!$e) $db->_die('The current page text could not be selected; as a result, creating the backup of the page failed. Please make a backup copy of the page by clicking Edit this page and then clicking Save Changes.');
  1460       $row = $db->fetchrow();
  1460       $row = $db->fetchrow();
  1461       $db->free_result();
  1461       $db->free_result();
  1462       $q='INSERT INTO ' . table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $page_id . '\', \'' . $namespace . '\', \'' . $db->escape($row['page_text']) . '\', \'' . $row['char_tag'] . '\', \'' . $session->username . '\', \''."Automatic backup created when logs were purged".'\', '.'false'.');';
  1462       $minor_edit = ( ENANO_DBLAYER == 'MYSQL' ) ? 'false' : '0';
       
  1463       $q='INSERT INTO ' . table_prefix.'logs(log_type,action,time_id,date_string,page_id,namespace,page_text,char_tag,author,edit_summary,minor_edit) VALUES(\'page\', \'edit\', '.time().', \''.date('d M Y h:i a').'\', \'' . $page_id . '\', \'' . $namespace . '\', \'' . $db->escape($row['page_text']) . '\', \'' . $row['char_tag'] . '\', \'' . $session->username . '\', \''."Automatic backup created when logs were purged".'\', '.$minor_edit.');';
  1463       if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.');
  1464       if(!$db->sql_query($q)) $db->_die('The history (log) entry could not be inserted into the logs table.');
  1464     }
  1465     }
  1465     return $lang->get('ajax_clearlogs_success');
  1466     return $lang->get('ajax_clearlogs_success');
  1466   }
  1467   }
  1467   
  1468   
  1650     global $db, $session, $paths, $template, $plugins; // Common objects
  1651     global $db, $session, $paths, $template, $plugins; // Common objects
  1651     global $lang;
  1652     global $lang;
  1652     
  1653     
  1653     ob_start();
  1654     ob_start();
  1654     $_ob = '';
  1655     $_ob = '';
  1655     $e = $db->sql_query('SELECT category_id FROM ' . table_prefix.'categories WHERE page_id=\'' . $paths->cpage['urlname_nons'] . '\' AND namespace=\'' . $paths->namespace . '\'');
  1656     $e = $db->sql_query('SELECT category_id FROM ' . table_prefix.'categories WHERE page_id=\'' . $paths->page_id . '\' AND namespace=\'' . $paths->namespace . '\'');
  1656     if(!$e) jsdie('Error selecting category information for current page: '.mysql_error());
  1657     if(!$e) jsdie('Error selecting category information for current page: '.mysql_error());
  1657     $cat_current = Array();
  1658     $cat_current = Array();
  1658     while($r = $db->fetchrow())
  1659     while($r = $db->fetchrow())
  1659     {
  1660     {
  1660       $cat_current[] = $r;
  1661       $cat_current[] = $r;
  2244               <p><label><input name="data[scope]" value="only_this" type="radio" checked="checked" /> ' . $lang->get('acl_radio_scope_thispage') . '</p>
  2245               <p><label><input name="data[scope]" value="only_this" type="radio" checked="checked" /> ' . $lang->get('acl_radio_scope_thispage') . '</p>
  2245               ' . $groupsel . '
  2246               ' . $groupsel . '
  2246               <p><label><input name="data[scope]" value="entire_site" type="radio" /> ' . $lang->get('acl_radio_scope_wholesite') . '</p>
  2247               <p><label><input name="data[scope]" value="entire_site" type="radio" /> ' . $lang->get('acl_radio_scope_wholesite') . '</p>
  2247               <div style="margin: 0 auto 0 0; text-align: right;">
  2248               <div style="margin: 0 auto 0 0; text-align: right;">
  2248                 <input name="data[mode]" value="seltarget" type="hidden" />
  2249                 <input name="data[mode]" value="seltarget" type="hidden" />
  2249                 <input type="hidden" name="data[page_id]" value="' . $paths->cpage['urlname_nons'] . '" />
  2250                 <input type="hidden" name="data[page_id]" value="' . $paths->page_id . '" />
  2250                 <input type="hidden" name="data[namespace]" value="' . $paths->namespace . '" />
  2251                 <input type="hidden" name="data[namespace]" value="' . $paths->namespace . '" />
  2251                 <input type="submit" value="' . htmlspecialchars($lang->get('etc_wizard_next')) . '" />
  2252                 <input type="submit" value="' . htmlspecialchars($lang->get('etc_wizard_next')) . '" />
  2252               </div>';
  2253               </div>';
  2253         echo $formend;
  2254         echo $formend;
  2254         break;
  2255         break;