function returnPath($path)
{
    if (strpos($path, "http://") !== false || strpos($path, "https://") !== false) {
        $upload_path = getUploadDirPath(basename($path));
        save_image($path, UPLOAD_CAR_IMAGES . $upload_path);
        return $upload_path;
    }
}
 /**
  * Constructor function used to get parameters from request URL
  */
 public function __construct()
 {
     parent::__construct();
     global $wpdb;
     $this->_wpdb = $wpdb;
     /** Get videosearchQuery param for videos */
     $this->_videosearchQuery = filter_input(INPUT_POST, 'videosearchQuery');
     /** Get add_video param for videos */
     $this->_addnewVideo = filter_input(INPUT_POST, 'add_video');
     /** Get status param for videos */
     $this->_status = filter_input(INPUT_GET, 'status');
     /** Get videosearchbtn param for videos */
     $this->_searchBtn = filter_input(INPUT_POST, 'videosearchbtn');
     /** Get update param for videos */
     $this->_update = filter_input(INPUT_GET, 'update');
     /** Get add param for videos */
     $this->_add = filter_input(INPUT_GET, 'add');
     /** Get del param for videos */
     $this->_del = filter_input(INPUT_GET, 'del');
     /** Get featured param for videos */
     $this->_featured = filter_input(INPUT_GET, 'featured');
     /** Get order param for videos */
     $this->_orderDirection = filter_input(INPUT_GET, 'order');
     /** Get orderby param for videos*/
     $this->_orderBy = filter_input(INPUT_GET, 'orderby');
     /** Set order by fields as array */
     $orderBy = array('id', 'title', 'author', 'category', 'fea', 'publish', 'date', 'ordering');
     $this->_order = '';
     /** Get order by fields nad direction for videos */
     if (isset($this->_orderBy) && in_array($this->_orderBy, $orderBy)) {
         $this->_order = $this->_orderBy;
     } else {
         $this->_orderDirection = 'DESC';
     }
     /** Get plugin settings date */
     $this->_settingsData = getPluginSettings();
     $this->_player_colors = unserialize($this->_settingsData->player_colors);
     /** Get upload directory path */
     $this->_srt_path = getUploadDirPath();
     $this->_adminorder_direction = $this->_player_colors['recentvideo_order'];
 }
function videogallery_admin_notices()
{
    /** Get adjustment settings option while plugin activation */
    $admin_notice_video_gallery = get_option('video_gallery_adjustment_instruction');
    /** Get videogallery folder option while plugin activation */
    $admin_folder_video_gallery = get_option('video_gallery_folder_instruction');
    /** Display instruction to adjust the settings while plugin activation */
    if ($admin_notice_video_gallery) {
        echo '<div id="message" class="updated"><p>To adjust the video gallery plugin setting please visit the link <strong><a href="' . admin_url('admin.php?page=hdflvvideosharesettings') . '">Settings</a></strong>.</p></div>';
        /** Delete option once the information is displayed */
        delete_option('video_gallery_adjustment_instruction');
    }
    /** Get videogallery upload directory folder path */
    $uploadDirname = getUploadDirPath();
    /** If folder is not exist then create folder */
    if (!file_exists($uploadDirname)) {
        /** If folder is not created then display error message */
        if (!wp_mkdir_p($uploadDirname) && $admin_folder_video_gallery) {
            echo '<div id="error" class="error"><p>Videogallery folder is not created in the folder path <strong>../wp-content/uploads/</strong></p></div>';
        }
    } else {
        /** If folder is created then delete error message */
        delete_option('video_gallery_folder_instruction');
    }
}
示例#4
0
 /**
  * Fucntion to move the uploaded file 
  * to video gallery folder ( OR ) Amazon s3 bucket.
  * 
  * @param unknown $file          
  * @return string
  */
 function doupload($file)
 {
     global $file, $errorcode, $file_name, $wpdb;
     /** Get last video id from database */
     $row = $wpdb->get_var('select MAX( vid ) from ' . $wpdb->prefix . 'hdflvvideoshare');
     /** Get uploaded directory path */
     $destination_path = getUploadDirPath();
     $row1 = $row + 1;
     /** Get uploaded file extension */
     $extension = explode('.', $file['name']);
     /** Convert extension into lower case */
     $extension = strtolower(end($extension));
     /** Check the uploaded file is image */
     if ($extension == 'jpeg') {
         $extension = 'jpg';
     }
     /**
      * Check the uploaded file is srt (subtitle files) 
      * or image or video. 
      * Based on that renmae the original file name
      */
     switch ($extension) {
         case 'srt':
             $file_name = $row1 . '_subtitle' . rand() . '.' . $extension;
             break;
         case 'jpg':
         case 'png':
         case 'gif':
             $file_name = $row1 . '_thumb' . rand() . '.' . $extension;
             break;
         default:
             $file_name = $row1 . '_video' . rand() . '.' . $extension;
             break;
     }
     /** Get destination path 
      * Move file from temporary path */
     $target_path = $destination_path . '' . $file_name;
     /** If  file is moved then set error code as 0 */
     if (@move_uploaded_file($file['tmp_name'], $target_path)) {
         $errorcode = 0;
     } else {
         /** Else file is moved then set error code as 4 */
         $errorcode = 4;
     }
     /** Sleep 1ms */
     sleep(1);
 }
 /** 
  * Function to upload logo image and get logo path
  * 
  * @param string $logopath
  * @return type
  */
 function uploadLogo($logopath)
 {
     /** Get "videogallery" directory path from plugin helper */
     $uploadPath = getUploadDirPath();
     /** Get logo file name and its type  */
     if (isset($_FILES['logopath']['name']) && $_FILES['logopath']['name'] != '') {
         /** Store allowed file types into an array */
         $allowedExtensions = array('jpg', 'jpeg', 'png', 'gif');
         $logoImage = strtolower($_FILES['logopath']['name']);
         /**
          * Check whether the logo file type is exist in the allowed extensions
          * If exist, move logo file to videogallery folder from temporary path
          * Else display error message
          */
         if ($logoImage && in_array(end(explode('.', $logoImage)), $allowedExtensions)) {
             move_uploaded_file($_FILES['logopath']['tmp_name'], $uploadPath . $_FILES['logopath']['name']);
             /** Return uploaded logo file path */
             return $_FILES['logopath']['name'];
         } else {
             /** If logo image is not exist or not valid extension then retur to settings page */
             $this->admin_redirect('admin.php?page=hdflvvideosharesettings&extension=1');
         }
     } else {
         /** Return already uploaded logo path */
         return $logopath;
     }
 }
示例#6
0
 /**
  * Function to unlink the given file 
  * 
  * @param type $filePath
  */
 function unlinkFile($filePath)
 {
     /** Get upload directory path to unlink file */
     $uploadPath = getUploadDirPath();
     /** Check file value is exist */
     if ($filePath) {
         /** Delete the given file */
         unlink($uploadPath . $filePath);
     }
 }