function wikipedia_search($procd_descr) { profiling_start('wikipedia_search'); $TERMS = wikipedia_process_term($procd_descr); $url = wikipedia_url($TERMS); $data = cached_file_get_contents($url); Error::setPrepend($data); Error::generate('debug', 'WIKIPEDIA'); eval('$arr = ' . $data . ';'); foreach ($arr['query']['pages'] as $k => $v) { $title = urlencode($v['title']); $url = urlencode($v['fullurl']); // https://dgl.cx/2008/10/wikipedia-summary-dns if ($k == -1) { // not found return array(); } break; } // this is probably a topic from a random unintended field like "frequency analysis (cryptoanalysis)" if (strlen($title) < strlen($TERMS) - 5 || strlen($title) > strlen($TERMS) + 5 || strrchr($title, '%28')) { return array(); } $store = array('title' => urldecode(str_replace('+', ' ', $title)), 'link' => urldecode($url), 'source' => 'wikipedia'); profiling_end('wikipedia_search'); return array($store); }
<?php @session_start(); @db_connect(); $memcached = new Memcached(); $memcached->addServer('localhost', 11211); controller_prefix(); if (isset($_SESSION)) { Error::setPrepend($_SESSION); } Error::generate('debug', 'start controller'); @(include "{$ROOT}/includes/tags.inc"); @(include "dataacquisition/search.util.php"); @(include "{$ROOT}/includes/subjects.inc"); @(include "{$ROOT}/includes/universities.inc"); @(include "{$ROOT}/includes/geography.inc"); $CONTROLLER = 'course'; $PAGE_REL_URL = "{$HTMLROOT}"; $ACTIONS = array('search' => new HttpAction("{$PAGE_REL_URL}/search", 'get', array('id')), 'search2' => new HttpAction("{$PAGE_REL_URL}/search", 'get', array('terms')), 'list' => new HttpAction("{$PAGE_REL_URL}/list", 'get', array()), 'show' => new HttpAction("{$PAGE_REL_URL}/show", 'get', array('id')), 'list2' => new HttpAction("{$PAGE_REL_URL}/show", 'get', array()), 'post' => new HttpAction("{$PAGE_REL_URL}/post", 'post', array('subject', 'body', 'cid')), 'contact' => new HttpAction("{$PAGE_REL_URL}/contact", 'get', array()), 'terms' => new HttpAction("{$PAGE_REL_URL}/terms", 'get', array()), 'privacy' => new HttpAction("{$PAGE_REL_URL}/privacy", 'get', array()), 'about' => new HttpAction("{$PAGE_REL_URL}/about", 'get', array()), 'countries' => new HttpAction("{$PAGE_REL_URL}/countries", 'get', array()), 'areas' => new HttpAction("{$PAGE_REL_URL}/areas", 'get', array('country')), 'universities' => new HttpAction("{$PAGE_REL_URL}/universities", 'get', array('area')), 'subjects' => new HttpAction("{$PAGE_REL_URL}/subjects", 'get', array('university')), 'subject' => new HttpAction("{$PAGE_REL_URL}/subject", 'get', array('university', 'code')), 'index' => new HttpAction("{$PAGE_REL_URL}/", 'get', array()), 'autocomplete' => new HttpAction("{$PAGE_REL_URL}/autocomplete", 'get', array('list')), 'favs' => new HttpAction("{$PAGE_REL_URL}/favs", 'post', array('cid', 'owner', 'type')), 'favsrm' => new HttpAction("{$PAGE_REL_URL}/favsrm", 'post', array('cid', 'owner', 'type')), 'voteup' => new HttpAction("{$PAGE_REL_URL}/voteup", 'post', array('id', 'cid', 'owner', 'type')), 'votedown' => new HttpAction("{$PAGE_REL_URL}/votedown", 'post', array('id', 'cid', 'owner', 'type')), 'check_lock' => new HttpAction("{$PAGE_REL_URL}/check_lock", 'post', array('cid')), 'invalidate' => new HttpAction("{$PAGE_REL_URL}/invalidate", 'get', array('id'), 'admin')); $search_results = array(); $action = false; $params = array(); foreach ($ACTIONS as $key => $val) { if ($val->wasCalled()) { if (!$action) { $action = $key; } $params = array_merge($params, $ACTIONS[$action]->getParams()); break; } }
<?php } ?> <div id="sidebar_course_recommendations">People who viewed this course also viewed:</div> <div id="sidebar_recommendation_tagcloud_hidden" class="hidden"> <?php $ctr = 0; Error::setPrepend($other_views); Error::generate('debug', 'Recommendation array'); $reduced_recs = array(); $i = 0; foreach ($other_views as $k => $v) { $reduced_recs[$i++] = $v; } $n_rrecs = $i; Error::setPrepend($reduced_recs); Error::generate('debug', 'Reduced Recommendation array'); $topn = 10; // limit to $topn top results foreach ($other_views as $k => $v) { if (++$ctr == $topn) { break; } // limit to $topn top results $id = intval($k); $subj = ucfirst(Comment::GetSubject($id)); $crs = new CourseDefn($subj); $success = $crs->load(); $hrefid = $crs->id; // cloudinizr javascript is in template_end for ($i = 0; $i < $v / $reduced_recs[min(10, $n_rrecs - 1)]; $i++) {
arsort($similarities); if ($similarities && count($similarities) > 0) { ?> <div id="course_similarities"> <?php } else { ?> <div id="course_similarities" class="hidden"> <?php } ?> <div id="sidebar_course_similarities">Similar courses:</div> <div id="sidebar_similarities_tagcloud_hidden" class="hidden"> <?php $ctr = 0; Error::setPrepend($similarities); Error::generate('debug', 'Similarity array'); $topn = 10; // limit to $topn top results foreach ($similarities as $k => $v) { if (++$ctr == $topn) { break; } // limit to $topn top results $id = intval($k); $subj = ucfirst(Comment::GetSubject($id)); $crs = new CourseDefn($subj); $crs->load(); $hrefid = $crs->id; // cloudinizr javascript is in template_end for ($i = 0; $i < (double) $similarities[$k] * 10; $i++) {