Skip to content

Commit 12fcb24

Browse files
author
jwarnier
committed
- replace double-quotes with single-quotes whenever appropriate
- fix indentation - get it nearer than similar server/lib/ files
1 parent 734d280 commit 12fcb24

File tree

5 files changed

+101
-105
lines changed

5 files changed

+101
-105
lines changed

interface/lib/classes/db_mysql.inc.php

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<?php
2-
32
/*
43
Copyright (c) 2007, Till Brehm, projektfarm Gmbh
54
All rights reserved.
@@ -33,11 +32,11 @@ class db {
3332
private $dbName = ''; // logical database name on that server
3433
private $dbUser = ''; // database authorized user
3534
private $dbPass = ''; // user's password
36-
private $dbCharset = ""; // what charset comes and goes to mysql: utf8 / latin1
35+
private $dbCharset = ''; // what charset comes and goes to mysql: utf8 / latin1
3736
private $linkId = 0; // last result of mysql_connect()
3837
private $queryId = 0; // last result of mysql_query()
3938
private $record = array(); // last record fetched
40-
private $autoCommit = 1; // Autocommit Transactions
39+
private $autoCommit = 1; // Autocommit Transactions
4140
private $currentRow; // current row number
4241
private $errorNumber = 0; // last error number
4342
public $errorMessage = ''; // last error message
@@ -68,7 +67,7 @@ public function updateError($location)
6867
}
6968

7069
public function connect()
71-
{
70+
{
7271
if($this->linkId == 0){
7372
$this->linkId = mysql_connect($this->dbHost, $this->dbUser, $this->dbPass);
7473
if(!$this->linkId){
@@ -82,7 +81,7 @@ public function connect()
8281
}
8382

8483
public function query($queryString)
85-
{
84+
{
8685
if(!$this->connect()){
8786
return false;
8887
}
@@ -101,7 +100,7 @@ public function query($queryString)
101100

102101
/** Returns all records as an array */
103102
public function queryAllRecords($queryString)
104-
{
103+
{
105104
if(!$this->query($queryString)){
106105
return false;
107106
}
@@ -114,7 +113,7 @@ public function queryAllRecords($queryString)
114113

115114
/** Returns one row as an array */
116115
public function queryOneRecord($queryString)
117-
{
116+
{
118117
if(!$this->query($queryString) || $this->numRows() == 0){
119118
return false;
120119
}
@@ -123,8 +122,8 @@ public function queryOneRecord($queryString)
123122

124123
/** Returns the next record as an array */
125124
public function nextRecord()
126-
{
127-
$this->record = mysql_fetch_assoc($this->queryId);
125+
{
126+
$this->record = mysql_fetch_assoc($this->queryId);
128127
$this->updateError('DB::nextRecord()<br />mysql_fetch_array');
129128
if(!$this->record || !is_array($this->record)){
130129
return false;
@@ -146,7 +145,7 @@ public function affectedRows()
146145

147146
/** Returns the last mySQL insert_id() */
148147
public function insertID()
149-
{
148+
{
150149
return mysql_insert_id($this->linkId);
151150
}
152151

@@ -217,7 +216,7 @@ public function update($tablename, $form, $bedingung, $debug = 0)
217216
}
218217
}
219218
*/
220-
219+
221220
public function diffrec($record_old, $record_new) {
222221
$diffrec_full = array();
223222
$diff_num = 0;
@@ -270,16 +269,16 @@ public function datalogSave($db_table, $action, $primary_field, $primary_id, $re
270269
unset($tmp);
271270

272271
// Insert the server_id, if the record has a server_id
273-
$server_id = (isset($record_old["server_id"]) && $record_old["server_id"] > 0)?$record_old["server_id"]:0;
274-
if(isset($record_new["server_id"])) $server_id = $record_new["server_id"];
272+
$server_id = (isset($record_old['server_id']) && $record_old['server_id'] > 0)?$record_old['server_id']:0;
273+
if(isset($record_new['server_id'])) $server_id = $record_new['server_id'];
275274

276275

277276
if($diff_num > 0) {
278277
//print_r($diff_num);
279278
//print_r($diffrec_full);
280279
$diffstr = $app->db->quote(serialize($diffrec_full));
281-
$username = $app->db->quote($_SESSION["s"]["user"]["username"]);
282-
$dbidx = $primary_field.":".$primary_id;
280+
$username = $app->db->quote($_SESSION['s']['user']['username']);
281+
$dbidx = $primary_field.':'.$primary_id;
283282

284283
if($action == 'INSERT') $action = 'i';
285284
if($action == 'UPDATE') $action = 'u';
@@ -327,8 +326,8 @@ public function datalogDelete($tablename, $index_field, $index_value) {
327326

328327
return true;
329328
}
330-
331-
329+
330+
332331

333332
public function closeConn()
334333
{
@@ -338,7 +337,7 @@ public function closeConn()
338337
return true;
339338
} else { return false; }
340339
}
341-
340+
342341
public function freeResult($query)
343342
{
344343
if(mysql_free_result($query))
@@ -406,10 +405,10 @@ public function createTable($table_name, $columns)
406405
if(isset($col['option']) && $col['option'] == 'primary'){ $index .= 'PRIMARY KEY ('.$col['name'].'),'; }
407406
if(isset($col['option']) && $col['option'] == 'index'){ $index .= 'INDEX ('.$col['name'].'),'; }
408407
if(isset($col['option']) && $col['option'] == 'unique'){ $index .= 'UNIQUE ('.$col['name'].'),'; }
409-
}
408+
}
410409
$sql .= $index;
411410
$sql = substr($sql,0,-1);
412-
$sql .= ')';
411+
$sql .= ')';
413412
$this->query($sql);
414413
return true;
415414
}
@@ -428,36 +427,36 @@ public function createTable($table_name, $columns)
428427
*/
429428
public function alterTable($table_name,$columns)
430429
{
431-
$index = '';
432-
$sql = "ALTER TABLE $table_name ";
433-
foreach($columns as $col){
430+
$index = '';
431+
$sql = "ALTER TABLE $table_name ";
432+
foreach($columns as $col){
434433
if($col['action'] == 'add'){
435-
$sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'], $col['typeValue']).' ';
434+
$sql .= 'ADD '.$col['name'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
436435
}elseif($col['action'] == 'alter') {
437436
$sql .= 'CHANGE '.$col['name'].' '.$col['name_new'].' '.$this->mapType($col['type'],$col['typeValue']).' ';
438437
}elseif($col['action'] == 'drop') {
439438
$sql .= 'DROP '.$col['name'].' ';
440439
}
441-
if($col["action"] != 'drop') {
442-
if($col["defaultValue"] != "") $sql .= "DEFAULT '".$col["defaultValue"]."' ";
443-
if($col["notNull"] == true) {
444-
$sql .= "NOT NULL ";
440+
if($col['action'] != 'drop') {
441+
if($col['defaultValue'] != '') $sql .= "DEFAULT '".$col['defaultValue']."' ";
442+
if($col['notNull'] == true) {
443+
$sql .= 'NOT NULL ';
445444
} else {
446-
$sql .= "NULL ";
445+
$sql .= 'NULL ';
447446
}
448-
if($col["autoInc"] == true) $sql .= "auto_increment ";
449-
$sql.= ",";
447+
if($col['autoInc'] == true) $sql .= 'auto_increment ';
448+
$sql.= ',';
450449
//* Index definitions
451450
if($col['option'] == 'primary') $index .= 'PRIMARY KEY ('.$col['name'].'),';
452451
if($col['option'] == 'index') $index .= 'INDEX ('.$col['name'].'),';
453452
if($col['option'] == 'unique') $index .= 'UNIQUE ('.$col['name'].'),';
454453
}
455-
}
456-
$sql .= $index;
457-
$sql = substr($sql,0,-1);
458-
//die($sql);
459-
$this->query($sql);
460-
return true;
454+
}
455+
$sql .= $index;
456+
$sql = substr($sql,0,-1);
457+
//die($sql);
458+
$this->query($sql);
459+
return true;
461460
}
462461

463462
public function dropTable($table_name)
@@ -484,7 +483,7 @@ public function getTables($database_name = '')
484483

485484
public function tableInfo($table_name) {
486485
//* Tabellenfelder einlesen ?
487-
if($rows = $this->queryAllRecords("SHOW FIELDS FROM $table_name")){
486+
if($rows = $this->queryAllRecords('SHOW FIELDS FROM $table_name')){
488487
foreach($rows as $row) {
489488
$name = $row['Field'];
490489
$default = $row['Default'];
@@ -512,9 +511,9 @@ public function tableInfo($table_name) {
512511
$tmp_typeValue = explode('(',$type);
513512
$column['typeValue'] = substr($tmp_typeValue[1], 0, -1);
514513
}
515-
if(stristr($type, 'text')) $metaType = 'text';
516-
if(stristr($type, 'double')) $metaType = 'double';
517-
if(stristr($type, 'blob')) $metaType = 'blob';
514+
if(stristr($type,'text')) $metaType = 'text';
515+
if(stristr($type,'double')) $metaType = 'double';
516+
if(stristr($type,'blob')) $metaType = 'blob';
518517

519518
$column['type'] = $metaType;
520519
$columns[] = $column;
@@ -548,7 +547,7 @@ public function mapType($metaType, $typeValue) {
548547
return 'blob';
549548
}
550549
}
551-
550+
552551
}
553552

554-
?>
553+
?>

interface/lib/classes/getconf.inc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ class getconf {
3434

3535
public function get_server_config($server_id, $section = '') {
3636
global $app;
37-
37+
3838
if(!is_array($this->config[$server_id])) {
3939
$app->uses('ini_parser');
4040
$server_id = intval($server_id);
41-
$server = $app->db->queryOneRecord("SELECT config FROM server WHERE server_id = $server_id");
42-
$this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server["config"]));
41+
$server = $app->db->queryOneRecord('SELECT config FROM server WHERE server_id = '.$server_id);
42+
$this->config[$server_id] = $app->ini_parser->parse_ini_string(stripslashes($server['config']));
4343
}
4444
return ($section == '') ? $this->config[$server_id] : $this->config[$server_id][$section];
4545
}
@@ -49,11 +49,11 @@ public function get_global_config($section = '') {
4949

5050
if(!is_array($this->config['global'])) {
5151
$app->uses('ini_parser');
52-
$tmp = $app->db->queryOneRecord("SELECT config FROM sys_ini WHERE sysini_id = 1");
53-
$this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp["config"]));
52+
$tmp = $app->db->queryOneRecord('SELECT config FROM sys_ini WHERE sysini_id = 1');
53+
$this->config['global'] = $app->ini_parser->parse_ini_string(stripslashes($tmp['config']));
5454
}
5555
return ($section == '') ? $this->config['global'] : $this->config['global'][$section];
5656
}
5757
}
5858

59-
?>
59+
?>

interface/lib/classes/ini_parser.inc.php

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,13 @@
3131
class ini_parser{
3232

3333
private $config;
34-
34+
3535
//* Converts a ini string to array
3636
public function parse_ini_string($ini) {
3737
$ini = str_replace("\r\n", "\n", $ini);
3838
$lines = explode("\n", $ini);
3939
foreach($lines as $line) {
40-
$line = trim($line);
40+
$line = trim($line);
4141
if($line != '') {
4242
if(preg_match("/^\[([\w\d_]+)\]$/", $line, $matches)) {
4343
$section = strtolower($matches[1]);
@@ -49,8 +49,8 @@ public function parse_ini_string($ini) {
4949
}
5050
return $this->config;
5151
}
52-
53-
52+
53+
5454
//* Converts a config array to a string
5555
public function get_ini_string($config_array = '') {
5656
if($config_array == '') $config_array = $this->config;
@@ -61,17 +61,14 @@ public function get_ini_string($config_array = '') {
6161
if($item != ''){
6262
$value = trim($value);
6363
$item = trim($item);
64-
$content .= "$item=$value\n";
65-
}
64+
$content .= "$item=$value\n";
65+
}
6666
}
6767
$content .= "\n";
6868
}
6969
return $content;
7070
}
71-
72-
73-
74-
71+
7572
}
7673

77-
?>
74+
?>

interface/lib/classes/plugin.inc.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@ private function loadPluginCache() {
6363
//** load the plugins
6464
foreach($tmp_plugins as $plugin_name => $file) {
6565
include_once($plugins_dir.$file);
66-
if($this->debug) $app->log("Loading Plugin: $plugin_name",LOGLEVEL_DEBUG);
66+
if($this->debug) $app->log('Loading plugin: '.$plugin_name,LOGLEVEL_DEBUG);
6767
$app->loaded_plugins[$plugin_name] = new $plugin_name;
6868
$app->loaded_plugins[$plugin_name]->onLoad();
6969
}
7070
} else {
71-
$app->log("Unable to open the plugin directory: $plugins_dir",LOGLEVEL_ERROR);
71+
$app->log('Unable to open the plugins directory: '.$plugins_dir,LOGLEVEL_ERROR);
7272
}
7373
} else {
74-
$app->log("Plugin directory missing: $plugins_dir",LOGLEVEL_ERROR);
74+
$app->log('Plugins directory missing: '.$plugins_dir,LOGLEVEL_ERROR);
7575
}
7676

7777
}
@@ -98,7 +98,7 @@ public function raiseEvent($event_name,$data) {
9898

9999
if(!isset($_SESSION['s']['plugin_cache'])) {
100100
$this->loadPluginCache();
101-
if($this->debug) $app->log("Loaded the plugin cache.",LOGLEVEL_DEBUG);
101+
if($this->debug) $app->log('Loaded the plugin cache.',LOGLEVEL_DEBUG);
102102
}
103103

104104

@@ -131,7 +131,7 @@ public function raiseEvent($event_name,$data) {
131131
}
132132

133133
} // end function raiseEvent
134-
134+
135135
//* Internal function to load the plugin and call the event function in the plugin.
136136
private function callPluginEvent($event_name,$data) {
137137
global $app;
@@ -158,4 +158,4 @@ private function callPluginEvent($event_name,$data) {
158158

159159
}
160160

161-
?>
161+
?>

0 commit comments

Comments
 (0)