public function index() { $this->id = "content"; $this->template = "login/login.tpl"; $this->layout = "common/layout-empty"; if (Registry::get('username')) { header("Location: search.php"); exit; } $request = Registry::get('request'); $session = Registry::get('session'); $db = Registry::get('db'); $this->load->model('user/auth'); $this->load->model('user/user'); $this->load->model('user/prefs'); $this->load->model('domain/domain'); $this->load->model('folder/folder'); if (ENABLE_SAAS == 1) { $this->load->model('saas/ldap'); $this->load->model('saas/customer'); } $this->data['title'] = $this->data['text_login']; $this->data['title_prefix'] = TITLE_PREFIX; $this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count(); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) { if ($this->model_user_auth->checkLogin($this->request->post['username'], $_POST['password']) == 1) { if ($session->get("ga_block") == 1) { header("Location: " . SITE_URL . "index.php?route=login/ga"); exit; } else { $this->model_user_prefs->get_user_preferences($session->get('username')); if (ENABLE_SAAS == 1) { $this->model_saas_customer->online($session->get('email')); } LOGGER('logged in'); if (isAdminUser() == 1) { header("Location: " . SITE_URL . "index.php?route=health/health"); exit; } header("Location: " . SITE_URL . "search.php"); exit; } } else { $this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']); $this->data['failed_login_count']++; } $this->data['x'] = $this->data['text_invalid_email_or_password']; } if (ENABLE_GOOGLE_LOGIN == 1) { $client = new apiClient(); $client->setApplicationName(GOOGLE_APPLICATION_NAME); $client->setScopes(array('https://www.googleapis.com/auth/userinfo.email', 'https://www.googleapis.com/auth/userinfo.profile', 'https://mail.google.com/')); $client->setClientId(GOOGLE_CLIENT_ID); $client->setClientSecret(GOOGLE_CLIENT_SECRET); $client->setRedirectUri(GOOGLE_REDIRECT_URL); $client->setDeveloperKey(GOOGLE_DEVELOPER_KEY); $this->data['auth_url'] = $client->createAuthUrl(); } $this->render(); }
/** * @param CFilterChain $filterChain * @return bool * @throws CHttpException */ protected function preFilter($filterChain) { $app = Yii::app(); $bIsAdmin = false; if (function_exists('isAdminUser')) { $bIsAdmin = isAdminUser(); } else { /** @var emailModule $email */ $email = $app->getModule('email'); if (in_array($app->getUser()->getName(), $email->adminUsers)) { $bIsAdmin = true; } } if (!$bIsAdmin) { throw new CHttpException(403, 'You are not allowed to access this page.'); } return parent::preFilter($filterChain); }
public function index() { $this->id = "content"; $this->template = "user/settings.tpl"; $this->layout = "common/layout"; $request = Registry::get('request'); $session = Registry::get('session'); $db = Registry::get('db'); $this->load->model('user/auth'); $this->load->model('user/prefs'); $this->load->model('user/user'); $this->load->model('group/group'); require DIR_BASE . 'system/helper/PHPGangsta_GoogleAuthenticator.php'; $this->data['ga'] = $this->model_user_prefs->get_ga_settings($session->get('username')); $this->document->title = $this->data['text_settings']; $d = $r = ''; $auditemails = $auditdomains = $auditgroups = $auditfolders = ''; $auditemails = implode(", ", $session->get("emails")); $_auditdomains = $session->get("auditdomains"); foreach ($_auditdomains as $d) { $auditdomains .= ', ' . $d; } $auditdomains = preg_replace("/^,\\s/", "", $auditdomains); $auditgroups = preg_replace("/\\s/", ", ", $this->model_group_group->get_groups_by_email($session->get("emails"))); $folders = $session->get("folders"); foreach ($folders as $r) { $auditfolders .= ', ' . $r; } $auditfolders = preg_replace("/^,\\s/", "", $auditfolders); if ($auditemails) { $this->data['emails'] = $auditemails; } else { $this->data['emails'] = $this->data['text_none_found']; } if ($auditdomains) { $this->data['domains'] = $auditdomains; } else { $this->data['domains'] = $this->data['text_none_found']; } if ($auditgroups) { $this->data['groups'] = $auditgroups; } else { $this->data['groups'] = $this->data['text_none_found']; } if ($auditfolders) { $this->data['folders'] = $auditfolders; } else { $this->data['folders'] = $this->data['text_none_found']; } if (isset($this->request->post['pagelen']) && isset($this->request->post['theme'])) { $this->model_user_prefs->set_user_preferences(Registry::get('username'), $this->request->post); AUDIT(ACTION_CHANGE_USER_SETTINGS, '', '', '', 'pagelen:' . $this->request->post['pagelen'] . ', theme:' . $this->request->post['theme'] . ', lang:' . $this->request->post['lang']); if (isAdminUser() == 1) { header("Location: " . SITE_URL . "index.php?route=health/health"); return; } header("Location: " . SITE_URL . "search.php"); return; } if ($this->request->server['REQUEST_METHOD'] == 'POST' && PASSWORD_CHANGE_ENABLED == 1 && $this->validate() == true) { if ($this->model_user_auth->change_password(Registry::get('username'), $this->request->post['password']) == 1) { $this->data['x'] = $this->data['text_password_changed']; } else { $this->data['x'] = $this->data['text_failed_to_change_password']; } } $this->data['page_len'] = get_page_length(); $this->data['theme'] = $session->get("theme"); $this->data['lang'] = $session->get("lang"); $this->render(); }
require_once "config.php"; require DIR_SYSTEM . "/startup.php"; $request = new Request(); Registry::set("request", $request); Registry::set('document', new Document()); $start = NULL; $loader = new Loader(); Registry::set('load', $loader); $language = new Language(); Registry::set('language', $language); if (ENABLE_SYSLOG == 1) { openlog("piler-webui", LOG_PID, LOG_MAIL); } /* check if user has authenticated himself. If not, we send him to login */ Registry::set('username', getAuthenticatedUsername()); Registry::set('admin_user', isAdminUser()); Registry::set('auditor_user', isAuditorUser()); Registry::set('readonly_admin', isReadonlyAdmin()); $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE, DB_PREFIX); Registry::set('DB_DATABASE', DB_DATABASE); Registry::set('db', $db); Registry::set('DB_DRIVER', DB_DRIVER); $sphx = new DB(SPHINX_DRIVER, SPHINX_HOSTNAME, "", "", SPHINX_DATABASE, ""); Registry::set('sphx', $sphx); if (MEMCACHED_ENABLED) { $memcache = new Memcache(); foreach ($memcached_servers as $m) { $memcache->addServer($m[0], $m[1]); } Registry::set('memcache', $memcache); }
/** * 获取供应商列表信息 * * @access public * @param * * @return void */ function rebate_list($act = '') { $result = get_filter(); if ($result === false) { //$aiax = isset($_GET['is_ajax']) ? $_GET['is_ajax'] : 0; $where_store = ''; if (isAdminUser()) { $where_store = ''; } else { $store_ids = loginUserStore($_SESSION['admin_id']); if (count($store_ids) > 0) { $store_ids = array_unique($store_ids); $where_store = ' and sr.store_id in(' . implode(',', $store_ids) . ') '; } } /* 过滤信息 */ $filter['rebate_paytime_start'] = !empty($_REQUEST['rebate_paytime_start']) ? local_strtotime($_REQUEST['rebate_paytime_start']) : 0; $filter['rebate_paytime_end'] = !empty($_REQUEST['rebate_paytime_end']) ? local_strtotime($_REQUEST['rebate_paytime_end'] . " 23:59:59") : 0; $filter['status'] = isset($_REQUEST['status']) ? intval($_REQUEST['status']) : -1; $filter['sort_by'] = empty($_REQUEST['sort_by']) ? ' sr.supplier_id' : trim($_REQUEST['sort_by']); $filter['sort_order'] = empty($_REQUEST['sort_order']) ? ' ASC' : trim($_REQUEST['sort_order']); $filter['is_pay_ok'] = empty($_REQUEST['is_pay_ok']) ? '0' : intval($_REQUEST['is_pay_ok']); $filter['actname'] = empty($act) ? trim($_REQUEST['act']) : $act; //$where = 'WHERE sr.supplier_id=0 '.$where_store; $where = 'where 1 ' . $where_store; $where .= $filter['rebate_paytime_start'] ? " AND sr.rebate_paytime_start >= '" . $filter['rebate_paytime_start'] . "' " : " "; $where .= $filter['rebate_paytime_end'] ? " AND sr.rebate_paytime_end <= '" . $filter['rebate_paytime_end'] . "' " : " "; $where .= $filter['is_pay_ok'] ? " AND sr.is_pay_ok = '" . $filter['is_pay_ok'] . "' " : " AND sr.is_pay_ok = '0' "; $where .= $filter['status'] > -1 ? " AND sr.status = '" . $filter['status'] . "' " : " "; /* 分页大小 */ $filter['page'] = empty($_REQUEST['page']) || intval($_REQUEST['page']) <= 0 ? 1 : intval($_REQUEST['page']); if (isset($_REQUEST['page_size']) && intval($_REQUEST['page_size']) > 0) { $filter['page_size'] = intval($_REQUEST['page_size']); } elseif (isset($_COOKIE['ECSCP']['page_size']) && intval($_COOKIE['ECSCP']['page_size']) > 0) { $filter['page_size'] = intval($_COOKIE['ECSCP']['page_size']); } else { $filter['page_size'] = 15; } /* 记录总数 */ $sql = "SELECT COUNT(*) FROM " . $GLOBALS['ecs']->table('store_rebate') . " AS sr " . $where; $filter['record_count'] = $GLOBALS['db']->getOne($sql); $filter['page_count'] = $filter['record_count'] > 0 ? ceil($filter['record_count'] / $filter['page_size']) : 1; /* 查询 */ $sql = "SELECT sr.*,s.store_name, s.store_id,s.supplier_id, smr.rebate, ifnull(ss.supplier_name,'平台方') as sname " . "FROM " . $GLOBALS['ecs']->table("store_rebate") . " AS sr left join " . $GLOBALS['ecs']->table("store_main") . " AS s on sr.store_id=s.store_id left join " . $GLOBALS['ecs']->table("store_main_rebate") . " as smr on s.store_id = smr.store_id left join " . $GLOBALS['ecs']->table("supplier") . " as ss on sr.supplier_id=ss.supplier_id \n {$where}\n ORDER BY " . $filter['sort_by'] . " " . $filter['sort_order'] . "\n LIMIT " . ($filter['page'] - 1) * $filter['page_size'] . ", " . $filter['page_size'] . " "; set_filter($filter, $sql); } else { $sql = $result['sql']; $filter = $result['filter']; } $list = array(); $res = $GLOBALS['db']->query($sql); while ($row = $GLOBALS['db']->fetchRow($res)) { $row['sign'] = createSign($row['rebate_id'], $row['store_id']); $row['rebate_paytime_start'] = local_date('Y.m.d', $row['rebate_paytime_start']); $endtime = $row['rebate_paytime_end']; //+$GLOBALS['_CFG']['tuihuan_days_qianshou']*3600*24; $row['rebate_paytime_end'] = local_date('Y.m.d', $endtime); //$row['all_money'] = $GLOBALS['db']->getOne("select sum(money_paid + surplus) from ". $GLOBALS['ecs']->table('order_info') ." where rebate_id=". $row['rebate_id'] ." and rebate_ispay=2"); $row['all_money'] = $GLOBALS['db']->getOne("select sum(" . order_amount_field() . ") from " . $GLOBALS['ecs']->table('order_info') . " where store_rebate_id=" . $row['rebate_id'] . " and store_rebate_ispay=2"); $row['all_money_formated'] = price_format($row['all_money']); $row['rebate_money'] = $row['all_money'] > 0 ? getGoodsRbatePrice($row['rebate_id']) : 0; // $row['rebate_money'] = round($row['rebate_money'] * $row['rebate'] / 100, 2); $row['rebate_money_formated'] = price_format($row['rebate_money']); $row['pay_money'] = $row['all_money'] - $row['rebate_money']; $row['pay_money_formated'] = price_format($row['pay_money']); $row['pay_status'] = $row['is_pay_ok'] ? "已处理,已返佣" : "未处理"; $row['pay_time'] = local_date('Y.m.d', $row['pay_time']); $row['user'] = $_SESSION['user_name']; $row['payable_price'] = price_format($row['payable_price']); $row['status_name'] = rebateStatus($row['status']); $row['caozuo'] = getRebateDo($row['status'], $row['rebate_id'], $filter['actname']); $list[] = $row; } $arr = array('result' => $list, 'filter' => $filter, 'page_count' => $filter['page_count'], 'record_count' => $filter['record_count']); return $arr; }
public function index() { $this->id = "content"; $this->template = "login/ga.tpl"; $this->layout = "common/layout-empty"; $request = Registry::get('request'); $session = Registry::get('session'); $db = Registry::get('db'); $this->load->model('user/auth'); $this->load->model('user/user'); $this->load->model('user/prefs'); if (ENABLE_SAAS == 1) { $this->load->model('saas/ldap'); $this->load->model('saas/customer'); } require DIR_BASE . 'system/helper/PHPGangsta_GoogleAuthenticator.php'; $this->data['title'] = $this->data['text_login']; $this->data['title_prefix'] = TITLE_PREFIX; $this->data['failed_login_count'] = $this->model_user_auth->get_failed_login_count(); if ($this->request->server['REQUEST_METHOD'] == 'POST' && $this->validate() == true) { $GA = new PHPGangsta_GoogleAuthenticator(); $settings = $this->model_user_prefs->get_ga_settings($session->get('username')); if (strlen($this->request->post['ga_code']) > 5 && $GA->verifyCode($settings['ga_secret'], $this->request->post['ga_code'], 2)) { $session->set("ga_block", ""); $this->model_user_prefs->get_user_preferences($session->get('username')); if (ENABLE_SAAS == 1) { $this->model_saas_customer->online($session->get('email')); } LOGGER('logged in'); if (isAdminUser() == 1) { header("Location: " . SITE_URL . "index.php?route=health/health"); exit; } header("Location: " . SITE_URL . "search.php"); exit; } else { $this->model_user_auth->increment_failed_login_count($this->data['failed_login_count']); $this->data['failed_login_count']++; } $this->data['x'] = $this->data['text_invalid_pin_code']; } $this->render(); }