/** * Exclude pages from search * * @param obj $query the query object * @return obj the modified object */ function tz_exclude_pages($query) { if ($query->is_search) { $query->set('post_type', 'post'); } return $query; }
/** * 单一品牌商品列表 * */ private function showBrand() { $brand_id = intval($this->_input['brandid']); if ($brand_id == 0) { header("Location:?action=index"); exit; } /*品牌信息*/ $brand_info = $this->obj_brand->getBrandInfo(array('brand_id' => $brand_id)); $this->output('brand_info', $brand_info); /*创建分页对象*/ $view_list_num = $this->_viewinfo['websit']['other_brand_class'] == '1' ? (int) $this->_viewinfo['websit']['other_brand_class_num'] : 0; if (intval($this->_input['goods_nums']) != 0) { $view_list_num = intval($this->_input['goods_nums']); } require_once "commonpage.class.php"; $obj_page = new CommonPage(); $obj_page->pagebarnum($view_list_num); $brand_product = $this->obj_brand->productBrandList(array('brand_id' => intval($this->_input['brandid'])), $obj_page, '*', $this->_input['goods_show']); $product_brand_page = $obj_page->show(6); $this->output('product_brand_page', $product_brand_page); $this->output('brand_product', $brand_product); /*该品牌热门商品*/ $hot_array = array(); $hot_array = array('brand_id' => intval($this->_input['brandid']), 'order_value' => 'goods_click', 'limit_num' => 8); $brand_hot = $this->obj_brand->getBrandProduct($hot_array); $this->output('brand_hot', $brand_hot); /*推荐品牌,暂时无此字段*/ $brand_commend = $this->obj_brand->getBrandList(array('show_type' => 'class_show')); $this->output('brand_commend', $brand_commend); $this->showpage('product_brand_list'); }
/** * 実行ファイル指定処理 * * @access private * @return */ public function dispatch() { // 実行ファイル $controller = $this->request_obj->getController(); // 実行コントローラーファイル取得 $controller_file = $controller . '_controller.php'; // 実行コントローラーまでのパス取得 $controller_path = APP_CONTROLLERS_PATH . $controller_file; // 実行コントローラー存在チェック if (file_exists($controller_path) == false) { $controller = 'error'; $controller_path = APP_CONTROLLERS_PATH . 'error_controller.php'; } // 実行コントローラー名格納 $this->controller_name = $controller; // 実行コントローラー読み込み include_once $controller_path; // クラス名にフォーマット $controller_class = ucfirst($controller) . 'Controller'; // インスタンス生成 $this->con_obj = new $controller_class($this); // 指定アクション名取得 $action = $this->request_obj->getAction(); // アクション名存在チェック if (empty($action)) { $action = 'index'; } elseif (!is_callable(array(&$this->con_obj, $action))) { $action = 'error'; } // 実行アクション名格納 $this->action_name = $action; // 初期処理実行 $this->con_obj->startup(); }
/** * 购物车信息 * */ function showCart() { $goods_count = $this->obj_shop_cart->GoodsCount(); $this->output('goods_count', $goods_count); //购买商品数量 $this->showpage('cart_window'); }
/** * Process a site and pull all it's posts * * @param int $site_id The ID of the site for which to pull it's posts * @param obj $client The syndication client class instance * @return array|bool Array of posts on success, false on failure */ public function process_site($site_id, $client) { global $site_manager, $client_manager; // Fetch the site status if (!in_array($site_manager->get_site_status($site_id), array('idle', ''))) { return false; } // Mark site as in progress $site_manager->update_site_status('pulling'); try { // Fetch the site's posts by calling the class located at the // namespace given during registration $posts = $client->get_posts($site_id); /** * Filter the array of posts to be processed by a pull client. * * @param array $posts The array of Types\Post objects to be pulled. * @param int $site_id The id of the site being processed. * @param Pull_Client $client The pull client processing the posts. */ $posts = apply_filters('syn_pre_pull_posts', $posts, $site_id, $client); // Process the posts we fetched $this->process_posts($posts, $site_id, $client); } catch (\Exception $e) { Syndication_Logger::log_post_error($site_id, $status = 'error', $message = __('Exception processing site.', 'push-syndication'), $log_time = null, $extra = array('error' => $e)); } // Update site status $site_manager->update_site_status('idle'); if (is_array($posts) && !empty($posts)) { return $posts; } else { return false; } }
/** * Process function * * @param obj $node */ private static function _process($node) { $occurance = []; $result = []; if ($node->childNodes != null) { foreach ($node->childNodes as $key => $child) { if (array_key_isset($child->nodeName, $occurance)) { $occurance[$child->nodeName]++; } else { $occurance[$child->nodeName] = 1; } } } if ($node->nodeType == XML_TEXT_NODE) { $result = html_entity_decode(htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8'); } else { if ($node->nodeType == XML_CDATA_SECTION_NODE) { $result = html_entity_decode(htmlentities($node->nodeValue, ENT_COMPAT, 'UTF-8'), ENT_COMPAT, 'UTF-8'); } else { if ($node->hasChildNodes()) { $children = $node->childNodes; for ($i = 0; $i < $children->length; $i++) { $child = $children->item($i); if ($child->nodeName != '#text' && $child->nodeName != '#cdata-section') { if ($occurance[$child->nodeName] > 1) { $result[$child->nodeName][] = self::_process($child); } else { $result[$child->nodeName] = self::_process($child); } } else { if ($child->nodeName == '#cdata-section') { $text = self::_process($child); if (trim($text) != '') { // $result[$child->nodeName] = self::_process($child); $result['#text'] = (string) $text; } } else { if ($child->nodeName == '#text') { $text = self::_process($child); if (trim($text) != '') { // $result[$child->nodeName] = self::_process($child); $result[$child->nodeName] = (string) $text; } } } } } } if ($node->hasAttributes()) { $attributes = $node->attributes; if (!is_null($attributes)) { foreach ($attributes as $key => $attr) { $result['@' . $attr->name] = $attr->value; } } } } } return $result; }
/** * Checks if given Pods object has the correct item fetch, and if not fetch it. * * @param obj|Pod $pod A Pod object to check * @param int $id ID of item you want. * * @return Pods object */ function slug_ensure_single_pod($pod, $id) { if ($pod->id() !== $id || $pod->id === 0 || is_null($pod->id)) { $pod->fetch($id); } return $pod; }
/** * создание нового файла * @return bool */ public function create() { $dir = $this->folder->pwd(); if (is_dir($dir) && is_writable($dir)) { return @touch($this->path); } return false; }
/** * 获取源代码 * * @param obj $class 反射类实例 * @return string */ private static function _getClassSourse($class) { $path = $class->getFileName(); $lines = @file($path); $from = $class->getStartLine(); $to = $class->getEndLine(); $len = $to - $from + 1; return implode(array_slice($lines, $from - 1, $len)); }
/** * function for adding class name * @author Eleri<*****@*****.**> * @param obj $elem element * @param string $cls new probably additional class name */ function addClass($elem, $cls) { $a = explode(" ", $elem->getClassName()); //mixed array_search ( $needle , array $haystack [, bool $strict = false ] ) if (array_search($cls, $a, true) === false) { $a[] = $cls; } $elem->setClassName(implode(" ", $a)); }
/** * Update data in Excel table * * @param obj $objPHPExcel PHP Excel object * @param int $row Row id * @param int $sum_old Sum of items * @param string $currentDate Current date * * @return obj $objPHPExcel PHP Excel object. */ public function Update($objPHPExcel, $row, $sum_old, $currentDate) { $this->load->model('Database'); $sum_new = $this->db->count_all_results('exercises'); if ($sum_new > $sum_old) { $objPHPExcel->setActiveSheetIndex(0)->setCellValue('A' . $row, $currentDate)->setCellValue('B' . $row, $sum_new); } return $objPHPExcel; }
/** * Create a new Metadata Instance * @param array $settings configuration settings. */ public function __construct($settings) { $this->settings = $settings; // Add logging to metadata parsers $this->pathToLog = $settings['LOGGING']['path_to_log']; // Create log channel for metadataparsers $this->log = new \Monolog\Logger('metadataparsers'); $this->logStreamHandler = new \Monolog\Handler\StreamHandler($this->pathToLog, Logger::WARNING); $this->log->pushHandler($this->logStreamHandler); }
public function validate($path_to_mods) { $mods = new \DomDocument('1.0'); $mods->load($path_to_mods); if ($mods->schemaValidate($this->schema_location)) { $this->log->addInfo("MODS file validates", array('file' => $path_to_mods)); } else { $this->log->addWarning("MODS file does not validate", array('file' => $path_to_mods)); } }
/** * Set the default order on the portfolio posts page to display by * menu order and not date * * @param obj $query The original query object * @return void */ function set_portfolio_post_type_admin_order($query) { if (is_admin()) { $post_type = $query->query['post_type']; if ($post_type == 'portfolio' && empty($_GET['orderby'])) { $query->set('orderby', 'menu_order'); $query->set('order', 'ASC'); } } }
/** * 友情链接 * */ private function showIndex() { /*友情链接*/ $link_image = $this->obj_shop_link->getLinkList(array('logo' => 1), ''); $this->output('link_image', $link_image); $link_text = $this->obj_shop_link->getLinkList(array('logo' => 2), ''); $this->output('text_link_num', count($link_text)); $this->output('link_text', $link_text); $this->shopshowpage("links"); }
/** * Parser Hook * * The following method is assigned to a hook, which will be run whenever * the user adds a <bugs /> tag in the main MediaWiki code. * * @param string $text * @param array $args * @param obj $parser * @return str */ public static function executeHook($text, $args = array(), $parser) { $parser->disableCache(); // Set the page namespace $namespace['dbKey'] = $parser->getTitle()->getPrefixedDBkey(); $namespace['text'] = $parser->getTitle()->getPrefixedText(); $isParserHook = true; // Process request $instance = self::_getInstance(); $output = $instance->_processActionRequest($namespace, $isParserHook, $args); return $output; }
private function footer() { $info_array = $this->obj_shopnc_info->getSystemList(); $this->output('info_array', $info_array); $this->showpage('footer'); /*访问记录*/ //$input_param['ip'] = $this->agent_ip; //ip //$input_param['ip_area'] = "null"; //来源地区 //$input_param['visit_url'] = $this->cur_url; //访问地址 //$input_param['source_url'] = $this->refer_url; //来源地址 //$input_param['visit_system'] = $this->obj_shop_visit->getOS($_SERVER['HTTP_USER_AGENT']);//访问系统 //$this->obj_shop_visit->addVisit($input_param); }
/** * Login API * @param string $email email of user * @param string $password password of user * @param obj $mysqli mysql connection * @return bool success or not */ function login($email, $password, $mysqli) { // Using prepared statements means that SQL injection is not possible. if ($stmt = $mysqli->prepare("SELECT id, username, password, salt\n FROM members\n WHERE email = ?\n LIMIT 1")) { $stmt->bind_param('s', $email); // Bind "$email" to parameter. $stmt->execute(); // Execute the prepared query. $stmt->store_result(); // get variables from result. $stmt->bind_result($user_id, $username, $db_password, $salt); $stmt->fetch(); // hash the password with the unique salt. $password = hash('sha512', $password . $salt); if ($stmt->num_rows == 1) { // If the user exists we check if the account is locked // from too many login attempts if (checkbrute($user_id, $mysqli) == true) { // Account is locked // Send an email to user saying their account is locked return false; } else { // Check if the password in the database matches // the password the user submitted. if ($db_password == $password) { // Password is correct! // Get the user-agent string of the user. $user_browser = $_SERVER['HTTP_USER_AGENT']; // XSS protection as we might print this value $user_id = preg_replace("/[^0-9]+/", "", $user_id); $_SESSION['user_id'] = $user_id; // XSS protection as we might print this value $username = preg_replace("/[^a-zA-Z0-9_\\-]+/", "", $username); $_SESSION['username'] = $username; $_SESSION['login_string'] = hash('sha512', $password . $user_browser); // Login successful. return true; } else { // Password is not correct // We record this attempt in the database $now = time(); $mysqli->query("INSERT INTO login_attempts(user_id, time)\n VALUES ('{$user_id}', '{$now}')"); return false; } } } else { // No user exists. return false; } } }
private function showInfo() { /*底部其他信息,侧边栏显示*/ $info_id = intval($this->_input['info_id']); if ($info_id == 0) { header("Location:?info_id=1"); exit; } $foot_array = $this->obj_shopnc_info->getSystemList(); $this->output('foot_array', $foot_array); $info_array = $this->obj_shopnc_info->getSystemInfo(array('info_id' => intval($this->_input['info_id']))); $this->output('article_array', $info_array); $this->shopshowpage("shop_info"); }
private function nc_header() { /*在导航的商品分类*/ $header_product_class = $this->obj_product_class->getSpecificClass(array('show_type' => 'header')); $this->output('header_product_class', $header_product_class); /*在导航的文章分类*/ $header_article_class = $this->obj_article_class->getArticleClass(array('article_class_menu' => 1)); $this->output('header_article_class', $header_article_class); /*语言包选择*/ require_once "moduleLanguage.class.php"; $module_language = new ModuleLanguageClass(); $conditon_array = array(); $language_array = $module_language->getLanguageList($conditon_array); $this->output('language_array', $language_array); /*判断选中的语言包类型*/ if ($_SESSION['language'] != '') { $language_ver = $_SESSION['language']; } else { $language_ver = $this->_configinfo['websit']['versionarea']; } $this->output('language_ver', $language_ver); /*购物车*/ require_once "shopCart.class.php"; $shop_cart = new ShopCartClass(); $this->output('cart_count', $shop_cart->GoodsCount()); /*导航菜单选中*/ $show_menu = ''; $show_product_menu = ''; $show_article_menu = ''; $menu_name = basename($_SERVER['PHP_SELF']); if ($menu_name == 'index.php') { $show_menu = 'index'; } elseif ($menu_name == 'product_subject.php') { $show_menu = 'subject'; } elseif ($menu_name == 'product_brand.php') { $show_menu = 'brand'; } elseif ($menu_name == 'article_class.php') { $show_article_menu = $this->_input['id']; if ($show_article_menu == '') { $show_article_menu = 'article'; } } elseif ($menu_name == 'product_class.php') { $show_product_menu = $this->_input['classid']; } $this->output('show_menu', $show_menu); $this->output('show_product_menu', $show_product_menu); $this->output('show_article_menu', $show_article_menu); $this->showpage('header'); }
/** * Order posts. * * @since 1.3 * @param obj $query The WP_Query object * @return void */ function mdjm_quote_post_order($query) { if (!is_admin() || 'mdjm-quotes' != $query->get('post_type')) { return; } switch ($query->get('orderby')) { case 'quote_view_date': $query->set('meta_key', '_mdjm_quote_viewed_date'); $query->set('orderby', 'meta_value'); break; case 'quote_value': // TO DO break; } }
public function __construct() { $this->connection = new Connection(); $this->Account = new Account(); $this->Security = new Security(); $this->AssetClass = new AssetClass(); $this->AssetSubclass = new AssetSubclass(); $this->Transaction = new Transaction(); $this->Client = new Client(); $this->Ria = new Ria(); $this->log = new Logger('filesys'); $this->log->pushHandler(new StreamHandler(__DIR__ . '/../logs/rebalancer.log', Logger::WARNING)); $this->connection = new Connection(); $this->db = $this->connection->getMySqlDB(); }
/** * Validate captcha * * @return bool */ public function isValidCaptcha() { if ($this->params->get('captcha_verify') && (!$this->session('saola_captcha') || $this->session('saola_captcha') !== $this->post('saola-captcha'))) { $this->errors[] = JText::_('SAOLA_ERROR_CAPTCHA_VERIFICATION'); } return !$this->errors; }
private function showInfo() { /*底部其他信息,侧边栏显示*/ $info_id = intval($this->_input['info_id']); if ($info_id == 0) { header("Location:?info_id=1"); exit; } require_once "system.class.php"; $footer_shopnc_info = new SystemClass(); $foot_array = $footer_shopnc_info->getSystemList(); $this->output('foot_array', $foot_array); $info_array = $this->obj_shopnc_info->getSystemInfo(array('shop_id' => NC_SHOP_ID, 'info_id' => intval($this->_input['info_id']))); $this->output('info_array', $info_array); $this->showpage('shopnc_info'); }
/** * 文章内容 * */ private function showArticleContent() { /*右侧文章列表*/ include "shopArticleClass.class.php"; $article_class = new ShopArticleClassClass(); $class_array = $article_class->getArticleClassList(); $article_array = $this->obj_article->getArticleList('', ''); foreach ($class_array as $k => $v) { foreach ($article_array as $v1) { if ($v['cid'] == $v1['arc_class']) { if (count($class_array[$k]['body']) < 5) { $class_array[$k]['body'][] = $v1; } } } } $this->output('artclass_array', $class_array); /*文章内容信息*/ $content_array = $this->obj_article->getArticleContent(array('aid' => intval($this->_input['id']))); $this->output('article_array', $content_array[0]); /*相关内容*/ /*热门店铺*/ $hot_shops_array = $this->obj_shopuser->getShopListType(array('shop_type' => 'hot_shop'), 5); $this->output('hot_shops_array', $hot_shops_array); $this->shopshowpage('article'); }
function __construct() { global $page; $name = !$page->content || !$page->content->name ? c::get('tpl.default') : $page->content->name; $params = self::load($name); // handle defaults if (!isset($params['pages'])) { $params['pages'] = true; } if (!isset($params['files'])) { $params['files'] = true; } parent::__construct($params); $this->sortable = true; $this->flip = false; $this->limit = 10; if (isset($this->pages['sort'])) { switch ($this->pages['sort']) { case 'no': $this->sortable = false; break; case 'flip': $this->flip = true; break; } } if (isset($settings->pages['limit'])) { $this->limit = intval($settings->pages['limit']); } }
function edit_art_translations() { global $def; global $check; if ($check->num(query::$post['id']) && query::$post['type'] == 'art') { $time = microtime(true)*1000; $date = obj::transform('text')->rudate(); obj::db()->update('art_translation','active',0,query::$post['id'],'art_id'); if (query::$post['size'] == 'resized') { $info = obj::db()->sql('select resized, md5 from art where id='.query::$post['id'],1); $full_size = explode('x',$info['resized']); $small_size = getimagesize(ROOT_DIR.SL.'images/booru/resized/'.$info['md5'].'.jpg'); $coeff = $full_size[0] / $small_size[0]; } else { $coeff = 1; } foreach (query::$post['trans'] as $key => $translation) { if (!$text = obj::transform('text')->format($translation['text'])) unset (query::$post['trans'][$key]); else { foreach ($translation as $key2 => $one) if ($key2 != 'text') query::$post['trans'][$key][$key2] = round(intval($one) * $coeff); query::$post['trans'][$key]['pretty_text'] = $translation['text']; query::$post['trans'][$key]['text'] = $text; } } obj::db()->insert('art_translation',array(query::$post['id'],base64_encode(serialize(query::$post['trans'])),query::$post['author'],$date,$time,1)); obj::db()->sql('update art set translator="'.query::$post['author'].'" where id='.query::$post['id'].' and translator=""',0); } }
/** * 列表处理 * * @param obj $model 实例化后的模型 * @param array $map 条件数据 * @param string $sort_by 排序字段 * @param string $order_by 排序方法 * @param string $field_list 显示字段 * @param intval $pagesize 每页数据行数 */ protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $pagesize = 20) { //排序 $mod_pk = $model->getPk(); if ($this->_request("sort", 'trim')) { $sort = $this->_request("sort", 'trim'); } else { if (!empty($sort_by)) { $sort = $sort_by; } else { if ($this->sort) { $sort = $this->sort; } else { $sort = $mod_pk; } } } if ($this->_request("order", 'trim')) { $order = $this->_request("order", 'trim'); } else { if (!empty($order_by)) { $order = $order_by; } else { if ($this->order) { $order = $this->order; } else { $order = 'DESC'; } } } //语言项目 $map['lang'] = $this->lang; //如果需要分页 if ($pagesize) { $count = $model->where($map)->count($mod_pk); $pager = new Page($count, $pagesize); } $select = $model->field($field_list)->where($map)->order($sort . ' ' . $order); $this->list_relation && $select->relation(true); if ($pagesize) { $select->limit($pager->firstRow . ',' . $pager->listRows); $page = $pager->show(); } $list = $select->select(); $this->assign('list', $list); $this->assign('list_table', true); }
/** * 事务回滚 */ function back() { if ($this->_begin_transaction) { $this->_begin_transaction = false; $this->db->rollback(); } return false; }
/** * 列表处理 * * @param obj $model 实例化后的模型 * @param array $map 条件数据 * @param string $sort_by 排序字段 * @param string $order_by 排序方法 * @param string $field_list 显示字段 * @param intval $pagesize 每页数据行数 */ protected function _list($model, $map = array(), $sort_by = '', $order_by = '', $field_list = '*', $page, $pagesize = 10) { //排序 $mod_pk = $model->getPk(); if ($this->_request("sort", 'trim')) { $sort = $this->_request("sort", 'trim'); } else { if (!empty($sort_by)) { $sort = $sort_by; } else { if ($this->sort) { $sort = $this->sort; } else { $sort = $mod_pk; } } } if ($this->_request("order", 'trim')) { $order = $this->_request("order", 'trim'); } else { if (!empty($order_by)) { $order = $order_by; } else { if ($this->order) { $order = $this->order; } else { $order = 'ASC'; } } } if ($page) { $count = $model->where($map)->count($mod_pk); $appjson['count'] = intval($count); $pagecount = ceil($count / $pagesize); $start = ($page - 1) * $pagesize; $appjson['pagecount'] = $pagecount; } $select = $model->field($field_list)->where($map)->order($sort . ' ' . $order); $this->list_relation && $select->relation(true); if ($page) { $select->limit($start . ',' . $pagesize); } $list = $select->select(); $appjson['list'] = $list; return $appjson; }