<?
if (!defined("_VALID_ACCESS_") || _VALID_ACCESS_ !=1) {
	die("Foot Bokra");
}

echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
<HTML dir=rtl>';

$mysqlQuery=new mysqlQueryClass();

$action=addslashes($_GET[action]);

switch ($action)
{

/**********************************************************************************************
- Search - Search - Search - Search - Search - Search - Search - Search - Search - Search
**********************************************************************************************/

case "search" :
		$title = " البحث في الموقع ";
$align="center";
        $psearch = $_POST['keyword'];
        {

 if(empty($psearch)){ 
			$main="<td height='195' valign='top'><center> يجب عليك كتابة كلمة للبحث عنها <br /> <br>
             <a href='index.php'><div onMouseOver='turn_off(this);' onmouseout='turn_on(this);' class='back'><b> عـــودة </b></div> </a></center><br /></center></td>"; }
        else
           {
        $query="SELECT `id`, `name`, `visits`, `shortdes`, `photo` FROM `products`
         WHERE  `name` LIKE '%$psearch%' OR `shortdes` LIKE '%$psearch%' ANd  `valid` = 1 ORDER BY `id` DESC";

        $mysqlQuery->mysqlQueryWOF($query);
$nor = 0; 
        if ($mysqlQuery->resultNoRows!=0)
          {
           $counter=1;
          $main .= "<td  valign='top'><div align='center'> نتيجة بحث المقالات عن  $psearch <br /></div><br />
           <table width='90%' align='center' class='content' border='0' cellspacing='3' cellpadding='3'>              
            
              <tr> <td colspan='6'> </td></tr></td>
                ";
            			while (list($prodId,$name,$visits,$shortdes,$photo) = mysql_fetch_array($mysqlQuery->result)) {
            	$name=substr($name,0,40);
				 if ($nor % 4 == 0) {
				   $main .= '</tr><tr>';
				   }

						$main .="<td style='border: 0px none; margin: 0px; padding: 0px; width: 240px;' align='center' valign='top'>
		   <div style='margin: 10px 9px 10px 0pt;' align='center'>
<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='232'>
		<tbody><tr>
			<td class='normalheader' align='center' valign='bottom'>
			<div style='overflow: hidden; width: 210px; height: 30px; margin-bottom: 8px;'><a href='t$id-$name.html'><div style='overflow: hidden; width: 230px;'>
					$name
				</div></td>
		</tr>
		<tr>
			<td class='normalpic' align='center' valign='top'>
				<a href='count-$id.html'>
			<img src='$photo' alt='Article Photo' style='border: 1px solid rgb(68, 68, 68); margin: 1px 0pt 0pt; padding: 0px; vertical-align: middle;' border='0' height='161' width='210'></a></td>
		</tr>
		<tr>
			<td class='normaldesc' align='center'><div dir='rtl' style='padding: 0pt; overflow: auto; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 50px; width: 210px; text-align: center; font-family: tahoma; font-size: 13px; color: rgb(153, 153, 153); font-weight: bold;'>$shortdes</div>
		</tr>
		<tr>
			<td class='normalfooter2' align='center'><div style='margin: 3px 0pt 0pt;'>
				<a class='clink' href='cat-$catId.html'>
				$catname
				</a></div></td>
		</tr>
		<tr>
			<td class='normalfooter1' align='center'>
			<div style='margin: 3px 0pt 0pt;'><div class='download'><a class='dlink' href='count-$id.html'>
								  التحميل :  $visits
					</a></div>
</td>
		</tr>
	</tbody></table></div></td>";
						$counter++;	  
				   		      $nor++;  
					}
					

          $main .= ("</table> <br />");
          }
          else
            {
            $main .="<td height='195' valign='top'><br><br><center> لا توجد نتائج للبحث<br /> <br>
             <a href='index.php'><div onMouseOver='turn_off(this);' onmouseout='turn_on(this);' class='back'><b> عـــودة </b></div> </a></center><br /><br /><td>";
            }
        }

$main .="</ul></div>";


break;



}
       
		break;
		
/*********************************************************************************************
Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - Cats - 
*********************************************************************************************/


case "viewCat" :
$align="right";
$amysqlQuery=new mysqlQueryClass();


$catId=$_GET['catId'];
If (!is_numeric($catId)) {die("Foot Bokra");}

$pquery=("SELECT COUNT(`id`) AS `c` FROM `products` WHERE `valid` = 1 AND `catid` = '$catId'");
$mysqlQuery->mysqlQueryWOF($pquery);

extract(mysql_fetch_array($mysqlQuery->result));
$limit = $pagesnum;
$start = $_GET['start'];
if(!isset($start)) $start = 0;
$num_pages = ceil($c/$limit);

$squery="SELECT `id`, `name`,`photo`,`shortdes`, `vb`,`visits` FROM `products` 
				WHERE `valid` = 1 AND `catid` ='$catId' ORDER BY `id` DESC LIMIT $start, $limit";
			
			$mysqlQuery->mysqlQueryWOF($squery);
			
			
			$tquery="SELECT `name` FROM `catagories` 
				WHERE `level` = 1 AND `id` ='$catId' LIMIT 1";
			
			$amysqlQuery->mysqlQueryWOF($tquery);
			
				list($catname)= mysql_fetch_array($amysqlQuery->result);
				$title = $catname;
				
			 $counter = 1 + $start  ;			
$nor = 0; 
      if ($mysqlQuery->resultNoRows!=0) {
      while(list($id,$name,$photo,$shortdes,$vbname,$visits) = mysql_fetch_array($mysqlQuery->result)){
		    	
     if ($nor % 4 == 0) {
        $main .= '</tr><tr>';
                  }  
				  
						$main .="<td style='border: 0px none; margin: 0px; padding: 0px; width: 240px;' align='center' valign='top'>
		   <div style='margin: 10px 9px 10px 0pt;' align='center'>
<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='232'>
		<tbody><tr>
			<td class='normalheader' align='center' valign='bottom'>
			<div style='overflow: hidden; width: 210px; height: 30px; margin-bottom: 8px;'><a href='t$id-$name.html'><div style='overflow: hidden; width: 230px;'>
					$name
				</div></td>
		</tr>
		<tr>
			<td class='normalpic' align='center' valign='top'>
				<a href='count-$id.html'>
			<img src='$photo' alt='Article Photo' style='border: 1px solid rgb(68, 68, 68); margin: 1px 0pt 0pt; padding: 0px; vertical-align: middle;' border='0' height='161' width='210'></a></td>
		</tr>
		<tr>
			<td class='normaldesc' align='center'><div dir='rtl' style='padding: 0pt; overflow: auto; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 50px; width: 210px; text-align: center; font-family: tahoma; font-size: 13px; color: rgb(153, 153, 153); font-weight: bold;'>$shortdes</div>
		</tr>
		<tr>
			<td class='normalfooter2' align='center'><div style='margin: 3px 0pt 0pt;'>
				<a class='clink' href='cat-$catId.html'>
				$catname
				</a></div></td>
		</tr>
		<tr>
			<td class='normalfooter1' align='center'>
			<div style='margin: 3px 0pt 0pt;'><div class='download'><a class='dlink' href='count-$id.html'>
								  التحميل :  $visits
					</a></div>
</td>
		</tr>
	</tbody></table></div></td>
	  ";
				   			$counter++;	  
				   		      $nor++;  

			}			
			}
			else{
			$main .="<td valign='top'><center><div align=center>لا يوجد اى مقالات فى هذا القسم !</div></center><td>";
			}
						$current = ($start/$limit)+1;

break;

/**********************************************************************************************
- Default - Default - Default - Default - Default - Default - Default - Default - Default -
**********************************************************************************************/

default:
$align="right";
$title = $sitename;
$amysqlQuery=new mysqlQueryClass();

$pquery=("SELECT COUNT(`id`) AS `c` FROM `products` WHERE `valid` = 1 AND `sticky` = 2");
$mysqlQuery->mysqlQueryWOF($pquery);

extract(mysql_fetch_array($mysqlQuery->result));
$limit1 = $pagesnum;
$start = $_GET['start'];
if(!isset($start)) $start = 0;
$num_pages = ceil($c/$limit1);

$squery="SELECT `id`, `name`,`photo`,`shortdes`, `vb`,`visits`,`catid` FROM `products` 
				WHERE `valid` = 1 AND `sticky` = 2 ORDER BY `id` DESC LIMIT $start, $limit1";
			
			$mysqlQuery->mysqlQueryWOF($squery);

			 $counter = 1 + $start  ;			
       $nor = 0; 
      if ($mysqlQuery->resultNoRows!=0) {
      while(list($id,$name,$photo,$shortdes,$vbname,$visits,$catId) = mysql_fetch_array($mysqlQuery->result)){
		    	
				$tquery="SELECT `name` FROM `catagories` 
				WHERE `level` = 1 AND `id` ='$catId' LIMIT 1";
			
			$amysqlQuery->mysqlQueryWOF($tquery);
			
				list($catname)= mysql_fetch_array($amysqlQuery->result);
				
     if ($nor % 4 == 0) {
        $main .= '</tr><tr>';
                  }  
				  
						$main .="<td style='border: 0px none; margin: 0px; padding: 0px; width: 240px;' align='center' valign='top'>
		   <div style='margin: 10px 9px 10px 0pt;' align='center'>
<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='232'>
		<tbody><tr>
			<td class='normalheader' align='center' valign='bottom'>
			<div style='overflow: hidden; width: 210px; height: 30px; margin-bottom: 8px;'><a href='t$id-$name.html'><div style='overflow: hidden; width: 230px;'>
					$name
				</div></td>
		</tr>
		<tr>
			<td class='normalpic' align='center' valign='top'>
				<a href='count-$id.html'>
			<img src='$photo' alt='Article Photo' style='border: 1px solid rgb(68, 68, 68); margin: 1px 0pt 0pt; padding: 0px; vertical-align: middle;' border='0' height='161' width='210'></a></td>
		</tr>
		<tr>
			<td class='normaldesc' align='center'><div dir='rtl' style='padding: 0pt; overflow: auto; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 50px; width: 210px; text-align: center; font-family: tahoma; font-size: 13px; color: rgb(153, 153, 153); font-weight: bold;'>$shortdes</div>
		</tr>
		<tr>
			<td class='normalfooter2' align='center'><div style='margin: 3px 0pt 0pt;'>
				<a class='clink' href='cat-$catId.html'>
				$catname
				</a></div></td>
		</tr>
		<tr>
			<td class='normalfooter1' align='center'>
			<div style='margin: 3px 0pt 0pt;'><div class='download'><a class='dlink' href='count-$id.html'>
								  التحميل :  $visits
					</a></div>
</td>
		</tr>
	</tbody></table></div></td>";
				   			$counter++;	  
				   		      $nor++;  

			}			
			}
			else{
			$main .="<td valign='top'><center><div align=center>لا يوجد اى مقالات فى هذا القسم !</div></center><td>";
			}
						$current = ($start/$limit1)+1;
			
/*****************************************************************************************************
- Sticky - Sticky - Sticky - Sticky - Sticky - Sticky - Sticky - Sticky - Sticky - Sticky - Sticky -
*****************************************************************************************************/
$amysqlQuery=new mysqlQueryClass();

$pquery=("SELECT COUNT(`id`) AS `c` FROM `products` WHERE `sticky` = 1");
$mysqlQuery->mysqlQueryWOF($pquery);

extract(mysql_fetch_array($mysqlQuery->result));

$squery="SELECT `id`, `name`,`photo`,`shortdes`, `vb`,`visits`,`catid` FROM `products` 
				WHERE `sticky` = 1 ORDER BY `id` DESC";
			
			$mysqlQuery->mysqlQueryWOF($squery);

			 $counter = 1 + $start  ;			
       $nor = 0; 
      if ($mysqlQuery->resultNoRows!=0) {
      while(list($id,$name,$photo,$shortdes,$vbname,$visits,$catId) = mysql_fetch_array($mysqlQuery->result)){
		    	
				$tquery="SELECT `name` FROM `catagories` 
				WHERE `level` = 1 AND `id` ='$catId' LIMIT 1";
			
			$amysqlQuery->mysqlQueryWOF($tquery);
			
				list($catname)= mysql_fetch_array($amysqlQuery->result);
				
     if ($nor % 3 == 0) {
        $sticky .= '</tr><tr>';
                  }  
				  
						$sticky .="<td style='border: 0px none; margin: 0px; padding: 0px; width: 325px;' align='center' valign='top'>
		   <div style='margin: 10px 0pt;' align='center'>
	<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='308'>
		<tbody><tr>
			<td>
			<div align='center'>
				<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='100%'>
					<tbody><tr>
						<td colspan='3' align='center'>
						<img src='style/$style/images/green_29.jpg' alt='Name' border='0' height='11' width='308'></td>
					</tr>
					<tr>
						<td align='right' width='12'>
						<img src='style/$style/images/green_33.jpg' alt='Name' border='0' height='35' width='12'></td>
						<td class='stickytitle' align='center' width='100'>
			<div style='overflow: hidden; width: 284px; height: 30px;'><a style='text-decoration: none; line-height: 30px;' href='t$id-$name.html'>					$name
				</a></div></td>
						<td align='left' width='4%'>
						<img src='style/$style/images/green_31.jpg' alt='Name' border='0' height='35' width='12'></td>
					</tr>
					<tr>
						<td colspan='3' align='center'>
						<img src='style/$style/images/green_34.jpg' alt='Name' border='0' height='4' width='308'></td>
					</tr>
				</tbody></table>
			</div>
			</td>
		</tr>
		<tr>
			<td>
			<div align='center'>
				<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='100%'>
					<tbody><tr>
						<td class='stickypic' align='center' valign='top'><a href='count-$id.html'>
			<img src='$photo' alt='Article photo' style='border: 1px solid rgb(68, 68, 68); margin: 5px 3px 0pt 0pt; vertical-align: middle;' border='0' height='120' width='155'></a></td>
						<td width='130'>
						<div align='left'>
							<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='130'>
								<tbody><tr>
									<td align='left'>
									<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='130'>
										<tbody><tr>
											<td class='stickydesc' align='left' height='94'><div dir='rtl' style='margin-left: 5px; padding: 0pt; overflow: auto; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 50px; width: 110px; text-align: center; font-family: tahoma; font-size: 13px; color: rgb(153, 153, 153);'> $shortdes</div></td>
											<td rowspan='2' align='left' width='12'>
											<img src='style/$style/images/green_35.jpg' alt='Name' border='0' height='128' width='12'></td>
										</tr>
										<tr>
											<td onclick= window.location.href='count-$id.html' style='cursor: pointer;' class='stickydownload' height='40'></td>
										</tr>
									</tbody></table>
									</td>
								</tr>
								<tr>
									<td class='stickycenter3'></td>
								</tr>
							</tbody></table>
						</div>
						</td>
					</tr>
				</tbody></table>
			</div>
			</td>
		</tr>
		<tr>
			<td>
			<div align='center'>
				<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='100%'>
					<tbody><tr>
						<td class='stickyfooter1'></td>
						<td class='stickyfooter2' align='center' valign='top'><div class='catt' style='margin: 3px 0pt 0pt;'>
				<a href='cat-$catId.html'>
				$catname
				</a>   </div>
			</td>
						<td class='stickyfooter3' align='center' valign='top'><div style='margin: 3px 0pt 0pt;'><a href='count-$id.html'>
					  التحميل :  $visits
								</a></div></td>
					</tr>
				</tbody></table>
			</div>
			</td>
		</tr>
	</tbody></table>
</div>";
				   			$counter++;	  
				   		      $nor++;  

			}			
			}
			else{
			$sticky .="<td valign='top'><center><div align=center>لا يوجد مقالات مثبته حتي الان !</div></center><td>";
			}

break;
/***********************************************************************************************
- 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404 - 404
************************************************************************************************/
case "404" :
$align="center";
$title = "خطأ 404 - Error 404";
$main .= "<td  valign='top'><center><br><br><font size='5' color='#FF0000'><b>
		   عفوا الصفحة المطلوبة غير موجودة
		   </b></font>
		  <br>
		  <br>
		  <br>
		  <img src='./style/$style/images/404.gif'>
		  <br>
		  <font size='4' color='#0000FF'> يمكنك استخدام خاصية البحث في الموقع </font>
		  	<div id='search' style='width: 300px; height: 45px'>
	<form action='index.php?action=search' method='post'> 
	<br>
	<br>
	<center>
		<input name='keyword' type='text' tabindex='1' size='24' style='text-align: right;'>
		 <input type='submit' value='ابحث' tabindex='1' class='input_button'>
		 </center>
	</form></div></center></td>";

break;
/***********************************************************************************************
- 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403 - 403
************************************************************************************************/
case "403" :

$align="center";
$title = "خطأ 403 - Error 403";
//البريد الذي سوف يستقبل رسائل خطأ 403
$myemail="$from";

//إسم دومين موقعك كامل ... لا تضغ / في النهايه
$websiteaddress="$siteurl";

$emailsubject="hacking";

$thedatetime=date("l")." ".date("F")." ".date("j")." ".date("Y")." - ".date("g").":".date("i").":".date("s")." ".date("A");
$userip=getenv("REMOTE_ADDR");

$useragent=getenv("HTTP_USER_AGENT");

$requestedfile=$websiteaddress.getenv("REQUEST_URI");

$referrerpage=getenv("HTTP_REFERER");

$emailmessage="Error 404 Report\r\nDate/Time: ".$thedatetime."\r\nIP Address: ".$userip."\r\nUser agent: ".$useragent."\r\nRequest page that doesn't exists: ".$requestedfile."\r\nReferrer page that contains the broken link: ".$referrerpage;

mail($myemail, $emailsubject, $emailmessage, "From: ".$myemail);

$main .= "<td  valign='top'><center><br><br><font size='5' color='#FF0000'><b>
		   عفوا انت لا تملك الصلاحية للدخول الي هذه المنطقة
		   </b></font>
		  <br>
		  <br>
		  <br>
		  <img src='./style/$style/images/403.gif'>
		  <br>
		  <font color='#0000FF'><b>Your IP IS </b>
		  <b><i>$userip</i></b></font>
		  <br>
		  <br>
		  <b><i><u> IF You're Trying To Hack This System You'll Be In Jail SooN </u></i></b></font>
		  
		  </center></td>";

break;
/***********************************************************************************************
- topic - topic - topic - topic - topic - topic - topic - topic - topic - topic - topic - topic-
************************************************************************************************/
case "topic" :
$align="center";
$id = intval($_GET['id']);
$name = $_GET['name'];

  $mysqlQuery=new mysqlQueryClass();
  
  $query="Update `products` SET `visits` =`visits` + 1 where `id` = '$id'";
      $mysqlQuery->mysqlQueryUpdate($query);

	$query="SELECT `name`, `photo`, `shortdes`, `vb`, `catid` FROM `products`	WHERE `valid` = 1 AND `id`= '$id'";
	
	$mysqlQuery->mysqlQueryWOF($query);
	
      list($name,$photo,$shortdes,$vbname,$catId) = mysql_fetch_array($mysqlQuery->result);
	  $title = $name;
	  $tquery="SELECT `name` FROM `catagories` 
				WHERE `level` = 1 AND `id` ='$catId' LIMIT 1";
			
			$mysqlQuery->mysqlQueryWOF($tquery);
			
				list($catname)= mysql_fetch_array($mysqlQuery->result);

$main .= "<center><a href='random.html'><img src='style/$style/images/random.gif'></a></center>

<table width='700' style='border:1px solid #000000;' bgcolor='#FFFFFF' cellspacing='0'>
<tr>
<td valign='top'>
<center>
<font size='5'><h1><a href='cat-$catId.html'>$catname</a></h1><h2><a href='t$id-$name.html'>$name</a></h2></font><img border='0' src='$photo'  border='0' alt='$name'><font size='3'><p><b>$shortdes</b></p></font><a style='text-decoration: none; font-family: tahoma; font-size: 10pt; font-weight: bold; color: #FF0000;' href='count-$id.html'><font size='5'> تحميل</font></a>
</center>
</td>
</tr>
</table>";

break;
/***************************************************************************************************
- Random - Random - Random - Random - Random - Random - Random - Random - Random - Random - Random -
***************************************************************************************************/
case "random" :
$align="right";
$title = "تصفح عشوائي للمقالات";
$amysqlQuery=new mysqlQueryClass();

$squery="SELECT `id`, `name`,`photo`,`shortdes`, `vb`,`visits`,`catid` FROM `products` 
				WHERE `valid` = 1 ORDER BY Rand() LIMIT $pagesnum";
			
			$mysqlQuery->mysqlQueryWOF($squery);

			 $counter = 1 + $start  ;			
       $nor = 0; 
      if ($mysqlQuery->resultNoRows!=0) {
      while(list($id,$name,$photo,$shortdes,$vbname,$visits,$catId) = mysql_fetch_array($mysqlQuery->result)){
		    	
				$tquery="SELECT `name` FROM `catagories` 
				WHERE `level` = 1 AND `id` ='$catId' LIMIT 1";
			
			$amysqlQuery->mysqlQueryWOF($tquery);
			
				list($catname)= mysql_fetch_array($amysqlQuery->result);
				
     if ($nor % 4 == 0) {
        $main .= '</tr><tr>';
                  }  
				  
						$main .="<td style='border: 0px none; margin: 0px; padding: 0px; width: 240px;' align='center' valign='top'>
		   <div style='margin: 10px 9px 10px 0pt;' align='center'>
<table dir='rtl' border='0' cellpadding='0' cellspacing='0' width='232'>
		<tbody><tr>
			<td class='normalheader' align='center' valign='bottom'>
			<div style='overflow: hidden; width: 210px; height: 30px; margin-bottom: 8px;'><a href='t$id-$name.html'><div style='overflow: hidden; width: 230px;'>
					$name
				</div></td>
		</tr>
		<tr>
			<td class='normalpic' align='center' valign='top'>
				<a href='count-$id.html'>
			<img src='$photo' alt='Article Photo' style='border: 1px solid rgb(68, 68, 68); margin: 1px 0pt 0pt; padding: 0px; vertical-align: middle;' border='0' height='161' width='210'></a></td>
		</tr>
		<tr>
			<td class='normaldesc' align='center'><div dir='rtl' style='padding: 0pt; overflow: auto; -moz-background-clip: border; -moz-background-origin: padding; -moz-background-inline-policy: continuous; height: 50px; width: 210px; text-align: center; font-family: tahoma; font-size: 13px; color: rgb(153, 153, 153); font-weight: bold;'>$shortdes</div>
		</tr>
		<tr>
			<td class='normalfooter2' align='center'><div style='margin: 3px 0pt 0pt;'>
				<a class='clink' href='cat-$catId.html'>
				$catname
				</a></div></td>
		</tr>
		<tr>
			<td class='normalfooter1' align='center'>
			<div style='margin: 3px 0pt 0pt;'><div class='download'><a class='dlink' href='count-$id.html'>
								  التحميل :  $visits
					</a></div>
</td>
		</tr>
	</tbody></table></div></td>";
				   			$counter++;	  
				   		      $nor++;  

			}			
			}
			else{
			$main .="<td valign='top'><center><div align=center>لا يوجد اى مقالات فى هذا القسم !</div></center><td>";
			}

break;		
}

?>

