function getDirectoryList($directory) { // create an array to hold directory list $results = array(); // create a handler for the directory $handler = opendir($directory); // open directory and walk through the filenames while ($file = readdir($handler)) { // if file isn't this directory or its parent, add it to the results if ($file != "." && $file != "..") { $results[] = $file; } } // tidy up: close the handler closedir($handler); if (in_array(".DS_Store", $results)) { $results = remove_item_by_value($results, ".DS_Store"); } if (in_array("index.php", $results)) { $results = remove_item_by_value($results, "index.php"); } /*if (in_array("Thefile", $results)) { $results = remove_item_by_value($results, "Thefile"); }*/ //for blacklisting a file if (in_array("POSTTEMPLATE", $results)) { $results = remove_item_by_value($results, "POSTTEMPLATE"); } // done! return $results; }
function remove_favorite() { $post_id = (int) $_POST['post_id']; $user_login_id2 = get_user_by("id", get_current_user_id()); $_favorites = get_user_meta(get_current_user_id(), $user_login_id2->user_login . "_favorites"); if (is_array($_favorites[0])) { if (in_array($post_id, $_favorites[0])) { $remove_item = remove_item_by_value($_favorites[0], $post_id); update_user_meta(get_current_user_id(), $user_login_id2->user_login . "_favorites", $remove_item); } } $count = get_post_meta($post_id, 'question_favorites', true); if (!$count) { $count = 0; } $count--; if ($count < 0) { $count = 0; } $update = update_post_meta($post_id, 'question_favorites', $count); die; }
if (!$appEngine->isUserViewActive() || !$appEngine->isGroupViewActive() || !$appEngine->isGroupEditActive()) { $appEngine->forwardInvalidModule(true); } $appEngine->checkUserAuthentication(true, ACL_MOD_GROUP, ACL_ACTION_ASSIGN); // Load language. $appTR->loadModule("groupassign"); // Form request. $assign = check_request_var('assign'); if ($assign) { $appEngine->handleAction('assign_togroup'); } // User list. $users = null; if ($appEngine->isUserViewActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_USER, ACL_ACTION_VIEW)) { $users = $appEngine->getUserViewProvider()->getUsers(); // Remove the * user from array. $o = new \svnadmin\core\entities\User(); $o->id = '*'; $o->name = '*'; $users = remove_item_by_value($users, $o, true); usort($users, array('\\svnadmin\\core\\entities\\User', "compare")); } // Group list. $groups = null; if ($appEngine->isGroupViewActive() && $appEngine->checkUserAuthentication(false, ACL_MOD_GROUP, ACL_ACTION_VIEW)) { $groups = $appEngine->getGroupViewProvider()->getGroups(); usort($groups, array('\\svnadmin\\core\\entities\\Group', "compare")); } SetValue("UserList", $users); SetValue("GroupList", $groups); ProcessTemplate("group/membership.html.php");
function closeChat() { unset($_SESSION['openChatBoxes'][$_POST['chatbox']]); if (str_replace(' ', '_', $_POST['chatbox']) != $_SESSION["lessonid"] && in_array(str_replace(' ', '_', $_POST['chatbox']), $_SESSION['lesson_rooms'])) { $_SESSION['lesson_rooms'] = remove_item_by_value($_SESSION['lesson_rooms'], str_replace(' ', '_', $_POST['chatbox'])); } echo $_POST['chatbox']; exit(0); }
function build_query_string($desired_cols, $search_term, $params, $user_id = NULL, $limit = NULL, $start = NULL) { //No search term short circuit if ($user_id) { array_push($desired_cols, "prof.id in (select prof_id from bookmarked_professors where user_id = {$user_id}) as starred"); } $desired_cols = remove_item_by_value($desired_cols, "starred"); $starred = False; $limit_str = ''; if ($start && $limit) { $limit_str = "limit {$start}, {$limit}"; } else { if ($limit) { $limit_str = "limit {$limit}"; } } if (isset($params['starred'])) { unset($params['starred']); $starred = True; } $where_queries = ""; if ($starred && $user_id) { $where_queries = "exists (select prof_id from bookmarked_professors where user_id = {$user_id} and prof_id = prof.id)"; } if ($where_queries != "" && $search_term) { $where_queries .= " and "; } if ($search_term) { $search_term = process_search_term($search_term); $where_queries .= "match (keyword) against ('{$search_term}' in boolean mode)"; } foreach ($params as $filter => $value_list) { $vals = explode(",", $value_list); $possible_values = "'" . join('\',\'', $vals) . "'"; $where_queries .= " and {$filter} in ({$possible_values})"; } if (strpos($where_queries, " and") === 0) { $where_queries = substr($where_queries, 4); } if ($where_queries != "") { $where_queries = "where " . $where_queries; } $col_terms = implode(", ", $desired_cols); if ($search_term) { $stmnt = "\n select {$col_terms} from prof\n where match(name) against('{$search_term}*' in boolean mode) \n union\n select " . $col_terms . " from keywords \n inner join keywordmap on keywords.id=keywordmap.keyword_id \n join prof on prof.id = keywordmap.prof_id \n {$where_queries}\n union\n select distinct {$col_terms} from prof " . str_replace("match (keyword)", "match (research_summary)", $where_queries); } else { $stmnt = "select distinct " . $col_terms . " from bookmarked_professors inner join prof on prof.id=bookmarked_professors.prof_id " . $where_queries . ' ' . $limit_str; } if ($start || $limit) { return "select SQL_CALC_FOUND_ROWS * from ({$stmnt}) as T {$limit_str}"; } else { return $stmnt; } }