$userID = $_SESSION['user_id']; $videoID = $_GET['video_id']; $annotationMode = $_GET['annotation_mode']; $viewMode = intval($_GET['view_mode']); //(isset($flagMode)) ? $flagMode = true : $flagMode = false; // strip out hash $videoID = str_replace("#", "", $videoID); //print "flagMode($flagMode)\n"; //(is_bool($flagMode)) ? print "flagMode is a bool" : print "flagMode is ! a bool"; //(is_string($flagMode)) ? print "flagMode is a string" : print "flagMode is ! a string"; $annotationsDB = new annotationsDB(); $annotations = $annotationsDB->getAnnotations($videoID, $userID, $annotationMode, $viewMode); //print_r($annotations); $jsonString; // TODO: this bit is redundant // annotation ownership property if (count($annotations) > 0) { foreach ($annotations as $key => $val) { //print "key:$key<br />"; if ($userID == $annotations[$key]['user_id']) { $annotations[$key]['my_annotation'] = "true"; } else { $annotations[$key]['my_annotation'] = "false"; } // automatically make links clickable (while stripping out everything else to prevent XSS) $annotations[$key]['description_with_html'] = makeLinksClickable($annotations[$key]['description']); } } //print_r($annotations); $jsonString .= json_encode($annotations); print $jsonString;
checkMessageSize(); checkFlood(); } $post = newPost(setParent()); $post['ip'] = $_SERVER['REMOTE_ADDR']; list($post['name'], $post['tripcode']) = nameAndTripcode($_POST['name']); $post['name'] = cleanString(substr($post['name'], 0, 75)); $post['email'] = cleanString(str_replace('"', '"', substr($_POST['email'], 0, 75))); $post['subject'] = cleanString(substr($_POST['subject'], 0, 75)); if ($rawpost) { $rawposttext = $isadmin ? ' <span style="color: red;">## Admin</span>' : ' <span style="color: purple;">## Mod</span>'; $post['message'] = $_POST['message']; // Treat message as raw HTML } else { $rawposttext = ''; $post['message'] = str_replace("\n", '<br>', makeLinksClickable(colorQuote(postLink(cleanString(rtrim($_POST['message'])))))); } $post['password'] = $_POST['password'] != '' ? md5(md5($_POST['password'])) : ''; $post['nameblock'] = nameBlock($post['name'], $post['tripcode'], $post['email'], time(), $rawposttext); if (isset($_POST['embed']) && trim($_POST['embed']) != '') { list($service, $embed) = getEmbed(trim($_POST['embed'])); if (empty($embed) || !isset($embed['html']) || !isset($embed['title']) || !isset($embed['thumbnail_url'])) { fancyDie("Invalid embed URL. Only YouTube, Vimeo, and SoundCloud URLs are supported."); } $post['file_hex'] = $service; $temp_file = time() . substr(microtime(), 2, 3); $file_location = "thumb/" . $temp_file; file_put_contents($file_location, file_get_contents($embed['thumbnail_url'])); $file_info = getimagesize($file_location); $file_mime = $file_info['mime']; $post['image_width'] = $file_info[0];
public function act_load_grid() { global $global; include_once 'searchSql.php'; $start = (int) $_GET['iDisplayStart']; $limit = (int) $_GET['iDisplayLength']; if (!$limit) { $limit = 10; } //convert json query to an object $query = json_decode($_GET['query']); //build the select field array $fields_array = array(); $entities = analysis_get_search_entities(); if ($query->group_by != NULL) { //if the query is a count put group by field to the array foreach ($query->group_by as $field) { $entity = isset($entities[$field->entity]['ac_type']) ? $entities[$field->entity]['ac_type'] : $field->entity; $mt = is_mt_field($entity, $field->field); array_push($fields_array, array('name' => $field->entity . '_' . $field->field, 'mt' => $mt)); } array_push($fields_array, array('name' => 'count')); } else { //if the query is a search put select fields to the array foreach ($query->select as $field) { $entity = isset($entities[$field->entity]['ac_type']) ? $entities[$field->entity]['ac_type'] : $field->entity; $mt = is_mt_field($entity, $field->field); array_push($fields_array, array('name' => $field->entity . '_' . $field->field, 'mt' => $mt)); } } //var_dump('fields_array',$fields_array); if (!$sidx) { $sidx = 1; } $searchSql = new SearchResultGenerator(); $sqlArray = $searchSql->sqlForJsonQuery($_GET['query']); //var_dump($_GET['query'],$sqlArray['result']);exit; //$count_query = $sqlArray['count']; $count_query = "SELECT COUNT(*) FROM ({$sqlArray['result']}) as results"; //var_dump($sqlArray['result']);exit; try { $res_count = $global['db']->Execute($count_query); } catch (Exception $e) { $response->error = "error"; echo $e->getMessage(); $res_count = null; } if ($res_count != null) { while (!$res_count->EOF) { $count = $res_count->fields[0]; $res_count->MoveNext(); } } if ($count > 0) { $total_pages = ceil($count / $limit); } else { $total_pages = 0; } if ($page > $total_pages) { $page = $total_pages; } // $start = $limit * $page - $limit; if ($start < 0) { $start = 0; } $sql = $sqlArray['result']; //print $sql; if ($limit != -1) { $sql .= " LIMIT {$start} , {$limit}"; } //$sql .= "LIMIT $start , $limit"; //echo $sql; try { $res = $global['db']->Execute($sql); } catch (Exception $e) { $response->error = "error"; //$e->getMessage(); } $response->sEcho = intval($_GET['sEcho']); $response->page = (int) $page; // current page $response->iTotalRecords = (int) $count; // total pages $response->iTotalDisplayRecords = (int) $count; // total records //$response->aaSorting = array(array(1=>"desc")); $i = 0; $aoColumns = array(); foreach ($fields_array as $fields_arrayItem) { $aoColumns[] = array("mData" => $fields_arrayItem["name"], "sTitle" => $fields_arrayItem["name"]); } $number_of_fields = count($fields_array); $response->aaData = array(); foreach ($res as $key => $val) { //$response->aaData[$i]['id'] = $val[$fields_array[0]]; $array_values = array(); $array_values['id'] = $val[$fields_array[0]]; for ($count = 0; $number_of_fields > $count; $count++) { $field_name = $fields_array[$count]['name']; $record_number_field = substr($field_name, strlen($field_name) - 13); $confidentiality_field = substr($field_name, strlen($field_name) - 15); $deceased_field = substr($field_name, strlen($field_name) - 8); $doc_field = substr($field_name, strlen($field_name) - 6); if ($confidentiality_field == 'confidentiality') { if ($val[$field_name] == 'y') { $val[$field_name] = _t('YES'); } else { $val[$field_name] = _t('NO'); } } if ($deceased_field == 'deceased') { if ($val[$field_name] == 'y') { $val[$field_name] = _t('YES'); } else { $val[$field_name] = _t('NO'); } } $string = null; if ($fields_array[$count]['mt']) { $list = explode(',', $val[$field_name]); foreach ($list as $term) { $string = $string . ", " . get_mt_term(trim($term)); } $array_values[$field_name] = ltrim($string, ','); } else { if ($record_number_field == 'record_number' || $doc_field == 'doc_id') { if (preg_match('/event/', $field_name)) { $link_entity = 'event'; } else { if (preg_match('/act/', $field_name)) { $link_entity = 'act'; } else { if (preg_match('/source/', $field_name)) { $link_entity = 'source'; } else { if (preg_match('/perpetrator/', $field_name)) { $link_entity = 'perpetrator'; } else { if (preg_match('/victim/', $field_name)) { $link_entity = 'victim'; } else { if (preg_match('/involvement/', $field_name)) { $link_entity = 'involvement'; } else { if (preg_match('/information/', $field_name)) { $link_entity = 'information'; } else { if (preg_match('/intervention/', $field_name)) { $link_entity = 'intervention'; } else { if (preg_match('/intervening_party/', $field_name)) { $link_entity = 'intervening_party'; } else { if (preg_match('/person/', $field_name)) { $link_entity = 'person'; } else { if (preg_match('/biographic_details/', $field_name)) { $link_entity = 'biographic_details'; } else { if (preg_match('/supporting_docs_meta/', $field_name)) { $link_entity = 'supporting_docs_meta'; } else { if (preg_match('/address/', $field_name)) { $link_entity = 'address'; } } } } } } } } } } } } } if ($link_entity != 'address') { $url = get_record_url($val[$field_name], $link_entity); $array_values[$field_name] = "<a href='{$url}' target='_blank'>" . $val[$field_name] . "</a>"; } else { $array_values[$field_name] = $val[$field_name]; } } else { $array_values[$field_name] = makeLinksClickable($val[$field_name]); } } } $response->aaData[$i] = $array_values; $i++; } $response->aoColumns = $aoColumns; echo json_encode($response); exit(0); }