Commit 458767fb authored by jwarnier's avatar jwarnier
Browse files

- replace double-quotes with single-quotes whenever appropriate

- reword some output
- fix typos
parent 85c4e5c1
...@@ -29,18 +29,18 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -29,18 +29,18 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
class db class db
{ {
var $dbHost = ""; // hostname of the MySQL server var $dbHost = ''; // hostname of the MySQL server
var $dbName = ""; // logical database name on that server var $dbName = ''; // logical database name on that server
var $dbUser = ""; // database authorized user var $dbUser = ''; // database authorized user
var $dbPass = ""; // user's password var $dbPass = ''; // user's password
var $linkId = 0; // last result of mysql_connect() var $linkId = 0; // last result of mysql_connect()
var $queryId = 0; // last result of mysql_query() var $queryId = 0; // last result of mysql_query()
var $record = array(); // last record fetched var $record = array(); // last record fetched
var $autoCommit = 1; // Autocommit Transactions var $autoCommit = 1; // Autocommit Transactions
var $currentRow; // current row number var $currentRow; // current row number
var $errorNumber = 0; // last error number var $errorNumber = 0; // last error number
var $errorMessage = ""; // last error message var $errorMessage = ''; // last error message
var $errorLocation = "";// last error location var $errorLocation = '';// last error location
var $show_error_messages = true; var $show_error_messages = true;
// constructor // constructor
...@@ -48,10 +48,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -48,10 +48,10 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{ {
global $conf; global $conf;
$this->dbHost = $conf["db_host"]; $this->dbHost = $conf['db_host'];
$this->dbName = $conf["db_database"]; $this->dbName = $conf['db_database'];
$this->dbUser = $conf["db_user"]; $this->dbUser = $conf['db_user'];
$this->dbPass = $conf["db_password"]; $this->dbPass = $conf['db_password'];
$this->dbCharset = $conf['db_charset']; $this->dbCharset = $conf['db_charset'];
//$this->connect(); //$this->connect();
} }
...@@ -66,7 +66,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -66,7 +66,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
if($this->errorNumber && $this->show_error_messages && method_exists($app,'log')) if($this->errorNumber && $this->show_error_messages && method_exists($app,'log'))
{ {
// echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage); // echo('<br /><b>'.$this->errorLocation.'</b><br />'.$this->errorMessage);
$app->log($this->errorLocation." ".$this->errorMessage,LOGLEVEL_WARN); $app->log($this->errorLocation.' '.$this->errorMessage,LOGLEVEL_WARN);
//flush(); //flush();
} }
} }
...@@ -282,16 +282,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -282,16 +282,16 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
unset($tmp); unset($tmp);
// Insert the server_id, if the record has a server_id // Insert the server_id, if the record has a server_id
$server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0; $server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"]; if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
if($diff_num > 0) { if($diff_num > 0) {
//print_r($diff_num); //print_r($diff_num);
//print_r($diffrec_full); //print_r($diffrec_full);
$diffstr = $app->db->quote(serialize($diffrec_full)); $diffstr = $app->db->quote(serialize($diffrec_full));
$username = $app->db->quote($_SESSION["s"]["user"]["username"]); $username = $app->db->quote($_SESSION['s']['user']['username']);
$dbidx = $primary_field.":".$primary_id; $dbidx = $primary_field.':'.$primary_id;
if($action == 'INSERT') $action = 'i'; if($action == 'INSERT') $action = 'i';
if($action == 'UPDATE') $action = 'u'; if($action == 'UPDATE') $action = 'u';
...@@ -383,27 +383,27 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -383,27 +383,27 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
function createTable($table_name,$columns) { function createTable($table_name,$columns) {
$index = ""; $index = '';
$sql = "CREATE TABLE $table_name ("; $sql = "CREATE TABLE $table_name (";
foreach($columns as $col){ foreach($columns as $col){
$sql .= $col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." "; $sql .= $col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
if($col["notNull"] == true) { if($col['notNull'] == true) {
$sql .= "NOT NULL "; $sql .= 'NOT NULL ';
} else { } else {
$sql .= "NULL "; $sql .= 'NULL ';
} }
if($col["autoInc"] == true) $sql .= "auto_increment "; if($col['autoInc'] == true) $sql .= 'auto_increment ';
$sql.= ","; $sql.= ',';
// key Definitionen // key Definitionen
if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),";
if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),";
if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),";
} }
$sql .= $index; $sql .= $index;
$sql = substr($sql,0,-1); $sql = substr($sql,0,-1);
$sql .= ")"; $sql .= ')';
$this->query($sql); $this->query($sql);
return true; return true;
...@@ -423,29 +423,29 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -423,29 +423,29 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
function alterTable($table_name,$columns) { function alterTable($table_name,$columns) {
$index = ""; $index = '';
$sql = "ALTER TABLE $table_name "; $sql = "ALTER TABLE $table_name ";
foreach($columns as $col){ foreach($columns as $col){
if($col["action"] == 'add') { if($col['action'] == 'add') {
$sql .= "ADD ".$col["name"]." ".$this->mapType($col["type"],$col["typeValue"])." "; $sql .= "ADD ".$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
} elseif ($col["action"] == 'alter') { } elseif ($col['action'] == 'alter') {
$sql .= "CHANGE ".$col["name"]." ".$col["name_new"]." ".$this->mapType($col["type"],$col["typeValue"])." "; $sql .= "CHANGE ".$col['name']." ".$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
} elseif ($col["action"] == 'drop') { } elseif ($col['action'] == 'drop') {
$sql .= "DROP ".$col["name"]." "; $sql .= "DROP ".$col['name'].' ';
} }
if($col["action"] != 'drop') { if($col['action'] != 'drop') {
if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' "; if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
if($col["notNull"] == true) { if($col['notNull'] == true) {
$sql .= "NOT NULL "; $sql .= 'NOT NULL ';
} else { } else {
$sql .= "NULL "; $sql .= 'NULL ';
} }
if($col["autoInc"] == true) $sql .= "auto_increment "; if($col['autoInc'] == true) $sql .= 'auto_increment ';
$sql.= ","; $sql.= ',';
// key Definitionen // key Definitionen
if($col["option"] == "primary") $index .= "PRIMARY KEY (".$col["name"]."),"; if($col['option'] == 'primary') $index .= "PRIMARY KEY (".$col['name']."),";
if($col["option"] == "index") $index .= "INDEX (".$col["name"]."),"; if($col['option'] == 'index') $index .= "INDEX (".$col['name']."),";
if($col["option"] == "unique") $index .= "UNIQUE (".$col["name"]."),"; if($col['option'] == 'unique') $index .= "UNIQUE (".$col['name']."),";
} }
} }
$sql .= $index; $sql .= $index;
...@@ -505,38 +505,38 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -505,38 +505,38 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$column = array(); $column = array();
$column["name"] = $name; $column['name'] = $name;
//$column["type"] = $type; //$column['type'] = $type;
$column["defaultValue"] = $default; $column['defaultValue'] = $default;
if(stristr($key,"PRI")) $column["option"] = "primary"; if(stristr($key,'PRI')) $column['option'] = 'primary';
if(stristr($isnull,"YES")) { if(stristr($isnull,'YES')) {
$column["notNull"] = false; $column['notNull'] = false;
} else { } else {
$column["notNull"] = true; $column['notNull'] = true;
} }
if($extra == 'auto_increment') $column["autoInc"] = true; if($extra == 'auto_increment') $column['autoInc'] = true;
// Type in Metatype umsetzen // Type in Metatype umsetzen
if(stristr($type,"int(")) $metaType = 'int32'; if(stristr($type,'int(')) $metaType = 'int32';
if(stristr($type,"bigint")) $metaType = 'int64'; if(stristr($type,'bigint')) $metaType = 'int64';
if(stristr($type,"char")) { if(stristr($type,'char')) {
$metaType = 'char'; $metaType = 'char';
$tmp_typeValue = explode('(',$type); $tmp_typeValue = explode('(',$type);
$column["typeValue"] = substr($tmp_typeValue[1],0,-1); $column['typeValue'] = substr($tmp_typeValue[1],0,-1);
} }
if(stristr($type,"varchar")) { if(stristr($type,'varchar')) {
$metaType = 'varchar'; $metaType = 'varchar';
$tmp_typeValue = explode('(',$type); $tmp_typeValue = explode('(',$type);
$column["typeValue"] = substr($tmp_typeValue[1],0,-1); $column['typeValue'] = substr($tmp_typeValue[1],0,-1);
} }
if(stristr($type,"text")) $metaType = 'text'; if(stristr($type,'text')) $metaType = 'text';
if(stristr($type,"double")) $metaType = 'double'; if(stristr($type,'double')) $metaType = 'double';
if(stristr($type,"blob")) $metaType = 'blob'; if(stristr($type,'blob')) $metaType = 'blob';
$column["type"] = $metaType; $column['type'] = $metaType;
$columns[] = $column; $columns[] = $column;
} }
...@@ -595,7 +595,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -595,7 +595,7 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
return 'char'; return 'char';
break; break;
case 'varchar': case 'varchar':
if($typeValue < 1) die("Datenbank Fehler: Für diesen Datentyp ist eine Längenangabe notwendig."); if($typeValue < 1) die('Database failure: Lenght required for these data types.');
return 'varchar('.$typeValue.')'; return 'varchar('.$typeValue.')';
break; break;
case 'text': case 'text':
...@@ -609,4 +609,4 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ...@@ -609,4 +609,4 @@ EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
} }
?> ?>
\ No newline at end of file
...@@ -33,14 +33,14 @@ class file{ ...@@ -33,14 +33,14 @@ class file{
function rf($file){ function rf($file){
global $app; global $app;
clearstatcache(); clearstatcache();
if(!$fp = fopen ($file, "rb")){ if(!$fp = fopen ($file, 'rb')){
$app->log("WARNING: could not open file ".$file, 2); $app->log('WARNING: Could not open file '.$file, 2);
return false; return false;
} else { } else {
if(filesize($file) > 0){ if(filesize($file) > 0){
$content = fread($fp, filesize($file)); $content = fread($fp, filesize($file));
} else { } else {
$content = ""; $content = '';
} }
fclose($fp); fclose($fp);
return $content; return $content;
...@@ -50,8 +50,8 @@ class file{ ...@@ -50,8 +50,8 @@ class file{
function wf($file, $content){ function wf($file, $content){
global $app; global $app;
$this->mkdirs(dirname($file)); $this->mkdirs(dirname($file));
if(!$fp = fopen ($file, "wb")){ if(!$fp = fopen ($file, 'wb')){
$app->log("WARNING: could not open file ".$file, 2); $app->log('WARNING: Could not open file '.$file, 2);
return false; return false;
} else { } else {
fwrite($fp,$content); fwrite($fp,$content);
...@@ -63,8 +63,8 @@ class file{ ...@@ -63,8 +63,8 @@ class file{
function af($file, $content){ function af($file, $content){
global $app; global $app;
$this->mkdirs(dirname($file)); $this->mkdirs(dirname($file));
if(!$fp = fopen ($file, "ab")){ if(!$fp = fopen ($file, 'ab')){
$app->log("WARNING: could not open file ".$file, 2); $app->log('WARNING: Could not open file '.$file, 2);
return false; return false;
} else { } else {
fwrite($fp,$content); fwrite($fp,$content);
...@@ -83,7 +83,7 @@ class file{ ...@@ -83,7 +83,7 @@ class file{
if($pos != 0){ if($pos != 0){
$new_lines[] = substr($line,0,$pos); $new_lines[] = substr($line,0,$pos);
} else { } else {
$new_lines[] = ""; $new_lines[] = '';
} }
} else { } else {
$new_lines[] = $line; $new_lines[] = $line;
...@@ -95,7 +95,7 @@ class file{ ...@@ -95,7 +95,7 @@ class file{
$new_lines = NULL; $new_lines = NULL;
return $content_without_comments; return $content_without_comments;
} else { } else {
return ""; return '';
} }
} }
...@@ -106,7 +106,7 @@ class file{ ...@@ -106,7 +106,7 @@ class file{
$manual = "\n".trim($parts[1]); $manual = "\n".trim($parts[1]);
return $manual; return $manual;
} else { } else {
return ""; return '';
} }
} }
...@@ -120,13 +120,13 @@ class file{ ...@@ -120,13 +120,13 @@ class file{
$lines = explode("\n", $content); $lines = explode("\n", $content);
if(!empty($lines)){ if(!empty($lines)){
foreach($lines as $line){ foreach($lines as $line){
if(trim($line) != "") $new_lines[] = $line; if(trim($line) != '') $new_lines[] = $line;
} }
} }
if(is_array($new_lines)){ if(is_array($new_lines)){
$content = implode("\n", $new_lines); $content = implode("\n", $new_lines);
} else { } else {
$content = ""; $content = '';
} }
if($file){ if($file){
$this->wf($input, $content); $this->wf($input, $content);
...@@ -160,17 +160,17 @@ class file{ ...@@ -160,17 +160,17 @@ class file{
function edit_dist($var, $val){ function edit_dist($var, $val){
global $$var; global $$var;
$files = array("/root/ispconfig/dist.inc.php"); $files = array('/root/ispconfig/dist.inc.php');
foreach($files as $file){ foreach($files as $file){
if(is_file($file)){ if(is_file($file)){
$file_content = $this->unix_nl($this->rf($file)); $file_content = $this->unix_nl($this->rf($file));
$lines = explode("\n", $file_content); $lines = explode("\n", $file_content);
for($i=0;$i<sizeof($lines);$i++){ for($i=0;$i<sizeof($lines);$i++){
$parts = explode("=", $lines[$i]); $parts = explode('=', $lines[$i]);
if($parts[0] == $var || $parts[0] == '$'.$var.' '){ if($parts[0] == $var || $parts[0] == '$'.$var.' '){
$parts[1] = str_replace($$var, $val, $parts[1]); $parts[1] = str_replace($$var, $val, $parts[1]);
} }
$lines[$i] = implode("=", $parts); $lines[$i] = implode('=', $parts);
} }
$file_content = implode("\n", $lines); $file_content = implode("\n", $lines);
$this->wf($file, $file_content); $this->wf($file, $file_content);
...@@ -178,7 +178,7 @@ class file{ ...@@ -178,7 +178,7 @@ class file{
} }
} }
function getDirectoryListing($dirname, $sortorder = "a", $show_subdirs = 0, $show_subdirfiles = 0, $exts = "", $ext_save = 1){ function getDirectoryListing($dirname, $sortorder = 'a', $show_subdirs = 0, $show_subdirfiles = 0, $exts = '', $ext_save = 1){
// This function will return an array with filenames based on the criteria you can set in the variables // This function will return an array with filenames based on the criteria you can set in the variables
// @sortorder : a for ascending (the standard) or d for descending (you can use the "r" for reverse as well, works the same) // @sortorder : a for ascending (the standard) or d for descending (you can use the "r" for reverse as well, works the same)
// @show_subdirs : 0 for NO, 1 for YES - meaning it will show the names of subdirectories if there are any // @show_subdirs : 0 for NO, 1 for YES - meaning it will show the names of subdirectories if there are any
...@@ -190,33 +190,33 @@ class file{ ...@@ -190,33 +190,33 @@ class file{
// @ext_save : 1 for YES, 0 for NO - meaning it will filter out system files or not (such as .htaccess) // @ext_save : 1 for YES, 0 for NO - meaning it will filter out system files or not (such as .htaccess)
$dirname = realpath($dirname); $dirname = realpath($dirname);
if (!$exts || empty($exts) || $exts == "") { if (!$exts || empty($exts) || $exts == '') {
$exts = array("jpg", "gif", "jpeg", "png"); $exts = array('jpg', 'gif', 'jpeg', 'png');
} }
if ($handle = opendir($dirname)) { if ($handle = opendir($dirname)) {
$filelist = array(); $filelist = array();
while (false !== ($file = readdir($handle))) { while (false !== ($file = readdir($handle))) {
// Filter out higher directory references // Filter out higher directory references
if ($file != "." && $file != "..") { if ($file != '.' && $file != '..') {
// Only look at directories or files, filter out symbolic links // Only look at directories or files, filter out symbolic links
if ( filetype ($dirname."/".$file) != "link") { if ( filetype ($dirname.'/'.$file) != 'link') {
// If it's a file, check against valid extentions and add to the list // If it's a file, check against valid extentions and add to the list
if ( filetype ($dirname."/".$file) == "file" ) { if ( filetype ($dirname.'/'.$file) == 'file' ) {
if ($this->checkFileExtension($file, $exts, $ext_save)) { if ($this->checkFileExtension($file, $exts, $ext_save)) {
$filelist[] = $file; $filelist[] = $file;
} }
} }
// If it's a directory and either subdirs should be listed or files from subdirs add relevant names to the list // If it's a directory and either subdirs should be listed or files from subdirs add relevant names to the list
else if ( filetype ($dirname."/".$file) == "dir" && ($show_subdirs == 1 || $show_subdirfiles == 1)) { else if ( filetype ($dirname.'/'.$file) == 'dir' && ($show_subdirs == 1 || $show_subdirfiles == 1)) {
if ($show_subdirs == 1) { if ($show_subdirs == 1) {
$filelist[] = $file; $filelist[] = $file;
} }
if ($show_subdirfiles == 1) { if ($show_subdirfiles == 1) {
$subdirname = $file; $subdirname = $file;
$subdirfilelist = $this->getDirectoryListing($dirname."/".$subdirname."/", $sortorder, $show_subdirs, $show_subdirfiles, $exts, $ext_save); $subdirfilelist = $this->getDirectoryListing($dirname.'/'.$subdirname.'/', $sortorder, $show_subdirs, $show_subdirfiles, $exts, $ext_save);
for ($i = 0 ; $i < count($subdirfilelist) ; $i++) { for ($i = 0 ; $i < count($subdirfilelist) ; $i++) {
$subdirfilelist[$i] = $subdirname."/".$subdirfilelist[$i]; $subdirfilelist[$i] = $subdirname.'/'.$subdirfilelist[$i];
} }
$filelist = array_merge($filelist, $subdirfilelist); $filelist = array_merge($filelist, $subdirfilelist);
} }
...@@ -231,7 +231,7 @@ class file{ ...@@ -231,7 +231,7 @@ class file{
// Sort the results // Sort the results
if (count($filelist) > 1) { if (count($filelist) > 1) {
natcasesort($filelist); natcasesort($filelist);
if ($sortorder == "d" || $sortorder == "r" ) { if ($sortorder == 'd' || $sortorder == 'r' ) {
$filelist = array_reverse($filelist, TRUE); $filelist = array_reverse($filelist, TRUE);
} }
} }
...@@ -249,7 +249,7 @@ class file{ ...@@ -249,7 +249,7 @@ class file{
return $passed; return $passed;
} }
} }
if ($exts == "all") { if ($exts == 'all') {
$passed = TRUE; $passed = TRUE;
return $passed; return $passed;
} }
......
...@@ -38,8 +38,8 @@ class getconf { ...@@ -38,8 +38,8 @@ class getconf {
if(!is_array($this->config[$server_id])) { if(!is_array($this->config[$server_id])) {
$app->uses('ini_parser'); $app->uses('ini_parser');
$server_id = intval($server_id); $server_id = intval($server_id);
$server = $app->db->queryOneRecord("SELECT config FROM server WHERE server_id = $server_id"); $server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
$this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server["config"])); $this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
} }
if($section == '') { if($section == '') {
...@@ -54,12 +54,12 @@ class getconf { ...@@ -54,12 +54,12 @@ class getconf {
if(!is_array($this->config['global'])) { if(!is_array($this->config['global'])) {
$app->uses('ini_parser'); $app->uses('ini_parser');
$tmp = $app->db->queryOneRecord("SELECT config FROM sys_ini WHERE sysini_id = 1"); $tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1');
$this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp["config"])); $this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp['config']));
} }
return ($section == '') ? $this->config['global'] : $this->config['global'][$section]; return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
} }
} }
?> ?>
\ No newline at end of file
...@@ -43,21 +43,21 @@ class modules { ...@@ -43,21 +43,21 @@ class modules {
$subPath = 'mods-enabled'; $subPath = 'mods-enabled';