Advertisement
Motekoni

POSTING V1.11

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