diff --git a/core/email.class.php b/core/email.class.php index a3e9f555..63677b09 100644 --- a/core/email.class.php +++ b/core/email.class.php @@ -113,7 +113,7 @@ Copyright (C) '.$this->sitename.'
log_info("mail", "Error sending message '$this->subject' to '$this->to'"); } - return $sent; + return $sent; } } -?> \ No newline at end of file +?> diff --git a/core/page.class.php b/core/page.class.php index befec2df..3761f4b2 100644 --- a/core/page.class.php +++ b/core/page.class.php @@ -300,8 +300,7 @@ class Page { * This function returns FALSE if it failed to cache the files, * and returns TRUE if it was successful. */ - private function add_cached_auto_html_headers() - { + private function add_cached_auto_html_headers() { global $config; // store local copy for speed. @@ -326,8 +325,7 @@ class Page { $data_href = get_base_href(); /* ----- CSS Files ----- */ - if ($autocache_css) - { + if($autocache_css) { // First get all the CSS from the lib directory $contents_from_lib = ''; $css_files = glob("lib/*.css"); @@ -358,7 +356,7 @@ class Page { $data = $contents_from_lib .' '. $contents_from_extensions; // Minify the CSS if enabled. - if ($config->get_bool("autocache_min_css")){ + if($config->get_bool("autocache_min_css")) { // not supported yet. // TODO: add support for Minifying CSS files. } @@ -366,19 +364,20 @@ class Page { // compute the MD5 sum of the concatenated CSS files $md5sum = md5($data); - if (!file_exists($cache_location.$md5sum.'.css')) { + if(!file_exists($cache_location.$md5sum.'.css')) { // remove any old cached CSS files. $mask = '*.css'; array_map( 'unlink', glob( $mask ) ); // output the combined file - if (file_put_contents($cache_location.$md5sum.'.css', $data, LOCK_EX) === FALSE) { + if(file_put_contents($cache_location.$md5sum.'.css', $data, LOCK_EX) === FALSE) { return false; // failed to write the file } } // tell the client where to get the css cache file $this->add_html_header(''); - } else { + } + else { // Caching of CSS disabled. foreach(glob("lib/*.css") as $css) { $this->add_html_header(''); @@ -393,8 +392,7 @@ class Page { /* ----- JavaScript Files ----- */ - if ($autocache_js) - { + if($autocache_js) { $data = ''; $js_files = glob("lib/*.js"); if($js_files) { @@ -428,7 +426,8 @@ class Page { } // tell the client where to get the js cache file $this->add_html_header(''); - } else { + } + else { // Caching of Javascript disabled. foreach(glob("lib/*.js") as $js) { $this->add_html_header(''); @@ -443,6 +442,5 @@ class Page { return true; } - } ?> diff --git a/core/util.inc.php b/core/util.inc.php index fb302bfb..d32facdb 100644 --- a/core/util.inc.php +++ b/core/util.inc.php @@ -146,15 +146,14 @@ function autodate($date, $html=true) { * * @retval boolean */ -function isValidDateTime($dateTime) -{ - if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { - if (checkdate($matches[2], $matches[3], $matches[1])) { - return true; - } - } +function isValidDateTime($dateTime) { + if (preg_match("/^(\d{4})-(\d{2})-(\d{2}) ([01][0-9]|2[0-3]):([0-5][0-9]):([0-5][0-9])$/", $dateTime, $matches)) { + if (checkdate($matches[2], $matches[3], $matches[1])) { + return true; + } + } - return false; + return false; } /** @@ -162,16 +161,15 @@ function isValidDateTime($dateTime) * * @retval boolean */ -function isValidDate($date) -{ - if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) { +function isValidDate($date) { + if (preg_match("/^(\d{4})-(\d{2})-(\d{2})$/", $date, $matches)) { // checkdate wants (month, day, year) - if (checkdate($matches[2], $matches[3], $matches[1])) { - return true; - } - } + if (checkdate($matches[2], $matches[3], $matches[1])) { + return true; + } + } - return false; + return false; } /** @@ -420,10 +418,11 @@ function captcha_check() { $rpk = $config->get_string('api_recaptcha_pubkey'); if(!empty($rpk)) { $resp = recaptcha_check_answer( - $rpk, - $_SERVER["REMOTE_ADDR"], - $_POST["recaptcha_challenge_field"], - $_POST["recaptcha_response_field"]); + $rpk, + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"] + ); if(!$resp->is_valid) { log_info("core", "Captcha failed (ReCaptcha): " . $resp->error); @@ -548,21 +547,16 @@ function get_memory_limit() { */ $memory = parse_shorthand_int(ini_get("memory_limit")); - if ($memory == -1) { + if($memory == -1) { // No memory limit. - // Return the larger of the set limits. - if ($shimmie_limit > $default_limit) { - return $shimmie_limit; - } else { - return $default_limit; // return the default memory limit - } - } else { + return max($shimmie_limit, $default_limit); + } + else { // PHP has a memory limit set. - if ($shimmie_limit > $memory) { // Shimmie wants more memory than what PHP is currently set for. - + // Attempt to set PHP's memory limit. if ( ini_set("memory_limit", $shimmie_limit) === FALSE ) { /* We can't change PHP's limit, oh well, return whatever its currently set to */ @@ -570,7 +564,7 @@ function get_memory_limit() { } $memory = parse_shorthand_int(ini_get("memory_limit")); } - + // PHP's memory limit is more than Shimmie needs. return $memory; // return the current setting } @@ -583,10 +577,10 @@ function get_memory_limit() { * @retval string */ function get_session_ip(Config $config) { - $mask = $config->get_string("session_hash_mask", "255.255.0.0"); - $addr = $_SERVER['REMOTE_ADDR']; - $addr = inet_ntop(inet_pton($addr) & inet_pton($mask)); - return $addr; + $mask = $config->get_string("session_hash_mask", "255.255.0.0"); + $addr = $_SERVER['REMOTE_ADDR']; + $addr = inet_ntop(inet_pton($addr) & inet_pton($mask)); + return $addr; } /** @@ -826,18 +820,18 @@ function ip_in_range($IP, $CIDR) { */ function deltree($f) { //Because Windows (I know, bad excuse) - if (PHP_OS === 'WINNT') { + if(PHP_OS === 'WINNT') { $real = realpath($f); $path = realpath('./').'\\'.str_replace('/', '\\', $f); - if ($path != $real) { + if($path != $real) { rmdir($path); } - else - { + else { foreach(glob($f.'/*') as $sf) { if (is_dir($sf) && !is_link($sf)) { deltree($sf); - } else { + } + else { unlink($sf); } } @@ -852,7 +846,8 @@ function deltree($f) { foreach(glob($f.'/*') as $sf) { if (is_dir($sf) && !is_link($sf)) { deltree($sf); - } else { + } + else { unlink($sf); } } @@ -981,7 +976,8 @@ function get_debug_info() { if($config->get_string("commit_hash", "unknown") == "unknown"){ $commit = ""; - }else{ + } + else { $commit = " (".$config->get_string("commit_hash").")"; } $time = sprintf("%5.2f", microtime(true) - $_load_start); @@ -998,53 +994,6 @@ function get_debug_info() { return $debug; } -// print_obj ($object, $title, $return) -function print_obj($object,$title="Object Information", $return=false) { - global $user; - if(DEBUG && isset($_GET['DEBUG']) && $user->can("override_config")) { - $pr = print_r($object,true); - $count = substr_count($pr,"\n")<=25?substr_count($pr,"\n"):25; - $pr = ""; - - if($return) { - return $pr; - } else { - global $page; - $page->add_block(new Block($title,$pr,"main",1000)); - return true; - } - } -} - -// preset tests. - -// Prints the contents of $event->args, even though they are clearly visible in -// the URL bar. -function print_url_args() { - global $event; - print_obj($event->args,"URL Arguments"); -} - -// Prints all the POST data. -function print_POST() { - print_obj($_POST,"\$_POST"); -} - -// Prints GET, though this is also visible in the url ( url?var&var&var) -function print_GET() { - print_obj($_GET,"\$_GET"); -} - -$_last_time = microtime(true); -$_last_msg = null; -function timeline($text) { - if(empty($_GET["timeline"])) return; - global $_last_time, $_last_msg; - $time = microtime(true); - if($_last_msg) printf("TL: %s (%dms)
", $_last_msg, (int)(($time-$_last_time)*1000)); - $_last_time = $time; - $_last_msg = $text; -} /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Request initialisation stuff * diff --git a/install.php b/install.php index 15335082..404517ed 100644 --- a/install.php +++ b/install.php @@ -59,34 +59,34 @@ require_once __SHIMMIE_ROOT__."core/util.inc.php"; require_once __SHIMMIE_ROOT__."core/exceptions.class.php"; require_once __SHIMMIE_ROOT__."core/database.class.php"; +// repair console {{{ /* * This file lets anyone destroy the database -- disable it * as soon as the admin is done installing for the first time */ if(is_readable("config.php")) { session_start(); -?> -
-

Shimmie Repair Console

-'; + echo '

Shimmie Repair Console

'; + // Load the config require_once __SHIMMIE_ROOT__."config.php"; // Load user/site specifics First require_once __SHIMMIE_ROOT__."core/default_config.inc.php"; // Defaults for the rest. - if ( - ( array_key_exists('dsn', $_SESSION) && $_SESSION['dsn'] === DATABASE_DSN ) || - ( array_key_exists('dsn', $_POST) && $_POST['dsn'] === DATABASE_DSN ) - ) - { - if ( array_key_exists('dsn', $_POST) && !empty($_POST['dsn']) ) - { + if( + (array_key_exists('dsn', $_SESSION) && $_SESSION['dsn'] === DATABASE_DSN) || + (array_key_exists('dsn', $_POST) && $_POST['dsn'] === DATABASE_DSN) + ) { + if (array_key_exists('dsn', $_POST) && !empty($_POST['dsn'])) { $_SESSION['dsn'] = $_POST['dsn']; } if(empty($_GET["action"])) { - echo "

Basic Checks

"; - echo "If these checks fail, something is broken; if they all pass, "; - echo "something might be broken, just not checked for..."; + echo " +

Basic Checks

+ If these checks fail, something is broken; if they all pass, + something might be broken, just not checked for... + "; eok("Images writable", is_writable("images")); eok("Thumbs writable", is_writable("thumbs")); eok("Data writable", is_writable("data")); @@ -105,8 +105,8 @@ if(is_readable("config.php")) { "; */ - echo "

Log Out

"; echo " +

Log Out

@@ -116,7 +116,8 @@ if(is_readable("config.php")) { session_destroy(); echo "

Logged Out

You have been logged out.

Main Shimmie Page"; } - } else { + } + else { echo "

Login

Enter the database DSN exactly as in config.php (ie, as originally installed) to access advanced recovery tools:

@@ -134,6 +135,7 @@ if(is_readable("config.php")) { echo "\t\t
"; exit; } +// }}} do_install(); @@ -205,15 +207,19 @@ function begin() { // {{{ $dberr = ""; if(check_gd_version() == 0 && check_im_version() == 0) { - $thumberr = "

PHP's GD extension seems to be missing, ". - "and imagemagick's \"convert\" command cannot be found - ". - "no thumbnailing engines are available."; + $thumberr = " +

PHP's GD extension seems to be missing, + and imagemagick's \"convert\" command cannot be found - + no thumbnailing engines are available. + "; } if(!function_exists("mysql_connect")) { - $dberr = "

PHP's MySQL extension seems to be missing; you may ". - "be able to use an unofficial alternative, checking ". - "for libraries..."; + $dberr = " +

PHP's MySQL extension seems to be missing; you may + be able to use an unofficial alternative, checking + for libraries... + "; if(!function_exists("pg_connect")) { $dberr .= "
PgSQL is missing"; } @@ -378,15 +384,17 @@ function build_dirs() { // {{{ if(!is_writable("data") ) @chmod("data", 0755); if( - !file_exists("images") || !file_exists("thumbs") || !file_exists("data") || - !is_writable("images") || !is_writable("thumbs") || !is_writable("data") + !file_exists("images") || !file_exists("thumbs") || !file_exists("data") || + !is_writable("images") || !is_writable("thumbs") || !is_writable("data") ) { - print "

Shimmie needs three folders in it's directory, 'images', 'thumbs', and 'data', - and they need to be writable by the PHP user.

-

If you see this error, if probably means the folders are owned by you, and they need to be - writable by the web server.

-

PHP reports that it is currently running as user: ".$_ENV["USER"]." (". $_SERVER["USER"] .")

-

Once you have created these folders and/or changed the ownership of the shimmie folder, hit 'refresh' to continue.

"; + print " +

Shimmie needs three folders in it's directory, 'images', 'thumbs', and 'data', + and they need to be writable by the PHP user.

+

If you see this error, if probably means the folders are owned by you, and they need to be + writable by the web server.

+

PHP reports that it is currently running as user: ".$_ENV["USER"]." (". $_SERVER["USER"] .")

+

Once you have created these folders and / or changed the ownership of the shimmie folder, hit 'refresh' to continue.

+ "; exit; } } // }}} @@ -401,14 +409,14 @@ function write_config() { // {{{ else { $h_file_content = htmlentities($file_content); print << +

-

One done, Continue +

One done, Continue EOD; exit; }