4 * irreco - Ir Remote Control
5 * Copyright (C) 2007,2008 Arto Karppinen (arto.karppinen@iki.fi),
6 * Joni Kokko (t5kojo01@students.oamk.fi),
7 * Sami Mäki (kasmra@xob.kapsi.fi),
8 * Harri Vattulainen (t5vaha01@students.oamk.fi)
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2
13 * of the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25 require_once 'irreco_webdb_log.php';
26 require_once 'XML/RPC2/Server.php';
28 class IrrecoWebdbServer
31 const ADD_USER_ERROR_MSG
= "Adding user failed.";
32 const UPLOAD_CONFIGURATION_ERROR_MSG
= "Uploading configuration\nfailed.";
33 const USERNAME_AND_PASSWORD_MISMATCH_MSG
= "Username and password mismatch.";
34 const FILE_ALREADY_EXIST_MSG
= "Database already contains identical device.";
35 const HASH_AND_DATA_MISMATCH_MSG
= "File hash and file data don't match.";
36 const FAULTCODE_ERROR_MSG
= "\nInvalid string faultCode.";
37 const LOGIN_ERROR_MSG
= "Login failed.";
38 const EMPTY_DB_MSG
= "Database is empty.";
40 const ADD_USER_ERROR
= 10001;
41 const UPLOAD_CONFIGURATION_ERROR
= 10002;
42 const USERNAME_AND_PASSWORD_MISMATCH
= 10003;
43 const FILE_ALREADY_EXIST
= 10004;
44 const HASH_AND_DATA_MISMATCH
= 10005;
45 const FAULTCODE_ERROR
= 10006;
46 const LOGIN_ERROR
= 10007;
47 const EMPTY_DB_ERROR
= 10008;
51 public function __construct($database)
53 $this->database
= $database;
61 * @return int Sum of integers
63 public function sum($num_a, $num_b)
65 IrrecoLog
::$server->log('XML-RPC sum');
66 return $num_a +
$num_b;
70 * Add user to database
72 * Returns TRUE if user is added successfully to database.
74 * @param string name Username
75 * @param string email full email address
76 * @param string passwd sha1-hash of password
77 * @return boolean User added successfully
79 function addUser($name, $email, $passwd)
81 IrrecoLog
::$server->log('XML-RPC addUser');
84 /* Check for faultCode */
85 if(strstr($name, "faultCode")) {
86 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
87 self
::FAULTCODE_ERROR
);
89 if(strstr($email, "faultCode")) {
90 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
91 self
::FAULTCODE_ERROR
);
94 /* Check parameters here */
95 if(strlen($name) < 6) {
96 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
97 self
::ADD_USER_ERROR
);
100 if(strlen($email) < 6) {
101 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
102 self
::ADD_USER_ERROR
);
105 if(strlen($passwd) < 6) {
106 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
107 self
::ADD_USER_ERROR
);
110 if(!strstr($email, "@")) {
111 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
112 self
::ADD_USER_ERROR
);
115 if(!strstr($email, ".")) {
116 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
117 self
::ADD_USER_ERROR
);
120 $data = $this->database
->addUser($name, $email, $passwd, $table);
122 if ($data == FALSE) {
124 throw new XML_RPC2_FaultException(self
::ADD_USER_ERROR_MSG
,
125 self
::ADD_USER_ERROR
);
131 * Add configuration to database
133 * Returns error message or 'configuration added successfully' as string
136 * @param string backend Name for Backend. e.g. "IRTrans Transceiver"
137 * @param string category Name for Category. e.g. "Tv"
138 * @param string manufacturer Name for Manufacturer. e.g. "Sony"
139 * @param string model Name for Model. e.g. "Sony"
140 * @param string user Username
141 * @param string password sha1-hash of password
142 * @param string file_hash sha1-hash of file_data
143 * @param string file_name Name for File
144 * @param string file_data Content of file
147 function uploadConfiguration($backend,
157 IrrecoLog
::$server->log('XML-RPC uploadConfiguration');
159 /* Check for faultCode */
160 if(strstr($backend, "faultCode")) {
161 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
162 self
::FAULTCODE_ERROR
);
164 if(strstr($category, "faultCode")) {
165 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
166 self
::FAULTCODE_ERROR
);
168 if(strstr($manufacturer, "faultCode")) {
169 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
170 self
::FAULTCODE_ERROR
);
172 if(strstr($model, "faultCode")) {
173 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
174 self
::FAULTCODE_ERROR
);
176 if(strstr($user, "faultCode")) {
177 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
178 self
::FAULTCODE_ERROR
);
180 if(strstr($file_hash, "faultCode")) {
181 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
182 self
::FAULTCODE_ERROR
);
184 if(strstr($file_name, "faultCode")) {
185 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
186 self
::FAULTCODE_ERROR
);
188 if(strstr($file_data, "faultCode")) {
189 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
190 self
::FAULTCODE_ERROR
);
193 /* Check parameters here */
194 if(strlen($backend) == 0) {
195 throw new XML_RPC2_FaultException(
196 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
197 self
::UPLOAD_CONFIGURATION_ERROR
);
200 if(strlen($category) == 0) {
201 throw new XML_RPC2_FaultException(
202 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
203 self
::UPLOAD_CONFIGURATION_ERROR
);
206 if(strlen($manufacturer) == 0) {
207 throw new XML_RPC2_FaultException(
208 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
209 self
::UPLOAD_CONFIGURATION_ERROR
);
212 if(strlen($model) == 0) {
213 throw new XML_RPC2_FaultException(
214 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
215 self
::UPLOAD_CONFIGURATION_ERROR
);
218 if(strlen($user) < 6) {
219 throw new XML_RPC2_FaultException(
220 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
221 self
::UPLOAD_CONFIGURATION_ERROR
);
224 if(strlen($password) < 6) {
225 throw new XML_RPC2_FaultException(
226 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
227 self
::UPLOAD_CONFIGURATION_ERROR
);
230 if(strlen($file_hash) != 40) {
231 throw new XML_RPC2_FaultException(
232 self
::UPLOAD_CONFIGURATION_ERROR_MSG
,
233 self
::UPLOAD_CONFIGURATION_ERROR
);
236 /* try to add data to db */
237 $table = 'configuration';
238 $return = $this->database
->uploadConfiguration($backend,
248 if ($return == 'username and password mismatch.') {
249 throw new XML_RPC2_FaultException(
250 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
251 self
::USERNAME_AND_PASSWORD_MISMATCH
);
253 else if ($return == 'file already exist.') {
254 throw new XML_RPC2_FaultException(
255 self
::FILE_ALREADY_EXIST_MSG
,
256 self
::FILE_ALREADY_EXIST
);
258 else if ($return == 'file hash and file data mismatch.') {
259 throw new XML_RPC2_FaultException(
260 self
::HASH_AND_DATA_MISMATCH_MSG
,
261 self
::HASH_AND_DATA_MISMATCH
);
268 * Get list of categories that have configurations in them.
272 function getCategories()
274 IrrecoLog
::$server->log('XML-RPC getCategories');
275 $data = $this->database
->getCategoryList();
278 foreach ($data as $item) {
279 array_push($array, $item->name
);
282 IrrecoLog
::$database->log("Category list:\n" .
283 IrrecoLog
::getVarDump($array));
287 * Get list of all categories. Even those that don't have
288 * configurations in them.
292 function getAllCategories()
294 IrrecoLog
::$server->log('XML-RPC getAllCategories');
295 $data = $this->database
->getWholeCategoryList();
298 foreach ($data as $item) {
299 array_push($array, $item->name
);
302 IrrecoLog
::$database->log("Category list:\n" .
303 IrrecoLog
::getVarDump($array));
308 * Get list of manufacturers for category.
310 * @param string category Name for Category. e.g. "Tv"
313 function getManufacturers($category)
315 IrrecoLog
::$server->log('XML-RPC getManufacturers');
316 $data = $this->database
->getManufacturerList($category);
319 foreach ($data as $item) {
320 array_push($array, $item->name
);
323 IrrecoLog
::$database->log("Manufacturer list:\n" .
324 IrrecoLog
::getVarDump($array));
329 * Get list of all manufacturers. Even those that don't have
330 * configurations in them.
334 function getAllManufacturers()
336 IrrecoLog
::$server->log('XML-RPC getAllManufacturers');
337 $data = $this->database
->getWholeManufacturerList();
340 foreach ($data as $item) {
341 array_push($array, $item->name
);
344 IrrecoLog
::$database->log("Manufacturer list:\n" .
345 IrrecoLog
::getVarDump($array));
350 * Get list of models by manufacturer in selected category.
352 * @param string category Name for Category. e.g. "Tv"
353 * @param string manufacturer Name for Manufacturer. e.g. "Sony"
356 function getModels($category,$manufacturer)
358 IrrecoLog
::$server->log('XML-RPC getModels');
359 $data = $this->database
->getModelList($category,$manufacturer);
362 foreach ($data as $item) {
363 array_push($array, $item->model
);
366 IrrecoLog
::$database->log("Model list:\n" .
367 IrrecoLog
::getVarDump($array));
373 * Get id list for configurations by model.
375 * This function is deprecated. Use the getConfigurations function
377 * @param string model Name for Model. e.g. "xyz"
380 function getConfigs($model)
382 IrrecoLog
::$server->log('XML-RPC getConfigs');
383 $data = $this->database
->getConfigs($model);
385 foreach ($data as $item) {
386 array_push($array, $item->id
);
389 IrrecoLog
::$database->log("Config id:\n" .
390 IrrecoLog
::getVarDump($array));
395 * Get id list for configurations by model and manufacturer
397 * @param string manufacturer Name for Manufacturer. e.g. "Sony"
398 * @param string model Name for Model. e.g. "xyz"
401 function getConfigurations($manufacturer, $model)
403 IrrecoLog
::$server->log('XML-RPC getConfigurations');
404 $data = $this->database
->getConfigurations($manufacturer, $model);
407 foreach ($data as $item) {
408 array_push($array, $item->id
);
411 IrrecoLog
::$database->log("Config id:\n" .
412 IrrecoLog
::getVarDump($array));
417 * Get all data from configuration
419 * Returns user, backend, category, manufacturer,
420 * model, file_hash, file_name, uploaded, download_count
422 * This function is deprecated. Use the getConfigurationById function
424 * @param string id id-number for configuration.
427 function getConfiguration($id)
429 IrrecoLog
::$server->log('XML-RPC getConfiguration');
430 $data = $this->database
->getConfiguration($id);
433 $array['user'] = $data[0]->user
;
434 $array['backend'] = $data[0]->backend
;
435 $array['category'] = $data[0]->category
;
436 $array['manufacturer'] = $data[0]->manufacturer
;
437 $array['model'] = $data[0]->model
;
438 $array['file_hash'] = $data[0]->file_hash
;
439 $array['file_name'] = $data[0]->file_name
;
440 $array['uploaded'] = $data[0]->uploaded
;
441 $array['download_count'] = $data[0]->download_count
;
443 IrrecoLog
::$database->log("Configuration:\n" .
444 IrrecoLog
::getVarDump($array));
449 * Get all data from configuration
451 * Returns user, backend, category, manufacturer,
452 * model, file_hash, file_name, uploaded, download_count
453 * @param int id id-number for configuration.
456 function getConfigurationById($id)
458 IrrecoLog
::$server->log('XML-RPC getConfigurationById');
459 $data = $this->database
->getConfiguration($id);
462 $array['user'] = $data[0]->user
;
463 $array['backend'] = $data[0]->backend
;
464 $array['category'] = $data[0]->category
;
465 $array['manufacturer'] = $data[0]->manufacturer
;
466 $array['model'] = $data[0]->model
;
467 $array['file_hash'] = $data[0]->file_hash
;
468 $array['file_name'] = $data[0]->file_name
;
469 $array['uploaded'] = $data[0]->uploaded
;
470 $array['download_count'] = $data[0]->download_count
;
472 IrrecoLog
::$database->log("Configuration:\n" .
473 IrrecoLog
::getVarDump($array));
482 * Returns content of file
483 * @param string hash sha1-hash of file_data
484 * @param string name Name for File
487 function getFile($hash,$name)
489 IrrecoLog
::$server->log('XML-RPC getFile');
490 $data = $this->database
->getFileData($hash,$name);
494 $array['data']= $data[0]->data
;
496 IrrecoLog
::$database->log("Data:\n" .
497 IrrecoLog
::getVarDump($array));
503 * Get whether user already exists
505 * Returns TRUE if given name is already in database.
506 * Used at irreco_webdb_register_dlg when adding new user.
508 * @param string name Username
509 * @return boolean User exists
511 function getUserExists($name)
513 IrrecoLog
::$server->log('XML-RPC getUserExists');
515 $data = $this->database
->getNameId($table, $name);
528 * @param string name Name of Theme
529 * @param string comment
530 * @param string preview_button name of preview button
531 * @param string folder name of themefolder
532 * @param string user Username
533 * @param string password sha1-hash of password
536 function createNewTheme($name, $comment, $preview_button,
537 $folder, $user, $password)
539 IrrecoLog
::$server->log('XML-RPC createNewTheme');
540 $theme_id = $this->database
->createNewTheme($name, $comment,
545 if ($theme_id == 'username and password mismatch.') {
546 throw new XML_RPC2_FaultException(
547 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
548 self
::USERNAME_AND_PASSWORD_MISMATCH
);
551 IrrecoLog
::$database->log("Theme_id: " . $theme_id . "\n");
556 * Set Theme downloadable
558 * @param int id id-number for theme.
559 * @param bool downloadable
560 * @param string user Username
561 * @param string password sha1-hash of password
564 function setThemeDownloadable($id, $downloadable, $user, $password)
566 IrrecoLog
::$server->log('XML-RPC ThemeSetDownloadable');
567 $success = $this->database
->setThemeDownloadable($id,
572 if ($success == 'username and password mismatch.') {
573 throw new XML_RPC2_FaultException(
574 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
575 self
::USERNAME_AND_PASSWORD_MISMATCH
);
581 * Get id list for themes
587 IrrecoLog
::$server->log('XML-RPC getThemes');
588 $data = $this->database
->getThemeList();
590 if ($data == 'Database is empty.') {
591 throw new XML_RPC2_FaultException(self
::EMPTY_DB_MSG
,
592 self
::EMPTY_DB_ERROR
);
596 foreach ($data as $item) {
597 array_push($array, $item->id
);
600 IrrecoLog
::$database->log("Theme id:\n" .
601 IrrecoLog
::getVarDump($array));
606 * Get all data from theme
608 * Returns name, user, comment, preview_button, folder,
609 * uploaded, modified, downloaded, download_count
610 * @param int id id-number for theme.
614 function getThemeById($id)
616 IrrecoLog
::$server->log('XML-RPC getThemeById');
617 $data = $this->database
->getTheme($id);
620 $array['name'] = $data[0]->name
;
621 $array['user'] = $data[0]->user
;
622 $array['comment'] = $data[0]->comment
;
623 $array['preview_button'] = $data[0]->preview_button
;
624 $array['folder'] = $data[0]->folder
;
625 $array['uploaded'] = $data[0]->uploaded
;
626 $array['modified'] = $data[0]->modified
;
627 $array['downloaded'] = $data[0]->downloaded
;
628 $array['download_count'] = intval($data[0]->download_count
);
630 IrrecoLog
::$database->log("Theme:\n" .
631 IrrecoLog
::getVarDump($array));
636 * Get theme versions by name
639 * @param string name name for theme.
643 function getThemeVersionsByName($name)
645 IrrecoLog
::$server->log('XML-RPC getThemeVersionsByName');
646 $data = $this->database
->getThemeVersionsByName($name);
649 foreach ($data as $item) {
650 array_push($array, $item->id
);
653 IrrecoLog
::$database->log("Theme versions:\n".
654 IrrecoLog
::getVarDump($array));
659 * Get date for theme by id
661 * @param int id id-number for theme.
665 function getThemeDateById($id)
667 IrrecoLog
::$server->log('XML-RPC getThemeById');
668 $data = $this->database
->getTheme($id);
670 IrrecoLog
::$database->log("Theme-date: ".$data[0]->uploaded
);
671 return $data[0]->uploaded
;
675 * Add button to Theme
678 * @param string name Name of button
679 * @param bool allow_text
680 * @param string text_format_up
681 * @param string text_format_down
682 * @param int text_padding
683 * @param float text_h_align
684 * @param float text_v_align
685 * @param string image_up_hash
686 * @param string image_up_name
687 * @param string image_up
688 * @param string image_down_hash
689 * @param string image_down_name
690 * @param string image_down
691 * @param string folder
692 * @param int theme_id
693 * @param string user Username
694 * @param string password sha1-hash of password
697 function addButtonToTheme($name, $allow_text, $text_format_up,
698 $text_format_down, $text_padding,
699 $text_h_align, $text_v_align,
700 $image_up_hash, $image_up_name, $image_up,
701 $image_down_hash, $image_down_name, $image_down,
702 $folder, $theme_id, $user, $password)
705 IrrecoLog
::$server->log('XML-RPC addButtonToTheme');
707 $button_id = $this->database
->addButtonToTheme(
708 $name, $allow_text, $text_format_up,
709 $text_format_down, $text_padding,
710 $text_h_align, $text_v_align,
711 $image_up_hash, $image_up_name,
712 base64_decode($image_up), $image_down_hash,
713 $image_down_name, base64_decode($image_down),
714 $folder, $theme_id, $user, $password);
716 if ($button_id == 'username and password mismatch.') {
717 throw new XML_RPC2_FaultException(
718 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
719 self
::USERNAME_AND_PASSWORD_MISMATCH
);
721 else if ($button_id == 'file hash and file data mismatch.') {
722 throw new XML_RPC2_FaultException(
723 self
::HASH_AND_DATA_MISMATCH_MSG
,
724 self
::HASH_AND_DATA_MISMATCH
);
727 IrrecoLog
::$database->log("Button_id: " . $button_id . "\n");
732 * Get id list of buttons for theme
734 * @param int theme_id id of theme
737 function getButtons($theme_id)
739 IrrecoLog
::$server->log('XML-RPC getButtons');
740 $data = $this->database
->getButtonList($theme_id);
743 foreach ($data as $item) {
744 array_push($array, intval($item->id
));
747 if (count($array) == 0) {
748 array_push($array, 0);
751 IrrecoLog
::$database->log("Button id:\n".
752 IrrecoLog
::getVarDump($array));
757 * Get all data from Button
759 * Returns name, allow_text, text_format_up, text_format_down,
760 * text_padding, image_up_hash, image_up_name, base64 encoded image_up,
761 * image_down_hash, image_down_name, base64 encoded image_down, folder
762 * @param int id id-number for button.
765 function getButtonById($id)
767 IrrecoLog
::$server->log('XML-RPC getButtonById');
768 $array = $this->database
->getButton($id);
770 IrrecoLog
::$database->log("Button:\n".
771 IrrecoLog
::getVarDump($array));
778 * Returns base64 encoded image-data string.
779 * @param int theme_id id for theme
783 function getPreviewButton($theme_id)
785 IrrecoLog
::$server->log('XML-RPC getPreviewButton');
786 $data = $this->database
->getPreviewButton($theme_id);
787 return base64_encode($data);
791 * Add background to Theme
793 * Returns background_id
794 * @param string name Name of background
795 * @param string image_hash sha1-hash of image-data
796 * @param string image_name Name for image
797 * @param string image Content of image
798 * @param string folder name of button-folder
799 * @param int theme_id id of theme
800 * @param string user Username
801 * @param string password sha1-hash of password
804 function addBgToTheme($name, $image_hash, $image_name, $image,
805 $folder, $theme_id, $user, $password)
807 IrrecoLog
::$server->log('XML-RPC addBgToTheme');
808 $bg_id = $this->database
->addBgToTheme($name, $image_hash,
810 base64_decode($image),
814 if ($bg_id == 'username and password mismatch.') {
815 throw new XML_RPC2_FaultException(
816 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
817 self
::USERNAME_AND_PASSWORD_MISMATCH
);
819 else if ($bg_id == 'file hash and file data mismatch.') {
820 throw new XML_RPC2_FaultException(
821 self
::HASH_AND_DATA_MISMATCH_MSG
,
822 self
::HASH_AND_DATA_MISMATCH
);
825 IrrecoLog
::$database->log("Bg_id: " . $bg_id . "\n");
830 * Get id list of backgrounds for theme
832 * @param int theme_id id of theme
835 function getBackgrounds($theme_id)
837 IrrecoLog
::$server->log('XML-RPC getBackgrounds');
838 $data = $this->database
->getBgList($theme_id);
841 foreach ($data as $item) {
842 array_push($array, intval($item->id
));
845 if (count($array) == 0) {
846 array_push($array, 0);
849 IrrecoLog
::$database->log("Bg id:\n" .
850 IrrecoLog
::getVarDump($array));
855 * Get all data from Background
857 * Returns name, image_hash, image_name,
858 * folder and base64 encoded image_data
859 * @param int id id-number for background.
862 function getBgById($id)
864 IrrecoLog
::$server->log('XML-RPC getBgById');
865 $array = $this->database
->getBg($id);
867 IrrecoLog
::$database->log("Bg:\n" .
868 IrrecoLog
::getVarDump($array));
875 * Returns TRUE if login successful, FALSE otherwise.
877 * @param string user Username
878 * @param string password sha1-hash of password
881 function loginToDB($user, $password)
883 IrrecoLog
::$server->log('XML-RPC loginToDB');
885 /* Check for faultCode */
886 if(strstr($user, "faultCode")) {
887 throw new XML_RPC2_FaultException(self
::FAULTCODE_ERROR_MSG
,
888 self
::FAULTCODE_ERROR
);
891 /* Check parameters here */
892 if(strlen($user) < 6) {
893 throw new XML_RPC2_FaultException(
894 self
::LOGIN_ERROR_MSG
,
898 if(strlen($password) < 6) {
899 throw new XML_RPC2_FaultException(
900 self
::LOGIN_ERROR_MSG
,
904 $return = $this->database
->loginToDB($user, $password);
906 if ($return == FALSE) {
907 throw new XML_RPC2_FaultException(
908 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
909 self
::USERNAME_AND_PASSWORD_MISMATCH
);
916 * Get max image-size in bytes
918 * Returns max image-size
921 function getMaxImageSize()
923 IrrecoLog
::$server->log('XML-RPC getMaxImageSize');
924 $val = trim(ini_get('post_max_size'));
925 $last = strtolower($val[strlen($val)-1]);
928 // The 'G' modifier is available since PHP 5.1.0
937 $val = $val / 2 - (100 * 1024); //divided by 2 because of base64
939 IrrecoLog
::$server->log("Max image-size: " . $val . "\n");
948 * @param string name Name of Remote
949 * @param string comment
950 * @param string category Name for Category. e.g. "Tv"
951 * @param string manufacturer Name for Manufacturer. e.g. "Sony"
952 * @param string model Name for Model. e.g. "Sony"
953 * @param string file_hash sha1-hash of file_data
954 * @param string file_name Name for File
955 * @param string file_data Content of file
956 * @param string user Username
957 * @param string password sha1-hash of password
960 function createNewRemote($name, $comment, $category, $manufacturer,
961 $model, $file_hash, $file_name, $file_data,
964 IrrecoLog
::$server->log('XML-RPC createNewRemote');
965 $remote_id = $this->database
->createNewRemote($name, $comment,
966 $category, $manufacturer, $model, $file_hash,
967 $file_name, $file_data, $user, $password);
969 if ($remote_id == 'username and password mismatch.') {
970 throw new XML_RPC2_FaultException(
971 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
972 self
::USERNAME_AND_PASSWORD_MISMATCH
);
974 else if ($remote_id == 'file hash and file data mismatch.') {
975 throw new XML_RPC2_FaultException(
976 self
::HASH_AND_DATA_MISMATCH_MSG
,
977 self
::HASH_AND_DATA_MISMATCH
);
980 IrrecoLog
::$database->log("Remote_id: " . $remote_id . "\n");
985 * Set Remote downloadable
987 * @param int id id-number for remote.
988 * @param bool downloadable
989 * @param string user Username
990 * @param string password sha1-hash of password
993 function setRemoteDownloadable($id, $downloadable, $user, $password)
995 IrrecoLog
::$server->log('XML-RPC RemoteSetDownloadable');
996 $success = $this->database
->setRemoteDownloadable($id,
1001 if ($success == 'username and password mismatch.') {
1002 throw new XML_RPC2_FaultException(
1003 self
::USERNAME_AND_PASSWORD_MISMATCH_MSG
,
1004 self
::USERNAME_AND_PASSWORD_MISMATCH
);