whitespace consistency
This commit is contained in:
parent
eb8c15b9a0
commit
f9910ba98f
4 changed files with 94 additions and 139 deletions
|
@ -113,7 +113,7 @@ Copyright (C) <a href="'.$this->sitedomain.'">'.$this->sitename.'</a><br />
|
|||
log_info("mail", "Error sending message '$this->subject' to '$this->to'");
|
||||
}
|
||||
|
||||
return $sent;
|
||||
return $sent;
|
||||
}
|
||||
}
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -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('<link rel="stylesheet" href="'.$data_href.'/'.$cache_location.$md5sum.'.css" type="text/css">');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Caching of CSS disabled.
|
||||
foreach(glob("lib/*.css") as $css) {
|
||||
$this->add_html_header('<link rel="stylesheet" href="'.$data_href.'/'.$css.'" type="text/css">');
|
||||
|
@ -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('<script src="'.$data_href.'/'.$cache_location.$md5sum.'.js" type="text/javascript"></script>');
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Caching of Javascript disabled.
|
||||
foreach(glob("lib/*.js") as $js) {
|
||||
$this->add_html_header('<script src="'.$data_href.'/'.$js.'" type="text/javascript"></script>');
|
||||
|
@ -443,6 +442,5 @@ class Page {
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -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 = "<textarea rows='".$count."' cols='80'>$pr</textarea>";
|
||||
|
||||
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)<br>", $_last_msg, (int)(($time-$_last_time)*1000));
|
||||
$_last_time = $time;
|
||||
$_last_msg = $text;
|
||||
}
|
||||
|
||||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\
|
||||
* Request initialisation stuff *
|
||||
|
|
80
install.php
80
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();
|
||||
?>
|
||||
<div id="iblock">
|
||||
<h1>Shimmie Repair Console</h1>
|
||||
<?php
|
||||
echo '<div id="iblock">';
|
||||
echo '<h1>Shimmie Repair Console</h1>';
|
||||
|
||||
// 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 "<h3>Basic Checks</h3>";
|
||||
echo "If these checks fail, something is broken; if they all pass, ";
|
||||
echo "something <i>might</i> be broken, just not checked for...";
|
||||
echo "
|
||||
<h3>Basic Checks</h3>
|
||||
If these checks fail, something is broken; if they all pass,
|
||||
something <i>might</i> 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 "<h3>Log Out</h3>";
|
||||
echo "
|
||||
<h3>Log Out</h3>
|
||||
<form action='install.php?action=logout' method='POST'>
|
||||
<input type='submit' value='Leave'>
|
||||
</form>
|
||||
|
@ -116,7 +116,8 @@ if(is_readable("config.php")) {
|
|||
session_destroy();
|
||||
echo "<h3>Logged Out</h3><p>You have been logged out.</p><a href='index.php'>Main Shimmie Page</a>";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
echo "
|
||||
<h3>Login</h3>
|
||||
<p>Enter the database DSN exactly as in config.php (ie, as originally installed) to access advanced recovery tools:</p>
|
||||
|
@ -134,6 +135,7 @@ if(is_readable("config.php")) {
|
|||
echo "\t\t</div>";
|
||||
exit;
|
||||
}
|
||||
// }}}
|
||||
|
||||
do_install();
|
||||
|
||||
|
@ -205,15 +207,19 @@ function begin() { // {{{
|
|||
$dberr = "";
|
||||
|
||||
if(check_gd_version() == 0 && check_im_version() == 0) {
|
||||
$thumberr = "<p>PHP's GD extension seems to be missing, ".
|
||||
"and imagemagick's \"convert\" command cannot be found - ".
|
||||
"no thumbnailing engines are available.";
|
||||
$thumberr = "
|
||||
<p>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 = "<p>PHP's MySQL extension seems to be missing; you may ".
|
||||
"be able to use an unofficial alternative, checking ".
|
||||
"for libraries...";
|
||||
$dberr = "
|
||||
<p>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 .= "<br>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 "<p>Shimmie needs three folders in it's directory, 'images', 'thumbs', and 'data',
|
||||
and they need to be writable by the PHP user.</p>
|
||||
<p>If you see this error, if probably means the folders are owned by you, and they need to be
|
||||
writable by the web server.</p>
|
||||
<p>PHP reports that it is currently running as user: ".$_ENV["USER"]." (". $_SERVER["USER"] .")</p>
|
||||
<p>Once you have created these folders and/or changed the ownership of the shimmie folder, hit 'refresh' to continue.</p>";
|
||||
print "
|
||||
<p>Shimmie needs three folders in it's directory, 'images', 'thumbs', and 'data',
|
||||
and they need to be writable by the PHP user.</p>
|
||||
<p>If you see this error, if probably means the folders are owned by you, and they need to be
|
||||
writable by the web server.</p>
|
||||
<p>PHP reports that it is currently running as user: ".$_ENV["USER"]." (". $_SERVER["USER"] .")</p>
|
||||
<p>Once you have created these folders and / or changed the ownership of the shimmie folder, hit 'refresh' to continue.</p>
|
||||
";
|
||||
exit;
|
||||
}
|
||||
} // }}}
|
||||
|
@ -401,14 +409,14 @@ function write_config() { // {{{
|
|||
else {
|
||||
$h_file_content = htmlentities($file_content);
|
||||
print <<<EOD
|
||||
The web server isn't allowed to write to the config file; please copy
|
||||
the text below, save it as 'config.php', and upload it into the shimmie
|
||||
folder manually. Make sure that when you save it, there is no whitespace
|
||||
before the "<?php" or after the "?>"
|
||||
The web server isn't allowed to write to the config file; please copy
|
||||
the text below, save it as 'config.php', and upload it into the shimmie
|
||||
folder manually. Make sure that when you save it, there is no whitespace
|
||||
before the "<?php" or after the "?>"
|
||||
|
||||
<p><textarea cols="80" rows="2">$file_content</textarea>
|
||||
<p><textarea cols="80" rows="2">$file_content</textarea>
|
||||
|
||||
<p>One done, <a href='index.php'>Continue</a>
|
||||
<p>One done, <a href='index.php'>Continue</a>
|
||||
EOD;
|
||||
exit;
|
||||
}
|
||||
|
|
Reference in a new issue