public function testGetUserList() { // count there is 7 users $this->assertEquals(count(getUserList()), 7); // test some username $this->assertEquals(getUserList()[0], "user_with_allPermissions"); $this->assertEquals(getUserList()[1], "user_with_listtaskpermission"); // test the last username $this->assertEquals(getUserList()[6], "user_with_nonepermissions"); }
function knockKnock($userName, $callerID) { $user_list = getUserList(); $users = json_decode($user_list); if (count($users->rows) == 0) { return false; } else { foreach ($users->rows as $user) { $channel = $user->value->channel; $network = $user->value->network; $name = $user->value->name; $address = $user->key; $msg = "{$userName} is outside knocking, please let them in."; if ($channel == 'VOICE') { $address = 'tel:+1' . $address; } message($msg, array("to" => $address, "network" => $network)); } return true; } }
public function get_view() { ob_start(); ?> <form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <label>Username</label> <select name="id" class="form-control"> <?php foreach (getUserList() as $uid => $name) { echo "<option>" . $name . "</option>"; } ?> </select> <p> <button class="btn btn-defaut" type="submit">Pose as User</button> </p> </form> <?php $this->add_onload_command("\$('select.form-control').focus();\n"); return ob_get_clean(); }
/** * 设置人员属性 */ function updateUser($userId, $matchId, $groupId = -1, $apply_follow = -1, $apply_match = -1, $apply_group = -1, $pass_apply_match = -1, $pass_apply_group = -1) { global $wpdb; $_userId = intval($userId); $_matchId = intval($matchId); $_groupId = intval($groupId); $_apply_follow = intval($apply_follow); $_apply_match = intval($apply_match); $_apply_group = intval($apply_group); $_pass_apply_match = intval($pass_apply_match); $_pass_apply_group = intval($pass_apply_group); $columns = array(); if ($_groupId > -1) { $columns['group_id'] = intval($_groupId); } if ($_apply_follow > -1) { $columns['apply_follow'] = intval($_apply_follow); } if ($_apply_match > -1) { $columns['apply_match'] = intval($_apply_match); } if ($_apply_group > -1) { $columns['apply_group'] = intval($_apply_group); } if ($_pass_apply_match > -1) { $columns['pass_apply_match'] = intval($_pass_apply_match); } if ($_pass_apply_group > -1) { $columns['pass_apply_group'] = intval($_pass_apply_group); } if ($_userId > 0 && $_matchId > 0) { $users = getUserList($userId, $matchId); if (empty($users)) { return $wpdb->insert('wp_likedome_match_user', array('uid' => $_userId, 'match_id' => $_matchId) + $columns); } $result = $wpdb->update('wp_likedome_match_user', $columns, array('uid' => $_userId, 'match_id' => $_matchId)); } return $result; }
} wp_reset_postdata(); } else { ?> <li style="width: 100%; float: left;"> * 目前你还没有参加过任何比赛 </li> <?php } ?> </ul> </div> <div class="tab_main"> <ul class="joinList margin-t13" style="width: 100%; float: left;"> <?php $users = getUserList($current_user->ID, -1, -1, 1); if (count($users)) { foreach ($users as $user) { $args = get_match_post($user->match_id); query_posts($args); if (have_posts()) { while (have_posts()) { the_post(); ?> <li style="width: 100%; float: left;"> <a href="?p=77&matchid=<?php echo $user->match_id; ?> "><?php the_post_thumbnail(); ?>
/** * Retrieve a HTML <OPTION> list of survey admin users * * @param mixed $bIncludeOwner If the survey owner should be included * @param mixed $bIncludeSuperAdmins If Super admins should be included * @param int surveyid * @return string */ function getSurveyUserList($bIncludeOwner = true, $bIncludeSuperAdmins = true, $surveyid) { $surveyid = sanitize_int($surveyid); $sSurveyIDQuery = "SELECT a.uid, a.users_name, a.full_name FROM {{users}} AS a\n LEFT OUTER JOIN (SELECT uid AS id FROM {{permissions}} WHERE entity_id = {$surveyid} and entity='survey') AS b ON a.uid = b.id\n WHERE id IS NULL "; if (!$bIncludeSuperAdmins) { // @todo: Adjust for new permission system - not urgent since it it just display // $sSurveyIDQuery.='and superadmin=0 '; } $sSurveyIDQuery .= 'ORDER BY a.users_name'; $oSurveyIDResult = Yii::app()->db->createCommand($sSurveyIDQuery)->query(); //Checked $aSurveyIDResult = $oSurveyIDResult->readAll(); $surveyselecter = ""; if (Yii::app()->getConfig('usercontrolSameGroupPolicy') == true) { $authorizedUsersList = getUserList('onlyuidarray'); } foreach ($aSurveyIDResult as $sv) { if (Yii::app()->getConfig('usercontrolSameGroupPolicy') == false || in_array($sv['uid'], $authorizedUsersList)) { $surveyselecter .= "<option"; $surveyselecter .= " value='{$sv['uid']}'>{$sv['users_name']} {$sv['full_name']}</option>\n"; } } if (!isset($svexist)) { $surveyselecter = "<option value='-1' selected='selected'>" . gT("Please choose...") . "</option>\n" . $surveyselecter; } else { $surveyselecter = "<option value='-1'>" . gT("None") . "</option>\n" . $surveyselecter; } return $surveyselecter; }
<?php include 'functions.php'; include 'header.php'; $get = getUserList(); setlocale(LC_TIME, 'Estonia'); date_default_timezone_set('Europe/Tallinn'); $praegu = time(); $algus = strtotime("01-03-2016 10:00:00"); $kulunud = $praegu - $algus; echo "Kursuse algusest on möödunud " . $kulunud . " sekundit<br>"; echo "Tänane kuupäev: " . strftime("%Y. %B %d."); ?> <div class="page-header pool"> <h1>Tabel</h1> </div> <form action="new.php" method="post"> <button type="submit" class="btn btn-default">Lisa</button> </form> <div class="row"> <div class="col-md-6"> <table class="table table-striped"> <thead> <tr> <th>#</th> <th>Nimi</th> <th>Kasutaja</th> <th>E-mail</th> <th>Tel</th> <th>Sugu</th> <th>Muudetud</th>
} else { $userInfo = array('ip' => $ip, 'addtime' => microtime()); $redis->rPush('userlist', json_encode($userInfo)); $redis->decr('goods_count'); $arr['succ'] = 'T'; $arr['msg'] = $userInfo['ip'] . '恭喜您,抢到了商品!'; } } else { // 不存在商品了,直接返回数据 $arr['msg'] = '商品已经抢光了,谢谢您的参与,下次再来吧'; } backjson($arr); } elseif ($act == 'user') { //获取中奖用户 $msg = ""; $userArr = getUserList(); if (!empty($userArr)) { foreach ($userArr as $user) { $msg .= "<tr>\r\n <td>" . $user['ip'] . "</td>\r\n <td>" . $user['addtime'] . "</td>\r\n </tr>"; } } else { $msg .= "<tr colspan='2'>没有查询到用户</tr>"; } $arr['succ'] = 'T'; $arr['msg'] = $msg; backjson($arr); } elseif ($act == 'gettime') { $time = date("Y-m-d H:i:s"); } function backjson($data) {
echo "\n</form>"; } else { switch (getVAR("action")) { case "create_notice": if (strtolower($username) == "student") { echo send_notice("ERROR", "Students may not create notices."); } else { echo "\n<form method=\"POST\" action=\"{$PHP_SELF}?action=create_notice_add&display_date={$display_date}&username={$username}&password={$password}\">"; echo "\n<table bgcolor={$table_heading_bgcolour} width=100%>"; echo "\n<tr><td colspan=2><h2>Create New Notice</h2></td></tr>"; echo "\n<tr><td>Date(s):</td><td><table><tr><td>" . getDateList(true, "") . "</td><td>Note: CTRL + click to select multiple days.</td></tr></table></td></tr>"; echo "\n<tr><td>Title:</td><td><input type=\"text\" size=40 name=\"txttitle\"></td></tr>"; echo "\n<tr><td>Notice:</td><td><textarea rows=5 cols=40 name=\"txtnotice\"></textarea></td></tr>"; echo "\n<tr><td>Author:</td><td><input type=\"text\" size=40 name=\"txtauthor\"></td></tr>"; echo "\n<tr><td>Importance:</td><td>" . getImportanceList() . "</td></tr>"; echo "\n<tr><td>Who should see this notice?:</td><td>" . getUserList() . "</td></tr>"; echo "\n<tr><td>Typeface:</td><td>" . getTypeFaceList() . "</td></tr>"; echo "\n<tr><td>Size:</td><td>" . getFontSizeList() . "<p>"; echo "\n<input type=\"submit\" value=\"Create\" name=\"B1\"></td></tr>"; echo "\n</table>"; echo "\n</form>"; } break; case "create_notice_add": if (!getVAR("lstdate")) { echo send_notice("ERROR", "No date was specified."); continue; } $tempDate = getVAR("lstdate"); $tempTitle = mysql_real_escape_string(getVAR("txttitle")); $tempNotice = mysql_real_escape_string(getVAR("txtnotice"));
function setusertemplates() { App()->getClientScript()->registerPackage('jquery-tablesorter'); App()->getClientScript()->registerScriptFile(App()->getAssetManager()->publish(ADMIN_SCRIPT_PATH . 'users.js')); $postuserid = (int) Yii::app()->request->getPost("uid"); $aData['postuser'] = flattenText(Yii::app()->request->getPost("user")); $aData['postemail'] = flattenText(Yii::app()->request->getPost("email")); $aData['postuserid'] = $postuserid; $aData['postfull_name'] = flattenText(Yii::app()->request->getPost("full_name")); $this->_refreshtemplates(); $templaterights = array(); foreach (getUserList() as $usr) { if ($usr['uid'] == $postuserid) { $trights = Permission::model()->findAllByAttributes(array('uid' => $usr['uid'], 'entity' => 'template')); foreach ($trights as $srow) { $templaterights[$srow["permission"]] = array("use" => $srow["read_p"]); } $templates = Template::model()->findAll(); $aData['list'][] = array('templaterights' => $templaterights, 'templates' => $templates); } } $aData['fullpagebar']['savebutton']['form'] = 'modtemplaterightsform'; $aData['fullpagebar']['closebutton']['url'] = 'admin/user/sa/index'; $this->_renderWrappedTemplate('user', 'setusertemplates', $aData); }
$insertlog->execute(); $template_file = $spracheResponse->table_add; } // No update or insert failed } else { $template_file = $spracheResponse->error_table; } } } // An error occurred during validation // unset the redirect information and display the form again if (!$ui->smallletters('action', 2, 'post') or count($errors) != 0) { unset($header, $text); // Gather data for adding if needed and define add template if ($ui->st('d', 'get') == 'ad') { $table = getUserList($resellerLockupID); $query = $sql->prepare("SELECT m.`id`,m.`ssh2ip`,m.`description`, COUNT(d.`dnsID`)/(m.`max_dns`/100) AS `usedpercent` FROM `voice_tsdns` AS m LEFT JOIN `voice_dns` AS d ON d.`tsdnsID`=m.`id` WHERE m.`resellerid`=? AND m.`active`='Y' GROUP BY m.`id` HAVING `usedpercent`<100 ORDER BY `usedpercent` ASC"); $query->execute(array($resellerLockupID)); while ($row = $query->fetch(PDO::FETCH_ASSOC)) { $table2[$row['id']] = trim($row['ssh2ip'] . ' ' . $row['description']); } $template_file = 'admin_voice_dns_add.tpl'; // Gather data for modding in case we have an ID and define mod template } else { if ($ui->st('d', 'get') == 'md' and $id) { // Check if database entry exists and if not display 404 page $template_file = isset($oldActive) ? 'admin_voice_dns_md.tpl' : 'admin_404.tpl'; // Show 404 if GET parameters did not add up or no ID was given with mod } else { $template_file = 'admin_404.tpl'; }
$messageAuthor = intval($_POST['messageAuthor']); $content = trim($_POST['content']); $message = addMessage($messageAuthor, $content); header("location:index.php?ac=userinfo"); } else { if ($ac == 'search') { $type = !empty($_GET['type']) ? intval($_GET['key']) : 1; if ($type == 1) { $key = !empty($_GET['key']) ? trim($_GET['key']) : null; $memberid = !empty($_GET['memberid']) ? intval($_GET['memberid']) : null; $title = $memberid ? '我的问题' : ''; $questions = getQuestionList($memberid, $key); include 'tpl/main.php'; } else { $key = !empty($_GET['key']) ? trim($_GET['key']) : null; $users = getUserList($key); include 'tpl/userlist.php'; } } else { if ($ac == 'myanswers') { $memberid = !empty($_GET['memberid']) ? intval($_GET['memberid']) : null; $myanswers = getAnswerList($memberid); include 'tpl/myanswer.php'; } else { if ($ac == 'userinfo') { $usersession = $_SESSION['userinfo']; $info = getOneUser($usersession['username']); include 'tpl/userinfo.php'; } else { if ($ac == 'good') { $qid = intval($_GET['qid']);
/** * surveypermission::adduser() * Function responsible to add user. * @param mixed $surveyid * @return void */ function adduser($surveyid) { $aData['surveyid'] = $surveyid = sanitize_int($surveyid); $aViewUrls = array(); $action = $_POST['action']; $clang = Yii::app()->lang; $imageurl = Yii::app()->getConfig('imageurl'); $postuserid = $_POST['uid']; if ($action == "addsurveysecurity") { $addsummary = "<div class='header ui-widget-header'>" . $clang->gT("Add User") . "</div>\n"; $addsummary .= "<div class=\"messagebox ui-corner-all\">\n"; $result = Survey::model()->findAll('sid = :sid AND owner_id = :owner_id AND owner_id != :postuserid', array(':sid' => $surveyid, ':owner_id' => Yii::app()->session['loginID'], ':postuserid' => $postuserid)); if (count($result) > 0 && in_array($postuserid, getUserList('onlyuidarray')) || Yii::app()->session['USER_RIGHT_SUPERADMIN'] == 1) { if ($postuserid > 0) { $isrresult = Survey_permissions::model()->insertSomeRecords(array('sid' => $surveyid, 'uid' => $postuserid, 'permission' => 'survey', 'read_p' => 1)); if ($isrresult) { $addsummary .= "<div class=\"successheader\">" . $clang->gT("User added.") . "</div>\n"; $addsummary .= "<br />" . CHtml::form(array("admin/surveypermission/sa/set/surveyid/{$surveyid}"), 'post') . "<input type='submit' value='" . $clang->gT("Set survey permissions") . "' />" . "<input type='hidden' name='action' value='setsurveysecurity' />" . "<input type='hidden' name='uid' value='{$postuserid}' />" . "</form>\n"; } else { // Username already exists. $addsummary .= "<div class=\"warningheader\">" . $clang->gT("Failed to add user.") . "</div>\n" . "<br />" . $clang->gT("Username already exists.") . "<br />\n"; $addsummary .= "<br/><input type=\"submit\" onclick=\"window.open('" . $this->getController()->createUrl('admin/surveypermission/sa/view/surveyid/' . $surveyid) . "', '_top')\" value=\"" . $clang->gT("Continue") . "\"/>\n"; } } else { $addsummary .= "<div class=\"warningheader\">" . $clang->gT("Failed to add user.") . "</div>\n" . "<br />" . $clang->gT("No Username selected.") . "<br />\n"; $addsummary .= "<br/><input type=\"submit\" onclick=\"window.open('" . $this->getController()->createUrl('admin/surveypermission/sa/view/surveyid/' . $surveyid) . "', '_top')\" value=\"" . $clang->gT("Continue") . "\"/>\n"; } } else { accessDenied(); } $addsummary .= "</div>\n"; $aViewUrls['output'] = $addsummary; } $this->_renderWrappedTemplate('authentication', $aViewUrls, $aData); }
$stmt = $db->prepare($pre_user_1); $stmt->execute(); $pre_all_1 = $stmt->fetchAll(PDO::FETCH_NUM); $stmt = $db->prepare($pre_user_2); $stmt->execute(); $pre_all_2 = $stmt->fetchAll(PDO::FETCH_NUM); $stmt = $db->prepare($this_user_1); $stmt->execute(); $this_all_1 = $stmt->fetchAll(PDO::FETCH_NUM); $stmt = $db->prepare($this_user_2); $stmt->execute(); $this_all_2 = $stmt->fetchAll(PDO::FETCH_NUM); $data->user_create_pre = getUserList($pre_all_1); $data->user_desgin_pre = getUserList($pre_all_2); $data->user_create_this = getUserList($this_all_1); $data->user_desgin_this = getUserList($this_all_2); } $db = null; //echo $pre_lin; echo '{"summary":' . json_encode($data) . '}'; } catch (PDOException $e) { echo '{"error":{"text":"' . $e->getMessage() . '"}}'; } }); /** * 获取需求属性 */ $app->get('/users/:power', function ($power) use($app) { $sql = "SELECT * FROM `tb_users` WHERE `user_power` =" . $power; try { $db = getConnection();
case 'setFavorite': setFavorite(); break; case 'getBonusHistory': getBonusHistory(); break; case 'getMultipleBidList': getMultipleBidList(); break; case 'getProjects': $userId = isset($_SESSION['userid']) ? $_SESSION['userid'] : 0; $currentUser = User::find($userId); getProjects(!$currentUser->isInternal()); break; case 'getUserList': getUserList(); break; case 'getUsersList': getUsersList(); break; case 'payBonus': payBonus(); break; case 'pingTask': pingTask(); break; case 'userReview': userReview(); break; case 'visitQuery': echo json_encode(VisitQueryTools::visitQuery((int) $_GET['jobid']));
/** * survey::_generalTabEditSurvey() * Load "General" tab of edit survey screen. * @param mixed $iSurveyID * @param mixed $esrow * @return */ private function _generalTabEditSurvey($iSurveyID, $esrow) { $aData['action'] = "editsurveysettings"; $aData['esrow'] = $esrow; $aData['surveyid'] = $iSurveyID; // Get users, but we only need id and name (NOT password etc) $users = getUserList(); $aData['users'] = array(); foreach ($users as $user) { $aData['users'][] = array('username' => $user['user'], 'uid' => $user['uid']); } $beforeSurveySettings = new PluginEvent('beforeSurveySettings'); $beforeSurveySettings->set('survey', $iSurveyID); App()->getPluginManager()->dispatchEvent($beforeSurveySettings); $aData['pluginSettings'] = $beforeSurveySettings->get('surveysettings'); return $aData; }
"data": {"group_name":"nouveau groupe"} }'; */ /*$jsonString = '{ "request": "createGroup", "data": {"group_name":"nouveau groupe"} }';*/ //$json = json_decode($jsonString,true); $json = json_decode(file_get_contents("php://input"), true); $request = $json["request"]; $response = null; if ($request == "getAllAccount") { $response = getUserList($json["userId"], $json["raw"], false); } else { if ($request == "getAllAccountReady") { $response = getUserList($json["userId"], $json["raw"], true); } else { if ($request == "save") { $response = saveUser($json["data"]); } else { if ($request == "createUser") { $response = createUser($json["raw"]); } else { if ($request == "saveGroups") { $response = saveGroups($json["data"]); } else { if ($request == "removeUserFromGroup") { $response = removeUserFromGroup($json["data"]); } else { if ($request == "addUserToGroup") { $response = addUserToGroup($json["data"]);
<?php require 'authCheck.php'; if (!isset($USER->id)) { return; } require 'queries/userQueries.php'; $PAGE->id = 'userlistGet'; //setup for query $stmt = getUserList($DB); if (!$stmt->execute()) { return errorHandler("failed to get this list {$stmt->errno}: {$stmt->error}"); } //format results $data = array(); $stmt->bind_result($data['userId'], $data['userName'], $data['userEmail']); /* fetch values */ $listResults = array(); while ($stmt->fetch()) { $row = arrayCopy($data); array_push($listResults, $row); } echo json_encode($listResults); function arrayCopy(array $array) { $result = array(); foreach ($array as $key => $val) { if (is_array($val)) { $result[$key] = arrayCopy($val); } elseif (is_object($val)) { $result[$key] = clone $val;
private function userSelect() { $this->add_onload_command("\$('select.form-control').focus();\n"); $ret = '<div class="form-group"> <label>Username</label> <select name="id" class="form-control">'; foreach (getUserList() as $uid => $name) { $ret .= "<option>" . $name . "</option>"; } $ret .= '</select></div>'; return $ret; }
/** * 获取关注比赛按钮_小 */ function get_follow_match_button($userid, $matchid) { if (intval($userid) == 0) { $userid = -1; } else { $users = getUserList($userid, $matchid); } if (!empty($users)) { if (intval($users[0]->apply_follow)) { ?> <div class="btn margin-r10 fl"> 已经关注 </div> <?php return; } } ?> <a class="btn margin-r10 fl" onclick="showWindowsFrameTimer('follow_match', 'wp-content/plugins/likedome/tournament.php?opt=follow&matchid=<?php echo $matchid; ?> &flag=1', 500);" > 关注比赛 </a> <?php }
updateUserInfo($tmp_u_id); echo "--------start getting {$tmp_u_id}'s " . $user_info['followees_count'] . " followees user list--------\n"; $followee_users = getUserList($tmp_u_id, 'followees', $user_info['followees_count'], 1); $tmp_redis->set($tmp_u_id, 'followees_count', count($followee_users)); if (!empty($followee_users)) { foreach ($followee_users as $user) { $tmp_redis->lpush('request_queue', $user[3]); } } Log::info('empty followee_users u_id' . $tmp_u_id); echo "--------get " . count($followee_users) . " followees users done--------\n"; } if ($user_info['followers_count'] != $user_followers_count) { updateUserInfo($tmp_u_id); echo "--------start getting {$tmp_u_id}'s " . $user_info['followers_count'] . " followers user list--------\n"; $follower_users = getUserList($tmp_u_id, 'followers', $user_info['followers_count'], 1); $tmp_redis->set($tmp_u_id, 'follower_users', count($follower_users)); if (!empty($follower_users)) { foreach ($follower_users as $user) { $tmp_redis->lpush('request_queue', $user[1]); } } Log::info('empty follower_users u_id' . $tmp_u_id); echo "--------get " . count($follower_users) . " followers users done--------\n"; } $tmp_redis->zadd('already_get_queue', 1, $tmp_u_id); $tmp_redis->close(); $endTime = microtime(); $startTime = explode(' ', $startTime); $endTime = explode(' ', $endTime); $total_time = $endTime[0] - $startTime[0] + $endTime[1] - $startTime[1];
function _mssql_make_user_with_grants($db, $the_host, $db_name, $login, $passwd) { _mssql_make_user($db, $the_host, $db_name, $login, $passwd); $op->status_ok = true; $op->msg = 'ok - new user'; // Check if has been created, because I'm not able to get return code. $user_list = getUserList($db, 'mssql'); $user_list = array_map('strtolower', $user_list); $user_exists = in_array(trim($login), $user_list); if (!$user_exists) { $op->status_ok = false; $op->msg = "ko - " . $db->error_msg(); } else { _mssql_assign_grants($db, $the_host, $db_name, $login, $passwd); } return $op; }
function tournament() { global $wpdb, $user_identity, $user_ID; header('Content-Type: text/html; charset=' . getCharset() . ''); if (intval($_REQUEST['matchid']) > 0 && intval($_REQUEST['opt']) > 0) { echo "参数错误!"; exit; } $matchid = intval($_REQUEST['matchid']); if (!empty($user_identity)) { $username = htmlspecialchars(addslashes($user_identity)); } else { if (!empty($_COOKIE['comment_author_' . COOKIEHASH])) { $username = htmlspecialchars(addslashes($_COOKIE['comment_author_' . COOKIEHASH])); } else { echo "需要登陆"; exit; } } switch ($_REQUEST['opt']) { case 'apply': if (!getUserVerify($user_ID)) { echo "需要选手认证才可以报名"; exit; } $apply = $wpdb->query("SELECT verify1 FROM pre_common_member_verify WHERE uid = {$user_ID}"); if (count(getUserList($user_ID, $matchid, -1, -1, 1)) > 0) { echo "你已经报过名了"; exit; } updateUser($user_ID, $matchid, -1, -1, 1); if (count(getUserList($user_ID, $matchid, -1, -1, 1)) > 0) { echo "报名成功!"; exit; } echo "报名时发生错误"; exit; case 'cancelapply': updateUser($user_ID, $matchid, -1, -1, 0); echo "报名已取消"; exit; case 'follow': updateUser($user_ID, $matchid, -1, 1); if (count(getUserList($user_ID, $matchid, -1, 1)) > 0) { echo "关注成功!"; exit; } echo "关注时发生错误"; exit; case 'cancelfollow': updateUser($user_ID, $matchid, -1, 0); echo "关注已取消"; exit; case 'cancelgroup': $groupid = intval($_REQUEST['groupid']); $memberid = intval($_REQUEST['memberid']); $users = getUserList($memberid); if (empty($users)) { echo "找不到此用户ID, " . $memberid; exit; } $groups = getGroupList(-1, $groupid); if (empty($groups)) { echo "找不到此队伍ID, " . $groupid; exit; } $matchs = getMatchList($groups[0]->match_id); if (empty($matchs)) { echo "找不到此队伍的比赛ID, error code : " . $groups[0]->match_id; exit; } if ($matchs[0]->stage != 1) { echo "比赛不处于报名阶段,无法退出 . error code : " . $groups[0]->match_id; exit; } if ($groups[0]->captain_id == $user_ID || $memberid == $user_ID) { // 队员离开 updateUser($memberid, $matchid, 0, -1, -1, 0, -1, 0); echo "已退出队伍"; exit; } echo "权限不足."; exit; case 'applygroup': $users = getUserList($user_ID, $matchid); if (!empty($users)) { $groupid = $_REQUEST['groupid']; if (intval($users[0]->apply_group)) { echo "您已经申请了其他的队伍!"; exit; } $groups = getGroupList($matchid, $groupid); if (empty($groups)) { echo "比赛" . $matchid . "中找不到这个队伍!" . $groupid; exit; } $groupusers = getUserList(-1, -1, $groupid); if ($groups[0]->maxpeople - 1 < count($groupusers)) { echo "这个队伍中的人数已经满了!" . $groupid; exit; } updateUser($user_ID, $matchid, $groupid, -1, -1, 1); echo "申请成功!"; exit; } echo "你尚未参加此项比赛!"; exit; case 'passapplygroup': $memberid = intval($_REQUEST['memberid']); $users = getUserList($memberid, $matchid); if (!empty($users)) { $groupid = intval($_REQUEST['groupid']); if ($users[0]->group_id == $groupid) { updateUser($memberid, $matchid, $groupid, -1, -1, 1, -1, 1); echo "通过申请!"; exit; } echo "申请失败!" . $users[0]->group_id . ":" . $groupid; exit; } echo "此用户尚未参加此项比赛!"; exit; case 'creategroup': $users = getUserList($user_ID, $matchid); if (!intval($users[0]->apply_match)) { echo "你尚未参加此项比赛!"; exit; } if (intval($users[0]->apply_group)) { echo "您已经申请了其他的队伍!"; exit; } $groupname = trim($_REQUEST['groupname']); $success = addGroup($groupname, $user_ID, $matchid); if (intval($success)) { $groups = getGroupList($matchid, -1, $user_ID); updateUser($user_ID, $matchid, $groups[0]->id, -1, -1, 1, -1, 1); echo "申请成功!"; exit; } echo "申请发生错误error code : " . $success; exit; case 'ranksubmit': $matchId = intval($_POST['matchId']); $matchTypeId = intval($_POST['matchTypeId']); $scheduleId = intval($_POST['scheduleId']); $applyId = intval(addUserRankApply($user_ID, $matchId, $scheduleId)); if (!$applyId) { echo "申请发生错误, Code:" . $applyId; exit; } $submit = getUserRankApplyList(-1, $user_ID, $matchId, $scheduleId); $rankTypeList = getRankTypeList(-1, $matchTypeId); foreach ($rankTypeList as $rankType) { $value = intval($_POST['rank-' . $rankType->id]); if ($value && $submit[0]->id) { $result = addUserRank($user_ID, $matchTypeId, $rankType->id, $value, 0, $submit[0]->id); if (!$result) { echo "录入信息失败,Code:" . $rankType->id; exit; } } else { echo "录入信息失败,Error Code:" . $value . " AND " . $submit[0]->id; exit; } } echo "提交选手成绩完成"; exit; default: echo "无法解析此函数"; exit; } }
/** * return error message as string, or true indicating success * requires setup to be written first. */ function setup_database() { $conn = DB_Helper::getInstance(false); $db_exists = checkDatabaseExists($conn, $_POST['db_name']); if (!$db_exists) { if (@$_POST['create_db'] == 'yes') { try { $conn->query("CREATE DATABASE {{{$_POST['db_name']}}}"); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_db', $e->getMessage())); } } else { throw new RuntimeException('The provided database name could not be found. Review your information or specify that the database should be created in the form below.'); } } // create the new user, if needed if (@$_POST['alternate_user'] == 'yes') { $user_list = getUserList($conn); if ($user_list) { $user_exists = in_array(strtolower(@$_POST['eventum_user']), $user_list); if (@$_POST['create_user'] == 'yes') { if (!$user_exists) { $stmt = "GRANT SELECT, UPDATE, DELETE, INSERT, ALTER, DROP, CREATE, INDEX ON {{{$_POST['db_name']}}}.* TO ?@'%' IDENTIFIED BY ?"; try { $conn->query($stmt, array($_POST['eventum_user'], $_POST['eventum_password'])); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_user', $e->getMessage())); } } } else { if (!$user_exists) { throw new RuntimeException('The provided MySQL username could not be found. Review your information or specify that the username should be created in the form below.'); } } } } // check if we can use the database try { $conn->query("USE {{{$_POST['db_name']}}}"); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('select_db', $e->getMessage())); } // set sql mode (sad that we rely on old bad mysql defaults) $conn->query("SET SQL_MODE = ''"); // check the CREATE and DROP privileges by trying to create and drop a test table $table_list = getTableList($conn); if (!in_array('eventum_test', $table_list)) { try { $conn->query('CREATE TABLE eventum_test (test char(1))'); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('create_test', $e->getMessage())); } } try { $conn->query('DROP TABLE eventum_test'); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('drop_test', $e->getMessage())); } // if requested. drop tables first if (@$_POST['drop_tables'] == 'yes') { $queries = get_queries(APP_PATH . '/upgrade/drop.sql'); foreach ($queries as $stmt) { try { $conn->query($stmt); } catch (DbException $e) { throw new RuntimeException(getErrorMessage('drop_table', $e->getMessage())); } } } // setup database with upgrade script $buffer = array(); try { $dbmigrate = new DbMigrate(APP_PATH . '/upgrade'); $dbmigrate->setLogger(function ($e) use(&$buffer) { $buffer[] = $e; }); $dbmigrate->patch_database(); $e = false; } catch (Exception $e) { } global $tpl; $tpl->assign('db_result', implode("\n", $buffer)); if ($e) { $upgrade_script = APP_PATH . '/upgrade/update-database.php'; $error = array('Database setup failed on upgrade:', "<tt>{$e->getMessage()}</tt>", '', "You may want run update script <tt>{$upgrade_script}</tt> manually"); throw new RuntimeException(implode('<br/>', $error)); } // write db name now that it has been created $setup = array(); $setup['database'] = $_POST['db_name']; // substitute the appropriate values in config.php!!! if (@$_POST['alternate_user'] == 'yes') { $setup['username'] = $_POST['eventum_user']; $setup['password'] = $_POST['eventum_password']; } Setup::save(array('database' => $setup)); }
} if (!$acess) { print_error('dennyacess', 'block_uniquelogin_list', '', $courseid); } $PAGE->set_context($context); $PAGE->set_course($course); $PAGE->set_url('/blocks/uniquelogin_list/list_users.php', array('courseid' => $courseid)); $PAGE->navbar->add(get_string("blocktitle", "block_uniquelogin_list")); $PAGE->set_title(get_string("blocktitle", "block_uniquelogin_list")); $PAGE->set_heading(get_string("blocktitle", "block_uniquelogin_list")); $PAGE->set_pagetype(get_string("blocktitle", "block_uniquelogin_list")); $PAGE->set_pagelayout('standard'); //Calculate if we are in separate groups $isseparategroups = $PAGE->course->groupmode == SEPARATEGROUPS && $PAGE->course->groupmodeforce && !has_capability('moodle/site:accessallgroups', $PAGE->context); $currentgroup = $isseparategroups ? groups_get_course_group($PAGE->course) : NULL; $aUsers = getUserList($currentgroup, $courseid, $PAGE->context->contextlevel, $PAGE->context); echo $OUTPUT->header(); echo '<h3>' . get_string("blocktitle_list", "block_uniquelogin_list") . '</h3>'; $baseurl = new moodle_url('/blocks/uniquelogin_list/list_users.php', array('contextid' => $context->id, 'courseid' => $courseid, 'perpage' => $perpage)); $table = new flexible_table('user-index-participants-' . $courseid); $table->define_columns(array('userpic', 'firstname', 'lastname', 'lastip', 'lastaccess', 'deletesession')); $table->define_headers(array(get_string('userpic'), get_string('firstname'), get_string('lastname'), 'IP', get_string('lastaccess'), get_string("deletesession", "block_uniquelogin_list"))); $table->define_baseurl($baseurl->out()); if (!isset($hiddenfields['lastaccess'])) { $table->sortable(true, 'lastaccess', SORT_DESC); } else { $table->sortable(true, 'firstname', SORT_ASC); } $table->set_attribute('cellspacing', '0'); $table->set_attribute('id', 'participants'); $table->set_attribute('class', 'generaltable generalbox');
function setusertemplates() { App()->getClientScript()->registerPackage('jquery-tablesorter'); App()->getClientScript()->registerScriptFile(Yii::app()->getConfig('adminscripts') . 'users.js'); $postuserid = (int) Yii::app()->request->getPost("uid"); $aData['postuser'] = flattenText(Yii::app()->request->getPost("user")); $aData['postemail'] = flattenText(Yii::app()->request->getPost("email")); $aData['postuserid'] = $postuserid; $aData['postfull_name'] = flattenText(Yii::app()->request->getPost("full_name")); $this->_refreshtemplates(); $templaterights = array(); foreach (getUserList() as $usr) { if ($usr['uid'] == $postuserid) { $trights = Permission::model()->findAllByAttributes(array('uid' => $usr['uid'], 'entity' => 'template')); foreach ($trights as $srow) { $templaterights[$srow["permission"]] = array("use" => $srow["read_p"]); } $templates = Template::model()->findAll(); $aData['list'][] = array('templaterights' => $templaterights, 'templates' => $templates); } } $this->_renderWrappedTemplate('user', 'setusertemplates', $aData); }
/** * This get the userlist in surveylist screen. * * @access public * @return void */ public function ajaxgetusers() { header('Content-type: application/json'); $result = getUserList(); $aUsers = array(); if (count($result) > 0) { foreach ($result as $rows) { $aUsers[$rows['user']] = $rows['uid']; } } ksort($aUsers); $ajaxoutput = ls_json_encode($aUsers) . "\n"; echo $ajaxoutput; }
/** * surveypermission::surveyright() * Function responsible to process setting of permission of a user/usergroup. * @param mixed $surveyid * @return void */ function surveyright($surveyid) { $aData['surveyid'] = $surveyid = sanitize_int($surveyid); $aViewUrls = array(); $action = $_POST['action']; $imageurl = Yii::app()->getConfig('imageurl'); $postuserid = !empty($_POST['uid']) ? $_POST['uid'] : false; $postusergroupid = !empty($_POST['ugid']) ? $_POST['ugid'] : false; if ($postuserid && !in_array($postuserid, getUserList('onlyuidarray'))) { $this->getController()->error('Access denied'); } elseif ($postusergroupid && !in_array($postusergroupid, getUserGroupList(null, 'simplegidarray'))) { $this->getController()->error('Access denied'); } if ($action == "surveyrights" && Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'update')) { $addsummary = "<div class='header ui-widget-header'>" . gT("Edit survey permissions") . "</div>\n"; $addsummary .= "<div class='messagebox ui-corner-all'>\n"; $where = ' '; if ($postuserid) { if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) { $where .= "sid = :surveyid AND owner_id != :postuserid AND owner_id = :owner_id"; $resrow = Survey::model()->find($where, array(':surveyid' => $surveyid, ':owner_id' => Yii::app()->session['loginID'], ':postuserid' => $postuserid)); } } else { $where .= "sid = :sid"; $resrow = Survey::model()->find($where, array(':sid' => $surveyid)); $iOwnerID = $resrow['owner_id']; } $aBaseSurveyPermissions = Permission::model()->getSurveyBasePermissions(); $aPermissions = array(); foreach ($aBaseSurveyPermissions as $sPermissionKey => $aCRUDPermissions) { foreach ($aCRUDPermissions as $sCRUDKey => $CRUDValue) { if (!in_array($sCRUDKey, array('create', 'read', 'update', 'delete', 'import', 'export'))) { continue; } if ($CRUDValue) { if (isset($_POST["perm_{$sPermissionKey}_{$sCRUDKey}"])) { $aPermissions[$sPermissionKey][$sCRUDKey] = 1; } else { $aPermissions[$sPermissionKey][$sCRUDKey] = 0; } } } } if (isset($postusergroupid) && $postusergroupid > 0) { $oResult = UserInGroup::model()->findAll('ugid = :ugid AND uid <> :uid AND uid <> :iOwnerID', array(':ugid' => $postusergroupid, ':uid' => Yii::app()->session['loginID'], ':iOwnerID' => $iOwnerID)); if (count($oResult) > 0) { foreach ($oResult as $aRow) { Permission::model()->setPermissions($aRow->uid, $surveyid, 'survey', $aPermissions); } $addsummary .= "<div class=\"successheader\">" . gT("Survey permissions for all users in this group were successfully updated.") . "</div>\n"; } } else { if (Permission::model()->setPermissions($postuserid, $surveyid, 'survey', $aPermissions)) { $addsummary .= "<div class=\"successheader\">" . gT("Survey permissions were successfully updated.") . "</div>\n"; } else { $addsummary .= "<div class=\"warningheader\">" . gT("Failed to update survey permissions!") . "</div>\n"; } } $addsummary .= "<br/><input type=\"submit\" onclick=\"window.open('" . $this->getController()->createUrl('admin/surveypermission/sa/view/surveyid/' . $surveyid) . "', '_top')\" value=\"" . gT("Continue") . "\"/>\n"; $addsummary .= "</div>\n"; $aViewUrls['output'] = $addsummary; } else { $this->getController()->error('Access denied'); } $this->_renderWrappedTemplate('authentication', $aViewUrls, $aData); }
function setusertemplates() { $this->getController()->_js_admin_includes(Yii::app()->getConfig('generalscripts') . 'jquery/jquery.tablesorter.min.js'); $this->getController()->_js_admin_includes(Yii::app()->getConfig('adminscripts') . 'users.js'); $aData['postuser'] = Yii::app()->request->getPost("user"); $aData['postemail'] = Yii::app()->request->getPost("email"); $postuserid = Yii::app()->request->getPost("uid"); $aData['postuserid'] = $postuserid; $aData['postfull_name'] = Yii::app()->request->getPost("full_name"); $this->_refreshtemplates(); foreach (getUserList() as $usr) { if ($usr['uid'] == $postuserid) { $trights = Templates_rights::model()->findAllByAttributes(array('uid' => $usr['uid'])); foreach ($trights as $srow) { $templaterights[$srow["folder"]] = array("use" => $srow["use"]); } $templates = Template::model()->findAll(); $aData['list'][] = array('templaterights' => $templaterights, 'templates' => $templates); } } $this->_renderWrappedTemplate('user', 'setusertemplates', $aData); }
/** * surveypermission::surveyright() * Function responsible to process setting of permission of a user/usergroup. * @param mixed $surveyid * @return void */ function surveyright($surveyid) { $aData['surveyid'] = $surveyid = sanitize_int($surveyid); $aViewUrls = array(); $action = $_POST['action']; $imageurl = Yii::app()->getConfig('imageurl'); $postuserid = !empty($_POST['uid']) ? $_POST['uid'] : false; $postusergroupid = !empty($_POST['ugid']) ? $_POST['ugid'] : false; if ($postuserid && !in_array($postuserid, getUserList('onlyuidarray'))) { $this->getController()->error('Access denied'); } elseif ($postusergroupid && !in_array($postusergroupid, getUserGroupList(null, 'simplegidarray'))) { $this->getController()->error('Access denied'); } if ($action == "surveyrights" && Permission::model()->hasSurveyPermission($surveyid, 'surveysecurity', 'update')) { $addsummary = "<div id='edit-permission' class='side-body " . getSideBodyClass(false) . "'>"; $addsummary .= '<div class="row"><div class="col-lg-12 content-right">'; $addsummary .= "<div class=\"jumbotron message-box\">\n"; $addsummary .= "<h2>" . gT("Edit survey permissions") . "</h2>\n"; $where = ' '; if ($postuserid) { if (!Permission::model()->hasGlobalPermission('superadmin', 'read')) { $where .= "sid = :surveyid AND owner_id != :postuserid AND owner_id = :owner_id"; $resrow = Survey::model()->find($where, array(':surveyid' => $surveyid, ':owner_id' => Yii::app()->session['loginID'], ':postuserid' => $postuserid)); } } else { $where .= "sid = :sid"; $resrow = Survey::model()->find($where, array(':sid' => $surveyid)); $iOwnerID = $resrow['owner_id']; } $aBaseSurveyPermissions = Permission::model()->getSurveyBasePermissions(); $aPermissions = array(); foreach ($aBaseSurveyPermissions as $sPermissionKey => $aCRUDPermissions) { foreach ($aCRUDPermissions as $sCRUDKey => $CRUDValue) { if (!in_array($sCRUDKey, array('create', 'read', 'update', 'delete', 'import', 'export'))) { continue; } if ($CRUDValue) { if (isset($_POST["perm_{$sPermissionKey}_{$sCRUDKey}"])) { $aPermissions[$sPermissionKey][$sCRUDKey] = 1; } else { $aPermissions[$sPermissionKey][$sCRUDKey] = 0; } } } } if (isset($postusergroupid) && $postusergroupid > 0) { $oResult = UserInGroup::model()->findAll('ugid = :ugid AND uid <> :uid AND uid <> :iOwnerID', array(':ugid' => $postusergroupid, ':uid' => Yii::app()->session['loginID'], ':iOwnerID' => $iOwnerID)); if (count($oResult) > 0) { foreach ($oResult as $aRow) { Permission::model()->setPermissions($aRow->uid, $surveyid, 'survey', $aPermissions); } $addsummary .= "<div class=\"successheader\">" . gT("Survey permissions for all users in this group were successfully updated.") . "</div>\n"; } } else { if (Permission::model()->setPermissions($postuserid, $surveyid, 'survey', $aPermissions)) { Yii::app()->setFlashMessage(gT("Survey permissions were successfully updated.")); } else { Yii::app()->setFlashMessage(gT("Failed to update survey permissions!")); } if (App()->getRequest()->getPost('close-after-save') == 'false') { Yii::app()->request->redirect(Yii::app()->getController()->createUrl('admin/surveypermission/sa/set', array('action' => 'setsurveysecurity', 'surveyid' => $surveyid, 'uid' => $postuserid))); } Yii::app()->request->redirect(Yii::app()->getController()->createUrl('admin/surveypermission/sa/view', array('surveyid' => $surveyid))); } $addsummary .= "<br/><input class='btn btn-default' type=\"submit\" onclick=\"window.open('" . $this->getController()->createUrl('admin/surveypermission/sa/view/surveyid/' . $surveyid) . "', '_top')\" value=\"" . gT("Continue") . "\"/>\n"; $addsummary .= "</div></div></div>\n"; $aViewUrls['output'] = $addsummary; } else { $this->getController()->error('Access denied'); } $aData['sidemenu']['state'] = false; $surveyinfo = Survey::model()->findByPk($surveyid)->surveyinfo; $aData['title_bar']['title'] = $surveyinfo['surveyls_title'] . "(" . gT("ID") . ":" . $surveyid . ")"; $this->_renderWrappedTemplate('authentication', $aViewUrls, $aData); }