public function testAutomaticaly() { I18n::SetDefault("en"); I18n::load("en"); $res = I18n::get_answer_from_google("Bienvenue, veuillez vous identifier\nContacter le créateur de l'application", "fr"); $this->assertEquals($res[0], "Welcome, please log"); $this->assertEquals($res[1], "Contact the creator of the application"); }
function __($text, $lgfrom = "auto") { //return $text; if ($lgfrom === "auto") { $lgfrom = I18n::GetDefault(); } $calledFrom = debug_backtrace(); //return "<span id=\"".sha1($text)."\" lang=\"".$_LG->Get()."\">".$_LG->_($text,$lgfrom,$calledFrom[0]['file'],$calledFrom[0]['line'])."</span>"; $file = str_replace(ROOT . "/", '', $calledFrom[0]['file']); $var = I18n::_($text, $lgfrom, $file, $calledFrom[0]['line']); //debug(I18n::$_translations); if (preg_match_all('#\\[(\\w+)]#', $var, $m)) { //print_r( $m ); } if (count($m[1]) > 0) { $replace_with = array(); foreach ($m[1] as $species) { $scientific_name = str_replace("_", " ", $species); $sql = "SELECT b.text \r\n\t\t\t\tFROM species_main a\r\n\t\t\t\tinner JOIN scientific_name_translation b ON a.id = b.id_species_main AND b.id_species_sub = 0 and b.is_valid=1\r\n\t\t\t\tINNER JOIN language c ON c.iso3 = b.language AND c.iso = '" . I18n::Get() . "'\r\n\t\t\twhere a.scientific_name ='" . $scientific_name . "'"; $res = I18n::getDb()->sql(I18n::DATABASE)->sql_query($sql); if (I18n::getDb()->sql(I18n::DATABASE)->sql_num_rows($res) == 1) { $ob = I18n::getDb()->sql(I18n::DATABASE)->sql_fetch_object($res); $replace_with[] = $ob->text . " (" . $scientific_name . ")"; } else { $replace_with[] = $scientific_name; } } $var = str_replace($m[0], $replace_with, $var); } return $var; }
function stop($param) { $id_daemon = $param[0]; $id_daemon = 1; $db = $this->di['db']->sql(DB_DEFAULT); $this->view = false; $this->layout_name = false; $sql = "SELECT * FROM daemon_main where id ='" . $id_daemon . "'"; $res = $db->sql_query($sql); if ($db->sql_num_rows($res) !== 1) { $msg = I18n::getTranslation(__("Impossible to find the daemon with the id : ") . "'" . $id_daemon . "'"); $title = I18n::getTranslation(__("Error")); set_flash("error", $title, $msg); header("location: " . LINK . $this->url); exit; } $ob = $db->sql_fetch_object($res); if ($this->isRunning($ob->pid)) { $msg = I18n::getTranslation(__("The daemon with pid : '" . $ob->pid . "' successfully stopped ")); $title = I18n::getTranslation(__("Success")); set_flash("success", $title, $msg); $cmd = "kill " . $ob->pid; shell_exec($cmd); //shell_exec("echo '[" . date("Y-m-d H:i:s") . "] DAEMON STOPPED !' >> " . $ob->log_file); $this->logger->info(Color::getColoredString('Stopped daemon with the pid : ' . $ob->pid, "white", "red")); } else { if (!empty($pid)) { $this->logger->info(Color::getColoredString('Impossible to find the daemon with the pid : ' . $pid, "yellow")); } $msg = I18n::getTranslation(__("Impossible to find the daemon with the pid : ") . "'" . $ob->pid . "'"); $title = I18n::getTranslation(__("Daemon was already stopped or in error")); set_flash("caution", $title, $msg); } sleep(1); if (!$this->isRunning($ob->pid)) { $sql = "UPDATE daemon_main SET pid ='0' WHERE id = '" . $id_daemon . "'"; $db->sql_query($sql); } else { $this->logger->info(Color::getColoredString('Impossible to stop daemon with pid : ' . $pid, "white", "red")); throw new Exception('PMACTRL-876 : Impossible to stop daemon with pid : "' . $ob->pid . '"'); } header("location: " . LINK . $this->url); }
function stop($param) { $id_cleaner = $param[0]; $db = $this->di['db']->sql(DB_DEFAULT); $this->view = false; $this->layout_name = false; $sql = "SELECT * FROM cleaner_main where id ='" . $id_cleaner . "'"; $res = $db->sql_query($sql); if ($db->sql_num_rows($res) !== 1) { $msg = I18n::getTranslation(__("Impossible to find the cleaner with the id : ") . "'" . $id_cleaner . "'"); $title = I18n::getTranslation(__("Error")); set_flash("error", $title, $msg); header("location: " . LINK . "cleaner/index"); exit; } $ob = $db->sql_fetch_object($res); if ($this->isRunning($ob->pid)) { $msg = I18n::getTranslation(__("The cleaner with pid : '" . $ob->pid . "' successfully stopped ")); $title = I18n::getTranslation(__("Success")); set_flash("success", $title, $msg); $cmd = "kill " . $ob->pid; shell_exec($cmd); shell_exec("echo '[" . date("Y-m-d H:i:s") . "] CLEANER STOPED !' >> " . $ob->log_file); } else { $msg = I18n::getTranslation(__("Impossible to find the cleaner with the pid : ") . "'" . $ob->pid . "'"); $title = I18n::getTranslation(__("Cleaner was already stopped or in error")); set_flash("caution", $title, $msg); } sleep(1); if (!$this->isRunning($ob->pid)) { $sql = "UPDATE cleaner_main SET pid ='0' WHERE id = '" . $id_cleaner . "'"; $db->sql_query($sql); } else { throw new Exception('PMACTRL-875 : Impossible to stop cleaner with pid : "' . $ob->pid . '"'); } header("location: " . LINK . "cleaner/index"); }
<?php use Glial\I18n\I18n; use Glial\Synapse\FactoryController; echo "<!DOCTYPE html>\n"; echo "<html lang=\"" . I18n::Get() . "\">"; echo "<head>\n"; echo "<!--\n"; echo SITE_LOGO; echo "Powered by Esysteme (www.esysteme.com)\n"; echo "-->"; echo "<meta charset=utf-8 />\n"; echo "<meta name=\"Keywords\" content=\"\" />\n"; echo "<meta name=\"Description\" content=\"\" />\n"; echo "<meta name=\"Author\" content=\"Aurelien LEQUOY\" />\n"; echo "<meta name=\"robots\" content=\"index,follow,all\" />\n"; echo "<meta name=\"generator\" content=\"GLIALE 1.1\" />\n"; echo "<meta name=\"runtime\" content=\"[PAGE_GENERATION]\" />\n"; echo "<link rel=\"shortcut icon\" href=\"favicon.ico\" />"; echo "<title>" . strip_tags($GLIALE_TITLE) . " - " . SITE_NAME . " " . SITE_VERSION . "</title>\n"; ?> <link href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAMAAABEpIrGAAABdFBMVEUAAABDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMdDhMeYweDeAAAAe3RSTlMAAQIDBAUGBwgJCgsNDg8QERITFxgaHB4gISIjJSYnKCksLS4vMTIzNTY3ODk7PD0+QEFCR0lMTVFSVFZZW11hYmNna2xtb3B0dXd4fIKDiYuOj5KVnZ6goqWoqq2wtbq+wMHDxcfI0dPV2drc3uTm6Ovt7/Hz9ff5+/0KBW49AAABeUlEQVQYGXXBC1sSURQF0H1nREEJAjPMNM0hNCWzBMwkzd4lVqb2kMpKBPMJoiXuP+8cBpEP5q4Fx5WpjwVeKmXnehUujefZ6uSVF46OTbo7HUfVd2oFIKg3DEE9C+KYWgMQs9TZNlA1eURXyx7UGPF1NttZCKAmCpvRM7Gw+nu7WCnv5rPvUoM+2LxXIfjzloIL/8tTC4JkeWk0ZKJB5425HEkLokTH4bcPi8/S86+XVvNndPRDJKmzpVAVO6CrjIkaFft8xiaFJ12oicOmuuPzK78KxUp5d2v9TbK/A7ZACIL7j4No1Rb9SguCttJKerTH5zEUoMz20FDybZ42C2KHWhGIyH9qvIfDm6nQxZ8h1JnRzF82OvmSCuLCjzCE0RUZuZ+YmX44NhhqgzDTtyHIbMyDFt0vjmlBUOQWEzf97aYCDI/v2tjTtX+0DUNsUCsM4d+jxiM4jPQRXayFUaf6nufYqPhpwosmynf9zr3ETOrB3YGgibpzl+IgDrtTZxkAAAAASUVORK5CYII=" rel="icon" type="image/x-icon"> <link rel="stylesheet" type="text/css" href="<?php echo CSS; ?> bootstrap.css"> <link rel="stylesheet" type="text/css" href="<?php echo CSS; ?> autocomplete.css" /> <link rel="stylesheet" type="text/css" href="<?php
public function authenticate($check_post = true) { if ($_SERVER['REQUEST_METHOD'] == "POST" && $check_post) { if (empty($_POST[self::$_tableName][self::$_login])) { return false; } if (empty($_POST[self::$_tableName][self::$_passwd])) { return false; } if (empty($_POST[self::$_tableName][self::$_login]) || empty($_POST[self::$_tableName][self::$_passwd])) { return true; } $Identity = self::$_dbLink->sql_real_escape_string($_POST[self::$_tableName][self::$_login]); $Credential = self::$_dbLink->sql_real_escape_string($_POST[self::$_tableName][self::$_passwd]); $hash_password = $this->hash_password($Identity, $Credential); if (LDAP_CHECK) { if ($ldap = $this->checkLdap($Identity, $Credential)) { $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . $Identity . "'"; $res = self::$_dbLink->sql_query($sql); $data = array(); if (self::$_dbLink->sql_num_rows($res) === 1) { $ob = self::$_dbLink->sql_fetch_object($res); $this->_user = $ob; $data[self::$_tableName]['id'] = $ob->id; $data[self::$_tableName][self::$_passwd] = $hash_password; $data[self::$_tableName]['date_last_login'] = date('Y-m-d H:i:s'); $data[self::$_tableName]['date_last_connected'] = date('Y-m-d H:i:s'); } elseif (self::$_dbLink->sql_num_rows($res) === 0) { $data[self::$_tableName]['date_last_login'] = date('Y-m-d H:i:s'); $data[self::$_tableName]['date_last_connected'] = date('Y-m-d H:i:s'); $data[self::$_tableName][self::$_passwd] = $hash_password; $data[self::$_tableName][self::$_login] = $ldap['samaccountname'][0]; $data[self::$_tableName]['email'] = $ldap['mail'][0]; $data[self::$_tableName]['name'] = strtoupper($ldap['sn'][0]); $data[self::$_tableName]['firstname'] = $ldap['givenname'][0]; $data[self::$_tableName]['ip'] = $_SERVER["REMOTE_ADDR"]; $data[self::$_tableName]['date_created'] = substr($ldap['whencreated'][0], 0, 4) . "-" . substr($ldap['whencreated'][0], 4, 2) . "-" . substr($ldap['whencreated'][0], 6, 2) . " " . substr($ldap['whencreated'][0], 8, 2) . ":" . substr($ldap['whencreated'][0], 10, 2) . ":" . substr($ldap['whencreated'][0], 12, 2); $data[self::$_tableName]['id_group'] = 2; $data[self::$_tableName]['is_valid'] = 0; } else { throw new \Exception('GLI-999 : Whilte list failed'); } if (!self::$_dbLink->sql_save($data)) { debug($data); debug(self::$_dbLink->sql_error()); die; } $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . self::$_dbLink->sql_real_escape_string($ldap['samaccountname'][0]) . "'"; $res = self::$_dbLink->sql_query($sql); $ob = self::$_dbLink->sql_fetch_object($res); $this->_user = $ob; $this->id_user = $ob->id; setcookie(self::$_name_cookie_login, $ob->{self::$_login}, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true); setcookie(self::$_name_cookie_passwd, $hash_password, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true); return true; } return false; } else { $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . $Identity . "'"; $res = self::$_dbLink->sql_query($sql); if (self::$_dbLink->sql_num_rows($res) === 1) { $ob = self::$_dbLink->sql_fetch_object($res); $this->id_user = $ob->id; if ($hash_password === $ob->{self::$_passwd}) { $this->_user = $ob; setcookie(self::$_name_cookie_login, $ob->{self::$_login}, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true); setcookie(self::$_name_cookie_passwd, $hash_password, time() + AUTH_SESSION_TIME, '/', $_SERVER['SERVER_NAME'], false, true); return true; } } } } if (empty($_POST[self::$_tableName][self::$_login])) { if (!empty($_COOKIE[self::$_name_cookie_login]) && !empty($_COOKIE[self::$_name_cookie_passwd])) { $sql = "select * from " . self::$_tableName . " where " . self::$_login . " = '" . self::$_dbLink->sql_real_escape_string($_COOKIE[self::$_name_cookie_login]) . "'"; $res = self::$_dbLink->sql_query($sql); if (self::$_dbLink->sql_num_rows($res) === 1) { $ob = self::$_dbLink->sql_fetch_object($res); if ($_COOKIE[self::$_name_cookie_passwd] === $ob->{self::$_passwd}) { //if (password_verify($ob->{self::$_passwd}, $_COOKIE[self::$_name_cookie_passwd]) ) { $this->_user = $ob; if ($ob->is_valid == 0) { if ($_SERVER['REQUEST_METHOD'] === "GET") { $msg = I18n::getTranslation(__("Hello,") . "<br />" . __("Thank you for registering.") . "<br />" . __("To finalise your registration, an administrator have to give you a role.")); $title = I18n::getTranslation(__("Restricted access")); set_flash("caution", $title, $msg); } } return true; } } } } return false; }
function index() { //remove view $this->view = false; //to make sexy install ? //header echo PHP_EOL . Glial::header() . PHP_EOL; // ini_set('display_errors', '0'); $drivers = $this->testDatabases(); ini_set('display_errors', '1'); $map_driver_with_ext = array("mysql" => "mysqli", "pgsql" => "pgsql", "sybase" => "sybase", "oracle" => "oci8"); $ext = array(); foreach ($drivers as $driver) { $ext[] = $map_driver_with_ext[$driver]; } $this->testPhpComponent($ext); //making tree directory $fct = function ($msg) { $dirs = array("data", "data/img", "documentation", "tmp/crop", "tmp/documentation", "application/webroot/js", "application/webroot/css", "application/webroot/file", "application/webroot/video", "application/webroot/image"); $error = array(); foreach ($dirs as $dir) { $dir = $_SERVER['PWD'] . "/" . $dir; if (!file_exists($dir)) { if (!mkdir($dir)) { echo $this->out("Impossible to create this directory : " . $dir . " ", "KO"); } } } return array(true, $msg); }; $this->anonymous($fct, "Making tree directory"); // replace and install lastest jQuery $fct = function ($msg) { $name = "jquery-latest.min.js"; $jQuery = $_SERVER['PWD'] . "/application/webroot/js/" . $name; $old_version = ""; if (file_exists($jQuery)) { $data = file_get_contents($jQuery); preg_match("/v[\\d]+\\.[\\d]+\\.[\\d]+/", $data, $version); $old_version = $version[0] . " => "; $this->cmd("rm " . $jQuery, "Delete old jQuery"); } $this->cmd("cd " . $_SERVER['PWD'] . "/application/webroot/js && wget -q http://code.jquery.com/" . $name, "Download lastest jQuery"); if (file_exists($jQuery)) { $data = file_get_contents($jQuery); preg_match("/v[\\d]+\\.[\\d]+\\.[\\d]+/", $data, $version); $msg = sprintf($msg, $old_version . Color::getColoredString($version[0], "green")); return array(true, $msg); } else { $msg = sprintf($msg, "NOT INSTALLED"); return array(false, $msg); } }; $this->anonymous($fct, "jQuery installed (%s)"); //$this->cmd("chown www-data:www-data -R *", "Setting right to www-data:www-data"); $this->cmd("php glial administration admin_index_unique", "Generating DDL cash for index"); $this->cmd("php glial administration admin_table", "Generating DDL cash for databases"); $this->cmd("php glial administration generate_model", "Making model with reverse engineering of databases"); $fct = function ($msg) { $file = $_SERVER['PWD'] . "/glial"; $data = file_get_contents($file); $new_data = str_replace("php application", "php " . $_SERVER['PWD'] . "/application", $data); if (!file_put_contents($file, $new_data)) { return array(false, $msg); } return array(true, $msg); }; $this->anonymous($fct, "Replace relative path by full path in Glial exec"); $fct = function ($msg) { $file = $_SERVER['PWD'] . "/glial"; $path_to_php = exec("which php", $res, $code); if ($code !== 0) { return array(false, $msg . " {$code}:{$path_to_php}: can't find php"); } $data = file($file); $data[0] = "#!" . $path_to_php . PHP_EOL; file_put_contents($file, implode("", $data)); return array(true, $msg); }; $this->anonymous($fct, "get full path of php"); $this->cmd("chmod +x glial", "Setting chmod +x to executable 'glial'"); $this->cmd("cp -a glial /usr/local/bin/glial", "Copy glial to /usr/local/bin/"); \Glial\I18n\I18n::install(); // \Glial\I18n\I18n::unInstall(); /* shell_exec("find " . $_SERVER['PWD'] . " -type f -exec chmod 740 {} \;;"); echo $this->out("Setting chmod 440 to all files", "OK"); shell_exec("find " . $_SERVER['PWD'] . " -type d -exec chmod 750 {} \;;"); echo $this->out("Setting chmod 550 to all files", "OK"); shell_exec("find " . $_SERVER['PWD'] . "/tmp -type f -exec chmod 770 {} \;;"); echo $this->out("Setting chmod 660 to all files of /tmp", "OK"); shell_exec("find " . $_SERVER['PWD'] . "/tmp -type d -exec chmod 770 {} \;;"); echo $this->out("Setting chmod 660 to all directory of /tmp", "OK"); */ //echo $this->di['acl']; //echo $this->di['db']; }
function index($params) { /* * SHOW TABLES * SHOW COLUMNS FROM table_name * */ $this->layout_name = 'pmacontrol'; $db = $this->di['db']->sql(DB_DEFAULT); $this->db_default = $db; $this->title = __("Compare"); $this->ariane = "> " . '<a href="' . LINK . 'Plugins/index/">' . __('Plugins') . "</a> > " . $this->title; $redirect = false; if ($_SERVER['REQUEST_METHOD'] == "POST") { $id_server1 = empty($_POST['compare_main']['id_mysql_server__original']) ? "" : $_POST['compare_main']['id_mysql_server__original']; $id_server2 = empty($_POST['compare_main']['id_mysql_server__compare']) ? "" : $_POST['compare_main']['id_mysql_server__compare']; $db1 = empty($_POST['compare_main']['database__original']) ? "" : $_POST['compare_main']['database__original']; $db2 = empty($_POST['compare_main']['database__compare']) ? "" : $_POST['compare_main']['database__compare']; $out = $this->checkConfig($id_server1, $db1, $id_server2, $db2); if ($out !== true) { $extra = ""; foreach ($out as $msg) { $extra .= "<br />" . __($msg); } $msg = I18n::getTranslation(__("Please correct your paramaters !") . $extra); $title = I18n::getTranslation(__("Error")); set_flash("error", $title, $msg); $redirect = true; } header('location: ' . LINK . 'compare/index/compare_main:id_mysql_server__original:' . $id_server1 . '/compare_main:' . 'id_mysql_server__compare:' . $id_server2 . '/compare_main:' . 'database__original:' . $db1 . '/compare_main:' . 'database__compare:' . $db2); } $this->di['js']->addJavascript(array("jquery-latest.min.js", "jquery.browser.min.js", "jquery.autocomplete.min.js", "compare/index.js")); $sql = "SELECT * FROM mysql_server WHERE `error` = '' order by `name`"; $servers = $db->sql_fetch_yield($sql); $data['server'] = []; foreach ($servers as $server) { $tmp = []; $tmp['id'] = $server['id']; $tmp['libelle'] = str_replace('_', '-', $server['name']) . " (" . $server['ip'] . ")"; $data['server'][] = $tmp; } $data['listdb1'] = array(); if (!empty($_GET['compare_main']['id_mysql_server__original'])) { $select1 = $this->getDatabaseByServer(array($_GET['compare_main']['id_mysql_server__original'])); $data['listdb1'] = $select1['databases']; } $data['listdb2'] = array(); if (!empty($_GET['compare_main']['id_mysql_server__compare'])) { $select1 = $this->getDatabaseByServer(array($_GET['compare_main']['id_mysql_server__compare'])); $data['listdb2'] = $select1['databases']; } $data['display'] = false; if (count($data['listdb2']) != 0 && count($data['listdb1']) != 0) { if (!empty($_GET['compare_main']['database__original']) && !empty($_GET['compare_main']['database__compare'])) { $data['resultat'] = $this->analyse($_GET['compare_main']['id_mysql_server__original'], $_GET['compare_main']['database__original'], $_GET['compare_main']['id_mysql_server__compare'], $_GET['compare_main']['database__compare']); $data['display'] = true; //log $this->di['log']->warning('[Compare] ' . $_GET['compare_main']['id_mysql_server__original'] . ":" . $_GET['compare_main']['database__original'] . " vs " . $_GET['compare_main']['id_mysql_server__compare'] . ":" . $_GET['compare_main']['database__compare'] . "(" . $_SERVER["REMOTE_ADDR"] . ")"); } } $this->set('data', $data); }
$_SYSTEM['param'] = !empty($_SERVER["argv"][3]) ? $_SERVER["argv"][3] : ''; if ($_SERVER["argc"] > 3) { $params = array(); for ($i = 3; $i < $_SERVER["argc"]; $i++) { $params[] = $_SERVER["argv"][$i]; } $_SYSTEM['param'] = $params; } //cli_set_process_title("glial-" . $_SYSTEM['controller'] . "-" . $_SYSTEM['action']." (".$name.")"); } else { throw new InvalidArgumentException('usage : gial <controlleur> <action> [params]'); } define('LINK', WWW_ROOT . "en" . "/"); } else { //mode with apache define('LINK', WWW_ROOT . I18n::Get() . "/"); if (AUTH_ACTIVE) { $auth = new Auth(); $auth->setInstance($_DB->sql(DB_DEFAULT), "user_main", array("login", "password")); $auth->setFctToHashCookie(function ($password) { return password_hash($password . $_SERVER['HTTP_USER_AGENT'] . $_SERVER['REMOTE_ADDR'], PASSWORD_DEFAULT); }); $auth->authenticate(false); FactoryController::addDi("auth", $auth); } ENVIRONEMENT ? $_DEBUG->save("User connexion") : ""; $_SYSTEM['controller'] = \Glial\Utility\Inflector::camelize($url['controller']); $_SYSTEM['action'] = $url['action']; $_SYSTEM['param'] = $url['param']; $acl = new Acl(CONFIG . "acl.config.ini"); FactoryController::addDi("acl", $acl);
final function setLayout() { Variable::$_open = false; if (!IS_CLI) { global $_SITE; $GLIALE_CONTENT = $this->html; $GLIALE_TITLE = $this->title; $GLIALE_ARIANE = $this->ariane; ob_implicit_flush(false); ob_start(); Variable::$_open = true; include APP_DIR . DS . "layout" . DS . $this->layout_name . ".layout.php"; if (!$this->ajax) { //echo $this->js; echo $this->di['js']->getJavascript(); //echo $this->js; } echo "</html>\n"; //TODO a mettre ailleurs Variable::$_html = ob_get_clean(); Variable::$_html = I18n::getTranslation(Variable::$_html); echo Variable::$_html; } }
public function add() { //df -Ph . | tail -1 | awk '{print $2}' => to know space $db = $this->di['db']->sql(DB_DEFAULT); if ($_SERVER['REQUEST_METHOD'] == "POST") { Crypt::$key = CRYPT_KEY; $storage_area['backup_storage_area'] = $_POST['backup_storage_area']; if (!Ssh::testAccount($storage_area['backup_storage_area']['ip'], $storage_area['backup_storage_area']['port'], $storage_area['backup_storage_area']['ssh_login'], $storage_area['backup_storage_area']['ssh_password'])) { foreach ($_POST['backup_storage_area'] as $var => $val) { $ret[] = "backup_storage_area:" . $var . ":" . urlencode(html_entity_decode($val)); } $param = implode("/", $ret); $title = I18n::getTranslation(__("Failed to connect on ssh/scp/sFtp")); $msg = I18n::getTranslation(__("Please check your hostname and you credentials !")); set_flash("error", $title, $msg); header("location: " . LINK . "backup/storageArea/add/" . $param); exit; } $storage_area['backup_storage_area']['ssh_login'] = Crypt::encrypt($storage_area['backup_storage_area']['ssh_login']); $storage_area['backup_storage_area']['ssh_password'] = Crypt::encrypt($storage_area['backup_storage_area']['ssh_password']); if (!($id_storage_area = $db->sql_save($storage_area))) { $error = $db->sql_error(); $_SESSION['ERROR'] = $error; $title = I18n::getTranslation(__("Fail to add this storage area")); $msg = I18n::getTranslation(__("One or more problem came when you try to add this storage, please verify your informations")); set_flash("error", $title, $msg); foreach ($_POST['backup_storage_area'] as $var => $val) { $ret[] = "backup_storage_area:" . $var . ":" . urlencode(html_entity_decode($val)); } $param = implode("/", $ret); header("location: " . LINK . "backup/storageArea/add/" . $param); exit; } else { $this->getStorageSpace(array($id_storage_area)); $title = I18n::getTranslation(__("Successfull")); $msg = I18n::getTranslation(__("You storage area has been successfull added !")); set_flash("success", $title, $msg); } } $this->di['js']->addJavascript(array("http://www.estrildidae.net/js/jquery.1.3.2.js", "jquery.autocomplete.min.js")); //$this->di['js']->addJavascript(array("jquery-latest.min.js", "jquery.autocomplete.min.js")); $this->di['js']->code_javascript('$("#backup_storage_area-id_geolocalisation_city-auto").autocomplete("' . LINK . 'user/city/ajax>yes", { extraParams: { country: function() {return $("#backup_storage_area-id_geolocalisation_country").val();} }, mustMatch: true, autoFill: true, max: 100, scrollHeight: 302, delay:0 }); $("#backup_storage_area-id_geolocalisation_city-auto").result(function(event, data, formatted) { if (data) $("#backup_storage_area-id_geolocalisation_city").val(data[1]); }); $("#backup_storage_area-id_geolocalisation_country").change( function() { $("#backup_storage_area-id_geolocalisation_city-auto").val(""); $("#backup_storage_area-id_geolocalisation_city").val(""); } ); '); $sql = "SELECT id, libelle from geolocalisation_country where libelle != '' order by libelle asc"; $res = $db->sql_query($sql); $this->data['geolocalisation_country'] = $db->sql_to_array($res); $this->set('data', $this->data); }