mirror of
https://github.com/slawkens/myaac.git
synced 2025-10-14 01:34:55 +02:00
* remove whitespaces
This commit is contained in:
@@ -39,30 +39,30 @@ spl_autoload_register(function ($class) {
|
||||
});
|
||||
|
||||
function is_sub_dir($path = NULL, $parent_folder = SITE_PATH) {
|
||||
|
||||
|
||||
//Get directory path minus last folder
|
||||
$dir = dirname($path);
|
||||
$folder = substr($path, strlen($dir));
|
||||
|
||||
|
||||
//Check the the base dir is valid
|
||||
$dir = realpath($dir);
|
||||
|
||||
|
||||
//Only allow valid filename characters
|
||||
$folder = preg_replace('/[^a-z0-9\.\-_]/i', '', $folder);
|
||||
|
||||
|
||||
//If this is a bad path or a bad end folder name
|
||||
if( !$dir OR !$folder OR $folder === '.') {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
//Rebuild path
|
||||
$path = $dir. '/' . $folder;
|
||||
|
||||
|
||||
//If this path is higher than the parent folder
|
||||
if( strcasecmp($path, $parent_folder) > 0 ) {
|
||||
return $path;
|
||||
}
|
||||
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -311,7 +311,7 @@ class Plugins {
|
||||
self::$error = "You cannot use absolute paths (starting with slash - '/'): " . $file;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
$file = str_replace('\\', '/', BASE . $file);
|
||||
$realpath = str_replace('\\', '/', realpath(dirname($file)));
|
||||
if(!is_sub_dir($file, BASE) || $realpath != dirname($file)) {
|
||||
@@ -320,7 +320,7 @@ class Plugins {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($success) {
|
||||
foreach($plugin_info['uninstall'] as $file) {
|
||||
if(!deleteDirectory(BASE . $file)) {
|
||||
@@ -328,7 +328,7 @@ class Plugins {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (isset($plugin_info['hooks'])) {
|
||||
foreach ($plugin_info['hooks'] as $_name => $info) {
|
||||
if (defined('HOOK_'. $info['type'])) {
|
||||
@@ -387,7 +387,7 @@ class Plugins {
|
||||
public static function getPlugin() {
|
||||
return self::$plugin;
|
||||
}
|
||||
|
||||
|
||||
public static function removeComments($string) {
|
||||
$string = preg_replace('!/\*.*?\*/!s', '', $string);
|
||||
$string = preg_replace('/\n\s*\n/', "\n", $string);
|
||||
@@ -400,7 +400,7 @@ class Plugins {
|
||||
|
||||
// Strip blank lines
|
||||
$string = preg_replace("/(^[\r\n]*|[\r\n]+)[\s\t]*[\r\n]+/", "\n", $string);
|
||||
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
@@ -14,18 +14,18 @@
|
||||
|
||||
/**
|
||||
* Base class for all database drivers.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* It defines additional rotines required by database driver for POT using default SQL standard-compliant method.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
*/
|
||||
abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
{
|
||||
/**
|
||||
* Tables prefix.
|
||||
*
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $prefix = '';
|
||||
@@ -42,7 +42,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
|
||||
/**
|
||||
* Query-quoted field name.
|
||||
*
|
||||
*
|
||||
* @param string $name Field name.
|
||||
* @return string Quoted name.
|
||||
*/
|
||||
@@ -67,7 +67,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
|
||||
/**
|
||||
* Query-quoted table name.
|
||||
*
|
||||
*
|
||||
* @param string $name Table name.
|
||||
* @return string Quoted name.
|
||||
*/
|
||||
@@ -242,7 +242,7 @@ abstract class OTS_Base_DB extends PDO implements IOTS_DB
|
||||
public function queries() {
|
||||
return $this->queries;
|
||||
}
|
||||
|
||||
|
||||
public function getLog() {
|
||||
return $this->log;
|
||||
}
|
||||
|
@@ -14,11 +14,11 @@
|
||||
|
||||
/**
|
||||
* MySQL connection interface.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* At all everything that you really need to read from this class documentation is list of parameters for driver's constructor.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* @package POT
|
||||
* @version 0.1.3
|
||||
*/
|
||||
@@ -28,15 +28,15 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
private $has_column_cache = array();
|
||||
/**
|
||||
* Creates database connection.
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* Connects to MySQL database on given arguments.
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <p>
|
||||
* List of parameters for this drivers:
|
||||
* </p>
|
||||
*
|
||||
*
|
||||
* <ul>
|
||||
* <li><var>host</var> - database server.</li>
|
||||
* <li><var>port</var> - port (optional, also it is possible to use host:port in <var>host</var> parameter).</li>
|
||||
@@ -44,7 +44,7 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
* <li><var>user</var> - user login.</li>
|
||||
* <li><var>password</var> - user password.</li>
|
||||
* </ul>
|
||||
*
|
||||
*
|
||||
* @version 0.0.6
|
||||
* @param array $params Connection parameters.
|
||||
* @throws PDOException On PDO operation error.
|
||||
@@ -138,7 +138,7 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
|
||||
/**
|
||||
* Query-quoted field name.
|
||||
*
|
||||
*
|
||||
* @param string $name Field name.
|
||||
* @return string Quoted name.
|
||||
*/
|
||||
@@ -149,7 +149,7 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
|
||||
/**
|
||||
* LIMIT/OFFSET clause for queries.
|
||||
*
|
||||
*
|
||||
* @param int|bool $limit Limit of rows to be affected by query (false if no limit).
|
||||
* @param int|bool $offset Number of rows to be skipped before applying query effects (false if no offset).
|
||||
* @return string LIMIT/OFFSET SQL clause for query.
|
||||
@@ -182,20 +182,20 @@ class OTS_DB_MySQL extends OTS_Base_DB
|
||||
|
||||
return $this->hasTableInternal($name);
|
||||
}
|
||||
|
||||
|
||||
private function hasTableInternal($name) {
|
||||
global $config;
|
||||
return ($this->has_table_cache[$name] = $this->query("SELECT `TABLE_NAME` FROM `information_schema`.`tables` WHERE `TABLE_SCHEMA` = " . $this->quote($config['database_name']) . " AND `TABLE_NAME` = " . $this->quote($name) . " LIMIT 1;")->rowCount() > 0);
|
||||
}
|
||||
|
||||
|
||||
public function hasColumn($table, $column) {
|
||||
if(isset($this->has_column_cache[$table . '.' . $column])) {
|
||||
return $this->has_column_cache[$table . '.' . $column];
|
||||
}
|
||||
|
||||
|
||||
return $this->hasColumnInternal($table, $column);
|
||||
}
|
||||
|
||||
|
||||
private function hasColumnInternal($table, $column) {
|
||||
return $this->hasTable($table) && ($this->has_column_cache[$table . '.' . $column] = count($this->query("SHOW COLUMNS FROM `" . $table . "` LIKE '" . $column . "'")->fetchAll()) > 0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user