project.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  1. <?php
  2. # 定义几个常用的选项
  3. $local = array
  4. (
  5. 1 => '关闭',
  6. 2 => '开启',
  7. );
  8. $status = array
  9. (
  10. 1 => '待机',
  11. 2 => '运行中',
  12. 3 => '抓取中',
  13. 4 => '已完成',
  14. );
  15. $cate = function()
  16. {
  17. $array = array();
  18. $cate = Dever::load('spider/cate-main');
  19. if ($cate) {
  20. $array += $cate;
  21. }
  22. return $array;
  23. };
  24. $cate_child = function()
  25. {
  26. $cate = Dever::load('spider/cate-child');
  27. return $cate;
  28. };
  29. $search_cate = function()
  30. {
  31. $array = array
  32. (
  33. -1 => array('id' => '-1', 'name' => '所有分类'),
  34. );
  35. $cate = Dever::load('forum/cate.all');
  36. if ($cate) {
  37. $array += $cate;
  38. }
  39. return $array;
  40. };
  41. return array
  42. (
  43. # 表名
  44. 'name' => 'project',
  45. # 显示给用户看的名称
  46. 'lang' => '项目管理',
  47. # 后台菜单排序
  48. 'order' => 20,
  49. //'desc' => 'API:http://192.168.15.10/plant/spider/??project_id=1',
  50. # 数据结构
  51. 'struct' => array
  52. (
  53. 'id' => array
  54. (
  55. 'type' => 'int-11',
  56. 'name' => '项目ID',
  57. 'default' => '',
  58. 'desc' => '',
  59. 'match' => 'is_numeric',
  60. 'search' => 'order',
  61. 'list' => true,
  62. 'order' => 'desc',
  63. ),
  64. 'name' => array
  65. (
  66. 'type' => 'varchar-100',
  67. 'name' => '项目名称',
  68. 'default' => '',
  69. 'desc' => '请输入项目名称',
  70. 'match' => 'is_string',
  71. 'update' => 'text',
  72. 'search' => 'order,fulltext',
  73. 'list' => true,
  74. 'edit' => true,
  75. ),
  76. 'cate_id_parent' => array
  77. (
  78. 'type' => 'int-11',
  79. 'name' => '选择分类',
  80. 'default' => '0',
  81. 'desc' => '请选择分类',
  82. 'match' => 'is_numeric',
  83. 'update' => 'select',
  84. //'search' => 'order,select',
  85. 'list_name' => '父级分类',
  86. 'option' => $cate,
  87. # 当值改变时,执行下一步操作
  88. 'child_name' => 'cate_id',
  89. 'child' => $cate_child,
  90. 'child_value' => '{cate_id}',
  91. ),
  92. 'cate_id' => array
  93. (
  94. 'type' => 'int-11',
  95. 'name' => '子分类',
  96. 'default' => '0',
  97. 'desc' => '请选择子分类',
  98. 'match' => 'is_numeric',
  99. 'search' => 'group',
  100. 'option' => $search_cate,
  101. 'list_name' => '分类',
  102. 'list' => '{cate_id} > 0 ? Dever::load("spider/cate-one#name", {cate_id}) : "无"',
  103. ),
  104. 'site' => array
  105. (
  106. 'type' => 'text-255',
  107. 'name' => '采集网址-多个网址换行隔开',
  108. 'default' => '',
  109. 'desc' => '采集网址',
  110. 'match' => 'option',
  111. 'update' => 'textarea',
  112. //'list' => true,
  113. //'edit' => 'textarea',
  114. ),
  115. 'collect_rule' => array
  116. (
  117. 'type' => 'varchar-500',
  118. 'name' => '采集规则-支持dom解析、正则、json格式',
  119. 'default' => '',
  120. 'desc' => '采集规则',
  121. 'match' => 'is_string',
  122. 'update' => 'textarea',
  123. 'edit' => true,
  124. 'list' => true,
  125. ),
  126. 'page_rule' => array
  127. (
  128. 'type' => 'varchar-300',
  129. 'name' => '采集页数规则-填写采集的页数的正则表达式',
  130. 'default' => '',
  131. 'desc' => '采集页数规则',
  132. 'match' => 'option',
  133. 'update' => 'textarea',
  134. ),
  135. 'page_num' => array
  136. (
  137. 'type' => 'int-11',
  138. 'name' => '采集页数',
  139. 'default' => '10',
  140. 'desc' => '采集页数',
  141. 'match' => 'option',
  142. 'update' => 'text',
  143. ),
  144. 'status' => array
  145. (
  146. 'type' => 'tinyint-1',
  147. 'name' => '状态',
  148. 'default' => '1',
  149. 'desc' => '状态',
  150. 'match' => 'is_numeric',
  151. 'option' => $status,
  152. 'list' => true,
  153. //'update' => 'radio',
  154. ),
  155. 'num' => array
  156. (
  157. 'type' => 'int-11',
  158. 'name' => '抓取次数',
  159. 'default' => '0',
  160. 'desc' => '抓取次数',
  161. 'match' => 'is_numeric',
  162. 'list' => true,
  163. ),
  164. 'sdate' => array
  165. (
  166. 'type' => 'int-11',
  167. 'name' => '抓取开始时间',
  168. 'default' => '0',
  169. 'desc' => '抓取开始时间',
  170. 'match' => 'is_numeric',
  171. 'update' => 'date',
  172. 'list' => 'date("Y-m-d H:i:s", {sdate})',
  173. 'callback' => 'maketime',
  174. ),
  175. 'interval' => array
  176. (
  177. 'type' => 'int-11',
  178. 'name' => '抓取间隔秒数-填写开始时间之后的间隔抓取的秒数,为0则只抓取一次',
  179. 'default' => '0',
  180. 'desc' => '抓取间隔秒数',
  181. 'match' => 'is_numeric',
  182. 'update' => 'text',
  183. ),
  184. 'reorder' => array
  185. (
  186. 'type' => 'int-11',
  187. 'name' => '排序(数值越大越靠前)',
  188. 'default' => '1',
  189. 'desc' => '请输入排序',
  190. 'match' => 'option',
  191. //'update' => 'text',
  192. 'search' => 'order',
  193. 'list' => true,
  194. 'edit' => true,
  195. 'order' => 'desc',
  196. ),
  197. 'state' => array
  198. (
  199. 'type' => 'tinyint-1',
  200. 'name' => '状态',
  201. 'default' => '1',
  202. 'desc' => '请选择状态',
  203. 'match' => 'is_numeric',
  204. ),
  205. 'cdate' => array
  206. (
  207. 'type' => 'int-11',
  208. 'name' => '更新时间',
  209. 'match' => array('is_numeric', time()),
  210. 'desc' => '',
  211. # 只有insert时才生效
  212. //'insert' => true,
  213. //'list' => 'date("Y-m-d H:i:s", {cdate})',
  214. ),
  215. ),
  216. 'manage' => array
  217. (
  218. # 更新数据时,要显示的按钮,这里填写js脚本事件即可。保存当前数据可为固定参数:"save-data",复制数据为:copy-data
  219. 'update_button' => array
  220. (
  221. '提交保存' => 'save-data',
  222. '放弃保存' => "msg({status:1,msg:'yes'})",
  223. '复制数据' => 'copy-data',
  224. ),
  225. # 不允许编辑
  226. //'edit' => false,
  227. # 列表页的类型
  228. //'list_type' => 'parent',
  229. # 可以删除
  230. 'list_button' => array
  231. (
  232. 'list_col' => array('字段设置', '"col&search_option_project_id={id}&oper_parent=project"'),
  233. //'list_data' => array('数据列表', '"data&search_option_project_id={id}&oper_save_jump=project&oper_parent=project"'),
  234. //'delete' => array('采集数据', 'Dever::url("spider/data.daemon?id={id}&")'),
  235. ),
  236. //'desc' => '注意:命令码',
  237. ),
  238. # request 请求接口定义
  239. 'request' => array
  240. (
  241. # 获取所有待机并且符合当前时间的配置
  242. 'get' => array
  243. (
  244. 'option' => array
  245. (
  246. 'id' => 'yes',
  247. 'status' => array('yes', '<='),
  248. 'sdate' => array('yes-sdate`+`time', '<='),
  249. 'state' => 1,
  250. ),
  251. 'type' => 'all',
  252. 'order' => array('reorder' => 'desc', 'id' => 'desc'),
  253. 'col' => '*',
  254. ),
  255. # 获取所有运行中的数据
  256. 'getOne' => array
  257. (
  258. 'option' => array
  259. (
  260. 'id' => 'yes',
  261. 'status' => array('yes'),
  262. 'sdate' => array('yes-sdate`+`time', '<='),
  263. 'state' => 1,
  264. ),
  265. 'type' => 'one',
  266. ),
  267. )
  268. );