Advertisement
SecretWorker

Untitled

Feb 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.77 KB | None | 0 0
  1. <?php
  2. echo '<head><meta charset="UTF-8"/></head>';
  3. $style="
  4. *{
  5. direction:rtl;
  6. font-family:'arimo';
  7. }
  8. body{
  9. background-image:url('https://media.giphy.com/media/czyRCsoai6tZm/giphy.gif');
  10. }
  11. table{
  12. background-color: rgb(52, 152, 219);
  13. border-radius: 100px;
  14. padding:10px;
  15. color:white;
  16. }
  17. input{
  18. border:0;
  19. }
  20. #motek{
  21. background-color:#e74c3c;
  22. border-radius:100px;
  23. width:90%;
  24. padding-bottom:10px;
  25.  
  26. }
  27. #num{
  28. background-coloR: #ecf0f1;
  29. width: 400px;
  30. padding: 10px;
  31. border-radius: 100px;
  32. margin:0; }
  33. table{
  34. text-align:center;
  35. }
  36. td {
  37. padding: 20px;
  38. }
  39. .myButton {
  40. background-color:#44c767;
  41. -moz-border-radius:42px;
  42. border:0;
  43. width:90%;
  44. -webkit-border-radius:42px;
  45. border-radius:42px;
  46. display:inline-block;
  47. cursor:pointer;
  48. color:#ffffff;
  49. font-size:28px;
  50. padding:27px 48px;
  51. text-decoration:none;
  52. text-shadow:-2px 1px 23px #2f6627;
  53. margin-bottom:10px;
  54. }
  55. .myButton:hover {
  56. background-color:#5cbf2a;
  57. }
  58. .myButton:active {
  59. position:relative;
  60. top:1px;
  61. }
  62. .error{
  63. background-image: url('https://media.giphy.com/media/VS95jHa4UCOe4/giphy.gif');
  64. color: red;
  65. font-size: 100px;
  66. height: 170px;
  67. text-align: center;
  68. margin: auto;
  69. }
  70. ";
  71. echo '<head>
  72. <link href="https://fonts.googleapis.com/css?family=Arimo&subset=hebrew,latin" rel="stylesheet" type="text/css">
  73. <title>POSTING</title>
  74. <style>'.$style.'</style>
  75.  
  76. </head>';
  77. $a = dirname(__FILE__);;
  78. echo $a.'<br>';
  79. include_once($a . "/wp-load.php");
  80. include_once($a .'/wp-admin/includes/media.php');
  81. include_once($a .'/wp-admin/includes/file.php');
  82. include_once($a .'/wp-admin/includes/image.php');
  83. include_once($a .'/wp-admin/includes/taxonomy.php');
  84. query_posts('showposts=1');
  85. define('WP_USE_THEMES', false);
  86. include_once( $a .'/wp-blog-header.php');
  87. function motek($name){
  88. $s = str_replace(" ", "-",$name);
  89. return $s;
  90. }
  91. function contain($str,$find='<video>'){
  92. if (strpos($str,$find) !== false){ return true;}
  93. return false;
  94.  
  95. }
  96. function removeVideo($str){
  97. $pos = strpos($str,"<video>");
  98. $sub1 = substr($str,0,$pos);
  99. $pos1 = strpos($str,"</video>") + strlen("</video>");
  100. $sub2 = substr($str,$pos1);
  101. $sub1 = $sub1 . $sub2;
  102. while(contain($sub1)){
  103. $str = $sub1;
  104. $pos = strpos($str,"<video>");
  105. $sub1 = substr($str,0,$pos);
  106. $pos1 = strpos($str,"</video>") + strlen("</video>");
  107. $sub2 = substr($str,$pos1);
  108. $sub1 = $sub1 . $sub2;
  109. }
  110. return $sub1;
  111.  
  112.  
  113.  
  114. }
  115. function isEmpty($a,$b){
  116. if ($a == "" || $b == ""){ return true; }
  117. return false;
  118. }
  119. function ftr_image_now( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
  120. if ( !$url || !$post_id ) return new WP_Error('missing', "Need a valid URL and post ID...");
  121. include_once($a . '/wp-admin/includes/file.php' );
  122. $tmp = download_url( $url );
  123.  
  124. // If error storing temporarily, unlink
  125. if ( is_wp_error( $tmp ) ) {
  126. @unlink($file_array['tmp_name']); // clean up
  127. $file_array['tmp_name'] = '';
  128. return $tmp; // output wp_error
  129. }
  130.  
  131. preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); // תיקון שם קובץ
  132. $url_filename = basename($matches[0]); // חילוץ שם קובץ
  133. $url_type = wp_check_filetype($url_filename); // זיהוי סוג
  134.  
  135. if ( !empty( $filename ) ) {
  136. $filename = sanitize_file_name($filename);
  137. $tmppath = pathinfo( $tmp ); // חילוץ
  138. $new = $tmppath['dirname'] . "/". $filename . "." . $tmppath['extension']; // בניית מיקום חדש
  139. rename($tmp, $new); // שינוי שם בהתאם לשרת
  140. $tmp = $new; // הכנה למערך
  141. }
  142.  
  143. $file_array['tmp_name'] = $tmp; // כתובת שרת מלאה
  144.  
  145. if ( !empty( $filename ) ) {
  146. $file_array['name'] = $filename . "." . $url_type['ext']; // שינוי כתובת בהתאם לצורך
  147. } else {
  148. $file_array['name'] = $url_filename; // שימוש בכתובת מקורית
  149. }
  150.  
  151. // set additional wp_posts columns
  152. if ( empty( $post_data['post_title'] ) ) {
  153. $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // שימוש בכתובת המקורית ללא סיומת
  154. }
  155.  
  156. // make sure gets tied to parent
  157. if ( empty( $post_data['post_parent'] ) ) {
  158. $post_data['post_parent'] = $post_id;
  159. }
  160.  
  161. include_once($a . '/wp-admin/includes/file.php');
  162. include_once($a . '/wp-admin/includes/media.php');
  163. include_once($a . '/wp-admin/includes/image.php');
  164.  
  165. $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // פרטי פוסט (לא חובה)
  166.  
  167.  
  168. if ( is_wp_error($att_id) ) {
  169. @unlink($file_array['tmp_name']); // clean up
  170. return $att_id; // output wp_error
  171. }
  172.  
  173. // set as post thumbnail if desired
  174. if ($thumb) {
  175. set_post_thumbnail($post_id, $att_id);
  176. }
  177.  
  178. return $att_id;
  179. }
  180.  
  181.  
  182.  
  183.  
  184. if(isset($_POST['go'])){
  185.  
  186. $prog = $_POST['prog'];
  187. if (!post_exists($prog)){
  188. echo 'PROG:'.$prog.'<br>';
  189. $img = $_POST['img'];
  190. echo 'IMG:'.$img.'<br>';
  191. if (isEmpty($prog,$img)){
  192. echo '<h1 class="error">מה אתה טמבל? תמלא הכל נו</h1>';
  193. }
  194. else{
  195. $cat = $_POST['category'];
  196. $cats = explode(',',$cat);
  197. $catIDS = array();
  198. $j = 0;
  199. echo var_dump($cats);
  200. foreach($cats as $m){
  201. $term = get_cat_ID($m);
  202. if ($term != 0) {
  203. $catIDS[$j] = $term;
  204. }
  205. else{
  206. $catIDS[$j] = wp_create_category($m);
  207. }
  208. $j++;
  209. }
  210. echo 'CATID:'.var_dump($catIDS).'<br>';
  211.  
  212. $name = $prog;
  213. $content = $_POST['article'];
  214. $my_post = array(
  215. 'post_title' => $name,
  216. 'post_content' => htmlspecialchars_decode(removeVideo($content)),
  217. 'post_status' => 'publish',
  218. 'post_author' => 1,
  219. 'post_category' => $catIDS
  220. );
  221. echo 'POST:'.var_dump($my_post).'<br>';
  222. $id=wp_insert_post( $my_post ); // העלאת הפוסט
  223. if($id){
  224. echo '<h1>עבד</h1>';
  225. }
  226. else{
  227. echo '<h1>לא עבד</h1>';
  228. }
  229. $tags = $_POST['tags'];
  230. echo 'TAGS:'.$tags;
  231. wp_set_post_tags( $id, $tags);
  232. /* $engName = $_POST['engname'];
  233. $heName = $_POST['hename'];
  234. $rating = $_POST['rating'];
  235. $date = $_POST['date'];
  236. $viewlinks = $_POST['viewlinks'];
  237. $tr = $_POST['trailer'];
  238. $dsc = $_POST['descp'];
  239. $dscim = $_POST['descpimdb'];
  240. $img1 = $_POST['img1'];
  241. $url1 = $_POST['url1'];
  242. add_post_meta($id, 'viewlinks', $viewlinks);
  243. add_post_meta($id, '_viewlinks', 'field_56c736033ca2c');
  244. add_post_meta($id, 'url', $url1);
  245. add_post_meta($id, '_url', 'field_56c736283ca2e');
  246. add_post_meta($id, 'img', $img1);
  247. add_post_meta($id, '_img', 'field_56c736083ca2d');
  248. add_post_meta($id, 'descpimdb', $dscim);
  249. add_post_meta($id, '_descpimdb', 'field_56c735f21b1dc');
  250. add_post_meta($id, 'descp', $dsc);
  251. add_post_meta($id, '_descp', 'field_56c735de1b1db');
  252. add_post_meta($id, 'tariler', $tr);
  253. add_post_meta($id, '_tariler', 'field_56c735d41b1da');
  254. add_post_meta($id, 'date', $date);
  255. add_post_meta($id, '_date', 'field_56c7357395b9f');
  256. add_post_meta($id, 'engname', $engName);
  257. add_post_meta($id, '_engname', 'field_56c7350bd5e60');
  258. add_post_meta($id,'rating', $rating);
  259. add_post_meta($id, '_rating', 'field_56c7357a95ba0');
  260. add_post_meta($id,'hebName', $heName);
  261. add_post_meta($id, '_hebName', 'field_56c7356995b9e'); */
  262.  
  263. /*update_post_meta($id, '_aioseop_title', $name);
  264. update_post_meta($id, '_aioseop_description', $des);
  265. update_post_meta($id, '_aioseop_keywords', $tags); */
  266. $motek = ftr_image_now($img,$id, true); // צירוף תמונה
  267. }
  268. }
  269. }
  270.  
  271. ?>
  272. <form method="post">
  273. <table style="text-align:center;width:600px; margin:auto;">
  274. <tr>
  275. <td>שם סדרה</td><td><input type="text" placeholder="אני מלך עונה 3" name="prog" id="1"/></td>
  276. </tr>
  277. <tr>
  278. <td>תוכן</td><td><textarea name="article" id="2"></textarea></td>
  279. </tr>
  280. <tr>
  281. <td>תגיות (אנא להפריד בפסיקים, או שסנאי יבוא וינשך לך את האף)</td><td><input type="text" name="tags" id="3"/></td>
  282. </tr>
  283. <tr>
  284. <td>קטגוריה</td><td><input type="text" name="category" id="4"/></td>
  285. </tr>
  286.  
  287. <tr>
  288. <td>שם בעברית</td><td><input type="text" name="hename" id="5"/></td>
  289. </tr><tr>
  290. <td>שם באנגלית</td><td><input type="text" name="engname" id="6"/></td>
  291. </tr>
  292. <tr>
  293. <td>תאריך</td><td><input type="text" name="date" id="7"/></td>
  294. </tr>
  295. <tr>
  296. <td>דירוג</td><td><input type="text" name="rating" id="8"/></td>
  297. </tr>
  298. <tr>
  299. <td>טריילר</td><td><input type="text" name="trailer" id="9"/></td>
  300. </tr>
  301. <tr>
  302. <td>viewlinks</td><td><input type="text" name="viewlinks" id="10"/></td>
  303. </tr>
  304. <tr>
  305. <td>תמונה</td><td><input type="text" name="img1" id="11"/></td>
  306. </tr>
  307. <tr>
  308. <td>קישור</td><td><input type="text" name="url1" id="12"/></td>
  309. </tr>
  310. <tr>
  311. <td>descpimdb</td><td><textarea name="descpimdb" id="13"></textarea></td>
  312. </tr>
  313. <tr>
  314. <td>descp</td><td><textarea name="descp" id="14"></textarea></td>
  315. </tr>
  316. <tr>
  317. <td>קישור לתמונה ראשית</td><td><input type="text" placeholder="IMG URL?" name="img" id="15"/></td>
  318. </tr>
  319.  
  320. </table>
  321. <br>
  322. <center><input type="submit" class="myButton" name="go" value="תן בראש כאילו אין מחר!" id="16"/></center>
  323. </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement