diff -r 902822492a68 -r fe660c52c48f includes/functions.php~ --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/includes/functions.php~ Wed Jun 13 16:07:17 2007 -0400 @@ -0,0 +1,1863 @@ +escape($v); + $e=$db->sql_query('DELETE FROM '.table_prefix.'config WHERE config_name=\''.$n.'\';'); + if(!$e) $db->_die('Error during generic setConfig() call row deletion.'); + $e=$db->sql_query('INSERT INTO '.table_prefix.'config(config_name, config_value) VALUES(\''.$n.'\', \''.$v.'\')'); + if(!$e) $db->_die('Error during generic setConfig() call row insertion.'); +} + +function makeUrl($t, $query = false, $escape = false) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $flags = ''; + $sep = urlSeparator; + if(isset($_GET['printable'])) { $flags .= $sep.'printable'; $sep = '&'; } + if(isset($_GET['theme'])) { $flags .= $sep.'theme='.$session->theme; $sep = '&'; } + if(isset($_GET['style'])) { $flags .= $sep.'style='.$session->style; $sep = '&'; } + $url = $session->append_sid(contentPath.$t.$flags); + if($query) + { + $sep = strstr($url, '?') ? '&' : '?'; + $url = $url . $sep . $query; + } + return ($escape) ? htmlspecialchars($url) : $url; +} + +function makeUrlNS($n, $t, $query = false, $escape = false) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $flags = ''; + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) $sep = urlSeparator; + else $sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; + if(isset($_GET['printable'])) { $flags .= $sep.'printable'; $sep = '&'; } + if(isset($_GET['theme'])) { $flags .= $sep.'theme='.$session->theme; $sep = '&'; } + if(isset($_GET['style'])) { $flags .= $sep.'style='.$session->style; $sep = '&'; } + + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) + { + $url = contentPath.$paths->nslist[$n].$t.$flags; + } + else + { + $url = contentPath.$n.':'.$t.$flags; + } + + if($query) + { + if(strstr($url, '?')) $sep = '&'; + else $sep = '?'; + $url = $url . $sep . $query . $flags; + } + + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) + { + $url = $session->append_sid($url); + } + + return ($escape) ? htmlspecialchars($url) : $url; +} + +function makeUrlComplete($n, $t, $query = false, $escape = false) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + $flags = ''; + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) $sep = urlSeparator; + else $sep = (strstr($_SERVER['REQUEST_URI'], '?')) ? '&' : '?'; + if(isset($_GET['printable'])) { $flags .= $sep.'printable'; $sep = '&'; } + if(isset($_GET['theme'])) { $flags .= $sep.'theme='.$session->theme; $sep = '&'; } + if(isset($_GET['style'])) { $flags .= $sep.'style='.$session->style; $sep = '&'; } + if(defined('ENANO_BASE_CLASSES_INITIALIZED')) $url = $session->append_sid(contentPath.$paths->nslist[$n].$t.$flags); + else $url = contentPath.$n.':'.$t.$flags; + if($query) + { + if(strstr($url, '?')) $sep = '&'; + else $sep = '?'; + $url = $url . $sep . $query . $flags; + } + $baseprot = 'http' . ( isset($_SERVER['HTTPS']) ? 's' : '' ) . '://' . $_SERVER['HTTP_HOST']; + $url = $baseprot . $url; + return ($escape) ? htmlspecialchars($url) : $url; +} + +/** + * Redirect the user to the specified URL. + * @param string $url The URL, either relative or absolute. + * @param string $title The title of the message + * @param string $message A short message to show to the user + * @param string $timeout Timeout, in seconds, to delay the redirect. Defaults to 3. + */ + +function redirect($url, $title = 'Redirecting...', $message = 'Please wait while you are redirected.', $timeout = 3) +{ + global $db, $session, $paths, $template, $plugins; // Common objects + + if ( $timeout == 0 ) + { + header('Location: ' . $url); + header('HTTP/1.1 307 Temporary Redirect'); + } + + $template->add_header(''); + $template->add_header(' + '); + + $template->tpl_strings['PAGE_NAME'] = $title; + $template->header(true); + echo '
' . $message . '
If you are not redirected within ' . ( $timeout + 1 ) . ' seconds, please click here.
'; + $template->footer(true); + + $db->close(); + exit(0); + +} + +// Removed wikiFormat() from here, replaced with RenderMan::render + +function isPage($p) { + global $db, $session, $paths, $template, $plugins; // Common objects + if(isset($paths->pages[$p])) return true; + $d = RenderMan::strToPageID($p); + if($d[1] != 'Special' && $d[1] != 'Template' && $d[1] != 'Admin') return false; + $a = explode('/', $p); + if(isset($paths->pages[$a[0]])) return true; + else return false; +} + +function arrayItemUp($arr, $keyname) { + $keylist = array_keys($arr); + $keyflop = array_flip($keylist); + $idx = $keyflop[$keyname]; + $idxm = $idx - 1; + $temp = $arr[$keylist[$idxm]]; + if($arr[$keylist[0]] == $arr[$keyname]) return $arr; + $arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; + $arr[$keylist[$idx]] = $temp; + return $arr; +} + +function arrayItemDown($arr, $keyname) { + $keylist = array_keys($arr); + $keyflop = array_flip($keylist); + $idx = $keyflop[$keyname]; + $idxm = $idx + 1; + $temp = $arr[$keylist[$idxm]]; + $sz = sizeof($arr); $sz--; + if($arr[$keylist[$sz]] == $arr[$keyname]) return $arr; + $arr[$keylist[$idxm]] = $arr[$keylist[$idx]]; + $arr[$keylist[$idx]] = $temp; + return $arr; +} + +function arrayItemTop($arr, $keyname) { + $keylist = array_keys($arr); + $keyflop = array_flip($keylist); + $idx = $keyflop[$keyname]; + while( $orig != $arr[$keylist[0]] ) { + // echo 'Keyname: '.$keylist[$idx] . ''; + print_r($arr); + echo '
'; + print_r($arr); + echo '
There are no subcategories in this category.
'; + echo ''.$paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'].' | '; + if($ticker==2) echo '
There are no pages in this category.
'; + echo ''.$paths->pages[$paths->nslist[$row['namespace']].$row['page_id']]['name'].' | '; + if($ticker==2) echo '
There are no files uploaded with this name yet. Upload a file...
Type: '.$r['mimetype'].'
Size: ';
+ $fs = $r['size'];
+ echo $fs.' bytes';
+ $fs = (int)$fs;
+ if($fs >= 1048576)
+ {
+ $fs = round($fs / 1048576, 1);
+ echo ' ('.$fs.' MB)';
+ } elseif($fs >= 1024) {
+ $fs = round($fs / 1024, 1);
+ echo ' ('.$fs.' KB)';
+ }
+ echo '
Uploaded: '.$datestring.'
Download this file'; + if(!$paths->page_protected && ( $paths->wiki_mode || $session->get_permissions('upload_new_version') )) + { + echo ' | Upload new version'; + } + echo '
'; + if($db->numrows() > 1) + { + echo '';
+ while($r = $db->fetchrow())
+ {
+ echo '(this ver) ';
+ if($session->get_permissions('history_rollback'))
+ echo ' (revert) ';
+ $mimetype = $r['mimetype'];
+ $datestring = 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) {
+ $fs = round($fs / 1024, 1);
+ echo ' '.$fs.' KB';
+ } else {
+ echo ' '.$fs.' bytes';
+ }
+ echo '
';
+ }
+ echo '
You must supply a password to access this page.