From 57e5c8cab648ee1fac7d2402ce9e607761446055 Mon Sep 17 00:00:00 2001 From: Joni Kokko Date: Mon, 1 Dec 2008 16:14:54 +0200 Subject: [PATCH] whitespaces removed from php-files --- database/php/index.php | 6 +- database/php/irreco_webdb_database.php | 172 ++++++++++++++++----------------- database/php/irreco_webdb_log.php | 76 +++++++-------- database/php/irreco_webdb_server.php | 168 ++++++++++++++++---------------- 4 files changed, 211 insertions(+), 211 deletions(-) diff --git a/database/php/index.php b/database/php/index.php index 3a81e96a..63b9bb71 100644 --- a/database/php/index.php +++ b/database/php/index.php @@ -1,4 +1,4 @@ -=")) { +if (!version_compare(phpversion(), "5.2.0", ">=")) { die("PHP " . $version . ' or later is required.'); } @@ -47,7 +47,7 @@ if (!isset($GLOBALS['HTTP_RAW_POST_DATA'])) { * Create XML-RPC server. */ -require_once 'irreco_webdb_database.php'; +require_once 'irreco_webdb_database.php'; require_once 'irreco_webdb_server.php'; $database = new IrrecoWebdbDatabase('mysqli://irreco:abcd@localhost/irreco'); diff --git a/database/php/irreco_webdb_database.php b/database/php/irreco_webdb_database.php index 70e413ad..d4e5ec68 100644 --- a/database/php/irreco_webdb_database.php +++ b/database/php/irreco_webdb_database.php @@ -1,4 +1,4 @@ - 2, 'result_buffering' => false); - + IrrecoLog::$database->log('Connecting to "' . $dsn . '".'); $this->db = MDB2::factory($dsn, $options); - + $this->db->setFetchMode(MDB2_FETCHMODE_OBJECT); if (PEAR::isError($this->db)) { IrrecoLog::critical($this->db->getMessage()); } } - + function __destruct() { if (is_object($this->db)) { $this->db->disconnect(); $this->db = NULL; } } - + /** * Run Query on database. Die on error. */ private function query($query) { - /* Make sure that we dont collect multiple result + /* Make sure that we dont collect multiple result sets in memory. */ if (is_object($this->previous_result_set)) { $this->previous_result_set->free(); $this->previous_result_set = NULL; } - + IrrecoLog::$database->log('Query: "' . $query . '"'); $result = $this->db->query($query); if (PEAR::isError($result)) { @@ -74,7 +74,7 @@ class IrrecoWebdbDatabase return $result; } } - + /** * Prepare Query on database. Die on error. */ @@ -85,7 +85,7 @@ class IrrecoWebdbDatabase $this->prepared_query->free(); $this->prepared_query = NULL; } - + IrrecoLog::$database->log('Prepare: "' . $query . '"'); $result = $this->db->prepare($query/*, $types, $prepare*/); if (PEAR::isError($result)) { @@ -95,19 +95,19 @@ class IrrecoWebdbDatabase return $result; } } - + /** * Execute Query on database. Die on error. */ private function execute($args) { - /* Make sure that we dont collect multiple result + /* Make sure that we dont collect multiple result sets in memory. */ if (is_object($this->previous_result_set)) { $this->previous_result_set->free(); $this->previous_result_set = NULL; } - + IrrecoLog::$database->log('Execute: "' . serialize($args) . '"'); $result = $this->prepared_query->execute($args); if (PEAR::isError($result)) { @@ -117,7 +117,7 @@ class IrrecoWebdbDatabase return $result; } } - + private function lockTable($table) { $this->query('LOCK TABLE ' . @@ -129,12 +129,12 @@ class IrrecoWebdbDatabase $this->execute($table); */ } - + private function unlockTables() { $this->query('UNLOCK TABLES'); } - + /** * Add user to database */ @@ -142,17 +142,17 @@ class IrrecoWebdbDatabase { IrrecoLog::$database->log('Add user: "' . $name . '" to table "' . $table . '".'); - + /* Lock table */ $this->lockTable($table); - + /* Check for same name already at DB */ $data = $this->getNameId($table, $name); if ($data != "") { IrrecoLog::$database->log('Name already at database.'); return FALSE; } - + /* insert data */ $this->query("INSERT INTO " . $this->db->quoteIdentifier($table, 'text'). @@ -164,9 +164,9 @@ class IrrecoWebdbDatabase /* Unlock table */ $this->unlockTables(); - + IrrecoLog::$database->log('Done.'); - + return TRUE; } @@ -184,11 +184,11 @@ class IrrecoWebdbDatabase if($user_agent != $rows[0]->user_agent) { $this->query('INSERT INTO user_agent (user_agent, date, count) VALUES('. - $this->db->quote($user_agent, 'text').', CURDATE(), 1)'); + $this->db->quote($user_agent, 'text').', CURDATE(), 1)'); } else{ $this->query('UPDATE user_agent SET count = count+1 WHERE user_agent = '. - $this->db->quote($user_agent, 'text').' AND date= CURDATE()'); + $this->db->quote($user_agent, 'text').' AND date= CURDATE()'); } } @@ -208,13 +208,13 @@ class IrrecoWebdbDatabase * @param string file_data Content of file * @return string */ - function uploadConfiguration($backend, + function uploadConfiguration($backend, $category, - $manufacturer, + $manufacturer, $model, $user, $password, - $file_hash, + $file_hash, $file_name, $file_data) { @@ -223,11 +223,11 @@ class IrrecoWebdbDatabase if($user_id == NULL) { return('username and password mismatch.'); } - + /* Check if file hash matches with sha1 sum of file data */ if(sha1($file_data) != $file_hash) { return('file hash and file data mismatch.'); - } + } /* get id for backend, category and manufacturer */ /* create new if needed */ @@ -236,7 +236,7 @@ class IrrecoWebdbDatabase $category_id = $this->createNameId('category', $category); $manufacturer_id = $this->createNameId('manufacturer', $manufacturer); - + /* insert data */ $this->lockTable('file'); @@ -250,10 +250,10 @@ class IrrecoWebdbDatabase $this->db->quote($file_name, 'text'). ', '. $this->db->quote($file_data, 'text'). ', '. 'NOW(), NOW(), 0)'); - + /* Unlock table */ $this->unlockTables(); - + /* Create configuration */ $this->lockTable('configuration'); $this->query("INSERT INTO configuration VALUES (NULL, ". @@ -264,28 +264,28 @@ class IrrecoWebdbDatabase $this->db->quote($model, 'text'). ", ". $this->db->quote($file_hash, 'text'). ", ". $this->db->quote($file_name, 'text'). ")"); - + /* Unlock table */ $this->unlockTables(); - + IrrecoLog::$database->log('configuration added successfully.'); - + return('configuration added successfully'); } - + function dumpResultToLog($result) { IrrecoLog::$database->log('Dumping result set.'); - + $i = 1; while ($row = $result->fetchRow()) { - IrrecoLog::$database->log(' Row ' . $i++ . ': ' . + IrrecoLog::$database->log(' Row ' . $i++ . ': ' . serialize($row)); } - + IrrecoLog::$database->log('Done.'); } - + /** * Check username and password. */ @@ -321,7 +321,7 @@ class IrrecoWebdbDatabase 'WHERE hash = '. $this->db->quote($file_hash, 'text'). ' '. 'AND name = '. $this->db->quote($file_name, 'text')); $row = $result->fetchRow(); - + if (is_object($row)) { IrrecoLog::$database->log('file exist'); return TRUE; @@ -329,7 +329,7 @@ class IrrecoWebdbDatabase IrrecoLog::$database->log('file not exist'); return FALSE; } - + /** * Get ID of name. */ @@ -342,18 +342,18 @@ class IrrecoWebdbDatabase 'WHERE name LIKE ' . $this->db->quote($name, 'text')); $row = $result->fetchRow(); - + if (is_object($row)) { $id = $row->id; IrrecoLog::$database->log( - 'Id for name "' . $name .'" in table "' . + 'Id for name "' . $name .'" in table "' . $table . '" is "' . $id . '".', PEAR_LOG_DEBUG); } else { $id = NULL; } return $id; } - + /** * Create ID for name if it does not exist, or get old ID of name. */ @@ -361,10 +361,10 @@ class IrrecoWebdbDatabase { IrrecoLog::$database->log('Get id for name "' . $name . '" in table "' . $table . '".'); - + // Lock the table $this->lockTable($table); - + // Create category if it does not exists. $id = $this->getNameId($table, $name); if ($id != NULL) { @@ -373,16 +373,16 @@ class IrrecoWebdbDatabase } else { $this->query('INSERT INTO ' . $this->db->quoteIdentifier($table, 'text'). - ' (name) VALUES(' . + ' (name) VALUES(' . $this->db->quote($name, 'text') . ')'); $id = $this->db->lastInsertID(); } - + $this->unlockTables(); - IrrecoLog::$database->log('Category ID: "' . $id . '".'); + IrrecoLog::$database->log('Category ID: "' . $id . '".'); return $id; } - + /** * Get list of categories that have configurations in them. * @@ -402,7 +402,7 @@ class IrrecoWebdbDatabase $rows = $result->fetchAll(); return $rows; } - + /** * Get whole list of all categories. Even those that don't * have configurations in them. @@ -445,7 +445,7 @@ class IrrecoWebdbDatabase $rows = $result->fetchAll(); return $rows; } - + /** * Get list of all manufacturers. Even those that don't have * configurations in them. @@ -462,7 +462,7 @@ class IrrecoWebdbDatabase $rows = $result->fetchAll(); return $rows; } - + /** * Get list of Models by manufacturer in selected category. * @@ -490,7 +490,7 @@ class IrrecoWebdbDatabase $rows = $result->fetchAll(); return $rows; } - + /** * Get list of Configurations for Model * @@ -499,7 +499,7 @@ class IrrecoWebdbDatabase function getConfigs($model) { IrrecoLog::$database->log('Model name: "'.$model.'"'); - + $result = $this->query( 'SELECT configuration.id AS id, '. 'user.name AS user FROM configuration '. @@ -515,7 +515,7 @@ class IrrecoWebdbDatabase return $rows; } - + /** * Get list of Configurations for Model and manufacturer * @@ -524,7 +524,7 @@ class IrrecoWebdbDatabase function getConfigurations($manufacturer, $model) { IrrecoLog::$database->log('Model name: "'.$model.'"'); - + $result = $this->query( 'SELECT configuration.id AS id, '. 'user.name AS user FROM configuration '. @@ -543,7 +543,7 @@ class IrrecoWebdbDatabase return $rows; } - + /** * Get all data from category * @@ -552,7 +552,7 @@ class IrrecoWebdbDatabase function getConfiguration($id) { IrrecoLog::$database->log('Category id: "'.$id.'"'); - + $result = $this->query( 'SELECT configuration.id AS id, '. 'user.name AS user, '. @@ -582,7 +582,7 @@ class IrrecoWebdbDatabase return $rows; } - + /** * Get file data by hash and name * @@ -601,7 +601,7 @@ class IrrecoWebdbDatabase "AND file.name = ". $this->db->quote($name, 'text')); $rows = $result->fetchAll(); - + //Update download_count. (timestamp will be updated //automatically) @@ -616,7 +616,7 @@ class IrrecoWebdbDatabase return $rows; } - + /** * Create new Theme * @@ -631,13 +631,13 @@ class IrrecoWebdbDatabase 'Previewbutton: "'.$preview_button.'" '. 'Folder: "'.$folder.'" '. 'User: "'.$user.'" '); - + /* Check if username matches up to password and get id */ $user_id = $this->checkUsernameAndPassword($user, $password); if($user_id == NULL) { return('username and password mismatch.'); } - + $result = $this->query( 'INSERT INTO irreco.theme ( '. 'id, name, user_id, comment, preview_button, folder, '. @@ -648,7 +648,7 @@ class IrrecoWebdbDatabase $this->db->quote($preview_button, 'text').', '. $this->db->quote($folder, 'text').', '. 'NOW(), NOW(), NOW(), 0)'); - + $theme = $this->query( 'SELECT id AS id FROM irreco.theme '. 'WHERE uploaded = (SELECT MAX(uploaded) '. @@ -713,7 +713,7 @@ class IrrecoWebdbDatabase function getTheme($id) { IrrecoLog::$database->log('Theme id: "'.$id.'"'); - + $result = $this->query( 'SELECT theme.id AS id, '. 'theme.name AS name, '. @@ -778,19 +778,19 @@ class IrrecoWebdbDatabase 'folder: "'.$folder.'" '. 'theme_id: "'.$theme_id.'" '. 'User: "'.$user.'" '); - + /* Check if username matches up to password and get id */ $user_id = $this->checkUsernameAndPassword($user, $password); if($user_id == NULL) { return('username and password mismatch.'); } - + /* Check if file hash matches with sha1 sum of file data */ if(sha1($image_up) != $image_up_hash || sha1($image_down) != $image_down_hash) { return('file hash and file data mismatch.'); } - + /* insert data */ $this->lockTable('file'); @@ -812,10 +812,10 @@ class IrrecoWebdbDatabase if ($allow_text == TRUE) { $allow_text_string = 'TRUE'; } - + /* Unlock table */ $this->unlockTables(); - + $button = $this->query( 'SELECT id AS id FROM irreco.button '. 'WHERE theme_id = '. @@ -823,7 +823,7 @@ class IrrecoWebdbDatabase 'name = '.$this->db->quote($name, 'text')); $row = $button->fetchAll(); - + if ($row[0]->id == NULL) { $result = $this->query( 'INSERT INTO irreco.button ( '. @@ -845,9 +845,9 @@ class IrrecoWebdbDatabase $this->db->quote($image_down_name, 'text').', '. $this->db->quote($folder, 'text').', '. $this->db->quote($theme_id, 'text').')'); - + IrrecoLog::$database->log('Button added'); - + $button = $this->query( 'SELECT id AS id FROM irreco.button '. 'WHERE theme_id = '. @@ -881,7 +881,7 @@ class IrrecoWebdbDatabase 'WHERE theme_id = '. $this->db->quote($theme_id, 'text').' AND '. 'name = '.$this->db->quote($name, 'text')); - + IrrecoLog::$database->log('Button updated'); } @@ -998,9 +998,9 @@ class IrrecoWebdbDatabase $this->db->quote($theme_id, 'text').') AND '. 'button.theme_id = '. $this->db->quote($theme_id, 'text')); - + $rows = $result->fetchAll(); - + $data = $this->getFileData($rows[0]->hash, $rows[0]->name); return $data[0]->data; @@ -1045,14 +1045,14 @@ class IrrecoWebdbDatabase /* Unlock table */ $this->unlockTables(); - + $bg = $this->query( 'SELECT id AS id FROM irreco.bg '. 'WHERE theme_id = '. $this->db->quote($theme_id, 'text').' AND '. 'name = '.$this->db->quote($name, 'text')); $row = $bg->fetchAll(); - + if ($row[0]->id == NULL) { $result = $this->query( 'INSERT INTO irreco.bg ( '. @@ -1062,7 +1062,7 @@ class IrrecoWebdbDatabase $this->db->quote($image_name, 'text').', '. $this->db->quote($folder, 'text').', '. $this->db->quote($theme_id, 'text').')'); - + if ($result == 1) { IrrecoLog::$database->log('BG added'); } @@ -1072,7 +1072,7 @@ class IrrecoWebdbDatabase 'WHERE theme_id = '. $this->db->quote($theme_id, 'text').' AND '. 'name = '.$this->db->quote($name, 'text')); - + $row = $bg->fetchAll(); } else { @@ -1086,17 +1086,17 @@ class IrrecoWebdbDatabase 'WHERE theme_id = '. $this->db->quote($theme_id, 'text').' AND '. 'name = '.$this->db->quote($name, 'text')); - + if ($result == 1) { IrrecoLog::$database->log('BG updated'); } } - + return intval($row[0]->id); } - + /** * Get list of backgrounds for theme * diff --git a/database/php/irreco_webdb_log.php b/database/php/irreco_webdb_log.php index 0a2f2d9b..4ec52b21 100644 --- a/database/php/irreco_webdb_log.php +++ b/database/php/irreco_webdb_log.php @@ -1,4 +1,4 @@ - 0644, + $file = 'webdb.log'; + $conf = array('mode' => 0644, 'timeFormat' => '%Y-%m-%d %T'); - + /* Critical. */ if (!is_object(self::$critical)) { self::$critical = Log::singleton( 'file', $file, NULL, $conf); } - + /* Setup PHP error logging. */ if (!is_object(self::$php)) { self::$php = Log::singleton( @@ -42,7 +42,7 @@ class IrrecoLog set_error_handler( array('IrrecoLog', 'phpErrorHandler')); } - + /* Setup PHP exception error logging. */ if (!is_object(self::$exception)) { self::$exception = Log::singleton( @@ -50,7 +50,7 @@ class IrrecoLog set_exception_handler( array('IrrecoLog', 'phpExceptionHandler')); } - + /* Setup PEAR error logging. */ if (!is_object(self::$pear)) { self::$pear = Log::singleton( @@ -58,26 +58,26 @@ class IrrecoLog PEAR::setErrorHandling(PEAR_ERROR_CALLBACK, array('IrrecoLog', 'pearErrorHandler')); } - + /* Index */ if (!is_object(self::$index)) { self::$index = Log::singleton( 'file', $file, 'Index', $conf); } - + /* Database */ if (!is_object(self::$database)) { self::$database = Log::singleton( 'file', $file, 'Database', $conf); } - + /* Server */ if (!is_object(self::$server)) { self::$server = Log::singleton( 'file', $file, 'Server', $conf); } } - + /** * Log critical error, and exit. */ @@ -86,57 +86,57 @@ class IrrecoLog IrrecoLog::$critical->log($message, PEAR_LOG_CRIT); die($message); } - + /** * PHP error handler for saving errors to Log. */ public static function phpErrorHandler($code, $message, $file, $line) { if ($code > self::$php_level) return; - + /* Map the PHP error to a Log priority. */ switch ($code) { case E_WARNING: case E_USER_WARNING: $priority = PEAR_LOG_WARNING; break; - + case E_NOTICE: case E_USER_NOTICE: $priority = PEAR_LOG_NOTICE; break; - + case E_ERROR: case E_USER_ERROR: $priority = PEAR_LOG_ERR; break; - + default: $priority = PEAR_LOG_INFO; break; } - - IrrecoLog::$php->log('[' . $code . '] ' . $message . ' in ' . - $file . ' at line ' . $line . '.', + + IrrecoLog::$php->log('[' . $code . '] ' . $message . ' in ' . + $file . ' at line ' . $line . '.', $priority); } - + /** * PHP exception handler for saving uncaught exceptions to log. */ public static function phpExceptionHandler($exception) { - IrrecoLog::$exception->log($exception->getMessage(), + IrrecoLog::$exception->log($exception->getMessage(), PEAR_LOG_ALERT); } - + /** * PEAR error handler for saving errors to Log. */ public static function pearErrorHandler($error) { $message = $error->getMessage(); - + if (!empty($error->backtrace[1]['file'])) { $message .= ' (' . $error->backtrace[1]['file']; if (!empty($error->backtrace[1]['line'])) { @@ -145,39 +145,39 @@ class IrrecoLog } $message .= ')'; } - + $log = IrrecoLog::$pear; - + /* Make sure the error code is a valid PEAR error code. */ switch ($error->code) { case PEAR_LOG_EMERG: case PEAR_LOG_ALERT: - case PEAR_LOG_CRIT: - case PEAR_LOG_ERR: + case PEAR_LOG_CRIT: + case PEAR_LOG_ERR: case PEAR_LOG_WARNING: case PEAR_LOG_NOTICE: case PEAR_LOG_INFO: case PEAR_LOG_DEBUG: $code = $error->code; break; - + default: - $message = '[' . $error->code . '] ' . $message; - $code = PEAR_LOG_NOTICE; + $message = '[' . $error->code . '] ' . $message; + $code = PEAR_LOG_NOTICE; } - + $log->log($message, $code); } - + /** - * Set PEAR error reporting level. + * Set PEAR error reporting level. * * @param $level Errors of this level or more signifacant are logged. */ public static function pearLevel($level) { $mask = IrrecoLog::$database->MAX($level); - + IrrecoLog::$critical->setMask($mask); IrrecoLog::$php->setMask($mask); IrrecoLog::$exception->setMask($mask); @@ -186,7 +186,7 @@ class IrrecoLog IrrecoLog::$database->setMask($mask); IrrecoLog::$server->setMask($mask); } - + /** * PHP logging level. * diff --git a/database/php/irreco_webdb_server.php b/database/php/irreco_webdb_server.php index 4b05c407..716d39ba 100644 --- a/database/php/irreco_webdb_server.php +++ b/database/php/irreco_webdb_server.php @@ -1,22 +1,22 @@ -database = $database; } - + /** * Sum two numbers. * @@ -65,7 +65,7 @@ class IrrecoWebdbServer IrrecoLog::$server->log('XML-RPC sum'); return $num_a + $num_b; } - + /** * Add user to database * @@ -80,7 +80,7 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC addUser'); $table = 'user'; - + /* Check for faultCode */ if(strstr($name, "faultCode")) { throw new XML_RPC2_FaultException(self::FAULTCODE_ERROR_MSG, @@ -121,18 +121,18 @@ class IrrecoWebdbServer if ($data == FALSE) { /* if failed */ - throw new XML_RPC2_FaultException(self::ADD_USER_ERROR_MSG, + throw new XML_RPC2_FaultException(self::ADD_USER_ERROR_MSG, self::ADD_USER_ERROR); } return $data; } - + /** * Add configuration to database * * Returns error message or 'configuration added successfully' as string * - * + * * @param string backend Name for Backend. e.g. "IRTrans Transceiver" * @param string category Name for Category. e.g. "Tv" * @param string manufacturer Name for Manufacturer. e.g. "Sony" @@ -142,20 +142,20 @@ class IrrecoWebdbServer * @param string file_hash sha1-hash of file_data * @param string file_name Name for File * @param string file_data Content of file - * @return string + * @return string */ - function uploadConfiguration($backend, + function uploadConfiguration($backend, $category, - $manufacturer, + $manufacturer, $model, $user, $password, - $file_hash, + $file_hash, $file_name, $file_data) { IrrecoLog::$server->log('XML-RPC uploadConfiguration'); - + /* Check for faultCode */ if(strstr($backend, "faultCode")) { throw new XML_RPC2_FaultException(self::FAULTCODE_ERROR_MSG, @@ -235,24 +235,24 @@ class IrrecoWebdbServer /* try to add data to db */ $table = 'configuration'; - $return = $this->database->uploadConfiguration($backend, + $return = $this->database->uploadConfiguration($backend, $category, - $manufacturer, + $manufacturer, $model, $user, $password, - $file_hash, + $file_hash, $file_name, $file_data); if ($return == 'username and password mismatch.') { throw new XML_RPC2_FaultException( - self::USERNAME_AND_PASSWORD_MISMATCH_MSG, + self::USERNAME_AND_PASSWORD_MISMATCH_MSG, self::USERNAME_AND_PASSWORD_MISMATCH); } else if ($return == 'file already exist.') { throw new XML_RPC2_FaultException( - self::FILE_ALREADY_EXIST_MSG, + self::FILE_ALREADY_EXIST_MSG, self::FILE_ALREADY_EXIST); } else if ($return == 'file hash and file data mismatch.') { @@ -263,7 +263,7 @@ class IrrecoWebdbServer return $return; } - + /** * Get list of categories that have configurations in them. * @@ -273,13 +273,13 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getCategories'); $data = $this->database->getCategoryList(); - + $array = array(); foreach ($data as $item) { array_push($array, $item->name); } - - IrrecoLog::$database->log("Category list:\n" . + + IrrecoLog::$database->log("Category list:\n" . IrrecoLog::getVarDump($array)); return $array; } @@ -293,13 +293,13 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getAllCategories'); $data = $this->database->getWholeCategoryList(); - + $array = array(); foreach ($data as $item) { array_push($array, $item->name); } - - IrrecoLog::$database->log("Category list:\n" . + + IrrecoLog::$database->log("Category list:\n" . IrrecoLog::getVarDump($array)); return $array; } @@ -314,17 +314,17 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getManufacturers'); $data = $this->database->getManufacturerList($category); - + $array = array(); foreach ($data as $item) { array_push($array, $item->name); } - - IrrecoLog::$database->log("Manufacturer list:\n" . + + IrrecoLog::$database->log("Manufacturer list:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get list of all manufacturers. Even those that don't have * configurations in them. @@ -335,13 +335,13 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getAllManufacturers'); $data = $this->database->getWholeManufacturerList(); - + $array = array(); foreach ($data as $item) { array_push($array, $item->name); } - - IrrecoLog::$database->log("Manufacturer list:\n" . + + IrrecoLog::$database->log("Manufacturer list:\n" . IrrecoLog::getVarDump($array)); return $array; } @@ -357,18 +357,18 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getModels'); $data = $this->database->getModelList($category,$manufacturer); - + $array = array(); foreach ($data as $item) { array_push($array, $item->model); } - - IrrecoLog::$database->log("Model list:\n" . + + IrrecoLog::$database->log("Model list:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get id list for configurations by model. * @@ -385,12 +385,12 @@ class IrrecoWebdbServer foreach ($data as $item) { array_push($array, $item->id); } - - IrrecoLog::$database->log("Config id:\n" . + + IrrecoLog::$database->log("Config id:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get id list for configurations by model and manufacturer * @@ -407,12 +407,12 @@ class IrrecoWebdbServer foreach ($data as $item) { array_push($array, $item->id); } - - IrrecoLog::$database->log("Config id:\n" . + + IrrecoLog::$database->log("Config id:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get all data from configuration * @@ -429,7 +429,7 @@ class IrrecoWebdbServer IrrecoLog::$server->log('XML-RPC getConfiguration'); $data = $this->database->getConfiguration($id); $array = array(); - + $array['user'] = $data[0]->user; $array['backend'] = $data[0]->backend; $array['category'] = $data[0]->category; @@ -439,12 +439,12 @@ class IrrecoWebdbServer $array['file_name'] = $data[0]->file_name; $array['uploaded'] = $data[0]->uploaded; $array['download_count'] = $data[0]->download_count; - - IrrecoLog::$database->log("Configuration:\n" . + + IrrecoLog::$database->log("Configuration:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get all data from configuration * @@ -458,7 +458,7 @@ class IrrecoWebdbServer IrrecoLog::$server->log('XML-RPC getConfigurationById'); $data = $this->database->getConfiguration($id); $array = array(); - + $array['user'] = $data[0]->user; $array['backend'] = $data[0]->backend; $array['category'] = $data[0]->category; @@ -468,13 +468,13 @@ class IrrecoWebdbServer $array['file_name'] = $data[0]->file_name; $array['uploaded'] = $data[0]->uploaded; $array['download_count'] = $data[0]->download_count; - - IrrecoLog::$database->log("Configuration:\n" . + + IrrecoLog::$database->log("Configuration:\n" . IrrecoLog::getVarDump($array)); return $array; } - - + + /** * Get File * @@ -488,22 +488,22 @@ class IrrecoWebdbServer { IrrecoLog::$server->log('XML-RPC getFile'); $data = $this->database->getFileData($hash,$name); - + $array = array(); - + $array['data']= $data[0]->data; - - IrrecoLog::$database->log("Data:\n" . + + IrrecoLog::$database->log("Data:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get whether user already exists * * Returns TRUE if given name is already in database. - * Used at irreco_webdb_register_dlg when adding new user. + * Used at irreco_webdb_register_dlg when adding new user. * * @param string name Username * @return boolean User exists @@ -513,14 +513,14 @@ class IrrecoWebdbServer IrrecoLog::$server->log('XML-RPC getUserExists'); $table = 'user'; $data = $this->database->getNameId($table, $name); - + if ($data == "") { return FALSE; } else { return TRUE; } } - + /** * Create new Theme * @@ -541,13 +541,13 @@ class IrrecoWebdbServer $preview_button, $folder, $user, $password); - + if ($theme_id == 'username and password mismatch.') { throw new XML_RPC2_FaultException( - self::USERNAME_AND_PASSWORD_MISMATCH_MSG, + self::USERNAME_AND_PASSWORD_MISMATCH_MSG, self::USERNAME_AND_PASSWORD_MISMATCH); } - + IrrecoLog::$database->log("Theme_id: " . $theme_id . "\n"); return $theme_id; } @@ -596,12 +596,12 @@ class IrrecoWebdbServer foreach ($data as $item) { array_push($array, $item->id); } - - IrrecoLog::$database->log("Theme id:\n" . + + IrrecoLog::$database->log("Theme id:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get all data from theme * @@ -616,7 +616,7 @@ class IrrecoWebdbServer IrrecoLog::$server->log('XML-RPC getThemeById'); $data = $this->database->getTheme($id); $array = array(); - + $array['name'] = $data[0]->name; $array['user'] = $data[0]->user; $array['comment'] = $data[0]->comment; @@ -626,12 +626,12 @@ class IrrecoWebdbServer $array['modified'] = $data[0]->modified; $array['downloaded'] = $data[0]->downloaded; $array['download_count'] = intval($data[0]->download_count); - + IrrecoLog::$database->log("Theme:\n" . IrrecoLog::getVarDump($array)); return $array; } - + /** * Get theme versions by name * @@ -715,9 +715,9 @@ class IrrecoWebdbServer if ($button_id == 'username and password mismatch.') { throw new XML_RPC2_FaultException( - self::USERNAME_AND_PASSWORD_MISMATCH_MSG, + self::USERNAME_AND_PASSWORD_MISMATCH_MSG, self::USERNAME_AND_PASSWORD_MISMATCH); - } + } else if ($button_id == 'file hash and file data mismatch.') { throw new XML_RPC2_FaultException( self::HASH_AND_DATA_MISMATCH_MSG, @@ -810,22 +810,22 @@ class IrrecoWebdbServer base64_decode($image), $folder, $theme_id, $user, $password); - + if ($bg_id == 'username and password mismatch.') { throw new XML_RPC2_FaultException( - self::USERNAME_AND_PASSWORD_MISMATCH_MSG, + self::USERNAME_AND_PASSWORD_MISMATCH_MSG, self::USERNAME_AND_PASSWORD_MISMATCH); - } + } else if ($bg_id == 'file hash and file data mismatch.') { throw new XML_RPC2_FaultException( self::HASH_AND_DATA_MISMATCH_MSG, self::HASH_AND_DATA_MISMATCH); } - + IrrecoLog::$database->log("Bg_id: " . $bg_id . "\n"); return $bg_id; } - + /** * Get id list of backgrounds for theme * @@ -845,8 +845,8 @@ class IrrecoWebdbServer if (count($array) == 0) { array_push($array, 0); } - - IrrecoLog::$database->log("Bg id:\n" . + + IrrecoLog::$database->log("Bg id:\n" . IrrecoLog::getVarDump($array)); return $array; } @@ -876,12 +876,12 @@ class IrrecoWebdbServer * * @param string user Username * @param string password sha1-hash of password - * @return boolean + * @return boolean */ function loginToDB($user, $password) { IrrecoLog::$server->log('XML-RPC loginToDB'); - + /* Check for faultCode */ if(strstr($user, "faultCode")) { throw new XML_RPC2_FaultException(self::FAULTCODE_ERROR_MSG, @@ -905,7 +905,7 @@ class IrrecoWebdbServer if ($return == FALSE) { throw new XML_RPC2_FaultException( - self::USERNAME_AND_PASSWORD_MISMATCH_MSG, + self::USERNAME_AND_PASSWORD_MISMATCH_MSG, self::USERNAME_AND_PASSWORD_MISMATCH); } -- 2.11.4.GIT