private static function initConfig() { if (self::$_no_of_instance == null) { $config = Zend_Registry::get('configuration'); if (isset($config->cachingfarm)) { if (isset($config->default_cache)) { self::$_default_instance = $config->default_cache; } $list = $config->cachingfarm->list; $arr = explode(',', $list); if (count($arr) > 0) { self::$_no_of_instance = count($arr); for ($i = 0; $i < self::$_no_of_instance; $i++) { $cache = $arr[$i]; if (isset($config->cachingfarm->{$cache})) { $con = $config->cachingfarm->{$cache}; $_enable = $con->enable; $_server = $con->host; $_port = $con->port; $debug = Globals::isDebug(); if (empty($debug)) { $debug = false; } if ($_enable) { //echo "i'm here with $cache - $_enable - $_server - $_port <br>"; $memcache = new Zing_Cache_ZingCache($_server, $_port, $debug); self::$_cache_array[$cache] = $memcache; } } } } } } }
function getGoodDistanceNew(SmrSector &$sector, $goodID, $transaction) { global $var, $container; // check if we already did this if (isset($var['good_distance'])) { // transfer this value transfer('good_distance'); // return this value return $var['good_distance']; } $x = Globals::getGood($goodID); switch ($transaction) { case 'Buy': $x['TransactionType'] = 'Sell'; break; case 'Sell': $x['TransactionType'] = 'Buy'; } $di = Plotter::findDistanceToX($x, $sector, true); if (is_object($di)) { $di = $di->getRelativeDistance(); } $container['good_distance'] = $di; return $di; }
function checkRepMySQL() { if (!Globals::$rep_mysql or !mysql_ping(Globals::$rep_mysql)) { Globals::$rep_mysql = mysql_pconnect(Config::$rep_mysqlhost . ':' . Config::$rep_mysqlport, Config::$rep_mysqluser, Config::$rep_mysqlpass); mysql_select_db(Config::$rep_mysqldb, Globals::$rep_mysql); } }
function checkRepMySQL() { if (!Globals::$mw_mysql or !mysqli_ping(Globals::$mw_mysql)) { Globals::$mw_mysql = mysqli_connect('p:' . Config::$mw_mysql_host, Config::$mw_mysql_user, Config::$mw_mysql_pass, Config::$mw_mysql_db, Config::$mw_mysql_port); mysqli_select_db(Globals::$mw_mysql, Config::$mw_mysql_db); } }
/** * Alterna entre los entornos disonibles * * @param string $next_environment Entorno a utilizar, si no se indica se * se utilizara el siguiente disponible */ public static function doSwitch($next_environment = null) { $environment = self::info(); if (empty($environment['available'])) { return false; } if ($next_environment === null) { $index = array_search($environment['current'], $environment['available']) + 1; if ($index >= count($environment['available'])) { $index = 0; } } else { $index = array_search($next_environment, $environment['available']); if (false === $index) { return false; } } $environment['current'] = $environment['available'][$index]; $info = json_encode($environment, JSON_PRETTY_PRINT); $path = Globals::get('base_path') . '/config/environment.json'; if (false === @file_put_contents($path, $info)) { return false; } return $environment['current']; }
public function __construct() { //set country //lookup country from subdomain // must be format like http://country.site.org $parts = explode('.', $_SERVER['HTTP_HOST']); self::$COUNTRY = $parts[0]; require_once 'settings.php'; $countryLoaded = false; if ($parts[1] == 'trainingdata') { Settings::$DB_DATABASE = Globals::$DB_TABLE_PREFIX . $parts[0]; self::$COUNTRY = $parts[0]; Settings::$COUNTRY_BASE_URL = 'http://' . $parts[0] . '.' . Globals::$DOMAIN; $countryLoaded = true; } error_reporting(E_ALL); // PATH_SEPARATOR = ; for windows, : for *nix $iReturn = ini_set('include_path', Globals::$BASE_PATH . PATH_SEPARATOR . Globals::$BASE_PATH . 'app' . PATH_SEPARATOR . (Globals::$BASE_PATH . 'ZendFramework' . DIRECTORY_SEPARATOR . 'library') . PATH_SEPARATOR . ini_get('include_path')); require_once 'Zend/Loader.php'; if ($countryLoaded) { //fixes mysterious configuration issue require_once 'Zend/Db/Adapter/Pdo/Mysql.php'; require_once 'Zend/Db.php'; //set a default database adaptor $db = Zend_Db::factory('PDO_MYSQL', array('host' => Settings::$DB_SERVER, 'username' => Settings::$DB_USERNAME, 'password' => Settings::$DB_PWD, 'dbname' => Settings::$DB_DATABASE)); require_once 'Zend/Db/Table/Abstract.php'; Zend_Db_Table_Abstract::setDefaultAdapter($db); } }
function channel_msg_sd_list($fp, $rdata, $account, $player) { if (preg_match('/^:(.*)!(.*)@(.*)\\sPRIVMSG\\s(.*)\\s:!sd list\\s$/i', $rdata, $msg)) { global $sds; $nick = $msg[1]; $user = $msg[2]; $host = $msg[3]; $channel = $msg[4]; echo_r('[SD_LIST] by ' . $nick . ' in ' . $channel); $refresh_per_hour = 250 * Globals::getGameSpeed($player->getGameID()); $refresh_per_sec = $refresh_per_hour / 3600; fputs($fp, 'PRIVMSG ' . $channel . ' :The following supply/demand list has been recorded:' . EOL); fputs($fp, 'PRIVMSG ' . $channel . ' :Sector Amount' . EOL); foreach ($sds as $sd) { if ($sd[3] == $channel) { $seconds_since_refresh = time() - $sd[2]; if ($seconds_since_refresh < 0) { $seconds_since_refresh = 0; } $amt_to_add = floor($seconds_since_refresh * $refresh_per_sec); if ($sd[1] + $amt_to_add > 4000) { fputs($fp, 'PRIVMSG ' . $channel . ' : ' . sprintf('%4s', $sd[0]) . ' ' . sprintf('%4s', 'full') . EOL); } else { fputs($fp, 'PRIVMSG ' . $channel . ' : ' . sprintf('%4s', $sd[0]) . ' ' . sprintf('%4s', $sd[1] + $amt_to_add) . EOL); } } } return true; } }
public static function checkModeAdmin() { if (session_id() == '') { @session_start("suite"); } $_SERVER['HTTP_SOURCE'] = isset($_SERVER['HTTP_SOURCE']) ? $_SERVER['HTTP_SOURCE'] : ""; if ($_SERVER['HTTP_SOURCE'] != "suite") { $manager = null; // controla o acesso ao manager, verificando a autenticação /*if(count(Globals::get('app/options/master/manager')) > 0 ){ $manager = Globals::get('app/options/master/manager'); }*/ if (count(Globals::get('settings/manager')) > 0) { $manager = Globals::get('settings/manager'); } //$manager = isset(Globals::get('app/options/master/manager/access/username'))?'1':null;//isset(Globals::get('app/options/master/manager'))?Globals::get('app/options/master/manager'):null; if ($manager != null) { $manager_access = count($manager->access) > 0 ? $manager->access : null; if ($manager_access != null && strpos(Globals::get('http/controllers/destination'), '!/manager/access') === false) { if (!isset($_SESSION["suite"])) { return false; } $sessionSuite = $_SESSION["suite"]; $sessionSuiteObj = json_decode($sessionSuite); if (!isset($sessionSuiteObj->manager->access)) { //$querys = "&querybefore=". Globals::get()->http->destination; header("location: " . Globals::get('path/manager/link') . "/manager/access"); return false; } } } //return false; } return true; }
public function saveAction() { require Globals::get('current/path/action/path') . "../ModelAssistent.php"; $modelAssistent = new ModelAssistent(); $data = $_POST['data']; $dataObj = json_decode($data); $option = ""; foreach ($dataObj as $key => $value) { foreach ($value as $key2 => $value2) { if ($option != "") { $option .= ","; } $option .= '"' . $key2 . '" : ' . json_encode($value2) . ''; } } $options = "{" . $option . "}"; $filename = Globals::get('path/domain/path') . 'options.json'; $result = file_put_contents($filename, $options); if ($result) { $status = "success"; } $optionsObj = json_decode($options); $modelAssistent->makeStruct($optionsObj); echo json_encode(array('status' => $status)); return array('continue' => false); }
public function post() { $post = Input::all(); $validator = Product::validate($post); $productId = $post['id']; if ($validator->fails()) { return Redirect::to('productos/' . $productId)->withErrors($validator)->withInput(); } else { $product = self::__checkExistence($productId); $isNew = false; if (!$productId) { $product = new Product(); $isNew = true; } $product->name = $post['name']; $product->description = $post['description']; $product->code = $post['code']; $product->minimum_stock = $post['minimum_stock']; $product->cost = str_replace(',', '.', $post['cost']); $product->save(); if ($isNew) { Globals::triggerAlerts(4, array('productId' => $product->id)); } if ($post['status'] == 'inactive') { $product->delete(); } else { if ($product->trashed()) { $product->restore(); } } Session::flash('success', 'Producto guardado correctamente.'); return Redirect::to('productos'); } }
function doInit() { if (Config::$pass == null) { Config::$pass = trim(file_get_contents(getenv("HOME") . '/.cluebotng.password.only')); } API::init(); API::$a->login(Config::$user, Config::$pass); Globals::$mysql = false; checkMySQL(); Globals::$tfas = 0; Globals::$stdin = fopen('php://stdin', 'r'); Globals::$run = API::$q->getpage('User:'******'/Run'); Globals::$wl = API::$q->getpage('Wikipedia:Huggle/Whitelist'); Globals::$optin = API::$q->getpage('User:'******'/Optin'); Globals::$aoptin = API::$q->getpage('User:'******'/AngryOptin'); Globals::$stalk = array(); Globals::$edit = array(); $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutostalk.js')); foreach ($tmp as $tmp2) { if (substr($tmp2, 0, 1) != '#') { $tmp3 = explode('|', $tmp2, 2); Globals::$stalk[$tmp3[0]] = trim($tmp3[1]); } } $tmp = explode("\n", API::$q->getpage('User:'******'/CBAutoedit.js')); foreach ($tmp as $tmp2) { if (substr($tmp2, 0, 1) != '#') { $tmp3 = explode('|', $tmp2, 2); Globals::$edit[$tmp3[0]] = trim($tmp3[1]); } } }
function cacheCleanAction() { if ($this->getRequest()->getOption('all')) { Globals::getCache()->clean(Zend_Cache::CLEANING_MODE_ALL); } else { Globals::getCache()->clean(Zend_Cache::CLEANING_MODE_OLD); } }
/** * Gets our cache * * @return Zend_Cache * */ static function getCache() { if (self::$_cache) { return self::$_cache; } self::$_cache = Zend_Cache::factory('Core', 'File', array('lifetime' => 60 * 60, 'automatic_serialization' => true), array('cache_dir' => realpath(dirname(__FILE__) . '/../cache/'))); return self::$_cache; }
public function logoutAction() { //$path = Globals::get('path/manager/link').'manager/access/out'; //$html = file_get_contents($path); Session::out(); header("location:" . Globals::get('path/manager/link')); return array('continue' => false, 'parameters' => array('title' => 'Suite Manager', 'subtitle' => 'Manager Tool', 'content' => ''), 'view' => array(array('html' => '$html'))); }
public function ICDCodeSearch($params) { ini_set('memory_limit', '256M'); $type = Globals::getGlobal('dx_code_type'); $query = is_object($params) ? $params->query : $params; /** * get last icd9 code revision */ $revision = $this->getLastRevisionByCodeType('ICD9'); $records = array(); $whereQuery = ''; $queries = explode(' ', $query); $wheres = array(); $wheresIndex = 0; foreach ($queries as $q) { $q = trim($q); $w0 = ':W0' . $wheresIndex; $wheres[$w0] = '%' . $q . '%'; $w1 = ':W1' . $wheresIndex; $wheres[$w1] = $q . '%'; $w2 = ':W2' . $wheresIndex; $wheres[$w2] = $q . '%'; $w3 = ':W3' . $wheresIndex++; $wheres[$w3] = $q . '%'; $whereQuery .= " AND (short_desc \tLIKE {$w0}\n OR long_desc \t\t LIKE {$w1}\n OR dx_code\t\t\t LIKE {$w2}\n OR formatted_dx_code\tLIKE {$w3}) "; } if ($type == 'ICD9' || $type == 'BOTH') { /** * ICD9 */ $sql = "SELECT dx_id AS id,\n\t\t\t\t\t\t formatted_dx_code,\n\t\t\t\t\t\t formatted_dx_code AS code,\n\t\t\t\t\t\t dx_code,\n\t\t\t\t\t\t dx_code \t\t\tAS xcode,\n\t\t\t\t\t\t long_desc,\n\t\t\t\t\t\t long_desc \t\tAS code_text,\n\t\t\t\t\t\t short_desc,\n\t\t\t\t\t\t 'ICD9-DX'\t\t\tAS code_type\n\t\t\t\t FROM icd9_dx_code\n\t WHERE active = '1'\n\t AND revision = '{$revision}'\n\t {$whereQuery}\n\t ORDER BY formatted_dx_code ASC"; $recordSet = $this->conn->prepare($sql); $recordSet->execute($wheres); $records = array_merge($records, $recordSet->fetchAll(PDO::FETCH_ASSOC)); } elseif ($type == 'ICD10' || $type == 'BOTH') { /** * get last icd10 code revision */ $revision = $this->getLastRevisionByCodeType('ICD10'); /** * ICD10 DX */ $sql = "SELECT dx_id AS id,\n\t\t\t\t\t\t formatted_dx_code,\n\t\t\t\t\t\t formatted_dx_code AS code,\n\t\t\t\t\t\t dx_code,\n\t\t\t\t\t\t dx_code \t\t\tAS xcode,\n\t\t\t\t\t\t long_desc,\n\t\t\t\t\t\t TRIM(long_desc) \t\tAS code_text,\n\t\t\t\t\t\t short_desc,\n\t\t\t\t\t\t 'ICD10-CM'\t\tAS code_type\n\t\t\t\t\t FROM icd10_dx_order_code\n WHERE active = '1'\n AND revision = '{$revision}'\n {$whereQuery}\n ORDER BY formatted_dx_code ASC"; $recordSet = $this->conn->prepare($sql); $recordSet->execute($wheres); $records = array_merge($records, $recordSet->fetchAll(PDO::FETCH_ASSOC)); } if (is_object($params)) { $total = count($records); if (isset($params->start) && isset($params->limit)) { $records = array_slice($records, $params->start, $params->limit, true); } return array('totals' => $total, 'rows' => $records); } else { return $records; } }
public function open($db) { $this->db = (string) $db; $dbglobs = Globals::getDBInfo(); $host_port = (string) $dbglobs[0] . ':' . (string) $dbglobs[2]; // connection to testing database $this->connect = mysql_connect($host_port, $dbglobs[3], $dbglobs[4]) or die(mysql_error()); $select = mysql_select_db($this->db, $this->connect) or die(mysql_error()); }
public static function in_array_r($needle, $haystack, $strict = false) { foreach ($haystack as $item) { if (($strict ? $item === $needle : $item == $needle) || is_array($item) && Globals::in_array_r($needle, $item, $strict)) { return true; } } return false; }
/** * verifica estrutura da aplicação esta correta * @return [type] [description] */ public function checkFirstAccess() { $pathApp = Globals::get('path/app/appbase/path'); $dirArray = Functions::scanOnlyDir($pathApp); if (count($dirArray) < 1) { return true; } else { return false; } }
public function AboutAction() { $link = '<a class="link" target="_blank" href="http://' . Globals::get('suite/site') . '">' . Globals::get('suite/site') . '</a>'; $html = '<dl>'; $html .= '<dt>Version</dt><dd>' . Globals::get('suite/version') . '</dd>'; $html .= '<dt>Author</dt><dd>' . Globals::get('suite/author') . '</dd>'; $html .= '<dt>Site</dt><dd>' . $link . '</dd>'; $html .= '</dl>'; return array('continue' => true, 'parameters' => array('title' => 'About Suite', 'subtitle' => 'Framework for developed web', 'content' => $html)); }
public static function detect_current_rscript() { if (strtoupper(substr(PHP_OS, 0, 3)) == "WIN") { Globals::$Rscript_current = Globals::$RScript_Windows; Globals::$R_current = Globals::$R_Windows; } else { Globals::$Rscript_current = Globals::$RScript_Linux; Globals::$R_current = Globals::$R_Linux; } }
public function authenticate() { $adminuser = Globals::getConfig()->sumaserver->admin->user; $adminpass = Globals::getConfig()->sumaserver->admin->pass; if ($adminuser === $this->_username && $adminpass === $this->_password) { return new Zend_Auth_Result(Zend_Auth_Result::SUCCESS, "admin"); } else { return new Zend_Auth_Result(Zend_Auth_Result::FAILURE, "admin"); } }
/** * @return array */ public static function getGlobalsArray() { if (self::$g == null) { self::$g = MatchaModel::setSenchaModel('App.model.administration.Globals'); } $gs = array(); foreach (self::$g->load()->all() as $g) { $gs[$g['gl_name']] = $g['gl_value']; } return $gs; }
private function __construct() { $this->set_routing_table(); $a_get_request = Globals::get('_GET'); $m_route = array(); if (isset($a_get_request['viewfile']) && !is_null($a_get_request['viewfile'])) { $m_route = explode('/', $a_get_request['viewfile']); } else { $m_route[0] = 'start'; } $a_route = $this->get_route($m_route[0]); if ($a_route !== false) { if ($a_route['type'] === 'class') { try { $o_reflect_class = new ReflectionClass($m_route[0] . '\\' . $a_route['file']); if ($o_reflect_class->hasMethod($m_route[1])) { if ($m_route[0] === 'ajax') { $o_reflect_class->newInstance($m_route[1]); exit(1); } else { $o_reflect_method = $o_reflect_class->getMethod($m_route[1]); if ($o_reflect_method->isStatic()) { $o_reflect_method->invoke(null); } else { $o_reflect_method->invoke($o_reflect_class->newInstance()); } } } } catch (ReflectionException $e) { try { $o_reflect_class = new ReflectionClass($m_route[0] . '\\' . $a_route['file']); if ($o_reflect_class->hasMethod($a_route['default_method'])) { $o_reflect_method = $o_reflect_class->getMethod($a_route['default_method']); if ($o_reflect_method->isStatic()) { $o_reflect_method->invoke(null); } else { $o_reflect_method->invoke($o_reflect_class->newInstance()); } } } catch (ReflectionException $e) { echo $e->getMessage(); } } } } /* $size = sizeof($m_view_file)-1; self::$s_current_request_file = $m_view_file[$size]; unset($m_view_file[$size]); $m_view_file = implode('/',$m_view_file); self::$s_current_request_path = $m_view_file; */ }
public function open($db) { $this->db = (string) $db; $dbglobs = Globals::getDBInfo(); $host_port = (string) $dbglobs[0] . ':' . (string) $dbglobs[2]; //echo $host_port; // connection to testing database $this->connect = mysql_connect('localhost', $dbglobs[3], $dbglobs[4]) or die(mysql_error()); $select = mysql_select_db($this->db, $this->connect) or die(mysql_error()); //$this->connect = mysql_connect('localhost','root','') or die(mysql_error()); //$select = mysql_select_db('hacker_blog',$this->connect) or die("can't connect to blog db"); }
public function dispatchLoopShutdown() { if (Globals::isDebug()) { $print = ""; self::$_time_end_render = gettimeofday(true); $print = $this->dumpPageRenderProfiler(self::$_time_start_render, self::$_time_end_render); $print .= $this->dumpCacheProfiler(); $print .= '<br><br>' . ProfilerLog::dumpLog(); $print .= $this->dumpDbProfiler(); $this->getResponse()->appendBody($print); } }
public function welcomeAction() { //$html = Globals::get()->http->destination; $content = "<br>You can access the manager page to administer your application"; $content .= "<br><br><strong style='min-width:100px;display:inline-table'>Username:</strong> admin"; $content .= "<br><strong style='min-width:100px;display:inline-table'>Password:</strong> admin"; $content .= '<a href="' . Globals::get('path/manager/link') . '">Go to Manager</a>'; $content .= '<br>Use the assistant to create the application structure. '; $content .= '<a href="' . Globals::get('path/manager/link') . '/manager/assistant">Go to Assistant</a>'; $content .= '<br>for help and instructions to develop, visit the link below.'; $content .= '<a href="' . Globals::get('path/manager/link') . '/manager/help">Go to Help</a>'; return array('continue' => true, 'parameters' => array('title' => 'Wellcome', 'subtitle' => 'You can now develop your application.', 'content' => $content)); }
function buildPage($controllers) { $tmp = Globals::getPageInfo(); if ($controllers != null) { if (is_array($controllers)) { foreach ($controllers as $controller) { include $tmp[1] . (string) $controller . '_controller.php'; } } elseif (is_string($controllers)) { include $tmp[1] . (string) $controllers . '_controller.php'; } } }
public static function append($id, $msg) { // blockieren Semphore::p(); $counter = Globals::get('counter', 0); $counter++; Globals::put('counter', $counter); $textToAdd = $counter . ";" . $id . ";" . time() . ";" . $msg . PHP_EOL; $myfile = fopen(self::FILE, "a") or die("Unable to open file!"); fwrite($myfile, $textToAdd); fclose($myfile); // freigeben Semphore::v(); }
public static function getAll($unFiltered = true) { $db = Globals::getDBConn(); $select = $db->select()->from('session')->order('start DESC'); if ($unFiltered == false) { $select->where('deleted != 1'); } $rows = $select->query()->fetchAll(); $sessions = array(); foreach ($rows as $row) { $sessions[] = new SessionModel($row['id']); } return $sessions; }
public function buildPage() { $tmp = Globals::getPageInfo(); //echo "Cool".$this->controller; if ($this->controller != null) { if (is_array($this->controller)) { foreach ($this->controller as $controller) { $_SERVER . (include $tmp[1] . (string) $controller . '_controller.php'); echo $tmp[1] . (string) $controller . '_controller.php'; } } elseif (is_string($this->controller)) { $_SERVER . (include $tmp[1] . (string) $this->controllers . '_controller.php'); } } }