0 AND mLocation < 14
LIMIT 13 ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$txt = "no";
$row['image'] = "https://images.alarab.com/data/news/{$row['picPath']}/{$row['picture']}";
$txt = "no";
if ($row['stnews'] == 3) {
$txt = "خبر عاجل";
}
if ($row['stnews'] == 2) {
$txt = "خبر حصري";
}
if ($row['stnews'] == 1) {
$txt = "نشر اول";
}
if ($row['stnews'] == 4) {
$txt = "بث مباشر";
}
$row['nstatus'] = $txt;
$data2['editor_picked'][] = $row;
}
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,news.picturesby, ncategories2.Name, erea.erea as ereaname
FROM news
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE mobilevideo != '' ORDER BY ID DESC
LIMIT 7 ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$txt = "no";
$row['image'] = "https://images.alarab.com/data/news/{$row['picPath']}/{$row['picture']}";
$txt = "no";
if ($row['stnews'] == 3) {
$txt = "خبر عاجل";
}
if ($row['stnews'] == 2) {
$txt = "خبر حصري";
}
if ($row['stnews'] == 1) {
$txt = "نشر اول";
}
if ($row['stnews'] == 4) {
$txt = "بث مباشر";
}
$row['nstatus'] = $txt;
$data2['video_news'][] = $row;
}
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,news.picturesby, ncategories2.Name, erea.erea as ereaname
FROM news
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE mobilevideo != '' ORDER BY articleviews DESC
LIMIT 7 ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$txt = "no";
$row['image'] = "https://images.alarab.com/data/news/{$row['picPath']}/{$row['picture']}";
$txt = "no";
if ($row['stnews'] == 3) {
$txt = "خبر عاجل";
}
if ($row['stnews'] == 2) {
$txt = "خبر حصري";
}
if ($row['stnews'] == 1) {
$txt = "نشر اول";
}
if ($row['stnews'] == 4) {
$txt = "بث مباشر";
}
$row['nstatus'] = $txt;
$data2['most_visited'][] = $row;
}
responseDataOnly(200, "Results", $data2);
}
if (!empty($action)) {
if ($action == "article") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.fData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,news.picturesby, ncategories2.Name, erea.erea as ereaname
FROM news
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE news.ID =$identifier
ORDER BY ID DESC
LIMIT 1 ";
$result = $conn->query($query);
$row = $result->fetch_assoc();
if ($row['mCat'] == 7) {
$addTo_title = "(ع.ع)";
} else {
$addTo_title = "";
}
$row['title'] = $row['title'] . " " . $addTo_title;
$scat = $row[sCat];
/*
//$row[fData] = str_replace("
", "
\n", $stringWithBRs);
$paragraphAfter[2]= '
'; $paragraphAfter[7]= '
';
$finalHtml = str_replace("
\n
", "
", $row[fData]);
$finalHtml = str_replace("
\n
\n
", "
", $finalHtml);
$finalHtml = str_replace("
", "
", $finalHtml);
$finalHtml = str_replace("
", "
", $finalHtml);
$finalHtmlsave=$finalHtml;
if(!$row[mobilevideo]) {
$html = explode("
", $finalHtml);
$count = count($html);
for ($i = 0; $i < $count; $i++ ) {
if ( array_key_exists($i, $paragraphAfter) ) {
$finalHtml .= $html[$i] ."". $paragraphAfter[$i] . "
";
}else{
$finalHtml .= $html[$i] . "
";
}
}
}else{
$finalHtml=$finalHtmlsave;
}*/
$finalHtml = str_replace(".jpeg", ".jpeg?auto_optimize=high", $row[fData]);
$finalHtml = str_replace(".JPG", ".JPG?auto_optimize=high", $finalHtml);
$finalHtml = str_replace(".jpg", ".jpg?auto_optimize=high", $finalHtml);
$query = "SELECT cat.ID,cat.Name,cat.eName,cat.sData,cat.keywords,cat.MainCat,parent.Name as maincatname,parent.eName as eNamemother
FROM ncategories AS cat JOIN ncategories AS parent ON parent.ID = cat.MainCat WHERE cat.ID = $scat";
//$query="SELECT ID,Name,eName,sData,keywords,MainCat FROM `ncategories` where id=$identifier" ;
$result = $conn->query($query);
$non_vi_row = $result->fetch_assoc();
$submenu = "";
$isid = $non_vi_row[ID];
$headerTitle = $non_vi_row[Name];
$headerDesc = $non_vi_row[sData];
$headerKeywords = $non_vi_row[keywords];
$eheaderTitle = $non_vi_row[eNamemother];
$maincatname = $non_vi_row[maincatname];
$maincatnameURL = "/" . $non_vi_row[MainCat] . "/";
if ($isid) {
$query = "SELECT ID,Name FROM ncategories
WHERE MainCat = {$non_vi_row[MainCat]} ";
$result = $conn->query($query);
while ($non_vi_row_sub = $result->fetch_assoc()) {
$sql .= "sCat={$non_vi_row_sub[ID]} OR ";
if ($scat == $non_vi_row_sub[ID]) {
$s = "class='selected'";
} else {
$s = '';
}
}
$submenu .= "
{$non_vi_row_sub[Name]}";
}
$data = prepare_articles_list($row);
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle, $maincatname, $maincatnameURL, '');
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "articlenew") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.fData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,news.picturesby, ncategories2.Name, erea.erea as ereaname
FROM news
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE news.ID =$identifier
ORDER BY ID DESC
LIMIT 1 ";
$result = $conn->query($query);
$row = $result->fetch_assoc();
if ($row['mCat'] == 7) {
$addTo_title = "(\u0639.\u0639)";
} else {
$addTo_title = "";
}
$row['title'] = $row['title'] . " " . $addTo_title;
$scat = $row['sCat'];
$erea = $row['erea'];
$mcat = $row['mCat'];
$finalHtml = str_replace(".jpeg", ".jpeg?auto_optimize=high", $row['fData']);
$finalHtml = str_replace(".JPG", ".JPG?auto_optimize=high", $finalHtml);
$finalHtml = str_replace(".jpg", ".jpg?auto_optimize=high", $finalHtml);
$query = "SELECT cat.ID,cat.Name,cat.eName,cat.sData,cat.keywords,cat.MainCat,parent.Name as maincatname,parent.eName as eNamemother
FROM ncategories AS cat JOIN ncategories AS parent ON parent.ID = cat.MainCat WHERE cat.ID = $scat";
$result = $conn->query($query);
$non_vi_row = $result->fetch_assoc();
$submenu = "";
$isid = $non_vi_row['ID'];
$headerTitle = $non_vi_row['Name'];
$headerDesc = $non_vi_row['sData'];
$headerKeywords = $non_vi_row['keywords'];
$eheaderTitle = $non_vi_row['eNamemother'];
$maincatname = $non_vi_row['maincatname'];
$maincatnameURL = "/" . $non_vi_row['MainCat'] . "/";
if ($isid) {
$query = "SELECT ID,Name FROM ncategories
WHERE MainCat = {$non_vi_row['MainCat']} ";
$result = $conn->query($query);
while ($non_vi_row_sub = $result->fetch_assoc()) {
$sql .= "sCat={$non_vi_row_sub['ID']} OR ";
if ($scat == $non_vi_row_sub['ID']) {
$s = "class='selected'";
} else {
$s = '';
}
}
$submenu .= "{$non_vi_row_sub['Name']}";
}
$querywow = "SELECT * FROM images WHERE newsid=$identifier ORDER BY img_order ASC";
$rrr = $conn->query($querywow) or die($conn->error);
while($rowwow = $rrr->fetch_assoc()){
$row['media'][]=$rowwow;
}
// Fetch related articles
if($erea>0) {
$relatedQuery = "SELECT ID, title, smalltitle, picPath,picture,nWriter,pdate FROM news WHERE erea = $erea AND ID != $identifier ORDER BY ID DESC LIMIT 5";
}else{
$relatedQuery = "SELECT ID, title, smalltitle, picPath,picture,nWriter,pdate FROM news WHERE mCat = $mcat AND ID != $identifier ORDER BY ID DESC LIMIT 5";
}
$relatedResult = $conn->query($relatedQuery);
$relatedArticles = [];
while ($relatedRow = $relatedResult->fetch_assoc()) {
$relatedArticles[] = $relatedRow;
}
$row['related_articles'] = $relatedArticles;
$data = prepare_articles_list($row);
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle, $maincatname, $maincatnameURL, "");
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "today") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE sCat!=2235 AND mStatus=1 ORDER BY ID DESC " . " LIMIT $offset, $rowsPerPage";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE mStatus=1 AND sCat!=2235 ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;
$numrows = $pagination['numrows'];
$maxPage = ceil($numrows/$rowsPerPage); */
$maxPage = 30;
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$keywrord = str_replace(" ", "-", $identifier);
$url_for_Cat = "/todaynews/{$i}";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
$headerDesc = "اخبار اليوم المحلية في الوسط العربي، برقيات موقع العرب العاجلة";
$headerKeywords = "اخبار محلية, اخبار اليوم, بانيت اخبار اليوم, اخبار رهط عاجل ,اخبار الطقس, اخبار اليوم في القدس, اخبار فلسطين";
$maincatnameURL = "/todaynews/";
$submenu .= "اخبار محلية";
$submenu .= "اخبار";
$submenu .= "رياضة";
$submenu .= "أخبار الناصرة اليوم";
$submenu .= "وفيات اليوم";
response(200, "Results", $data, 'اخبار اليوم', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "newsvideo") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mobilevideo !='' AND mStatus=1 AND sCat!=2235 ORDER BY ID DESC " . " LIMIT $offset, $rowsPerPage";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE CONCAT(news.title,news.sData,news.fData) REGEXP 'arabTV' AND mStatus=1 ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;*/
$numrows = 500;
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = ceil($numrows / $rowsPerPage);
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$keywrord = str_replace(" ", "-", $identifier);
$url_for_Cat = "/tag/{$keywrord}/{$i}.html";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, 'تلفزيون arabTV', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "reels") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$reelsfields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mobilevideo !='' AND mStatus=1 AND sCat!=2235 ORDER BY ID DESC " . " LIMIT $reelsoffset, $reelsrowsPerPage";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list_reels($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE CONCAT(news.title,news.sData,news.fData) REGEXP 'arabTV' AND mStatus=1 ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;*/
$numrows = 500;
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = ceil($numrows / $rowsPerPage);
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$keywrord = str_replace(" ", "-", $identifier);
$url_for_Cat = "/tag/{$keywrord}/{$i}.html";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, 'reels from alarab', '', '', '', '', '', '', '');
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "citieslist3") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT id,erea FROM `erea` ORDER BY `erea`.`corder` ASC";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
responseDataOnly(200, "Results", $data, 'citieslist', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "highlights") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mLocation >0 AND news.mLocation < 14 AND mStatus=1 AND sCat!=2235 ORDER BY ID DESC LIMIT 13";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data, 'Highlights', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "gallery") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT * FROM images where newsid = $identifier ORDER by img_order ASC";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
response(200, "Results", $data, 'Highlights', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "arabtv") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE CONCAT(news.title) REGEXP 'arabTV' AND mStatus=1 AND sCat!=2235 ORDER BY ID DESC " . " LIMIT $offset, $rowsPerPage";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE CONCAT(news.title,news.sData,news.fData) REGEXP 'arabTV' AND mStatus=1 ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;*/
$numrows = 500;
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = ceil($numrows / $rowsPerPage);
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$keywrord = str_replace(" ", "-", $identifier);
$url_for_Cat = "/tag/{$keywrord}/{$i}.html";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, 'تلفزيون arabTV', $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "relatednews") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$identifier = mysqli_real_escape_string($conn, $identifier);
$numw = str_word_count($identifier);
if ($identifier == "covid" or $identifier == "Covid" or $identifier == "COVID" or $identifier == "كرونا" or $identifier == "كورنا" or $identifier == "كورونا") {
response(400, "Identifier Not Found", NULL);
exit;
}
if ($numw < 2) {
$query = "SELECT news.ID,news.title,news.picture,news.picPath,news.mStatus,news.udate,news.pdate,news.mobilevideo,news.sData,news.sCat,news.mStatus, news.articleviews FROM news
WHERE news.title LIKE '%{$identifier}%' ORDER BY ID DESC " . " LIMIT 10";
//,news.sData,news.fData
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
if ($row[mStatus] == 1 and $row['sCat'] != 2235) {
$data[] = prepare_articles_list($row);
}
//$data[]=prepare_articles_list($row);
}
}
$html = "";
response(200, "Results", $data, $identifier, $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "search") {
if (!empty($identifier)) {
$maincatnameURL = "/tag/" . str_replace(' ', '-', $identifier);
$headerKeywords = $identifier;
$headerDesc = "نتائج بحث حول: " . $identifier;
$submenu = " صفحة البداية";
//$identifier=mysql_real_escape_string($identifier);
$reffurl = $_SERVER["REMOTE_ADDR"];
$identifier = str_replace("-", " ", $identifier);
$identifier = mysqli_real_escape_string($conn, $identifier);
if ($identifier == "covid" or $identifier == "Covid" or $identifier == "COVID" or $identifier == "كرونا" or $identifier == "كورنا" or $identifier == "كورونا") {
response(400, "Identifier Not Found", NULL);
exit;
}
$numw = str_word_count($identifier);
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,
news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,
ncategories.Name, ncategories2.Name as subcat
FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.sCat!=2235 AND MATCH(news.title) AGAINST ('{$identifier}' IN NATURAL LANGUAGE MODE) AND title like '%{$identifier}%' AND mStatus=1 ORDER BY ID DESC
" . " LIMIT $offset, $rowsPerPage ";
//,news.sData,news.fData
if ($identifier == "موقع بانيت") {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.sCat!=2235 ORDER BY ID DESC " . " LIMIT $offset, $rowsPerPage";
}
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
//$html .= "";
response(200, "Results", $data, $identifier, $headerDesc, $headerKeywords, $submenu, $identifier, $identifier, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "opinion") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE mCat=6 AND mStatus=1 ORDER BY ID DESC
LIMIT 3";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "ticker") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT title,ID,pdate,udate,sData FROM ticker ORDER BY udate DESC limit 15";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "ticker3") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT title,ID,pdate,udate,sData FROM news WHERE ((scroll=1 AND mStatus=1) OR (mCat=1 AND mStatus=1)) AND news.pdate < \"{$firstdate}\" AND news.pdate > \"{$seconddate}\" ORDER BY udate DESC limit 15";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "breaking") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT title,ID,pdate,udate,sData,userInserted FROM ticker WHERE mStatus=1 ORDER BY udate desc limit 30";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$row['pdate'] = time_elapsed_string($row['pdate']);
$row['udate'] = time_elapsed_string($row['udate']);
$data[] = $row;
}
response4(200, "Results", $data);
} else {
response4(400, "Identifier Not Found", NULL);
}
}
if ($action == "commercials") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE mLocation>0 AND mLocation<14 AND mStatus=1 ORDER BY ID DESC
LIMIT 1";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "copywriter") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$identifier = str_replace(" ", " ", $identifier);
$identifier = str_replace("من: ", " ", $identifier);
$identifier = str_replace("بقلم: ", " ", $identifier);
$identifier = str_replace("مراسل كل العرب", " ", $identifier);
$identifier = ltrim($identifier);
$headerTitle = $identifier;
$headerDesc = "أخبار ومثالات من " . $identifier . " صحيفة كل العرب ";
$headerKeywords = "" . $identifier;
//$eheaderTitle=$row[eName];
$submenu = "";
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mStatus=1 AND news.nWriter LIKE '%{$identifier}%' ORDER BY news.ID DESC
" . " LIMIT $offset, $rowsPerPage";
//echo $query;
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu = "", $eheaderTitle = "", "", "", "");
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "topvisited") {
if (!empty($identifier)) {
$identifier = str_replace("-", " ", $identifier);
$id = $page; // used page input as id on this widget
if ($identifier == "category") {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE news.mStatus=1 AND sCat=$id AND news.pdate >= now() - INTERVAL 3 DAY AND news.pdate <= now() ORDER BY news.articleviews DESC LIMIT 5";
}
if ($identifier == "mothercategory") {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE news.mStatus=1 AND mCat=$id AND news.pdate >= now() - INTERVAL 3 DAY AND news.pdate <= now() ORDER BY news.articleviews DESC LIMIT 5";
}
if ($identifier == "city") {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE news.mStatus=1 AND erea=$id AND news.pdate >= now() - INTERVAL 3 DAY AND news.pdate <= now() ORDER BY news.articleviews DESC LIMIT 5";
}
if ($identifier == "todayviewed") {
$today = date("Y-m-d");
$today = $today . " 00:00:00";
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE (news.pdate >= \"{$today}\") ORDER BY news.articleviews DESC LIMIT 15";
}
} else {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE news.mStatus=1 AND news.pdate >= now() - INTERVAL 1 DAY AND news.pdate <= now() ORDER BY news.articleviews DESC
" . " LIMIT $offset, $rowsPerPage";
}
$headerTitle = $identifier;
$headerDesc = "أخبار ومثالات من " . $identifier . " صحيفة كل العرب ";
$headerKeywords = "" . $identifier;
//$eheaderTitle=$row[eName];
$submenu = "";
//echo $query;
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data, "top visite", $headerDesc, $headerKeywords, $submenu = "", $eheaderTitle = "");
}
if ($action == "topvisitedToday") {
$headerTitle = $identifier;
$headerDesc = "أخبار ومثالات من " . $identifier . " صحيفة كل العرب ";
$headerKeywords = "" . $identifier;
//$eheaderTitle=$row[eName];
$submenu = "";
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID WHERE news.mStatus=1 ORDER BY news.articleviews DESC
" . " LIMIT $offset, $rowsPerPage";
//echo $query;
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
response(200, "Results", $data, "top visite", $headerDesc, $headerKeywords, $submenu = "", $eheaderTitle = "");
}
if ($action == "NewNews") {
$pageNum = $page + 1;
$offset = ($pageNum - 1) * 10;
$query = "SELECT {$fields} , erea.erea as ereaname FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE news.mStatus=1 ORDER BY news.ID DESC " . " LIMIT $offset, 10";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$row['title'] = $row['title'] . " " . $addTo_title;
$row['smalltitle'] = $row['smalltitle'] . " " . $addTo_title;
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE mStatus=1 AND sCat=$identifier AND picture!='' ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;
$numrows = $pagination['numrows'];
$maxPage = ceil($numrows/$rowsPerPage);
$maxPage = ceil($numrows/$rowsPerPage);*/
$maxPage = 30;
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$url_for_Cat = "/Archive/{$identifier}/{$i}";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle, $maincatname, $maincatnameURL, $html);
}
if ($action == "category") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
$query = "SELECT cat.ID,cat.Name,cat.eName,cat.sData,cat.keywords,cat.MainCat,parent.Name as maincatname
FROM ncategories AS cat JOIN ncategories AS parent ON parent.ID = cat.MainCat WHERE cat.ID = $identifier ";
//$query="SELECT ID,Name,eName,sData,keywords,MainCat FROM `ncategories` where id=$identifier" ;
$result = $conn->query($query);
$row = $result->fetch_assoc();
if ($row['MainCat'] == 7) {
$addTo_title = "(ع.ع)";
} else {
$addTo_title = "";
}
$submenu = "";
$headerTitle = $row[Name];
$headerDesc = $row[sData];
$headerKeywords = $row[keywords];
$eheaderTitle = $row[eName];
$maincatname = $row[maincatname];
$maincatnameURL = "/" . $row[MainCat] . "/";
$query = "SELECT ID,Name FROM ncategories
WHERE MainCat = {$row[MainCat]} ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$sql .= "sCat={$row[ID]} OR ";
if ($identifier == $row[ID]) {
$s = "class='selected'";
} else {
$s = '';
}
$submenu .= "{$row[Name]}";
}
$query = "SELECT {$fields} , erea.erea as ereaname FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
LEFT JOIN erea ON news.erea = erea.id
WHERE news.mStatus=1 AND news.sCat = $identifier AND news.sCat!=2235 AND mStatus=1 ORDER BY news.ID DESC " . " LIMIT $offset, $rowsPerPage";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$row['title'] = $row['title'] . " " . $addTo_title;
$row['smalltitle'] = $row['smalltitle'] . " " . $addTo_title;
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE mStatus=1 AND sCat=$identifier AND picture!='' ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;
$numrows = $pagination['numrows'];
$maxPage = ceil($numrows/$rowsPerPage);
$maxPage = ceil($numrows/$rowsPerPage);*/
$maxPage = 30;
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$url_for_Cat = "/Archive/{$identifier}/{$i}";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle, $maincatname, $maincatnameURL, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "mothercategory") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
if ($identifier == 7) {
$addTo_title = "(ع.ع)";
} else {
$addTo_title = "";
}
$query = "SELECT ID,Name,eName,sData,keywords FROM `ncategories` where id=$identifier";
$result = $conn->query($query);
$row = $result->fetch_assoc();
$headerTitle = $row[Name];
$headerDesc = $row[sData];
$headerKeywords = $row[keywords];
$eheaderTitle = $row[eName];
$submenu = "";
$query = "SELECT ID,Name FROM ncategories
WHERE MainCat = $identifier ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$sql .= "sCat={$row[ID]} OR ";
$submenu .= "{$row[Name]}";
}
$sql = rtrim($sql, ' OR');
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mStatus=1 AND( {$sql} ) AND news.sCat!=2235 ORDER BY news.ID DESC " . " LIMIT $offset, $rowsPerPage";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$row['title'] = $row['title'] . " " . $addTo_title;
$row['smalltitle'] = $row['smalltitle'] . " " . $addTo_title;
$data[] = prepare_articles_list($row);
}
$x = "SELECT COUNT(id) AS numrows FROM news WHERE mStatus=1 AND( {$sql} ) ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc();
$numrows = $pagination['numrows'];
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = ceil($numrows / $rowsPerPage);
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$url_for_Cat = "/{$identifier}/{$i}.html";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle, $maincatname = null, $maincatnameURL = Null, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "citieslist") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
$query = "SELECT * FROM `erea` where showmain=1 order by corder ASC";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$subs = array();
$subcities = explode("-", $row[data]);
for ($s = 0; $s < count($subcities); $s++) {
$subs[] = rtrim(ltrim($subcities[$s]));
}
$row[data] = $subs;
$data[] = $row;
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle = null, $maincatname = null, $maincatnameURL = Null, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "sugg_tags") {
if (!empty($identifier)) {
$identifier = str_replace('-', ' ', $identifier);
$words = explode(' ', $identifier);
$find = implode('.*', array_map(function ($word) {
return '(' . $word . ')';
}, $words));
$find = arquery($find);
$find = mysqli_real_escape_string($conn, $find);
$query = "SELECT * FROM `sugg_tags` WHERE CONCAT(sugg_tags.tag) REGEXP '$find' LIMIT 4";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = $row;
}
responseDataOnly(200, "success" , $data);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "city") {
if (!empty($identifier)) {
$identifier = (int)$identifier;
$query = "SELECT * FROM `erea` where id=$identifier";
$result = $conn->query($query);
$row = $result->fetch_assoc();
$headerTitle = "أخبار " . $row[erea];
$headerDesc = "أخبار " . $row[data];
$keywords = explode("-", $row[data]);
$submenu = "";
for ($i = 0; $i < count($keywords); $i++) {
$cityname = ltrim($keywords[$i]);
$headerKeywords .= "أخبار " . $keywords[$i] . ",";
$sq = ltrim($cityname);
$sq = rtrim($sq);
$sq = str_replace(" ", "-", $sq);
/*$sq=trim(preg_replace('/\s\s+/', ' ', str_replace("\n", " ", $p_path)));*/
$submenu .= "{$sq}";
}
rtrim($headerKeywords, ',');
$headerKeywords = preg_replace('/\s+/', ' ', $headerKeywords);
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.mStatus=1 AND news.erea=$identifier AND news.sCat!=2235 ORDER BY news.ID DESC " . " LIMIT $offset, $rowsPerPage";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
}
/*$x = "SELECT COUNT(id) AS numrows FROM news WHERE mStatus=1 AND erea=$identifier ' ";
$rx = $conn->query($x);
$pagination = $rx->fetch_assoc() ;*/
$numrows = $pagination['numrows'];
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = ceil($numrows / $rowsPerPage);
$maxPage = 30;
if (!isset($_GET['page'])) {
$current_page = 1;
} else {
$current_page = (int)$_GET['page'];
}
$nx = $current_page + 1;
$number_of_pages = $maxPage;
$current_page = min($current_page, $number_of_pages);
$current_page = max($current_page, 1);
$min = max(1, $current_page - 5);
$max = min($number_of_pages, $min + 10);
$html .= "";
$next_one = "/" . $identifier . "/" . $nx;
for ($i = $min; $i <= $max; $i++) {
if ($i != 1) {
if ($i == $current_page) {
$class = 'active';
} else {
$class = 'gradient';
}
$url_for_Cat = "/city/{$identifier}/{$i}.html";
$html .= "{$i}";
//$pages_to_path .= "{$i}";
}
}
response(200, "Results", $data, $headerTitle, $headerDesc, $headerKeywords, $submenu, $eheaderTitle = null, $maincatname = null, $maincatnameURL = Null, $html);
} else {
response(400, "Identifier Not Found", NULL);
}
}
if ($action == "search1") {
//v=1-5553-6181-297,n=افلام,
if (!empty($identifier)) {
$maincatnameURL = "/tag/" . str_replace(' ', '-', $identifier);
$headerKeywords = $identifier;
$headerDesc = "نتائج بحث حول: " . $identifier;
$submenu = " صفحة البداية";
//$identifier=mysql_real_escape_string($identifier);
$reffurl = $_SERVER["REMOTE_ADDR"];
$identifier = str_replace("-", " ", $identifier);
$headerTitle = $identifier;
$identifier = mysqli_real_escape_string($conn, $identifier);
if ($identifier == "covid" or $identifier == "Covid" or $identifier == "COVID" or $identifier == "كرونا" or $identifier == "كورنا") {
response(400, "Identifier Not Found", NULL);
exit;
}
$numw = str_word_count($identifier);
$find = arquery($identifier);
$query = "SELECT * FROM `tags_router` WHERE `tag` = '" . $identifier . "' AND roleactive=1 LIMIT 1 ";
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$tag = $row;
}
if ($tag['role'] == "redirect") {
response_redirect(200, "redirect", $tag[merge_values]);
exit;
}
if ($tag['role'] == "merge") {
if ($tag[merge_values]) {
$rols = explode(";", $tag[merge_values]);
for ($z = 0; $z < count($rols); $z++) {
if (rtrim(ltrim($rols[$z]))) {
$f_rosl[] = rtrim(ltrim($rols[$z]));
}
}
}
}
$htmlto = array();
$standings = array();
$weather = array();
for ($i = 0; $i < count($f_rosl); $i++) {
$role = array();
$role = explode("=", $f_rosl[$i]);
if (rtrim(ltrim($role[1])) != "") {
if ($role[0] == "w") {
if ($role[1] == "1") {
$loadweather = "fff";
} else {
$weather[] = $role[1];
}
}
if ($role[0] == "n") {
if ($role[1] != "") {
$find = arquery($role[1]);
$sqlfilter = " news.title LIKE '%$identifier%' ";
}
}
if ($role[0] == "s") {
if ($role[1] != "") {
$standings[] = $role[1];
}
}
if ($role[0] == "ps") {
if ($role[1] != "") {
$htmlto[] = $role[1];
}
}
}
}
if ($sqlfilter) {
$rowsPerPage = 5;
if (!empty($page)) {
$pageNum = $_GET['page'];
$offset = ($pageNum - 1) * $rowsPerPage;
} else {
$pageNum = 1;
$offset = ($pageNum - 1) * $rowsPerPage;
}
if (substr($_GET['identifier'], -1) == "ه" or substr($_GET['identifier'], -1) == "ة") {
$identifier = arquery($identifier);
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,
news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,
ncategories.Name, ncategories2.Name as subcat
FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE CONCAT(news.title) REGEXP '$identifier' AND news.sCat!=2235 AND mStatus=1 ORDER BY pdate DESC " . " LIMIT $offset, $rowsPerPage ";
} else {
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,
news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,
ncategories.Name, ncategories2.Name as subcat
FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.title LIKE '%$identifier%' AND news.sCat!=2235 AND mStatus=1 ORDER BY pdate DESC " . " LIMIT $offset, $rowsPerPage ";
}
} else {
$rowsPerPage = 5;
if (!empty($page)) {
$pageNum = $_GET['page'];
$offset = ($pageNum - 1) * $rowsPerPage;
} else {
$pageNum = 1;
$offset = ($pageNum - 1) * $rowsPerPage;
}
$query = "
SELECT news.ID,news.fb_country,news.fb_cont,news.fb_comp,news.fb_teams,news.pdate,news.title,news.sData,news.nWriter,news.mStatus,news.mCat,news.picture,news.userInserted,news.sCat,
news.smalltitle,news.picPath,news.scroll,news.udate,news.stnews,news.links,news.mLocation,news.erea,news.searchtags,news.mobilevideo,news.articleviews,
ncategories.Name, ncategories2.Name as subcat
FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE CONCAT(news.title) REGEXP '$identifier' AND news.sCat!=2235 AND mStatus=1 ORDER BY ID DESC
" . " LIMIT $offset, $rowsPerPage ";
}
//,news.sData,news.fData
if ($identifier == "موقع بانيت") {
$query = "SELECT {$fields} FROM news
INNER JOIN `ncategories` ON news.mCat = ncategories.ID
LEFT JOIN ncategories ncategories2 ON news.sCat = ncategories2.ID
WHERE news.sCat!=2235 ORDER BY ID DESC " . " LIMIT $offset, $rowsPerPage";
}
$result = $conn->query($query);
while ($row = $result->fetch_assoc()) {
$data[] = prepare_articles_list($row);
$cdata[] = prepare_articles_list($row);
}
$vflag = 1;
$vdata = $data;
$msg = "status: OK";
response3(200, "Results", $headerTitle, $data, "", $vflag, $htmlto, $standings);
} else {
response3(400, "Identifier Not Found", NULL);
}
}
} else {
response(400, "Action Not Found", NULL);
}
/*if(!empty($_GET['action']))
{
$name=$_GET['action'];
$price = get_price($name);
if(empty($price))
{
response(200,"Product Not Found",NULL);
}
else
{
response(200,"Product Found",$price);
}
}
else
{
response(400,"Invalid Request",NULL);
}
*/
mysqli_close($conn);
function response($status, $status_message, $data, $headerTitle = null, $headerDesc = null, $headerKeywords = null, $submenu = null, $eheaderTitle = null, $maincatname = null, $maincatnameURL = Null, $html)
{
header("HTTP/1.1 " . $status);
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['pageTitle'] = $headerTitle;
$response['pageDesc'] = $headerDesc;
$response['pageKeywords'] = $headerKeywords;
$response['maincatname'] = $maincatname;
$response['maincatnameURL'] = $maincatnameURL;
$response['eheaderTitle'] = $eheaderTitle;
$response['pages'] = $html;
$response['submenu'] = $submenu;
$response['data'] = $data;
$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);
echo $json_response;
}
function response4($status, $status_message, $data)
{
header("HTTP/1.1 " . $status);
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['pageTitle'] = $headerTitle;
$response['pageDesc'] = $headerDesc;
$response['pageKeywords'] = $headerKeywords;
$response['maincatname'] = $maincatname;
$response['maincatnameURL'] = $maincatnameURL;
$response['eheaderTitle'] = $eheaderTitle;
$response['pages'] = $html;
$response['submenu'] = $submenu;
$response['data'] = $data;
$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);
echo $json_response;
}
function response3($status, $status_message, $headerTitle, $data, $vdata, $vflag, $page_suggestions, $standings, $weather)
{
header("HTTP/1.1 " . $status);
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['pageTitle'] = $headerTitle;
$response['data'] = $data;
$response['vdata'] = $vdata;
$response['v'] = $vflag;
$response['page_suggestions'] = $page_suggestions;
$response['standings'] = $standings;
$response['weather'] = $weather;
$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);
echo $json_response;
}
function response_redirect($status, $status_message, $url)
{
header("HTTP/1.1 " . $status);
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['url'] = $url;
$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);
echo $json_response;
}
function responseDataOnly($status, $status_message, $data)
{
header("HTTP/1.1 " . $status);
$response['status'] = $status;
$response['status_message'] = $status_message;
$response['data'] = $data;
$json_response = json_encode($response, JSON_UNESCAPED_UNICODE);
echo $json_response;
}
/*if($action=="search" OR $action=="relatednews" OR $action=="article" OR $action=="category"){
$fp = fopen($cachefile, 'w');
// save the contents of output buffer to the file
fwrite($fp, ob_get_contents());
// close the file
fclose($fp);
// Send the output to the browser
ob_end_flush();
}*/