content.php 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732
  1. <?php
  2. /**
  3. * 会员前台投稿操作类
  4. */
  5. defined('IN_PHPCMS') or exit('No permission resources.');
  6. pc_base::load_app_class('foreground');
  7. pc_base::load_sys_class('format', '', 0);
  8. pc_base::load_sys_class('form', '', 0);
  9. pc_base::load_app_func('global', 'member');
  10. class content extends foreground {
  11. private $times_db;
  12. function __construct() {
  13. parent::__construct();
  14. }
  15. public function publish() {
  16. $memberinfo = $this->memberinfo;
  17. $grouplist = getcache('grouplist');
  18. $priv_db = pc_base::load_model('category_priv_model'); //加载栏目权限表数据模型
  19. //判断会员组是否允许投稿
  20. if(!$grouplist[$memberinfo['groupid']]['allowpost']) {
  21. showmessage(L('member_group').L('publish_deny'), HTTP_REFERER);
  22. }
  23. //判断每日投稿数
  24. $this->content_check_db = pc_base::load_model('content_check_model');
  25. $todaytime = strtotime(date('y-m-d',SYS_TIME));
  26. $_username = $this->memberinfo['username'];
  27. $allowpostnum = $this->content_check_db->count("`inputtime` > $todaytime AND `username`='$_username'");
  28. if($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) {
  29. showmessage(L('allowpostnum_deny').$grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER);
  30. }
  31. $siteids = getcache('category_content', 'commons');
  32. header("Cache-control: private");
  33. if(isset($_POST['dosubmit'])) {
  34. $catid = intval($_POST['info']['catid']);
  35. //判断此类型用户是否有权限在此栏目下提交投稿
  36. if (!$priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  37. $siteid = $siteids[$catid];
  38. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  39. $category = $CATEGORYS[$catid];
  40. $modelid = $category['modelid'];
  41. if(!$modelid) showmessage(L('illegal_parameters'), HTTP_REFERER);
  42. $this->content_db = pc_base::load_model('content_model');
  43. $this->content_db->set_model($modelid);
  44. $table_name = $this->content_db->table_name;
  45. $fields_sys = $this->content_db->get_fields();
  46. $this->content_db->table_name = $table_name.'_data';
  47. $fields_attr = $this->content_db->get_fields();
  48. $fields = array_merge($fields_sys,$fields_attr);
  49. $fields = array_keys($fields);
  50. $info = array();
  51. foreach($_POST['info'] as $_k=>$_v) {
  52. if($_k == 'content') {
  53. $info[$_k] = remove_xss(strip_tags($_v, '<p><a><br><img><ul><li><div>'));
  54. } elseif(in_array($_k, $fields)) {
  55. $info[$_k] = new_html_special_chars(trim_script($_v));
  56. }
  57. }
  58. $_POST['linkurl'] = str_replace(array('"','(',')',",",' ','%'),'',new_html_special_chars(strip_tags($_POST['linkurl'])));
  59. $post_fields = array_keys($_POST['info']);
  60. $post_fields = array_intersect_assoc($fields,$post_fields);
  61. $setting = string2array($category['setting']);
  62. if($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint']))
  63. showmessage(L('points_less_than',array('point'=>$memberinfo['point'],'need_point'=>abs($setting['presentpoint']))),APP_PATH.'index.php?m=pay&c=deposit&a=pay&exchange=point',3000);
  64. //判断会员组投稿是否需要审核
  65. if($grouplist[$memberinfo['groupid']]['allowpostverify'] || !$setting['workflowid']) {
  66. $info['status'] = 99;
  67. } else {
  68. $info['status'] = 1;
  69. }
  70. $info['username'] = $memberinfo['username'];
  71. if(isset($info['title'])) $info['title'] = safe_replace($info['title']);
  72. $this->content_db->siteid = $siteid;
  73. $id = $this->content_db->add_content($info);
  74. //检查投稿奖励或扣除积分
  75. if ($info['status']==99) {
  76. $flag = $catid.'_'.$id;
  77. if($setting['presentpoint']>0) {
  78. pc_base::load_app_class('receipts','pay',0);
  79. receipts::point($setting['presentpoint'],$memberinfo['userid'], $memberinfo['username'], $flag,'selfincome',L('contribute_add_point'),$memberinfo['username']);
  80. } else {
  81. pc_base::load_app_class('spend','pay',0);
  82. spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
  83. }
  84. }
  85. //缓存结果
  86. $model_cache = getcache('model','commons');
  87. $infos = array();
  88. foreach ($model_cache as $modelid=>$model) {
  89. if($model['siteid']==$siteid) {
  90. $datas = array();
  91. $this->content_db->set_model($modelid);
  92. $datas = $this->content_db->select(array('username'=>$memberinfo['username'],'sysadd'=>0),'id,catid,title,url,username,sysadd,inputtime,status',100,'id DESC');
  93. if($datas) $infos = array_merge($infos,$datas);
  94. }
  95. }
  96. setcache('member_'.$memberinfo['userid'].'_'.$siteid, $infos,'content');
  97. //缓存结果 END
  98. if($info['status']==99) {
  99. showmessage(L('contributors_success'), APP_PATH.'index.php?m=member&c=content&a=published');
  100. } else {
  101. showmessage(L('contributors_checked'), APP_PATH.'index.php?m=member&c=content&a=published');
  102. }
  103. } else {
  104. $show_header = $show_dialog = $show_validator = '';
  105. $temp_language = L('news','','content');
  106. $sitelist = getcache('sitelist','commons');
  107. if(!isset($_GET['siteid']) && count($sitelist)>1) {
  108. include template('member', 'content_publish_select_model');
  109. exit;
  110. }
  111. //设置cookie 在附件添加处调用
  112. param::set_cookie('module', 'content');
  113. $siteid = intval($_GET['siteid']);
  114. if(!$siteid) $siteid = 1;
  115. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  116. foreach ($CATEGORYS as $catid=>$cat) {
  117. if($cat['siteid']==$siteid && $cat['child']==0 && $cat['type']==0 && $priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) break;
  118. }
  119. $catid = $_GET['catid'] ? intval($_GET['catid']) : $catid;
  120. if (!$catid) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  121. //判断本栏目是否允许投稿
  122. if (!$priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  123. $category = $CATEGORYS[$catid];
  124. if($category['siteid']!=$siteid) showmessage(L('site_no_category'),'?m=member&c=content&a=publish');
  125. $setting = string2array($category['setting']);
  126. if($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint']))
  127. showmessage(L('points_less_than',array('point'=>$memberinfo['point'],'need_point'=>abs($setting['presentpoint']))),APP_PATH.'index.php?m=pay&c=deposit&a=pay&exchange=point',3000);
  128. if($category['type']!=0) showmessage(L('illegal_operation'));
  129. $modelid = $category['modelid'];
  130. $model_arr = getcache('model', 'commons');
  131. $MODEL = $model_arr[$modelid];
  132. unset($model_arr);
  133. require CACHE_MODEL_PATH.'content_form.class.php';
  134. $content_form = new content_form($modelid, $catid, $CATEGORYS);
  135. $forminfos_data = $content_form->get();
  136. $forminfos = array();
  137. foreach($forminfos_data as $_fk=>$_fv) {
  138. if($_fv['isomnipotent']) continue;
  139. if($_fv['formtype']=='omnipotent') {
  140. foreach($forminfos_data as $_fm=>$_fm_value) {
  141. if($_fm_value['isomnipotent']) {
  142. $_fv['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$_fv['form']);
  143. }
  144. }
  145. }
  146. $forminfos[$_fk] = $_fv;
  147. }
  148. $formValidator = $content_form->formValidator;
  149. //去掉栏目id
  150. unset($forminfos['catid']);
  151. $workflowid = $setting['workflowid'];
  152. header("Cache-control: private");
  153. $template = $MODEL['member_add_template'] ? $MODEL['member_add_template'] : 'content_publish';
  154. include template('member', $template);
  155. }
  156. }
  157. public function published() {
  158. $memberinfo = $this->memberinfo;
  159. $sitelist = getcache('sitelist','commons');
  160. if(!isset($_GET['siteid']) && count($sitelist)>1) {
  161. include template('member', 'content_publish_select_model');
  162. exit;
  163. }
  164. $_username = $this->memberinfo['username'];
  165. $_userid = $this->memberinfo['userid'];
  166. $siteid = intval($_GET['siteid']);
  167. if(!$siteid) $siteid = 1;
  168. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  169. $siteurl = siteurl($siteid);
  170. $pagesize = 20;
  171. $page = max(intval($_GET['page']),1);
  172. $workflows = getcache('workflow_'.$siteid,'commons');
  173. $this->content_check_db = pc_base::load_model('content_check_model');
  174. $infos = $this->content_check_db->listinfo(array('username'=>$_username, 'siteid'=>$siteid),'inputtime DESC',$page);
  175. $datas = array();
  176. foreach($infos as $_v) {
  177. $arr_checkid = explode('-',$_v['checkid']);
  178. $_v['id'] = $arr_checkid[1];
  179. $_v['modelid'] = $arr_checkid[2];
  180. $_v['url'] = $_v['status']==99 ? go($_v['catid'],$_v['id']) : APP_PATH.'index.php?m=content&c=index&a=show&catid='.$_v['catid'].'&id='.$_v['id'];
  181. if(!isset($setting[$_v['catid']])) $setting[$_v['catid']] = string2array($CATEGORYS[$_v['catid']]['setting']);
  182. $workflowid = $setting[$_v['catid']]['workflowid'];
  183. $_v['flag'] = $workflows[$workflowid]['flag'];
  184. $datas[] = $_v;
  185. }
  186. $pages = $this->content_check_db->pages;
  187. include template('member', 'content_published');
  188. }
  189. /**
  190. * 编辑内容
  191. */
  192. public function edit() {
  193. $_username = $this->memberinfo['username'];
  194. if(isset($_POST['dosubmit'])) {
  195. $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
  196. $siteids = getcache('category_content', 'commons');
  197. $siteid = $siteids[$catid];
  198. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  199. $category = $CATEGORYS[$catid];
  200. if($category['type']==0) {
  201. $id = intval($_POST['id']);
  202. $catid = $_POST['info']['catid'] = intval($_POST['info']['catid']);
  203. $this->content_db = pc_base::load_model('content_model');
  204. $modelid = $category['modelid'];
  205. $this->content_db->set_model($modelid);
  206. //判断会员组投稿是否需要审核
  207. $memberinfo = $this->memberinfo;
  208. $grouplist = getcache('grouplist');
  209. $setting = string2array($category['setting']);
  210. if(!$grouplist[$memberinfo['groupid']]['allowpostverify'] || $setting['workflowid']) {
  211. $_POST['info']['status'] = 1;
  212. }
  213. $info = array();
  214. foreach($_POST['info'] as $_k=>$_v) {
  215. if($_k == 'content') {
  216. $_POST['info'][$_k] = strip_tags($_v, '<p><a><br><img><ul><li><div>');
  217. } elseif(in_array($_k, $fields)) {
  218. $_POST['info'][$_k] = new_html_special_chars(trim_script($_v));
  219. }
  220. }
  221. $_POST['linkurl'] = str_replace(array('"','(',')',",",' ','%'),'',new_html_special_chars(strip_tags($_POST['linkurl'])));
  222. $this->content_db->edit_content($_POST['info'],$id);
  223. $forward = $_POST['forward'];
  224. showmessage(L('update_success'),$forward);
  225. }
  226. } else {
  227. $show_header = $show_dialog = $show_validator = '';
  228. $temp_language = L('news','','content');
  229. //设置cookie 在附件添加处调用
  230. param::set_cookie('module', 'content');
  231. $id = intval($_GET['id']);
  232. if(isset($_GET['catid']) && $_GET['catid']) {
  233. $catid = $_GET['catid'] = intval($_GET['catid']);
  234. param::set_cookie('catid', $catid);
  235. $siteids = getcache('category_content', 'commons');
  236. $siteid = $siteids[$catid];
  237. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  238. $category = $CATEGORYS[$catid];
  239. if($category['type']==0) {
  240. $modelid = $category['modelid'];
  241. $this->model = getcache('model', 'commons');
  242. $this->content_db = pc_base::load_model('content_model');
  243. $this->content_db->set_model($modelid);
  244. $this->content_db->table_name = $this->content_db->db_tablepre.$this->model[$modelid]['tablename'];
  245. $r = $this->content_db->get_one(array('id'=>$id,'username'=>$_username,'sysadd'=>0));
  246. if(!$r) showmessage(L('illegal_operation'));
  247. if($r['status']==99) showmessage(L('has_been_verified'));
  248. $this->content_db->table_name = $this->content_db->table_name.'_data';
  249. $r2 = $this->content_db->get_one(array('id'=>$id));
  250. $data = array_merge($r,$r2);
  251. require CACHE_MODEL_PATH.'content_form.class.php';
  252. $content_form = new content_form($modelid,$catid,$CATEGORYS);
  253. $forminfos_data = $content_form->get($data);
  254. $forminfos = array();
  255. foreach($forminfos_data as $_fk=>$_fv) {
  256. if($_fv['isomnipotent']) continue;
  257. if($_fv['formtype']=='omnipotent') {
  258. foreach($forminfos_data as $_fm=>$_fm_value) {
  259. if($_fm_value['isomnipotent']) {
  260. $_fv['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$_fv['form']);
  261. }
  262. }
  263. }
  264. $forminfos[$_fk] = $_fv;
  265. }
  266. $formValidator = $content_form->formValidator;
  267. include template('member', 'content_publish');
  268. }
  269. }
  270. header("Cache-control: private");
  271. }
  272. }
  273. /**
  274. *
  275. * 会员删除投稿 ...
  276. */
  277. public function delete(){
  278. $id = intval($_GET['id']);
  279. if(!$id){
  280. return false;
  281. }
  282. //判断该文章是否待审,并且属于该会员
  283. $username = param::get_cookie('_username');
  284. $userid = param::get_cookie('_userid');
  285. $siteid = get_siteid();
  286. $catid = intval($_GET['catid']);
  287. $siteids = getcache('category_content', 'commons');
  288. $siteid = $siteids[$catid];
  289. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  290. $category = $CATEGORYS[$catid];
  291. if(!$category){
  292. showmessage(L('operation_failure'), HTTP_REFERER);
  293. }
  294. $modelid = $category['modelid'];
  295. $checkid = 'c-'.$id.'-'.$modelid;
  296. $where = " checkid='$checkid' and username='$username' and status!=99 ";
  297. $check_pushed_db = pc_base::load_model('content_check_model');
  298. $array = $check_pushed_db->get_one($where);
  299. if(!$array){
  300. showmessage(L('operation_failure'), HTTP_REFERER);
  301. }else{
  302. $content_db = pc_base::load_model('content_model');
  303. $content_db->set_model($modelid);
  304. $table_name = $content_db->table_name;
  305. $content_db->delete_content($id); //删除文章
  306. $check_pushed_db->delete(array('checkid'=>$checkid));//删除对应投稿表
  307. showmessage(L('operation_success'), HTTP_REFERER);
  308. }
  309. }
  310. public function info_publish() {
  311. $memberinfo = $this->memberinfo;
  312. $grouplist = getcache('grouplist');
  313. $SEO['title'] = L('info_publish','','info');
  314. //判断会员组是否允许投稿
  315. if(!$grouplist[$memberinfo['groupid']]['allowpost']) {
  316. showmessage(L('member_group').L('publish_deny'), HTTP_REFERER);
  317. }
  318. //判断每日投稿数
  319. $this->content_check_db = pc_base::load_model('content_check_model');
  320. $todaytime = strtotime(date('y-m-d',SYS_TIME));
  321. $_username = $memberinfo['username'];
  322. $allowpostnum = $this->content_check_db->count("`inputtime` > $todaytime AND `username`='$_username'");
  323. if($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) {
  324. showmessage(L('allowpostnum_deny').$grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER);
  325. }
  326. $siteids = getcache('category_content', 'commons');
  327. header("Cache-control: private");
  328. if(isset($_POST['dosubmit'])) {
  329. $catid = intval($_POST['info']['catid']);
  330. $siteid = $siteids[$catid];
  331. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  332. $category = $CATEGORYS[$catid];
  333. $modelid = $category['modelid'];
  334. if(!$modelid) showmessage(L('illegal_parameters'), HTTP_REFERER);
  335. $this->content_db = pc_base::load_model('content_model');
  336. $this->content_db->set_model($modelid);
  337. $table_name = $this->content_db->table_name;
  338. $fields_sys = $this->content_db->get_fields();
  339. $this->content_db->table_name = $table_name.'_data';
  340. $fields_attr = $this->content_db->get_fields();
  341. $fields = array_merge($fields_sys,$fields_attr);
  342. $fields = array_keys($fields);
  343. $info = array();
  344. foreach($_POST['info'] as $_k=>$_v) {
  345. if(in_array($_k, $fields)) $info[$_k] = $_v;
  346. }
  347. $post_fields = array_keys($_POST['info']);
  348. $post_fields = array_intersect_assoc($fields,$post_fields);
  349. $setting = string2array($category['setting']);
  350. if($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint']))
  351. showmessage(L('points_less_than',array('point'=>$memberinfo['point'],'need_point'=>abs($setting['presentpoint']))),APP_PATH.'index.php?m=pay&c=deposit&a=pay&exchange=point',3000);
  352. //判断会员组投稿是否需要审核
  353. if($grouplist[$memberinfo['groupid']]['allowpostverify'] || !$setting['workflowid']) {
  354. $info['status'] = 99;
  355. } else {
  356. $info['status'] = 1;
  357. }
  358. $info['username'] = $memberinfo['username'];
  359. $this->content_db->siteid = $siteid;
  360. $id = $this->content_db->add_content($info);
  361. //检查投稿奖励或扣除积分
  362. $flag = $catid.'_'.$id;
  363. if($setting['presentpoint']>0) {
  364. pc_base::load_app_class('receipts','pay',0);
  365. receipts::point($setting['presentpoint'],$memberinfo['userid'], $memberinfo['username'], $flag,'selfincome',L('contribute_add_point'),$memberinfo['username']);
  366. } else {
  367. pc_base::load_app_class('spend','pay',0);
  368. spend::point($setting['presentpoint'], L('contribute_del_point'), $memberinfo['userid'], $memberinfo['username'], '', '', $flag);
  369. }
  370. //缓存结果
  371. $model_cache = getcache('model','commons');
  372. $infos = array();
  373. foreach ($model_cache as $modelid=>$model) {
  374. if($model['siteid']==$siteid) {
  375. $datas = array();
  376. $this->content_db->set_model($modelid);
  377. $datas = $this->content_db->select(array('username'=>$memberinfo['username'],'sysadd'=>0),'id,catid,title,url,username,sysadd,inputtime,status',100,'id DESC');
  378. }
  379. }
  380. setcache('member_'.$memberinfo['userid'].'_'.$siteid, $infos,'content');
  381. //缓存结果 END
  382. if($info['status']==99) {
  383. showmessage(L('contributors_success'), APP_PATH.'index.php?m=member&c=content&a=info_top&id='.$id.'&catid='.$catid.'&msg=1');
  384. } else {
  385. showmessage(L('contributors_checked'), APP_PATH.'index.php?m=member&c=content&a=info_top&id='.$id.'&catid='.$catid.'&msg=1');
  386. }
  387. } else {
  388. $show_header = $show_dialog = $show_validator = '';
  389. $step = $step_1 = $step_2 = $step_3 = $step_4;
  390. $temp_language = L('news','','content');
  391. $sitelist = getcache('sitelist','commons');
  392. /*
  393. if(!isset($_GET['siteid']) && count($sitelist)>1) {
  394. include template('member', 'content_publish_select_model');
  395. exit;
  396. }
  397. */
  398. //设置cookie 在附件添加处调用
  399. param::set_cookie('module', 'content');
  400. $siteid = intval($_GET['siteid']);
  401. //获取信息模型类别、区域、城市信息
  402. $info_linkageid = getinfocache('info_linkageid');
  403. $cityid = getcity(trim($_GET['city']),'linkageid');
  404. $cityname = getcity(trim($_GET['city']),'name');
  405. $citypinyin = getcity(trim($_GET['city']),'pinyin');
  406. $zone = intval($_GET['zone']);
  407. $zone_name = get_linkage($zone, $info_linkageid, '', 0);
  408. if(!$siteid) $siteid = 1;
  409. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  410. $priv_db = pc_base::load_model('category_priv_model'); //加载栏目权限表数据模型
  411. foreach ($CATEGORYS as $catid=>$cat) {
  412. if($cat['siteid']==$siteid && $cat['child']==0 && $cat['type']==0 && $priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) break;
  413. }
  414. $catid = $_GET['catid'] ? intval($_GET['catid']) : $catid;
  415. if (!$catid) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  416. //判断本栏目是否允许投稿
  417. if (!$priv_db->get_one(array('catid'=>$catid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  418. $category = $CATEGORYS[$catid];
  419. if($category['siteid']!=$siteid) showmessage(L('site_no_category'),'?m=member&c=content&a=info_publish');
  420. $setting = string2array($category['setting']);
  421. if($zone == 0 && !isset($_GET['catid'])) {
  422. $step = 1;
  423. include template('member', 'info_content_publish_select');
  424. exit;
  425. } elseif($zone == 0 && $category['child']) {
  426. $step = 2;
  427. $step_1 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'&city='.$citypinyin.'">'.$category['catname'].'</a>';
  428. include template('member', 'info_content_publish_select');
  429. exit;
  430. } elseif($zone == 0 && isset($_GET['catid'])) {
  431. $step = 3;
  432. $step_1 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'">'.$CATEGORYS[$category['parentid']]['catname'].'</a>';
  433. $step_2 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'&city='.$citypinyin.'&catid='.$category['parentid'].'">'.$category['catname'].'</a>';
  434. $zone_arrchild = show_linkage($info_linkageid,$cityid,$cityid);
  435. include template('member', 'info_content_publish_select');
  436. exit;
  437. } elseif($zone !== 0 && get_linkage_level($info_linkageid,$zone,'child') && !$_GET['jumpstep']) {
  438. $step = 4;
  439. $step_1 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'&city='.$citypinyin.'">'.$CATEGORYS[$category['parentid']]['catname'].'</a>';
  440. $step_2 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'&city='.$citypinyin.'&catid='.$category['parentid'].'">'.$category['catname'].'</a>';
  441. $step_3 = '<a href="'.APP_PATH.'index.php?m=member&c=content&a=info_publish&siteid='.$siteid.'&city='.$citypinyin.'&catid='.$catid.'">'.$zone_name.'</a>';
  442. $zone_arrchild = get_linkage_level($info_linkageid,$zone,'arrchildinfo');
  443. include template('member', 'info_content_publish_select');
  444. exit;
  445. }
  446. if($setting['presentpoint'] < 0 && $memberinfo['point'] < abs($setting['presentpoint']))
  447. showmessage(L('points_less_than',array('point'=>$memberinfo['point'],'need_point'=>abs($setting['presentpoint']))),APP_PATH.'index.php?m=pay&c=deposit&a=pay&exchange=point',3000);
  448. if($category['type']!=0) showmessage(L('illegal_operation'));
  449. $modelid = $category['modelid'];
  450. require CACHE_MODEL_PATH.'content_form.class.php';
  451. $content_form = new content_form($modelid, $catid, $CATEGORYS);
  452. $data = array('zone'=>$zone,'city'=>$cityid);
  453. $forminfos_data = $content_form->get($data);
  454. $forminfos = array();
  455. foreach($forminfos_data as $_fk=>$_fv) {
  456. if($_fv['isomnipotent']) continue;
  457. if($_fv['formtype']=='omnipotent') {
  458. foreach($forminfos_data as $_fm=>$_fm_value) {
  459. if($_fm_value['isomnipotent']) {
  460. $_fv['form'] = str_replace('{'.$_fm.'}',$_fm_value['form'],$_fv['form']);
  461. }
  462. }
  463. }
  464. $forminfos[$_fk] = $_fv;
  465. }
  466. $formValidator = $content_form->formValidator;
  467. //去掉栏目id
  468. unset($forminfos['catid']);
  469. $workflowid = $setting['workflowid'];
  470. header("Cache-control: private");
  471. include template('member', 'info_content_publish');
  472. }
  473. }
  474. function info_top() {
  475. $exist_posids = array();
  476. $memberinfo = $this->memberinfo;
  477. $_username = $this->memberinfo['username'];
  478. $id = intval($_GET['id']);
  479. $catid = $_GET['catid'];
  480. $pos_data = pc_base::load_model('position_data_model');
  481. if(!$id || !$catid) showmessage(L('illegal_parameters'), HTTP_REFERER);
  482. if(isset($catid) && $catid) {
  483. $siteids = getcache('category_content', 'commons');
  484. $siteid = $siteids[$catid];
  485. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  486. $category = $CATEGORYS[$catid];
  487. if($category['type']==0) {
  488. $modelid = $category['modelid'];
  489. $this->model = getcache('model', 'commons');
  490. $this->content_db = pc_base::load_model('content_model');
  491. $this->content_db->set_model($modelid);
  492. $this->content_db->table_name = $this->content_db->db_tablepre.$this->model[$modelid]['tablename'];
  493. $r = $this->content_db->get_one(array('id'=>$id,'username'=>$_username,'sysadd'=>0));
  494. if(!$r) showmessage(L('illegal_operation'));
  495. //再次重新赋值,以数据库为准
  496. $catid = $CATEGORYS[$r['catid']]['catid'];
  497. $modelid = $CATEGORYS[$catid]['modelid'];
  498. require_once CACHE_MODEL_PATH.'content_output.class.php';
  499. $content_output = new content_output($modelid,$catid,$CATEGORYS);
  500. $data = $content_output->get($r);
  501. extract($data);
  502. }
  503. }
  504. //置顶推荐位数组
  505. $infos = getcache('info_setting','commons');
  506. $toptype_posid = array('1'=>$infos['top_city_posid'],
  507. '2'=>$infos['top_zone_posid'],
  508. '3'=>$infos['top_district_posid'],
  509. );
  510. foreach($toptype_posid as $_k => $_v) {
  511. if($pos_data->get_one(array('id'=>$id,'catid'=>$catid,'posid'=>$_v))) {
  512. $exist_posids[$_k] = 1;
  513. }
  514. }
  515. include template('member', 'info_top');
  516. }
  517. function info_top_cost() {
  518. $amount = $msg = '';
  519. $memberinfo = $this->memberinfo;
  520. $_username = $this->memberinfo['username'];
  521. $_userid = $this->memberinfo['userid'];
  522. $infos = getcache('info_setting','commons');
  523. $toptype_arr = array(1,2,3);
  524. //置顶积分数组
  525. $toptype_price = array('1'=>$infos['top_city'],
  526. '2'=>$infos['top_zone'],
  527. '3'=>$infos['top_district'],
  528. );
  529. //置顶推荐位数组
  530. $toptype_posid = array('1'=>$infos['top_city_posid'],
  531. '2'=>$infos['top_zone_posid'],
  532. '3'=>$infos['top_district_posid'],
  533. );
  534. if(isset($_POST['dosubmit'])) {
  535. $posids = array();
  536. $push_api = pc_base::load_app_class('push_api','admin');
  537. $pos_data = pc_base::load_model('position_data_model');
  538. $catid = intval($_POST['catid']);
  539. $id = intval($_POST['id']);
  540. $flag = $catid.'_'.$id;
  541. $toptime = intval($_POST['toptime']);
  542. if($toptime == 0 || empty($_POST['toptype'])) showmessage(L('info_top_not_setting_toptime'));
  543. //计算置顶扣费积分,时间
  544. if(is_array($_POST['toptype']) && !empty($_POST['toptype'])) {
  545. foreach($_POST['toptype'] as $r) {
  546. if(is_numeric($r) && in_array($r, $toptype_arr)) {
  547. $posids[] = $toptype_posid[$r];
  548. $amount += $toptype_price[$r];
  549. $msg .= $r.'-';
  550. }
  551. }
  552. }
  553. //应付总积分
  554. $amount = $amount * $toptime;
  555. //扣除置顶点数
  556. pc_base::load_app_class('spend','pay',0);
  557. $pay_status = spend::point($amount, L('info_top').$msg, $_userid, $_username, '', '', $flag);
  558. if($pay_status == false) {
  559. $msg = spend::get_msg();
  560. showmessage($msg);
  561. }
  562. //置顶过期时间
  563. //TODO
  564. $expiration = SYS_TIME + $toptime * 3600;
  565. //获取置顶文章信息内容
  566. if(isset($catid) && $catid) {
  567. $siteids = getcache('category_content', 'commons');
  568. $siteid = $siteids[$catid];
  569. $CATEGORYS = getcache('category_content_'.$siteid, 'commons');
  570. $category = $CATEGORYS[$catid];
  571. if($category['type']==0) {
  572. $modelid = $category['modelid'];
  573. $this->model = getcache('model', 'commons');
  574. $this->content_db = pc_base::load_model('content_model');
  575. $this->content_db->set_model($modelid);
  576. $this->content_db->table_name = $this->content_db->db_tablepre.$this->model[$modelid]['tablename'];
  577. $r = $this->content_db->get_one(array('id'=>$id,'username'=>$_username,'sysadd'=>0));
  578. }
  579. }
  580. if(!$r) showmessage(L('illegal_operation'));
  581. $push_api->position_update($id, $modelid, $catid, $posids, $r, $expiration, 1);
  582. $refer = $_POST['msg'] ? $r['url'] : '';
  583. if($_POST['msg']) showmessage(L('ding_success'),$refer);
  584. else showmessage(L('ding_success'), '', '', 'top');
  585. } else {
  586. $toptype = trim($_POST['toptype']);
  587. $toptime = trim($_POST['toptime']);
  588. $types = explode('_', $toptype);
  589. if(is_array($types) && !empty($types)) {
  590. foreach($types as $r) {
  591. if(is_numeric($r) && in_array($r, $toptype_arr)) {
  592. $amount += $toptype_price[$r];
  593. }
  594. }
  595. }
  596. $amount = $amount * $toptime;
  597. echo $amount;
  598. }
  599. }
  600. /**
  601. * 初始化phpsso
  602. * about phpsso, include client and client configure
  603. * @return string phpsso_api_url phpsso地址
  604. */
  605. private function _init_phpsso() {
  606. pc_base::load_app_class('client', '', 0);
  607. define('APPID', pc_base::load_config('system', 'phpsso_appid'));
  608. $phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url');
  609. $phpsso_auth_key = pc_base::load_config('system', 'phpsso_auth_key');
  610. $this->client = new client($phpsso_api_url, $phpsso_auth_key);
  611. return $phpsso_api_url;
  612. }
  613. /**
  614. * Function UPLOAD_VIDEO
  615. * 用户上传视频
  616. */
  617. public function upload_video() {
  618. $memberinfo = $this->memberinfo;
  619. $grouplist = getcache('grouplist');
  620. //判断会员组是否允许投稿
  621. if(!$grouplist[$memberinfo['groupid']]['allowpost']) {
  622. showmessage(L('member_group').L('publish_deny'), HTTP_REFERER);
  623. }
  624. //判断每日投稿数
  625. $this->content_check_db = pc_base::load_model('content_check_model');
  626. $todaytime = strtotime(date('y-m-d',SYS_TIME));
  627. $_username = $this->memberinfo['username'];
  628. $allowpostnum = $this->content_check_db->count("`inputtime` > $todaytime AND `username`='$_username'");
  629. if($grouplist[$memberinfo['groupid']]['allowpostnum'] > 0 && $allowpostnum >= $grouplist[$memberinfo['groupid']]['allowpostnum']) {
  630. showmessage(L('allowpostnum_deny').$grouplist[$memberinfo['groupid']]['allowpostnum'], HTTP_REFERER);
  631. }
  632. //加载视频库配置信息
  633. pc_base::load_app_class('ku6api', 'video', 0);
  634. $setting = getcache('video', 'video');
  635. if(empty($setting)) {
  636. showmessage('上传功能还在开发中,请稍后重试!');
  637. }
  638. $ku6api = new ku6api($setting['sn'], $setting['skey']);
  639. if (isset($_POST['dosubmit'])) {
  640. $_POST['info']['catid'] = isset($_POST['info']['catid']) ? intval($_POST['info']['catid']) : showmessage('请选择栏目!');
  641. $_POST['info']['title'] = isset($_POST['info']['title']) ? safe_replace($_POST['info']['title']) : showmessage('标题不能为空!');
  642. $_POST['info']['keywords'] = isset($_POST['info']['keywords']) ? safe_replace($_POST['info']['keywords']) : '';
  643. $_POST['info']['description'] = isset($_POST['info']['description']) ? safe_replace($_POST['info']['description']) : '';
  644. //查询此模型下的视频字段
  645. $field = get_video_field($_POST['info']['catid']);
  646. if (!$field) showmessage('上传功能还在开发中,请稍后重试!');
  647. $_POST['info'][$field] = 1;
  648. $_POST[$field.'_video'] = array(1=>array('title'=>$_POST['info']['title'], 'vid' => $_POST['vid'], 'listorder'=>1));
  649. unset($_POST['vid']);
  650. $this->publish();
  651. } else {
  652. $categorys = video_categorys();
  653. if (is_array($categorys) && !empty($categorys)) {
  654. $cat = array();
  655. $priv_db = pc_base::load_model('category_priv_model'); //加载栏目权限表数据模型
  656. foreach ($categorys as $cid=>$c) {
  657. if($c['child']==0 && $c['type']==0 && !$priv_db->get_one(array('catid'=>$cid, 'roleid'=>$memberinfo['groupid'], 'is_admin'=>0, 'action'=>'add'))) unset($categorys[$cid]);
  658. }
  659. if (empty($categorys)) showmessage(L('category').L('publish_deny'), APP_PATH.'index.php?m=member');
  660. foreach ($categorys as $cid => $c) {
  661. if ($c['child']) {
  662. $ischild = 1;
  663. $categorys[$cid]['disabled'] = 'disabled';
  664. }
  665. $cat[$cid] = $c['catname'];
  666. }
  667. if (!$ischild) {
  668. $cat_list = form::radio($cat, '', 'name="info[catid]"', '90');
  669. } else {
  670. $tree = pc_base::load_sys_class('tree');
  671. $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>";
  672. $tree->init($categorys);
  673. $string = $tree->get_tree(0, $str);
  674. $cat_list = '<select name="info[catid]" id="catid"><option value="0">请选择栏目</option>'.$string.'</select>';
  675. }
  676. }
  677. $flash_info = $ku6api->flashuploadparam(); //加载视频上传工具信息
  678. include template('member', 'upload_video');
  679. }
  680. }
  681. }
  682. ?>