Permalink
Browse files

changed coding style rules. Starting the PR1 branch

  • Loading branch information...
snytkine committed May 26, 2012
1 parent fe525e4 commit d3f7f22a146a9e4fdea5043c49ee74fe72bc5d10
Showing 425 changed files with 103,844 additions and 78,851 deletions.
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+ <component name="ProjectCodeStyleSettingsManager">
+ <option name="PER_PROJECT_SETTINGS">
+ <value />
+ </option>
+ </component>
+</project>
+
@@ -0,0 +1,8 @@
+<component name="ProjectDictionaryState">
+ <dictionary name="admin">
+ <words>
+ <w>lampcms</w>
+ <w>snytkine</w>
+ </words>
+ </dictionary>
+</component>
View
@@ -47,19 +47,19 @@
* genocidal quotes added by magic_quotes
*/
if (get_magic_quotes_gpc()) {
- $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
- while (list($key, $val) = each($process)) {
- foreach ($val as $k => $v) {
- unset($process[$key][$k]);
- if (is_array($v)) {
- $process[$key][stripslashes($k)] = $v;
- $process[] = &$process[$key][stripslashes($k)];
- } else {
- $process[$key][stripslashes($k)] = stripslashes($v);
- }
- }
- }
- unset($process);
+ $process = array(&$_GET, &$_POST, &$_COOKIE, &$_REQUEST);
+ while (list($key, $val) = each($process)) {
+ foreach ($val as $k => $v) {
+ unset($process[$key][$k]);
+ if (is_array($v)) {
+ $process[$key][stripslashes($k)] = $v;
+ $process[] = &$process[$key][stripslashes($k)];
+ } else {
+ $process[$key][stripslashes($k)] = stripslashes($v);
+ }
+ }
+ }
+ unset($process);
}
@@ -68,57 +68,60 @@
* functions to use UTF-8
* as internal encoding
*/
-if(function_exists('mb_internal_encoding')){
- mb_internal_encoding("UTF-8");
+if (function_exists('mb_internal_encoding')) {
+ mb_internal_encoding("UTF-8");
}
-function exception_handler($e){
- $code = $e->getCode();
- if(!($e instanceof \OutOfBoundsException)){
- try {
- $err = Lampcms\Responder::makeErrorPage('<strong>Error:</strong> '.Lampcms\Exception::formatException($e));
- $extra = (isset($_SERVER)) ? ' $_SERVER: '.print_r($_SERVER, 1) : ' no extra';
- if(($code >=0) && defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7){
- @mail(LAMPCMS_DEVELOPER_EMAIL, 'ErrorHandle in inc.php', $err.$extra);
- }
- echo nl2br($err);
- } catch(\Exception $e) {
- echo 'Error in Exception handler: : '.$e->getMessage().' line '.$e->getLine().$e->getTraceAsString();
- }
- } else {
- echo('Got exit signal in error_handler from '.$e->getTraceAsString());
- }
+function exception_handler($e)
+{
+ $code = $e->getCode();
+ if (!($e instanceof \OutOfBoundsException)) {
+ try {
+ $err = Lampcms\Responder::makeErrorPage('<strong>Error:</strong> ' . Lampcms\Exception::formatException($e));
+ $extra = (isset($_SERVER)) ? ' $_SERVER: ' . print_r($_SERVER, 1) : ' no extra';
+ if (($code >= 0) && defined('LAMPCMS_DEVELOPER_EMAIL') && strlen(trim(constant('LAMPCMS_DEVELOPER_EMAIL'))) > 7) {
+ @mail(LAMPCMS_DEVELOPER_EMAIL, 'ErrorHandle in inc.php', $err . $extra);
+ }
+ echo nl2br($err);
+ } catch (\Exception $e) {
+ echo 'Error in Exception handler: : ' . $e->getMessage() . ' line ' . $e->getLine() . $e->getTraceAsString();
+ }
+ } else {
+ echo('Got exit signal in error_handler from ' . $e->getTraceAsString());
+ }
}
/**
* If php NOT running as fastcgi
* then we need to create a dummy function
*
*/
-if(!function_exists('fastcgi_finish_request')){
- define('NO_FFR', true);
- function fastcgi_finish_request(){}
+if (!function_exists('fastcgi_finish_request')) {
+ define('NO_FFR', true);
+ function fastcgi_finish_request()
+ {
+ }
}
set_exception_handler('exception_handler');
-$lampcmsClasses = LAMPCMS_LIB_DIR.DIRECTORY_SEPARATOR.'Lampcms'.DIRECTORY_SEPARATOR;
+$lampcmsClasses = LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'Lampcms' . DIRECTORY_SEPARATOR;
-require $lampcmsClasses.'Interfaces'.DIRECTORY_SEPARATOR.'All.php';
-require $lampcmsClasses.'Exception.php';
-require $lampcmsClasses.'Object.php';
-require $lampcmsClasses.'Responder.php';
-require $lampcmsClasses.'Mongo'.DIRECTORY_SEPARATOR.'Collections.php';
-require $lampcmsClasses.'Config'.DIRECTORY_SEPARATOR.'Ini.php';
-require $lampcmsClasses.'Log.php';
-require $lampcmsClasses.'Request.php';
-require $lampcmsClasses.DIRECTORY_SEPARATOR.'Mongo'.DIRECTORY_SEPARATOR.'DB.php';
-require $lampcmsClasses.DIRECTORY_SEPARATOR.'Mongo'.DIRECTORY_SEPARATOR.'Doc.php'; // User extends it
-require $lampcmsClasses.'User.php'; // User is always used
-require $lampcmsClasses.'SplClassLoader.php';
-require $lampcmsClasses.'Registry.php';
-require $lampcmsClasses.'Template'.DIRECTORY_SEPARATOR.'Fast.php';
+require $lampcmsClasses . 'Interfaces' . DIRECTORY_SEPARATOR . 'All.php';
+require $lampcmsClasses . 'Exception.php';
+require $lampcmsClasses . 'Object.php';
+require $lampcmsClasses . 'Responder.php';
+require $lampcmsClasses . 'Mongo' . DIRECTORY_SEPARATOR . 'Collections.php';
+require $lampcmsClasses . 'Config' . DIRECTORY_SEPARATOR . 'Ini.php';
+require $lampcmsClasses . 'Log.php';
+require $lampcmsClasses . 'Request.php';
+require $lampcmsClasses . DIRECTORY_SEPARATOR . 'Mongo' . DIRECTORY_SEPARATOR . 'DB.php';
+require $lampcmsClasses . DIRECTORY_SEPARATOR . 'Mongo' . DIRECTORY_SEPARATOR . 'Doc.php'; // User extends it
+require $lampcmsClasses . 'User.php'; // User is always used
+require $lampcmsClasses . 'SplClassLoader.php';
+require $lampcmsClasses . 'Registry.php';
+require $lampcmsClasses . 'Template' . DIRECTORY_SEPARATOR . 'Fast.php';
/**
* Custom error handle
@@ -146,79 +149,79 @@ function fastcgi_finish_request(){}
function LampcmsErrorHandler($errno, $errstr, $errfile, $errline)
{
- $errLevel = error_reporting();
+ $errLevel = error_reporting();
- if ($errno === E_RECOVERABLE_ERROR) {
+ if ($errno === E_RECOVERABLE_ERROR) {
- d($errfile.' '.$errline.' '.$errstr);
- $e = 'Caught catchable fatal error in file: %1$s<br>
+ d($errfile . ' ' . $errline . ' ' . $errstr);
+ $e = 'Caught catchable fatal error in file: %1$s<br>
on line: %2$s
<br><br>
Error message: <br>
%3$s<br>';
- $err = vsprintf($e, array($errfile, $errline, $errstr));
+ $err = vsprintf($e, array($errfile, $errline, $errstr));
- throw new Lampcms\DevException($err);
+ throw new Lampcms\DevException($err);
- } else {
+ } else {
- if ($errLevel === 0) {
+ if ($errLevel === 0) {
- return;
- }
- /**
- * If error level falls within our
- * error reporting mask, then throw an ErrorException
- */
- if ($errLevel & $errno) {
+ return;
+ }
+ /**
+ * If error level falls within our
+ * error reporting mask, then throw an ErrorException
+ */
+ if ($errLevel & $errno) {
- throw new \Lampcms\DevException($errstr, NULL, $errno, $errfile, $errline);
- }
- }
+ throw new \Lampcms\DevException($errstr, NULL, $errno, $errfile, $errline);
+ }
+ }
- return true;
+ return true;
}
$old_error_handler = set_error_handler("LampcmsErrorHandler");
// autoloader here
-require LAMPCMS_LIB_DIR.DIRECTORY_SEPARATOR.'autoload.php';
+require LAMPCMS_LIB_DIR . DIRECTORY_SEPARATOR . 'autoload.php';
$Registry = \Lampcms\Registry::getInstance();
-try{
-
- $Ini = $Registry->Ini;
- $dataDir = $Ini->LAMPCMS_DATA_DIR;
- $dataDir = rtrim($dataDir, '/');
-
- define('LAMPCMS_DEVELOPER_EMAIL', $Ini->EMAIL_DEVELOPER);
- define('LAMPCMS_SALT', $Ini->SALT);
- define('LAMPCMS_COOKIE_SALT', $Ini->COOKIE_SALT);
- define('LAMPCMS_DEFAULT_LANG', $Ini->DEFAULT_LANG);
- define('LAMPCMS_DEFAULT_LOCALE', $Ini->DEFAULT_LOCALE);
- define('LAMPCMS_TR_DIR', $Ini->TRANSLATIONS_DIR);
- define('LAMPCMS_COOKIE_DOMAIN', $Ini->COOKIE_DOMAIN );
- define('LAMPCMS_IMAGE_SITE', $Ini->IMAGE_SITE);
- define('LAMPCMS_AVATAR_IMG_SITE', $Ini->AVATAR_IMG_SITE);
- define('LAMPCMS_CATEGORIES', 'C'.(int)$Ini->CATEGORIES);
-
- if (!empty($dataDir)) {
- define('LAMPCMS_DATA_DIR', $dataDir.DIRECTORY_SEPARATOR);
- } else {
- define('LAMPCMS_DATA_DIR', LAMPCMS_WWW_DIR.'w'.DIRECTORY_SEPARATOR);
- }
-
-} catch(Lampcms\IniException $e){
- throw new \OutOfBoundsException($e->getMessage());
+try {
+
+ $Ini = $Registry->Ini;
+ $dataDir = $Ini->LAMPCMS_DATA_DIR;
+ $dataDir = rtrim($dataDir, '/');
+
+ define('LAMPCMS_DEVELOPER_EMAIL', $Ini->EMAIL_DEVELOPER);
+ define('LAMPCMS_SALT', $Ini->SALT);
+ define('LAMPCMS_COOKIE_SALT', $Ini->COOKIE_SALT);
+ define('LAMPCMS_DEFAULT_LANG', $Ini->DEFAULT_LANG);
+ define('LAMPCMS_DEFAULT_LOCALE', $Ini->DEFAULT_LOCALE);
+ define('LAMPCMS_TR_DIR', $Ini->TRANSLATIONS_DIR);
+ define('LAMPCMS_COOKIE_DOMAIN', $Ini->COOKIE_DOMAIN);
+ define('LAMPCMS_IMAGE_SITE', $Ini->IMAGE_SITE);
+ define('LAMPCMS_AVATAR_IMG_SITE', $Ini->AVATAR_IMG_SITE);
+ define('LAMPCMS_CATEGORIES', 'C' . (int)$Ini->CATEGORIES);
+
+ if (!empty($dataDir)) {
+ define('LAMPCMS_DATA_DIR', $dataDir . DIRECTORY_SEPARATOR);
+ } else {
+ define('LAMPCMS_DATA_DIR', LAMPCMS_WWW_DIR . 'w' . DIRECTORY_SEPARATOR);
+ }
+
+} catch (Lampcms\IniException $e) {
+ throw new \OutOfBoundsException($e->getMessage());
}
/**
* First thing is to set our timezone
*/
if (false === date_default_timezone_set($Ini->SERVER_TIMEZONE)) {
- throw new \Lampcms\DevException('Invalid name of "SERVER_TIMEZONE" in !config.ini constant. The list of valid timezone names can be found here: http://us.php.net/manual/en/timezones.php');
+ throw new \Lampcms\DevException('Invalid name of "SERVER_TIMEZONE" in !config.ini constant. The list of valid timezone names can be found here: http://us.php.net/manual/en/timezones.php');
}
/**
@@ -233,35 +236,35 @@ function LampcmsErrorHandler($errno, $errstr, $errfile, $errline)
$debug = $Ini->DEBUG;
if ($debug || isset($aMyIPs[$myIP]) || defined('SPECIAL_LOG_FILE')) {
- define('LAMPCMS_DEBUG', true);
- error_reporting(E_ALL | E_DEPRECATED);
- ini_set('display_errors', 1);
- ini_set('display_startup_errors', 1);
- ini_set('warn_plus_overloading', 1);
- /**
- * Turn on session garbage collection
- * to be run at every session start
- * to give us consistant behaviour
- * in debug mode
- * Session expiration is 5 minutes
- * which means when logged in without
- * using "remember me" option,
- * you supposed to be logged out after 5 minutes
- * of inactivity. The only way to test it
- * is to login, then after 6-7 minutes access site
- * with a different browser. Then go to the browser with logged
- * in user and try to use any other link. User should not
- * be logged in anymore at this time.
- */
- ini_set("session.gc_maxlifetime", "300");
- ini_set('session.gc_probability', "1");
- ini_set('session.gc_divisor', "1");
+ define('LAMPCMS_DEBUG', true);
+ error_reporting(E_ALL | E_DEPRECATED);
+ ini_set('display_errors', 1);
+ ini_set('display_startup_errors', 1);
+ ini_set('warn_plus_overloading', 1);
+ /**
+ * Turn on session garbage collection
+ * to be run at every session start
+ * to give us consistant behaviour
+ * in debug mode
+ * Session expiration is 5 minutes
+ * which means when logged in without
+ * using "remember me" option,
+ * you supposed to be logged out after 5 minutes
+ * of inactivity. The only way to test it
+ * is to login, then after 6-7 minutes access site
+ * with a different browser. Then go to the browser with logged
+ * in user and try to use any other link. User should not
+ * be logged in anymore at this time.
+ */
+ ini_set("session.gc_maxlifetime", "300");
+ ini_set('session.gc_probability', "1");
+ ini_set('session.gc_divisor', "1");
} else {
- define('LAMPCMS_DEBUG', false);
- error_reporting(E_ALL ^ E_WARNING);
- ini_set('display_errors', 0);
- ini_set('display_startup_errors', 0);
- ini_set('warn_plus_overloading', 0);
+ define('LAMPCMS_DEBUG', false);
+ error_reporting(E_ALL ^ E_WARNING);
+ ini_set('display_errors', 0);
+ ini_set('display_startup_errors', 0);
+ ini_set('warn_plus_overloading', 0);
}
define('LOG_FILE_PATH', $Ini->LOG_FILE_PATH);
@@ -275,24 +278,26 @@ function LampcmsErrorHandler($errno, $errstr, $errfile, $errline)
* will return string '1' for true
* or empty string for false
*/
-if((true === LAMPCMS_DEBUG) && ('' !== LOG_FILE_PATH) && (true === (bool)$Ini->LOG_PER_SCRIPT) && !\Lampcms\Request::isAjax()){
+if ((true === LAMPCMS_DEBUG) && ('' !== LOG_FILE_PATH) && (true === (bool)$Ini->LOG_PER_SCRIPT) && !\Lampcms\Request::isAjax()) {
- file_put_contents(LOG_FILE_PATH, PHP_SAPI.' '.print_r($_SERVER, 1), LOCK_EX);
+ file_put_contents(LOG_FILE_PATH, PHP_SAPI . ' ' . print_r($_SERVER, 1), LOCK_EX);
}
/**
* Shortcuts to log debug and log error
* MUST BE CALLED after DEBUG MODE and LOG_FILE_PATH
* has been defined
*/
-function d($message){
- if(defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG){
- \Lampcms\Log::d($message, 2);
- }
+function d($message)
+{
+ if (defined('LAMPCMS_DEBUG') && true === LAMPCMS_DEBUG) {
+ \Lampcms\Log::d($message, 2);
+ }
}
-function e($message){
- \Lampcms\Log::e($message, 2);
+function e($message)
+{
+ \Lampcms\Log::e($message, 2);
}
Oops, something went wrong.

0 comments on commit d3f7f22

Please sign in to comment.