public function geocodeMe() { $address = ""; if (!empty($this->Address)) { $address .= $this->Address; } else { Debug::show("sin dirección no se puede agregar en el mapa"); return false; } if (!empty($this->City)) { $address .= ', ' . $this->City; } if (!empty($this->State)) { $address .= ', ' . $this->State; } if (!empty($this->Zip)) { $address .= ', ' . $this->Zip; } $g = new GoogleGeocoder(); $point = $g->addressToPoint($address); if (!$point instanceof GeoPoint) { $point = YahooGeocoder::addressToPoint($address); } else { $this->Lat = $point->Lat; $this->Lng = $point->Lng; } if ($point instanceof GeoPoint) { return true; } }
function FixURLS() { $pages = DataObject::get("Page"); foreach ($pages as $page) { $page->write(); Debug::show($page); } }
/** * Contrutor da classe * @param string $url url acessada pelo usuário */ public function __construct($url) { define('CACHE_TIME', 60); $cache_config = Config::get('cache'); if ($cache_config['page']) { $cache = Cache::factory(); if ($cache->has(URL)) { $data = $cache->read(URL); exit($data); } } $registry = Registry::getInstance(); $this->args = $this->args($url); //I18n define('lang', $this->args['lang']); define('LANG', $this->args['lang']); $i18n = I18n::getInstance(); $i18n->setLang(LANG); $registry->set('I18n', $i18n); function __($string, $format = null) { return I18n::getInstance()->get($string, $format); } function _e($string, $format = null) { echo I18n::getInstance()->get($string, $format); } define('controller', Inflector::camelize($this->args['controller']) . 'Controller'); define('action', str_replace('-', '_', $this->args['action'])); define('CONTROLLER', Inflector::camelize($this->args['controller']) . 'Controller'); define('ACTION', str_replace('-', '_', $this->args['action'])); try { header('Content-type: text/html; charset=' . Config::get('charset')); Import::core('Controller', 'Template', 'Annotation'); Import::controller(CONTROLLER); $this->controller(); $this->auth(); $tpl = new Template(); $registry->set('Template', $tpl); $tpl->render($this->args); if ($cache_config['page']) { $cache = Cache::factory(); $data = ob_get_clean(); $cache->write(URL, $data, $cache_config['time']); } Debug::show(); } catch (PageNotFoundException $e) { header('HTTP/1.1 404 Not Found'); $this->loadError($e); exit; } catch (Exception $e) { header('HTTP/1.1 500 Internal Server Error'); $this->loadError($e); } }
public static function run() { self::loadEventClass(); event("APP_START"); DEBUG and Debug::start("APP_START"); self::init(); self::start(); DEBUG and Debug::show("APP_START", "APP_END"); Log::save(); event("APP_END"); }
public static function run() { session(C("SESSION_OPTIONS")); self::loadEventClass(); event("APP_START"); DEBUG and Debug::start("APP_START"); self::start(); DEBUG and Debug::show("APP_START", "APP_END"); Log::save(); event("APP_END"); }
public function startProcessing() { // Get all the traffic profiles $profiles = TrafficProfile::get(); if ($profiles->Count() == 0) { return null; } foreach ($profiles as $profile) { Debug::show($profile); } return true; }
protected final function renderAjax($errorCode, $errorMessage = '', $otherParams = array()) { $otherParams['errorCode'] = $errorCode; $otherParams['errorMessage'] = $errorMessage; Response::output($otherParams, 'json', Router::$CALLBACK); // debug Debug::p('PHP End'); if (isset($_COOKIE['ajaxdebug']) && Router::$IS_AJAX) { Debug::show(); } exit; }
public function all($settings = []) { $all = []; if (!isset($settings['page'])) { return $all; } try { $all = $this->listFromMethod($settings['page'], isset($settings['limit']) ? $settings['limit'] : 5); } catch (\Exception $e) { \Debug::show($e->getMessage()); } return $all; }
public function details($settings = []) { $body = []; try { $body = $this->getBodyFromCache($this->endpoint(), $settings); if (isset($body['result'])) { $body = $body['result']; } } catch (\Exception $e) { \Debug::show($e->getMessage()); } return $body; }
public function all($settings = []) { $all = []; try { $body = $this->getBodyFromCache($this->endpoint($settings['username']), $settings); foreach ($body['items'] as $post) { $all[] = $this->handlePost($post, $settings); } } catch (\Exception $e) { \Debug::show($e->getMessage()); } return $all; }
public function all($settings = []) { $all = []; $type = isset($settings['type']) ? $settings['type'] : $this->defaultType; try { $body = $this->getBodyFromCache($this->endpoint($type), $settings); foreach ($body as $post) { $all[] = $this->handlePost($post, $settings); } } catch (\Exception $e) { \Debug::show($e->getMessage()); } return $all; }
public function channelSearch($username, $settings = []) { $all = []; try { $settings['query']['forUsername'] = $username; if (!isset($settings['query']) || !isset($settings['query']['part'])) { $settings['query']['part'] = 'id'; } $body = $this->getBodyFromCache($this->endpoint('channels'), $settings); $all = $body['items']; } catch (\Exception $e) { \Debug::show($e->getMessage()); } return $all; }
function setUpOnce() { parent::setUpOnce(); self::$offset = time() - strtotime(DB::query('SELECT ' . DB::getConn()->now())->value()); foreach (self::$offset_thresholds as $code => $offset) { if (abs(self::$offset) > $offset) { if ($code == E_USER_NOTICE) { Debug::show('The time of the database is out of sync with the webserver by ' . abs(self::$offset) . ' seconds.'); } else { trigger_error('The time of the database is out of sync with the webserver by ' . abs(self::$offset) . ' seconds.', $code); } break; } } }
/** * 运行应用 * @access public * @reutrn mixed */ public static function run() { //session处理 session(C("SESSION_OPTIONS")); //加载应用与事件处理类 self::loadEventClass(); //执行应用开始事件 event("APP_START"); //Debug Start DEBUG and Debug::start("APP_START"); self::start(); //Debug End DEBUG and Debug::show("APP_START", "APP_END"); //日志记录 Log::save(); event("APP_END"); }
public function updateFrontendActions($actions) { Debug::show('here'); $svc = singleton('WorkflowService'); $active = $svc->getWorkflowFor($this->owner); if ($active) { if ($this->canEditWorkflow()) { $actions->push(new FormAction('updateworkflow', _t('WorkflowApplicable.UPDATE_WORKFLOW', 'Update Workflow'))); } } else { $effective = $svc->getDefinitionFor($this->owner); if ($effective) { // we can add an action for starting off the workflow at least $initial = $effective->getInitialAction(); $actions->push(new FormAction('startworkflow', $initial->Title)); } } }
/** * 运行应用 * @access public * @reutrn mixed */ public static function run() { event("APP_START"); //Debug Start DEBUG and Debug::start("APP_START"); self::init(); self::start(); //Debug End if (DEBUG) { if (!C("DEBUG_AJAX") && IS_AJAX || !C("DEBUG_SHOW")) { } else { Debug::show("APP_START", "APP_END"); } } //日志记录 Log::save(); event("APP_END"); }
/** * 运行应用 * @access public * @reutrn mixed */ public static function run() { //session处理 session(C("SESSION_OPTIONS")); //执行应用开始钓子 Hook::listen("APP_INIT"); //执行应用开始钓子 Hook::listen("APP_BEGIN"); //Debug Start DEBUG and Debug::start("APP_BEGIN"); self::start(); //Debug End DEBUG and Debug::show("APP_BEGIN", "APP_END"); //日志记录 !DEBUG and C('LOG_RECORD') and Log::save(); //应用结束钓子 Hook::listen("APP_END"); }
public function renderCustomElement(DOMNode $node, $parser, $context = NULL) { $mode = $node->getAttribute('data-test-mode'); if (!$mode) { $mode = 'attribute'; } switch ($mode) { case 'attribute': $markup = $node->getAttribute('data-attr'); Debug::show($markup); break; case 'nested': $markup = '<testelement>def</testelement>'; break; default: $markup = ''; break; } // recursively invoke the shortcode parser on the result, in case the element returns shortcodes // itself. return $parser->parse($markup); }
public function listProducts() { Debug::show($this); $idlist = $this->getProductIdsForPage(); $prods = Product::get()->byIDs($idlist)->sort('SortKey, Brand, Sold asc'); $oldpostBrand = ""; $oldpostSold = ""; $outdata = new ArrayList(); foreach ($prods as $prod) { if ($oldpostBrand != $prod->Brand || $oldpostSold != $prod->Sold) { // Rubrik ska skrivas ut s� den stoppas in i en egen ArrayData $headerRow = new ArrayData(array('isHeaderRow' => true, 'HeaderBrand' => $prod->Brand, 'HeaderSold' => $prod->Sold)); $outdata->push($headerRow); } #Vanlig row $thisrow = $prod; $outdata->push($thisrow); #spara undan för att jämföra $oldpostBrand = $prod->Brand; $oldpostSold = $prod->Sold; } return $outdata; }
/** * Produces a debug of the shopping cart. */ public function debug() { if (Director::isDev() || Permission::check("ADMIN")) { debug::show($this->currentOrder()); echo "<blockquote><blockquote><blockquote><blockquote>"; echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Items</h1>"; $items = $this->currentOrder()->Items(); if ($items) { foreach ($items as $item) { Debug::show($item); } } else { echo "<p>there are no items for this order</p>"; } echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Modifiers</h1>"; $modifiers = $this->currentOrder()->Modifiers(); if ($modifiers) { foreach ($modifiers as $modifier) { Debug::show($modifier); } } else { echo "<p>there are no modifiers for this order</p>"; } echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Addresses</h1>"; $billingAddress = $this->currentOrder()->BillingAddress(); if ($billingAddress && $billingAddress->exists()) { Debug::show($billingAddress); } else { echo "<p>there is no billing address for this order</p>"; } $shippingAddress = $this->currentOrder()->ShippingAddress(); if ($shippingAddress && $shippingAddress->exists()) { Debug::show($shippingAddress); } else { echo "<p>there is no shipping address for this order</p>"; } $currencyUsed = $this->currentOrder()->CurrencyUsed(); if ($currencyUsed && $currencyUsed->exists()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Currency</h1>"; Debug::show($currencyUsed); } $cancelledBy = $this->currentOrder()->CancelledBy(); if ($cancelledBy && $cancelledBy->exists()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Cancelled By</h1>"; Debug::show($cancelledBy); } $logs = $this->currentOrder()->OrderStatusLogs(); if ($logs && $logs->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Logs</h1>"; foreach ($logs as $log) { Debug::show($log); } } $payments = $this->currentOrder()->Payments(); if ($payments && $payments->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Payments</h1>"; foreach ($payments as $payment) { Debug::show($payment); } } $emails = $this->currentOrder()->Emails(); if ($emails && $emails->count()) { echo "<hr /><hr /><hr /><hr /><hr /><hr /><h1>Emails</h1>"; foreach ($emails as $email) { Debug::show($email); } } echo "</blockquote></blockquote></blockquote></blockquote>"; } }
public function check() { $OdeonCinemaID = (int) $this->request->param("ID"); if ($OdeonCinemaID) { if ($this->OdeonCinema = OdeonCinema::get_by_id("OdeonCinema", $OdeonCinemaID)) { $this->OdeonCinema->getCurrentFilms(); $OdeonFilmID = (int) $this->request->param("OtherID"); if ($OdeonFilmID) { if ($this->OdeonFilm = OdeonFilm::get_by_id("OdeonFilm", $OdeonFilmID)) { $maxdays = 15; $baseURL = "https://www.odeon.co.uk/"; $date = new Date(); $RestfulService = new RestfulService($baseURL); $i = 0; do { $date->setValue("+{$i} day"); if (!OdeonScreening::get("OdeonScreening", implode(" AND ", array("DATE_FORMAT(ScreeningTime,'%d%m%y') = '{$date->Format("dmy")}'", "FilmID='{$OdeonFilmID}'", "CinemaID='{$OdeonCinemaID}'")))->Count()) { $query = array('date' => $date->Format("Y-m-d"), 'siteId' => $OdeonCinemaID, 'filmMasterId' => $OdeonFilmID, 'type' => 'DAY'); $RestfulService->setQueryString($query); $Response = $RestfulService->request("showtimes/day"); if (!$Response->isError()) { $html = HtmlDomParser::str_get_html($Response->getBody()); foreach ($html->find('ul') as $ul) { foreach ($ul->find('li') as $li) { $ScreeningTime = new SS_Datetime(); $ScreeningTime->setValue("{$date->Format("Y-m-d")} {$li->find('a', 0)->innertext}:00"); $checkAgainstAPI = true; if ($OdeonScreening = OdeonScreening::get_one("OdeonScreening", implode(" AND ", array("CinemaID='{$OdeonCinemaID}'", "FilmID='{$OdeonFilmID}'", "ScreeningTime='{$ScreeningTime->Rfc2822()}'")))) { $checkAgainstAPI = $OdeonScreening->checkAgainstAPI(); } else { $OdeonScreening = new OdeonScreening(); $OdeonScreening->CinemaID = $OdeonCinemaID; $OdeonScreening->FilmID = $OdeonFilmID; $OdeonScreening->ScreeningTime = $ScreeningTime->Rfc2822(); } if ($checkAgainstAPI) { $URLSegment = str_replace($baseURL, "", $li->find('a', 0)->href); $Response_init = $RestfulService->request($URLSegment, "GET", null, null, array(CURLOPT_COOKIESESSION => TRUE)); if (!$Response_init->isError()) { $dom = new DOMDocument(); $dom->strictErrorChecking = FALSE; libxml_use_internal_errors(true); $dom->loadHTML($Response_init->getBody()); libxml_clear_errors(); $nodes = $dom->getElementsByTagName('form'); $submit_url = false; $hidden_inputs = array(); foreach ($nodes as $node) { if (!$submit_url && $node->hasAttributes()) { foreach ($node->attributes as $attribute) { if (!$submit_url && $attribute->nodeName == 'action') { $submit_url = $attribute->nodeValue; } } } } unset($node); $SubmitURL = ltrim($submit_url, '/'); $Cookies = $Response_init->getHeader("Set-Cookie"); if (is_array($Cookies)) { $Cookies = implode(';', $Cookies); } $Response_availability = $RestfulService->request($SubmitURL, "GET", null, null, array(CURLOPT_COOKIE => $Cookies)); if (!$Response_availability->isError()) { $html_availability = HtmlDomParser::str_get_html($Response_availability->getBody()); $ticketsTable = $html_availability->find('#tickets-table', 0); if ($ticketsTable) { $ticketsForm = $html_availability->find('#tickets', 0); $data = array("submit" => null); foreach ($ticketsTable->find('select') as $select) { $data[$select->attr["name"]] = "0"; } foreach ($ticketsTable->find('tr') as $tr) { foreach ($tr->find('td') as $td) { switch ($td->getAttribute("class")) { case "ticket-col": $OdeonScreening->Title = trim($td->innertext); break; case "price-col": $OdeonScreening->Cost = ltrim(explode(" ", trim($td->plaintext))[0], '£'); break; case "quantity-col": $Availability = 1; foreach ($td->find('select') as $select) { foreach ($select->find('option') as $option) { $Availability = $option->attr["value"]; } $data[$select->attr["name"]] = $Availability; } $Response_seats = $RestfulService->request(ltrim(html_entity_decode($ticketsForm->attr['action']), "/"), "POST", $data, null, array(CURLOPT_COOKIE => $Cookies)); if (!$Response_seats->isError()) { $html_seats = HtmlDomParser::str_get_html($Response_seats->getBody()); if (trim($html_seats->find('.step-headline', 0)->innertext) == "Choose your seats") { $OdeonScreening->Availability = $Availability; $OdeonScreening->SessionURL = $URLSegment; $OdeonScreening->duplicate(); } } break; } } } } } } } } } } else { Debug::show($query); Debug::show($Response); } } $i++; } while ($i < $maxdays); } else { echo "Not a valid film ID"; } } } else { echo "Not a valid cinema ID"; } } return $this; }
require_once "core/ClassInfo.php"; require_once 'core/Object.php'; require_once 'core/control/Director.php'; require_once 'filesystem/Filesystem.php'; require_once "core/Session.php"; /////////////////////////////////////////////////////////////////////////////// // MANIFEST /** * Include the manifest */ ManifestBuilder::include_manifest(); /** * ?debugmanifest=1 hook */ if (isset($_GET['debugmanifest'])) { Debug::show(file_get_contents(MANIFEST_FILE)); } // If this is a dev site, enable php error reporting // This is necessary to force developers to acknowledge and fix // notice level errors (you can override this directive in your _config.php) if (Director::isLive()) { if (defined('E_DEPRECATED')) { error_reporting(E_ALL ^ E_NOTICE ^ E_DEPRECATED); } else { error_reporting(E_ALL ^ E_NOTICE); } } /////////////////////////////////////////////////////////////////////////////// // POST-MANIFEST COMMANDS /** * Load error handlers
/** * Handle an HTTP request, defined with a SS_HTTPRequest object. * * @param SS_HTTPRequest $request * @param Session $session * @param DataModel $model * * @return SS_HTTPResponse|string */ protected static function handleRequest(SS_HTTPRequest $request, Session $session, DataModel $model) { $rules = Config::inst()->get('Director', 'rules'); if (isset($_REQUEST['debug'])) { Debug::show($rules); } foreach ($rules as $pattern => $controllerOptions) { if (is_string($controllerOptions)) { if (substr($controllerOptions, 0, 2) == '->') { $controllerOptions = array('Redirect' => substr($controllerOptions, 2)); } else { $controllerOptions = array('Controller' => $controllerOptions); } } if (($arguments = $request->match($pattern, true)) !== false) { $request->setRouteParams($controllerOptions); // controllerOptions provide some default arguments $arguments = array_merge($controllerOptions, $arguments); // Find the controller name if (isset($arguments['Controller'])) { $controller = $arguments['Controller']; } // Pop additional tokens from the tokenizer if necessary if (isset($controllerOptions['_PopTokeniser'])) { $request->shift($controllerOptions['_PopTokeniser']); } // Handle redirection if (isset($arguments['Redirect'])) { return "redirect:" . Director::absoluteURL($arguments['Redirect'], true); } else { Director::$urlParams = $arguments; $controllerObj = Injector::inst()->create($controller); $controllerObj->setSession($session); try { $result = $controllerObj->handleRequest($request, $model); } catch (SS_HTTPResponse_Exception $responseException) { $result = $responseException->getResponse(); } if (!is_object($result) || $result instanceof SS_HTTPResponse) { return $result; } user_error("Bad result from url " . $request->getURL() . " handled by " . get_class($controllerObj) . " controller: " . get_class($result), E_USER_WARNING); } } } // No URL rules matched, so return a 404 error. return new SS_HTTPResponse('No URL rule was matched', 404); }
/** * Output debugging information. */ public function debug() { Debug::show($this->javascript); Debug::show($this->css); Debug::show($this->customCSS); Debug::show($this->customScript); Debug::show($this->customHeadTags); Debug::show($this->combinedFiles); }
static function showError($errno, $errstr, $errfile, $errline, $errcontext) { if (!headers_sent()) { header("HTTP/1.0 500 Internal server error"); } if (Director::is_ajax()) { echo "ERROR:Error {$errno}: {$errstr}\n At l{$errline} in {$errfile}\n"; Debug::backtrace(); } else { echo "<div style=\"border: 5px red solid\">\n"; echo "<p style=\"color: white; background-color: red; margin: 0\">FATAL ERROR: {$errstr}<br />\n At line {$errline} in {$errfile}<br />\n<br />\n</p>\n"; Debug::backtrace(); //Debug::show(debug_backtrace()); echo "<h2>Context</h2>\n"; Debug::show($errcontext); echo "</div>\n"; } }
/** * @deprecated 2.4 Use Validator->getErrors() and custom code */ function showError() { Debug::show($this->errors); }
/** * Sets i18n locale and adds Content-language to meta tags. * @param string $locale */ public static function setup_locale($locale = "") { if ($locale != "") { Requirements::insertHeadTags('<meta http-equiv="Content-language" content="' . i18n::get_lang_from_locale($locale) . '" />'); i18n::set_locale($locale); } else { Debug::show("Your locale is not properly set. Remember that for using this function you need to use Object::add_extension('SiteTree', 'Translatable'); in your project _config.php"); } }
public function submit($data, $form, $request) { Debug::show("saveproduct"); return print_r($data); }
/** * @return DataObject */ static function get_all_versions($class, $id, $version) { $baseTable = ClassInfo::baseDataClass($class); $query = singleton($class)->buildVersionSQL("\"{$baseTable}\".\"RecordID\" = {$id} AND \"{$baseTable}\".\"Version\" = {$version}"); $record = $query->execute()->record(); $className = $record['ClassName']; if (!$className) { Debug::show($query->sql()); Debug::show($record); user_error("Versioned::get_version: Couldn't get {$class}.{$id}, version {$version}", E_USER_ERROR); } return new $className($record); }
static function debug() { Debug::show(Requirements::$javascript); Debug::show(Requirements::$css); Debug::show(Requirements::$customCSS); Debug::show(Requirements::$customScript); Debug::show(Requirements::$customHeadTags); }