static function init() { $fh = fopen("./log.txt", "w"); try { fputs($fh, "start\n"); $conf = new Conf(dirname(__FILE__) . "/../public/conf01.xml"); print "user: "******"\n"; print "host: " . $conf->get('host') . "\n"; $conf->set("pass", "newpass"); $conf->write(); } catch (FileException $e) { // permissions issue or non-existent file fputs($fh, "file exception\n"); throw $e; } catch (XmlException $e) { fputs($fh, "xml exception\n"); // broken xml } catch (ConfException $e) { fputs($fh, "conf exception\n"); // wrong kind of XML file } catch (Exception $e) { fputs($fh, "general exception\n"); // backstop: should not be called } finally { fputs($fh, "end\n"); fclose($fh); } }
private function _getProperModule() { $key = $this->_conf->get('module_url_variable_name'); $moduleUrlName = $this->_get->{$key}; $moduleName = $this->_appMap->getModuleNameFromUrlName($moduleUrlName); if (!is_null($moduleName)) { return new $moduleName($this->_get, $this->_post, $this->_conf, $this->_view, $this->_appMap); } throw new ControllerException('No module has been choosen for execution'); }
public function __construct(Map $map, Conf $conf) { $this->setImageHandler($map->getImageHandler()); $this->_logoLayout = LogoLayout::factory($conf->get('logo_layout')); $this->_logoFiles = $conf->get('logo_files'); $this->setWorldMap($map->getWorldMap()); $leftUpCorner = $map->getLeftUpCorner(); $this->setLeftUpCorner($leftUpCorner['lon'], $leftUpCorner['lat']); $rightDownCorner = $map->getRightDownCorner(); $this->setRightDownCorner($rightDownCorner['lon'], $rightDownCorner['lat']); parent::__construct($map->getImage()); }
function index() { /* 取得列表数据 */ $conditions = $this->_get_query_conditions(array(array('field' => 'state', 'name' => 'state', 'handler' => 'groupbuy_state_translator'), array('field' => 'group_name', 'name' => 'group_name', 'equal' => 'LIKE'))); // 标识有没有过滤条件 if ($conditions) { $this->assign('filtered', 1); } $page = $this->_get_page(10); //获取分页信息 $groupbuy_list = $this->_groupbuy_mod->find(array('join' => 'be_join', 'order' => 'gb.group_id DESC', 'limit' => $page['limit'], 'count' => true, 'conditions' => 'user_id=' . $this->visitor->info['user_id'] . $conditions)); $page['item_count'] = $this->_groupbuy_mod->getCount(); //获取统计的数据 foreach ($groupbuy_list as $key => $groupbuy) { $groupbuy['ican'] = $this->_ican($groupbuy['group_id']); $groupbuy_list[$key] = $groupbuy; $groupbuy_list[$key]['spec_quantity'] = unserialize($groupbuy['spec_quantity']); $groupbuy['default_image'] || ($groupbuy_list[$key]['default_image'] = Conf::get('default_goods_image')); } //dump($groupbuy_list); /* 当前位置 */ $this->_curlocal(LANG::get('member_center'), 'index.php?app=member', LANG::get('my_groupbuy'), 'index.php?app=buyer_groupbuy', LANG::get('groupbuy_list')); /* 当前用户中心菜单 */ $this->_curitem('my_groupbuy'); /* 当前所处子菜单 */ $this->_curmenu('groupbuy_list'); $this->_format_page($page); $this->assign('page_info', $page); //将分页信息传递给视图,用于形成分页条 $this->assign('groupbuy_list', $groupbuy_list); $this->assign('state', array('all' => Lang::get('group_all'), 'on' => Lang::get('group_on'), 'end' => Lang::get('group_end'), 'finished' => Lang::get('group_finished'), 'canceled' => Lang::get('group_canceled'))); $this->_config_seo('title', Lang::get('member_center') . ' - ' . Lang::get('my_groupbuy')); $this->display('buyer_groupbuy.index.html'); }
public function configure() { // Init category $category = new Model_Category(Conf::get('MAIN_CATEGORY')); if ($category->getQuestionsTotal(true, true) == 0) { return; } // Get questions $questions = $category->getQuestions('latest', $this->page, true, true); if ($category->getQuestionsTotal(true, true) <= ($this->page + 1) * Conf::get('QUESTION_PER_PAGE')) { header('X-JSON: (Question.setEndReached())'); } $colors = Conf::get('GRAPH_COLORS'); // Loop through all questions foreach ($questions as $key => $question) { // Get question's answers $answers = $question->getAnswers(); $data = array(); foreach (array_reverse($answers) as $key => $answer) { $data[] = array('value' => $answer->getPercentResultsMatching() / 100, 'color' => $colors[$key]); } // Assign question infos Globals::$tpl->assignLoopVar('question_archive', array('id' => $question->getId(), 'label' => $question->getLabel(), 'guid' => Tool::makeGuid($question->getLabel()), 'data' => json_encode($data), 'time' => Tool::timeWarp($question->getEndDate()))); // Assign answers infos foreach ($answers as $key => $answer) { Globals::$tpl->assignLoopVar('question_archive.answer', array('percentFormated' => round($answer->getPercentResultsMatching()), 'label' => $answer->getLabel(), 'key' => $key)); } } }
public function __construct() { $dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php'); if (!is_readable($dispatcher) || !Pi::inc($dispatcher)) { throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032); } }
public function configure() { // Get answers $answers = $this->question->getAnswers(); $colors = Conf::get('GRAPH_COLORS'); $dataWomen = array(); $dataMen = array(); // Percent MALE foreach (array_reverse($answers) as $key => $answer) { $dataMen[] = array('value' => $answer->getPercentResultsMatchingMale() / 100 * 0.95 + 0.05, 'color' => $colors[$key]); } foreach ($answers as $key => $answer) { Globals::$tpl->assignLoopVar('question_men', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format($answer->getPercentResultsMatchingMale(), 1, ',', ' '))); } // Percent FEMALE foreach (array_reverse($answers) as $key => $answer) { $dataWomen[] = array('value' => $answer->getPercentResultsMatchingFemale() / 100 * 0.95 + 0.05, 'color' => $colors[$key]); } foreach ($answers as $key => $answer) { Globals::$tpl->assignLoopVar('question_women', array('key' => $key, 'label' => $answer->getLabel(), 'percent' => number_format($answer->getPercentResultsMatchingFemale(), 1, ',', ' '))); } Globals::$tpl->assignVar('question_men_data', json_encode($dataMen)); Globals::$tpl->assignVar('question_women_data', json_encode($dataWomen)); Globals::$tpl->assignVar('question_label', $this->question->getLabel()); }
function login() { if ($this->visitor->has_login) { $this->show_warning('has_login'); return; } if (!IS_POST) { if (Conf::get('captcha_status.backend')) { $this->assign('captcha', 1); } $this->display('login.html'); } else { if (Conf::get('captcha_status.backend') && base64_decode($_SESSION['captcha']) != strtolower($_POST['captcha'])) { $this->show_warning('captcha_faild'); return; } $user_name = trim($_POST['user_name']); $password = $_POST['password']; $ms =& ms(); $user_id = $ms->user->auth($user_name, $password); if (!$user_id) { /* 未通过验证,提示错误信息 */ $this->show_warning($ms->user->get_error()); return; } /* 通过验证,执行登陆操作 */ if (!$this->_do_login($user_id)) { return; } $this->show_message('login_successed', 'go_to_admin', 'index.php'); } }
/** * Get PDO instance * * @return PDO */ public static function getPDO() { if (empty(self::$_pdo)) { self::$_pdo = new PDO(Conf::get(self::DSN), Conf::get(self::USER), Conf::get(self::PASSWORD)); } return self::$_pdo; }
/** * 取得某推荐下商品 * @param int $recom_id 推荐类型 * @param int $num 取商品数量 * @param bool $default_image 如果商品没有图片,是否取默认图片 * @param int $mall_cate_id 分类(最新商品用到) */ function get_recommended_goods($recom_id, $num, $default_image = true, $mall_cate_id = 0) { $goods_list = array(); $conditions = "g.if_show = 1 AND g.closed = 0 AND s.state = 1 "; if ($recom_id == REC_NEW) { /* 最新商品 */ if ($mall_cate_id > 0) { $gcategory_mod =& m('gcategory'); $conditions .= " AND g.cate_id " . db_create_in($gcategory_mod->get_descendant($mall_cate_id)); } $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock, gs.spec_id " . "FROM " . DB_PREFIX . "goods AS g " . "LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . "LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "WHERE " . $conditions . "ORDER BY g.add_time DESC " . "LIMIT {$num}"; } else { /* 推荐商品 */ $sql = "SELECT g.goods_id, g.goods_name, g.default_image, gs.price, gs.stock, gs.spec_id " . "FROM " . DB_PREFIX . "recommended_goods AS rg " . " LEFT JOIN " . DB_PREFIX . "goods AS g ON rg.goods_id = g.goods_id " . " LEFT JOIN " . DB_PREFIX . "goods_spec AS gs ON g.default_spec = gs.spec_id " . " LEFT JOIN " . DB_PREFIX . "store AS s ON g.store_id = s.store_id " . "WHERE " . $conditions . "AND rg.recom_id = '{$recom_id}' " . "AND g.goods_id IS NOT NULL " . "ORDER BY rg.sort_order " . "LIMIT {$num}"; } $res = $this->db->query($sql); $promotion_mod =& m('promotion'); while ($row = $this->db->fetchRow($res)) { $default_image && empty($row['default_image']) && ($row['default_image'] = Conf::get('default_goods_image')); /* 读取促销价格 */ $row['price'] = $promotion_mod->get_promotion_price($row['goods_id'], $row['spec_id']); $goods_list[] = $row; } return $goods_list; }
public function configureData() { // Look if this login exists $rs = DB::select(' SELECT `id` FROM `user` WHERE `login`="' . $_POST['login'] . '" AND `valided`=1 '); // If this user is not already registered // TODO : check if the email is not allready taken if ($rs['total'] == 0) { // Encrypte password $key = md5(rand(0, 1000) + microtime()); // Insert user's infos in the base $id = DB::insert('INSERT INTO `user` (`login`, `zip`, `male`, `email`, `password`, `key`, `register_date`) VALUES ( "' . $_POST['login'] . '", "' . $_POST['zip'] . '", "' . $_POST['gender'] . '", "' . $_POST['email'] . '", "' . md5($_POST['password']) . '", "' . $key . '", "' . time() . '" )'); // TODO : register informations should be sent by email echo $key . chr(13) . Conf::get('ROO_PATH') . $_POST['login'] . '/confirm?u=' . $id . '&k=' . $key; } }
public function configureData() { // Look if this login exists $rs = DB::select(' SELECT `id` FROM `user` WHERE `login`="' . $_POST['login'] . '" AND `valided`=1 '); // If this user is not already registered // TODO : check if the email is not allready taken if ($rs['total'] == 0) { // Encrypte password $key = md5(rand(0, 1000) + microtime()); // Insert user's infos in the base $id = DB::insert('INSERT INTO `user` (`login`, `zip`, `male`, `email`, `password`, `key`, `register_date`) VALUES ( "' . $_POST['login'] . '", "' . $_POST['zip'] . '", "' . $_POST['gender'] . '", "' . $_POST['email'] . '", "' . md5($_POST['password']) . '", "' . $key . '", "' . time() . '" )'); $subject = 'Bienvenue sur Opipop - confirmation de votre enregistrement'; $message = 'Clicked ici pour activer votre compte : ' . Conf::get('ROOT_PATH') . $_POST['login'] . '/confirm?u=' . $id . '&k=' . $key; Tool::sendMail(Conf::get('SITE_NAME'), Conf::get('ADMIN_EMAIL'), $_POST['email'], $subject, $message); } }
public function configureData() { if (!Tool::isOk($_POST['id']) || !($user = Model_User::getLoggedUser()) || $user->getId() != $_POST['id'] || !Tool::isOk($_POST['zip']) || !isset($_POST['gender']) || !Tool::isOk($_POST['login'])) { header('Location: ' . Conf::get('ROOT_PATH')); exit; } DB::update('UPDATE `user` SET `zip`="' . $_POST['zip'] . '", `male`="' . $_POST['gender'] . '" WHERE `id`="' . $_POST['id'] . '"'); if (isset($_FILES) && isset($_FILES['avatar']) && $_FILES['avatar']['error'] != 4) { $size = filesize($_FILES['avatar']['tmp_name']); $stat = stat($_FILES['avatar']['tmp_name']); if ($size[0] <= 1680 && $size[1] <= 1680 && $stat['size'] <= 450 * 1024) { $extention = strtolower(preg_replace('#.+\\.([a-zA-Z]+)$#isU', '$1', $_FILES['avatar']['name'])); $original = Conf::get('MEDIA_DIR') . 'avatar/original/' . $_POST['id'] . '.' . $extention; move_uploaded_file($_FILES['avatar']['tmp_name'], $original); $sizeSmall = explode('x', Conf::get('AVATAR_SMALL_SIZE')); $sizeMedium = explode('x', Conf::get('AVATAR_MEDIUM_SIZE')); $sizeLarge = explode('x', Conf::get('AVATAR_LARGE_SIZE')); Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_LARGE_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeLarge[0], isset($sizeLarge[1]) ? $sizeLarge[1] : false, true); Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_MEDIUM_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeMedium[0], isset($sizeMedium[1]) ? $sizeMedium[1] : false, true); Tool::redimage($original, Conf::get('MEDIA_DIR') . 'avatar/' . Conf::get('AVATAR_SMALL_SIZE') . '/' . $_POST['id'] . '.jpg', $sizeSmall[0], isset($sizeSmall[1]) ? $sizeSmall[1] : false, true); } } $_SESSION['feedback'] = 'Your informations has been updated'; header('Location: ' . Conf::get('ROOT_PATH') . $_POST['login']); }
/** * OPS read only db connector * * @return db connection handler */ public static function ops_ro() { $dsn = "mysql:host=" . Conf::get('ops_ro_host', 'db', 'dsn') . ";dbname=" . Conf::get('ops_ro_db', 'db', 'dsn'); $dsn .= ";port=" . Conf::get('ops_ro_port', 'db', 'dsn'); $user = Conf::get('ops_ro_user', 'db', 'dsn'); $pass = Conf::get('ops_ro_pwd', 'db', 'dsn'); return self::connect($dsn, $user, $pass); }
private function displayArchives() { if (!isset($this->displayArchives)) { $category = new Model_Category(Conf::get('MAIN_CATEGORY')); $this->displayArchives = $category->getQuestionsTotal(true, true) == 0 ? false : true; } return $this->displayArchives; }
/** * 判断Google sitemap是否过期 * * @author Garbin * @return boolean */ function _google_sitemap_expired() { if (!is_file($this->_google_sitemmap_file)) { return true; } $frequency = Conf::get('sitemap_frequency') * 3600; $filemtime = $this->_get_google_sitemap_lastupdate(); return time() >= $filemtime + $frequency; }
public function __construct() { $dispatcher = Conf::get('global.dispatcher_path', PI_CORE . 'RouteDispatcher.php'); if (file_exists($dispatcher)) { Pi::inc($dispatcher); } else { throw new Exception('can not find the dispatcher config : global.dispatcher_path', 1032); } }
public function getQuestions($page = false) { if (!isset($this->questions)) { $this->fetchQuestions(); } $from = (!$page ? 0 : $page) * Conf::get('QUESTION_PER_PAGE'); $max = $page === false ? 0 : Conf::get('QUESTION_PER_PAGE'); return array_slice($this->questions, $from, $max); }
public function testInstance() { $obj = App::make('markdown'); if ('sundown' == Conf::get('markdown')) { $this->assertInstanceOf('Pochika\\Markdown\\Sundown', $obj); } else { $this->assertInstanceOf('Pochika\\Markdown\\PHPMarkdownExtra', $obj); } }
static function remove($key) { if (Conf::get('MEMCACHED_ENABLED')) { if (!self::$memcached) { self::connect(); } self::$memcached->delete($key); } unset(self::$local[$key]); }
public function configure() { // Init category $category = new Model_Category(Conf::get('MAIN_CATEGORY')); if ($category->getQuestionsTotal(true) == 0) { return; } // Get logged user if there is one $user = Model_User::getLoggedUser(); // Get questions $questions = $category->getQuestions('latest', $this->page, 1); // Loop through all questions foreach ($questions as $question) { Globals::$tpl->assignLoopVar('question', array('id' => $question->getId(), 'label' => $question->getLabel(), 'image' => $question->getImageURL('medium'), 'label_urlencoded' => urlencode($question->getLabel()), 'time' => Tool::timeWarp($question->getEndDate()))); // Get answers $answers = $question->getAnswers(); $friendsVotedId = array(); if ($user) { $userResult = $user->getResult($question); $userGuess = $user->getGuess($question); } // Loop through all answers foreach ($answers as $answer) { Globals::$tpl->assignLoopVar('question.answer', array('id' => $answer->getId(), 'label' => $answer->getLabel())); if ($user && $userResult && $answer->getId() == $userResult->getAnswer()->getId()) { Globals::$tpl->assignLoopVar('question.answer.user', array('class' => 'vote', 'label' => 'Mon opinion', 'id' => $user->getId(), 'login' => $user->getLogin(), 'image' => $user->getAvatarURL('small'))); } if ($user && $userGuess && $answer->getId() == $userGuess->getAnswer()->getId()) { Globals::$tpl->assignLoopVar('question.answer.user', array('class' => 'guess', 'label' => 'Mon pronostic', 'id' => $user->getId(), 'login' => $user->getLogin(), 'image' => 'media/layout/icon24x24/map_mini.png')); } if ($user) { foreach ($user->getFriendGuesses($question) as $friendGuess) { if ($answer->getId() == $friendGuess->getAnswer()->getId()) { Globals::$tpl->assignLoopVar('question.answer.friend', array('class' => 'friend', 'userId' => $user->getId(), 'id' => $friendGuess->getFriend()->getId(), 'login' => $friendGuess->getFriend()->getLogin(), 'avatar' => $friendGuess->getFriend()->getAvatarURL('small'))); $friendsVotedId[] = $friendGuess->getFriend()->getId(); } } } } if ($user && !$userResult) { Globals::$tpl->assignLoopVar('question.pendingUser', array('class' => 'vote', 'label' => 'Mon opinion', 'id' => $user->getId(), 'login' => $user->getLogin(), 'avatar' => $user->getAvatarURL('small'))); } if ($user && !$userGuess) { Globals::$tpl->assignLoopVar('question.pendingUser', array('class' => 'guess', 'label' => 'Mon pronostic', 'id' => $user->getId(), 'login' => $user->getLogin(), 'avatar' => $user->getAvatarURL('small'))); } if ($user) { // Construct unvoted friends list foreach ($user->getFriends() as $friend) { if (!in_array($friend->getId(), $friendsVotedId)) { Globals::$tpl->assignLoopVar('question.pendingFriend', array('class' => 'friend', 'userId' => $user->getId(), 'id' => $friend->getId(), 'login' => $friend->getLogin(), 'avatar' => $friend->getAvatarURL('small'))); } } } } }
function index() { //$this->assign('index', 1); // 标识当前页面是首页,用于设置导航状态 $this->assign('icp_number', Conf::get('icp_number')); /* 热门搜素 */ $this->assign('hot_keywords', $this->_get_hot_keywords()); $this->_config_seo(array('title' => Lang::get('mall_index') . ' - ' . Conf::get('site_title'))); $this->assign('page_description', Conf::get('site_description')); $this->assign('page_keywords', Conf::get('site_keywords')); $this->display('index.html'); }
public static function info() { if (Conf::get('App.debug')) { $view = new View(); $view->view = CORE . DS . 'View' . DS . 'debug.php'; $debug = array('__CONTAINER__' => self::$container, '__SESSION__' => isset($_SESSION) ? $_SESSION : null, '__POST__' => &$_POST, '__GET__' => &$_GET, '__SERVER__' => &$_SERVER); $view->set(compact('debug')); $view->render(); return; } }
public function configureData() { // Logout user Model_User::logout(); // Go back to home or to where I was if (substr($_SERVER['HTTP_REFERER'], 0, strlen(Conf::get('ROOT_PATH'))) == Conf::get('ROOT_PATH')) { header('Location: ' . $_SERVER['HTTP_REFERER']); } else { header('Location: ' . Conf::get('ROOT_PATH')); } }
function _recommended_stores($num) { $store_mod =& m('store'); $goods_mod =& m('goods'); $stores = $store_mod->find(array('conditions' => 'recommended=1 AND state = 1', 'order' => 'sort_order', 'join' => 'belongs_to_user', 'limit' => '0,' . $num)); foreach ($stores as $key => $store) { empty($store['store_logo']) && ($stores[$key]['store_logo'] = Conf::get('default_store_logo')); $stores[$key]['goods_count'] = $goods_mod->get_count_of_store($store['store_id']); } return $stores; }
function execute() { $model_member =& m('member'); $seller_info = $model_member->get($this->_store_id); $model_mailqueue =& m('mailqueue'); $time = gmtime(); $site_name = Conf::get('site_name'); $mail = array('mail_to' => $seller_info['email'], 'mail_encoding' => CHARSET, 'mail_subject' => $this->_config['subject'], 'mail_body' => $this->_config['content'], 'add_time' => $time); $model_mailqueue->add($mail); $model_mailqueue->send(5); }
function index() { $this->assign('index', 1); // 标识当前页面是首页,用于设置导航状态 $this->assign('icp_number', Conf::get('icp_number')); /* 热门搜素 */ $this->assign('hot_keywords', $this->_get_hot_keywords()); $this->assign('page_title', Conf::get('site_title')); $this->assign('page_description', Conf::get('site_description')); $this->assign('page_keywords', Conf::get('site_keywords')); $this->display('index.html'); }
static function delete($query) { if (preg_match("/^\\s*(delete)/i", $query)) { if (Conf::get('DB_READONLY')) { return 0; } else { self::query($query); return mysql_affected_rows(self::$CON); } } return false; }
/** * 将GMT时间戳格式化为用户自定义时区日期 * * @param string $format * @param integer $time 该参数必须是一个GMT的时间戳 * * @return string */ function local_date($format, $time = NULL) { /* 现在暂时还没有用户自定义时区的功能,所有的时区都跟着商城的设置走 */ $timezone = Conf::get('time_zone'); if ($time === NULL) { $time = gmtime(); } elseif ($time <= 0) { return ''; } $time += $timezone * 3600; return date($format, $time); }
function index() { $themes = list_template('mall'); $theme_list = array(); foreach ($themes as $theme) { $theme_list[$theme] = list_style('mall', $theme); } $this->assign('curr_template_name', Conf::get('template_name')); $this->assign('curr_style_name', Conf::get('style_name')); $this->assign('theme_list', $theme_list); $this->display('theme.index.html'); }