Example #1
0
 public function __call($method, $args)
 {
     // If observer enabled
     if (!$this->Config || $this->Config->GetFieldByName("IsEnabled")->Value == 0) {
         return;
     }
     $enabled = $this->Config->GetFieldByName("{$method}Notify");
     if (!$enabled || $enabled->Value == 0) {
         return;
     }
     $DB = \Scalr::getDb();
     // Event name
     $name = substr($method, 2);
     // Event message
     $message = $DB->GetOne("SELECT message FROM events WHERE event_id = ? LIMIT 1", array($args[0]->GetEventID()));
     $farm_name = $DB->GetOne("SELECT name FROM farms WHERE id=? LIMIT 1", array($args[0]->GetFarmID()));
     // Set subject
     if (!$farm_name) {
         $this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()})");
     } else {
         $this->Mailer->setSubject("{$name} event notification (FarmID: {$args[0]->GetFarmID()} FarmName: {$farm_name})");
     }
     // Set body
     $this->Mailer->setMessage($message);
     // Send mail
     try {
         $res = $this->Mailer->send();
     } catch (\Exception $e) {
         $res = false;
     }
     if (!$res) {
         Logger::getLogger(__CLASS__)->info("Mail sent to '{$this->Config->GetFieldByName("EventMailTo")->Value}'. Result: {$res}");
     }
 }
 /**
  * Get Logger instance. Creates if not already created.
  *
  * @return Logger
  */
 protected function getLogger()
 {
     if (is_null($this->logger)) {
         $this->logger = Logger::getLogger('core.SchedulerService');
     }
     return $this->logger;
 }
 /**
  * Get Logger instance. Creates if not already created.
  *
  * @return Logger
  */
 protected function getLogger()
 {
     if (is_null($this->logger)) {
         $this->logger = Logger::getLogger('leave.LeaveEntitlementDao');
     }
     return $this->logger;
 }
 /**
  * Get Logger instance. Creates if not already created.
  *
  * @return Logger
  */
 protected function getLoggerInstance()
 {
     if (is_null($this->logger)) {
         $this->logger = Logger::getLogger('leave.undeleteLeaveTypeAction');
     }
     return $this->logger;
 }
 public function execute($request)
 {
     if ($request->isMethod(sfWebRequest::POST)) {
         $username = $request->getParameter('txtUsername');
         $password = $request->getParameter('txtPassword');
         $additionalData = array('timeZoneOffset' => $request->getParameter('hdnUserTimeZoneOffset', 0));
         try {
             $success = $this->getAuthenticationService()->setCredentials($username, $password, $additionalData);
             if ($success) {
                 $this->getLoginService()->addLogin();
                 $paramString = $this->_getParameterString($request, true);
                 //$this->redirect('oauth/authorize'. $paramString);
                 $url = url_for('oauth/authorize') . $paramString;
                 $logger = Logger::getLogger('login');
                 $loggedInUserId = $this->getAuthenticationService()->getLoggedInUserId();
                 $loggedInUser = $this->getSystemUserService()->getSystemUser($loggedInUserId);
                 $logger->info($loggedInUserId . ', ' . $loggedInUser->getUserName() . ', ' . $_SERVER['REMOTE_ADDR']);
                 $this->redirect($url);
             } else {
                 $paramString = $this->_getParameterString($request);
                 $this->getUser()->setFlash('message', __('Invalid credentials'), true);
                 $this->redirect('oauth/login' . $paramString);
             }
         } catch (AuthenticationServiceException $e) {
             $this->getUser()->setFlash('message', $e->getMessage(), true);
             $paramString = $this->_getParameterString($request);
             $this->redirect('oauth/login' . $paramString);
         }
     }
     return sfView::NONE;
 }
Example #6
0
 private function removeNodeFromChefServer(DBServer $dbServer, $config, $nodeName)
 {
     $chefSettings = $dbServer->GetFarmRoleObject()->getChefSettings();
     $chefServerInfo = $this->db->GetRow("SELECT * FROM services_chef_servers WHERE id=?", array($chefSettings[self::ROLE_CHEF_SERVER_ID]));
     $chefServerInfo['auth_key'] = trim($this->getCrypto()->decrypt($chefServerInfo['auth_key'], $this->cryptoKey));
     $chefClient = Scalr_Service_Chef_Client::getChef($config->serverUrl, $chefServerInfo['username'], trim($chefServerInfo['auth_key']));
     try {
         $status = $chefClient->removeNode($nodeName);
         if ($status) {
             Logger::getLogger(LOG_CATEGORY::FARM)->warn(new FarmLogMessage($dbServer->farmId, sprintf("Chef node '%s' removed from chef server", $nodeName)));
         } else {
             Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $status)));
         }
     } catch (Exception $e) {
         Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $e->getMessage())));
     }
     try {
         $status2 = $chefClient->removeClient($nodeName);
         if ($status2) {
             Logger::getLogger(LOG_CATEGORY::FARM)->warn(new FarmLogMessage($dbServer->farmId, sprintf("Chef client '%s' removed from chef server", $nodeName)));
         } else {
             Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef client '%s' from chef server: %s", $nodeName, $status2)));
         }
     } catch (Exception $e) {
         Logger::getLogger(LOG_CATEGORY::FARM)->error(new FarmLogMessage($dbServer->farmId, sprintf("Unable to remove chef node '%s' from chef server: %s", $nodeName, $e->getMessage())));
     }
 }
Example #7
0
 /**
  * @param $config
  * @key string [name]
  * @key string [key]
  * @key array [items]
  */
 function __construct($config)
 {
     $this->logger = Logger::getLogger(__CLASS__);
     $this->initialConfig = $config;
     $this->shm = new Scalr_System_Ipc_Shm($config);
     $key = $this->shm->key + 8;
     $this->logger->debug(sprintf("Get semaphore (key: 0x%08x)", $key));
     $this->sem = sem_get($key, 1, 0666, true);
     if (!$this->sem) {
         throw new Scalr_System_Ipc_Exception("Cannot sem_get (key: {$key})");
     }
     if (!sem_acquire($this->sem)) {
         throw new Scalr_System_Ipc_Exception("Cannot acquire semaphore");
     }
     try {
         $meta = $this->getMeta();
         if ($meta === null) {
             $this->clear0();
         }
         sem_release($this->sem);
     } catch (Exception $e) {
         sem_release($this->sem);
         throw $e;
     }
     if ($config["items"]) {
         foreach ($config["items"] as $item) {
             $this->add($item);
         }
     }
 }
Example #8
0
 public function handle(EventMessage $event)
 {
     if ($event instanceof \PAMI\Message\Event\AsyncAGIEvent) {
         if ($event->getSubEvent() == 'Start') {
             switch ($pid = pcntl_fork()) {
                 case 0:
                     $logger = \Logger::getLogger(__CLASS__);
                     $this->_client = new ClientImpl($this->_pamiOptions);
                     $this->_client->open();
                     $agi = new \PAMI\AsyncAgi\AsyncClientImpl(array('pamiClient' => $this->_client, 'asyncAgiEvent' => $event));
                     $app = new MyPAGIApplication(array('pagiClient' => $agi));
                     $app->init();
                     $app->run();
                     //$agi->indicateProgress();
                     //$agi->answer();
                     //$agi->streamFile('welcome');
                     //$agi->playCustomTones(array("425/50","0/50"));
                     //sleep(5);
                     //$agi->indicateCongestion(10);
                     //$agi->hangup();
                     $this->_client->close();
                     echo "Application finished\n";
                     exit(0);
                     break;
                 case -1:
                     echo "Could not fork application\n";
                     break;
                 default:
                     echo "Forked Application\n";
                     break;
             }
         }
     }
 }
Example #9
0
 /**
  * @static
  * @param mixed $resource A resource that needs to be closed, for example a mysql connection
  * @param callable $callable (resource) => T Callable method that accepts $resource as parameter
  * @param string $close [Optional] Name of close method on $resource
  * @return mixed product of $callable (can be null)
  * @throws \Exception If resource is null or if there is a problem with the callable
  */
 public static function using($resource, $callable, $close = 'close')
 {
     if (!$resource) {
         throw new \InvalidArgumentException('Cannot loan a null resource');
     }
     $logger = \Logger::getLogger(__CLASS__);
     $problem = null;
     $result = null;
     try {
         $result = $callable($resource);
         $logger->debug('Successfully executed callable on resource');
     } catch (\Exception $e) {
         $logger->warn('Problem encountered using resource', $e);
         $problem = $e;
     }
     try {
         $resource->{$close}();
         $logger->debug('Successfully closed resource');
     } catch (\Exception $e) {
         $logger->warn('Problem encountered closing resource', $e);
         if ($problem) {
             $problem = new CompoundException($e->getMessage(), $e->getCode(), $problem);
         } else {
             // PHP has no built in support for re-throwing, so we explicitly do so
             throw $e;
         }
     }
     if ($problem) {
         throw $problem;
     }
     return $result;
 }
 /**
  * Get Logger instance
  * @return Logger
  */
 public function getLogger()
 {
     if (empty($this->logger)) {
         $this->logger = Logger::getLogger('leave.leavemailer');
     }
     return $this->logger;
 }
Example #11
0
 /**
  * @param $config
  * @key string $jobDir
  * @key string $clsSuffix
  * @key string $clsNamespace
  * @key bool $oldSyntax (default true)
  * TODO: add $getopt key
  * TODO: support new syntax: php -q cron.php [options] task 
  */
 function __construct($config)
 {
     foreach ($config as $k => $v) {
         $this->{$k} = $v;
     }
     $this->logger = Logger::getLogger(__CLASS__);
 }
Example #12
0
 function __construct($bridge, $version)
 {
     $this->bridge = $bridge;
     $this->version = $version;
     $this->defaultCharset = 'utf-8';
     $this->logger = Logger::getLogger(__CLASS__);
 }
 /**
  * Constructor
  * @ignore 
  */
 function __construct()
 {
     $this->Logger = Logger::getLogger('SignalHandler');
     if (!function_exists("pcntl_signal")) {
         self::RaiseError("Function pcntl_signal() not found. PCNTL must be enabled in PHP.", E_ERROR);
     }
 }
 public function getUserRoleManager()
 {
     $logger = Logger::getLogger('core.UserRoleManagerService');
     $class = $this->getUserRoleManagerClassName();
     $manager = null;
     if (class_exists($class)) {
         try {
             $manager = new $class();
         } catch (Exception $e) {
             throw new ServiceException('Exception when initializing user role manager:' . $e->getMessage());
         }
     } else {
         throw new ServiceException('User Role Manager class ' . $class . ' not found.');
     }
     if (!$manager instanceof AbstractUserRoleManager) {
         throw new ServiceException('User Role Manager class ' . $class . ' is not a subclass of AbstractUserRoleManager');
     }
     // Set System User object in manager
     $userId = $this->getAuthenticationService()->getLoggedInUserId();
     $systemUser = $this->getSystemUserService()->getSystemUser($userId);
     if ($systemUser instanceof SystemUser) {
         $manager->setUser($systemUser);
     } else {
         if ($logger->isInfoEnabled()) {
             $logger->info('No logged in system user when creating UserRoleManager');
         }
     }
     return $manager;
 }
Example #15
0
 public function __construct($fieldsAndValues)
 {
     $logger = Logger::getLogger('NounRoot.__construct');
     $logger->debug("new NounRoot");
     parent::__construct($fieldsAndValues);
     $logger->debug("new NounRoot, apr�s parent::__construct");
     $this->number = $fieldsAndValues['number'];
     if ($this->number == NULL || $this->number == '') {
         $this->number = 's';
     }
     $this->cf = $fieldsAndValues['cf'];
     if ($this->cf != NULL && $this->cf != '') {
         $this->cfs = explode(' ', $this->cf);
     }
     $this->dialect = $fieldsAndValues['dialect'];
     $this->source = $fieldsAndValues['source'];
     if ($this->source == NULL || $this->source == '') {
         $this->source = 'A2';
     }
     $this->sources = explode(' ', $this->source);
     // Racine de composition pour les racines duelles et plurielles
     $this->compositionRoot = $fieldsAndValues['compositionRoot'];
     $this->morphemeID = self::make_id($fieldsAndValues);
     $logger->debug("new NounRoot, exit");
 }
 public function Save(Location $location)
 {
     try {
         $SQL = self::$INSERT;
         if ($location->getSeq() != null && $location->getSeq() != "" && $location->getSeq() > 0) {
             $SQL = self::$UPDATE;
         }
         $conn = self::$db->getConnection();
         $stmt = $conn->prepare($SQL);
         $stmt->bindValue(':name', $location->getLocationName());
         $stmt->bindValue(':locationfolder', $location->getLocationFolder());
         $stmt->bindValue(':details', $location->getLocationDetails());
         $isPrivate = 0;
         if ($location->getIsPrivate() == true || $location->getIsPrivate() == 1) {
             $isPrivate = 1;
         }
         $stmt->bindValue(':hasdirectory', $location->getHasDirectory());
         $stmt->bindValue(':isprivate', $isPrivate);
         if ($SQL == self::$UPDATE) {
             $stmt->bindValue(':locationSeq', $location->getSeq());
         }
         $stmt->execute();
         $error = $stmt->errorInfo();
         if ($error[2] != "") {
             throw new Exception($error[2]);
         }
     } catch (Exception $e) {
         $logger = Logger::getLogger($ConstantsArray["logger"]);
         $logger->error("Error During Save Location : - " . $e->getMessage());
     }
     //I will be put code here for throw exception and show on the screen
 }
Example #17
0
 public static function __run(AppExecutionContext $context, MMapResponse $response)
 {
     // Kill "login" process if any
     $PM = ProcManager::getInstance();
     $procList = $PM->getProcessesTable();
     foreach ($procList as $proc) {
         switch ($proc->getName()) {
             case 'init':
                 break;
             case 'session':
                 break;
             default:
                 try {
                     $PM->kill($proc);
                 } catch (Exception $e) {
                     Logger::getLogger('eyeosmobile.session')->warn('Cannot kill login process ' . $proc . ': ' . $e->getMessage());
                 }
                 break;
         }
     }
     $args = $context->getArgs();
     // User information (cached in eyeos.js)
     $args[0] = EyeosApplicationExecutable::__callModule('UserInfo', 'getCurrentUserInfo', array());
     // Initial application(s) to launch (= static list $initApps excluding already running processes)
     //		$procList = ProcManager::getInstance()->getProcessesList();
     //$args[1] = array_diff(self::$initApps, $procList);
     //        $args[1] = array_values(array_diff(self::$initApps, $procList));
     //For the moment we just restore init application
     $args[1] = self::$initApps;
 }
Example #18
0
 public static function unicodeToLegacy($text)
 {
     $logger = Logger::getLogger('Prosyl.unicodeToLegacy');
     $transcodedText = '';
     $cnt = mb_strlen($text);
     $logger->debug("\$cnt= '{$cnt}'");
     $chars = str_split($text);
     $i = 0;
     while ($i < $cnt) {
         $c = mb_substr($text, $i++, 1);
         $logger->debug("\$c= '{$c}'");
         $nc = utf8::utf8_to_numeric($c);
         $lc = self::$unicode_to_legacy_codes[$nc];
         if ($nc <= 0x20) {
             $transcodedText .= $c;
         } elseif ($lc == NULL) {
             $transcodedText .= 'V';
         } elseif (is_numeric($lc)) {
             $transcodedText .= utf8::numeric_to_utf8($lc);
         } elseif (is_array($lc)) {
             $transcodedText .= implode('', array_map('utf8::numeric_to_utf8', $lc));
         } else {
             $transcodedText .= $lc;
         }
     }
     return $transcodedText;
 }
 /**
  * read from channel
  * @access       public
  * @param        IChannel Array()
  * @param        string
  * @param        int
  * @return       false or Array()
  * @todo         return must return Array with data or void Array
  */
 public function read($channels, $from, $lastId = 0)
 {
     $Logger = Logger::getLogger('system.Frameworks.EyeosModules.NetSync');
     $sql = 'SELECT `netsync_messages`.* FROM `netsync_messages` INNER JOIN subscriptions ON netsync_messages.timestamp >= subscriptions.since AND netsync_messages.to = subscriptions.channel AND subscriptions.who = :from WHERE `to` IN (';
     $bindParam = array('from' => $from);
     $i = 0;
     foreach ($channels as $channel) {
         $sql .= " :channel" . $i . ",";
         $bindParam['channel' . $i++] = $channel->getName();
     }
     if (count($channels) > 0) {
         $sql = substr($sql, 0, -1);
         $sql .= ')';
     } else {
         $sql = substr($sql, 0, -5);
     }
     //@todo this is a test!
     $sql .= ' AND netsync_messages.id > ' . $lastId;
     $stmt = $this->db->prepare($sql);
     $results = $this->db->execute($stmt, $bindParam);
     if (count($results) == 0) {
         return false;
     }
     return $results->fetchAll(PDO::FETCH_ASSOC);
 }
Example #20
0
 public function id()
 {
     $logger = Logger::getLogger('VerbWord.id');
     $id = self::make_id($this->field_values);
     $logger->debug("id: \n" . print_r($id, true));
     return $id->toString();
 }
Example #21
0
 public function OnBeforeInstanceLaunch(BeforeInstanceLaunchEvent $event)
 {
     if ($event->DBServer->platform != SERVER_PLATFORMS::EC2) {
         return;
     }
     $DBFarm = $event->DBServer->GetFarmObject();
     $DBFarmRole = $event->DBServer->GetFarmRoleObject();
     $AmazonEC2Client = $this->GetAmazonEC2ClientObject($event->DBServer->GetEnvironmentObject(), $DBFarmRole->CloudLocation);
     // Create EBS volume for MySQLEBS
     if ($event->DBServer->IsSupported("0.6")) {
     } else {
         if ($DBFarmRole->GetRoleObject()->hasBehavior(ROLE_BEHAVIORS::MYSQL) && $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == MYSQL_STORAGE_ENGINE::EBS) {
             $server = $event->DBServer;
             $masterServer = $DBFarm->GetMySQLInstances(true);
             $isMaster = !$masterServer || $masterServer[0]->serverId == $server->serverId;
             $farmMasterVolId = $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID);
             $createEbs = $isMaster && !$farmMasterVolId;
             if ($createEbs) {
                 Logger::getLogger(LOG_CATEGORY::FARM)->info(new FarmLogMessage($event->DBServer->farmId, sprintf(_("Need EBS volume for MySQL %s instance..."), $isMaster ? "Master" : "Slave")));
                 $CreateVolumeType = new CreateVolumeType();
                 $CreateVolumeType->availabilityZone = $event->DBServer->GetProperty(EC2_SERVER_PROPERTIES::AVAIL_ZONE);
                 $CreateVolumeType->size = $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_EBS_VOLUME_SIZE);
                 $res = $AmazonEC2Client->CreateVolume($CreateVolumeType);
                 if ($res->volumeId) {
                     $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID, $res->volumeId);
                     Logger::getLogger(LOG_CATEGORY::FARM)->info(new FarmLogMessage($event->DBServer->farmId, sprintf(_("MySQL %S volume created. Volume ID: %s..."), $isMaster ? "Master" : "Slave", $res->volumeId)));
                 }
             }
         }
     }
 }
Example #22
0
 public static function init()
 {
     // Get rid of magic_quotes
     if (function_exists('get_magic_quotes_gpc') && get_magic_quotes_gpc() || ini_get('magic_quotes_sybase')) {
         $_POST = Bootstrap::multidimensionalArrayMap('stripslashes', $_POST);
         $_REQUEST = Bootstrap::multidimensionalArrayMap('stripslashes', $_REQUEST);
         $_GET = Bootstrap::multidimensionalArrayMap('stripslashes', $_GET);
         $_COOKIE = Bootstrap::multidimensionalArrayMap('stripslashes', $_COOKIE);
     }
     if (ini_get('magic_quotes_runtime') && function_exists('set_magic_quotes_runtime')) {
         @set_magic_quotes_runtime(0);
     }
     // This is needed to encode json correctly, because of the floating point
     setlocale(LC_ALL, 'en_US.utf8');
     // Each MMap plugin should decide waht type of response needs.
     //ob_start('mb_output_handler');
     // The environment is safe now, start the system
     Bootstrap::load(EYE_ROOT . '/' . SYSTEM_DIR . '/' . KERNEL_DIR . '/Kernel.php');
     //get the priority
     $priorities = Bootstrap::loadPriorities();
     // Load all libraries
     Bootstrap::loadLibraries($priorities);
     // Initialize self::$Logger for next steps
     self::$Logger = Logger::getLogger('bootstrap.Bootstrap');
     // Load all services
     Bootstrap::loadServices($priorities);
     // Load all frameworks
     Bootstrap::loadFrameworks($priorities);
 }
Example #23
0
 /**
  * {@inheritdoc}
  * @see EventObserver::OnBeforeInstanceLaunch()
  */
 public function OnBeforeInstanceLaunch(\BeforeInstanceLaunchEvent $event)
 {
     if ($event->DBServer->platform != \SERVER_PLATFORMS::EC2) {
         return;
     }
     $DBFarm = $event->DBServer->GetFarmObject();
     $DBFarmRole = $event->DBServer->GetFarmRoleObject();
     // Create EBS volume for MySQLEBS
     if (!$event->DBServer->IsSupported("0.6")) {
         // Only for old AMIs
         if ($DBFarmRole->GetRoleObject()->hasBehavior(\ROLE_BEHAVIORS::MYSQL) && $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_DATA_STORAGE_ENGINE) == \MYSQL_STORAGE_ENGINE::EBS) {
             $server = $event->DBServer;
             $masterServer = $DBFarm->GetMySQLInstances(true);
             $isMaster = !$masterServer || $masterServer[0]->serverId == $server->serverId;
             $farmMasterVolId = $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID);
             $createEbs = $isMaster && !$farmMasterVolId;
             if ($createEbs) {
                 \Logger::getLogger(\LOG_CATEGORY::FARM)->info(new \FarmLogMessage($event->DBServer->farmId, sprintf(_("Need EBS volume for MySQL %s instance..."), $isMaster ? "Master" : "Slave")));
                 $req = new CreateVolumeRequestData($event->DBServer->GetProperty(\EC2_SERVER_PROPERTIES::AVAIL_ZONE), $DBFarmRole->GetSetting(DBFarmRole::SETTING_MYSQL_EBS_VOLUME_SIZE));
                 $aws = $event->DBServer->GetEnvironmentObject()->aws($DBFarmRole->CloudLocation);
                 $res = $aws->ec2->volume->create($req);
                 if (!empty($res->volumeId)) {
                     $DBFarmRole->SetSetting(DBFarmRole::SETTING_MYSQL_MASTER_EBS_VOLUME_ID, $res->volumeId, DBFarmRole::TYPE_LCL);
                     \Logger::getLogger(\LOG_CATEGORY::FARM)->info(new \FarmLogMessage($event->DBServer->farmId, sprintf(_("MySQL %S volume created. Volume ID: %s..."), $isMaster ? "Master" : "Slave", $res->volumeId)));
                 }
             }
         }
     }
 }
Example #24
0
function GenerateGraph($farmid, $role_name, $rrddbpath, $watchername, $graph_type)
{
    if (CONFIG::$RRD_GRAPH_STORAGE_TYPE == RRD_STORAGE_TYPE::AMAZON_S3) {
        $image_path = APPPATH . "/cache/stats/{$farmid}/{$role_name}.{$watchername}.{$graph_type}.gif";
    } else {
        $image_path = CONFIG::$RRD_GRAPH_STORAGE_PATH . "/{$farmid}/{$role_name}_{$watchername}.{$graph_type}.gif";
    }
    @mkdir(dirname($image_path), 0777, true);
    $graph_info = GetGraphicInfo($graph_type);
    if (file_exists($image_path)) {
        clearstatcache();
        $time = filemtime($image_path);
        if ($time > time() - $graph_info['update_every']) {
            return;
        }
    }
    // Plot daily graphic
    try {
        $Reflect = new ReflectionClass("{$watchername}Watcher");
        $PlotGraphicMethod = $Reflect->getMethod("PlotGraphic");
        $PlotGraphicMethod->invoke(NULL, $rrddbpath, $image_path, $graph_info);
    } catch (Exception $e) {
        Logger::getLogger('STATS')->fatal("Cannot plot graphic: {$e->getMessage()}");
        return;
    }
}
 public function analyseContent($file_contents, $key = '', &$errMsg, &$retCode)
 {
     $logger = Logger::getLogger('Ofpay');
     $logger->debug("开始解析欧飞返回的数据(" . $file_contents . ")");
     $file_contents = auto_charset($file_contents, 'gbk', 'utf-8');
     $file_contents = str_replace("gb2312", "utf-8", $file_contents);
     $file_contents = str_replace("GB2312", "utf-8", $file_contents);
     $file_contents = simplexml_load_string($file_contents);
     $logger->debug("开始把数据解析成xml格式:" . $key);
     foreach ($file_contents->children() as $item) {
         switch ($item->getName()) {
             case "err_msg":
                 $errMsg = (string) $item;
                 break;
             case "retcode":
                 $retCode = (int) $item;
                 break;
             case $key:
                 return $item;
             default:
                 $msgBody = $item;
         }
     }
     return $msgBody;
 }
Example #26
0
 /**
  * Get Logger instance. Creates if not already created.
  *
  * @return Logger
  */
 protected function getLogger()
 {
     if (is_null($this->logger)) {
         $this->logger = Logger::getLogger('core.ConfigDao');
     }
     return $this->logger;
 }
 protected function getWebServiceLogger()
 {
     if (is_null($this->logger)) {
         $this->logger = Logger::getLogger('core.webservices.log');
     }
     return $this->logger;
 }
 public function execute($request)
 {
     $id = trim($request->getParameter('subunitId'));
     try {
         $form = new DefaultListForm();
         $form->bind($request->getParameter($form->getName()));
         $object = new stdClass();
         if ($form->isValid()) {
             $subunit = $this->getCompanyStructureService()->getSubunitById($id);
             $result = $this->getCompanyStructureService()->deleteSubunit($subunit);
             if ($result) {
                 $object->messageType = 'success';
                 $object->message = __(TopLevelMessages::DELETE_SUCCESS);
             } else {
                 $object->messageType = 'error';
                 $object->message = __(TopLevelMessages::DELETE_FAILURE);
             }
         } else {
             $object->messageType = 'error';
             $object->message = __(TopLevelMessages::VALIDATION_FAILED);
         }
     } catch (Exception $e) {
         $logger = Logger::getLogger('admin.subunit');
         $logger->error('Error deleting subunut: ' . $e);
         $object->messageType = 'error';
         $object->message = __(TopLevelMessages::DELETE_FAILURE);
     }
     @ob_clean();
     return $this->renderText(json_encode($object));
 }
 /**
  * @return \Logger
  */
 public function getLogger()
 {
     if ($this->logger === null) {
         $this->logger = \Logger::getLogger('autocommitter');
     }
     return $this->logger;
 }
Example #30
-1
    /**
     * Connect to server.
     * @param string $server
     * @param int $port
     */
    public function connect($server, $port = 5222)
    {
        $this->logger = \Logger::getLogger(__CLASS__);
        $this->server = $server;
        $this->port = $port;
        $connect = <<<CONNECT
<?xml version="1.0"?>
<stream:stream to="{$server}" xmlns="jabber:client" xmlns:stream="http://etherx.jabber.org/streams" version="1.0">
CONNECT;
        $type = 'tcp';
        if (5223 == $port) {
            $type = 'ssl';
        }
        $this->socket = \stream_socket_client("{$type}://{$server}:{$port}", $errno, $errstr, $this->timeout);
        if (false === $this->socket) {
            throw new \Exception($errstr, $errno);
            // TODO
        }
        \stream_set_blocking($this->socket, 0);
        // None blocking TODO CHeck error
        $this->stanzaParser = new StanzaParser();
        $this->sendRaw($connect);
        $readBytes = $this->read('stream:features');
        $this->logger->debug($this->stanzaParser->stanzas[0]->name);
        // TODO Error failed connection
    }