private final function scan($root_path, $dir) { if ($this->dump_scans) { echo "Scanning : " . $dir . "<br />"; } if (!is_dir($root_path . $dir)) { Log::warn(__METHOD__, "La directory " . $root_path . $dir . " non e' una directory valida ... skip ..."); return; } //IMPORTANTE SCANDIR DEVE RITORNARE IN ORDINE ALFABETICO!!! Default = 0 -> OK if (!array_key_exists($dir, self::$skip_dirs)) { $file_list = scandir($root_path . $dir); foreach ($file_list as $filename) { if (!array_key_exists($filename, self::$skip_dirs)) { //echo "Scanning : [ ".$filename." ]"; $full_path = $root_path . $dir . $filename; if ($this->scan_recursively && $this->is_subdirectory($root_path . $dir, $filename)) { $this->scan($root_path, $dir . $filename . DIRECTORY_SEPARATOR); } else { if (is_file($full_path) && $this->is_valid_filename($filename)) { if ($this->dump_scans) { echo "Valid file found : " . $dir . $filename . "<br />"; } $this->valid_file_found($dir, $filename); } } } } } }
/** * Planet クロールする **/ public static function __setup_crawl__() { $http_feed = new Feed(); foreach (C(PlanetSubscription)->find_all() as $subscription) { Exceptions::clear(); Log::debug(sprintf('[crawl] feed: %d (%s)', $subscription->id(), $subscription->title())); try { $feed = $http_feed->do_read($subscription->rss_url()); $subscription->title($feed->title()); if ($feed->is_link()) { $subscription->link(self::_get_link_href($feed->link())); } $subscription->rss_url($http_feed->url()); $subscription->save(true); foreach ($feed->entry() as $entry) { Exceptions::clear(); try { $planet_entry = new PlanetEntry(); $planet_entry->subscription_id($subscription->id()); $planet_entry->title(Tag::cdata($entry->title())); $planet_entry->description(Text::htmldecode(Tag::cdata($entry->fm_content()))); $planet_entry->link($entry->first_href()); $planet_entry->updated($entry->published()); $planet_entry->save(); } catch (Exception $e) { Log::warn($e->getMessage()); } } } catch (Exception $e) { Log::error($e); } } }
function myErrorHandler($errno, $errstr, $errfile, $errline) { if (!class_exists('Log')) { require YYUC_LIB . 'sys/log.php'; } $err_msg = "信息:{$errno}。内容:{$errstr},发生在文件{$errfile}的{$errline}行"; switch ($errno) { case E_USER_ERROR: Log::error($err_msg); if (Conf::$is_developing) { echo $err_msg; } exit(1); break; case E_USER_WARNING: Log::warn($err_msg); break; case E_USER_NOTICE: Log::info($err_msg); break; default: Log::info($err_msg); break; } return true; }
/** * @see \Components\Cache_Backend::set() set */ public function set($key_, $value_, $ttl_ = 86400) { if (false === @apc_store(COMPONENTS_CACHE_NAMESPACE . "-{$key_}", $value_, $ttl_)) { Log::warn('components/cache/backend/apc', 'Unable to cache value [key: %s, value: %s].', $key_, $value_); return false; } return true; }
/** * bung this user's ID in the session */ public function addToSession() { $s = Session::getInstance(); $s->user_id = $this->getId(); if ($s->user_id === null) { Log::warn("Adding null user ID to session"); } $this->setAuthed(true); }
public function LogAction() { Log::fatal('something'); Log::warn('something'); Log::notice('something'); Log::debug('something'); Log::sql('something'); echo '请到Log文件夹查看效果。如果是SAE环境,可以在日志中心的DEBUG日志查看。'; }
/** * Remove block marking as invalid * @param Entity\Abstraction\Block $block * @param string $reason */ public function removeInvalidBlock(Block $block, $reason = 'unknown') { /* @var $testBlock Entity\Abstraction\Block */ foreach ($this as $index => $testBlock) { if ($testBlock->equals($block)) { \Log::warn("Block {$block} removed as invalid with reason: {$reason}"); $this->offsetUnset($index); } } }
/** * Update category entry in database */ public function edit() { if ($this->id > 0 && $this->warehouseId > 0 && is_string($this->name) && strlen($this->name) > 0) { $sql = "UPDATE " . Database::getTableName('categories') . " SET parent=?, warehouse=?, name=?, demand=?, male=?, female=?, children=?, baby=?, summer=?, winter=?, weight=? WHERE id=?"; $response = Database::getInstance()->sql('editCategory', $sql, 'iisiiiiiiiii', [$this->parent, $this->warehouseId, $this->name, $this->demand, $this->male, $this->female, $this->children, $this->baby, $this->summer, $this->winter, $this->weight, $this->id], false); if (is_array($response)) { Log::debug('Edited category #' . $this->id); return true; } } else { Log::warn('Category id is #' . $this->id); } return false; }
public function load($class_name) { $loaded = false; if ($this->has_found_element($class_name)) { $path = $this->get_element_path_by_name($class_name); require_once $path; if (array_key_exists(self::CLASS_AFTER_LOAD_INTERFACE, class_implements($class_name))) { $eval_string = $class_name . "::" . self::CLASS_AFTER_LOAD_METHOD . "('{$class_name}');"; eval($eval_string); Log::info(__METHOD__, "Class {$class_name} initialized after loading."); } $loaded = true; return; } Log::warn(__METHOD__, "Classe non trovata : {$class_name}, using other classloaders ..."); }
/** * Sends a http-query. * @param string $url * @param array $params * @return null|Response */ public function send($url, array $params = []) { $params = array_merge(parse_url($url), $params); $request = $this->getRequest($params); try { $response = $this->getResponse($url, $params); } catch (BadResponseException $e) { if ($e->hasResponse()) { return $this->convertResponse($e->getResponse(), $request); } return null; } catch (\Exception $e) { if (class_exists('\\rock\\log\\Log')) { Log::warn(BaseException::convertExceptionToString($e)); } return null; } return $this->convertResponse($response, $request); }
/** * example.com/api/<guid>/balance?password=xxx&debug=1 */ public function balance($guid) { if (!$this->attemptAuth()) { return Response::json(['error' => AUTHENTICATION_FAIL]); } if (Input::get('cryptotype')) { $this->crypto_type_id = Input::get('cryptotype'); } // at this point '$this->user' is already set $user_balance = Balance::getBalance($this->user->id, $this->crypto_type_id); if (count($user_balance)) { Log::info('Queried balance for ' . $this->user->email . ': ' . $user_balance->balance . ' satoshis. Crypto type id: ' . $this->crypto_type_id); $response = ['balance' => $user_balance->balance, 'crypto_type' => $this->crypto_type_id]; } else { Log::warn('Balance not found for user ' . $this->user->email . 'for crypto type ' . $this->crypto_type_id); $response = ['error' => 'Balance not found for crypto type ' . $this->crypto_type_id]; } return Response::json($response); }
/** * Send data back to YAML * * @param array $array Array of data to convert * @param string $mode Mode to parse (loose|transitional|strict) * @return string */ public static function dump($array, $mode = null) { $mode = $mode ? $mode : self::getMode(); switch ($mode) { case 'loose': return Spyc::YAMLDump($array); case 'strict': return sYaml::dump($array, 5, 2); case 'transitional': try { return sYaml::dump($array, 5, 2); } catch (Exception $e) { Log::warn($e->getMessage() . ' Falling back to loose mode.', 'core', 'YAML'); return Spyc::YAMLDump($array); } default: return Spyc::YAMLDump($array); } }
public static function load_from_dir($dir) { if ($dir instanceof Dir) { $my_dir = $dir; } else { $my_dir = new Dir($dir); } self::$css_dirs[] = $my_dir; //CSS_DIRS if ($my_dir->exists() && $my_dir->isDir()) { $file_list = $my_dir->listFiles(); foreach ($file_list as $f) { if ($f->isFile() && $f->getExtension() == "css") { self::require_css_file($f); } } } else { Log::warn("load_from_dir", "Impossibile caricare i css dalla directory : " . $my_dir->getName()); } }
/** * Update carton entry in database */ public function edit() { if ($this->id > 0 && $this->warehouseId > 0) { if ($this->paletteId != null && $this->paletteId > 0) { $palette = new Palette($this->paletteId, $this->warehouseId); if ($palette) { $this->locationId = $palette->locationId; } } $sql = "UPDATE " . Database::getTableName('cartons') . " SET warehouse=?, location=?, palette=? WHERE id=?"; $response = Database::getInstance()->sql('editCarton', $sql, 'iiii', [$this->warehouseId, $this->locationId, $this->paletteId, $this->id], false); if (is_array($response)) { Log::debug('Edited carton #' . $this->id); return true; } else { Log::warn('carton id is #' . $this->id); } } return false; }
public static function setUp($logSettings) { Log::$err = $logSettings['errors']; Log::$warn = $logSettings['warnings']; Log::$all = $logSettings['all']; Log::$debug = $logSettings['debug']; Log::$req = $logSettings['requests']; //removing old files if (file_exists(Log::$err)) { unlink(Log::$err); } if (file_exists(Log::$warn)) { unlink(Log::$warn); } if (file_exists(Log::$all)) { unlink(Log::$all); } if (file_exists(Log::$debug)) { unlink(Log::$debug); } if (file_exists(Log::$req)) { unlink(Log::$req); } }
public function preview() { try { $file = BasefileModel::createFromPath($this->id); if ($file) { if ($file->type == 'image') { $thumb = BasefileModel::createFromPath($file->getThumb(intval($this->params->width), intval($this->params->height), intval($this->params->mode))); if ($thumb) { return new ResponseImage($thumb); } else { Log::warn("Not finde image {$this->id} thumb"); } } else { Log::error("File {$this->id} not image type"); } } else { Log::warn("Not finde image " . $this->id); } } catch (Exception $ex) { Log::exception($ex); } header("HTTP/1.0 404 Not Found"); exit; }
/** * Updates warehouse data in database. */ public function edit() { if ($this->id > 0 && is_string($this->name) && strlen($this->name) > 0 && is_string($this->password) && strlen($this->password) > 0) { $sql = "UPDATE " . Database::getTableName('warehouses') . " SET name=?, description=?, country=?, city=?, mail=?, password=?, passwordRestricted=?, disableLocationLess=?, disablePaletteLess=? WHERE id=?"; $response = Database::getInstance()->sql('editWarehouse', $sql, 'sssssssiii', [$this->name, $this->description, $this->country, $this->city, $this->mail, $this->password, $this->passwordRestricted, $this->disableLocationLess, $this->disablePaletteLess, $this->id], false); if (is_array($response)) { Log::debug('Edited warehouse ID #' . $this->id); return true; } } else { Log::warn('Warehouse id is #' . $this->id); } return false; }
public function Validate_Printer_Queue($db_id, $input) { /* *********************************** ** Verify times and ids are ints ** *********************************** * ready_at, started_at, blueprint_id */ foreach ($input->Player_Craft_Queue as $cq) { //we expect only three keys if (!isset($cq->ready_at) || !isset($cq->started_at) || !isset($cq->blueprint_id)) { continue; } else { if (!is_numeric($cq->ready_at) && !is_numeric($cq->started_at) && !is_numeric($cq->blueprint_id)) { Log::warn("Player ({$db_id}) sent Craft Queue values that contained something other than a number."); return false; } } //all keys set } //foreach return true; }
/** * Sends the users password to the email address or sends * * @param unknown_type $user_id * @param unknown_type $password */ function sendEmailPassword($user_id, $password) { $result = $GLOBALS['db']->query("SELECT email1, email2, first_name, last_name FROM users WHERE id='{$user_id}'"); $row = $GLOBALS['db']->fetchByAssoc($result); global $sugar_config; if (empty($row['email1']) && empty($row['email2'])) { $_SESSION['login_error'] = 'Please contact an administrator to setup up your email address associated to this account'; return; } global $locale; $OBCharset = $locale->getPrecedentPreference('default_email_charset'); $notify_mail = new SugarPHPMailer(); $notify_mail->CharSet = $sugar_config['default_charset']; $notify_mail->AddAddress(!empty($row['email1']) ? $row['email1'] : $row['email2'], $locale->translateCharsetMIME(trim($row['first_name'] . ' ' . $row['last_name']), 'UTF-8', $OBCharset)); if (empty($_SESSION['authenticated_user_language'])) { $current_language = $sugar_config['default_language']; } else { $current_language = $_SESSION['authenticated_user_language']; } $notify_mail->Subject = 'Sugar Token'; $notify_mail->Body = 'Your sugar session authentication token is: ' . $password; $notify_mail->setMailerForSystem(); $notify_mail->From = '*****@*****.**'; $notify_mail->FromName = 'Sugar Authentication'; if (!$notify_mail->Send()) { Log::warn("Notifications: error sending e-mail (method: {$notify_mail->Mailer}), (error: {$notify_mail->ErrorInfo})"); } else { Log::info("Notifications: e-mail successfully sent"); } }
public function processResponse($keyExchangeMessage) { $sessionRecord = $this->sessionStore->loadSession($this->recipientId, $this->deviceId); $sessionState = $sessionRecord->getSessionState(); $hasPendingKeyExchange = $sessionState->hasPendingKeyExchange(); $isSimultaneousInitiateResponse = $keyExchangeMessage->isResponseForSimultaneousInitiate(); if (!$hasPendingKeyExchange || $sessionState->getPendingKeyExchangeSequence() != $keyExchangeMessage->getSequence()) { Log::warn('procResponse', 'No matching sequence for response. Is simultaneous initiate response:' . ($isSimultaneousInitiateResponse ? 'true' : 'false')); if (!$isSimultaneousInitiateResponse) { throw new StaleKeyExchangeException(); } else { return; } } $parameters = new SymmetricBuilder(); $parameters->setOurBaseKey($sessionRecord->getSessionState()->getPendingKeyExchangeBaseKey())->setOurRatchetKey($sessionRecord->getSessionState()->getPendingKeyExchangeRatchetKey())->setOurIdentityKey($sessionRecord->getSessionState()->getPendingKeyExchangeIdentityKey())->setTheirBaseKey($keyExchangeMessage->getBaseKey())->setTheirRatchetKey($keyExchangeMessage->getRatchetKey())->setTheirIdentityKey($keyExchangeMessage->getIdentityKey()); if (!$sessionRecord->isFresh()) { $sessionRecord->archiveCurrentState(); } RatchetingSession::initializeSession($sessionRecord->getSessionState(), min($keyExchangeMessage->getMaxVersion(), CiphertextMessage::CURRENT_VERSION), $parameters->create()); if ($sessionRecord->getSessionState()->getSessionVersion() >= 3 && !Curve::verifySignature($keyExchangeMessage->getIdentityKey()->getPublicKey(), $keyExchangeMessage->getBaseKey()->serialize(), $keyExchangeMessage->getBaseKeySignature())) { throw new InvalidKeyException("Base key signature doesn't match!"); } $this->sessionStore->storeSession($this->recipientId, $this->deviceId, $sessionRecord); $this->identityKeyStore->saveIdentity($this->recipientId, $keyExchangeMessage->getIdentityKey()); }
/** * xml定義からhandlerを処理する * @param string $file アプリケーションXMLのファイルパス */ public static final function load($file = null) { if (!isset($file)) { $file = App::mode() . App::called_filename(); } if (!self::$is_app_cache || !Store::has($file)) { $parse_app = self::parse_app($file, false); if (self::$is_app_cache) { Store::set($file, $parse_app); } } if (self::$is_app_cache) { $parse_app = Store::get($file); } if (empty($parse_app['apps'])) { throw new RuntimeException('undef app'); } $app_result = null; $in_app = $match_handle = false; $app_index = 0; try { foreach ($parse_app['apps'] as $app) { switch ($app['type']) { case 'handle': $self = new self('_inc_session_=false'); foreach ($app['modules'] as $module) { $self->add_module(self::import_instance($module)); } if ($self->has_module('flow_handle_begin')) { $self->call_module('flow_handle_begin', $self); } try { if ($self->handler($app['maps'], $app_index++)->is_pattern()) { $self->cp(self::execute_var($app['vars'])); $src = $self->read(); if ($self->has_module('flow_handle_end')) { $self->call_module('flow_handle_end', $src, $self); } print $src; $in_app = true; $match_handle = true; if (!$parse_app["handler_multiple"]) { exit; } } } catch (Exception $e) { Log::warn($e); if (isset($app['on_error']['status'])) { Http::status_header((int) $app['on_error']['status']); } if (isset($app['on_error']['redirect'])) { $this->save_exception($e); $this->redirect($app['on_error']['redirect']); } else { if (isset($app['on_error']['template'])) { if (!$e instanceof Exceptions) { Exceptions::add($e); } $self->output($app['on_error']['template']); } else { throw $e; } } } break; case 'invoke': $class_name = isset($app['class']) ? Lib::import($app['class']) : get_class($app_result); $ref_class = new ReflectionClass($class_name); foreach ($app['methods'] as $method) { $invoke_class = $ref_class->getMethod($method['method'])->isStatic() ? $class_name : (isset($app['class']) ? new $class_name() : $app_result); $args = array(); foreach ($method['args'] as $arg) { if ($arg['type'] === 'result') { $args[] =& $app_result; } else { $args[] = $arg['value']; } } if (is_object($invoke_class)) { foreach ($app['modules'] as $module) { $invoke_class->add_module(self::import_instance($module)); } } $app_result = call_user_func_array(array($invoke_class, $method['method']), $args); $in_app = true; } break; } } if (!$match_handle) { Log::debug("nomatch"); if ($parse_app["nomatch_redirect"] !== null) { Http::redirect(App::url($parse_app["nomatch_redirect"])); } if ($parse_app["nomatch_template"] !== null) { Http::status_header(404); $self = new self(); $self->output($parse_app["nomatch_template"]); } } if (!$in_app) { Http::status_header(404); } } catch (Exception $e) { if (!$e instanceof Exceptions) { Exceptions::add($e); } } exit; }
function save($check_notify = false) { global $timedate; global $current_user; global $disable_date_format; if (isset($this->date_start)) { $td = $timedate->fromDb($this->date_start); if (!$td) { $this->date_start = $timedate->to_db($this->date_start); $td = $timedate->fromDb($this->date_start); } if ($td) { if (isset($this->duration_hours) && $this->duration_hours != '') { $td->modify("+{$this->duration_hours} hours"); } if (isset($this->duration_minutes) && $this->duration_minutes != '') { $td->modify("+{$this->duration_minutes} mins"); } $this->date_end = $td->asDb(); } } $check_notify = !empty($_REQUEST['send_invites']) && $_REQUEST['send_invites'] == '1' ? true : false; if (empty($_REQUEST['send_invites'])) { if (!empty($this->id)) { $old_record = new Meeting(); $old_record->retrieve($this->id); $old_assigned_user_id = $old_record->assigned_user_id; } if (empty($this->id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $GLOBALS['current_user']->id != $_REQUEST['assigned_user_id'] || isset($old_assigned_user_id) && !empty($old_assigned_user_id) && isset($_REQUEST['assigned_user_id']) && !empty($_REQUEST['assigned_user_id']) && $old_assigned_user_id != $_REQUEST['assigned_user_id']) { $this->special_notification = true; $check_notify = true; if (isset($_REQUEST['assigned_user_name'])) { $this->new_assigned_user_name = $_REQUEST['assigned_user_name']; } } } /*nsingh 7/3/08 commenting out as bug #20814 is invalid if($current_user->getPreference('reminder_time')!= -1 && isset($_POST['reminder_checked']) && isset($_POST['reminder_time']) && $_POST['reminder_checked']==0 && $_POST['reminder_time']==-1){ $this->reminder_checked = '1'; $this->reminder_time = $current_user->getPreference('reminder_time'); }*/ // prevent a mass mailing for recurring meetings created in Calendar module if (empty($this->id) && !empty($_REQUEST['module']) && $_REQUEST['module'] == "Calendar" && !empty($_REQUEST['repeat_type']) && !empty($this->repeat_parent_id)) { $check_notify = false; } if (empty($this->status)) { $this->status = $this->getDefaultStatus(); } // Do any external API saving // Clear out the old external API stuff if we have changed types if (isset($this->fetched_row) && $this->fetched_row['type'] != $this->type) { $this->join_url = ''; $this->host_url = ''; $this->external_id = ''; $this->creator = ''; } if (!empty($this->type) && $this->type != 'Sugar') { require_once 'include/externalAPI/ExternalAPIFactory.php'; $api = ExternalAPIFactory::loadAPI($this->type); } if (empty($this->type)) { $this->type = 'Sugar'; } if (isset($api) && is_a($api, 'WebMeeting') && empty($this->in_relationship_update)) { // Make sure the API initialized and it supports Web Meetings // Also make suer we have an ID, the external site needs something to reference if (!isset($this->id) || empty($this->id)) { $this->id = create_guid(); $this->new_with_id = true; } $response = $api->scheduleMeeting($this); if ($response['success'] == true) { // Need to send out notifications if ($api->canInvite) { $notifyList = $this->get_notification_recipients(); foreach ($notifyList as $person) { $api->inviteAttendee($this, $person, $check_notify); } } } else { // Generic Message Provides no value to End User - Log the issue with message detail and continue // SugarApplication::appendErrorMessage($GLOBALS['app_strings']['ERR_EXTERNAL_API_SAVE_FAIL']); Log::warn('ERR_EXTERNAL_API_SAVE_FAIL' . ": " . $this->type . " - " . $response['errorMessage']); } $api->logoff(); } $return_id = parent::save($check_notify); if ($this->update_vcal) { vCal::cache_sugar_vcal($current_user); } return $return_id; }
/** * Gets a Member's profile * * @deprecated * @param string $username username to check * @return mixed */ public static function get_profile($username) { // deprecation warning Log::warn('Use of `get_profile` is deprecated. Use `Member::getProfile` instead.', 'core', 'Member'); // get profile return self::getProfile($username); }
public function run() { $this->ajaxAuth = true; if ($this->getOption('auth')) { $this->ajaxAuth = false; $subController = new M_Office_Auth($_REQUEST['database']); if (!key_exists('adminPrivileges', $_SESSION) || key_exists('logout', $_REQUEST)) { $this->assign('username', User::getInstance('office')->getProperty('username')); $this->ajaxAuth = true; } elseif (!User::getInstance('office')->isLoggedIn()) { $this->ajaxAuth = false; } else { $subController->initOptions(); $this->assign('username', User::getInstance('office')->getProperty('username')); } } $not = Notifier::getInstance(); $not->addListener($this); if ($this->getOption('auth') && !User::getInstance('office')->isLoggedIn()) { if (self::isAjaxRequest()) { $this->assign('__action', 'ajaxlogin'); } return; } if (key_exists('updateSuccess', $_REQUEST)) { $this->say(__('Record was successfully updated')); M_Office_Util::clearRequest(array('updateSuccess' => 1)); } if (isset($_REQUEST['module'])) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); $module = $_REQUEST['module']; if (!$info) { if (strpos($_REQUEST['module'], ':')) { $info = array('type' => 'dyn', 'title' => 'Plugin'); $module = $tab[1]; } elseif (preg_match('`^(.+)helper$`', $_REQUEST['module'], $tab)) { $info = array('type' => 'dyn', 'title' => __("modules.{$tab[1]}helper.title")); $module = $_REQUEST['module']; } else { throw new NotFoundException(__('error.module_not_found', array($_REQUEST['module']))); } } } if ($this->isAjaxRequest() && $this->ajaxAuth && $info['type'] != 'dyn') { $this->output = ''; unset($this->localOutput); } if (isset($_REQUEST['debug']) && MODE == 'development') { $debug = (int) $_REQUEST['debug'] % 3; DB_DataObject::debugLevel($debug); ini_set('display_errors', 1); } if ($_REQUEST['livesearch']) { $aj = new M_Office_livesearch($_REQUEST['searchtext'], $_REQUEST['expand']); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['treesort']) { $aj = new M_Office_treesort(); $this->output = $aj->processRequest(); return; } elseif ($_REQUEST['liveedit']) { $aj = new M_Office_liveedit($_REQUEST['liveedit']); $this->output = $aj->processRequest(); return; } elseif (key_exists('ajaxfromtable', $_REQUEST)) { $table = $_REQUEST['module']; $do = DB_DataObject::factory($table); $do->get($_REQUEST['filterField'], $_REQUEST['filterValue']); $aj = new M_Office_ajaxFromTable($do, $_REQUEST['module'], $_REQUEST['module'], $_REQUEST['filterField'], $_REQUEST['filterValue']); $this->output = $aj->processRequest(); return; } if (isset($_REQUEST['module'])) { if (!$info) { $info = M_Office_Util::getModuleInfo($_REQUEST['module']); } switch ($info['type']) { case 'db': // TODO ajouter ce path en avant-dernier et non en dernier Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $info['table'] . '/', 'after'); Mreg::get('tpl')->addPath(APP_ROOT . 'app/' . APP_NAME . '/templates/' . $_REQUEST['module'] . '/', 'after'); $subController = new M_Office_ShowTable($_REQUEST['module'], $filter); break; case 'dyn': // home module = available for everyone $allowAccess = $_REQUEST['module'] == 'home' || M_Office_Util::getGlobalOption('view', 'showtable', $_REQUEST['module']); if (!$allowAccess) { Log::warn('User is NOT allowed to access ' . $_REQUEST['module']); M_Office_Util::refresh(M_Office::URL(array(), array_keys($_REQUEST))); } else { Log::info('User is allowed to access ' . $_REQUEST['module']); } $subController = Module::factory($_REQUEST['module'], M::getPaths('module')); $subController->executeAction($_REQUEST['action'] ? $_REQUEST['action'] : 'index'); $this->assign('__action', 'dyn'); $layout = $subController->getConfig('layout', $_REQUEST['action'] ? $_REQUEST['action'] : 'index'); if ($layout == '__self') { M_Office::$dsp = '__defaut/ajaxindex'; } elseif ($layout) { M_Office::$dsp = $layout; } $this->assign('output', $subController->output(null, '__self')); break; } $this->assign('currentmodule', $_REQUEST['module']); } else { $subController = new M_Office_FrontEndHome(); } }
public function edit_comment() { $comment = Table::factory('Comments')->read($this->getMatch('comment_id')); if ($comment == false || $comment->post_id != $this->post->getId()) { return $this->redirectAction("index", "You cannot perform this action"); } $notApprovedBefore = $comment->hasNeverBeenApproved(); if ($comment->updateValues($this->request->getPost(), true)) { if ($notApprovedBefore && $comment->approved) { // new approval $sentEmails = array(); $comment->approved_at = Utils::getDate("Y-m-d H:i:s"); if ($comment->emailOnApproval()) { // bosh! $from = Settings::getValue("contact.from_address"); $subject = "Your comment has been approved"; $to = $comment->name . " <" . $comment->email . ">"; $email = Email::factory(); $email->setFrom($from); $email->setTo($to); $email->setSubject($subject); $email->setBody($this->fetchTemplate("emails/comment-approved", array("host" => Settings::getValue("site.base_href"), "post" => $this->post, "comment" => $comment))); $email->send(); // ensure sent emails always contains the one we just sent, in case the same user has added another // email $sentEmails[$to] = true; } $comments = Table::factory('Comments')->findOthersForPost($this->post->getId(), $comment->getId()); foreach ($comments as $otherComment) { if ($otherComment->emailOnNew()) { $to = $otherComment->name . " <" . $otherComment->email . ">"; if (isset($sentEmails[$to])) { Log::warn("New comment notification email already sent to [" . $to . "]"); continue; } $from = Settings::getValue("contact.from_address"); $subject = "A new comment has been added"; $email = Email::factory(); $email->setFrom($from); $email->setTo($to); $email->setSubject($subject); $email->setBody($this->fetchTemplate("blog/views/emails/new-comment", array("host" => Settings::getValue("site.base_href"), "post" => $this->post, "comment" => $otherComment, "unsubscribe_hash" => $otherComment->getUnsubscribeHash()))); $email->send(); $sentEmails[$to] = true; } } } $comment->save(); return $this->redirectAction("index", "Comment Updated"); } $this->setErrors($comment->getErrors()); }
function __execute_action() { //chiamo prima della action sul controller //prima cosa, preparo i parametri $this->format_helper->loadInputData($this->params); //ok //callback a cui è possibile linkarsi $this->__before_action(); // agisco sui Params if ($this->execute_action) { //invoco il metodo. Non esiste? Sara' invocato __action_not_found $this->action_result_was_null = false; try { //eseguo la call $tmp_result = $this->controller->{$this->action}(); //la action non ha dato risultati? invoco il metodo __action_result_null() if ($tmp_result === null) { Log::warn("__dispatch_action", "The action result was null ..."); $this->action_result_was_null = true; $tmp_result = $this->__action_result_null(); } $this->action_result = $tmp_result; $this->is_error = false; } catch (Exception $ex) { $this->action_result = $ex; $this->is_error = true; } //callback a cui è possibile linkarsi $this->__after_action(); //agisco sui dati dopo l'azione, i parametri sono ancora al loro posto ... } }
/** * Return the value of the given item. * * If the given item is a Closure the result of the Closure will be returned. * * @deprecated Use Helper::resolveValue() instead * * @param mixed $value * @return mixed */ function value($value) { Log::warn("Use of value() is deprecated. Use Helper::resolveValue() instead.", "core", "Statamic_Helper"); return Helper::resolveValue($value); }
/** * @return string appropriate value for username when binding to directory server. * @param string $user_name the value provided in login form * @desc Take the login username and return either said username for AD or lookup * distinguished name using anonymous credentials for OpenLDAP. * Contributions by Erik Mitchell erikm@logicpd.com */ function ldap_rdn_lookup($user_name, $password) { // MFH BUG# 14547 - Added htmlspecialchars_decode() $server = $GLOBALS['ldap_config']->settings['ldap_hostname']; $base_dn = htmlspecialchars_decode($GLOBALS['ldap_config']->settings['ldap_base_dn']); if (!empty($GLOBALS['ldap_config']->settings['ldap_authentication'])) { $admin_user = htmlspecialchars_decode($GLOBALS['ldap_config']->settings['ldap_admin_user']); $admin_password = htmlspecialchars_decode($GLOBALS['ldap_config']->settings['ldap_admin_password']); } else { $admin_user = ''; $admin_password = ''; } $user_attr = $GLOBALS['ldap_config']->settings['ldap_login_attr']; $bind_attr = $GLOBALS['ldap_config']->settings['ldap_bind_attr']; $port = $GLOBALS['ldap_config']->settings['ldap_port']; if (!$port) { $port = DEFAULT_PORT; } $ldapconn = ldap_connect($server, $port); $error = ldap_errno($ldapconn); if ($this->loginError($error)) { return false; } ldap_set_option($ldapconn, LDAP_OPT_PROTOCOL_VERSION, 3); ldap_set_option($ldapconn, LDAP_OPT_REFERRALS, 0); // required for AD //if we are going to connect anonymously lets at least try to connect with the user connecting if (empty($admin_user)) { $bind = @ldap_bind($ldapconn, $user_name, $password); $error = ldap_errno($ldapconn); } if (empty($bind)) { $bind = @ldap_bind($ldapconn, $admin_user, $admin_password); $error = ldap_errno($ldapconn); } if ($this->loginError($error)) { return false; } if (!$bind) { Log::warn("ldapauth.ldap_rdn_lookup: Could not bind with admin user, trying to bind anonymously"); $bind = @ldap_bind($ldapconn); $error = ldap_errno($ldapconn); if ($this->loginError($error)) { return false; } if (!$bind) { Log::warn("ldapauth.ldap_rdn_lookup: Could not bind anonymously, returning username"); return $user_name; } } // If we get here we were able to bind somehow $search_filter = $this->getUserNameFilter($user_name); Log::info("ldapauth.ldap_rdn_lookup: Bind succeeded, searching for {$user_attr}={$user_name}"); Log::debug("ldapauth.ldap_rdn_lookup: base_dn:{$base_dn} , search_filter:{$search_filter}"); $result = @ldap_search($ldapconn, $base_dn, $search_filter, array("dn", $bind_attr)); $error = ldap_errno($ldapconn); if ($this->loginError($error)) { return false; } $info = ldap_get_entries($ldapconn, $result); if ($info['count'] == 0) { return false; } ldap_unbind($ldapconn); Log::info("ldapauth.ldap_rdn_lookup: Search result:\nldapauth.ldap_rdn_lookup: " . count($info)); if ($bind_attr == "dn") { $found_bind_user = $info[0]['dn']; } else { $found_bind_user = $info[0][strtolower($bind_attr)][0]; } Log::info("ldapauth.ldap_rdn_lookup: found_bind_user=" . $found_bind_user); if (!empty($found_bind_user)) { return $found_bind_user; } elseif ($user_attr == $bind_attr) { return $user_name; } else { return false; } }
/** * Determine if a file is of a given type. * * The Fileinfo PHP extension is used to determine the file's MIME type. * * <code> * // Determine if a file is a JPG image * $jpg = File::is('jpg', 'path/to/file.jpg'); * * // Determine if a file is one of a given list of types * $image = File::is(array('jpg', 'png', 'gif'), 'path/to/file.jpg'); * </code> * * @param array|string $extensions * @param string $path * @return bool */ public static function is($extensions, $path) { $mimes = Config::get('mimes'); if (self::exists($path)) { if (function_exists('finfo_file')) { $mime = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $path); } elseif (function_exists('mime_content_type')) { $mime = mime_content_type($path); } else { Log::warn("Your PHP config is missing both `finfo_file()` and `mime_content_type()` functions. We recommend enabling one of them.", "system", "File"); $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); $mime = array_get($mimes, $ext); if (is_array($mime)) { $mime = $mime[0]; } } // The MIME configuration file contains an array of file extensions and // their associated MIME types. We will loop through each extension the // developer wants to check and look for the MIME type. foreach ((array) $extensions as $extension) { if (isset($mimes[$extension]) && in_array($mime, (array) $mimes[$extension])) { return true; } } } return false; }
| | Useful for running your own route. Remember to use $app->pass() if | you're not doing anything with the current request. | */ Hook::run('_routes', 'before'); $file_requested = implode($segments, '/'); $file = Theme::getPath() . $file_requested; $file = realpath($file); # Routes only if the file doesn't already exist (e.g. /assets/whatever.ext) if ( ! File::exists(array($file_requested, $file))) { Log::warn("The Static Asset Pipeline is deprecated. It may yet come back to fight another battle someday.", "core", "asset pipeline"); $mime = File::resolveMime($file); header("Content-type: {$mime}"); readfile($file); exit(); } else { // Moving on. Not a valid asset. $app->pass(); } });