Guest User

Untitled

a guest
Jul 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.16 KB | None | 0 0
  1. <?PHP
  2.  
  3. defined('SED_CODE') or die('Wrong URL');
  4.  
  5. $id = sed_import('id','G','INT');
  6. $r = sed_import('r','G','ALP');
  7.  
  8. list($usr['auth_read'], $usr['auth_write'], $usr['isadmin']) = sed_auth('plug', 'projects', 'RWA');
  9. sed_block($usr['auth_write']);
  10.  
  11. if(!$usr['isadmin'])
  12. {
  13. // Запрет публикации проектов для обычных фрилансеров
  14. if (!sed_ispro($usr['profile']['user_protodate'], $usr['id']) && $usr['profile']['user_maingrp'] == 4)
  15. {
  16. header("Location: " . SED_ABSOLUTE_URL . sed_url('message', "msg=1001", '', true));
  17. exit;
  18. }
  19. // Запрет публикации проектов для обычных работодателей
  20. if (!sed_ispro($usr['profile']['user_protodate'], $usr['id']) && $usr['profile']['user_maingrp'] == 8 && $cfg['prjlimitforemployers'] > 0)
  21. {
  22. // Проверяем количество оставшихся ответов на проекты
  23. $countprjofuser = sed_getcountprjofuser($usr['id']);
  24. if($countprjofuser >= $cfg['prjlimitforemployers']){
  25. header("Location: " . SED_ABSOLUTE_URL . sed_url('message', "msg=1002", '', true));
  26. exit;
  27. }
  28. }
  29. }
  30.  
  31. /* === Hook === */
  32. $extp = sed_getextplugins('projects.add.first');
  33. if (is_array($extp))
  34. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  35. /* ===== */
  36.  
  37. if ($a=='add')
  38. {
  39. sed_shield_protect();
  40.  
  41. /* === Hook === */
  42. $extp = sed_getextplugins('projects.add.add.first');
  43. if (is_array($extp))
  44. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  45. /* ===== */
  46.  
  47. $cat = sed_import('cat','P','INT');
  48. $type = sed_import('type','P','INT');
  49. $title = sed_import('title','P','TXT');
  50. $text = sed_import('text','P','TXT');
  51. $cost = sed_import('cost','P','TXT');
  52. $country = sed_import('country','P','INT');
  53. $region = sed_import('region','P','INT');
  54. $city = sed_import('city','P','INT');
  55.  
  56. $error_string .= (empty($cat)) ? "Не выбран раздел<br />" : '';
  57. // $error_string .= (empty($region)) ? "Не выбран регион<br />" : '';
  58. $error_string .= (empty($title)) ? "Заголовок не может быть пустым<br />" : '';
  59. $error_string .= (empty($text)) ? "Объявление не может быть пустым<br />" : '';
  60.  
  61. if (empty($error_string))
  62. {
  63.  
  64. // if ($usr['isadmin'] && $cfg['autovalidate'])
  65. // {
  66. // $rpublish = sed_import('rpublish', 'P', 'ALP');
  67. // if ($rpublish == 'OK' )
  68. // {
  69. // $item_state = 0;
  70. // }
  71. // else
  72. // {
  73. // $item_state = 1;
  74. // }
  75. // }
  76. // else
  77. // {
  78. // $item_state = 1;
  79. // }
  80.  
  81. $item_state = 1;
  82.  
  83. /* === Hook === */
  84. $extp = sed_getextplugins('projects.add.add.query');
  85. if (is_array($extp))
  86. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  87. /* ===== */
  88.  
  89. $ssql = "INSERT into sed_projects
  90. (item_userid,
  91. item_date,
  92. item_cat,
  93. item_type,
  94. item_title,
  95. item_text,
  96. item_cost,
  97. item_country,
  98. item_region,
  99. item_city,
  100. item_state)
  101. VALUES
  102. (".(int)$usr['id'].",
  103. ".(int)$sys['now_offset'].",
  104. ".(int)$cat.",
  105. ".(int)$type.",
  106. '".sed_sql_prep($title)."',
  107. '".sed_sql_prep($text)."',
  108. '".sed_sql_prep($cost)."',
  109. ".(int)$country.",
  110. ".(int)$region.",
  111. ".(int)$city.",
  112. ".(int)$item_state.")";
  113. $sql = sed_sql_query($ssql);
  114.  
  115. $id = sed_sql_insertid();
  116.  
  117. $sed_pcat = sed_load_pcat();
  118. sed_cache_store('sed_pcat', $sed_pcat, 3600);
  119.  
  120. for($i = 0; $i < 10; $i++){
  121. if($_FILES["file"]['size'][$i] > 0 && $_FILES["file"]['error'][$i] == 0){
  122.  
  123. $u_tmp_name_file = $_FILES['file']['tmp_name'][$i];
  124. $u_type_file = $_FILES['file']['type'][$i];
  125. $u_name_file = $_FILES['file']['name'][$i];
  126. $u_size_file = $_FILES['file']['size'][$i];
  127.  
  128. if(!empty($u_tmp_name_file)){
  129. $u_name_file = str_replace("\'",'',$u_name_file );
  130. $u_name_file = trim(str_replace("\"",'',$u_name_file ));
  131. $dotpos = strrpos($u_name_file,".")+1;
  132. $f_extension = substr($u_name_file, $dotpos, 5);
  133. $u_newname_file = md5(uniqid(rand(),true)).".".$f_extension;
  134. $file = "datas/attachs/".$u_newname_file;
  135.  
  136. move_uploaded_file($u_tmp_name_file, $file);
  137. @chmod($file, 0766);
  138.  
  139. $sql = sed_sql_query("INSERT INTO sed_attachs (
  140. att_pid,
  141. att_file
  142. ) VALUES(
  143. ".(int)$id.",
  144. '".sed_sql_prep($file)."'
  145. )");
  146. }
  147. }
  148. }
  149.  
  150. $r_url = sed_url('plug', "e=projects&m=step2&itemid=".$id, '', true);
  151.  
  152. /* === Hook === */
  153. $extp = sed_getextplugins('projects.add.add.done');
  154. if (is_array($extp))
  155. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  156. /* ===== */
  157.  
  158. header("Location: " . SED_ABSOLUTE_URL . $r_url);
  159. exit;
  160. }
  161. }
  162.  
  163. $mskin = sed_skinfile('projects.add', true);
  164. $t = new XTemplate($mskin);
  165.  
  166. /* === Hook === */
  167. $extp = sed_getextplugins('projects.add.main');
  168. if (is_array($extp))
  169. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  170. /* ===== */
  171.  
  172. if (!empty($error_string))
  173. {
  174. $t->assign("PRJADD_ERROR_BODY",$error_string);
  175. $t->parse("MAIN.PRJADD_ERROR");
  176. }
  177.  
  178. list($select_country, $select_region, $select_city) = sed_select_location('', $country, $region, $city);
  179.  
  180. $t->assign(array(
  181. "PRJADD_FORM_SEND" => sed_url('plug', "e=projects&m=add&a=add"),
  182. "PRJADD_FORM_OWNERID" => $usr['id'],
  183. "PRJADD_FORM_CAT" => sed_selectbox_pcat('cat', $cat),
  184. "PRJADD_FORM_TYPE" => sed_selectbox_ptype('type', $type),
  185. "PRJADD_FORM_COUNTRY" => $select_country,
  186. "PRJADD_FORM_REGION" => $select_region,
  187. "PRJADD_FORM_CITY" => $select_city,
  188. "PRJADD_FORM_TITLE" => $title,
  189. "PRJADD_FORM_TEXT" => $text,
  190. "PRJADD_FORM_COST" => $cost,
  191. ));
  192.  
  193. /* === Hook === */
  194. $extp = sed_getextplugins('projects.add.tags');
  195. if (is_array($extp))
  196. { foreach($extp as $k => $pl) { include_once($cfg['plugins_dir'].'/'.$pl['pl_code'].'/'.$pl['pl_file'].'.php'); } }
  197. /* ===== */
  198.  
  199. if ($usr['isadmin'])
  200. {
  201. if ($cfg['autovalidate']) $usr_can_publish = TRUE;
  202. $t->parse('MAIN.ADMIN');
  203. }
  204.  
  205. ?>
Add Comment
Please, Sign In to add comment