PageRenderTime 58ms CodeModel.GetById 30ms RepoModel.GetById 1ms app.codeStats 0ms

/show/show.php

https://github.com/sangyuanyuan/fanqie
PHP | 333 lines | 300 code | 20 blank | 13 comment | 24 complexity | ea89626d5ae2c3750eeb9ba2824e64a6 MD5 | raw file
  1. <?php
  2. require_once('../frame.php');
  3. session_start();
  4. setsession($_SERVER['HTTP_HOST']);
  5. $id = $_REQUEST['id'];
  6. $image = new smg_images_class();
  7. $image->find($id);
  8. $category = new table_class('smg_category');
  9. $category->find($image->category_id);
  10. //$y2k = mktime(0,0,0,1,1,2020);
  11. //$cookie_name = 'show_'.date("Y-m-d").'_'.$id;
  12. //if($_COOKIE[$cookie_name]==''){
  13. // SetCookie($cookie_name,'1',$y2k,'/');
  14. //}else{
  15. // $cookie = $_COOKIE[$cookie_name]+1;
  16. // SetCookie($cookie_name,$cookie,$y2k,'/');
  17. //}
  18. //if($_COOKIE[$cookie_name]<200){
  19. $image->click_count = $image->click_count+1;
  20. $image -> save();
  21. //}
  22. ?>
  23. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
  24. <html xmlns="http://www.w3.org/1999/xhtml">
  25. <head>
  26. <meta http-equiv=Content-Type content="text/html; charset=utf-8">
  27. <meta http-equiv=Content-Language content=zh-cn>
  28. <title>SMG-番茄网-展示-摄影</title>
  29. <?php
  30. css_include_tag('show_show','top','bottom');
  31. use_jquery();
  32. js_include_tag('pubfun','total');
  33. ?>
  34. </head>
  35. <?php
  36. //if($_COOKIE[$cookie_name]<200){
  37. ?>
  38. <script>
  39. total("<?php echo $category->name;?>","<?php echo $category->platform;?>");
  40. </script>
  41. <?php
  42. //}
  43. ?>
  44. <body>
  45. <? require_once('../inc/top.inc.html');
  46. if($image->url!=''){
  47. if(strpos($image->url,basename($_SERVER['PHP_SELF']))&&strpos($image->url,'id='.$id)){
  48. alert('对不起,链接出错了!请联系管理员!');
  49. }else{
  50. redirect($image->url);
  51. }
  52. }
  53. ?>
  54. <div id=ibody>
  55. <div id=ibody_left>
  56. <div id=l_t>
  57. <a href="show_sub.php?type=image"><img border=0 src="/images/show/show_l_t.jpg" width="290"></a>
  58. <?php
  59. $db = get_db();
  60. $sql = 'select i.id as img_id,i.title,i.src,i.priority as ipriority from smg_images i left join smg_category c on i.category_id=c.id where i.priority=0 and i.is_adopt=1 and c.name="番茄广告" and c.platform="show" order by i.priority asc,i.created_at desc limit 4';
  61. $record_ad=$db -> query($sql);
  62. $count = count($record_ad);
  63. for($i=0;$i<$count;$i++){
  64. $picsurl[]=$record_ad[$i]->src;
  65. $picslink[]='/show/show.php?id='.$record_ad[$i]->id;
  66. $picstext[]=flash_str_replace($record_ad[$i]->title);
  67. }
  68. ?>
  69. <?php if($count==1){?>
  70. <a href="/show/show.php?id=<?php echo $record_ad[0]->img_id?>" target=_blank><img src="<?php echo $record_ad[0]->src?>" width=289; height=187; border=0></a>
  71. <? }else{?>
  72. <script src="/flash/sohuflash_1.js" type="text/javascript"></script>
  73. <div id="focus_02"></div>
  74. <script type="text/javascript">
  75. var pic_width1=290; //图片宽度
  76. var pic_height1=190; //图片高度
  77. var pics="<?php echo implode(',',$picsurl);?>";
  78. var mylinks="<?php echo implode(',',$picslink);?>";
  79. var texts="<?php echo implode(',',$picstext);?>";
  80. var picflash = new sohuFlash("/flash/focus.swf", "focus_02", pic_width1, pic_height1, "4","#FFFFFF");
  81. picflash.addParam('wmode','opaque');
  82. picflash.addVariable("picurl",pics);
  83. picflash.addVariable("piclink",mylinks);
  84. picflash.addVariable("pictext",texts);
  85. picflash.addVariable("pictime","5");
  86. picflash.addVariable("borderwidth",pic_width1);
  87. picflash.addVariable("borderheight",pic_height1);
  88. picflash.addVariable("borderw","false");
  89. picflash.addVariable("buttondisplay","true");
  90. picflash.addVariable("textheight","15");
  91. picflash.addVariable("pic_width",pic_width1);
  92. picflash.addVariable("pic_height",pic_height1);
  93. picflash.write("focus_02");
  94. </script>
  95. <? }?>
  96. </div>
  97. <div class=l_m>
  98. <div class=title><div name="user" class=left1>用户排行榜|</div><div class=left1 name="dept" style="color:#999999">部门排行榜</div></div>
  99. <?php
  100. $sql = 'SELECT t1.publisher,count(t1.title) as num FROM smg_images t1 join smg_category t2 on t1.category_id=t2.id where t1.publisher!="" and t1.is_adopt=1 and t1.publisher!="admin" and t2.platform="show" group by t1.publisher order by num desc limit 5';
  101. $records = $db->query($sql);
  102. $count = count($records);
  103. for($i=0;$i<$count;$i++){
  104. ?>
  105. <div class="content user change" <?php if($i==$count-1){?>style="border-bottom:none;"<?php }?>>
  106. <div class=left><? echo $i+1;?></div>
  107. <div class=right>
  108. <div class=top><a href="list.php?publisher=<?php echo urlencode($records[$i]->publisher);?>&type=image"><?php echo $records[$i]->publisher; ?></a></div>
  109. <div class=bottom>发布了<?php echo $records[$i]->num; ?>张图片</div>
  110. </div>
  111. </div>
  112. <? }?>
  113. <?php
  114. $db = get_db();
  115. $sql = 'SELECT t3.name,count(t1.title) as num FROM smg_images t1 join smg_category t2 on t1.category_id=t2.id join smg_dept t3 on t1.dept_id=t3.id where t1.is_adopt=1 and t2.platform="show" group by t1.dept_id order by num desc limit 5';
  116. $records = $db->query($sql);
  117. $count = count($records);
  118. for($i=0;$i<$count;$i++){
  119. ?>
  120. <div class="content dept change" style="display:none;" <?php if($i==$count-1){?>style="border-bottom:none;"<?php }?>>
  121. <div class=left><? echo $i+1;?></div>
  122. <div class=right>
  123. <div class=top><?php echo $records[$i]->name;?></div>
  124. <div class=bottom>发布了<?php echo $records[$i]->num; ?>张图片</div>
  125. </div>
  126. </div>
  127. <? }?>
  128. </div>
  129. <div class=l_m>
  130. <div class=title><div class=left>热门标签</div></div>
  131. <div class=content style="border-bottom:none;">
  132. <?php
  133. $sql = 'select keywords from smg_images where keywords!="" order by click_count desc limit 10';
  134. $records = $db->query($sql);
  135. $c = array();
  136. for($i=0;$i<count($records);$i++){
  137. $keywords = explode(',', $records[$i]->keywords);
  138. if(count($keywords)==1)$keywords = explode(',', $records[$i]->keywords);
  139. if(count($keywords)==1)$keywords = explode(' ', $records[$i]->keywords);
  140. if(count($keywords)==1)$keywords = explode(' ', $records[$i]->keywords);
  141. for($j=0;$j<count($keywords);$j++){
  142. if(!in_array($keywords[$j],$c))array_push($c,$keywords[$j]);
  143. }
  144. $keywords = '';
  145. }
  146. for($i=0;$i<count($c);$i++){
  147. ?>
  148. <a class="tag<?php echo rand(1, 6);?>" href="/search/?key=<?php echo urlencode($c[$i]);?>&search_type=smg_images"><?php echo $c[$i];?></a>
  149. <?php } ?>
  150. </div>
  151. </div>
  152. </div>
  153. <div id=ibody_right>
  154. <div id=r_t>
  155. <?php if($image->src==''){?>
  156. 对不起你所访问的图片链接有错误请与管理员联系
  157. <?php }else{
  158. ?>
  159. <div id="image">
  160. <div id=image_border>
  161. <a href="<?php echo $image->src;?>" >
  162. <img border=0 src="<?php echo $image->src?>" style=" padding:0; float:left; display:inline" width=670>
  163. </a>
  164. </div>
  165. </div>
  166. <div class=digg>
  167. <div id="flower" title="送鲜花">
  168. <?php echo $image->flower;?>
  169. <input type="hidden" id="hidden_flower" value="<?php echo $image->flower!=''?$image->flower:0;?>">
  170. </div>
  171. <div id="tomato" title="丢番茄">
  172. <?php echo $image->tomato;?>
  173. <input type="hidden" id="hidden_tomato" value="<?php echo $image->tomato!=''?$image->tomato:0;?>">
  174. </div>
  175. <input type="hidden" id="image_id" value="<?php echo $id;?>">
  176. </div>
  177. <?php }?>
  178. </div>
  179. <div id="info">
  180. <div class=title>图片信息</div>
  181. <div class=content>
  182. <div class=top>
  183. <div id=name>图片名称<?php echo $image->title;?></div>
  184. </div>
  185. <div class=center>
  186. <div class=left>
  187. <div class=title>发布者</div>
  188. <div id=publisher><?php echo $image->publisher;?></div>
  189. </div>
  190. <div class=middle>
  191. <div class=title>发布于</div>
  192. <div id=date><?php echo substr($image->created_at, 0, 10);?></div>
  193. </div>
  194. <div class=right>
  195. <div class=title>该图片被点击</div>
  196. <div id=count><?php echo $image->click_count;?></div>
  197. </div>
  198. </div>
  199. <div class=bottom>
  200. <div class=title>图片简介</div>
  201. <div id=description><?php echo $image->description;?></div>
  202. </div>
  203. </div>
  204. </div>
  205. <div id=r_b>
  206. <div id=r_b_l>
  207. <div class=title>网友评论</div>
  208. <?php
  209. $comment = new table_class('smg_comment');
  210. $records = $comment->find('all',array('conditions' => 'resource_type="picture" and resource_id='.$id));
  211. $count2 = count($records);
  212. $records = $comment->paginate('all',array('conditions' => 'resource_type="picture" and resource_id='.$id,'order' => 'created_at desc'),6);
  213. $count = count($records);
  214. for($i=0;$i<$count;$i++){
  215. ?>
  216. <div class=content>
  217. <div class=r>
  218. <div class=t><?php echo $records[$i]->nick_name?></div>
  219. <div class=b><?php echo $records[$i]->comment?></div>
  220. </div>
  221. </div>
  222. <?php }?>
  223. <div id=paginate><?php paginate();?></div>
  224. <div id=comment_box <?php if($image->commentable!="on"){?>style="display:none;"<?php } ?>>
  225. <form id="comment_form" action="/pub/pub.post.php" method="post">
  226. <div class=title>现在有<span style="color:#FF5800"><?php echo $count2;?></span>人发表评论</div>
  227. <div id=commenter_box><input type="text" style="width:330px;" id="c_n_n" name="post[nick_name]"></div>
  228. <input type="hidden" name="post[resource_id]" value="<?php echo $id;?>">
  229. <input type="hidden" name="post[resource_type]" value="picture">
  230. <input type="hidden" name="type" value="comment">
  231. <div id="commit_fck"><?php show_fckeditor('post[comment]','Title',false,'75','','334');?></div>
  232. <div id=fqbq></div>
  233. <div id=submit_comment></div>
  234. </form>
  235. </div>
  236. </div>
  237. <div id=r_b_r>
  238. <div class=title>更多该用户的照片</div>
  239. <?php
  240. $images = new smg_images_class();
  241. $records = $images->find('all',array('conditions' => 'is_adopt=1 and src is not null and publisher="'.$image->publisher.'" and id!='.$id,'limit' => '8'));
  242. $count = count($records);
  243. for($i=0;$i<$count;$i++){
  244. ?>
  245. <div class=pic><a title="<?php echo $records[$i]->title; ?>" href="show.php?id=<?php echo $records[$i]->id;?>"><img width=145 height=105 border=0 src="<?php echo $records[$i]->src_path('small');?>"></a></div>
  246. <?php }?>
  247. </div>
  248. </div>
  249. </div>
  250. </div>
  251. <?php
  252. close_db();
  253. require_once('../inc/bottom.inc.php');
  254. ?>
  255. </body>
  256. </html>
  257. <script>
  258. $(function(){
  259. var flower_num = $("#hidden_flower").attr('value');
  260. var tomato_num = $("#hidden_tomato").attr('value');
  261. display_fqbq('fqbq','post[comment]');
  262. $("#submit_comment").click(function(){
  263. var oEditor = FCKeditorAPI.GetInstance('post[comment]') ;
  264. var comment = oEditor.GetHTML();
  265. if($("#c_n_n").val().length>80){
  266. alert("昵称长度太长!");
  267. return false;
  268. }
  269. if(comment==""){
  270. alert("请输入评论内容!");
  271. return false;
  272. }
  273. if(comment.length > 1500){
  274. alert('评论内容太长,请联系管理员');
  275. return false;
  276. }
  277. $("#comment_form").submit();
  278. })
  279. $("#flower").click(function(){
  280. flower_num++;
  281. $("#hidden_flower").attr('value',flower_num);
  282. $(this).html(flower_num);
  283. $.post("/pub/pub.post.php",{'type':'flower','id':$("#image_id").attr('value'),'db_table':'smg_images','digg_type':'picture'},function(data){
  284. if(data!=''){
  285. alert(data);
  286. }else{
  287. total("<?php echo $category->name;?>digg","<?php echo $category->platform;?>");
  288. }
  289. });
  290. });
  291. $("#tomato").click(function(){
  292. tomato_num++;
  293. $("#hidden_tomato").attr('value',tomato_num);
  294. $(this).html(tomato_num);
  295. $.post("/pub/pub.post.php",{'type':'tomato','id':$("#image_id").attr('value'),'db_table':'smg_images','digg_type':'picture'},function(data){
  296. if(data!=''){
  297. alert(data);
  298. }else{
  299. total("<?php echo $category->name;?>digg","<?php echo $category->platform;?>");
  300. }
  301. });
  302. })
  303. $(".left1").hover(function(){
  304. $(".left1").css('color','#999999');
  305. $(this).css('color','#000000');
  306. $(".change").hide();
  307. $("."+$(this).attr('name')).show();
  308. })
  309. $("[class*=tag]").click(function(){
  310. //window.location.href="list.php?tag="+$(this).html();
  311. })
  312. });
  313. </script>