diff -r 9bcc185dc151 -r 85f91037cd4f includes/functions.php --- a/includes/functions.php Tue Jan 29 17:29:08 2008 -0500 +++ b/includes/functions.php Tue Jan 29 23:15:44 2008 -0500 @@ -321,7 +321,11 @@ if ( $timeout == 0 && empty($_POST) ) { header('Location: ' . $url); + header('Content-length: 0'); header('HTTP/1.1 307 Temporary Redirect'); + + // with 3xx codes HTTP clients expect a response of 0 bytes, so just die here + exit(); } if ( !is_object($template) ) @@ -330,7 +334,7 @@ $template->load_theme('oxygen', 'bleu', false); $template->tpl_strings['SITE_NAME'] = 'Enano'; $template->tpl_strings['SITE_DESC'] = 'This site is experiencing a critical error and cannot load.'; - $template->tpl_strings['COPYRIGHT'] = 'Powered by Enano CMS - © 2007 Dan Fuhry. This program is Free Software; see the GPL file included with this package for details.'; + $template->tpl_strings['COPYRIGHT'] = 'Powered by Enano CMS - © 2006-2008 Dan Fuhry. This program is Free Software; see the GPL file included with this package for details.'; $template->tpl_strings['PAGE_NAME'] = htmlspecialchars($title); } @@ -435,10 +439,6 @@ // echo 'Keyname: '.$keylist[$idx] . '
'; flush(); ob_flush(); // Debugger if($idx < 0) return $arr; if($keylist[$idx] == '' || $keylist[$idx] < 0 || !$keylist[$idx]) { - /* echo 'Infinite loop caught in arrayItemTop(
';
-      print_r($arr);
-      echo '

, '.$keyname.');

EnanoCMS: Critical error during function call, exiting to prevent excessive server load.'; - exit; */ return $arr; } $arr = arrayItemUp($arr, $keylist[$idx]); @@ -613,7 +613,7 @@ { $db->_die(); } - echo '

Subcategories

'; + echo '

' . $lang->get('onpage_cat_heading_subcategories') . '

'; echo '
'; echo ''; echo ''; @@ -636,10 +636,10 @@ } else { - echo ''; + echo ''; } echo '
No subcategories.' . $lang->get('onpage_cat_msg_no_subcategories') . '
' . "\n\n"; - echo '

Pages

'; + echo '

' . $lang->get('onpage_cat_heading_pages') . '

'; echo '
'; echo ''; echo ''; @@ -684,10 +684,10 @@ } else { - echo ''; + echo ''; } echo '
No subcategories.' . $lang->get('onpage_cat_msg_no_subcategories') . '
' . "\n\n"; - echo '

Pages

'; + echo '

' . $lang->get('onpage_cat_heading_pages') . '

'; echo '
'; echo ''; echo ''; @@ -706,7 +706,7 @@ } else { - echo ''; + echo ''; } echo '
No pages in this category.' . $lang->get('onpage_cat_msg_no_pages') . '
' . "\n\n"; } @@ -770,65 +770,111 @@ function show_file_info() { global $db, $session, $paths, $template, $plugins; // Common objects - if($paths->namespace != 'File') return null; // Prevent unnecessary work - $selfn = $paths->page_id; // substr($paths->page, strlen($paths->nslist['File']), strlen($paths->cpage)); - if(substr($paths->cpage['name'], 0, strlen($paths->nslist['File']))==$paths->nslist['File']) $selfn = substr($paths->page_id, strlen($paths->nslist['File']), strlen($paths->page_id)); + global $lang; + + // Prevent unnecessary work + if ( $paths->namespace != 'File' ) + return null; + + $selfn = $paths->page_id; + if ( substr($paths->cpage['name'], 0, strlen($paths->nslist['File'])) == $paths->nslist['File']) + { + $selfn = substr($paths->page_id, strlen($paths->nslist['File']), strlen($paths->page_id)); + } $q = $db->sql_query('SELECT mimetype,time_id,size FROM '.table_prefix.'files WHERE page_id=\''.$selfn.'\' ORDER BY time_id DESC;'); - if(!$q) $db->_die('The file type could not be fetched.'); - if($db->numrows() < 1) { echo '

Uploaded file

There are no files uploaded with this name yet. Upload a file...


'; return; } + if ( !$q ) + { + $db->_die('The file type could not be fetched.'); + } + + if ( $db->numrows() < 1 ) + { + echo '
+

' . $lang->get('onpage_filebox_heading') . '

+

' . $lang->get('onpage_filebox_msg_not_found', array('upload_link' => makeUrlNS('Special', 'UploadFile/'.$paths->page_id))) . '

+
+
'; + return; + } $r = $db->fetchrow(); $mimetype = $r['mimetype']; $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); - echo '

Uploaded file

Type: '.$r['mimetype'].'
Size: '; - $fs = $r['size']; - echo $fs.' bytes'; - $fs = (int)$fs; - if($fs >= 1048576) + echo '

+

' . $lang->get('onpage_filebox_heading') . '

+

' . $lang->get('onpage_filebox_lbl_type') . ' '.$r['mimetype'].'
'; + + $size = $r['size'] . ' ' . $lang->get('etc_unit_bytes'); + if ( $r['size'] >= 1048576 ) + { + $size .= ' (' . ( round($r['size'] / 1048576, 1) ) . ' ' . $lang->get('etc_unit_megabytes_short') . ')'; + } + else if ( $r['size'] >= 1024 ) { - $fs = round($fs / 1048576, 1); - echo ' ('.$fs.' MB)'; - } elseif($fs >= 1024) { - $fs = round($fs / 1024, 1); - echo ' ('.$fs.' KB)'; + $size .= ' (' . ( round($r['size'] / 1024, 1) ) . ' ' . $lang->get('etc_unit_kilobytes_short') . ')'; + } + + echo $lang->get('onpage_filebox_lbl_size', array('size' => $size)); + + echo '
' . $lang->get('onpage_filebox_lbl_uploaded') . ' ' . $datestring . '

'; + if ( substr($mimetype, 0, 6) != 'image/' && ( substr($mimetype, 0, 5) != 'text/' || $mimetype == 'text/html' || $mimetype == 'text/javascript' ) ) + { + echo '
+ ' . $lang->get('onpage_filebox_msg_virus_warning') . ' +
'; } - echo '
Uploaded: '.$datestring.'

'; - if(substr($mimetype, 0, 6)!='image/' && ( substr($mimetype, 0, 5) != 'text/' || $mimetype == 'text/html' || $mimetype == 'text/javascript' )) + if ( substr($mimetype, 0, 6) == 'image/' ) { - echo '
This file type may contain viruses or other code that could harm your computer. You should exercise caution if you download it.
'; + echo '

+ + '.$paths->page.' + +

'; } - if(substr($mimetype, 0, 6)=='image/') - { - echo '

'.$paths->page.'

'; - } - echo '

Download this file'; + echo '

+ + ' . $lang->get('onpage_filebox_btn_download') . ' + '; if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) { - echo ' | Upload new version'; + echo ' | + ' . $lang->get('onpage_filebox_btn_upload_new') . ' + '; } echo '

'; - if($db->numrows() > 1) + if ( $db->numrows() > 1 ) { - echo '

File history

'; - while($r = $db->fetchrow()) + echo '

' . $lang->get('onpage_filebox_heading_history') . '

'; + while ( $r = $db->fetchrow() ) { - echo '(this ver) '; - if($session->get_permissions('history_rollback')) - echo ' (revert) '; + echo '(' . $lang->get('onpage_filebox_btn_this_version') . ') '; + if ( $session->get_permissions('history_rollback') ) + echo ' (' . $lang->get('onpage_filebox_btn_revert') . ') '; $mimetype = $r['mimetype']; $datestring = enano_date('F d, Y h:i a', (int)$r['time_id']); + echo $datestring.': '.$r['mimetype'].', '; + $fs = $r['size']; $fs = (int)$fs; + if($fs >= 1048576) { $fs = round($fs / 1048576, 1); - echo ' '.$fs.' MB'; - } elseif($fs >= 1024) { + $size = $fs . ' ' . $lang->get('etc_unit_megabytes_short'); + } + else + if ( $fs >= 1024 ) + { $fs = round($fs / 1024, 1); - echo ' '.$fs.' KB'; - } else { - echo ' '.$fs.' bytes'; + $size = $fs . ' ' . $lang->get('etc_unit_kilobytes_short'); } + else + { + $size = $fs . ' ' . $lang->get('etc_unit_bytes'); + } + + echo $size; + echo '
'; } echo '

'; @@ -879,37 +925,6 @@ } /** - * Deprecated, do not use. - */ - -function password_prompt($id = false) -{ - global $db, $session, $paths, $template, $plugins; // Common objects - if(!$id) $id = $paths->page; - if(isset($paths->pages[$id]['password']) && strlen($paths->pages[$id]['password']) == 40 && !isset($_REQUEST['pagepass'])) - { - die_friendly('Password required', '

You must supply a password to access this page.

Password:

'); - } elseif(isset($_REQUEST['pagepass'])) { - $p = (preg_match('#^([a-f0-9]*){40}$#', $_REQUEST['pagepass'])) ? $_REQUEST['pagepass'] : sha1($_REQUEST['pagepass']); - if($p != $paths->pages[$id]['password']) die_friendly('Password required', '

The password you entered is incorrect.

Password:

'); - } -} - -/** - * Some sort of primitive hex converter from back in the day. Deprecated, do not use. - * @param string Text to encode - * @return string - */ - -function str_hex($string){ - $hex=''; - for ($i=0; $i < strlen($string); $i++){ - $hex .= ' '.dechex(ord($string[$i])); - } - return substr($hex, 1, strlen($hex)); -} - -/** * 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. * @param socket A socket resource * @param string The expected response from the server, this needs to be exactly three characters. @@ -1187,14 +1202,6 @@ } /** - * What kinda sh** was I thinking when I wrote this. Deprecated. - */ - -function _dualurlenc($t) { - return rawurlencode(rawurlencode($t)); -} - -/** * Badly named function to send back eval'able Javascript code with an error message. Deprecated, use JSON instead. * @param string Message to send */