PageRenderTime 51ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/Quản lý website bán áo đồng phục PHP/lamao/modules/bp.php

https://gitlab.com/phamngsinh/baitaplon_sinhvien
PHP | 207 lines | 207 code | 0 blank | 0 comment | 1 complexity | ecbb5104646bb92dd5ad5fb889943fdd MD5 | raw file
  1. <?php if (substr_count($_SERVER['PHP_SELF'],'/bp.php')>0) die ("You can't access this file directly..."); ?>
  2. <div class="bo">
  3. <table width="100%" border="0" cellpadding="0" cellspacing="0">
  4. <?php
  5. if (isset($_REQUEST['catID']))
  6. {
  7. $tblname='products';
  8. $query ='select * from '.$tblname.'_cat where id='.$_REQUEST['catID'].'';
  9. $doquery=mysql_query($query,$link);
  10. if ($doquery and mysql_num_rows($doquery)>0)
  11. {
  12. $result=mysql_fetch_array($doquery);
  13. $path=$result['level'];
  14. $name=$result['name'];
  15. $level=strlen(str_replace('.','',$path))/2;
  16. }
  17. $obj=$level;
  18. switch ($obj)
  19. {
  20. case '1':
  21. $itemonrow=1;
  22. $rows=18;
  23. $curpage=1;
  24. // Get title
  25. $query1 ='select '.$tblname.'.*,'.$tblname.'_cat.level as category_level';
  26. $query1.=' from '.$tblname.' inner join '.$tblname.'_cat';
  27. $query1.=' on '.$tblname.'.category='.$tblname.'_cat.id';
  28. $query1.=' where '.$tblname.'_cat.level like "'.$path.'%"';
  29. //echo $query1;
  30. $doquery1=mysql_query($query1,$link);
  31. if ($doquery1 and mysql_num_rows($doquery1)>0)
  32. {
  33. $catid='';
  34. $j=0;
  35. while($result1=mysql_fetch_array($doquery1))
  36. {
  37. $j++;
  38. $id=$result1['id'];
  39. $chain=chain($tblname,$result1['category_level'],'level',get_langID());
  40. $catid.=$id.',';
  41. }
  42. }
  43. ?>
  44. <tr>
  45. <td height="29" colspan="3" background="/images/bg_center1.gif">
  46. <p>
  47. <div style="float:left; margin-top:3px;">&nbsp;<img src="/images/home_ico.gif" height="20" width="20"/></div>
  48. <div style="float:left; margin-top:5px;"><font class="btitle">&nbsp;&nbsp;<?php echo $name; ?>&nbsp;&nbsp;&nbsp;&nbsp;</font></div>
  49. </p>
  50. </td>
  51. </tr>
  52. <tr><td colspan="3" height="20" align="right" style="padding-top: 6px;"><?php include ($module_dir.'navigator.php'); ?></td></tr>
  53. <tr><td height="29" colspan="3" align="center">
  54. <?php
  55. // Get items
  56. $query2 ='select * from '.$tblname.' where';
  57. $query2.=' id in ('.$catid.') and';
  58. $query2.=' lang="'.get_langID().'"';
  59. $query2.=' and '.$tblname.'.active=1';
  60. $query2.=' order by log DESC';
  61. $query2= str_replace(',)',')',$query2);
  62. //echo $query2;
  63. //show_content();
  64. if (isset($_REQUEST['curpage'],$_REQUEST['totalpage'],$_REQUEST['found']))
  65. {
  66. $found=$_REQUEST['found'];
  67. $totalpage=$_REQUEST['totalpage'];
  68. $curpage=$_REQUEST['curpage'];
  69. $from=($curpage-1) * $itemonrow * $rows;
  70. $to=$from + $itemonrow*$rows;
  71. $limit=' limit '.$from.','.$to;
  72. }
  73. if (isset($limit,$query2))
  74. $query2.=$limit;
  75. //exit;
  76. //echo $query2;
  77. $doquery2=mysql_query($query2,$link);
  78. if ($doquery2 and mysql_num_rows($doquery2)>1)
  79. {
  80. if (!isset($found))
  81. $found=mysql_num_rows($doquery2);
  82. if (!isset($totalpage))
  83. {
  84. if ($found<($itemonrow*$rows))
  85. $totalpage=1;
  86. else
  87. {
  88. if ($found%($itemonrow*$rows)==0)
  89. $totalpage=$found/($itemonrow*$rows);
  90. else
  91. $totalpage=(int)($found/($itemonrow*$rows))+1;
  92. }
  93. }
  94. if (isset($found) and $found!=0)
  95. {
  96. }
  97. $i=0;
  98. while ($result2=mysql_fetch_array($doquery2) and $i<=($itemonrow*$rows))
  99. {
  100. $title=$result2['title'];
  101. $content=stripslashes($result2['content']);
  102. $id=$result2['id'];
  103. $image=$result2['image'];
  104. $category=$result2['category'];
  105. $price=bsVndDot($result2['price']);
  106. //$url='?module=dp&catID='.$category.'&artID='.$id;
  107. $url='/chi-tiet-san-pham/'.$category.'/'.$id.'/'.removeSpecialChars(removesign($title)).'.html';
  108. //Show item
  109. ?>
  110. <div class="bg">
  111. <div class="vien">
  112. <div><a href="/<?php echo $image; ?>" rel="lightbox"><?php displaypic($image,'medium','center'); ?></a></div>
  113. <div class="title"><a href="<?php echo $url; ?>"><?php echo $title; ?></a></div>
  114. <div class="gia"><?php echo $price; ?> VNĐ</div>
  115. </div>
  116. </div>
  117. <?php
  118. $i++;
  119. if ($i==$rows*$itemonrow)
  120. break;
  121. }
  122. ?>
  123. </td></tr>
  124. <tr><td height="30" colspan="3" align="right" style="padding: 6 6 6 6;">
  125. <?php
  126. if (isset($totalpage))
  127. {
  128. for ($i=1; $i<=$totalpage; $i++)
  129. {
  130. //if ($i%20==1)
  131. //echo '</p><p class="title" style="font-weight: bold; text-align: right;">';
  132. echo '<input type="button" value="';
  133. if ($i<10)
  134. echo '0';
  135. echo $i.'"';
  136. if ($i!=$curpage)
  137. {
  138. echo ' class="button"';
  139. echo ' onClick="browse('.$i;
  140. echo ')"';
  141. echo ' onmouseover="this.className=\'button_over\'" onmouseout="this.className=\'button\'"';
  142. }
  143. else
  144. echo ' class="button_down"';
  145. echo ">&nbsp;\n";
  146. }
  147. }
  148. ?>
  149. <script language="Javascript">
  150. function browse(curpage)
  151. {
  152. document.browsesearch.curpage.value=curpage;
  153. //document.browsesearch.cat.value=cat;
  154. document.browsesearch.submit();
  155. }
  156. </script>
  157. <form name="browsesearch" method="get" action="">
  158. <input type="hidden" name="module" value="bp">
  159. <input type="hidden" name="found" value="<?php echo $found; ?>">
  160. <input type="hidden" name="totalpage" value="<?php echo $totalpage; ?>">
  161. <input type="hidden" name="curpage" value="">
  162. <?php
  163. if (isset($_REQUEST['catID']))
  164. echo "<input type=\"hidden\" name=\"catID\" value=\"".$_REQUEST['catID']."\">\n";
  165. ?>
  166. </form>
  167. </td></tr>
  168. <?php
  169. }
  170. else
  171. {
  172. if (mysql_num_rows($doquery2)==1)
  173. {
  174. $result2=mysql_fetch_array($doquery2);
  175. $id=$result2['id'];
  176. $title=$result2['title'];
  177. $category=$result2['category'];
  178. //$url='?module=dp&artID='.$id.'&catID='.$category;
  179. $url='/chi-tiet-san-pham/'.$category.'/'.$id.'/'.removeSpecialChars(removesign($title)).'.html';
  180. ?>
  181. <script>
  182. //replace
  183. window.location.replace("<?php echo $url; ?>")
  184. </script>
  185. <?php
  186. }
  187. else
  188. {
  189. ?>
  190. <script>
  191. alert("<?php echo $display['noarticle']; ?>")
  192. window.history.go(-1)
  193. </script>
  194. <?php
  195. }
  196. }
  197. break;
  198. default:
  199. break;
  200. }
  201. }
  202. ?>
  203. </td></tr>
  204. </table>
  205. </div>