19 AND id_mag <> 49"; if ($_SERVER['HTTP_HOST'] == 'dev.nbpublish.com') { //$where_en = "free = 0"; //$where_en = "0 "; } $subscribtionUser = GetActualSubscribtionUser(); if ($filtered) { $where_en ="0"; //echo $subscribtionUser; if ($subscribtionUser != 0) { DBConnect(); $purchased_items = GetRecordSet("nb_library_purchased_items", array("*"), 'id_user = '.$subscribtionUser.' AND is_active=1 AND id_article=-1 AND month > 0 AND year > 0'); for ($i = 0 ; $i < count($purchased_items); $i++) { $id_mag = $purchased_items[$i]['id_mag']; $month = $purchased_items[$i]['month']; $year = $purchased_items[$i]['year']; $where_en .= ' OR (id_mag ='.$id_mag.' AND year = '.$year.' AND month = '.$month.' ) '; } DBDisconnect(); } if (isset($_SESSION['library_sql_where'])) { //echo $_SESSION['library_sql_where']; $where_nb .= " AND (".$_SESSION['library_sql_where'].")"; if ($_SESSION['library_id_user'] < 0) { $id_user = str_replace("-","",$_SESSION['library_id_user']); EDBConnect(); $orders = GetRecordSet("emag_orders", array("id_order","id_user","id_article"), 'id_user = '.$id_user.' AND order_type = 22 AND is_payed=1'); EDBDisconnect(); $articleIDs = array(); for ($i = 0 ; $i < count($orders); $i++) { $articleIDs[] = $orders[$i]['id_article']; } DBConnect(); $purchased_items = GetRecordSet("nb_library_purchased_items", array("*"), 'id_user = '.$_SESSION['library_id_user'].' AND is_active=1 AND id_article < -1'); DBDisconnect(); for ($i = 0 ; $i < count($purchased_items); $i++) { $articleIDs[] = str_replace("-","",$purchased_items[$i]['id_article']); } if (count($orders) == 0 && count($purchased_items) == 0) { $where_en .= " AND 0"; } $enQuery = implode(",", $articleIDs); $where_en .= " AND (id_article IN (".$enQuery ."))"; } else { $where_en .= " AND 0"; } } else { $where_nb .= " AND 0"; $where_en .= " AND 0"; } } $articles = array(); $count = 0; if (!$filtered) { $where_nb.= " AND free = 0 AND istype <> '' "; } GetMergeArticles($articles, $count, $where_nb, $where_en); DBConnect(); $id_order_full = GetSQLValue("nb_library_purchased_items", "id_item", "is_active = 1 AND year=-1 AND month=-1 AND id_user=".$subscribtionUser." AND (((id_mag=-3) AND (DATE_ADD(order_date, INTERVAL 1 YEAR) > NOW())) OR ((id_mag=-4) AND (DATE_ADD(order_date, INTERVAL 1 DAY) > NOW())))"); DBDisconnect(); if (is_numeric($id_order_full)) { for($i = 0; $i < count($articles); $i++) { $articles[$i]['free'] = 2; } } EDBConnect(); $sideMenuHTML = GetSideMenuHTML($filtered ? -4 : -2); $paidArticles = new CSimplePage('library_main/records.tpl'); $paidArticles->AddVar('filtered', $filtered ? 1 : 0); SetVarsForArticle($paidArticles, 1, $filtered ? -4 : -2); SetAllArticlesCount($paidArticles); $paidArticles->Show(); ShowBottomPart(); ?>