public function add() { if (Input::method() == 'POST') { if (Users::add()) { return Response::redirect($this->admin_url . '/users/edit/' . Db::insert_id()); } } Template::render('users/add'); }
public function selectUsers($ids) { try { $split_ids = explode(",", $ids); $users = new Users(); foreach ($split_ids as $id) { $users->add($this->selectUser(intval($id))); } return $users; } catch (Exception $e) { echo $e->getMessage(); } }
/** * Add the site name for the current site. * * @param string new site name * @return boolean True if successful; false otherwise. */ public function add($unixName, $siteName, $isDemo = 0, $modelSite = false) { $sql = sprintf("INSERT INTO\n site\n (\n unix_name,\n name,\n is_demo,\n date_created,\n is_free\n ) values (%s,%s,%s,'%s',%s)", $this->_db->makeQueryString($unixName), $this->_db->makeQueryString($siteName), $isDemo, date("Y-m-d h:i:s"), 0); $siteCreated = (bool) $this->_db->query($sql); $siteID = $this->_db->getLastInsertID(); $date_created = date("Y-m-d H:i:s"); if (is_numeric($modelSite)) { $sql = "insert into extra_field_settings (field_name,site_id,date_created,data_item_type,extra_field_type,extra_field_options,position) (select field_name,{$siteID},'{$date_created}',data_item_type,extra_field_type,extra_field_options,position from extra_field_settings where site_id={$modelSite})"; $this->_db->query($sql); } $objUser = new Users($siteID); $objUser->add("Administrator", "CandidATS", "", "admin", "candidats", 500); return $siteID; }
public function index($param) { // check if we've submitted a new user registration if (isset($_POST['username'])) { if (Users::add($_POST['username'], $_POST['password'], $_POST['realname'])) { // OK, take us to the admin (or most often to the login) $this->redirect('/secure/'); die; // failed to add a user, show the form again } else { $this->redirect('/register/'); die; } } $this->view->display('register'); }
/** * Signup */ public function signupAction() { $form = new Form_User(); if ($this->getRequest()->isPost() && $form->isValid($this->getRequest()->getPost())) { $userData = $form->getValues(); $userData['id'] = User::fetchNextId(); // save user $user = new User($userData['id']); $user->setValue($userData); $users = new Users(); $users->add($userData['id']); // save login to id link User::setLoginToIdLink($userData['login'], $userData['id']); $this->_redirect('/user/login'); } $this->view->form = $form; }
<?php $redirect = function () { if (array_key_exists('state', $_GET)) { header('Location: ' . $_GET['state']); } else { header('Location: /'); } }; $auth = new GoogleAuth(Config::get('GOOGLE_WA_CLIENT_ID'), Config::get('GOOGLE_WA_CLIENT_SECRET'), Config::get('GOOGLE_OAUTH_REDIRECT_URI'), Config::get('GOOGLE_OAUTH_SCOPES')); $info = $auth->getUserInfo($_GET['code']); if (null === $info) { // Access denied $redirect(); } else { // Access granted $email = $info['email']; $nick = $info['name']; $picture = $info['picture']; $user = Users::getByEmail($email); if (null == $user) { $user = Users::add($email); $user->setNick($nick); $user->setPicture(Image::INSERT($picture)); } $user->login(); $redirect(); }
public function load($rowData = false) { if ($this->loaded) { return true; } if (!$rowData) { if (!$this->id) { $this->setXMLAttibute('auth', 0); } else { if ($cachedUser = Users::getFromCache($this->id)) { $this->profile = $cachedUser->profile; foreach ($this->profile as $field => $value) { $this->setXMLAttibute($field, $value); } $this->profileAdditional = $cachedUser->profileAdditional; $this->loaded = true; return; } else { $rowData = Database::sql2row('SELECT * FROM `users` WHERE `id`=' . $this->id); } } } if (!$rowData) { // нет юзера в базе throw new Exception('Такого пользователя #' . $this->id . ' не существует', Error::E_USER_NOT_FOUND); } $this->id = (int) $rowData['id']; foreach ($rowData as $field => $value) { if ($field == 'serialized') { $arr = json_decode($value, true); if (is_array($arr)) { foreach ($arr as $field => $value) { $this->setPropertySerialized($field, $value, $save = false); $this->setXMLAttibute($field, $value); } } } // все данные в profile $this->setProperty($field, $value, $save = false); // данные для xml - в xml $this->setXMLAttibute($field, $value); } Users::add($this); $this->loaded = true; Users::putInCache($this->id); return; }
public function wizard_addUser() { if (!isset($_SESSION['CATS']) || empty($_SESSION['CATS'])) { echo 'CATS has lost your session data!'; return; } /* Bail out if the user doesn't have SA permissions. */ if ($this->_realAccessLevel < ACCESS_LEVEL_SA) { echo 'You do not have access to add a user.'; return; } if (isset($_GET[$id = 'firstName'])) { $firstName = $_GET[$id]; } else { $firstName = ''; } if (isset($_GET[$id = 'lastName'])) { $lastName = $_GET[$id]; } else { $lastName = ''; } if (isset($_GET[$id = 'password'])) { $password = $_GET[$id]; } else { $password = ''; } if (isset($_GET[$id = 'loginName'])) { $loginName = $_GET[$id]; } else { $loginName = ''; } if (isset($_GET[$id = 'email'])) { $email = $_GET[$id]; } else { $email = ''; } if (isset($_GET[$id = 'accessLevel']) && intval($_GET[$id]) < ACCESS_LEVEL_SA) { $accessLevel = intval($_GET[$id]); } else { $accessLevel = ACCESS_LEVEL_READ; } if (strlen($firstName) < 2 || strlen($lastName) < 2 || strlen($loginName) < 2 || strlen($password) < 2) { echo 'First and last name are too short.'; return; } $users = new Users($this->_siteID); /* If adding an e-mail username, verify it is a valid e-mail. */ if (strpos($loginName, '@') !== false && !eregi("^[_a-z0-9-]+(.[_a-z0-9-]+)*@[a-z0-9-]+(.[a-z0-9-]+)*(.[a-z]{2,4})\$", $loginName)) { echo 'That is not a valid login name.'; return; } /* Make it a multisite user name if the user is part of a hosted site. */ $unixName = $_SESSION['CATS']->getUnixName(); if (strpos($loginName, '@') === false && !empty($unixName)) { $loginName .= '@' . $_SESSION['CATS']->getSiteID(); } /* Bail out if the specified username already exists. */ if ($users->usernameExists($loginName)) { echo 'That username already exists.'; return; } $data = $users->getLicenseData(); if ($data['totalUsers'] >= $data['userLicenses']) { echo 'You cannot add any more users with your license.'; return; } if ($users->add($lastName, $firstName, $email, $loginName, $password, $accessLevel, false) !== -1) { echo 'Ok'; return; } else { echo 'Unable to add user. One of the fields you entered may have been formatted incorrectly.'; return; } }
function getSearch() { $query_string = isset(Request::$get_normal['s']) ? Request::$get_normal['s'] : false; $query_string_prepared = '%' . mysql_escape_string($query_string) . '%'; $cond = new Conditions(); $per_page = 0; if (isset($this->params['per_page'])) { $per_page = (int) $this->params['per_page']; } $per_page = $per_page > 0 ? $per_page : 60; $pagingName = isset($this->params['paging_parameter_name']) ? $this->params['paging_parameter_name'] : 'p'; $where = 'WHERE `nickname` LIKE \'' . $query_string_prepared . '\' OR `email` LIKE \'' . $query_string_prepared . '\' OR `id`=\'' . $query_string_prepared . '\''; $order = 'ORDER BY `regTime` DESC '; $group_by = ''; $query = 'SELECT COUNT(1) FROM `users` ' . $where . ' ' . $group_by . ''; $count = Database::sql2single($query); $cond->setPaging($count, $per_page, $pagingName); $limit = $cond->getLimit(); $limit = ' LIMIT ' . $limit; $query = 'SELECT * FROM `users`' . $where . ' ' . $group_by . ' ' . $order . ' ' . $limit; $data = Database::sql2array($query); foreach ($data as $row) { $user = new User($row['id'], $row); Users::add($user); $this->data['users'][] = $user->getListData(true); } $this->data['users']['title'] = 'Пользователи'; $this->data['users']['count'] = $count; $this->data['conditions'] = $cond->getConditions(); }
if (!$user->isValidUsername($cfg->ADMIN_USER)) { $cfg->error = true; $cfg->ADMIN_USER = ''; } else { $usrCheck = $user->getByUsername($cfg->ADMIN_USER); if ($usrCheck) { $cfg->error = true; $cfg->ADMIN_USER = ''; } } if (!$user->isValidEmail($cfg->ADMIN_EMAIL)) { $cfg->error = true; $cfg->ADMIN_EMAIL = ''; } if (!$cfg->error) { $cfg->adminCheck = $user->add($cfg->ADMIN_USER, $cfg->ADMIN_PASS, $cfg->ADMIN_EMAIL, 2, '', ''); if (!is_numeric($cfg->adminCheck)) { $cfg->error = true; } else { $user->login($cfg->adminCheck, "", 1); } } } if (!$cfg->error) { $cfg->setSession(); header("Location: ?success"); die; } } $page->smarty->assign('cfg', $cfg); $page->smarty->assign('page', $page);
/** * 功能号:12080 * 订单接口 * */ public function order_create() { COMFilter::$_jump = false; $clientmac = $_COOKIE['CLIENTMAC']; if (!$clientmac) { $boxmac = new COMGetmac(); // print 'getmac'; $clientmac = 'M' . $boxmac->getmac(); setcookie("CLIENTMAC", $clientmac); } // print $clientmac; $clientboxid = intval($_COOKIE['CLIENTBOXID']); if (!$clientboxid) { $clientbox = new Boxs(); $one = $clientbox->getOne("mac=?", $clientmac); if ($one) { $clientboxid = $one->id; setcookie("CLIENTMAC", $clientmac); } } $phone = Core::$_dataFilter->valueCheck(Core::get("phone"), "Require,Limit", "手机号不能为空,手机号最多11个字符", false, 11); $goodsid = 10001; if ($phone) { //统计 Statistics::hitscounter(intval($clientboxid), "logined", "logined"); $user = new Users(); $addate = COMCommon::sysTime(); $one = $user->getOne('user_name=?', $phone); if (empty($one)) { $id = $user->add($phone, $addate); } else { $id = $one->id; } setcookie("CLIENTPHONE", $phone); $token = new Users_token(); //$host = '115.28.92.216'; $host = $this->_host; $network = Core::connect_check($host); if ($network) { $param = array("m" => 12080, "phone" => $phone, "goods" => $goodsid); if (!$clientboxid) { $param['mac'] = $clientmac; } else { $param['box'] = $clientboxid; } $param['at'] = $_SERVER['REQUEST_TIME']; $one = $token->getOne("id = ? and end_time - UNIX_TIMESTAMP() > 0", $id); if (empty($one)) { $param['pal'] = 1; } $sign = Core::get_signature($param); $param["sign"] = $sign; $url = "http://{$host}/tvmv/?m=12080"; $temp = Core::request_url($url, $param, 1); $return = json_decode($temp); if ($return->status === 1) { $data = $return->data; if ($data->token) { if (!$data->status) { $order = new Orders(); $one = $order->getOne("order_sn=?", $data->ordersn, "pay_time desc"); if ($one) { $one->status = 1; $one->pay_time = date("Y-m-d H:i:s", $data->start_time); $flag = $one->save(); if ($flag) { $one = $token->getOne("id = ?", $id); if ($one) { $flag = $token->edit(1, $data->ordersn, $data->token, $data->start_time, $data->end_time, 1, $data->code, $id); } else { $flag = $token->add($id, 1, $data->ordersn, $data->token, $data->start_time, $data->end_time, 1, $data->code); } if ($flag) { $this->notify_server($one, $data->token); } } } } setcookie("CLIENTTOKEN", $data->token); $retval['token'] = $data->token; Core::json_result($retval, '已支付'); } elseif ($data->ordersn) { $order = new Orders(); $one = $order->getOne("order_sn=?", $data->ordersn, "pay_time desc"); if (empty($one)) { $orderid = $order->add($data->ordersn, $id, 0, $clientboxid, 0, "", $goodsid, 0, 0, "", 1); if ($orderid) { $ordersn = $data->ordersn; } } else { $ordersn = $one->order_sn; } setcookie("CLIENTORDERSN", $ordersn); $retval['ordersn'] = $ordersn; Core::json_result($retval, '订单生成'); } } else { $msg = $return->msg; Core::json_error($msg); } } else { $flag = $token->del("id = {$id} and end_time - UNIX_TIMESTAMP() < 0"); $one = $token->getOne("id = ? and end_time - UNIX_TIMESTAMP() > 0", $id); if ($one) { if ($one->status == 1) { $flag = $this->notify_server($one, $one->token_id); } setcookie("CLIENTTOKEN", $one->token_id); $retval['token'] = $one->token_id; Core::json_result($retval, '已支付'); } else { $msg = "请购买观影服务!"; Core::json_error($msg); } } } }
<?php require_once 'autoload.php'; $user = new Users(); if (!empty($_POST['registration'])) { if ($user->add($_POST)) { $_SESSION['username'] = $_POST['username']; header('Location: profile.php?' . $_POST['username']); } } ?> <div id="registration"> <h2>Registration</h2> <form action="" method="post" name="registration" id="regForm"> <span> <label for="regUserName">User name</label> <input id="regUserName" class="input" type="text" name="username"> <br> <label for="fName">First name</label> <input id="fName" class="input" type="text" name="fName"> <br> <label for="lName">Last name</label> <input id="lName" class="input" type="text" name="lName"> <br> </span> <span> <label for="mail">E-mail</label> <input id="mail" class="input" type="email" name="mail"> <br> <label for="regPass">Password</label>