Пример #1
0
 function DatacallModule()
 {
     parent::__construct();
     $this->type = isset($_REQUEST['type']) ? intval($_REQUEST['type']) : 'goods';
     $this->call_mod =& af('datacall');
     $this->_gcategory_mod =& bm("gcategory");
 }
Пример #2
0
 function edit_growth($user_id, $behave, $order_amount = '')
 {
     $growth_value = 0;
     $model_growth =& af('growth');
     $growth = $model_growth->getAll();
     switch ($behave) {
         case 'register':
             $growth_value = $growth['register_growth'];
             break;
         case 'bought':
             $growth_value = $growth['bought_growth'] * $order_amount;
             break;
         case 'comment':
             $growth_value = $growth['comment_growth'];
             break;
     }
     $user = $this->get($user_id);
     $this->edit($user['user_id'], array('growth' => $growth_value + $user['growth']));
     //更新成长值
     $user = $this->get($user_id);
     //重新读取member表的数据
     $ugrade_mod =& m('ugrade');
     $ugrade = $ugrade_mod->get(array('conditions' => "floor_growth <= " . $user['growth'] . " AND (top_growth IS NULL || top_growth > " . $user['growth'] . " )", 'field' => 'grade'));
     $this->edit($user['user_id'], array('ugrade' => $ugrade['grade']));
     //更新等级
 }
Пример #3
0
 /**
  * Gets others plugins that have the `InstallShell` class
  * @return array
  */
 protected function _getOtherPlugins()
 {
     //Gets all plugins
     $plugins = Plugin::all(['exclude' => [METOOLS, MECMS]]);
     //Returns only the plugins that have the `InstallShell` class
     return af(array_map(function ($plugin) {
         return Plugin::path($plugin, 'src' . DS . 'Shell' . DS . 'InstallShell.php', true) ? $plugin : false;
     }, $plugins));
 }
Пример #4
0
 function ChannelApp()
 {
     parent::BackendApp();
     $this->_channel_mod =& af('channels');
     $this->_gcategory_mod =& bm('gcategory', array('_store_id' => 0));
     $this->_tpl_filepath = ROOT_PATH . '/themes/mall/' . $this->_get_template_name() . '/';
     $this->_tpl_confpath = ROOT_PATH . '/data/page_config/';
     $this->_tpl_url = SITE_URL . '/themes/mall/' . $this->_get_template_name() . '/styles/' . $this->_get_style_name();
 }
Пример #5
0
 /**
  * Gets all update methods.
  *
  * Each value contains the name method and the version number.
  * @return array
  */
 protected function _getAllUpdateMethods()
 {
     $methods = getChildMethods(get_called_class());
     return af(array_map(function ($method) {
         //Filters invalid method names
         if (!preg_match('/^to([0-9]+)v([0-9]+)v(.+)$/', $method, $matches)) {
             return false;
         }
         //Returns array with the name method and the version number
         return ['name' => $method, 'version' => sprintf('%s.%s.%s', $matches[1], $matches[2], $matches[3])];
     }, $methods));
 }
Пример #6
0
 public function configure_dovecot()
 {
     global $conf;
     $config_dir = $conf['dovecot']['config_dir'];
     //* Configure master.cf and add a line for deliver
     if (is_file($config_dir . '/master.cf')) {
         copy($config_dir . '/master.cf', $config_dir . '/master.cf~2');
     }
     if (is_file($config_dir . '/master.cf~')) {
         chmod($config_dir . '/master.cf~2', 0400);
     }
     $content = rf($conf["postfix"]["config_dir"] . '/master.cf');
     // Only add the content if we had not addded it before
     if (!stristr($content, "dovecot/deliver")) {
         $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe' . "\n" . '  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
         af($conf["postfix"]["config_dir"] . '/master.cf', $deliver_content);
     }
     unset($content);
     unset($deliver_content);
     //* Reconfigure postfix to use dovecot authentication
     // Adding the amavisd commands to the postfix configuration
     $postconf_commands = array('dovecot_destination_recipient_limit = 1', 'virtual_transport = dovecot', 'smtpd_sasl_type = dovecot', 'smtpd_sasl_path = private/auth');
     // Make a backup copy of the main.cf file
     copy($conf["postfix"]["config_dir"] . '/main.cf', $conf["postfix"]["config_dir"] . '/main.cf~3');
     // Executing the postconf commands
     foreach ($postconf_commands as $cmd) {
         $command = "postconf -e '{$cmd}'";
         caselog($command . " &> /dev/null", __FILE__, __LINE__, "EXECUTED: {$command}", "Failed to execute the command {$command}");
     }
     //* copy dovecot.conf
     $configfile = 'dovecot.conf';
     if (is_file($config_dir . '/' . $configfile)) {
         copy($config_dir . '/' . $configfile, $config_dir . '/' . $configfile . '~');
     }
     copy('tpl/debian6_dovecot.conf.master', $config_dir . '/' . $configfile);
     //* dovecot-sql.conf
     $configfile = 'dovecot-sql.conf';
     if (is_file($config_dir . '/' . $configfile)) {
         copy($config_dir . '/' . $configfile, $config_dir . '/' . $configfile . '~');
     }
     chmod($config_dir . '/' . $configfile . '~', 0400);
     $content = rf('tpl/debian6_dovecot-sql.conf.master');
     $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
     $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
     $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
     $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
     wf($config_dir . '/' . $configfile, $content);
     chmod($config_dir . '/' . $configfile, 0600);
     chown($config_dir . '/' . $configfile, 'root');
     chgrp($config_dir . '/' . $configfile, 'root');
 }
Пример #7
0
 /**
  * Lists logs
  * @return void
  */
 public function index()
 {
     //Gets all log files
     $logs = (new Folder(LOGS))->read(true, ['empty'])[1];
     $logs = af(array_map(function ($log) {
         //Return, if this is a serialized log
         if (preg_match('/_serialized\\.log$/i', $log)) {
             return;
         }
         //If this log has a serialized copy
         $serialized = is_readable(LOGS . sprintf('%s_serialized.log', pathinfo($log, PATHINFO_FILENAME)));
         return (object) am(['filename' => $log, 'size' => filesize(LOGS . $log)], compact('serialized'));
     }, $logs));
     $this->set(compact('logs'));
 }
Пример #8
0
 function set()
 {
     $template_name = isset($_GET['template_name']) ? trim($_GET['template_name']) : null;
     $style_name = isset($_GET['style_name']) ? trim($_GET['style_name']) : null;
     if (!$template_name) {
         $this->show_warning('no_such_template');
         return;
     }
     if (!$style_name) {
         $this->show_warning('no_such_style');
         return;
     }
     $af_setting =& af('settings');
     $af_setting->setAll(array('template_name' => $template_name, 'style_name' => $style_name));
     $this->show_message('set_theme_successed');
 }
Пример #9
0
 public function configure_amavis()
 {
     global $conf;
     // amavisd user config file
     $configfile = 'fedora_amavisd_conf';
     if (is_file($conf["amavis"]["config_dir"] . '/amavisd.conf')) {
         copy($conf["amavis"]["config_dir"] . '/amavisd.conf', $conf["amavis"]["config_dir"] . '/amavisd.conf~');
     }
     if (is_file($conf["amavis"]["config_dir"] . '/amavisd.conf~')) {
         exec('chmod 400 ' . $conf["amavis"]["config_dir"] . '/amavisd.conf~');
     }
     if (!is_dir($conf["amavis"]["config_dir"])) {
         mkdir($conf["amavis"]["config_dir"]);
     }
     $content = rf("tpl/" . $configfile . ".master");
     $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
     $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
     $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
     $content = str_replace('{mysql_server_port}', $conf["mysql"]["port"], $content);
     $content = str_replace('{mysql_server_ip}', $conf['mysql']['ip'], $content);
     $content = str_replace('{hostname}', $conf['hostname'], $content);
     $content = str_replace('/var/spool/amavisd/clamd.sock', '/var/run/clamav/clamd.sock', $content);
     wf($conf["amavis"]["config_dir"] . '/amavisd.conf', $content);
     // Adding the amavisd commands to the postfix configuration
     $postconf_commands = array('content_filter = amavis:[127.0.0.1]:10024', 'receive_override_options = no_address_mappings');
     // Make a backup copy of the main.cf file
     copy($conf["postfix"]["config_dir"] . '/main.cf', $conf["postfix"]["config_dir"] . '/main.cf~2');
     // Executing the postconf commands
     foreach ($postconf_commands as $cmd) {
         $command = "postconf -e '{$cmd}'";
         caselog($command . " &> /dev/null", __FILE__, __LINE__, "EXECUTED: {$command}", "Failed to execute the command {$command}");
     }
     // Append the configuration for amavisd to the master.cf file
     if (is_file($conf["postfix"]["config_dir"] . '/master.cf')) {
         copy($conf["postfix"]["config_dir"] . '/master.cf', $conf["postfix"]["config_dir"] . '/master.cf~');
     }
     $content = rf($conf["postfix"]["config_dir"] . '/master.cf');
     // Only add the content if we had not addded it before
     if (!stristr($content, "127.0.0.1:10025")) {
         unset($content);
         $content = rf("tpl/master_cf_amavis.master");
         af($conf["postfix"]["config_dir"] . '/master.cf', $content);
     }
     unset($content);
     removeLine('/etc/sysconfig/freshclam', 'FRESHCLAM_DELAY=disabled-warn   # REMOVE ME', 1);
     replaceLine('/etc/freshclam.conf', 'Example', '# Example', 1);
 }
Пример #10
0
 /**
  * 显示文本框及处理提交的用户信息
  *
  */
 function index()
 {
     if (!IS_POST) {
         $this->import_resource('jquery.plugins/jquery.validate.js');
         $this->display("find_password.html");
     } else {
         $addr = $_SERVER['HTTP_REFERER'];
         if (empty($_POST['username']) || empty($_POST['captcha'])) {
             $this->show_warning("unsettled_required", 'go_back', $addr);
             return;
         }
         if (base64_decode($_SESSION['captcha']) != strtolower($_POST['captcha'])) {
             $this->show_warning("captcha_faild", 'go_back', $addr);
             return;
         }
         $username = trim($_POST['username']);
         /* 简单验证是否是该用户 */
         $ms =& ms();
         //连接用户系统
         $info = $ms->user->get($username, true);
         if (empty($info)) {
             $this->show_warning('not_exist', 'go_back', $addr);
             return;
         }
         $this->import_resource('jquery.plugins/jquery.validate.js');
         $mod_member =& m('member');
         $info1 = $mod_member->get($info['user_id']);
         $this->assign('user', $info1);
         $model_msg =& af('msg');
         $setting = $model_msg->getAll();
         //载入设置数据
         if ($setting['msg_status']['find_password']) {
             $this->assign('phone_code', 1);
         }
         $this->assign('email', substr_replace($info['email'], '****', 3, -10));
         $this->assign('phone_mob', substr_replace($info1['phone_mob'], '****', 3, -4));
         $this->display("find_password.step2.html");
     }
 }
Пример #11
0
 function ShareApp()
 {
     parent::BackendApp();
     $this->_m_share =& af('share');
 }
Пример #12
0
 public function configure_nginx()
 {
     global $conf;
     if ($conf['nginx']['installed'] == false) {
         return;
     }
     //* Create the logging directory for the vhost logfiles
     if (!@is_dir($conf['ispconfig_log_dir'] . '/httpd')) {
         mkdir($conf['ispconfig_log_dir'] . '/httpd', 0755, true);
     }
     // Sites enabled and available dirs
     exec('mkdir -p ' . $conf['nginx']['vhost_conf_enabled_dir']);
     exec('mkdir -p ' . $conf['nginx']['vhost_conf_dir']);
     $content = rf('/etc/nginx/nginx.conf');
     if (stripos($content, 'include /etc/nginx/sites-enabled/*.vhost;') === false) {
         $content = trim($content);
         $content = substr($content, 0, -1) . "\n    include /etc/nginx/sites-enabled/*.vhost;\n}";
         wf('/etc/nginx/nginx.conf', $content);
     }
     unset($content);
     // create PHP-FPM pool dir
     exec('mkdir -p ' . $conf['nginx']['php_fpm_pool_dir']);
     $content = rf('/etc/php5/fpm/php-fpm.conf');
     if (stripos($content, 'include=/etc/php5/fpm/pool.d/*.conf') === false) {
         af('/etc/php5/fpm/php-fpm.conf', "\ninclude=/etc/php5/fpm/pool.d/*.conf");
     }
     unset($content);
     if (!@is_file($conf['nginx']['php_fpm_ini_path'])) {
         if (@is_file('/etc/php5/cli/php.ini')) {
             exec('cp -f /etc/php5/cli/php.ini ' . $conf['nginx']['php_fpm_ini_path']);
         } elseif (@is_file('/etc/php5/fastcgi/php.ini')) {
             exec('cp -f /etc/php5/fastcgi/php.ini ' . $conf['nginx']['php_fpm_ini_path']);
         } elseif (@is_file('/etc/php5/apache2/php.ini')) {
             exec('cp -f /etc/php5/apache2/php.ini ' . $conf['nginx']['php_fpm_ini_path']);
         }
     }
     //* make sure that webalizer finds its config file when it is directly in /etc
     if (@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
         mkdir('/etc/webalizer');
         symlink('/etc/webalizer.conf', '/etc/webalizer/webalizer.conf');
     }
     if (is_file('/etc/webalizer/webalizer.conf')) {
         // Change webalizer mode to incremental
         replaceLine('/etc/webalizer/webalizer.conf', '#IncrementalName', 'IncrementalName webalizer.current', 0, 0);
         replaceLine('/etc/webalizer/webalizer.conf', '#Incremental', 'Incremental     yes', 0, 0);
         replaceLine('/etc/webalizer/webalizer.conf', '#HistoryName', 'HistoryName     webalizer.hist', 0, 0);
     }
     // Check the awsatst script
     if (!is_dir('/usr/share/awstats/tools')) {
         exec('mkdir -p /usr/share/awstats/tools');
     }
     if (!file_exists('/usr/share/awstats/tools/awstats_buildstaticpages.pl') && file_exists('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl')) {
         symlink('/usr/share/doc/awstats/examples/awstats_buildstaticpages.pl', '/usr/share/awstats/tools/awstats_buildstaticpages.pl');
     }
     if (file_exists('/etc/awstats/awstats.conf.local')) {
         replaceLine('/etc/awstats/awstats.conf.local', 'LogFormat=4', 'LogFormat=1', 0, 1);
     }
     //* add a sshusers group
     $command = 'groupadd sshusers';
     if (!is_group('sshusers')) {
         caselog($command . ' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: {$command}", "Failed to execute the command {$command}");
     }
 }
Пример #13
0
 function ECBaseApp()
 {
     parent::__construct();
     if (!defined('MODULE')) {
         /* GZIP */
         if ($this->gzip_enabled()) {
             ob_start('ob_gzhandler');
         } else {
             ob_start();
         }
         /* 非utf8转码 */
         if (CHARSET != 'utf-8' && isset($_REQUEST['ajax'])) {
             $_FILES = ecm_iconv_deep('utf-8', CHARSET, $_FILES);
             $_GET = ecm_iconv_deep('utf-8', CHARSET, $_GET);
             $_POST = ecm_iconv_deep('utf-8', CHARSET, $_POST);
         }
         /* 载入配置项 */
         $setting =& af('settings');
         Conf::load($setting->getAll());
         /* 初始化访问者(放在此可能产生问题) */
         $this->_init_visitor();
         /* 计划任务守护进程 */
         $this->_run_cron();
     }
 }
Пример #14
0
 function growth_value()
 {
     $model_growth =& af('growth');
     $growth = $model_growth->getAll();
     if (!IS_POST) {
         $this->import_resource(array('script' => 'jquery.plugins/jquery.validate.js'));
         $this->assign('growth', $growth);
         $this->display('ugrade_growth.html');
     } else {
         $data['register_growth'] = $_POST['register_growth'];
         $data['bought_growth'] = $_POST['bought_growth'];
         $data['comment_growth'] = $_POST['comment_growth'];
         $model_growth->setAll($data);
         $this->show_message('edit_ok');
     }
 }
Пример #15
0
 function _af()
 {
     $m = null;
     empty($_GET['type']) && ($_GET['type'] = NOTICE_MAIL);
     $this->_type = $_GET['type'] == NOTICE_MAIL ? NOTICE_MAIL : NOTICE_MSG;
     switch ($this->_type) {
         case NOTICE_MAIL:
             $m =& af('mailtemplate');
             break;
         case NOTICE_MSG:
             $m =& af('msgtemplate');
             break;
         default:
             $m =& af('mailtemplate');
     }
     return $m;
 }
Пример #16
0
/**
 *    获取邮件内容
 *
 *    @author    Garbin
 *    @param     string $mail_tpl
 *    @param     array  $var
 *    @return    array
 */
function get_mail($mail_tpl, $var = array())
{
    $subject = '';
    $message = '';
    /* 获取邮件模板 */
    $model_mailtemplate =& af('mailtemplate');
    $tpl_info = $model_mailtemplate->getOne($mail_tpl);
    if (!$tpl_info) {
        return false;
    }
    /* 解析其中变量 */
    $tpl =& v(true);
    $tpl->direct_output = true;
    $tpl->assign('site_name', Conf::get('site_name'));
    $tpl->assign('site_url', SITE_URL);
    $tpl->assign('mail_send_time', local_date('Y-m-d H:i', gmtime()));
    foreach ($var as $key => $val) {
        $tpl->assign($key, $val);
    }
    $subject = $tpl->fetch('str:' . $tpl_info['subject']);
    $message = $tpl->fetch('str:' . $tpl_info['content']);
    /* 返回邮件 */
    return array('subject' => $subject, 'message' => $message);
}
Пример #17
0
 function DatacallModule()
 {
     parent::__construct();
     $this->_datacall_mod =& af("datacall");
 }
Пример #18
0
 function Sms_Get($method = '', $phone = '', $text = '', $user_id = 0)
 {
     $model_msg =& af('msg');
     $setting = $model_msg->getAll();
     //载入设置数据
     // 获取短信条数接口
     if ($method == 'SMS_Num') {
         if (strtoupper(CHARSET) == 'GBK') {
             $gateway = 'http://sms.webchinese.cn/web_api/SMS/GBK/?Action=SMS_Num&';
         } else {
             $gateway = 'http://sms.webchinese.cn/web_api/SMS/?Action=SMS_Num&';
         }
         $url = $gateway . 'Uid=' . $setting['msg_pid'] . '&Key=' . $setting['msg_key'];
         return ecm_fopen($url);
     } else {
         if (strtoupper(CHARSET) == 'GBK') {
             $gateway = 'http://gbk.sms.webchinese.cn/?';
         } else {
             $gateway = 'http://utf8.sms.webchinese.cn/?';
         }
         $url = $gateway . 'Uid=' . $setting['msg_pid'] . '&Key=' . $setting['msg_key'] . '&smsMob=' . $phone . '&smsText=' . urlencode($text);
         $mod_msglog =& m('msglog');
         $res = ecm_fopen($url);
         if ($res > 0) {
             $mod_msgstatistics =& m('msgstatistics');
             $mod_msgstatistics->edit(0, "used = used +" . $res);
             //已经使用短信数,写入统计
             if ($user_id > 0) {
                 $mod_msg =& m('msg');
                 $mod_msg->edit("user_id='{$user_id}'", "num = num - " . $res);
                 //如果是用户发送减少用户的短信数
             }
             $add_msglog = array('user_id' => $user_id, 'to_mobile' => $phone, 'content' => $text, 'quantity' => $res, 'state' => 1, 'result' => $res, 'time' => gmtime());
             $mod_msglog->add($add_msglog);
         } else {
             $add_msglog = array('user_id' => $user_id, 'to_mobile' => $phone, 'content' => $text, 'quantity' => 0, 'state' => 0, 'result' => $res, 'time' => gmtime());
             $mod_msglog->add($add_msglog);
         }
         return $res;
     }
 }
 public function configure_apache()
 {
     global $conf;
     if ($conf['apache']['installed'] == false) {
         return;
     }
     if (is_file('/etc/suphp.conf')) {
         //replaceLine('/etc/suphp.conf','php=php:/usr/bin','x-httpd-suphp=php:/usr/bin/php-cgi',0);
         replaceLine('/etc/suphp.conf', 'docroot=', 'docroot=/home/www', 0);
         replaceLine('/etc/suphp.conf', 'umask=0077', 'umask=0022', 0);
     }
     //* Create the logging directory for the vhost logfiles
     exec('mkdir -p /var/log/ispconfig/httpd');
     // Sites enabled and avaulable dirs
     exec('mkdir -p ' . $conf['apache']['vhost_conf_enabled_dir']);
     exec('mkdir -p ' . $conf['apache']['vhost_conf_dir']);
     $content = rf('/etc/httpd/conf/httpd.conf');
     if (!stristr($content, 'Include /etc/httpd/conf/sites-enabled/')) {
         af('/etc/httpd/conf/httpd.conf', "\nNameVirtualHost *:80\nNameVirtualHost *:8443\nInclude /etc/httpd/conf/sites-enabled/\n\n");
     }
     unset($content);
     //* Copy the ISPConfig configuration include
     $vhost_conf_dir = $conf['apache']['vhost_conf_dir'];
     $vhost_conf_enabled_dir = $conf['apache']['vhost_conf_enabled_dir'];
     $tpl = new tpl('apache_ispconfig.conf.master');
     $tpl->setVar('apache_version', getapacheversion());
     $records = $this->db->queryAllRecords('SELECT * FROM ' . $conf['mysql']['master_database'] . '.server_ip WHERE server_id = ' . $conf['server_id'] . " AND virtualhost = 'y'");
     $ip_addresses = array();
     if (is_array($records) && count($records) > 0) {
         foreach ($records as $rec) {
             if ($rec['ip_type'] == 'IPv6') {
                 $ip_address = '[' . $rec['ip_address'] . ']';
             } else {
                 $ip_address = $rec['ip_address'];
             }
             $ports = explode(',', $rec['virtualhost_port']);
             if (is_array($ports)) {
                 foreach ($ports as $port) {
                     $port = intval($port);
                     if ($port > 0 && $port < 65536 && $ip_address != '') {
                         $ip_addresses[] = array('ip_address' => $ip_address, 'port' => $port);
                     }
                 }
             }
         }
     }
     if (count($ip_addresses) > 0) {
         $tpl->setLoop('ip_adresses', $ip_addresses);
     }
     wf($vhost_conf_dir . '/ispconfig.conf', $tpl->grab());
     unset($tpl);
     if (!@is_link($vhost_conf_enabled_dir . "/000-ispconfig.conf")) {
         exec("ln -s " . $vhost_conf_dir . "/ispconfig.conf " . $vhost_conf_enabled_dir . "/000-ispconfig.conf");
     }
     //* make sure that webalizer finds its config file when it is directly in /etc
     if (@is_file('/etc/webalizer.conf') && !@is_dir('/etc/webalizer')) {
         exec('mkdir /etc/webalizer');
         exec('ln -s /etc/webalizer.conf /etc/webalizer/webalizer.conf');
     }
     if (is_file('/etc/webalizer/webalizer.conf')) {
         // Change webalizer mode to incremental
         replaceLine('/etc/webalizer/webalizer.conf', '#IncrementalName', 'IncrementalName webalizer.current', 0, 0);
         replaceLine('/etc/webalizer/webalizer.conf', '#Incremental', 'Incremental     yes', 0, 0);
         replaceLine('/etc/webalizer/webalizer.conf', '#HistoryName', 'HistoryName     webalizer.hist', 0, 0);
     }
     //* add a sshusers group
     $command = 'groupadd sshusers';
     if (!is_group('sshusers')) {
         caselog($command . ' &> /dev/null 2> /dev/null', __FILE__, __LINE__, "EXECUTED: {$command}", "Failed to execute the command {$command}");
     }
 }
Пример #20
0
 function SettingApp()
 {
     parent::BackendApp();
     $_POST = stripslashes_deep($_POST);
     $this->model_setting =& af('settings');
 }
Пример #21
0
 /**
  * Changes tags from string to array
  * @param string $tags Tags
  * @return array Tags
  */
 public function tagsAsArray($tags)
 {
     return af(array_map(function ($tag) {
         return trim($tag) ? compact('tag') : null;
     }, preg_split('/\\s*,+\\s*/', $tags)));
 }
Пример #22
0
 function index()
 {
     // 查询参数
     $param = $this->_get_query_param();
     // 验证当前请求地址,是否需要跳转到频道页  psmb
     /**/
     $check_param_for_channel = true;
     if (isset($param['cate_id']) && $param['cate_id'] > 0) {
         foreach ($param as $k => $v) {
             if (!empty($v) && ($k != 'cate_id' && $k != 'layer')) {
                 $check_param_for_channel = false;
             }
         }
         // 如果当前请求的地址,只要一个 cate_id 参数,则检验当前 cate_id 是否有对应的频道页
         if ($check_param_for_channel === true) {
             $channel_mod =& af('channels');
             $channel_list = $channel_mod->getAll();
             if ($channel_list) {
                 foreach ($channel_list as $k => $v) {
                     if ($v['cate_id'] == $param['cate_id'] && $v['status'] == 1) {
                         header('Location:' . SITE_URL . '/index.php?app=channel&id=' . $k);
                         break;
                     }
                 }
             }
         }
     }
     // end psmb
     if (isset($param['cate_id']) && $param['layer'] === false) {
         $this->show_warning('no_such_category');
         return;
     }
     /* 筛选条件 */
     $this->assign('filters', $this->_get_filter($param));
     /* 按分类、品牌、地区、价格区间统计商品数量 */
     $stats = $this->_get_group_by_info($param, ENABLE_SEARCH_CACHE);
     $this->assign('categories', $stats['by_category']);
     $this->assign('category_count', count($stats['by_category']));
     if ($stats['by_brand']) {
         foreach ($stats['by_brand'] as $key => $val) {
             if ($this->filter_select_brand($val['brand'])) {
                 $stats['by_brand'][$key]['brand_logo'] = $this->filter_select_brand($val['brand']);
             }
         }
     }
     $this->assign('brands', $stats['by_brand']);
     $this->assign('brand_count', count($stats['by_brand']));
     $this->assign('price_intervals', $stats['by_price']);
     $this->assign('cate_id', $param['cate_id'] ? $param['cate_id'] : 0);
     $this->assign('regions', $stats['by_region']);
     $this->assign('region_count', count($stats['by_region']));
     // sku psmb
     $this->assign('props', $stats['by_props']);
     $this->assign('props_selected', isset($param['props']) ? $param['props'] . ';' : '');
     $this->assign('props_count', count($stats['by_props']));
     /* 排序 */
     $orders = $this->_get_orders();
     $this->assign('orders', $orders);
     /* 分页信息 */
     $page = $this->_get_page(NUM_PER_PAGE);
     $page['item_count'] = $stats['total_count'];
     $this->_format_page($page);
     $this->assign('page_info', $page);
     /* 商品列表 */
     $sgrade_mod =& m('sgrade');
     $sgrades = $sgrade_mod->get_options();
     $conditions = $this->_get_goods_conditions($param);
     $goods_mod =& m('goods');
     $goods_list = $goods_mod->get_list(array('conditions' => $conditions, 'order' => isset($_GET['order']) && isset($orders[$_GET['order']]) ? $_GET['order'] : '', 'limit' => $page['limit']));
     $goodsimage_mod =& m('goodsimage');
     foreach ($goods_list as $key => $goods) {
         $step = intval(Conf::get('upgrade_required'));
         $step < 1 && ($step = 5);
         $store_mod =& m('store');
         $goods_list[$key]['credit_image'] = $this->_view->res_base . '/images/' . $store_mod->compute_credit($goods['credit_value'], $step);
         empty($goods['default_image']) && ($goods_list[$key]['default_image'] = Conf::get('default_goods_image'));
         if ($param['cate_id'] == 21 || $param['cate_id'] == 272) {
             if ($goods['default_image']) {
                 $goods_list[$key]['default_image'] = str_replace("small_", "", $goods['default_image']);
             }
         }
         $spec_image = $goodsimage_mod->find('goods_id=' . $goods['goods_id']);
         if (count($spec_image) > 1) {
             $current_pic = current($spec_image);
             if ($current_pic['image_url'] !== $goods_list[$key]['default_image']) {
                 $image = $current_pic['image_url'];
             } else {
                 $next_pic = next($spec_image);
                 $image = $next_pic['image_url'];
             }
             $goods_list[$key]['another_image'] = $image;
         } else {
             $goods_list[$key]['another_image'] = $goods_list[$key]['default_image'];
         }
         $goods_list[$key]['grade_name'] = $sgrades[$goods['sgrade']];
     }
     $this->assign('goods_list', $goods_list);
     /* 商品展示方式 */
     $display_mode = ecm_getcookie('goodsDisplayMode');
     if (empty($display_mode) || !in_array($display_mode, array('list', 'squares'))) {
         $display_mode = 'squares';
         // 默认格子方式
     }
     $this->assign('display_mode', $display_mode);
     /* 取得导航 */
     $this->assign('navs', $this->_get_navs());
     /* 当前位置 */
     $cate_id = isset($param['cate_id']) ? $param['cate_id'] : 0;
     $this->_curlocal($this->_get_goods_curlocal($cate_id));
     /* 配置seo信息 */
     $this->_config_seo($this->_get_seo_info('goods', $cate_id));
     $this->display('search.goods.html');
 }
Пример #23
0
 function ECBaseApp()
 {
     parent::__construct();
     if (!defined('MODULE')) {
         /* GZIP */
         if ($this->gzip_enabled()) {
             ob_start('ob_gzhandler');
         } else {
             ob_start();
         }
         /* 非utf8转码 */
         if (CHARSET != 'utf-8' && isset($_REQUEST['ajax'])) {
             $_FILES = ecm_iconv_deep('utf-8', CHARSET, $_FILES);
             $_GET = ecm_iconv_deep('utf-8', CHARSET, $_GET);
             $_POST = ecm_iconv_deep('utf-8', CHARSET, $_POST);
         }
         /* 载入配置项 */
         $setting =& af('settings');
         Conf::load($setting->getAll());
         //TODO 随语言自动切换模板
         //settings.inc.php中有   'template_name' => 'default','style_name' => 'default',
         if (isset($GLOBALS['ECMALL_CONFIG']['template_name'])) {
             $GLOBALS['ECMALL_CONFIG']['template_name'] = LANG;
             //                if(isset($GLOBALS['my_language']))
             //                {
             //                    $templang=trim($GLOBALS['my_language']);
             //                    if(!$templang=='')
             //                    {
             //                        $GLOBALS['ECMALL_CONFIG']['template_name']=$templang;
             //                    }
             //                }
         }
         /* 初始化访问者(放在此可能产生问题) */
         $this->_init_visitor();
         /* 计划任务守护进程 */
         $this->_run_cron();
     }
 }
Пример #24
0
 public function configure_dovecot()
 {
     global $conf;
     $config_dir = $conf['dovecot']['config_dir'];
     //* Configure master.cf and add a line for deliver
     if (is_file($config_dir . '/master.cf')) {
         copy($config_dir . '/master.cf', $config_dir . '/master.cf~2');
     }
     if (is_file($config_dir . '/master.cf~')) {
         chmod($config_dir . '/master.cf~2', 0400);
     }
     $content = rf($conf["postfix"]["config_dir"] . '/master.cf');
     // Only add the content if we had not addded it before
     if (!stristr($content, "dovecot/deliver")) {
         $deliver_content = 'dovecot   unix  -       n       n       -       -       pipe' . "\n" . '  flags=DRhu user=vmail:vmail argv=/usr/lib/dovecot/deliver -f ${sender} -d ${user}@${nexthop}';
         af($conf["postfix"]["config_dir"] . '/master.cf', $deliver_content);
     }
     unset($content);
     unset($deliver_content);
     //* Reconfigure postfix to use dovecot authentication
     // Adding the amavisd commands to the postfix configuration
     $postconf_commands = array('dovecot_destination_recipient_limit = 1', 'virtual_transport = dovecot', 'smtpd_sasl_type = dovecot', 'smtpd_sasl_path = private/auth');
     // Make a backup copy of the main.cf file
     copy($conf["postfix"]["config_dir"] . '/main.cf', $conf["postfix"]["config_dir"] . '/main.cf~3');
     // Executing the postconf commands
     foreach ($postconf_commands as $cmd) {
         $command = "postconf -e '{$cmd}'";
         caselog($command . " &> /dev/null", __FILE__, __LINE__, "EXECUTED: {$command}", "Failed to execute the command {$command}");
     }
     //* copy dovecot.conf
     $configfile = 'dovecot.conf';
     if (is_file($config_dir . '/' . $configfile)) {
         copy($config_dir . '/' . $configfile, $config_dir . '/' . $configfile . '~');
     }
     //* Get the dovecot version
     exec('dovecot --version', $tmp);
     $dovecot_version = $tmp[0];
     unset($tmp);
     //* Copy dovecot configuration file
     if (version_compare($dovecot_version, 2) >= 0) {
         if (is_file($conf['ispconfig_install_dir'] . '/server/conf-custom/install/debian6_dovecot2.conf.master')) {
             copy($conf['ispconfig_install_dir'] . '/server/conf-custom/install/debian6_dovecot2.conf.master', $config_dir . '/' . $configfile);
         } else {
             copy('tpl/debian6_dovecot2.conf.master', $config_dir . '/' . $configfile);
         }
         replaceLine($config_dir . '/' . $configfile, 'postmaster_address = postmaster@example.com', 'postmaster_address = postmaster@' . $conf['hostname'], 1, 0);
         if (version_compare($dovecot_version, 2.1) < 0) {
             removeLine($config_dir . '/' . $configfile, 'ssl_protocols =');
         }
     } else {
         if (is_file($conf['ispconfig_install_dir'] . '/server/conf-custom/install/debian6_dovecot.conf.master')) {
             copy($conf['ispconfig_install_dir'] . '/server/conf-custom/install/debian6_dovecot.conf.master', $config_dir . '/' . $configfile);
         } else {
             copy('tpl/debian6_dovecot.conf.master', $config_dir . '/' . $configfile);
         }
     }
     //* dovecot-sql.conf
     $configfile = 'dovecot-sql.conf';
     if (is_file($config_dir . '/' . $configfile)) {
         copy($config_dir . '/' . $configfile, $config_dir . '/' . $configfile . '~');
         chmod($config_dir . '/' . $configfile . '~', 0400);
     }
     $content = rfsel($conf['ispconfig_install_dir'] . '/server/conf-custom/install/debian6_dovecot-sql.conf.master', 'tpl/debian6_dovecot-sql.conf.master');
     $content = str_replace('{mysql_server_ispconfig_user}', $conf['mysql']['ispconfig_user'], $content);
     $content = str_replace('{mysql_server_ispconfig_password}', $conf['mysql']['ispconfig_password'], $content);
     $content = str_replace('{mysql_server_database}', $conf['mysql']['database'], $content);
     $content = str_replace('{mysql_server_host}', $conf['mysql']['host'], $content);
     $content = str_replace('{server_id}', $conf['server_id'], $content);
     wf($config_dir . '/' . $configfile, $content);
     chmod($config_dir . '/' . $configfile, 0600);
     chown($config_dir . '/' . $configfile, 'root');
     chgrp($config_dir . '/' . $configfile, 'root');
     // Dovecot shall ignore mounts in website directory
     if (is_installed('doveadm')) {
         exec("doveadm mount add '/var/www/*' ignore > /dev/null 2> /dev/null");
     }
 }
Пример #25
0
 /**
  *    二级域名设置
  *
  *    @author    Garbin
  *    @return    void
  */
 function subdomain_setting()
 {
     $model_setting =& af('settings');
     $setting = $model_setting->getAll();
     //载入系统设置数据
     if (!IS_POST) {
         $this->assign('setting', $setting);
         $this->assign('config', array('enabled_subdomain' => ENABLED_SUBDOMAIN, 'subdomain_suffix' => defined('SUBDOMAIN_SUFFIX') ? SUBDOMAIN_SUFFIX : ''));
         $this->assign('yes_or_no', array(Lang::get('no'), Lang::get('yes')));
         $this->display('setting.subdomain_setting.html');
     } else {
         /* 初始化 */
         $subdomain_reserved = empty($_POST['subdomain_reserved']) ? '' : trim($_POST['subdomain_reserved']);
         $subdomain_length = empty($_POST['subdomain_length']) ? '' : trim($_POST['subdomain_length']);
         $enabled_subdomain = empty($_POST['enabled_subdomain']) ? 0 : intval($_POST['enabled_subdomain']);
         $subdomain_suffix = empty($_POST['subdomain_suffix']) ? '' : trim($_POST['subdomain_suffix']);
         /* Setting */
         $data['subdomain_reserved'] = $subdomain_reserved;
         $data['subdomain_length'] = $subdomain_length;
         /* Config */
         $config_file = ROOT_PATH . '/data/config.inc.php';
         $config = (include $config_file);
         $config['ENABLED_SUBDOMAIN'] = $enabled_subdomain;
         $config['SUBDOMAIN_SUFFIX'] = $subdomain_suffix;
         $new_config = var_export($config, true);
         /* 写入 */
         $model_setting->setAll($data);
         file_put_contents($config_file, "<?php\r\n\r\nreturn {$new_config};\r\n\r\n?>");
         $this->show_message('edit_subdomain_setting_successed');
     }
 }
Пример #26
0
 /**
  * 自动取消
  */
 function _auto_cancel()
 {
     $now = gmtime();
     //载入系统设置数据
     $model_setting =& af('settings');
     $setting = $model_setting->getAll();
     /* 默认2小时 */
     $auto_cancel_minutes = $setting['auto_deal']['auto_cancel'];
     $interval = empty($this->_config['cancel_interval']) ? $auto_cancel_minutes * 60 : intval($this->_config['cancel_interval']);
     $model_order =& m('order');
     /* 取消订单 */
     //已下订单
     $orders = $model_order->find(array('fields' => 'order_id', 'conditions' => "add_time + {$interval} < {$now} AND status = " . ORDER_PENDING));
     /* 操作日志 */
     $order_logs = array();
     $order_pending = order_status(ORDER_PENDING);
     $order_canceled = order_status(ORDER_CANCELED);
     if (!empty($orders)) {
         /* 更新订单状态 */
         $model_order->edit(array_keys($orders), array('status' => ORDER_CANCELED, 'finished_time' => gmtime()));
         /* 操作记录 */
         foreach ($orders as $order_id => $order) {
             $order_logs[] = array('order_id' => $order_id, 'operator' => '0', 'order_status' => $order_pending, 'changed_status' => $order_canceled, 'remark' => '', 'log_time' => $now);
         }
     }
     $order_log =& m('orderlog');
     $order_log->add($order_logs);
 }
Пример #27
0
 public function configure_bind()
 {
     global $conf;
     //* Check if the zonefile directory has a slash at the end
     $content = $conf['bind']['bind_zonefiles_dir'];
     if (substr($content, -1, 1) != '/') {
         $content .= '/';
     }
     //* New default format of named.conf uses views. Check which version the system is using and include our zones file.
     $named_conf = rf($conf['bind']['named_conf_path']);
     if (stripos($named_conf, 'include "' . $conf['bind']['named_conf_local_path'] . '";') === false) {
         preg_match_all("/(?<=\n)view \"(?:public|internal)\" in \\{.*\n\\};/Us", $named_conf, $views);
         if (count($views[0]) == 2) {
             foreach ($views[0] as $view) {
                 $named_conf = str_replace($view, substr($view, 0, -2) . "include \"{$conf['bind']['named_conf_local_path']}\";\n};", $named_conf);
             }
             wf($conf['bind']['named_conf_path'], $named_conf);
         } else {
             af($conf['bind']['named_conf_path'], 'include "' . $conf['bind']['named_conf_local_path'] . '";');
         }
     }
 }
Пример #28
0
 /**
  * Gets the title for a static page
  * @param string $slug Slug
  * @return string
  */
 public static function title($slug)
 {
     $slug = af(explode('/', $slug));
     $slug = str_replace('-', '_', $slug[count($slug) - 1]);
     return Inflector::humanize($slug);
 }
Пример #29
0
 function _get_share($goods)
 {
     $m_share =& af('share');
     $shares = $m_share->getAll();
     $shares = array_msort($shares, array('sort_order' => SORT_ASC));
     $goods_name = ecm_iconv(CHARSET, 'utf-8', $goods['goods_name']);
     $goods_url = urlencode(SITE_URL . '/' . str_replace('&amp;', '&', url('app=goods&id=' . $goods['goods_id'])));
     $site_title = ecm_iconv(CHARSET, 'utf-8', Conf::get('site_title'));
     $share_title = urlencode($goods_name . '-' . $site_title);
     foreach ($shares as $share_id => $share) {
         $shares[$share_id]['link'] = str_replace(array('{$link}', '{$title}'), array($goods_url, $share_title), $share['link']);
     }
     return $shares;
 }
 function MailtemplateApp()
 {
     parent::BackendApp();
     $this->_mailtemplate_mod =& af('mailtemplate');
 }