public static function get_page_specific_data($title, $link, $description = '') { $originalArray = self::$page_specific_data ? self::$page_specific_data : self::get_all_options($title, $link, $description); $finalArray = array(); $inc = Config::inst()->get("ShareThisSTE", "included_icons"); $exc = Config::inst()->get("ShareThisSTE", "excluded_icons"); if (count($inc)) { $new_array_of_icons_to_include = array(); foreach ($inc as $key => $value) { $new_array_of_icons_to_include[$value] = $value; if (!isset($originalArray[$value])) { debug::show("Error in ShareIcons::set_icons_to_include, {$key} does not exist in bookmark list"); } } foreach ($originalArray as $key => $array) { if (!isset($new_array_of_icons_to_include[$key])) { unset($originalArray[$key]); } } } //which ones do we exclude if (count($exc)) { foreach ($exc as $key) { if (!isset($originalArray[$key])) { debug::show("Error in ShareIcons::set_icons_to_exclude, {$key} does not exist in bookmark list"); } else { unset($originalArray[$key]); } } } if (!$link) { self::$page_specific_data = null; } return $originalArray; }
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(); }
/** * 入口方法 * @param array $config 项目简单配置 */ public static function run($config) { //初始化设置 self::init(); //定义系统常量 self::define($config); //包含框架中的函数库文件 require FIREZP_PATH . 'common' . DIRECTORY_SEPARATOR . 'function.inc.php'; //加载所有配置 if (file_exists(APP_PATH . 'conf' . DIRECTORY_SEPARATOR . 'confing.inc.php')) { $appConfig = (require APP_PATH . 'conf' . DIRECTORY_SEPARATOR . 'confing.inc.php'); $sysConfig = array('page' => 8); //系统配置 $config = array_merge($sysConfig, $appConfig, $config); } C($config); //系统url self::initUrl(); //设置自动加载类 spl_autoload_register(array('self', 'autoload')); //设置包含目录(类所在的全部目录), PATH_SEPARATOR 分隔符号 Linux(:) Windows(;) $include_path = get_include_path(); //原基目录 $include_path .= PATH_SEPARATOR . FIREZP_PATH . "base/"; //框架中基类所在的目录 set_include_path($include_path); //调试开始 debug::debugbegin(); //项目结构化 appStruct::make(); //url解析 parseUrl::run(); //安全过滤 self::safe(); //开始session session_start(); //实例化控制器 $controllerFile = APP_PATH . "controller" . DIRECTORY_SEPARATOR . strtolower($_GET["c"]) . "Controller.php"; define('CONTROLLER', $_GET["c"]); define('ACTION', $_GET["a"]); if (file_exists($controllerFile)) { $controller = $_GET["c"] . "Controller"; $controllerObj = new $controller(); $action = $_GET["a"] . "Action"; if (method_exists($controllerObj, $action)) { $controllerObj->{$action}(); } else { debug::add($action . '方法不存在'); } } else { debug::add('控制器不存在'); } //输出调试信息 if (DEBUG == 1) { debug::debugend(); debug::show(); } }
static function add_to_array_of_currencies_to_show($arrayOfCodes) { if (is_array($arrayOfCodes)) { foreach ($arrayOfCodes as $code) { if (3 == strlen($code)) { self::$array_of_currencies_to_show[] = $code; } } } elseif (3 == strlen($arrayOfCodes)) { self::$array_of_currencies_to_show[] = $arrayOfCodes; } else { debug::show("add_to_array_of_currencies_to_show is not provided with right argument"); } }
/** * 运行项目 */ public static function run() { self::init(); //初始化运行环境 self::formatRequest(); //如果开启自动转义,去除转义 self::setAppGroupPath(); //设置应用路径 self::loadAppGroupConfig(); //载入应用组配置 self::setAppPath(); //设置PATH_APP self::loadAppConfig(); //加载应用配置文件 self::loadUserFile(); //加载系统类文件数据 self::setPathConst(); //设置缓存目录常量 self::createDemoControl(); //创建应用目录 self::setTplConst(); //设置模板常量 self::language(); //加载语言包 self::ajaxCloseDebug(); //ajax时关闭调试 self::setCharset(); //设置字符集 self::createDir(); //创建项目缓存目录结构 self::session_set(); self::compileAppGroupFile(); //项目核心文件编译缓存 self::compileAppFile(); //模块核心文件编译缓存 debug::start("app_start"); //调试开启,需要打开配置文件调试开关 self::apprun(); //项目开始 debug::show("app_start", "app_end"); //显示调试结果 log::save(); //记录日志 }
/** * create a continent * @param array - $contentint, continent data * @param Object - $parent, a BrowseWorldPage object that will be the parent page of the Continent. **/ public function CreateContinent(array $continent, BrowseWorldPage $parent) { $bt = defined('DB::USE_ANSI_SQL') ? "\"" : "`"; if ($parent && isset($continent["Continent"])) { $name = htmlentities($continent["Continent"]); if ($name) { if (isset($_GET["geobuild"])) { echo "<li>creating " . $name . "</li>"; } $this->ParentID = $parent->ID; $this->Title = $name; $this->MetaTitle = $name; $this->MenuTitle = $name; $this->HiddenDataID = $continent["ContinentID"]; $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("name does not exist"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } }
deve::load(_FFPHP_ . 'source/core/view.class.php'); } //加载核心文件 deve::load(array(_FFPHP_ . 'source/core/ffphp.class.php', _FFPHP_ . 'source/core/compile.class.php', _FFPHP_ . 'source/core/action.class.php')); //检测数据连接类型 if (C('CONNECT_TYPE') == 1) { deve::load(_FFPHP_ . 'source/drive/mysqli.class.php'); } else { deve::load(_FFPHP_ . 'source/drive/pdo.class.php'); } //URL路由 ffphp::pathUrl(); //类的自动加载 function __autoload($className) { deve::load(_APP_ . 'behavior/' . $className . '.class.php'); } //控制器的格式化创建 $actionfile = _APP_ . 'action/' . strtolower($_GET['m']) . '.class.php'; if (file_exists($actionfile)) { deve::buildAction($_GET['m']); $newAction = strtolower($_GET['m']) . 'Action'; deve::load(_APP_ . 'core/action/' . $newAction . '.class.php'); $action = new $newAction(); $action->{$_GET}['a'](); } else { debug::error('控制器不存在!', 202102); } if (C('DEBUG')) { debug::$showed or debug::show(); }
public function __construct($pageLink, $name, $year = 0, $month = 0) { $this->pageLink = $pageLink; // Assign name to calendar if (strpos($name, ' ') || strpos($name, '_') || is_numeric(substr($name, 0, 1))) { debug::show($name); user_error('Calendar should have a valid CSS name in the ManyMonthsCalendar Class', E_USER_ERROR); } $this->calendarName = $name; // Set day, month and year of calendar $this->month = 0 == $month ? date('n') : $month; $this->year = 0 == $year ? date('Y') : $year; // Check for valid input if (!preg_match('~[0-9]{4}~', $this->year)) { debug::show($this->year); user_error('Year should be a valid number in the ManyMonthsCalendar Class', E_USER_ERROR); } if (!is_numeric($this->month) || $this->month < 0 || $this->month > 13) { debug::show($this->month); user_error('Month should be a valid number in the ManyMonthsCalendar Class', E_USER_ERROR); } // Set the current timestamp $this->timeStamp = mktime(1, 1, 1, $this->month, 1, $this->year); // Set the number of days in the current month $this->daysInMonth = date('t', $this->timeStamp); }
/** * 输出错误信息 * @param $msg 信息内容 */ function error($error, $showFile = true) { $exception = array(); //错误内容 $backtrace = debug_backtrace(); $exception['message'] = "<b>[ERROR]</b> " . $error . "<br/>"; if ($showFile) { $exception['message'] .= "\t<b>[FILE]</b> " . $backtrace[0]['file'] . "<br/>"; $exception['message'] .= "\t<b>[LINE]</b> " . $backtrace[0]['line'] . "<br/>"; } log::write(strip_tags($exception['message'])); //写入日志 if (!C("DEBUG")) { $e['message'] = C("ERROR_MESSAGE") . "\t\t <span style='color:#666; font-weight:normal;'>\n " . L("functions_error_debug") . "\n </span>"; //查看详细错误信息方法有两种: ① 查看网站日志文件 ② 开启调试模式 include C("LIBS_ERROR_TPL"); exit; } $e['message'] = $exception['message']; include C("LIBS_ERROR_TPL"); debug::show("app_start", "app_end"); exit; }
public static function route($config, $re_route) { $router_vars = self::get_router_vars($config); if (count($router_vars) > 1) { if (utils::key_exists(array($router_vars['controller']), $re_route)) { if (in_array($router_vars['action'], $re_route[$router_vars['controller']])) { $router_vars['controller'] = $router_vars['action']; $router_vars['action'] = !empty($router_vars['fnc_args']) ? $router_vars['fnc_args'][0] : $config['action']; if (count($router_vars['fnc_args']) > 1) { array_shift($router_vars['fnc_args']); } else { $router_vars['fnc_args'] = array(); } } } } if ($router_vars['controller'] == "base") { $router_vars['controller'] = $config['class']; } if (!file_exists(APP . 'controllers' . DS . $router_vars['controller'] . '.php')) { throw new NotFoundException(); } require_once APP . 'controllers' . DS . $router_vars['controller'] . '.php'; if (!class_exists($router_vars['controller'])) { throw new NotFoundException(); } $instance = new $router_vars['controller'](); if (!method_exists($instance, $router_vars['action'])) { throw new NotFoundException(); } $instance->{$router_vars}['action']($router_vars['fnc_args'], $router_vars['gets']); if (DEBUG) { debug::set("router", "router", $router_vars); debug::set("session", "session", session::get_all()); debug::show(); } }
/** * Create a country based on an array and a Continent Parent **/ public function CreateCountry(array $country, BrowseContinentsPage $parent) { if ($parent && isset($country["Country"])) { $name = htmlentities($country["Country"]); if ($name) { if (isset($_GET["geobuild"])) { echo "<li>creating " . $name . "</li>"; } $this->ParentID = $parent->ID; $this->Title = $name; $this->MetaTitle = $name; $this->MenuTitle = $name; $this->HiddenDataID = $country["CountryID"]; $this->ISO2 = $country["ISO2"]; $this->Internet = $country["Internet"]; $this->Capital = htmlentities($country["Capital"]); $this->NationalitySingular = htmlentities($country["NationalitySingular"]); $this->NationalityPlural = htmlentities($country["NationalityPlural"]); $this->Currency = $country["Currency"]; $this->CurrencyCode = $country["CurrencyCode"]; $this->Population = $country["Population"]; $this->AdditionalTitle = htmlentities($country["Title"]); $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("name does not exist"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } }
/** * eturns array */ protected function makeShareIcons($bookmarks) { $icons = array(); if ($bookmarks) { $useFontAwesome = Config::inst()->get("ShareThisSTE", "use_font_awesome"); Requirements::themedCSS('SocialNetworking', "sharethis"); // ALSO added in template if ($useFontAwesome) { Requirements::css("http://maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css"); } Requirements::javascript(FRAMEWORK_DIR . '/thirdparty/jquery/jquery.js'); Requirements::javascript(SS_SHARETHIS_DIR . '/javascript/shareThis.js'); if (Config::inst()->get("ShareThisSTE", "use_bw_effect")) { Requirements::customScript('sharethis.set_use_BW(true);', 'ShareThisBWEffect'); } foreach ($bookmarks as $key => $bookmark) { if (isset($bookmark['title']) && isset($bookmark['url'])) { $icon = array('Title' => Convert::raw2att($bookmark['title']), 'URL' => $bookmark['url'], 'Key' => $key, 'ImageSource' => "sharethis/images/icons/{$key}.png", 'FAIcon' => $bookmark["faicon"], 'UseStandardImage' => true); if (isset($bookmark['click'])) { $icon['OnClick'] = $bookmark['click']; } if ($useFontAwesome) { $icon['ImageSource'] = null; $icon['UseStandardImage'] = false; $icon['FAIcon'] = $bookmark["faicon"]; } if (isset($bookmark['icon'])) { $icon['ImageSource'] = $bookmark['icon']; $icon['UseStandardImage'] = false; $icon['FAIcon'] = null; } $icons[] = new ArrayData($icon); } else { debug::show("Title of url not defined for {$key}"); } } } return new ArrayList($icons); }
function debug() { debug::show("debugging DpsPxPayComs"); echo $this->getDebugMessage(); }
/** * Get geocode from google. * * @see http://code.google.com/apis/maps/documentation/services.html#Geocoding_Direct * @param string $q Place name (e.g. 'Portland' or '30th Avenue, New York") * @return Object Multiple Placemarks and status code */ protected static function get_geocode_obj($q) { if (!Config::inst()->get("GoogleMap", "GoogleMapAPIKey")) { user_error('Please define a valid Google Maps API Key: GoogleMapAPIKey', E_USER_ERROR); } $q = trim($q); if (self::$debug) { var_dump($q); } if (empty($q)) { return false; } $url = sprintf(self::$geocode_url, urlencode($q)); if (self::$debug) { debug::show(print_r($url, 1)); } $curl = curl_init($url); curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curl, CURLOPT_VERBOSE, true); $responseString = curl_exec($curl); if (!$responseString) { $responseString = file_get_contents($url); if (!$responseString) { return false; } } if (self::$debug) { debug::show(print_r($responseString, 1)); } return self::json_decoder($responseString); }
/** * Create a page * @param Array - $city: the data for the city * @param Object $parent: BrowseRegionsPage **/ public function CreateCity(array $city, BrowseRegionsPage $parent) { if ($parent && isset($city["City"])) { $name = htmlentities($city["City"]); if (isset($name)) { if (isset($_GET["geobuild"])) { echo "<li>creating " . $name . "</li>"; } $this->ParentID = $parent->ID; $this->Title = $name; $this->MetaTitle = $name; $this->MenuTitle = $name; $this->HiddenDataID = $city["CityID"]; $this->Code = $city["Code"]; $this->Latitude = $city["Latitude"]; $this->Longitude = $city["Longitude"]; $this->TimeZone = $city["TimeZone"]; $this->County = htmlentities($city["County"]); $this->Code = $city["Code"]; $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->URLSegment = $this->generateURLSegment($this->Title); $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("No name can be found"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } }
function showError() { debug::show($this->errors); }
/** * Creates a region... called from BrowseCountriesPage * *@param Array $region - array of region details *@param Object $parent - a BrowseCountriesPage object * **/ public function CreateRegion(array $region, BrowseCountriesPage $parent) { if ($parent && isset($region["Region"])) { $name = htmlentities($region["Region"]); if ($name) { if (isset($_GET["geobuild"])) { echo "<li>creating " . $name . "</li>"; } $this->ParentID = $parent->ID; $this->Title = $name; $this->MetaTitle = $name; $this->MenuTitle = $name; $this->HiddenDataID = $region["RegionID"]; $this->Code = $region["Code"]; $this->CreateChildren = $parent->CreateAllChildren; $this->CreateAllChildren = $parent->CreateAllChildren; $this->URLSegment = $this->generateURLSegment($this->Title); $this->writeToStage('Stage'); $this->publish('Stage', 'Live'); $this->flushCache(); } else { if (isset($_GET["geobuild"])) { debug::show("region does not exist"); } } } else { if (isset($_GET["geobuild"])) { debug::show("Parent does not exist"); } } }
/** * 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>"; } }
function requireDefaultRecords() { parent::requireDefaultRecords(); $bt = defined('DB::USE_ANSI_SQL') ? '"' : '`'; $update = array(); $siteConfig = DataObject::get_one('SiteConfig'); $folder = Folder::findOrMake(self::get_folder_name()); if ($siteConfig && $folder) { $fullArray = self::get_images_to_replace(); //copying .... if ($fullArray) { foreach ($fullArray as $key => $array) { $className = $array["ClassName"]; $fieldName = $array["FieldName"] . "ID"; if (class_exists($className)) { $dataObject = singleton($className); $dbFieldName = $array["DBFieldName"]; $fileName = basename($array["CopyFromPath"]); $fromLocationLong = Director::baseFolder() . '/' . $array["CopyFromPath"]; $toLocationShort = "assets/" . self::get_folder_name() . "/{$fileName}"; $toLocationLong = Director::baseFolder() . '/' . $toLocationShort; $image = DataObject::get_one('Image', "Filename='{$toLocationShort}' AND ParentID = " . $folder->ID); if (!$image) { if (!file_exists($toLocationLong)) { copy($fromLocationLong, $toLocationLong); } $image = new Image(); $image->ParentID = $folder->ID; $image->FileName = $toLocationShort; $image->setName($fileName); $image->write(); } elseif (!$image && file_exists($toLocationLong)) { debug::show("need to update files"); } if ($image && $image->ID) { if (!$siteConfig->{$dbFieldName}) { $siteConfig->{$dbFieldName} = $image->ID; $update[] = "created placeholder image for {$key}"; } $updateSQL = " UPDATE {$bt}" . $className . "{$bt}"; if (isset($_GET["removeplaceholderimages"])) { $setSQL = " SET {$bt}" . $fieldName . "{$bt} = 0"; $whereSQL = " WHERE {$bt}" . $fieldName . "{$bt} = " . $image->ID; DB::alteration_message("removing " . $className . "." . $fieldName . " placeholder images", 'deleted'); } else { DB::alteration_message("adding " . $className . "." . $fieldName . " placeholder images", 'created'); $setSQL = " SET {$bt}" . $fieldName . "{$bt} = " . $image->ID; if (!isset($_GET["forceplaceholder"])) { $whereSQL = " WHERE {$bt}" . $fieldName . "{$bt} IS NULL OR {$bt}" . $fieldName . "{$bt} = 0"; } else { $whereSQL = ''; } } $sql = $updateSQL . $setSQL . $whereSQL; DB::query($sql); $versioningPresent = false; $array = $dataObject->stat('extensions'); if (is_array($array) && count($array)) { if (in_array("Versioned('Stage', 'Live')", $array)) { $versioningPresent = true; } } if ($dataObject->stat('versioning')) { $versioningPresent = true; } if ($versioningPresent) { $sql = str_replace("{$bt}{$className}{$bt}", "{$bt}{$className}_Live{$bt}", $sql); DB::query($sql); } } else { debug::show("could not create image!" . print_r($array)); } } else { debug::show("bad classname reference " . $className); } } } if (count($update)) { $siteConfig->write(); DB::alteration_message($siteConfig->ClassName . " created/updated: " . implode(" --- ", $update), 'created'); } } elseif (!$folder) { debug::show("COULD NOT CREATE FOLDER: " . self::get_folder_name()); } }