Ejemplo n.º 1
0
 function get_services_main($nrpp)
 {
     // START INIT VARS \\
     global $path_site;
     $return = NULL;
     $append_url = NULL;
     $list = NULL;
     $page = (BRequest::getVar('smpage', false) and preg_match('/^[0-9]{1,999}$/i', BRequest::getVar('smpage'))) ? BRequest::getVar('smpage') : 1;
     // $_REQUEST['s'] = sort and value=r is ratings, value=l is likes
     if (BRequest::getVar('s') == 'r') {
         $SORT = ", avg(r.`rating`) desc";
         $append_url .= '&s=r';
     } else {
         if (BRequest::getVar('s') == 'l') {
             $SORT = ", sum(l.`like`) desc";
             $append_url .= '&s=l';
         } else {
             $SORT = NULL;
         }
     }
     // $_REQUEST['r'] = release and value=n is latest to oldest released, value=o is oldest to newest
     if (BRequest::getVar('r') == 'n') {
         $RELEASE = ",b.dateCreated desc";
         $append_url .= '&r=n';
     } else {
         if (BRequest::getVar('r') == 'o') {
             $RELEASE = ",b.dateCreated asc";
             $append_url .= '&r=o';
         } else {
             $RELEASE = NULL;
         }
     }
     // RANDOM TRIGGER IF NO SORTING SET
     $RAND = NULL;
     if (empty($SORT) && empty($RELEASE)) {
         $RAND = 'RAND()';
     } else {
         if (!empty($SORT)) {
             $SORT = substr($SORT, 1);
         } else {
             if (!empty($RELEASE)) {
                 $RELEASE = substr($RELEASE, 1);
             }
         }
     }
     $startof = $page * $nrpp - $nrpp + 1;
     $endof = $page * $nrpp;
     $append_url = isset($_SESSION['category']) ? $append_url . '&category=' . urlencode($_SESSION['category']) : $append_url;
     $append_url = isset($_SESSION['collection']) ? $append_url . '&collection=' . urlencode($_SESSION['collection']) : $append_url;
     $append_url = isset($_SESSION['asssortment']) ? $append_url . '&asssortment=' . urlencode($_SESSION['asssortment']) : $append_url;
     $append_url = BRequest::getVar('spage', false) ? $append_url . '&spage=' . BRequest::getVar('spage') : $append_url;
     // END INIT VARS \\
     // GO
     if (isset($_SESSION['assortment'])) {
         $catid = 108;
         $colid = get_colid_from_name(html_entity_decode(urldecode($_SESSION['collection'])));
         $asstid = get_asstid_from_name(html_entity_decode(urldecode($_SESSION['assortment'])));
         $cacid = get_cacid($catid, $colid);
         $ccaid = get_ccaid($cacid, $asstid);
         $query = "select b.id as id,b.name as name,b.flag_SS as type,b.urlPM as url,b.desc as `desc`, i.filepath as fp, i.file as f, avg(r.`rating`) as rating from rel_serv_cca rscca\n\t\t\t\t\t\tjoin business b on rscca.bizid=b.id\n\t\t\t\t\t\tleft join images i on b.id = i.itemid\n\t\t\t\t\t\tleft join likes l on b.id=l.itemid\n\t\t\t\t\t\tleft join ratings r on b.id=r.itemid\n\t\t\t\t\t\t\twhere i.item='businessicon' and b.status='active' and rscca.catid='108' and rscca.cacid='" . $cacid . "' and rscca.ccaid='" . $ccaid . "'\n\t\t\t\t\t\t\t\tgroup by b.id\n\t\t\t\t\t\t\t\torder by " . $RAND . $SORT . $RELEASE;
     } else {
         if (isset($_SESSION['collection'])) {
             $catid = 108;
             $colid = get_colid_from_name(html_entity_decode(urldecode($_SESSION['collection'])));
             $cacid = get_cacid($catid, $colid);
             $query = "select b.id as id,b.name as name,b.flag_SS as type,b.urlPM as url,b.desc as `desc`, i.filepath as fp, i.file as f, avg(r.`rating`) as rating from rel_serv_cca rscca\n\t\t\t\t\t\tjoin business b on rscca.bizid=b.id\n\t\t\t\t\t\tleft join images i on b.id = i.itemid\n\t\t\t\t\t\tleft join likes l on b.id=l.itemid\n\t\t\t\t\t\tleft join ratings r on b.id=r.itemid\n\t\t\t\t\t\t\twhere i.item='businessicon' and b.status='active' and rscca.catid='108' and rscca.cacid='" . $cacid . "'\n\t\t\t\t\t\t\t\tgroup by b.id\n\t\t\t\t\t\t\t\torder by " . $RAND . $SORT . $RELEASE;
         } else {
             $query = "select b.id as id,b.name as name,b.flag_SS as type,b.urlPM as url,b.desc as `desc`, i.filepath as fp, i.file as f, avg(r.`rating`) as rating from rel_serv_cca rscca\n\t\t\t\t\t\tjoin business b on rscca.bizid=b.id\n\t\t\t\t\t\tleft join images i on b.id = i.itemid\n\t\t\t\t\t\tleft join likes l on b.id=l.itemid\n\t\t\t\t\t\tleft join ratings r on b.id=r.itemid\n\t\t\t\t\t\t\twhere i.item='businessicon' and b.status='active' and rscca.catid='108'\n\t\t\t\t\t\t\t\tgroup by b.id\n\t\t\t\t\t\t\t\torder by " . $RAND . $SORT . $RELEASE;
         }
     }
     //CACHING SEARCH RESULTS FOR THE LAST 30 MINUTES OF SESSION
     if (!isset($_SESSION['indexServmainData'][$query]) || $_SESSION['indexServmainData'][$query]['time'] < time() - 30 * 60) {
         $result = mysql_query($query) or die(mysql_error());
         $_SESSION['indexServmainData'][$query]['time'] = time();
         $_SESSION['indexServmainData'][$query]['count'] = mysql_num_rows($result);
         $i = 0;
         if ($_SESSION['indexServmainData'][$query]['count'] > 0) {
             while ($row = mysql_fetch_assoc($result)) {
                 $_SESSION['indexServmainData'][$query]['data'][$i] = $row;
                 $i++;
             }
         } else {
             $_SESSION['indexServmainData'][$query]['data'] = NULL;
         }
     }
     $data = $_SESSION['indexServmainData'][$query]['data'];
     if (!empty($data)) {
         $count_total = $_SESSION['indexServmainData'][$query]['count'];
         $num_pages = ceil($count_total / $nrpp);
         $prev = $page > 1 ? '<a href="' . SITE_BASEURL . 'index.php?spage=' . ($page - 1) . $append_url . '">&laquo; previous</a>' : NULL;
         $next = $page < $num_pages ? '<a href="' . SITE_BASEURL . 'index.php?spage=' . ($page + 1) . $append_url . '">next &raquo;</a>' : NULL;
         $pn_divide = (!empty($prev) and !empty($next)) ? ' | ' : NULL;
         if ($page > 1) {
             $y = ($page - 1) * $nrpp;
             $z = $page * $nrpp;
         } else {
             $y = 0;
             $z = $nrpp;
         }
         while ($y < $z) {
             if (isset($data[$y]['name'])) {
                 $seoPhrase = preg_replace('/[[:punct:]]*/i', '', stripslashes($data[$y]['name']));
                 $seoPhrase = preg_replace('/[[:space:]]+/i', '-', $seoPhrase);
                 $seoPhrase = preg_replace('/-{0,1}$/i', '', $seoPhrase);
                 $rating = round($data[$y]['rating'], 0);
                 $ratings = compile_rating($data[$y]['id'], $rating);
                 $list .= replace_hh('HH-PM-INDEX-SERV2', array('path_site' => SITE_BASEURL, 'alt' => stripslashes($data[$y]['name']), 'title' => truncate_hard(stripslashes($data[$y]['name']), 30), 'desc' => truncate(strip_tags(stripslashes($data[$y]['desc'])), 100), 'image_src' => SITE_BASEURL . $data[$y]['fp'] . $data[$y]['f'], 'serv_href' => SITE_BASEURL . $data[$y]['url'] . '/' . $seoPhrase));
             }
             $y++;
         }
         $endof = $count_total < $endof ? $count_total : $endof;
         $return = replace_output(file_get_contents($path_site . 'inc/cb/indexServicesMain.inc'), array('start' => $startof, 'end' => $endof, 'total' => $count_total, 'prevnext' => $prev . $pn_divide . $next, 'services' => $list));
     } else {
         $return = '<div class="services_box" style="width:440px; padding:20px;">' . ERROR_MS_SERV1 . '</div>';
     }
     return $return;
 }
Ejemplo n.º 2
0
function pms_account()
{
    if (!is_user_logged_in()) {
        return false;
    }
    return replace_hh('HH-PM-HDR-TEXTNAV-ACCOUNT', array('path_site' => SITE_BASEURL));
}