includes/pageprocess.php
changeset 1081 745200a9cc2a
parent 1068 4bcefa85649c
child 1175 1e2c9819ede3
equal deleted inserted replaced
1080:6358f769ecb1 1081:745200a9cc2a
     1 <?php
     1 <?php
     2 
     2 
     3 /*
     3 /*
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     4  * Enano - an open-source CMS capable of wiki functions, Drupal-like sidebar blocks, and everything in between
     5  * Version 1.1.6 (Caoineag beta 1)
       
     6  * pageprocess.php - intelligent retrieval of pages
     5  * pageprocess.php - intelligent retrieval of pages
     7  * Copyright (C) 2006-2008 Dan Fuhry
     6  * Copyright (C) 2006-2009 Dan Fuhry
     8  *
     7  *
     9  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
     8  * This program is Free Software; you can redistribute and/or modify it under the terms of the GNU General Public License
    10  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
     9  * as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
    11  *
    10  *
    12  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
    11  * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied
   455     $text = $db->escape($text_undb);
   454     $text = $db->escape($text_undb);
   456     $author = $db->escape($session->username);
   455     $author = $db->escape($session->username);
   457     $time = time();
   456     $time = time();
   458     $edit_summary = ( strval($edit_summary) === $edit_summary ) ? $db->escape($edit_summary) : '';
   457     $edit_summary = ( strval($edit_summary) === $edit_summary ) ? $db->escape($edit_summary) : '';
   459     $minor_edit = ( $minor_edit ) ? '1' : '0';
   458     $minor_edit = ( $minor_edit ) ? '1' : '0';
   460     $date_string = enano_date('d M Y h:i a');
   459     $date_string = enano_date(ED_DATE | ED_TIME);
   461     
   460     
   462     // Insert log entry
   461     // Insert log entry
   463     $sql = 'INSERT INTO ' . table_prefix . "logs ( time_id, date_string, log_type, action, page_id, namespace, author, page_text, edit_summary, minor_edit, page_format )\n"
   462     $sql = 'INSERT INTO ' . table_prefix . "logs ( time_id, date_string, log_type, action, page_id, namespace, author, page_text, edit_summary, minor_edit, page_format )\n"
   464          . "  VALUES ( $time, '$date_string', 'page', 'edit', '{$this->page_id}', '{$this->namespace}', '$author', '$text', '$edit_summary', $minor_edit, '$page_format' );";
   463          . "  VALUES ( $time, '$date_string', 'page', 'edit', '{$this->page_id}', '{$this->namespace}', '$author', '$text', '$edit_summary', $minor_edit, '$page_format' );";
   465     if ( !$db->sql_query($sql) )
   464     if ( !$db->sql_query($sql) )
   588     if ( !$q )
   587     if ( !$q )
   589       $db->_die('PageProcessor page creation - text stage');
   588       $db->_die('PageProcessor page creation - text stage');
   590     
   589     
   591     // Query 3: Log entry
   590     // Query 3: Log entry
   592     $db->sql_query('INSERT INTO ' . table_prefix."logs(time_id, date_string, log_type, action, author, page_id, namespace)\n"
   591     $db->sql_query('INSERT INTO ' . table_prefix."logs(time_id, date_string, log_type, action, author, page_id, namespace)\n"
   593                    . "  VALUES ( " . time() . ", '" . enano_date('d M Y h:i a') . "', 'page', 'create', \n"
   592                    . "  VALUES ( " . time() . ", 'DEPRECATED', 'page', 'create', \n"
   594                    . "          '" . $db->escape($session->username) . "', '" . $db->escape($this->page_id) . "', '" . $this->namespace . "');");
   593                    . "          '" . $db->escape($session->username) . "', '" . $db->escape($this->page_id) . "', '" . $this->namespace . "');");
   595     if ( !$q )
   594     if ( !$q )
   596       $db->_die('PageProcessor page creation - logging stage');
   595       $db->_die('PageProcessor page creation - logging stage');
   597     
   596     
   598     // Update the cache
   597     // Update the cache
   651     
   650     
   652     // All good, fetch and free the result
   651     // All good, fetch and free the result
   653     $log_entry = $db->fetchrow();
   652     $log_entry = $db->fetchrow();
   654     $db->free_result();
   653     $db->free_result();
   655     
   654     
   656     $dateline = enano_date('d M Y h:i a', $log_entry['time_id']);
   655     $dateline = enano_date(ED_DATE | ED_TIME, $log_entry['time_id']);
   657     
   656     
   658     // Let's see, what do we have here...
   657     // Let's see, what do we have here...
   659     switch ( $log_entry['action'] )
   658     switch ( $log_entry['action'] )
   660     {
   659     {
   661       case 'rename':
   660       case 'rename':
  1131     global $db, $session, $paths, $template, $plugins; // Common objects
  1130     global $db, $session, $paths, $template, $plugins; // Common objects
  1132     global $lang;
  1131     global $lang;
  1133     global $email;
  1132     global $email;
  1134     
  1133     
  1135     // Log it for crying out loud
  1134     // Log it for crying out loud
  1136     $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'illegal_page\', '.time().', \''.enano_date('d M Y h:i a').'\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(serialize(array($this->page_id, $this->namespace))) . '\')');
  1135     $q = $db->sql_query('INSERT INTO '.table_prefix.'logs(log_type,action,time_id,date_string,author,edit_summary,page_text) VALUES(\'security\', \'illegal_page\', '.time().', \'DEPRECATED\', \''.$db->escape($session->username).'\', \''.$db->escape($_SERVER['REMOTE_ADDR']).'\', \'' . $db->escape(serialize(array($this->page_id, $this->namespace))) . '\')');
  1137     
  1136     
  1138     $ob = '';
  1137     $ob = '';
  1139     //$template->tpl_strings['PAGE_NAME'] = 'Access denied';
  1138     //$template->tpl_strings['PAGE_NAME'] = 'Access denied';
  1140     $template->tpl_strings['PAGE_NAME'] = htmlspecialchars( $this->title );
  1139     $template->tpl_strings['PAGE_NAME'] = htmlspecialchars( $this->title );
  1141       
  1140