/** J\"{a}rjest\"{a} kysymykset tagin mukaan */ function organize_questions_by_tag() { /* $end_array array * $tags_and_Qid array * $titles_and_Qid array * $titles array * $was_sent_at_times array * $usernames array * $user_ids array */ $end_array = get_tags(); $tags_and_Qid = get_tags(); $titles_and_Qid = get_titles(); $titles = get_titles(); $was_sent_at_times = get_was_sent_at_times(); $usernames = get_usernames(); $user_ids = get_user_ids(); if ($_GET['tab_tag'] == 'oldest') { organize_questions($end_array, $tags_and_Qid, $titles_and_Qid, $titles, $was_sent_at_times, $usernames, $user_ids); } else { organize_questions(array_reverse($end_array, true), $tags_and_Qid, $titles_and_Qid, $titles, $was_sent_at_times, $usernames, $user_ids); } }
$sql = "SELECT facebook_id \n\t\tFROM user"; $result = $connection->query($sql); $id_array = array(); if ($result->num_rows > 0) { $i = 0; while ($row = $result->fetch_assoc()) { $id_array[$i++] = $row['facebook_id']; } } return $id_array; } function befriends($id_a, $id_b, $connection) { $sql = "INSERT INTO FriendsWith (facebook_id_a, facebook_id_b)\n\t\tVALUES ('{$id_a}', '{$id_b}')"; $result = $connection->query($sql); } $conn = new mysqli($servername, $username, $password, $dbname); if (mysqli_connect_error()) { die("Databse failed: " . mysqli_connect_error()); } $user_ids_1 = get_user_ids($conn); $user_ids_2 = get_user_ids($conn); for ($i = 0; $i < 10; $i++) { shuffle($user_ids_1); shuffle($user_ids_2); $j = 0; foreach ($user_ids_1 as $user) { befriends($user, $user_ids_2[$j], $conn); $j++; } }
public function pushMessage($folder, $title, $result) { $contacts = D('SystemFolder')->get_folder_member($folder); $ids = get_user_ids($contacts['read']); foreach ($ids as $id) { if ($id == UID) { } else { person_push(get_userEmpNo($id), "收到新的通知", $title, 1, $result); } } }
if (mysqli_connect_error()) { die("Databse failed: " . mysqli_connect_error()); } //extract facebook_id if ($_GET) { $facebook_id = $_GET['facebook_id']; } else { $facebook_id = $argv[1]; } if (check_id_exists($facebook_id, $conn) == 0) { echo "-1"; return; } $A_perm = get_events_attended($facebook_id, $conn); $N_perm = get_events_not_attended($facebook_id, $conn); $user_ids = get_user_ids($facebook_id, $conn); //echo "count : ", count($user_ids), "<br>"; $similarity_indices = array(); foreach ($user_ids as $id) { $A_2 = get_events_attended($id, $conn); $N_2 = get_events_attended($id, $conn); $similarity_indices["{$id}"] = calculate_similarity_index($A_perm, $N_perm, $A_2, $N_2); //echo $id, " ------ ", $similarity_indices["$id"], "<br>"; } $event_ids = get_events($conn); $event_probablity = array(); foreach ($event_ids as $event_id) { //echo $event_id, " : "; $users_attending = get_attendance($event_id, $facebook_id, $conn); $sum_similarity; settype($sum_similarity, "float");
$result = $connection->query($sql); $id_array = array(); if ($result->num_rows > 0) { $i = 0; while ($row = $result->fetch_assoc()) { $id_array[$i++] = $row['id']; } } return $id_array; } function attends_event($event_id, $facebook_id, $connection) { $sql = "INSERT INTO IsAttending (event_id, facebook_id)\n\t\tVALUES ({$event_id}, '{$facebook_id}')"; $result = $connection->query($sql); } $conn = new mysqli($servername, $username, $password, $dbname); if (mysqli_connect_error()) { die("Databse failed: " . mysqli_connect_error()); } $events_array = get_events($conn); $length = count($events_array); echo $length, "<br>"; $user_ids = get_user_ids($conn); for ($i = 0; $i < 10; $i++) { shuffle($events_array); $j = 0; foreach ($user_ids as $user) { attends_event($events_array[rand(0, 100000) % $length], $user, $conn); $j++; } }