Esempio n. 1
0
 public static function sendMail($data)
 {
     $transport = Swift_SmtpTransport::newInstance(Config::get('smtp.server'), Config::get('smtp.port'))->setUsername(Config::get('smtp.username'))->setPassword(Config::get('smtp.password'));
     $mailer = Swift_Mailer::newInstance($transport);
     $message = Swift_Message::newInstance($data['subject'])->setFrom([Config::get('smtp.username') => Config::get('framework.title')])->setTo([$data['to']])->setContentType('text/html')->setBody($data['text']);
     return $mailer->send($message);
 }
Esempio n. 2
0
 /**
  * Init database
  */
 private static function _initDb()
 {
     $config = \Core\Config::getInstance();
     $dbConnection = new PDO($config->database['driver'] . ':host=' . $config->database['host'] . ';dbname=' . $config->database['dbname'], $config->database['user'], $config->database['password'], array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
     $dbConnection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
     \Core\Db\Connector::getInstance()->setConnection($dbConnection);
 }
Esempio n. 3
0
 public function indexAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Seo
     $this->_seo['h1'] = 'Поиск';
     $this->_seo['title'] = 'Поиск';
     $this->_seo['keywords'] = 'Поиск';
     $this->_seo['description'] = 'Поиск';
     $this->setBreadcrumbs('Поиск');
     // Check query
     $query = Arr::get($_GET, 'query');
     if (!$query) {
         return $this->_content = $this->noResults();
     }
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : conf::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get items list
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit, ($page - 1) * $limit)->as_object()->execute();
     // Check for empty list
     if (!count($result)) {
         return $this->_content = $this->noResults();
     }
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->or_where_open()->or_where('catalog.name', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where('catalog.artikul', 'LIKE', DB::expr('"%' . $query . '%"'))->or_where_close()->where('catalog.status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render page
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
Esempio n. 4
0
 public function __construct($data)
 {
     if (isset($data)) {
         $this->_data = $data;
     }
     $this->_db = Database::getInstance(Config::get('mysql/host'), Config::get('mysql/db'), Config::get('mysql/user'), Config::get('mysql/pass'));
 }
Esempio n. 5
0
 public function __construct()
 {
     //Setup extra autoloader.
     new Autoloader(Config::get("autoloader"));
     $this->setVars();
     $this->run();
 }
Esempio n. 6
0
 public function endAction()
 {
     $orderId = (int) Route::param('id');
     if ($orderId and isset($_POST) and count($_POST) > 0) {
         $data = json_decode(base64_decode($_POST['data']), true);
         $order = DB::select()->from('afisha_orders')->where('id', '=', $orderId)->find();
         if (!$order) {
             return Config::error();
         }
         // update status
         if ($data['status'] && $data['status'] == 'success') {
             Common::update('afisha_orders', array('status' => 'success', 'updated_at' => time()))->where('id', '=', $orderId)->execute();
             // Change status for seats
             $prices = DB::select('id')->from('prices')->where('afisha_id', '=', $order->afisha_id)->find_all();
             $pricesArr = array();
             if (count($prices)) {
                 foreach ($prices as $key => $value) {
                     $pricesArr[] = $value->id;
                 }
                 $res2 = \Core\Common::update('seats', array('status' => 3))->where('view_key', 'IN', array_filter(explode(',', $order->seats_keys)))->where('price_id', 'IN', $pricesArr)->execute();
             }
         }
     }
     //        	HTTP::redirect('after_payment/');
     return;
 }
Esempio n. 7
0
 /**
  * 从tld判断域名
  */
 public function checkFromTld($domain)
 {
     $tld = (array) \Core\Config::item('tld');
     $provinceTld = (array) \Core\Config::item('provinceTld');
     $suffix = \common\Common::getDomainAllTld($domain);
     return in_array($suffix, $tld) || in_array($suffix, $provinceTld) ? array('flag' => 1) : array('flag' => 0);
 }
Esempio n. 8
0
 /**
  * 定时处理竞价结束的数据处理
  *
  *
  */
 public function checkAcuctionStatusAction()
 {
     // step1 取出已过交易结束时间,类型为竞价的并且有买家id的交易记录
     $taoModel = new NewTaoModel();
     $taoData = $taoModel->getExpiredByType(\core\Config::item('isInquiry')->toArray()[1], time());
     // step2 将step1的记录修改状态为等待买卖双方确认的状态,存到new_trans_result表,并更新用户关注表
     $historyModel = new NewTransHistoryModel();
     $transLogic = new TransLogic();
     if (!empty($taoData)) {
         foreach ($taoData as $data) {
             $data = get_object_vars($data);
             $data['t_status'] = 2;
             //存表
             if ($historyModel->setTransHistory($data)) {
                 //更新用户关注表
                 if ($transLogic->updateWatchInfo($data['t_id'], $data['t_now_price'], $data['t_nickname'], $endTime = $data['t_end_time'])) {
                     // step3 删除new_tao里面该条交易记录
                     if ($taoModel->delByTid($data['t_id'])) {
                         echo 'tid 为' . $data['t_id'] . '操作成功';
                     } else {
                         echo 'tid 为' . $data['t_id'] . '删除net_tao原表数据失败';
                     }
                 } else {
                     echo 'tid 为' . $data['t_id'] . '更新用户关注表失败';
                 }
             } else {
                 echo 'tid 为' . $data['t_id'] . '复制到history 失败';
             }
         }
     }
 }
Esempio n. 9
0
 /**
  * Make a URL that links to a controller/action/variables.
  *
  * By default we do not use the URL variables, but you can chose to do so.
  *
  * <code>
  * array(
  *     'controller'      => 'Index',
  *     'action'          => 'Index',
  *     'variables'       => array(
  *         'foo' => 'bar',
  *         'bar' => 'foobar'
  *     )
  *     'variable_retain' => false
  * )
  * </code>
  *
  * @access public
  * @param  array  $param Parameters used to build the URL.
  * @return string
  */
 public function render($param = array())
 {
     // Set some defaults
     $defaults = array('controller' => $this->controller, 'action' => '', 'variables' => isset($param['variable_retain']) && $param['variable_retain'] ? $_GET : array(), 'variable_retain' => false);
     // However, we do not want the controller/action in the variable list
     unset($defaults['variables']['controller'], $defaults['variables']['action']);
     // Merge these in with the parameters
     // Parameters will take precedence
     $param = array_merge($defaults, $param);
     // Start to build URL
     // The controller
     $url = Core\Config::get('path', 'root') . $param['controller'] . '/' . $param['action'];
     // Any variables
     if ($param['variables']) {
         // Yes, there are variables to append, loop over them
         foreach ($param['variables'] as $variable => $value) {
             // If there is an odd amount of variables in the URL string
             // .. then we just set the last variable to true. This needs
             // .. to be the same in this case also.
             $url .= '/' . urlencode($variable) . '/' . ($value === true ? '' : $value);
         }
     }
     // URL has finished constructing, pass back
     return $url;
 }
Esempio n. 10
0
 /**
  * Retourne l'instance de Config
  * @param $key
  * @return \Core\Config
  */
 public function getConfig($key)
 {
     if (is_null($this->config_instance)) {
         $this->config_instance = Config::getInstance();
     }
     return $this->config_instance->get($key);
 }
Esempio n. 11
0
 /**
  * 从new_tao表中找出状态为15的交易,请求dc接口解锁域名,解锁成功后,将该记录复制到new_trans_history表,同时从new_tao表删除该记录
  *
  *
  *
  */
 public function downAction()
 {
     $taoModel = new NewTaoModel();
     $taoData = $taoModel->getDataByStatus(15);
     if (!empty($taoData)) {
         $dLogic = new DomainLogic();
         foreach ($taoData as $v) {
             $data[$v->t_id] = (array) $v;
             $res = $dLogic->setDomainStatus(\core\Config::item('doPubSta')->toArray()['down'], 1);
             if ($res !== true) {
                 unset($data[$v->t_id]);
                 echo "解锁new_tao状态为15的域名id{$v->t_id}失败,解锁时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n";
             }
         }
         if (!empty($data)) {
             $data = array_values($data);
             $TransLogic = new TransLogic();
             //将信息更新到历史表中,并在new_tao中删除
             foreach ($data as $v) {
                 $copyRes = $TransLogic->copyToHistory($v, $v['t_status']);
                 $delRes = $TransLogic->delByTid($v['t_id']);
                 if (!$copyRes) {
                     echo "域名id{$v['t_id']}解锁成功,但在插入new_trans_history时发生错误.时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n";
                 }
                 if (!$delRes) {
                     echo "域名id{$v['t_id']}解锁成功,但在从new_tao删除该条记录时发生错误.时间:" . date('Y-m-d H:i:s', $_SERVER['REQUEST_TIME']) . "\n";
                 }
             }
         }
     }
 }
Esempio n. 12
0
 public function innerAction()
 {
     $this->_template = 'CatalogItemsWithoutFilter';
     $page = !(int) Route::param('page') ? 1 : (int) Route::param('page');
     // Check for existance
     $brand = DB::select()->from('brands')->where('alias', '=', Route::param('alias'))->where('status', '=', 1)->as_object()->execute()->current();
     if (!$brand) {
         return Config::error();
     }
     // Seo
     $this->_seo['h1'] = $brand->h1;
     $this->_seo['title'] = $brand->title;
     $this->_seo['keywords'] = $brand->keywords;
     $this->_seo['description'] = $brand->description;
     $this->setBreadcrumbs($brand->name);
     // Get count items per page
     $limit = (int) Arr::get($_GET, 'per_page') ? (int) Arr::get($_GET, 'per_page') : Config::get('limit');
     // Get sort type
     $sort = in_array(Arr::get($_GET, 'sort'), array('name', 'created_at', 'cost')) ? Arr::get($_GET, 'sort') : 'sort';
     $type = in_array(strtolower(Arr::get($_GET, 'type')), array('asc', 'desc')) ? strtoupper(Arr::get($_GET, 'type')) : 'ASC';
     // Get popular items
     $result = DB::select(array('catalog_images.image', 'image'), 'catalog.*')->from('catalog')->join('catalog_images', 'LEFT')->on('catalog_images.catalog_id', '=', 'catalog.id')->on('catalog_images.main', '=', DB::expr('1'))->where('catalog.brand_id', '=', $brand->id)->where('catalog.status', '=', 1)->order_by('catalog.' . $sort, $type)->limit($limit)->offset(($page - 1) * $limit)->as_object()->execute();
     // Set description of the brand to show it above the sort part
     Config::set('brand_description', View::tpl(array('brand' => $brand), 'Brands/Inner'));
     // Count of parent groups
     $count = DB::select(array(DB::expr('COUNT(catalog.id)'), 'count'))->from('catalog')->where('brand_id', '=', $brand->id)->where('status', '=', 1)->as_object()->execute()->current()->count;
     // Generate pagination
     $pager = Pager::factory($page, $count, $limit)->create();
     // Render template
     $this->_content = View::tpl(array('result' => $result, 'pager' => $pager), 'Catalog/ItemsList');
 }
Esempio n. 13
0
 public static function Instance($database = NULL)
 {
     if (!isset(self::$instances[$database])) {
         if (is_null($database)) {
             $db_info = Config::Get('database');
         } else {
             $db_info = array('name' => $database);
         }
         $db_file = Config::Path(Config::DIR_DATA . DIRECTORY_SEPARATOR . $db_info['name'] . SQLite::DB_EXTENSION);
         if (!file_exists($db_file)) {
             $schema = file_get_contents(Config::Path(Config::DIR_DATA . DIRECTORY_SEPARATOR . $db_info['name'] . SQLite::INIT_EXTENSION));
             $schema = str_replace("\n", ' ', $schema);
             $schema = str_replace("\r", ' ', $schema);
             $db = new SQLite3($db_file, SQLITE3_OPEN_CREATE | SQLITE3_OPEN_READWRITE);
             $db->exec($schema);
         }
         // load database
         self::$instances[$database] = new PDO('sqlite:' . $db_file);
         if (Config::Get('debug')) {
             self::$instances[$database]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
         } else {
             self::$instances[$database]->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
         }
         self::$instances[$database]->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
     }
     self::$access++;
     return self::$instances[$database];
 }
Esempio n. 14
0
 public function run()
 {
     $config = Config::get('socket');
     $config = array('worker_num' => 4, 'task_worker_num' => 8, 'max_request' => 10000, 'dispatch_mode' => 2, 'debug_mode' => 0, 'daemonize' => false);
     if (isset($argv[1]) and $argv[1] == 'daemon') {
         $config['daemonize'] = true;
     } else {
         $config['daemonize'] = false;
     }
     $serv = new \swoole_server("0.0.0.0", 8808);
     $serv->set($config);
     $serv->config = $config;
     $handler = new Handler();
     $serv->on('Start', array($handler, "start"));
     $serv->on('Connect', array($handler, "connect"));
     $serv->on('Receive', array($handler, "receive"));
     $serv->on('Close', array($handler, "close"));
     $serv->on('Shutdown', array($handler, "shutdown"));
     $serv->on('Timer', array($handler, "timer"));
     $serv->on('WorkerStart', array($handler, "workStart"));
     $serv->on('WorkerStop', array($handler, "workStop"));
     $serv->on('Task', array($handler, "task"));
     $serv->on('Finish', array($handler, "finish"));
     $serv->on('WorkerError', array($handler, "workError"));
     $serv->start();
 }
Esempio n. 15
0
 public function getURL($params, $clean = true)
 {
     $request = \Core\Http\Request::getInstance();
     if ($clean) {
         $params = array_merge(array('module' => $request->getModule(), 'controller' => $request->getController(), 'action' => $request->getAction()), $params);
     } else {
         $p = $request->getParams();
         $names = array_keys($_POST);
         foreach ($p as $n => $v) {
             if (in_array($n, $names)) {
                 unset($p[$n]);
             }
         }
         $params = array_merge(array('module' => $request->getModule(), 'controller' => $request->getController(), 'action' => $request->getAction()), $p, $params);
     }
     $module = $params['module'];
     $controller = $params['controller'];
     $action = $params['action'];
     unset($params['module']);
     unset($params['controller']);
     unset($params['action']);
     $uri = \Core\Config::getInstance()->app['baseUrl'] . $module . '/' . $controller . '/' . $action . '/';
     if (!empty($params)) {
         $ps = array_keys($params);
         foreach ($ps as $param) {
             if ($param == session_name()) {
                 continue;
             }
             if (!is_null($params[$param])) {
                 $uri .= $param . '/' . $params[$param] . '/';
             }
         }
     }
     return $uri;
 }
function config($name, $value = null)
{
    if (!$value) {
        return Config::get($name);
    }
    Config::set($name, $value);
}
Esempio n. 17
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Заказы в один клик';
     $this->_seo['title'] = 'Заказы в один клик';
     $this->setBreadcrumbs('Заказы в один клик', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 18
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Характеристики';
     $this->_seo['title'] = 'Характеристики';
     $this->setBreadcrumbs('Характеристики', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 19
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Вопросы по товарам';
     $this->_seo['title'] = 'Вопросы по товарам';
     $this->setBreadcrumbs('Вопросы по товарам', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 20
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Управление городами';
     $this->_seo['title'] = 'Управление городами';
     $this->setBreadcrumbs('Управление городами', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 21
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Письма директору';
     $this->_seo['title'] = 'Письма директору';
     $this->setBreadcrumbs('Письма директору', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 22
0
 public function getUrl($params)
 {
     $path = $this->path;
     foreach ($params as $k => $v) {
         $path = str_replace(":{$k}:", $v, $path);
     }
     return Config::getInstance()->get('url') . $path;
 }
Esempio n. 23
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Сообщения из формы заказа звонка';
     $this->_seo['title'] = 'Сообщения из формы заказа звонка';
     $this->setBreadcrumbs('Сообщения из формы заказа звонка', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 24
0
 public function getDb()
 {
     $config = Config::getInstance(ROOT . '/config/config.php');
     if (is_null($this->db_instance)) {
         $this->db_instance = new MySQLDatabase($config->get("db_name"), $config->get("db_user"), $config->get("db_pass"), $config->get("db_host"));
     }
     return $this->db_instance;
 }
Esempio n. 25
0
 private function config()
 {
     $result = DB::select('key', 'zna')->from('config')->where('status', '=', 1)->find_all();
     foreach ($result as $obj) {
         Config::set($obj->key, $obj->zna);
     }
     $this->setBreadcrumbs('Главная', 'backend');
 }
Esempio n. 26
0
 public function handle()
 {
     $aConfig = c\Config::get('dsn');
     u\DB::connect($aConfig['data']);
     $aData = parent::handle();
     $aData['data']['host'] = "http://{$_SERVER['HTTP_HOST']}/?static=";
     return $aData;
 }
Esempio n. 27
0
 public function getDb()
 {
     $config = Config::getInstance(ROOT . '/config/config.php');
     if (is_null($this->db_instance)) {
         $this->db_instance = new MysqlDatabase($config->get('db_name'), $config->get('db_user'), $config->get('db_pass'), $config->get('db_host'));
     }
     return $this->db_instance;
 }
Esempio n. 28
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Банерная система';
     $this->_seo['title'] = 'Банерная система';
     $this->setBreadcrumbs('Банерная система', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }
Esempio n. 29
0
 /**
  * 定时从new_tao表删除指定状态的数据
  * 指定状态为:交易成功,等待卖家确认,管理员取消交易
  *
  *
  *
  */
 public function delFromTaoAction()
 {
     $status = \core\Config::item('transStaCode');
     $status = array($status->tranSuc, $status->buyHasCon, $status->adminCanceled);
     $newTaoModel = new NewTaoModel();
     $res = $newTaoModel->delDataByStatus($status);
     echo "删除{$res}条记录" . PHP_EOL;
 }
Esempio n. 30
0
 function before()
 {
     parent::before();
     $this->_seo['h1'] = 'Бронирование мест';
     $this->_seo['title'] = 'Бронирование мест';
     $this->setBreadcrumbs('Бронирование мест', 'backend/' . Route::controller() . '/index');
     $this->limit = Config::get('limit_backend');
 }