/** * Called before the controller action. You can use this method to configure and customize components * or perform logic that needs to happen before each controller action. * * @param object $c current controller object * @return void */ function beforeFilter(&$c) { $user = $this->__getActiveUser(); UsermgmtInIt($this); $pageRedirect = $c->Session->read('permission_error_redirect'); $c->Session->delete('permission_error_redirect'); $controller = $c->params['controller']; $action = $c->params['action']; $actionUrl = $controller . '/' . $action; $requested = isset($controller->params['requested']) && $controller->params['requested'] == 1 ? true : false; $permissionFree = array('users/login', 'users/logout', 'users/register', 'users/userVerification', 'users/forgotPassword', 'users/activatePassword', 'pages/display', 'users/accessDenied', 'users/customer_register', 'users/customer_login'); if ((empty($pageRedirect) || $actionUrl != 'users/login') && !$requested && !in_array($actionUrl, $permissionFree)) { App::import("Model", "Usermgmt.UserGroup"); $userGroupModel = new UserGroup(); if (!$this->isLogged()) { if (!$userGroupModel->isGuestAccess($controller, $action)) { $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG); $c->Session->write('permission_error_redirect', '/users/login'); $c->Session->setFlash('You need to be signed in to view this page.'); $c->Session->write('Usermgmt.OriginAfterLogin', '/' . $c->params->url); $c->redirect('/login'); } } else { if (!$userGroupModel->isUserGroupAccess($controller, $action, $this->getGroupId())) { $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG); $c->Session->write('permission_error_redirect', '/users/login'); $c->redirect('/accessDenied'); } } } }
/** * validate * * @param mixed $identifier * @return boolean */ public function validate($identifier = null) { // No identifier if (!$identifier) { throw new \InvalidArgumentException('identifier is a required argument'); } // Current attempts $attempts = $this->storage->increment($identifier); // No attempts if (!$attempts) { $this->storage->save($identifier, 1, $this->options['timespan']); // Logged } elseif ($attempts == $this->options['logged']) { // Set expiration to zero (perm ban) $this->storage->update($identifier, $attempts, 0); // Log $this->logger->log('warning', $identifier . ' exceeded the number of allowed requests'); return false; // Banned } elseif ($attempts >= $this->options['banned']) { return false; } // Valid return true; }
public function init() { // echo 'the dispatcher start..',PHP_EOL; $this->_orgcode = isset($_GET['__orgcode']) ? trim($_GET['__orgcode']) : ''; $this->_logger = Yii::createObject(['class' => 'yunke\\mqs\\log\\File', 'logFile' => '@runtime/logs/dispatcher_' . date('Ymd') . '.log']); if (is_array($this->whitelist) && in_array($this->_orgcode, $this->whitelist)) { $cfg = $this->targets['ali']; $this->_logger->log("Target:ali", $this->_orgcode); } else { $this->_logger->log("Target:httpsqs", $this->_orgcode); $cfg = $this->targets['httpsqs']; } $this->_target = Yii::createObject($cfg); }
/** * Execute a raw SQL query on the database. * * @param string $sql Raw SQL string to execute. * @param array &$values Optional array of bind values * @return mixed A result set object */ public function query($sql, &$values = array()) { $start_time = microtime(true); if ($this->logging) { $this->logger->log($sql, $values); } $this->last_query = $sql; try { if (!($sth = $this->connection->prepare($sql))) { $this->record_database_time(microtime(true) - $start_time); throw new DatabaseException($this); } } catch (PDOException $e) { $this->record_database_time(microtime(true) - $start_time); throw new DatabaseException($this); } $sth->setFetchMode(PDO::FETCH_ASSOC); try { if (!$sth->execute($values)) { $this->record_database_time(microtime(true) - $start_time); throw new DatabaseException($this); } } catch (PDOException $e) { $this->record_database_time(microtime(true) - $start_time); throw new DatabaseException($sth); } $this->record_database_time(microtime(true) - $start_time); return $sth; }
/** * Execute a raw SQL query on the database. * * @param string $sql Raw SQL string to execute. * @param array &$values Optional array of bind values * @return mixed A result set object */ public function query($sql, &$values = array()) { // BOF SQL业务性能分析功能 $sqlAnalysis = new \Lib\SqlAnalysis('orm'); if ($this->logging) { $this->logger->log($sql); if ($values) { $this->logger->log($values); } } $this->last_query = $sql; $sql = $this->buildSql($sql); try { if (!($sth = $this->connection->prepare($sql))) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($this); } $sth->setFetchMode(PDO::FETCH_ASSOC); try { if (!$sth->execute($values)) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($e); } // EOF SQL业务性能分析功能 $sqlAnalysis->run($sql, $values, $sth->rowCount()); return $sth; }
/** * Replacing MODX's getCount(), because it has bug on counting SQL with function.<br> * Retrieves a count of xPDOObjects by the specified xPDOCriteria. * * @param string $className Class of xPDOObject to count instances of. * @param mixed $criteria Any valid xPDOCriteria object or expression. * @return integer The number of instances found by the criteria. * @see xPDO::getCount() * @link http://forums.modx.com/thread/88619/getcount-fails-if-the-query-has-aggregate-leaving-having-039-s-field-undefined The discussion for this */ public function getQueryCount($className, $criteria = null) { $count = 0; if ($query = $this->modx->newQuery($className, $criteria)) { $expr = '*'; if ($pk = $this->modx->getPK($className)) { if (!is_array($pk)) { $pk = array($pk); } $expr = $this->modx->getSelectColumns($className, 'alias', '', $pk); } $query->prepare(); $sql = $query->toSQL(); $stmt = $this->modx->query("SELECT COUNT({$expr}) FROM ({$sql}) alias"); if ($stmt) { $tstart = microtime(true); if ($stmt->execute()) { $this->modx->queryTime += microtime(true) - $tstart; $this->modx->executedQueries++; if ($results = $stmt->fetchAll(PDO::FETCH_COLUMN)) { $count = reset($results); $count = intval($count); } } else { $this->modx->queryTime += microtime(true) - $tstart; $this->modx->executedQueries++; $this->modx->log(modX::LOG_LEVEL_ERROR, "[" . __CLASS__ . "] Error " . $stmt->errorCode() . " executing statement: \n" . print_r($stmt->errorInfo(), true), '', __METHOD__, __FILE__, __LINE__); } } } return $count; }
/** * Execute a raw SQL query on the database. * * @param string $sql Raw SQL string to execute. * @param array &$values Optional array of bind values * @return mixed A result set object */ public function query($sql, &$values = array()) { if ($this->logging) { $this->logger->log($sql); if ($values) { $this->logger->log($values); } } $this->last_query = $sql; try { if (!($sth = $this->connection->prepare($sql))) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($this); } $sth->setFetchMode(PDO::FETCH_ASSOC); try { if (!$sth->execute($values)) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($e); } return $sth; }
/** * @description get svn info * @param object $logger * @return void * @author Se# * @version 0.0.1 */ public function svn($logger) { exec('svn info', $svn); if (isset($svn[4])) { $logger->log($svn[4], Zend_Log::INFO); } }
/** * @since 1.4 * * @param string $msg * @return bool|int */ public static function log($msg = '') { if (self::$debugger) { return self::$debugger->log($msg); } return -1; }
/** * Repository log * * @museDescription Shows the past and pending changelog for the repository * * @return void **/ public function log() { $mode = $this->output->getMode(); $length = $this->arguments->getOpt('length') ? (int) $this->arguments->getOpt('length') : 20; $start = $this->arguments->getOpt('start') ? (int) $this->arguments->getOpt('start') : null; $upcoming = $this->arguments->getOpt('include-upcoming'); $installed = $this->arguments->getOpt('exclude-installed') ? false : true; $search = $this->arguments->getOpt('search') ? $this->arguments->getOpt('search') : null; $format = '%an: %s'; $count = $this->arguments->getOpt('count'); if ($mode == 'minimal') { $format = '%H||%an||%ae||%ad||%s'; } $logs = $this->mechanism->log($length, $start, $upcoming, $installed, $search, $format, $count); if ($count) { $this->output->addLine($logs); return; } if ($mode != 'minimal') { $output = array(); foreach ($logs as $log) { $output[] = array('message' => $log); } $this->output->addLinesFromArray($output); } else { if (is_array($logs) && count($logs) > 0) { foreach ($logs as $log) { $entry = array(); $parts = explode('||', $log); $entry[$parts[0]] = array('name' => $parts[1], 'email' => $parts[2], 'date' => $parts[3], 'subject' => $parts[4]); $this->output->addLine($entry); } } } }
/** * Execute a raw SQL query on the database. * * @param string $sql Raw SQL string to execute. * @param array &$values Optional array of bind values * @return mixed A result set object */ public function query($sql, &$values = array()) { if ($this->logging) { $start = microtime(true); } $this->last_query = $sql; try { if (!($sth = $this->connection->prepare($sql))) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($this); } $sth->setFetchMode(PDO::FETCH_ASSOC); try { if (!$sth->execute($values)) { throw new DatabaseException($this); } } catch (PDOException $e) { throw new DatabaseException($e); } if ($this->logging) { $time = microtime(true) - $start; $query = $this->expand_prepared_sql($sql, $values); $this->logger->log(sprintf("%.3fs -- %s", $time, $query)); } return $sth; }
function setHostStd($id = 0) { $Return = false; if (check_dbid($id)) { $Query = "UPDATE " . TM_TABLE_HOST . "\n\t\t\t\t\t\tSET standard=0\n\t\t\t\t\t\tWHERE standard=1\n\t\t\t\t\t\tAND siteid='" . TM_SITEID . "'"; //log $HOSTSTD = $this->getStdSMTPHost(); if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("standard" => 0, "id" => $HOSTSTD[0]['id']), "object" => "host", "action" => "edit")); } $Return = true; } else { $Return = false; return $Return; } $Query = "UPDATE " . TM_TABLE_HOST . "\n\t\t\t\t\t\tSET standard=1\n\t\t\t\t\t\tWHERE id=" . checkset_int($id) . "\n\t\t\t\t\t\tAND siteid='" . TM_SITEID . "'"; if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("standard" => 1, "id" => $id), "object" => "host", "action" => "edit")); } $Return = true; } else { $Return = false; return $Return; } } return $Return; }
function log($err, $priority = '') { // log to normal logger if ($this->init) { return $this->logger->log($err, $priority); } else { return $this->bufferMsg($err, $priority); } }
/** * Logs a message. * * @param string $level The log level of the message. * @param string $text The message to log. */ private function log($level = 'info', $text = '') { if (isset($this->logger)) { $this->logger->log($level, $text); return; } if ($this->logLevel <= $this->logLevels[$level]) { echo strtoupper($level), ': ', $text, "\n"; } }
/** * Check coverage * * @param string $targetFile Target file * @return void */ protected function _checkCoverage($targetFile = null) { $file = $this->_qis->getProjectQisRoot() . DIRECTORY_SEPARATOR . 'test-results' . DIRECTORY_SEPARATOR . 'coverage.xml'; if (!file_exists($file)) { throw new CoverageException("Cannot find file '{$file}'. " . "Ensure test module is executed first."); } $this->_qis->log('Parsing clover coverage report...'); $report = new CloverCoverageReport($file, $targetFile, $this->_root, $this->_ignorePaths); $totalCoverage = $report->getTotalCoverage(); $this->_saveTotalCoverage($totalCoverage); }
function updateCFG($cfg) { $Return = false; $Query = "UPDATE " . TM_TABLE_CONFIG . "\n\t\t\t\t\tSET\n\t\t\t\t\tname='" . dbesc($cfg["name"]) . "',\n\t\t\t\t\tlang='" . dbesc($cfg["lang"]) . "',\n\t\t\t\t\tstyle='" . dbesc($cfg["style"]) . "',\n\t\t\t\t\tnotify_mail='" . dbesc($cfg["notify_mail"]) . "',\n\t\t\t\t\tnotify_subscribe=" . checkset_int($cfg["notify_subscribe"]) . ",\n\t\t\t\t\tnotify_unsubscribe=" . checkset_int($cfg["notify_unsubscribe"]) . ",\n\t\t\t\t\temailcheck_intern=" . checkset_int($cfg["emailcheck_intern"]) . ",\n\t\t\t\t\temailcheck_subscribe=" . checkset_int($cfg["emailcheck_subscribe"]) . ",\n\t\t\t\t\temailcheck_sendit=" . checkset_int($cfg["emailcheck_sendit"]) . ",\n\t\t\t\t\temailcheck_checkit=" . checkset_int($cfg["emailcheck_checkit"]) . ",\n\t\t\t\t\tcheck_version=" . checkset_int($cfg["check_version"]) . ",\n\t\t\t\t\tmax_mails_retry=" . checkset_int($cfg["max_mails_retry"]) . ",\n\t\t\t\t\ttrack_image='" . dbesc($cfg["track_image"]) . "',\n\t\t\t\t\trcpt_name='" . dbesc($cfg["rcpt_name"]) . "',\n\t\t\t\t\tunsubscribe_use_captcha=" . checkset_int($cfg["unsubscribe_use_captcha"]) . ",\n\t\t\t\t\tunsubscribe_digits_captcha=" . checkset_int($cfg["unsubscribe_digits_captcha"]) . ",\n\t\t\t\t\tunsubscribe_sendmail=" . checkset_int($cfg["unsubscribe_sendmail"]) . ",\n\t\t\t\t\tunsubscribe_action='" . dbesc($cfg["unsubscribe_action"]) . "',\n\t\t\t\t\tunsubscribe_host='" . dbesc($cfg["unsubscribe_host"]) . "',\n\t\t\t\t\tcheckit_limit=" . checkset_int($cfg["checkit_limit"]) . ",\n\t\t\t\t\tcheckit_from_email='" . dbesc($cfg["checkit_from_email"]) . "',\n\t\t\t\t\tcheckit_adr_reset_error=" . checkset_int($cfg["checkit_adr_reset_error"]) . ",\n\t\t\t\t\tcheckit_adr_reset_status=" . checkset_int($cfg["checkit_adr_reset_status"]) . ",\n\t\t\t\t\tbounceit_limit=" . checkset_int($cfg["bounceit_limit"]) . ",\n\t\t\t\t\tbounceit_host=" . checkset_int($cfg["bounceit_host"]) . ",\n\t\t\t\t\tbounceit_action='" . dbesc($cfg["bounceit_action"]) . "',\n\t\t\t\t\tbounceit_search='" . dbesc($cfg["bounceit_search"]) . "',\n\t\t\t\t\tbounceit_filter_to=" . checkset_int($cfg["bounceit_filter_to"]) . ",\n\t\t\t\t\tbounceit_filter_to_email='" . dbesc($cfg["bounceit_filter_to_email"]) . "',\n\t\t\t\t\tproof=" . checkset_int($cfg["proof"]) . ",\n\t\t\t\t\tproof_url='" . dbesc($cfg["proof_url"]) . "',\n\t\t\t\t\tproof_trigger=" . checkset_int($cfg["proof_trigger"]) . ",\n\t\t\t\t\tproof_pc=" . checkset_int($cfg["proof_pc"]) . "\n\t\t\t\t\tWHERE siteid='" . dbesc($cfg["siteid"]) . "'\n\t\t\t\t\t"; if ($this->DB->Query($Query)) { if (TM_LOG) { $this->LOG->log(array("data" => $cfg, "object" => "cfg", "action" => "edit")); } $Return = true; } return $Return; }
function add($deployment_fields) { if (!is_array($deployment_fields)) { $this->_event->log("add", $_SERVER['REQUEST_TIME'], 2, "deployment.class.php", "Deployment_field not well defined", "", "", 0, 0, 0); return 1; } $db = openqrm_get_db_connection(); $result = $db->AutoExecute($this->_db_table, $deployment_fields, 'INSERT'); if (!$result) { $this->_event->log("add", $_SERVER['REQUEST_TIME'], 2, "deployment.class.php", "Failed adding new deployment to database", "", "", 0, 0, 0); } }
public function profile_and_execute($sth, $sql, &$values = array()) { $start_time = microtime(true); $valid = $sth->execute($values); $end_time = microtime(true); //$exec_time = str_pad(number_format(($end_time - $start_time)*1000, 1), 8, ' ', STR_PAD_LEFT); $exec_time = number_format(($end_time - $start_time) * 1000, 1); $log_str = "(Time: {$exec_time}ms) {$sql}"; $log_str .= !empty($values) ? " [['" . join("', '", $values) . "']]" : ''; $this->logger->log($log_str); return $valid; }
/** * Standard initialisation function */ public function init() { try { set_time_limit(0); $this->objRPCServer = $this->getObject('rpcserver', 'packages'); $this->objRPCClient = $this->getObject('rpcclient', 'packages'); $this->objUser = $this->getObject('user', 'security'); $this->objConfig = $this->getObject('altconfig', 'config'); $this->objLanguage = $this->getObject('language', 'language'); $this->objLanguageCode = $this->getObject('languagecode', 'language'); $this->objModuleAdmin = $this->getObject('modulesadmin', 'modulecatalogue'); $this->objModule = $this->getObject('modules'); //the class for reading register.conf files $this->objModFile = $this->getObject('modulefile'); $this->objPatch = $this->getObject('patch', 'modulecatalogue'); $this->objCatalogueConfig = $this->getObject('catalogueconfig', 'modulecatalogue'); if (!file_exists($this->objConfig->getSiteRootPath() . 'config/catalogue.xml')) { $this->objCatalogueConfig->writeCatalogue(); } $this->objSideMenu = $this->getObject('catalogue', 'modulecatalogue'); // Check which zip thing we will be using if (extension_loaded('zip') && function_exists('zip_open')) { $this->extzip = TRUE; } $this->objSideMenu->addNodes(array('local updates', 'remote updates', 'all', 'skins', 'languages')); $sysTypes = $this->objCatalogueConfig->getCategories(); //$xmlCat = $this->objCatalogueConfig->getNavParam('category'); //get list of categories //$catArray = $xmlCat['catalogue']['category']; //natcasesort($catArray); //$this->objSideMenu->addNodes($catArray); $this->objSideMenu->addNodes($sysTypes); $this->objTagCloud = $this->getObject('tagcloud', 'utilities'); $this->tagCloud = $this->objCatalogueConfig->getModuleTags(); $tagscl = $this->processTags(); //var_dump($tagscl); die(); if ($tagscl != NULL) { $this->objTagCloud = $this->objTagCloud->buildCloud($tagscl); } else { $this->objTagCloud = NULL; } //$this->tagCloud = $this->objTagCloud->exampletags(); $this->objPOFile = $this->getObject('pofile', 'modulecatalogue'); $this->objLog = $this->getObject('logactivity', 'logger'); $this->objLog->log(); // Load scriptaclous since we can no longer guarantee it is there $scriptaculous = $this->getObject('scriptaculous', 'prototype'); $this->appendArrayVar('headerParams', $scriptaculous->show('text/javascript')); } catch (customException $e) { $this->errorCallback('Caught exception: ' . $e->getMessage()); exit; } }
/** * Log the given String into log.txt * Notice: logging must be enabled -> use enableLog(); * @param string $msg - Message to log * @return bool - true=logged ELSE false=logging failed * @public */ public function log($message) { if (is_a($this->SofortLib_Multipay, 'SofortLib')) { $this->SofortLib_Multipay->log($message); return true; } elseif (is_a($this->SofortLib_TransactionData, 'SofortLib')) { $this->SofortLib_TransactionData->log($message); return true; } elseif (is_a($this->ConfirmSr, 'SofortLib')) { $this->ConfirmSr->log($message); return true; } return false; }
function restart_failed($q_id = 0) { $Return = false; if (check_dbid($q_id)) { $Query = "UPDATE " . TM_TABLE_NL_H . " " . "SET status=1 " . "WHERE " . "q_id=" . checkset_int($q_id) . " " . "AND (status=4 OR status=6) " . "AND siteid='" . TM_SITEID . "'"; if ($this->DB->Query($Query)) { //log if (TM_LOG) { $this->LOG->log(array("data" => array("restart_failed" => 1, "id" => $q_id), "object" => "q", "action" => "edit")); } $Return = true; } } return $Return; //anzahl affected rows etc zurueckgeben, siehe addHQ }
function display_overview($offset, $limit, $sort, $order) { $db = openqrm_get_db_connection(); $recordSet = $db->SelectLimit("select * from {$this->_db_table} order by {$sort} {$order}", $limit, $offset); $nagios3_service_array = array(); if (!$recordSet) { $this->_event->log("display_overview", $_SERVER['REQUEST_TIME'], 2, "nagios3.class.php", $db->ErrorMsg(), "", "", 0, 0, 0); } else { while (!$recordSet->EOF) { array_push($nagios3_service_array, $recordSet->fields); $recordSet->MoveNext(); } $recordSet->Close(); } return $nagios3_service_array; }
function delBL($id) { $Return = false; if (check_dbid($id)) { if (TM_LOG) { $this->LOG->log(array("data" => array("id" => $id), "object" => "bl", "action" => "delete")); } $Query = "DELETE FROM " . TM_TABLE_BLACKLIST . " WHERE siteid='" . TM_SITEID . "' AND id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } else { $Return = false; return $Return; } } return $Return; }
/** * Optimises a sub-value * @access public * @version 1.0 */ public function subvalue() { $replace_colors =& $this->parser->data['csstidy']['replace_colors']; $this->sub_value = trim($this->sub_value); if ($this->sub_value == '') { // caution : '0' return; } $important = ''; if ($this->parser->is_important($this->sub_value)) { $important = ' !important'; } $this->sub_value = $this->parser->gvw_important($this->sub_value); // Compress font-weight if ($this->property === 'font-weight' && $this->parser->get_cfg('compress_font-weight')) { if ($this->sub_value === 'bold') { $this->sub_value = '700'; $this->parser->log('Optimised font-weight: Changed "bold" to "700"', 'Information'); } elseif ($this->sub_value === 'normal') { $this->sub_value = '400'; $this->parser->log('Optimised font-weight: Changed "normal" to "400"', 'Information'); } } $temp = $this->compress_numbers($this->sub_value); if (strcasecmp($temp, $this->sub_value) !== 0) { if (strlen($temp) > strlen($this->sub_value)) { $this->parser->log('Fixed invalid number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning'); } else { $this->parser->log('Optimised number: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information'); } $this->sub_value = $temp; } if ($this->parser->get_cfg('compress_colors')) { $temp = $this->cut_color($this->sub_value); if ($temp !== $this->sub_value) { if (isset($replace_colors[$this->sub_value])) { $this->parser->log('Fixed invalid color name: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Warning'); } else { $this->parser->log('Optimised color: Changed "' . $this->sub_value . '" to "' . $temp . '"', 'Information'); } $this->sub_value = $temp; } } $this->sub_value .= $important; }
/** * Log the given String into log.txt * Notice: logging must be enabled -> use enableLog(); * @param string $msg - Message to log * @return bool - true=logged ELSE false=logging failed * @public */ function log($msg) { if (is_a($this->multipay, 'SofortLib')) { $this->multipay->log($msg); return true; } else { if (is_a($this->transactionData, 'SofortLib')) { $this->transactionData->log($msg); return true; } else { if (is_a($this->confirmSr, 'SofortLib')) { $this->confirmSr->log($msg); return true; } } } return false; //logging failed }
/** * Called before the controller action. You can use this method to configure and customize components * or perform logic that needs to happen before each controller action. * * @param object $c current controller object * @return void */ function beforeFilter(&$c) { UsermgmtInIt($this); $user = $this->__getActiveUser(); $pageRedirect = $c->Session->read('permission_error_redirect'); $c->Session->delete('permission_error_redirect'); $controller = $c->params['controller']; $action = $c->params['action']; $actionUrl = $controller . '/' . $action; $requested = isset($c->params['requested']) && $c->params['requested'] == 1 ? true : false; $permissionFree = array('users/login', 'users/logout', 'users/register', 'users/userVerification', 'users/forgotPassword', 'users/activatePassword', 'pages/display', 'users/accessDenied', 'users/emailVerification'); $access = str_replace(' ', '', ucwords(str_replace('_', ' ', $controller))) . '/' . $action; $allControllers = $this->ControllerList->getControllerWithMethods(); $errorPage = false; if (!in_array($access, $allControllers)) { $errorPage = true; } if ((empty($pageRedirect) || $actionUrl != 'users/login') && !$requested && !in_array($actionUrl, $permissionFree) && !$errorPage) { App::import("Model", "Usermgmt.UserGroup"); $userGroupModel = new UserGroup(); if (!$this->isLogged()) { if (!$userGroupModel->isGuestAccess($controller, $action)) { $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG); $c->Session->write('permission_error_redirect', '/users/login'); $c->Session->setFlash('You need to be signed in to view this page.'); $cUrl = '/' . $c->params->url; if (!empty($_SERVER['QUERY_STRING'])) { $rUrl = $_SERVER['REQUEST_URI']; $pos = strpos($rUrl, $cUrl); $cUrl = substr($rUrl, $pos, strlen($rUrl)); } $c->Session->write('Usermgmt.OriginAfterLogin', $cUrl); $c->redirect('/login'); } } else { if (!$userGroupModel->isUserGroupAccess($controller, $action, $this->getGroupId())) { $c->log('permission: actionUrl-' . $actionUrl, LOG_DEBUG); $c->Session->write('permission_error_redirect', '/users/login'); $c->redirect('/accessDenied'); } } } }
function delGrp($id) { $Return = false; if (check_dbid($id)) { //log before deletion! log will fetch old data if (TM_LOG) { $this->LOG->log(array("data" => array("id" => $id), "object" => "nl_grp", "action" => "delete")); } //standard gruppe suchen $Query = "SELECT id\n\t\t\t\t\tFROM " . TM_TABLE_NL_GRP . "\n\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\tAND standard=1"; if ($this->DB->Query($Query)) { $Return = true; } //wenn standardgruppe gefunden, weitermachen, ansonsten nichts tun!!! //loeschen geht nur wenn eine std gruppe definiert // wurde welche die NL aus zu loeschender Gruppe zugeordnet werden koennen if ($this->DB->next_record()) { $stdGrpID = $this->DB->Record['id']; //newsletter der stdgruppe neu zuordnen $Query = "UPDATE " . TM_TABLE_NL . " SET\n\t\t\t\t\t\t\tgrp_id=" . checkset_int($stdGrpID) . "\n\t\t\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\t\t\tAND grp_id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } else { $Return = false; return $Return; } //gruppe loeschen $Query = "DELETE FROM " . TM_TABLE_NL_GRP . "\n\t\t\t\t\t\t\tWHERE siteid='" . TM_SITEID . "'\n\t\t\t\t\t\t\tAND id=" . checkset_int($id); if ($this->DB->Query($Query)) { $Return = true; } else { $Return = false; return $Return; } } else { $Return = false; } } return $Return; }
public function getData($url, $params = array(), $generateHash = true) { if ($generateHash) { $params['serie'] = $this->getSerial(); $params['id'] = $this->getAppId(); $params['tm'] = date('YmdHis') . substr(microtime(), 2, 3); $params['tmc'] = hash_hmac('sha1', $params['tm'], hash('md5', $this->getAppKey(), false)); } if (!empty($params)) { $url .= '?' . http_build_query($params); } $data = file_get_contents($url); if ($this->logger) { $this->logger->log($url, $data); } $xml = simplexml_load_string($data); if ($xml === false) { return false; } // Petite astuce pour transformer simplement le XML en tableau return json_decode(json_encode($xml), true); }
function update($item, $grp) { $Return = false; if (isset($item['id']) && check_dbid($item['id'])) { $adr['grp'] = $grp; $Query = "UPDATE " . $this->TM_TABLE_ITEM . " SET\n\t\t\t\t\t\t\tshort='" . dbesc($item["short"]) . "',\n\t\t\t\t\t\t\tname='" . dbesc($item["name"]) . "',\n\t\t\t\t\t\t\turl='" . dbesc($item["url"]) . "',\n\t\t\t\t\t\t\tdescr='" . dbesc($item["descr"]) . "',\n\t\t\t\t\t\t\taktiv=" . checkset_int($item["aktiv"]) . ",\n\t\t\t\t\t\t\teditor='" . dbesc($item["author"]) . "',\n\t\t\t\t\t\t\tupdated='" . dbesc($item["created"]) . "'\n\t\t\t\t\t\t WHERE siteid='" . TM_SITEID . "' AND id=" . checkset_int($item["id"]); if ($this->DB->Query($Query)) { $item['grp'] = $grp; if (TM_LOG) { $this->LOG->log(array("data" => $item, "object" => "lnk", "action" => "edit")); } $Return = true; } else { $Return = false; return $Return; } //update group references //use setGroup instead!: $this->setGroup($item['id'], $grp); } //if adr_id return $Return; }
/** * Outputs a profiling message using the output handler * * @return string Returns the message */ public function output() { $messageParts = array(); foreach ($this->profilingData as $currentRunData) { $currentMessagePart = sprintf('Profiling run %s: Duration: %0.9f | Memory: %s (%s max)', $currentRunData['name'], $currentRunData['duration'], $this->formatMemory($currentRunData['memory']), $this->formatMemory($currentRunData['memoryPeak'])); if (isset($currentRunData['caller'])) { $caller = $currentRunData['caller']; $currentMessagePart .= sprintf(' @ %s:%s', $caller['file'], $caller['line']); } $messageParts[] = $currentMessagePart; } $message = implode(PHP_EOL, $messageParts); switch ($this->outputHandler) { case STDOUT: case STDERR: fwrite($this->outputHandler, $message); break; case is_object($this->outputHandler) && method_exists($this->outputHandler, 'log'): $this->outputHandler->log(LogLevel::DEBUG, $message); break; } return $message; }