/** * * Behaviour extracted from official email hook prep_for_email() function * * @param GitRepository $repository * @param PFUser $user * @param type $oldrev * @param type $newrev * @param type $refname * @return Git_Hook_PushDetails */ public function getPushDetails(GitRepository $repository, PFUser $user, $oldrev, $newrev, $refname) { $change_type = Git_Hook_PushDetails::ACTION_ERROR; $revision_list = array(); $rev_type = ''; try { if ($oldrev == self::FAKE_EMPTY_COMMIT) { $revision_list = $this->exec_repo->revListSinceStart($refname, $newrev); $change_type = Git_Hook_PushDetails::ACTION_CREATE; } elseif ($newrev == self::FAKE_EMPTY_COMMIT) { $change_type = Git_Hook_PushDetails::ACTION_DELETE; } else { $revision_list = $this->exec_repo->revList($oldrev, $newrev); $change_type = Git_Hook_PushDetails::ACTION_UPDATE; } if ($change_type == Git_Hook_PushDetails::ACTION_DELETE) { $rev_type = $this->exec_repo->getObjectType($oldrev); } else { $rev_type = $this->exec_repo->getObjectType($newrev); } } catch (Git_Command_Exception $exception) { $this->logger->error(__CLASS__ . " {$repository->getFullName()} {$refname} {$oldrev} {$newrev} " . $exception->getMessage()); } return new Git_Hook_PushDetails($repository, $user, $refname, $change_type, $rev_type, $revision_list); }
/** * Request the page from IMDb * @param $url * @return string Page html. Empty string on failure * @throws Exception\Http */ protected function requestPage($url) { $this->logger->info("[Page] Requesting [{$url}]"); $req = $this->buildRequest($url); if (!$req->sendRequest()) { $this->logger->error("[Page] Failed to connect to server when requesting url [{$url}]"); if ($this->config->throwHttpExceptions) { throw new Exception\Http("Failed to connect to server when requesting url [{$url}]"); } else { return ''; } } if (200 == $req->getStatus()) { return $req->getResponseBody(); } elseif ($redirectUrl = $req->getRedirect()) { $this->logger->debug("[Page] Following redirect from [{$url}] to [{$redirectUrl}]"); return $this->requestPage($redirectUrl); } else { $this->logger->error("[Page] Failed to retrieve url [{url}]. Response headers:{headers}", array('url' => $url, 'headers' => $req->getLastResponseHeaders())); if ($this->config->throwHttpExceptions) { throw new Exception\Http("Failed to retrieve url [{$url}]. Status code [{$req->getStatus()}]"); } else { return ''; } } }
private function importDumpFile(Project $project, $xml_svn, $extraction_path) { $attrs = $xml_svn->attributes(); if (!isset($attrs['dump-file'])) { return true; } $rootpath_arg = escapeshellarg($project->getSVNRootPath()); $dumpfile_arg = escapeshellarg("{$extraction_path}/{$attrs["dump-file"]}"); $commandline = "svnadmin load {$rootpath_arg} <{$dumpfile_arg} 2>&1"; $this->logger->info($commandline); try { $cmd = new System_Command(); $command_output = $cmd->exec($commandline); foreach ($command_output as $line) { $this->logger->debug("svnadmin: {$line}"); } $this->logger->debug("svnadmin returned with status 0"); } catch (System_Command_CommandException $e) { foreach ($e->output as $line) { $this->logger->error("svnadmin: {$line}"); } $this->logger->error("svnadmin returned with status {$e->return_value}"); throw new SVNXMLImporterException("failed to svnadmin load {$dumpfile_arg} in {$rootpath_arg}:" . " exited with status {$e->return_value}"); } }
private function logError(GitRepository $repository, $sysevent_prefix, $log_prefix, Exception $e) { $this->dao->setGerritMigrationError($repository->getId()); $this->error($sysevent_prefix . $e->getMessage()); $this->logger->error($log_prefix . $this->verbalizeParameters(null), $e); $this->sendErrorNotification($repository); }
/** * @param string|\Exception $msg * @param array $context * @throws \RuntimeException */ public static function error($msg, array $context = array()) { if (empty(static::$instance)) { throw new \RuntimeException('Logger instance not added to proxy yet'); } static::$instance->error($msg, $context); }
/** * @param $json * @return PlayerState * @throws \MetaPlayer\JsonException */ private function parseJson($json) { $playerState = $this->jsonUtils->deserialize($json); if (!$playerState instanceof PlayerState) { $this->logger->error("json should be instance of PlayerState but got " . print_r($playerState, true)); throw new JsonException("Wrong json format."); } return $playerState; }
private function getStore() { $store_path = $this->getStorePath(); if (!file_exists($store_path) && !mkdir($store_path)) { $this->logger->error("OPENID DRIVER - Unable to create Filestore self::OPENID_STORE_PATH unsufficient permissions"); throw new OpenId_OpenIdException($GLOBALS['Language']->getText('plugin_openid', 'error_openid_store', ForgeConfig::get('sys_name'))); } return new Auth_OpenID_FileStore($store_path); }
public function execute($queue) { $executed_events_ids = $this->loopOverEventsForOwner($this->getOwner(), $queue); try { $this->postEventsActions($executed_events_ids, $queue); } catch (Exception $exception) { $this->logger->error("[SystemEventProcessor] An error happened during execution of post actions: " . $exception->getMessage()); } }
public static function push($msg, $code = self::GENERIC_ERROR, $severity = self::SEVERITY_ERROR) { self::init(); self::$errors->enqueue(new Error($msg, $code, $severity)); if ($severity == self::SEVERITY_ERROR) { self::$logger->error($msg); } else { self::$logger->warn($msg); } }
/** * @return array */ public function read() { $settings = []; try { $settings = Yaml::parse($this->filePath); } catch (ParseException $e) { $this->logger->error(sprintf('Unable to read the core settings file "%s".', $this->filePath)); } return $settings; }
public function importFromArchive($project_id, ZipArchive $archive) { $this->logger->info('Start importing from archive ' . $archive->filename); $xml_content = $archive->getFromName(self::PROJECT_XML_FILENAME); if (!$xml_content) { $this->logger->error('No content available in archive for file ' . self::PROJECT_XML_FILENAME); return; } return $this->importContent($project_id, $xml_content); }
public function execute(Git_Hook_PushDetails $push_details) { $this->log_pushes->executeForRepository($push_details); foreach ($push_details->getRevisionList() as $commit) { try { $this->extract_cross_ref->execute($push_details, $commit); } catch (Git_Command_Exception $exception) { $this->logger->error(__CLASS__ . ": cannot extract references for {$push_details->getRepository()->getFullPath()} {$push_details->getRefname()} {$commit}: {$exception}"); } } }
private function launchForRepository(GitRepository $repository) { $res = $this->dao->retrieveTriggersPathByRepository($repository->getId()); if ($res && !$res->isError() && $res->rowCount() > 0) { foreach ($res as $row) { try { $this->jenkins_client->setToken($row['token'])->launchJobBuild($row['job_url']); } catch (Exception $exception) { $this->logger->error(__CLASS__ . '[' . $repository->getId() . '] ' . $exception->getMessage()); } } } }
public function importFromArchive($project_id, ZipArchive $archive) { $this->logger->info('Start importing from archive ' . $archive->filename); $project_archive = $this->getProjectZipArchive($archive, $project_id); $xml_content = $project_archive->getXML(); if (!$xml_content) { $this->logger->error('No content available in archive for file ' . ProjectXMLImporter_XMLImportZipArchive::PROJECT_XML_FILENAME); return; } $project_archive->extractFiles(); $this->importContent($project_id, $xml_content, $project_archive->getExtractionPath()); return $project_archive->cleanUp(); }
function LogAdmActivity($usrName, $activity, $oldVal = '', $newVal = '', $note = '') { $sqlStatement = "INSERT INTO adm_activity (user_login, aktivita, stara_hodnota, nova_hodnota, poznamka) VALUES ('{$usrName}', '{$activity}', '{$oldVal}', '{$newVal}', '{$note}')"; if (!sql($sqlStatement)) { Logger::error("Nepodarilo sa zapisat do admin-logu v DB. SQL:\n{$sqlStatement}"); } }
public function get_login() { $buf = $this->prefs->get('AuthMethod', 'Token'); $token_url = $buf['url']; $user_node_name = $buf['user_node_name']; $login_attribute_name = $buf['login_attribute_name']; if (!isset($token_url) or $token_url == '') { Logger::error('main', 'Token URL is not defined'); return NULL; } if (!isset($_REQUEST['token'])) { Logger::warning('main', 'Missing parameter : token'); return NULL; } $token_url = str_replace('%TOKEN%', $_REQUEST['token'], $token_url); $xml = query_url($token_url); $dom = new DomDocument('1.0', 'utf-8'); $ret = @$dom->loadXML($xml); if (!$ret) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } $user_node = $dom->getElementsByTagname($user_node_name)->item(0); if (!is_object($user_node)) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } if (!$user_node->hasAttribute($login_attribute_name)) { Logger::error('main', 'Token webservice does not send a valid XML'); return NULL; } $this->login = $user_node->getAttribute($login_attribute_name); return $this->login; }
public static function callMethod($method_name_, $type_, $element_ = NULL, $group_ = NULL) { Logger::debug('main', "Abstract_Liaison::callMethod ('{$method_name_}', '{$type_}', '{$element_}', '{$group_}')"); if ($type_ != 'UsersGroup') { $method_to_call = array('Abstract_Liaison_sql', $method_name_); $class_to_use = 'Abstract_Liaison_sql'; } else { $prefs = Preferences::getInstance(); if (!$prefs) { Logger::error('main', 'Abstract_Liaison::load get Preferences failed'); return NULL; } $mods_enable = $prefs->get('general', 'module_enable'); if (!in_array('UserGroupDB', $mods_enable)) { Logger::error('main', 'Abstract_Liaison::load UserGroupDB module must be enabled'); return NULL; } $mod_usergroup_name = 'UserGroupDB_' . $prefs->get('UserGroupDB', 'enable'); $liaison_type = call_user_func(array($mod_usergroup_name, 'liaisonType')); $method_to_call = array('Abstract_Liaison_' . $liaison_type, $method_name_); $class_to_use = 'Abstract_Liaison_' . $liaison_type; } if (!method_exists($class_to_use, $method_name_)) { Logger::error('main', "Abstract_Liaison::callMethod method '{$method_to_call}' does not exist"); return NULL; } return call_user_func($method_to_call, $type_, $element_, $group_); }
/** * Gets the default and possible currencies of the shop. * * @author David Pauli <*****@*****.**> * @since 0.0.0 * @since 0.1.0 Use HTTPRequestMethod enum * @since 0.1.0 Save timestamp of the last request. * @since 0.1.0 Add configured used Currency. * @api */ private static function load() { // if request method is blocked if (!RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { return; } $content = RESTClient::send(self::RESTPATH); // if respond is empty or there are no default AND items element if (InputValidator::isEmptyArrayKey($content, "default") || InputValidator::isEmptyArrayKey($content, "items")) { Logger::error("Respond for " . self::RESTPATH . " can not be interpreted."); return; } // reset values self::resetValues(); // save the default currency self::$DEFAULT = $content["default"]; // parse the possible currencies self::$ITEMS = $content["items"]; // set the configured shop Locale if it is empty. if (InputValidator::isEmpty(self::$USED)) { self::$USED = $content["default"]; } // update timestamp when make the next request $timestamp = (int) (microtime(true) * 1000); self::$NEXT_REQUEST_TIMESTAMP = $timestamp + RESTClient::$NEXT_RESPONSE_WAIT_TIME; }
/** * This function gets the product images. * * @author David Pauli <*****@*****.**> * @since 0.1.0 * @since 0.1.1 Fix bug with nonsetted product URL and delete reload functionality. * @since 0.1.1 Use unstatic variables. * @api * @param String $productID The product ID to get images. */ private function load($productID) { // if parameter is wrong or GET is blocked if (!InputValidator::isProductId($productID) || !RESTClient::setRequestMethod(HTTPRequestMethod::GET)) { return; } $content = RESTClient::send("products/" . $productID . "/" . self::RESTPATH); // if respond is empty if (InputValidator::isEmpty($content)) { return; } // if there is items if (InputValidator::isEmptyArrayKey($content, "items")) { Logger::error("Respond for product/" . $productID . "/" . self::RESTPATH . " can not be interpreted."); return; } // is there any images found: load the images. foreach ($content['items'] as $number => $image) { // parse every image size if (!InputValidator::isEmptyArrayKey($image, "sizes")) { $object = null; foreach ($image["sizes"] as $size) { // if there is "url" and "classifier" set in the image if (!InputValidator::isEmptyArrayKey($size, "url") && !InputValidator::isEmptyArrayKey($size, "classifier")) { $object[$size["classifier"]] = $size["url"]; } } // if all needed sizes are available, save it if (!InputValidator::isEmptyArrayKey($object, "Thumbnail") && !InputValidator::isEmptyArrayKey($object, "Small") && !InputValidator::isEmptyArrayKey($object, "HotDeal") && !InputValidator::isEmptyArrayKey($object, "MediumSmall") && !InputValidator::isEmptyArrayKey($object, "Medium") && !InputValidator::isEmptyArrayKey($object, "MediumLarge") && !InputValidator::isEmptyArrayKey($object, "Large")) { array_push($this->images, $object); } } } }
public function get_login() { Logger::debug('main', 'AuthMethod_CAS::get_login()'); if (!isset($_SESSION['backup_sso']) || !is_array($_SESSION['backup_sso'])) { $_SESSION['backup_sso'] = array(); } foreach ($_REQUEST as $k => $v) { $_SESSION['backup_sso'][$k] = $v; } $buf = $this->prefs->get('AuthMethod', 'CAS'); $CAS_server_url = $buf['user_authenticate_cas_server_url']; if (!isset($CAS_server_url) || $CAS_server_url == '') { Logger::error('main', 'AuthMethod_CAS::get_login() - Unable to find CAS server url in Preferences'); return NULL; } phpCAS::client(CAS_VERSION_2_0, parse_url($CAS_server_url, PHP_URL_HOST), parse_url($CAS_server_url, PHP_URL_PORT), parse_url($CAS_server_url, PHP_URL_PATH)); Logger::debug('main', 'AuthMethod_CAS::get_login() - Parsing URL - Host:"' . parse_url($CAS_server_url, PHP_URL_HOST) . '" Port:"' . parse_url($CAS_server_url, PHP_URL_PORT) . '" Path:"' . parse_url($CAS_server_url, PHP_URL_PATH) . '"'); phpCAS::setNoCasServerValidation(); if (!phpCAS::forceAuthentication()) { Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::forceAuthentication failed'); return NULL; } if (!phpCAS::isAuthenticated()) { Logger::error('main', 'AuthMethod_CAS::get_login() - phpCAS::isAuthenticated failed'); return NULL; } $this->login = phpCAS::getUser(); foreach ($_SESSION['backup_sso'] as $k => $v) { if (isset($_REQUEST[$k])) { continue; } $_REQUEST[$k] = $v; } return $this->login; }
public function import($login_) { Logger::debug('main', 'UserDB::activedirectory::import(' . $login_ . ')'); $atpos = strpos($login_, '@'); if ($atpos !== false) { $login = substr($login_, 0, $atpos); $domain = strtoupper(substr($login_, $atpos + 1)); } else { $login = $login_; $domain = null; } $user = parent::import($login); if (is_null($user)) { return $user; } if ($domain != null) { $user_domain = self::suffix2domain($user->getAttribute('dn')); if ($user_domain == $domain || $user_domain == $domain . '.' . strtoupper($this->config_ad['domain'])) { $user->setAttribute('domain', $user_domain); } else { if (strtolower($login_) == strtolower($user->getAttribute('principal'))) { $user->setAttribute('domain', $domain); } else { Logger::error('main', 'Bad domain name in given login (' . $domain . ') rather than result domain for user: ' . $user_domain); return null; } } } return $user; }
public function executeQuery($query, $logComponent, $defaultGraphURI = null, $format = null) { $sparqlendpoint = $this->sparqlendpointURL; $url = $sparqlendpoint . "?query="; $url .= urlencode($query); $url .= $this->_getDefaultGraphURI($defaultGraphURI); $url .= $this->_getFormat($format); // echo $url; Timer::start($logComponent . '::http_sparqlquery'); Logger::debug($logComponent . "::url = " . $url); $c = curl_init(); curl_setopt($c, CURLOPT_RETURNTRANSFER, 1); curl_setopt($c, CURLOPT_URL, $url); //curl_setopt($c, CURLOPT_HTTPHEADER, $headers); $contents = curl_exec($c); if ($contents === false) { $error = "\nSparqlRetrieval: endpoint failure {$sparqlendpoint}\n"; $error .= "Error: " . curl_error($c) . "\n"; $error .= "URL: " . $url . "\n"; $error .= "Query: " . $query . "\n"; Logger::error($logComponent . $error); } curl_close($c); Timer::stop($logComponent . '::http_sparqlquery'); //echo $contents;die; Logger::debug($logComponent . "returned: " . strlen($contents) . " of json code"); return $contents; }
/** * 执行 mysql_query 并返回其结果. */ public function query($sql) { if ($this->readonly) { if (self::is_write_query($sql)) { throw new Exception("write operation is not allowed on readonly db!"); } } $stime = microtime(true); $result = mysql_query($sql, $this->conn); $this->query_count++; if ($result === false) { Logger::error(mysql_error($this->conn) . " in SQL: {$sql}"); if (defined('ENV') && ENV == 'dev') { throw new Exception(mysql_error($this->conn) . " in SQL: {$sql}"); } else { throw new Exception('db error'); } } $etime = microtime(true); $time = number_format(($etime - $stime) * 1000, 2); $ro = $this->readonly ? '[RO]' : '[RW]'; $log = "{$ro} {$time} {$sql}"; if (defined('ENV') && ENV == 'dev') { $this->query_list[] = $log; } #Logger::debug($log); return $result; }
/** * @param $object * @param bool $disableMappingExceptions * @param null $idMapper * @throws \Exception */ public function reverseMap($object, $disableMappingExceptions = false, $idMapper = null) { $keys = get_object_vars($this); foreach ($keys as $key => $value) { $method = "set" . $key; if (method_exists($object, $method)) { $object->{$method}($value); } } //must be after generic setters above!! parent::reverseMap($object, $disableMappingExceptions, $idMapper); if (is_array($this->elements)) { foreach ($this->elements as $element) { $class = $object->getClass(); $setter = "set" . ucfirst($element->name); if (method_exists($object, $setter)) { $tag = $class->getFieldDefinition($element->name); if ($tag) { if ($class instanceof Model\Object\ClassDefinition\Data\Fieldcollections) { $object->{$setter}($tag->getFromWebserviceImport($element->fieldcollection, $object, [], $idMapper)); } else { $object->{$setter}($tag->getFromWebserviceImport($element->value, $object, [], $idMapper)); } } else { \Logger::error("tag for field " . $element->name . " not found"); } } else { if (!$disableMappingExceptions) { throw new \Exception("No element [ " . $element->name . " ] of type [ " . $element->type . " ] found in class definition [" . $class->getId() . "] | " . $class->getName()); } } } } }
/** * Overwrite the method from abstract PageController. * Possibility to handle requests sent to the 'shipping' page. */ public function handleRequestInMain() { // redirect the user if it's not logged in. if (isset($_SESSION[Session::USER])) { $this->redirect("mydata.php"); } // handle only POST requests if ($_SERVER["REQUEST_METHOD"] == "POST") { // create a NamedQuery, then add all given params in POST array $namedQuery = new NamedQuery($this->QUERY_INSERT_USER); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-firstname"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-lastname"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-email"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-address"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-addressnr"])); $namedQuery->addParam(QueryParam::TYPE_INTEGER, StringUtils::removeTags($_POST["name-zipcode"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-city"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::removeTags($_POST["name-country"])); $namedQuery->addParam(QueryParam::TYPE_STRING, StringUtils::convertInSha1($_POST["name-password"])); // try to execute the query if (!CRUDService::getInstance()->executeNamedQuery($namedQuery)) { Logger::error("error registering a new user"); } else { // query was OK. // reload the user's data and store them in the session $namedQuery = new NamedQuery($this->QUERY_LOAD_USER); $namedQuery->addParam(QueryParam::TYPE_STRING, $_POST["name-email"]); $result = CRUDService::getInstance()->fetchNamedQuery($namedQuery, "User"); $_SESSION[Session::USER] = serialize($result[0]); $this->redirect("home.php"); } } }
public static function get($label) { if (!self::wasSet($label)) { Logger::error('TheContainer: access to ' . $label . ' failed, not set previously'); } return self::$container[$label]; }
function load() { Logger::debug("Loading configurations", $this->controller, "load"); $routes = array(); if (file_exists(APP_ROOT . "/config/routes.php")) { Logger::debug("Loading routes: " . APP_ROOT . "/config/routes.php", $this->controller, "load"); include APP_ROOT . "/config/routes.php"; $this->routes = $routes; } else { Logger::error("Routes not found: " . APP_ROOT . "/config/routes.php", $this->controller, "load"); throw new Exception("Routes file not found in " . APP_ROOT . "config/routes.php"); } // try { // require_once APP_ROOT . "/config/".$hosts[$_SERVER["HTTP_HOST"]]; // } catch (Exception $e) { // Rescue::NoConfigurationAvailable(get_class($this)); // } $config = array(); if (file_exists(APP_ROOT . "/config/config.php")) { Logger::debug("Loading configuration: " . APP_ROOT . "/config/config.php", $this->controller, "load"); include APP_ROOT . "/config/config.php"; $this->config = $config; } else { Logger::error("Configuration not found: " . APP_ROOT . "/config/config.php", $this->controller, "load"); throw new Exception("Config file not found in " . APP_ROOT . "config/config.php"); } if ($this->config["data_source"] && class_exists($this->config["data_source"])) { Logger::debug("Loading datasource: " . $this->config["data_source"], $this->controller, "load"); $class = $this->config["data_source"]; $this->ds = new $class(); $this->ds->config = $this->config; } $this->loaded = true; }
public function checkPermission($object, IPermission $perm, LoginContext $context = null) { try { if ($object === null) { throw new EyeNullPointerException('$object cannot be null.'); } if ($perm === null) { throw new EyeNullPointerException('$perm cannot be null.'); } if ($context === null) { $currentProcess = ProcManager::getInstance()->getCurrentProcess(); if ($currentProcess === null) { self::$Logger->warn('Cannot check permission on object of class ' . get_class($object) . ': No current process.'); throw new EyeAccessControlException('Access denied: No current process.'); } $context = $currentProcess->getLoginContext(); if ($context === null) { //self::$Logger->warn('Cannot check permission on object of class ' . get_class($object) . ': No LoginContext found in current process.'); //throw new EyeAccessControlException('Access denied: No LoginContext found in current process.'); self::$Logger->info('Initializing blank login context for permission check on object of class ' . get_class($object) . '.'); $context = new LoginContext('eyeos-login', new Subject()); } } $checker = new SecurityChecker(); $checker->doCheck($object, $perm, $context); } catch (Exception $e) { self::$Logger->error('Cannot perform permission check: ' . $e->getMessage()); if (self::$Logger->isDebugEnabled()) { self::$Logger->debug(ExceptionStackUtil::getStackTrace($e, false)); } throw $e; } }
/** * allow or block operations * * @param string the kind of item to handle * @param string the foreseen operation ('edit', 'new', ...) * @return TRUE if the operation is accepted, FALSE otherwise */ function allows($action, $type = '') { global $context; // we filter only approvals if ($type != 'approval') { return TRUE; } // we filter only new votes if ($action != 'new') { return TRUE; } // block if this surfer has already voted if (isset($this->attributes['id']) && Surfer::get_id() && Comments::count_approvals_for_anchor($this->anchor->get_reference(), Surfer::get_id())) { Logger::error(i18n::s('You have already signed')); return FALSE; } // vote is open $open = FALSE; // no end date if (!isset($this->attributes['end_date']) || $this->attributes['end_date'] <= NULL_DATE) { $open = TRUE; } elseif ($context['now'] < $this->attributes['end_date']) { $open = TRUE; } // wait a minute if (!$open) { Logger::error(i18n::s('Petition has been closed.')); return FALSE; } // allowed return TRUE; }
/** * @param user * @param pass * * */ public static function login($request) { $request["user"] = isset($request["user"]) ? $request["user"] : null; $request["email"] = $request["user"]; if (isset($request["password"])) { $request["pass"] = $request["password"]; } $sql = "select pswd, cuenta, userID, mail from Usuario where BINARY ( userID = ? or mail = ? )"; $inputarray = array($request["user"], $request["email"]); global $db; $result = $db->Execute($sql, $inputarray); $resultData = $result->GetArray(); if (sizeof($resultData) == 1) { $dbUser = $resultData[0]; if (crypt($request["pass"], $dbUser["pswd"]) == $dbUser["pswd"]) { unset($dbUser["pswd"]); unset($dbUser[0]); $_SESSION['userID'] = $dbUser['userID']; Logger::info("sesion iniciada para " . $dbUser["userID"]); return array("result" => "ok", "user" => $dbUser); } } Logger::error("Credenciales invalidas para usuario :" . $request["user"]); return array("result" => "error", "reason" => "Credenciales invalidas."); }