Advertisement
SecretWorker

Moti V1.0

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