Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $servername = "localhost";
- $username = "doidjbpy_wp943";
- $password = "3S8P4D9A][";
- $dbname = "doidjbpy_wp943";
- // Create connection
- $conn = new mysqli($servername, $username, $password, $dbname);
- $conn->query("SET NAMES 'utf8'");
- $conn->query("set character_set_client='utf8'");
- $conn->query("set character_set_results='utf8'");
- $conn->query("set collation_connection='utf8'");
- echo '<head><meta charset="UTF-8"/></head>';
- $style="
- *{
- direction:rtl;
- font-family:'arimo';
- }
- body{
- background:aqua;
- }
- table{
- background-color: rgb(52, 152, 219);
- border-radius: 100px;
- padding:10px;
- color:white;
- }
- input{
- border:0;
- }
- #motek{
- background-color:#e74c3c;
- border-radius:100px;
- width:90%;
- padding-bottom:10px;
- }
- #num{
- background-coloR: #ecf0f1;
- width: 400px;
- padding: 10px;
- border-radius: 100px;
- margin:0; }
- table{
- text-align:center;
- }
- td {
- padding: 20px;
- }
- .myButton {
- background-color:#44c767;
- -moz-border-radius:42px;
- border:0;
- width:90%;
- -webkit-border-radius:42px;
- border-radius:42px;
- display:inline-block;
- cursor:pointer;
- color:#ffffff;
- font-size:28px;
- padding:27px 48px;
- text-decoration:none;
- text-shadow:-2px 1px 23px #2f6627;
- margin-bottom:10px;
- }
- .myButton:hover {
- background-color:#5cbf2a;
- }
- .myButton:active {
- position:relative;
- top:1px;
- }
- .error{
- background-image: url('https://media.giphy.com/media/VS95jHa4UCOe4/giphy.gif');
- color: red;
- font-size: 100px;
- height: 170px;
- text-align: center;
- margin: auto;
- }
- ";
- echo '<head>
- <link href="https://fonts.googleapis.com/css?family=Arimo&subset=hebrew,latin" rel="stylesheet" type="text/css">
- <title>POSTING</title>
- <style>'.$style.'</style>
- </head>';
- $a = dirname(__FILE__);;
- echo $a.'<br>';
- include_once($a . "/wp-load.php");
- include_once($a .'/wp-admin/includes/media.php');
- include_once($a .'/wp-admin/includes/file.php');
- include_once($a .'/wp-admin/includes/image.php');
- query_posts('showposts=1');
- define('WP_USE_THEMES', false);
- include_once( $a .'/wp-blog-header.php');
- function motek($name){
- $s = str_replace(" ", "-",$name);
- return $s;
- }
- function contain($str,$find='<video'){
- if (strpos($str,$find) !== false){ return true;}
- return false;
- }
- function post_exists($title) {
- global $conn;
- $title = htmlspecialchars($title);
- $sql = $conn->query("SELECT * FROM laq_posts WHERE post_title='".$title."'");
- $num = $sql->num_rows;
- if ($num > 0){
- return true;
- }
- return false;
- }
- function removeVideo($str){
- $pos = strpos($str,"<video");
- $sub1 = substr($str,0,$pos);
- $pos1 = strpos($str,"</video>") + strlen("</video>");
- $sub2 = substr($str,$pos1);
- $sub1 = $sub1 . $sub2;
- while(contain($sub1)){
- $str = $sub1;
- $pos = strpos($str,"<video");
- $sub1 = substr($str,0,$pos);
- $pos1 = strpos($str,"</video>") + strlen("</video>");
- $sub2 = substr($str,$pos1);
- $sub1 = $sub1 . $sub2;
- }
- return $sub1;
- }
- function isEmpty($a,$b){
- if ($a == "" || $b == ""){ return true; }
- return false;
- }
- function ftr_image_now( $url = null, $post_id = null, $thumb = null, $filename = null, $post_data = array() ) {
- if ( !$url || !$post_id ) return new WP_Error('missing', "Need a valid URL and post ID...");
- include_once($a . '/wp-admin/includes/file.php' );
- $tmp = download_url( $url );
- // If error storing temporarily, unlink
- if ( is_wp_error( $tmp ) ) {
- @unlink($file_array['tmp_name']); // clean up
- $file_array['tmp_name'] = '';
- return $tmp; // output wp_error
- }
- preg_match('/[^\?]+\.(jpg|JPG|jpe|JPE|jpeg|JPEG|gif|GIF|png|PNG)/', $url, $matches); // תיקון שם קובץ
- $url_filename = basename($matches[0]); // חילוץ שם קובץ
- $url_type = wp_check_filetype($url_filename); // זיהוי סוג
- if ( !empty( $filename ) ) {
- $filename = sanitize_file_name($filename);
- $tmppath = pathinfo( $tmp ); // חילוץ
- $new = $tmppath['dirname'] . "/". $filename . "." . $tmppath['extension']; // בניית מיקום חדש
- rename($tmp, $new); // שינוי שם בהתאם לשרת
- $tmp = $new; // הכנה למערך
- }
- $file_array['tmp_name'] = $tmp; // כתובת שרת מלאה
- if ( !empty( $filename ) ) {
- $file_array['name'] = $filename . "." . $url_type['ext']; // שינוי כתובת בהתאם לצורך
- } else {
- $file_array['name'] = $url_filename; // שימוש בכתובת מקורית
- }
- // set additional wp_posts columns
- if ( empty( $post_data['post_title'] ) ) {
- $post_data['post_title'] = basename($url_filename, "." . $url_type['ext']); // שימוש בכתובת המקורית ללא סיומת
- }
- // make sure gets tied to parent
- if ( empty( $post_data['post_parent'] ) ) {
- $post_data['post_parent'] = $post_id;
- }
- include_once($a . '/wp-admin/includes/file.php');
- include_once($a . '/wp-admin/includes/media.php');
- include_once($a . '/wp-admin/includes/image.php');
- $att_id = media_handle_sideload( $file_array, $post_id, null, $post_data ); // פרטי פוסט (לא חובה)
- if ( is_wp_error($att_id) ) {
- @unlink($file_array['tmp_name']); // clean up
- return $att_id; // output wp_error
- }
- // set as post thumbnail if desired
- if ($thumb) {
- set_post_thumbnail($post_id, $att_id);
- }
- return $att_id;
- }
- if(isset($_POST['go'])){
- $prog = $_POST['prog'];
- if (!post_exists($prog)){
- echo 'PROG:'.$prog.'<br>';
- $img = $_POST['img'];
- echo 'IMG:'.$img.'<br>';
- if (isEmpty($prog,$img)){
- echo '<h1 class="error">מה אתה טמבל? תמלא הכל נו</h1>';
- }
- else{
- $cat = $_POST['category'];
- $cats = explode(',',$cat);
- $catIDS = array();
- $j = 0;
- echo var_dump($cats);
- foreach($cats as $m){
- $term = get_cat_ID($m);
- if ($term != 0) {
- $catIDS[$j] = $term;
- }
- else{
- $catIDS[$j] = wp_create_category($m);
- }
- $j++;
- }
- echo 'CATID:'.var_dump($catIDS).'<br>';
- $name = $prog;
- $content = $_POST['article'];
- $my_post = array(
- 'post_title' => $name,
- 'post_content' => $content,
- 'post_status' => 'publish',
- 'post_author' => 1,
- 'post_category' => $catIDS
- );
- echo 'POST:'.var_dump($my_post).'<br>';
- $id=wp_insert_post( $my_post ); // העלאת הפוסט
- if($id){
- echo '<h1>עבד</h1>';
- }
- else{
- echo '<h1>לא עבד</h1>';
- }
- $tags = $_POST['tags'];
- echo 'TAGS:'.$tags;
- wp_set_post_tags( $id, $tags);
- $engName = $_POST['engname'];
- $heName = $_POST['hename'];
- $rating = $_POST['rating'];
- $date = $_POST['date'];
- $viewlinks = $_POST['viewlinks'];
- $tr = $_POST['trailer'];
- $dsc = $_POST['descp'];
- $dscim = $_POST['descpimdb'];
- $img1 = $_POST['img1'];
- $url1 = $_POST['url1'];
- add_post_meta($id, 'viewlinks', $viewlinks);
- add_post_meta($id, '_viewlinks', 'field_56c736033ca2c');
- add_post_meta($id, 'url', $url1);
- add_post_meta($id, '_url', 'field_56c736283ca2e');
- add_post_meta($id, 'img', $img1);
- add_post_meta($id, '_img', 'field_56c736083ca2d');
- add_post_meta($id, 'descpimdb', $dscim);
- add_post_meta($id, '_descpimdb', 'field_56c735f21b1dc');
- add_post_meta($id, 'tariler', $tr);
- add_post_meta($id, '_tariler', 'field_56c735d41b1da');
- add_post_meta($id, 'date', $date);
- add_post_meta($id, '_date', 'field_56c7357395b9f');
- add_post_meta($id, 'engname', $engName);
- add_post_meta($id, '_engname', 'field_56c7350bd5e60');
- add_post_meta($id,'rating', $rating);
- add_post_meta($id, '_rating', 'field_56c7357a95ba0');
- add_post_meta($id,'hebname', $heName);
- add_post_meta($id, '_hebname', 'field_56c7356995b9e');
- /*update_post_meta($id, '_aioseop_title', $name);
- update_post_meta($id, '_aioseop_description', $des);
- update_post_meta($id, '_aioseop_keywords', $tags); */
- $motek = ftr_image_now($img,$id, true); // צירוף תמונה
- }
- }
- else{
- echo 'הפוסט קיים חביבי!';
- }
- }
- ?>
- <form method="post">
- <table style="text-align:center;width:600px; margin:auto;">
- <tr>
- <td>שם סדרה</td><td><input type="text" placeholder="אני מלך עונה 3" name="prog" id="1"/></td>
- </tr>
- <tr>
- <td>תוכן</td><td><textarea style="width:100px;height:300px;" name="article" id="2"></textarea></td>
- </tr>
- <tr>
- <td>תגיות (אנא להפריד בפסיקים, או שסנאי יבוא וינשך לך את האף)</td><td><input type="text" name="tags" id="3"/></td>
- </tr>
- <tr>
- <td>קטגוריה</td><td><input type="text" name="category" id="4"/></td>
- </tr>
- <tr>
- <td>שם בעברית</td><td><input type="text" name="hename" id="5"/></td>
- </tr><tr>
- <td>שם באנגלית</td><td><input type="text" name="engname" id="6"/></td>
- </tr>
- <tr>
- <td>תאריך</td><td><input type="text" name="date" id="7"/></td>
- </tr>
- <tr>
- <td>דירוג</td><td><input type="text" name="rating" id="8"/></td>
- </tr>
- <tr>
- <td>טריילר</td><td><input type="text" name="trailer" id="9"/></td>
- </tr>
- <tr>
- <td>viewlinks</td><td><input type="text" name="viewlinks" id="10"/></td>
- </tr>
- <tr>
- <td>תמונה</td><td><input type="text" name="img1" id="11"/></td>
- </tr>
- <tr>
- <td>קישור</td><td><input type="text" name="url1" id="12"/></td>
- </tr>
- <tr>
- <td>descpimdb</td><td><textarea name="descpimdb" id="13"></textarea></td>
- </tr>
- <tr>
- <td>descp</td><td><textarea name="descp" id="14"></textarea></td>
- </tr>
- <tr>
- <td>קישור לתמונה ראשית</td><td><input type="text" placeholder="IMG URL?" name="img" id="15"/></td>
- </tr>
- </table>
- <br>
- <center><input type="submit" class="myButton" name="go" value="תן בראש כאילו אין מחר!" id="16"/></center>
- </form>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement