includes/functions.php
changeset 800 9cdfe82c56cd
parent 798 ddfc1b554a08
child 801 eb8b23f11744
equal deleted inserted replaced
799:4629ad98ee88 800:9cdfe82c56cd
   275   }
   275   }
   276   else if ( $force_logged_in )
   276   else if ( $force_logged_in )
   277   {
   277   {
   278     $logged_in = true;
   278     $logged_in = true;
   279   }
   279   }
   280   return $logged_in ? getConfig('main_page_alt', getConfig('main_page')) : getConfig('main_page');
   280   return $logged_in && getConfig('main_page_alt_enable', '0') == '1' ? getConfig('main_page_alt', getConfig('main_page')) : getConfig('main_page');
   281 }
   281 }
   282 
   282 
   283 /**
   283 /**
   284  * Enano replacement for date(). Accounts for individual users' timezone preferences.
   284  * Enano replacement for date(). Accounts for individual users' timezone preferences.
   285  * @param string Date-formatted string
   285  * @param string Date-formatted string
   521  */
   521  */
   522 
   522 
   523 function csrf_request_confirm()
   523 function csrf_request_confirm()
   524 {
   524 {
   525   global $db, $session, $paths, $template, $plugins; // Common objects
   525   global $db, $session, $paths, $template, $plugins; // Common objects
   526   global $lang;
   526   global $lang, $output;
   527   
   527   
   528   // If the token was overridden with the correct one, the user confirmed the action using this form. Continue exec.
   528   // If the token was overridden with the correct one, the user confirmed the action using this form. Continue exec.
   529   if ( isset($_POST['cstok']) || isset($_GET ['cstok']) )
   529   if ( isset($_POST['cstok']) || isset($_GET['cstok']) )
   530   {
   530   {
   531     // using the if() check makes sure that the token isn't in a cookie, since $_REQUEST includes $_COOKIE.
   531     // using the if() check makes sure that the token isn't in a cookie, since $_REQUEST includes $_COOKIE.
   532     $token_check =& $_REQUEST['cstok'];
   532     $token_check =& $_REQUEST['cstok'];
   533     if ( $token_check === $session->csrf_token )
   533     if ( $token_check === $session->csrf_token )
   534     {
   534     {
   535       // overridden token matches, continue exec
   535       // overridden token matches, continue exec
   536       return true;
   536       return true;
   537     }
   537     }
   538   }
   538   }
   539   
   539   
   540   $template->tpl_strings['PAGE_NAME'] = htmlspecialchars($lang->get('user_csrf_confirm_title'));
   540   $output->set_title($lang->get('user_csrf_confirm_title'));
   541   $template->header();
   541   $output->header();
   542   
   542   
   543   // initial info
   543   // initial info
   544   echo '<p>' . $lang->get('user_csrf_confirm_body') . '</p>';
   544   echo '<p>' . $lang->get('user_csrf_confirm_body') . '</p>';
   545   
   545   
   546   // start form
   546   // start form
   562   }
   562   }
   563   echo '</div></fieldset>';
   563   echo '</div></fieldset>';
   564   // insert the right CSRF token
   564   // insert the right CSRF token
   565   echo '<input type="hidden" name="cstok" value="' . $session->csrf_token . '" />';
   565   echo '<input type="hidden" name="cstok" value="' . $session->csrf_token . '" />';
   566   echo '<p><input type="submit" value="' . $lang->get('user_csrf_confirm_btn_continue') . '" /></p>';
   566   echo '<p><input type="submit" value="' . $lang->get('user_csrf_confirm_btn_continue') . '" /></p>';
   567   echo '</form>';
   567   echo '</form><script type="text/javascript">addOnloadHook(function(){load_component(\'expander\');});</script>';
   568   
   568   
   569   $template->footer();
   569   $output->footer();
   570   
   570   
   571   exit;
   571   exit;
   572 }
   572 }
   573 
   573 
   574 function csrf_confirm_get_recursive($_inner = false, $pfx = false, $data = false)
   574 function csrf_confirm_get_recursive($_inner = false, $pfx = false, $data = false)
   632     return true;
   632     return true;
   633   }
   633   }
   634   else
   634   else
   635   {
   635   {
   636     return false;
   636     return false;
       
   637   }
       
   638 }
       
   639 
       
   640 /**
       
   641  * Returns the appropriate Namespace_* object for a page.
       
   642  * @param string Page ID
       
   643  * @param string Namespace
       
   644  * @param int Revision ID
       
   645  */
       
   646 
       
   647 function namespace_factory($page_id, $namespace, $revision_id = 0)
       
   648 {
       
   649   if ( !class_exists("Namespace_$namespace") )
       
   650   {
       
   651     if ( file_exists(ENANO_ROOT . "/includes/namespaces/" . strtolower($namespace) . ".php") )
       
   652     {
       
   653       require(ENANO_ROOT . "/includes/namespaces/" . strtolower($namespace) . ".php");
       
   654     }
       
   655   }
       
   656   if ( class_exists("Namespace_$namespace") )
       
   657   {
       
   658     $class = "Namespace_$namespace";
       
   659     $ns = new $class($page_id, $namespace, $revision_id);
       
   660     return $ns;
       
   661   }
       
   662   else
       
   663   {
       
   664     $ns = new Namespace_Default($page_id, $namespace, $revision_id);
       
   665     return $ns;
   637   }
   666   }
   638 }
   667 }
   639 
   668 
   640 /**
   669 /**
   641  * These are some old functions that were used with the Midget codebase. They are deprecated and should not be used any more.
   670  * These are some old functions that were used with the Midget codebase. They are deprecated and should not be used any more.
   681   }
   710   }
   682   return $arr;
   711   return $arr;
   683 }
   712 }
   684 
   713 
   685 function arrayItemBottom($arr, $keyname) {
   714 function arrayItemBottom($arr, $keyname) {
   686   $keylist = array_keys($arr);
   715   $b = $arr[$keyname];
   687   $keyflop = array_flip($keylist);
   716   unset($arr[$keyname]);
   688   $idx = $keyflop[$keyname];
   717   $arr[$keyname] = $b;
   689   $sz = sizeof($arr); $sz--;
   718   unset($b);
   690   while( $orig != $arr[$keylist[$sz]] ) {
       
   691     // echo 'Keyname: '.$keylist[$idx] . '<br />'; flush(); ob_flush(); // Debugger
       
   692     if($idx > $sz) return $arr;
       
   693     if($keylist[$idx] == '' || $keylist[$idx] < 0 || !$keylist[$idx]) {
       
   694       echo 'Infinite loop caught in arrayItemBottom(<br /><pre>';
       
   695       print_r($arr);
       
   696       echo '</pre><br />, '.$keyname.');<br /><br />EnanoCMS: Critical error during function call, exiting to prevent excessive server load.';
       
   697       exit;
       
   698     }
       
   699     $arr = arrayItemDown($arr, $keylist[$idx]);
       
   700     $idx++;
       
   701   }
       
   702   return $arr;
   719   return $arr;
   703 }
   720 }
   704 
   721 
   705 /**
   722 /**
   706  * Implementation of array_merge() that preserves key names. $arr2 takes precedence over $arr1.
   723  * Implementation of array_merge() that preserves key names. $arr2 takes precedence over $arr1.
   820     echo '<h2>' . htmlspecialchars($t) . '</h2>';
   837     echo '<h2>' . htmlspecialchars($t) . '</h2>';
   821     echo "<p>$p</p>";
   838     echo "<p>$p</p>";
   822     exit;
   839     exit;
   823   }
   840   }
   824   
   841   
   825   $theme = ( defined('ENANO_CONFIG_FETCHED') ) ? getConfig('theme_default') : 'oxygen';
   842   $output = new Output_Safe();
   826   $style = ( defined('ENANO_CONFIG_FETCHED') ) ? '__foo__' : 'bleu';
   843   $output->set_title($t);
   827   
   844   $output->header();
   828   $tpl = new template_nodb();
       
   829   $tpl->load_theme($theme, $style);
       
   830   $tpl->tpl_strings['SITE_NAME'] = getConfig('site_name');
       
   831   $tpl->tpl_strings['SITE_DESC'] = getConfig('site_desc');
       
   832   $tpl->tpl_strings['COPYRIGHT'] = getConfig('copyright_notice');
       
   833   $tpl->tpl_strings['PAGE_NAME'] = $t;
       
   834   $tpl->header();
       
   835   echo $p;
   845   echo $p;
   836   $tpl->footer();
   846   $output->footer();
   837 
   847 
   838   exit;
   848   exit;
   839 }
   849 }
   840 
   850 
   841 /**
   851 /**
   916  * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths.
   926  * Prints out the categorization box found on most regular pages. Doesn't take or return anything, but assumes that the page information is already set in $paths.
   917  */
   927  */
   918 
   928 
   919 function show_category_info()
   929 function show_category_info()
   920 {
   930 {
   921   global $db, $session, $paths, $template, $plugins; // Common objects
   931   throw new Exception('show_category_info() is deprecated. Use Namespace_*::display_categories().');
   922   global $lang;
       
   923   
       
   924   if ( $paths->namespace == 'Category' )
       
   925   {
       
   926     // Show member pages and subcategories
       
   927     $q = $db->sql_query('SELECT p.urlname, p.namespace, p.name, p.namespace=\'Category\' AS is_category FROM '.table_prefix.'categories AS c
       
   928                            LEFT JOIN '.table_prefix.'pages AS p
       
   929                              ON ( p.urlname = c.page_id AND p.namespace = c.namespace )
       
   930                            WHERE c.category_id=\'' . $db->escape($paths->page_id) . '\'
       
   931                            ORDER BY is_category DESC, p.name ASC;');
       
   932     if ( !$q )
       
   933     {
       
   934       $db->_die();
       
   935     }
       
   936     echo '<h3>' . $lang->get('onpage_cat_heading_subcategories') . '</h3>';
       
   937     echo '<div class="tblholder">';
       
   938     echo '<table border="0" cellspacing="1" cellpadding="4">';
       
   939     echo '<tr>';
       
   940     $ticker = 0;
       
   941     $counter = 0;
       
   942     $switched = false;
       
   943     $class  = 'row1';
       
   944     while ( $row = $db->fetchrow() )
       
   945     {
       
   946       if ( $row['is_category'] == 0 && !$switched )
       
   947       {
       
   948         if ( $counter > 0 )
       
   949         {
       
   950           // Fill-in
       
   951           while ( $ticker < 3 )
       
   952           {
       
   953             $ticker++;
       
   954             echo '<td class="' . $class . '" style="width: 33.3%;"></td>';
       
   955           }
       
   956         }
       
   957         else
       
   958         {
       
   959           echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>';
       
   960         }
       
   961         echo '</tr></table></div>' . "\n\n";
       
   962         echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>';
       
   963         echo '<div class="tblholder">';
       
   964         echo '<table border="0" cellspacing="1" cellpadding="4">';
       
   965         echo '<tr>';
       
   966         $counter = 0;
       
   967         $ticker = -1;
       
   968         $switched = true;
       
   969       }
       
   970       $counter++;
       
   971       $ticker++;
       
   972       if ( $ticker == 3 )
       
   973       {
       
   974         echo '</tr><tr>';
       
   975         $ticker = 0;
       
   976         $class = ( $class == 'row3' ) ? 'row1' : 'row3';
       
   977       }
       
   978       echo "<td class=\"{$class}\" style=\"width: 33.3%;\">"; // " to workaround stupid jEdit bug
       
   979       
       
   980       $link = makeUrlNS($row['namespace'], sanitize_page_id($row['urlname']));
       
   981       echo '<a href="' . $link . '"';
       
   982       $key = $paths->nslist[$row['namespace']] . sanitize_page_id($row['urlname']);
       
   983       if ( !isPage( $key ) )
       
   984       {
       
   985         echo ' class="wikilink-nonexistent"';
       
   986       }
       
   987       echo '>';
       
   988       $title = get_page_title_ns($row['urlname'], $row['namespace']);
       
   989       echo htmlspecialchars($title);
       
   990       echo '</a>';
       
   991       
       
   992       echo "</td>";
       
   993     }
       
   994     if ( !$switched )
       
   995     {
       
   996       if ( $counter > 0 )
       
   997       {
       
   998         // Fill-in
       
   999         while ( $ticker < 2 )
       
  1000         {
       
  1001           $ticker++;
       
  1002           echo '<td class="' . $class . '" style="width: 33.3%;"></td>';
       
  1003         }
       
  1004       }
       
  1005       else
       
  1006       {
       
  1007         echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_subcategories') . '</td>';
       
  1008       }
       
  1009       echo '</tr></table></div>' . "\n\n";
       
  1010       echo '<h3>' . $lang->get('onpage_cat_heading_pages') . '</h3>';
       
  1011       echo '<div class="tblholder">';
       
  1012       echo '<table border="0" cellspacing="1" cellpadding="4">';
       
  1013       echo '<tr>';
       
  1014       $counter = 0;
       
  1015       $ticker = 0;
       
  1016       $switched = true;
       
  1017     }
       
  1018     if ( $counter > 0 )
       
  1019     {
       
  1020       // Fill-in
       
  1021       while ( $ticker < 2 )
       
  1022       {
       
  1023         $ticker++;
       
  1024         echo '<td class="' . $class . '" style="width: 33.3%;"></td>';
       
  1025       }
       
  1026     }
       
  1027     else
       
  1028     {
       
  1029       echo '<td class="' . $class . '">' . $lang->get('onpage_cat_msg_no_pages') . '</td>';
       
  1030     }
       
  1031     echo '</tr></table></div>' . "\n\n";
       
  1032   }
       
  1033   
       
  1034   if ( $paths->namespace != 'Special' && $paths->namespace != 'Admin' )
       
  1035   {
       
  1036     echo '<div class="mdg-comment" style="margin: 10px 0 0 0;" id="category_box_wrapper">';
       
  1037     echo '<div style="float: right;">';
       
  1038     echo '(<a href="#" onclick="ajaxCatToTag(); return false;">' . $lang->get('tags_catbox_link') . '</a>)';
       
  1039     echo '</div>';
       
  1040     echo '<div id="mdgCatBox">' . $lang->get('catedit_catbox_lbl_categories') . ' ';
       
  1041     
       
  1042     $where = '( c.page_id=\'' . $db->escape($paths->page_id) . '\' AND c.namespace=\'' . $db->escape($paths->namespace) . '\' )';
       
  1043     $prefix = table_prefix;
       
  1044     $sql = <<<EOF
       
  1045 SELECT c.category_id FROM {$prefix}categories AS c
       
  1046   LEFT JOIN {$prefix}pages AS p
       
  1047     ON ( ( p.urlname = c.page_id AND p.namespace = c.namespace ) OR ( p.urlname IS NULL AND p.namespace IS NULL ) )
       
  1048   WHERE $where
       
  1049   ORDER BY p.name ASC, c.page_id ASC;
       
  1050 EOF;
       
  1051     $q = $db->sql_query($sql);
       
  1052     if ( !$q )
       
  1053       $db->_die();
       
  1054     
       
  1055     if ( $row = $db->fetchrow() )
       
  1056     {
       
  1057       $list = array();
       
  1058       do
       
  1059       {
       
  1060         $cid = sanitize_page_id($row['category_id']);
       
  1061         $title = get_page_title_ns($cid, 'Category');
       
  1062         $link = makeUrlNS('Category', $cid);
       
  1063         $list[] = '<a href="' . $link . '">' . htmlspecialchars($title) . '</a>';
       
  1064       }
       
  1065       while ( $row = $db->fetchrow() );
       
  1066       echo implode(', ', $list);
       
  1067     }
       
  1068     else
       
  1069     {
       
  1070       echo $lang->get('catedit_catbox_lbl_uncategorized');
       
  1071     }
       
  1072     
       
  1073     $can_edit = ( $session->get_permissions('edit_cat') && ( !$paths->page_protected || $session->get_permissions('even_when_protected') ) );
       
  1074     if ( $can_edit )
       
  1075     {
       
  1076       $edit_link = '<a href="' . makeUrl($paths->page, 'do=catedit', true) . '" onclick="ajaxCatEdit(); return false;">' . $lang->get('catedit_catbox_link_edit') . '</a>';
       
  1077       echo ' [ ' . $edit_link . ' ]';
       
  1078     }
       
  1079     
       
  1080     echo '</div></div>';
       
  1081     
       
  1082   }
       
  1083   
       
  1084 }
   932 }
  1085 
   933 
  1086 /**
   934 /**
  1087  * Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File.
   935  * Prints out the file information box seen on File: pages. Doesn't take or return anything, but assumes that the page information is already set in $paths, and expects $paths->namespace to be File.
  1088  */
   936  */
  1089 
   937 
  1090 function show_file_info($page = false)
   938 function show_file_info($page = false)
  1091 {
   939 {
  1092   global $db, $session, $paths, $template, $plugins; // Common objects
   940   throw new Exception('show_file_info() is deprecated. Use Namespace_File::show_info().');
  1093   global $lang;
       
  1094   
       
  1095   $local_page_id = $paths->page_id;
       
  1096   $local_namespace = $paths->namespace;
       
  1097   
       
  1098   if ( is_object($page) )
       
  1099   {
       
  1100     $local_page = $page->page_id;
       
  1101     $local_namespace = $page->namespace;
       
  1102   }
       
  1103   
       
  1104   // Prevent unnecessary work
       
  1105   if ( $local_namespace != 'File' )
       
  1106     return null;
       
  1107   
       
  1108   $selfn = $local_page_id;
       
  1109   if ( substr($paths->cpage['name'], 0, strlen($paths->nslist['File'])) == $paths->nslist['File'])
       
  1110   {
       
  1111     $selfn = substr($local_page_id, strlen($paths->nslist['File']), strlen($local_page_id));
       
  1112   }
       
  1113   $selfn = $db->escape($selfn);
       
  1114   $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n"
       
  1115                     . "  LEFT JOIN " . table_prefix . "logs AS l\n"
       
  1116                     . "    ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n"
       
  1117                     . "  WHERE f.page_id = '$selfn'\n"
       
  1118                     . "    ORDER BY f.time_id DESC;");
       
  1119   if ( !$q )
       
  1120   {
       
  1121     $db->_die('The file type could not be fetched.');
       
  1122   }
       
  1123   
       
  1124   if ( $db->numrows() < 1 )
       
  1125   {
       
  1126     echo '<div class="mdg-comment" style="margin-left: 0;">
       
  1127             <h3>' . $lang->get('onpage_filebox_heading') . '</h3>
       
  1128             <p>' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$local_page_id))) . '</p>
       
  1129           </div>
       
  1130           <br />';
       
  1131     return;
       
  1132   }
       
  1133   $r = $db->fetchrow();
       
  1134   $mimetype = $r['mimetype'];
       
  1135   $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']);
       
  1136   echo '<div class="mdg-comment" style="margin-left: 0;">
       
  1137           <h3>' . $lang->get('onpage_filebox_heading') . '</h3>
       
  1138           <p>' . $lang->get('onpage_filebox_lbl_type') . ' '.$r['mimetype'].'<br />';
       
  1139   
       
  1140   $size = $r['size'] . ' ' . $lang->get('etc_unit_bytes');
       
  1141   if ( $r['size'] >= 1048576 )
       
  1142   {
       
  1143     $size .= ' (' . ( round($r['size'] / 1048576, 1) ) . ' ' . $lang->get('etc_unit_megabytes_short') . ')';
       
  1144   }
       
  1145   else if ( $r['size'] >= 1024 )
       
  1146   {
       
  1147     $size .= ' (' . ( round($r['size'] / 1024, 1) ) . ' ' . $lang->get('etc_unit_kilobytes_short') . ')';
       
  1148   }
       
  1149   
       
  1150   echo $lang->get('onpage_filebox_lbl_size', array('size' => $size));
       
  1151   
       
  1152   echo '<br />' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '</p>';
       
  1153   if ( substr($mimetype, 0, 6) != 'image/' && ( substr($mimetype, 0, 5) != 'text/' || $mimetype == 'text/html' || $mimetype == 'text/javascript' ) )
       
  1154   {
       
  1155     echo '<div class="warning-box">
       
  1156             ' . $lang->get('onpage_filebox_msg_virus_warning') . '
       
  1157           </div>';
       
  1158   }
       
  1159   if ( substr($mimetype, 0, 6) == 'image/' )
       
  1160   {
       
  1161     echo '<p>
       
  1162             <a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn).'">
       
  1163               <img style="border: 0;" alt="'.$paths->page.'" src="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.htmlspecialchars(urlSeparator).'preview').'" />
       
  1164             </a>
       
  1165           </p>';
       
  1166   }
       
  1167   echo '<p>
       
  1168           <a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'">
       
  1169             ' . $lang->get('onpage_filebox_btn_download') . '
       
  1170           </a>';
       
  1171   if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') ))
       
  1172   {
       
  1173     echo '  |  <a href="'.makeUrlNS('Special', 'UploadFile'.'/'.$selfn).'">
       
  1174             ' . $lang->get('onpage_filebox_btn_upload_new') . '
       
  1175           </a>';
       
  1176   }
       
  1177   echo '</p>';
       
  1178   if ( $db->numrows() > 1 )
       
  1179   {
       
  1180     // requery, sql_result_seek() doesn't work on postgres
       
  1181     $db->free_result();
       
  1182     $q = $db->sql_query('SELECT f.mimetype,f.time_id,f.size,l.log_id FROM ' . table_prefix . "files AS f\n"
       
  1183                     . "  LEFT JOIN " . table_prefix . "logs AS l\n"
       
  1184                     . "    ON ( l.time_id = f.time_id AND ( l.action = 'reupload' OR l.action IS NULL ) )\n"
       
  1185                     . "  WHERE f.page_id = '$selfn'\n"
       
  1186                     . "    ORDER BY f.time_id DESC;");
       
  1187     if ( !$q )
       
  1188       $db->_die();
       
  1189     
       
  1190     echo '<h3>' . $lang->get('onpage_filebox_heading_history') . '</h3><p>';
       
  1191     $last_rollback_id = false;
       
  1192     while ( $r = $db->fetchrow() )
       
  1193     {
       
  1194       echo '(<a href="'.makeUrlNS('Special', 'DownloadFile'.'/'.$selfn.'/'.$r['time_id'].htmlspecialchars(urlSeparator).'download').'">' . $lang->get('onpage_filebox_btn_this_version') . '</a>) ';
       
  1195       if ( $session->get_permissions('history_rollback') && $last_rollback_id )
       
  1196         echo ' (<a href="#rollback:' . $last_rollback_id . '" onclick="ajaxRollback(\''.$last_rollback_id.'\'); return false;">' . $lang->get('onpage_filebox_btn_revert') . '</a>) ';
       
  1197       else if ( $session->get_permissions('history_rollback') && !$last_rollback_id )
       
  1198         echo ' (' . $lang->get('onpage_filebox_btn_current') . ') ';
       
  1199       $last_rollback_id = $r['log_id'];
       
  1200       $mimetype = $r['mimetype'];
       
  1201       $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']);
       
  1202       
       
  1203       echo $datestring.': '.$r['mimetype'].', ';
       
  1204       
       
  1205       $fs = $r['size'];
       
  1206       $fs = (int)$fs;
       
  1207       
       
  1208       if($fs >= 1048576)
       
  1209       {
       
  1210         $fs = round($fs / 1048576, 1);
       
  1211         $size = $fs . ' ' . $lang->get('etc_unit_megabytes_short');
       
  1212       }
       
  1213       else
       
  1214       if ( $fs >= 1024 )
       
  1215       {
       
  1216         $fs = round($fs / 1024, 1);
       
  1217         $size = $fs . ' ' . $lang->get('etc_unit_kilobytes_short');
       
  1218       }
       
  1219       else
       
  1220       {
       
  1221         $size = $fs . ' ' . $lang->get('etc_unit_bytes');
       
  1222       }
       
  1223       
       
  1224       echo $size;
       
  1225       
       
  1226       echo '<br />';
       
  1227     }
       
  1228     echo '</p>';
       
  1229   }
       
  1230   $db->free_result();
       
  1231   echo '</div><br />';
       
  1232 }
   941 }
  1233 
   942 
  1234 /**
   943 /**
  1235  * Shows header information on the current page. Currently this is only the delete-vote feature. Doesn't take or return anything, but assumes that the page information is already set in $paths.
   944  * Shows header information on the current page. Currently this is only the delete-vote feature. Doesn't take or return anything, but assumes that the page information is already set in $paths.
  1236  */
   945  */
  1260  */
   969  */
  1261 
   970 
  1262 function display_page_footers()
   971 function display_page_footers()
  1263 {
   972 {
  1264   global $db, $session, $paths, $template, $plugins; // Common objects
   973   global $db, $session, $paths, $template, $plugins; // Common objects
  1265   if(isset($_GET['nofooters'])) return;
   974   
       
   975   if ( isset($_GET['nofooters']) )
       
   976   {
       
   977     return;
       
   978   }
       
   979   
  1266   $code = $plugins->setHook('send_page_footers');
   980   $code = $plugins->setHook('send_page_footers');
  1267   foreach ( $code as $cmd )
   981   foreach ( $code as $cmd )
  1268   {
   982   {
  1269     eval($cmd);
   983     eval($cmd);
  1270   }
   984   }
  1271   show_file_info();
       
  1272   show_category_info();
       
  1273 }
   985 }
  1274 
   986 
  1275 /**
   987 /**
  1276  * Essentially an return code reader for a socket. Don't use this unless you're writing mail code and smtp_send_email doesn't cut it. Ported from phpBB's smtp.php.
   988  * Essentially an return code reader for a socket. Don't use this unless you're writing mail code and smtp_send_email doesn't cut it. Ported from phpBB's smtp.php.
  1277  * @param socket A socket resource
   989  * @param socket A socket resource
  2913   {
  2625   {
  2914     $char = substr($char, 1);
  2626     $char = substr($char, 1);
  2915     $char = strtolower($char);
  2627     $char = strtolower($char);
  2916     $char = intval(hexdec($char));
  2628     $char = intval(hexdec($char));
  2917     $char = chr($char);
  2629     $char = chr($char);
       
  2630     if ( preg_match('/^[\w\.\/:;\(\)@\[\]_-]$/', $char) )
       
  2631       continue;
  2918     $page_id = str_replace($matches[0][$id], $char, $page_id);
  2632     $page_id = str_replace($matches[0][$id], $char, $page_id);
  2919   }
  2633   }
  2920   
  2634   
  2921   return $page_id;
  2635   return $page_id;
  2922 }
  2636 }