function conf_is_valid() { if (!defined('SESSIONMANAGER_SPOOL')) { return 'SESSIONMANAGER_SPOOL is not defined'; } if (!defined('SESSIONMANAGER_LOGS')) { return 'SESSIONMANAGER_LOGS is not defined'; } if (!defined('SESSIONMANAGER_CONFFILE_SERIALIZED')) { return 'SESSIONMANAGER_CONFFILE_SERIALIZED is not defined'; } if (!defined('SESSIONMANAGER_ADMIN_LOGIN')) { return 'SESSIONMANAGER_ADMIN_LOGIN is not defined'; } if (!defined('SESSIONMANAGER_ADMIN_PASSWORD')) { return 'SESSIONMANAGER_ADMIN_PASSWORD is not defined'; } if (!is_writable2(SESSIONMANAGER_SPOOL)) { return 'SESSIONMANAGER_SPOOL is not writable : ' . SESSIONMANAGER_SPOOL; } if (!is_writable2(SESSIONMANAGER_LOGS)) { return 'SESSIONMANAGER_LOGS is not writable : ' . SESSIONMANAGER_LOGS; } if (!is_writable2(SESSIONMANAGER_CONFFILE_SERIALIZED)) { return 'SESSIONMANAGER_CONFFILE_SERIALIZED is not writable : ' . SESSIONMANAGER_CONFFILE_SERIALIZED; } return true; }
break; case 4: // UPLOAD_ERR_NO_FILE $have_file = false; break; } } if ($have_file) { $source_file = $upload['tmp_name']; if (!is_readable($source_file)) { popup_error(_('The file is not readable')); redirect(); } if (get_classes_startwith('Imagick') != array()) { $path_rw = $app->getIconPathRW(); if (is_writable2($path_rw)) { try { $mypicture = new Imagick(); $mypicture->readImage($source_file); $mypicture->scaleImage(32, 0); $mypicture->writeImage($app->getIconPathRW()); } catch (Exception $e) { popup_error(_('The icon is not an image')); redirect(); } } else { Logger::error('main', 'getIconPathRW (' . $path_rw . ') is not writeable'); redirect(); } } else { Logger::info('main', 'No Imagick support found');
public function application_webapp_clone($id_) { Logger::info('api', "application_webapp_clone"); $this->check_authorized('manageApplications'); $applicationDB = ApplicationDB::getInstance(); if (!$applicationDB->isWriteable()) { Logger::error('api', 'ApplicationDB is not writable'); return false; } $webapp_application_DB = WebAppConfDB::getInstance(); if (!$webapp_application_DB->isWriteable()) { Logger::info('api', 'WebAppConfDB is not writable'); return null; } $app = $applicationDB->import($id_); if (!is_object($app)) { Logger::error('api', 'Unknown application "' . $id_ . '"'); return false; } $icon_path = $app->getIconPath(); $app->unsetAttribute('id'); $app->setAttribute('static', 1); $app->setAttribute('revision', 1); $ret = $applicationDB->add($app); if (!$ret) { return false; } // Clone Icon if ($app->haveIcon()) { // We remove the application icon if already exists because it shouldn't $app->delIcon(); } $path_rw = $app->getIconPathRW(); if (is_writable2($path_rw)) { @file_put_contents($path_rw, @file_get_contents($icon_path)); } // Clone app config $app_configuration = $webapp_application_DB->search($id_); if ($app_configuration != NULL) { $application_id = $app->getAttribute('id'); $app_configuration->unsetAttribute('id'); $app_configuration->setAttribute('application_id', $application_id); if (!$webapp_application_DB->isOK($app_configuration)) { Logger::info('api', 'Application configuration is not ok'); $removed_stale_application = $this->application_webapp_remove($application_id); if ($removed_stale_application == false) { Logger::info('api', 'Failed to remove static application "' . $app->getAttribute('name') . '". Remove it manually'); } return null; } $configuration_id = $webapp_application_DB->add($app_configuration); if (!$configuration_id) { Logger::info('api', 'Failed to add application configuration for "' . $app->getAttribute('name') . '". Removing stale application'); $removed_stale_application = $this->application_webapp_remove($application_id); if ($removed_stale_application == false) { Logger::info('api', 'Failed to remove static application "' . $app->getAttribute('name') . '". Remove it manually'); } return null; } else { Logger::info('api', 'Added configuration for "' . $app->getAttribute('name') . '"'); } } $servers = Abstract_Server::load_available_by_role('webapps', true); foreach ($servers as $server) { $server->syncWebApplications(); } $this->log_action('application_webapp_clone', array('id' => $app->getAttribute('id'), 'name' => $app->getAttribute('name'))); return true; }