/** * Constructor * @param array $configuration An array of the configuration options * nessisary to load this manager. To use the a specific manager store, a * store data source must be configured as noted in the class of said * manager store. * manager. * @access public */ function HarmoniRepositoryManager($configuration = NULL) { // Define the type to use as a key for Identifying repositories $this->repositoryKeyType = new HarmoniType("Repository", "edu.middlebury.harmoni", "Repository", "Nodes with this type are by definition Repositories."); // Cache any created repositories so that we can pass out references to them. $this->_createdRepositories = array(); $schemaMgr = Services::getService("SchemaManager"); $ids = Services::getService("Id"); $recordStructureId = $ids->getId("edu.middlebury.harmoni.repository.asset_content"); $recordDesc = "A RecordStructure for the generic content of an asset."; if (!$schemaMgr->schemaExists($recordStructureId->getIdString())) { // Create the Schema $schema = new Schema($recordStructureId->getIdString(), "Repository Asset Content", 1, $recordDesc); $schema->addField(new SchemaField("Content", "Content", "blob", "The binary content of the Asset")); $schemaMgr->synchronize($schema); // The SchemaManager only allows you to use Schemas created by it for use with Records. $schema = $schemaMgr->getSchemaByID($recordStructureId->getIdString()); debug::output("RecordStructure is being created from Schema with Id: '" . $schema->getID() . "'"); $nullRepositoryId = $ids->getId('null'); $this->_createdRecordStructures[$schema->getID()] = new HarmoniRecordStructure($this, $schema, $nullRepositoryId); // Add the parts to the schema // $partStructureType = new Type("Repository", "edu.middlebury.harmoni", "Blob", ""); // $this->_createdRecordStructures[$schema->getID()]->createPartStructure( // "Content", // "The binary content of the Asset", // $partStructureType, // FALSE, // FALSE, // FALSE, // $ids->getId("edu.middlebury.harmoni.repository.asset_content.Content") // ); } }
function debug_action($action, $parm1 = '', $parm2 = '', $parm3 = '') { static $debug; if ($action == 'init') { $debug = new debug($parm1); } elseif ($action == 'time') { $debug->settime($parm1); } elseif ($action == 'message') { $debug->setmessage($parm1, $parm2, $parm3); } elseif ($action == 'report') { $debug->report(); } }
/** * 引用模板 * @param $template 模板 * @param $cacheTime 是否使用静态缓存,等于0时不使用,大于0时为缓存时间 * @param $cacheKey 静态缓存KEY */ public function display($template, $cacheTime = false, $cacheKey = false) { $path['template_c'] = $this->get_path($template, 'view_c'); $path['template'] = $this->get_path($template); //当缓存时间未设置时,将自动获取配置中的缓存时间 $cache = $cacheTime ? intval($cacheTime) : Config::template('view_cache_time'); $kVar = empty($cacheKey) ? null : $cacheKey; if (file_exists($path['template'])) { //如果已编译模板的不存在或者模板修改时间大于已编译模板的时间将重新编译 if (!file_exists($path['template_c']) || filemtime($path['template']) > filemtime($path['template_c'])) { $this->write($path['template_c'], $this->template_parse(file_get_contents($path['template']))); } if ($cache > 0 && Config::template('view_cache')) { if (!Cache::is_cache($this->get_temp_name($template, $cacheKey), Config::template('view_cache_dir'))) { self::cache_compile($path['template_c'], $cacheKey); debug::add('写入缓存\'<strong>' . $template . $kVar . '</strong>\'缓存时间:' . $cache . '秒。'); } elseif (Cache::time($this->get_temp_name($template, $cacheKey), Config::config('view_cache_dir')) + $cache > time() && filemtime($path['template']) < Cache::time($this->get_temp_name($template, $cacheKey), Config::config('view_cache_dir'))) { echo Cache::get($this->get_temp_name($template, $cacheKey), Config::config('view_cache_dir')); debug::add('读取缓存\'<strong>' . $template . '[' . $kVar . ']' . '</strong>缓存时间:' . $cache . '秒。'); } else { self::cache_compile($path['template_c'], $cacheKey); debug::add('更新缓存\'<strong>' . $template . '[' . $kVar . ']' . '</strong>缓存时间:' . $cache . '秒。'); } } else { foreach ($this->var as $k => $v) { ${$k} = $v; } include $path['template_c']; //echo htmlspecialchars($this->template_parse(file_get_contents($path['template']))); debug::add('使用模板\'<strong>' . $template . '</strong>\'未使用缓存。'); } } else { debug::add('模板<strong>' . $path['template'] . '</strong>不存在。'); } }
function write($log_file_data, $string) { $log_dir = $log_file_data[0]; $log_name = $log_file_data[1]; $file_name = $log_dir . $log_name; if (!is_dir($log_dir)) { fs::mkdir($log_dir, 0775, true); } $oldumask = @umask(0); $file_existed = @file_exists($file_name); $log_file = @fopen($file_name, 'a'); if ($log_file) { $time = strftime("%b %d %Y %H:%M:%S", strtotime('now')); $notice = '[ ' . $time . " ]\n"; $user =& user::instance(); if (($user_id = $user->get_id()) != DEFAULT_USER_ID) { $notice .= '[ ' . $user_id . ' ] [ ' . $user->get_login() . ' ] [ ' . $user->get_email() . ' ] '; } $notice .= '[' . sys::client_ip() . '] [' . (isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '') . "]\n" . $string . "\n\n"; @fwrite($log_file, $notice); @fclose($log_file); if (!$file_existed) { @chmod($file_name, 0664); } @umask($oldumask); $result = true; } else { @umask($oldumask); $result = false; debug::write_error("Cannot open log file '{$file_name}' for writing\n" . "The web server must be allowed to modify the file.\n" . "File logging for '{$file_name}' is disabled.", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, false); } return $result; }
public static function init() { /* * Zuordnung der Prozessart * -> Unterscheidung zwischen CLI- * und Browser-Aufruf */ self::$proc = "browser"; if (defined('STDIN')) { self::$proc = "cli"; } self::$config_file = ROOT_DIR . "etc/config.php"; if (!file_exists(self::$config_file)) { throw new Exception("Konfigurations-Datei " . self::$config_file . " nicht gefunden!"); } else { require_once self::$config_file; } /* * Zuordnung der Konfigurations-Werte */ self::$debug = $debug; self::$debug_file = $debug_file; self::$web_root = $web_root; self::$db_host = $db_host; self::$db_name = $db_name; self::$db_user = $db_user; self::$db_pass = $db_pass; debug::init(); // debug::add_info("(" . __FILE__ . ")<b>" . __CLASS__ . "</b>::" . __FUNCTION__ . "(): Konfigurations-Datei eingelesen."); }
function generate_contents(&$code) { parent::generate_contents($code); if (isset($this->attributes['navigator'])) { if ($navigator =& $this->parent->find_child($this->attributes['navigator'])) { $limit = $code->get_temp_variable(); $code->write_php('$' . $limit . '= ' . $navigator->get_component_ref_code() . '->get_items_per_page();'); $code->write_php($this->get_component_ref_code() . '->set_parameter("limit", $' . $limit . ');'); $code->write_php('if(isset($_GET["page_' . $navigator->get_server_id() . '"])){'); $code->write_php($this->get_component_ref_code() . '->set_parameter("offset", ($_GET["page_' . $navigator->get_server_id() . '"]-1)*$' . $limit . ');'); $code->write_php('}'); } } $targets = explode(',', $this->attributes['target']); foreach ($targets as $target) { if ($target_component =& $this->parent->find_child(trim($target))) { $code->write_php($target_component->get_component_ref_code() . '->register_dataset(' . $this->get_component_ref_code() . '->get_dataset());'); } else { debug::write_error('component target not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('target' => $target)); } } if (isset($this->attributes['navigator']) && $navigator) { $code->write_php($navigator->get_component_ref_code() . '->set_total_items(' . $this->get_component_ref_code() . '->get_total_count());'); } }
function _valid_perform(&$request, &$response) { $data = $this->dataspace->export(); $request->set_status(REQUEST_STATUS_FAILURE); if($request->has_attribute('popup')) $response->write(close_popup_response($request)); if(!isset($data['ids']) || !is_array($data['ids'])) return; $objects = $this->_get_objects_to_delete(array_keys($data['ids'])); foreach($objects as $id => $item) { if($item['delete_status'] !== 0 ) continue; $site_object =& wrap_with_site_object($item); if(!$site_object->delete()) { debug :: write_error("object couldn't be deleted", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $id)); return; } } $request->set_status(REQUEST_STATUS_SUCCESS); $response->write(close_popup_response($request)); }
function run(&$filter_chain, &$request, &$response) { debug::add_timing_point('authentication filter started'); if (!($object_data = fetch_requested_object($request))) { if (!($node = map_request_to_node($request))) { if (defined('ERROR_DOCUMENT_404')) { $response->redirect(ERROR_DOCUMENT_404); } else { $response->header("HTTP/1.1 404 Not found"); } return; } $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); return; } $object =& wrap_with_site_object($object_data); $site_object_controller =& $object->get_controller(); if (($action = $site_object_controller->determine_action($request)) === false) { debug::write_error('"' . $action . '" action not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); if (defined('ERROR_DOCUMENT_404')) { $response->redirect(ERROR_DOCUMENT_404); } else { $response->header("HTTP/1.1 404 Not found"); } debug::add_timing_point('authentication filter finished'); $filter_chain->next(); return; } $actions = $object->get_attribute('actions'); if (!isset($actions[$action])) { $response->redirect('/root/login?redirect=' . urlencode($_SERVER['REQUEST_URI'])); } debug::add_timing_point('authentication filter finished'); $filter_chain->next(); }
function _update_media_record($id, $tmp_file_path, $file_name, $mime_type) { if (!file_exists($tmp_file_path)) { debug::write_error('file doesnt exist', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('tmp' => $tmp_file_path)); return false; } if (function_exists('md5_file')) { $etag = md5_file($tmp_file_path); } else { $fd = fopen($data['tmp_name'], 'rb'); $contents = fread($fd, filesize($tmp_file_path)); fclose($fd); $etag = md5($contents); } if (!is_dir(MEDIA_DIR)) { dir::mkdir(MEDIA_DIR, 777, true); } if (!copy($tmp_file_path, MEDIA_DIR . $id . '.media')) { debug::write_error('temporary file copy failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('src' => $tmp_file_path, 'dst' => MEDIA_DIR . $id . '.media')); return false; } $media_db_table = db_table_factory::instance('media'); $media_db_table->update_by_id($id, array('file_name' => $file_name, 'mime_type' => $mime_type, 'size' => filesize($tmp_file_path), 'etag' => $etag)); return true; }
function error($description, $error_place='', $params=array()) { if(isset($GLOBALS['error_recursion']) && $GLOBALS['error_recursion']) die(); $GLOBALS['error_recursion'] = true; if(defined('DEVELOPER_ENVIROMENT')) { trigger_error('error', E_USER_WARNING); echo( $description . '<br>' . $error_place . '<br><pre>'); print_r($params); echo('</pre>'); } $description = $description . "\n\nback trace:\n" . get_trace_back(); rollback_user_transaction(); debug :: set_message_output(DEBUG_OUTPUT_MESSAGE_STORE | DEBUG_OUTPUT_MESSAGE_SEND); debug :: write_error($description, $error_place, $params); if (debug :: is_console_enabled()) { debug :: write_error($description, $error_place, $params); echo debug :: parse_console(); } ob_end_flush(); exit; }
function _displayBrowse($path, &$root_group, &$current_group) { if ($root_group != $current_group) { echo '<p><a href="' . $this->getBaseURL() . '?browse=' . $path . '/..">Back</a></p>'; } if (is_a($current_group, 'LimbGroupTest')) { $group_tests = $current_group->getTestCasesHandles(); } else { $group_tests = array(); } $buffer = "<br><a href='" . $this->getBaseURL() . "?perform={$path}&back=1'>Run all tests from this group</a>\n"; $buffer .= "<p>Available test groups in '" . $current_group->getLabel() . "':</p>\n"; if (sizeof($group_tests)) { $buffer .= "<ul>"; foreach ($group_tests as $index => $group_test) { resolve_handle($group_test); if (!is_a($group_test, 'LimbGroupTest')) { $buffer .= "<li><a href='" . $this->getBaseURL() . "?perform={$path}/{$index}'>P</a> " . $group_test->getLabel() . "</li>\n"; } else { $buffer .= "<li><a href='" . $this->getBaseURL() . "?perform={$path}/{$index}'>P</a> <a href='" . $this->getBaseURL() . "?browse={$path}/{$index}'>B</a> " . $group_test->getLabel() . "</li>\n"; } } $buffer .= "</ul>\n"; } else { $buffer .= "<p>No groups available.</p> \n"; } echo $buffer; echo debug::parse_html_console(); }
public function save() { $db = database::get_instance(); if (count($this->changed_entries) > 0) { $tmp = array(); $bool = false; foreach ($this->changed_entries as $name) { if ($name == "table") { continue; } if ($name == "{$this->table}_id") { $bool = true; } $value = $this->entries[$name] === 'NULL' || $this->entries[$name] === null ? "NULL" : "'" . $db->escape($this->entries[$name]) . "'"; $tmp[] = "`{$name}` = {$value}"; } if ($bool == false && isset($this->entries["{$this->table}_id"])) { $tmp[] = "`{$this->table}_id` = '" . $db->escape($this->entries["{$this->table}_id"]) . "'"; } $sql = "INSERT INTO `{$this->table}` SET " . implode(",", $tmp) . " ON DUPLICATE\n\t\t\t\t\t\t\tKEY UPDATE " . implode(",", $tmp) . ";"; debug::add_info("(" . __FILE__ . ")<b>" . __CLASS__ . "</b>::" . __FUNCTION__ . "(): \$sql:<br /><pre>{$sql}</pre>"); $result = $db->query($sql); if (!isset($this->entries["{$this->table}_id"])) { $this->entries["{$this->table}_id"] = $db->insert_id(); } $this->reset(); } return; }
function clearfieldcache($showoutput = false) { $fieldsToClear = array(); $fieldsForEach = Config::inst()->get("MenuCache", "fields"); foreach ($fieldsForEach as $key => $field) { $fieldName = self::field_maker($key); $fieldsToClear[] = "\"" . $fieldName . "\" = ''"; } if (count($fieldsToClear)) { $tablesForEach = Config::inst()->get("MenuCache", "tables_to_clear"); foreach ($tablesForEach as $table) { $msg = ''; $sql = "UPDATE \"" . $table . "\" SET " . implode(", ", $fieldsToClear); if (Controller::curr()->getRequest()->param("ID") == "days" && ($days = intval(Controller::curr()->getRequest()->param("OtherID")))) { $sql .= ' WHERE \\"LastEdited\\" > ( NOW() - INTERVAL ' . $days . ' DAY )'; $msg .= ', created before the last ' . $days . ' days'; } elseif (Controller::curr()->getRequest()->param("ID") == "thispage") { $sql .= " WHERE \"" . $table . "\".\"ID\" = " . $this->owner->ID; $msg .= ', for page with ID = ' . $this->owner->ID; } if ($showoutput) { DB::alteration_message("Deleting cached data from {$table}, " . $msg); debug::show($sql); } DB::query($sql); } } return array(); }
/** * Nutzer einloggen und Session erzeugen * * @return Array Nutzer oder Fehler */ public function post() { $data = $this->getData(); if (!is_array($data)) { return $this->error(500); } $loginData = array('username' => $data['username'], 'uident_text' => $data['password'], 'status' => 'login'); // PID-Check (bbt-user sollen getrennt sein) $GLOBALS['user']->checkPid = true; $GLOBALS['user']->checkPid_value = $this->getConfigOption('userPID'); debug::log('user checkpid: ' . $GLOBALS['user']->checkPid); $info = $GLOBALS['user']->getAuthInfoArray(); debug::log($info); $user = $GLOBALS['user']->fetchUserRecord($info['db_user'], $loginData['username']); if (isset($user) && $user != '') { // User gefunden, jetzt noch Zugangspasswort prüfen $authBase = new tx_saltedpasswords_sv1(); $ok = $authBase->compareUident($user, $loginData); if ($ok) { $GLOBALS['user']->createUserSession($user); $data = array('Name' => $user['name'], 'Logo' => $user['tx_webetatext_logo'], 'Verified' => $user['tx_webetatext_verified']); $this->userLogo($data['Logo']); return $this->success($data); } return $this->error(401, 'Authentication failed'); } return $this->error(401, 'User not found'); }
public function resolveApplications() { $configs = $this->app['liby.app']; foreach ((array) $configs as $name => $callable) { if (!class_exists($callable)) { throw new \InvalidArgumentException(sprintf('Given class "%s"do not exist!', $callable)); } $this->configure[$name] = new $callable(); if ($this->configure[$name] instanceof Configure) { $configure = $this->configure; $this->parseAppConfigs($this->configure[$name]); $appConnect = $this; $this->acme[$name] = function ($name) use($configure, $appConnect) { $configure[$name]->connect($appConnect->app); // [Required] // Set route into application $configure[$name]->getService(); $configure[$name]->getRoute(); }; } else { throw new \InvalidArgumentException(sprintf('Given "%s" must by instances of "Liby\\Service\\Interfaces\\Configure"!', $callable)); } } \debug::info('Liby execute configs: ', $this->configure); }
function error($description, $error_place = '', $params = array()) { if (defined('DEVELOPER_ENVIROMENT')) { trigger_error('error', E_USER_WARNING); echo $description . '<br>' . $error_place . '<br><pre>'; print_r($params); echo '</pre>'; } debug::write_error($description, $error_place, $params); rollback_user_transaction(); if (debug::is_console_enabled()) { echo debug::parse_html_console(); } else { $message = ''; if ($user_id = user::get_id()) { $message .= "user id:\t{$user_id}\nlogin:\t\t" . user::get_login() . "\ne-mail:\t\t" . user::get_email() . "\n"; } $message .= "ip:\t\t" . sys::client_ip() . "\nrequest:\t" . REQUEST_URI . "\nerror:\t\t{$title}\ndescription:\t{$msg}"; $mail = new mime_mail(); $mail->set_body($message); $mail->build_message(); $mail->send('developer', DEVELOPER_EMAIL, '', WEBSITE_EMAIL, $_SERVER['HTTP_HOST'] . ' internal error!'); } ob_end_flush(); exit; }
function run(&$filter_chain, &$request, &$response) { if(!$response->is_empty() || !$this->_is_caching_enabled()) { $filter_chain->next(); return; } debug :: add_timing_point('full page cache started'); $cache = new full_page_cache_manager(); $cache->set_uri($request->get_uri()); if($contents =& $cache->get()) { debug :: add_timing_point('full page cache read finished'); $response->write($contents); return; } $filter_chain->next(); $cache->write($content =& $response->get_response_string()); debug :: add_timing_point('full page cache write finished'); }
function javaScriptConstraint($elementName = '', $functionMode = '', $value = '') { $this->elementName = $elementName; debug::message('MODE:' . $functionMode); switch ($functionMode) { case 'presence': $this->constraint = "!=''"; break; case 'match': $matchValue = $value[3]->toString(); $this->constraint = "== '{$matchValue}'"; break; case 'function': $functionPredicateValues = $value[3]->getPredicateValues(); $predicateName = $value[3]->getPredicateName(); debug::message('Function: ' . $predicateName); switch ($predicateName) { case 'lessThan': $this->constraint = '<' . $functionPredicateValues[0]->toString(); break; case 'greaterThanOrEqual': $this->constraint = '>=' . $functionPredicateValues[0]->toString(); break; } } }
function perform(&$request, &$response) { if (($t = $request->get_attribute('t')) && is_array($t) && sizeof($t) > 0) { $this->history = $t; $template_path = end($this->history); } else { $template_path = TEMPLATE_FOR_HACKERS; } if (substr($template_path, -5, 5) != '.html') { $template_path = TEMPLATE_FOR_HACKERS; } if (substr($template_path, -5, 5) != '.html') { $request->set_status(REQUEST_STATUS_FAILURE); } if (!($source_file_path = resolve_template_source_file_name($template_path))) { debug::write_error('template not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('template_path' => $this->template_path)); $source_file_path = resolve_template_source_file_name(TEMPLATE_FOR_HACKERS); } $template_contents = file_get_contents($source_file_path); if (sizeof($this->history) > 1) { $tmp_history = $this->history; $from_template_path = $tmp_history[sizeof($tmp_history) - 2]; $tmp_history = array_splice($tmp_history, 0, sizeof($tmp_history) - 1); $history_query = 't[]=' . implode('&t[]=', $tmp_history); $this->view->set('history_query', $history_query); $this->view->set('from_template_path', $from_template_path); } $this->view->set('template_path', $template_path); $this->view->set('template_content', $this->_process_template_content($template_contents)); }
function perform() { if (isset($_REQUEST['t']) && is_array($_REQUEST['t']) && sizeof($_REQUEST['t']) > 0) { $this->history = $_REQUEST['t']; $template_path = end($this->history); } else { $template_path = TEMPLATE_FOR_HACKERS; } if (substr($template_path, -5, 5) != '.html') { $template_path = TEMPLATE_FOR_HACKERS; } if (substr($template_path, -5, 5) != '.html') { return new failed_response(); } if (!($source_file_path = resolve_template_source_file_name($template_path))) { debug::write_error('template not found', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('template_path' => $this->template_path)); $source_file_path = resolve_template_source_file_name(TEMPLATE_FOR_HACKERS); } $template_contents = file_get_contents($source_file_path); if (sizeof($this->history) > 1) { $tmp_history = $this->history; $from_template_path = $tmp_history[sizeof($tmp_history) - 2]; $tmp_history = array_splice($tmp_history, 0, sizeof($tmp_history) - 1); $history_query = 't[]=' . implode('&t[]=', $tmp_history); $this->view->set('history_query', $history_query); $this->view->set('from_template_path', $from_template_path); } $this->view->set('template_path', $template_path); $this->view->set('template_content', $this->_process_template_content($template_contents)); return new response(); }
function perform() { if ($this->is_first_time()) { $this->_init_dataspace(); return $this->_first_time_perform(); } else { $this->_transfer_dataspace(); $this->_process_transfered_dataspace(); if(!$this->validate()) { $result =& new not_valid_response(); debug :: write_error('validation failed', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__); } else $result = $this->_valid_perform(); if($this->view && $form =& $this->view->find_child($this->name)) $form->set_valid_status($result->is_success()); return $result; } }
function _set_order_parameters($order_string) { $order_items = explode(',', $order_string); $order_pairs = array(); foreach($order_items as $order_pair) { $arr = explode('=', $order_pair); if(isset($arr[1])) { if(strtolower($arr[1]) == 'asc' || strtolower($arr[1]) == 'desc' || strtolower($arr[1]) == 'rand()') $order_pairs[$arr[0]] = strtoupper($arr[1]); else debug :: write_error('wrong order type', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('order' => $arr[1])); } else $order_pairs[$arr[0]] = 'ASC'; } if(sizeof($order_pairs)) $this->parameters['order'] = $order_pairs; }
function run(&$filter_chain, &$request, &$response) { if(!$response->is_empty() || !$this->_is_caching_enabled()) { $filter_chain->next(); return; } $cache = new image_cache_manager(); $cache->set_uri($request->get_uri()); ob_start(); $filter_chain->next(); if(!$response->is_empty()) return; debug :: add_timing_point('image cache started'); if($content = ob_get_contents()) { ob_end_clean(); $cache->process_content($content); $response->write($content); } debug :: add_timing_point('image cache write finished'); }
public function Send() { // $log = new EmailLogModel(); // Подготовляем для логирования $log->to = implode(',', $this->originalTo); $log->subject = $this->Subject; $log->content = $this->originalHtml; $log->date = date('Y-m-d H:i'); // debug::disable(); // $result = parent::Send(); // debug::enable(); // if (!$result) { $log->status = $this->ErrorInfo; $log->insert(); throw new MailException("Mailer Error: " . $this->ErrorInfo); } else { $log->insert(); } return $result; }
function output() { //set all template variables foreach ($this->vars as $var => $val) { ${$var} = $val; } if ($this->parent_view) { foreach ($this->parent_view->vars as $var => $val) { ${$var} = $val; } } // TODO: Check extract() for an alternative method $path = Kennel::cascade("{$this->view}", 'views'); if (!$path) { return debug::error("View <strong>{$this->view}</strong> not found."); } //begin intercepting the output buffer ob_start(); if ($path) { require $path; } //return the output and close the buffer return ob_get_clean(); //unset all template variables foreach ($this->vars as $var => $val) { unset(${$var}); } }
public function __destruct() { $this->values['end'] = date('H:i:s'); $logdb = new log_database(); try { $logdb->logSMSStatus($this->values); //throw new dbException('PACKET OVERFLOW',1153); } catch (dbException $e) { if ($e->getCode() == 1153) { //max_allowed_packet $logf = new log_file('/packet_overflow/'); if ($logf->packet_overflow($this->values)) { $this->values['log_message'] = "LOG TEXT OVER MySQL max_packet_size, WRITTEN TO " . $logf->path; $logdb->logSMSStatus($this->values); } else { $this->values['log_message'] = "TRIED TO CREATE LOG FILE AND FAILED " . $logf->path; } $this->status(CRITICAL); $logdb->logSMSStatus($this->values); } else { debug::output($e->getMessage()); $this->status(WARNING); } } }
function perform() { $tree =& limb_tree::instance(); if (isset($_REQUEST['id'])) { $node_id = (int) $_REQUEST['id']; } else { $node_id = get_mapped_id(); } if (!isset($_REQUEST['direction'])) { return false; } if (!($object_data = fetch_one_by_node_id($node_id))) { debug::write_error('Node is not accessible', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $node_id)); return false; } $direction = $_REQUEST['direction']; if (!($direction == 'up' || $direction == 'down')) { debug::write_error('Direction is not correct', __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('direction' => $direction)); return false; } if ($tree->change_node_order($node_id, $direction)) { reload(PHP_SELF . '#' . $node_id); } return false; }
function error($description, $error_place='', $params=array()) { trigger_error('error', E_USER_WARNING); if(isset($GLOBALS['error_recursion']) && $GLOBALS['error_recursion']) die($description . ' - (error recursion!!!)'); $description = $description . "\n\nback trace:\n" . get_trace_back(); $GLOBALS['error_recursion'] = true; rollback_user_transaction(); debug :: set_message_output(DEBUG_OUTPUT_MESSAGE_STORE | DEBUG_OUTPUT_MESSAGE_SEND); debug :: write_error($description, $error_place, $params); if (debug :: is_console_enabled()) { debug :: write_error($description, $error_place, $params); echo debug :: parse_console(); } ob_end_flush(); exit(); }
function run(&$filter_chain, &$request, &$response) { debug :: add_timing_point('locale filter started'); if(!$node = map_request_to_node($request)) { define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID); define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID); $locale =& locale :: instance(); $locale->setlocale(); $filter_chain->next(); return; } if($object_locale_id = site_object :: get_locale_by_id($node['object_id'])) define('CONTENT_LOCALE_ID', $object_locale_id); else define('CONTENT_LOCALE_ID', DEFAULT_CONTENT_LOCALE_ID); $user = user :: instance(); if($user_locale_id = $user->get_locale_id()) define('MANAGEMENT_LOCALE_ID', $user_locale_id); else define('MANAGEMENT_LOCALE_ID', CONTENT_LOCALE_ID); debug :: add_timing_point('locale filter finished'); $locale =& locale :: instance(); $locale->setlocale(); $filter_chain->next(); }
function _valid_perform() { $data = $this->dataspace->export(); if(!isset($data['ids']) || !is_array($data['ids'])) return new close_popup_response(RESPONSE_STATUS_FAILURE); $objects = $this->_get_objects_to_delete(array_keys($data['ids'])); foreach($objects as $id => $item) { if($item['delete_status'] !== 0 ) continue; $site_object =& wrap_with_site_object($item); if(!$site_object->delete()) { debug :: write_error("object couldn't be deleted", __FILE__ . ' : ' . __LINE__ . ' : ' . __FUNCTION__, array('node_id' => $id)); return new close_popup_response(RESPONSE_STATUS_FAILURE); } } return new close_popup_response(); }