| @@ -2,9 +2,9 @@ | ||
| 2 | 2 | /** |
| 3 | 3 | * Plugin Name: VdoCipher |
| 4 | 4 | * Plugin URI: http://www.vdocipher.com |
| 5 | 5 | * Description: Secured video hosting for wordpress |
| 6 | - * Version: 1.4 | |
| 6 | + * Version: 1.7 | |
| 7 | 7 | * Author: VdoCipher |
| 8 | 8 | * Author URI: http://www.vdocipher.com |
| 9 | 9 | * License: GPL2 |
| 10 | 10 | */ |
| @@ -14,43 +14,34 @@ | ||
| 14 | 14 | header($_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found'); |
| 15 | 15 | exit("<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML 2.0//EN\">\r\n<html><head>\r\n<title>404 Not Found</title>\r\n</head><body>\r\n<h1>Not Found</h1>\r\n<p>The requested URL " . $_SERVER['SCRIPT_NAME'] . " was not found on this server.</p>\r\n</body></html>"); |
| 16 | 16 | } |
| 17 | 17 | |
| 18 | -function vdo_send($action, $params, $posts = false){ | |
| 18 | +function vdo_send($action, $params, $posts = array()){ | |
| 19 | 19 | $client_key = get_option('vdo_client_key'); |
| 20 | 20 | if ($client_key == false || $client_key == "") { |
| 21 | 21 | return "Plugin not configured. Please set the key to embed videos."; |
| 22 | 22 | } |
| 23 | - $curl = curl_init(); | |
| 24 | - curl_setopt($curl, CURLOPT_FAILONERROR, true); | |
| 25 | - curl_setopt($curl, CURLOPT_RETURNTRANSFER,true); | |
| 26 | - curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); | |
| 27 | - curl_setopt($curl, CURLOPT_VERBOSE, true); | |
| 28 | - curl_setopt($curl, CURLOPT_FAILONERROR, false); | |
| 29 | - //curl_setopt($curl, CURLOPT_PROXY, "xxxxxxxxxxxxxxxxx:xxxx"); | |
| 30 | 23 | |
| 31 | 24 | $getData = http_build_query($params); |
| 32 | - curl_setopt($curl, CURLOPT_POST, true); | |
| 33 | - $postData = "clientSecretKey=$client_key"; | |
| 34 | - if ($posts) { | |
| 35 | - $postData .= "&". $posts; | |
| 36 | - } | |
| 37 | - curl_setopt($curl, CURLOPT_POSTFIELDS, $postData); | |
| 25 | + $posts["clientSecretKey"] = $client_key; | |
| 38 | 26 | $url = "http://api.vdocipher.com/v2/$action/?$getData"; |
| 39 | - curl_setopt($curl, CURLOPT_URL,$url); | |
| 40 | - $html = curl_exec($curl); | |
| 41 | - if (!$html) { | |
| 42 | - echo curl_error($curl); | |
| 27 | + $response = wp_safe_remote_post($url, array( | |
| 28 | + 'method' => 'POST', | |
| 29 | + 'body' => $posts | |
| 30 | + )); | |
| 31 | + if (is_wp_error( $response )) { | |
| 32 | + $error_message = $response->get_error_message(); | |
| 33 | + echo "VdoCipher: Something went wrong: $error_message"; | |
| 34 | + return ""; | |
| 43 | 35 | } |
| 44 | - curl_close($curl); | |
| 45 | - return $html; | |
| 36 | + return $response['body']; | |
| 46 | 37 | } |
| 47 | 38 | function vdo_shortcode( $atts ) { |
| 48 | 39 | extract( shortcode_atts( |
| 49 | 40 | array( |
| 50 | 41 | 'title' => 'TITLE_OF_VIDEO', |
| 51 | - 'width' => get_option('vdo_default_width'), | |
| 52 | - 'height' => get_option('vdo_default_height'), | |
| 42 | + 'width' => get_option('vdo_default_width') . "px", | |
| 43 | + 'height' => get_option('vdo_default_height') . "px", | |
| 53 | 44 | 'id' => 'id', |
| 54 | 45 | 'no_annotate'=> false |
| 55 | 46 | ), $atts ) |
| 56 | 47 | ); |
| @@ -82,14 +73,15 @@ | ||
| 82 | 73 | ); |
| 83 | 74 | $anno = false; |
| 84 | 75 | if (!function_exists("eval_date")) { |
| 85 | 76 | function eval_date($matches){ |
| 86 | - return date($matches[1]); | |
| 77 | + return current_time($matches[1]); | |
| 87 | 78 | } |
| 88 | 79 | } |
| 89 | 80 | if (get_option('vdo_annotate_code') != "") { |
| 90 | 81 | $current_user = wp_get_current_user(); |
| 91 | 82 | $vdo_annotate_code = get_option('vdo_annotate_code'); |
| 83 | + $vdo_annotate_code = apply_filters('vdocipher_annotate_preprocess', $vdo_annotate_code); | |
| 92 | 84 | if (is_user_logged_in()) { |
| 93 | 85 | $vdo_annotate_code = str_replace('{name}', $current_user->display_name , $vdo_annotate_code); |
| 94 | 86 | $vdo_annotate_code = str_replace('{email}', $current_user->user_email , $vdo_annotate_code); |
| 95 | 87 | $vdo_annotate_code = str_replace('{username}', $current_user->user_login , $vdo_annotate_code); |
| @@ -96,10 +88,11 @@ | ||
| 96 | 88 | $vdo_annotate_code = str_replace('{id}', $current_user->ID , $vdo_annotate_code); |
| 97 | 89 | } |
| 98 | 90 | $vdo_annotate_code = str_replace('{ip}', $_SERVER['REMOTE_ADDR'] , $vdo_annotate_code); |
| 99 | 91 | $vdo_annotate_code = preg_replace_callback('/\{date\.([^\}]+)\}/', "eval_date" , $vdo_annotate_code); |
| 92 | + $vdo_annotate_code = apply_filters('vdocipher_annotate_postprocess', $vdo_annotate_code); | |
| 100 | 93 | if(!$no_annotate) |
| 101 | - $anno = "annotate=". urlencode($vdo_annotate_code); | |
| 94 | + $anno = array("annotate" => $vdo_annotate_code); | |
| 102 | 95 | } |
| 103 | 96 | $OTP = vdo_send("otp", $params, $anno); |
| 104 | 97 | $OTP = json_decode($OTP); |
| 105 | 98 | if(is_null($OTP)){ |
| @@ -107,10 +100,12 @@ | ||
| 107 | 100 | return $output; |
| 108 | 101 | } |
| 109 | 102 | $OTP = $OTP->otp; |
| 110 | 103 | |
| 111 | - $output = "<span id='vdo$OTP'></span>"; | |
| 112 | - $output .= "<script src='https://de122v0opjemw.cloudfront.net/utils/playerInit.php?otp=$OTP&height=$height&width=$width&'></script>"; | |
| 104 | + $output = "<div id='vdo$OTP' style='height:$height;width:$width;max-width:100%' ></div>"; | |
| 105 | + $output .= "<script> (function(v,i,d,e,o){v[o]=v[o]||{}; v[o].add = v[o].add || function V(a){ (v[o].d=v[o].d||[]).push(a);};"; | |
| 106 | + $output .= "if(!v[o].l) { v[o].l=1*new Date(); a=i.createElement(d), m=i.getElementsByTagName(d)[0]; a.async=1; a.src=e; m.parentNode.insertBefore(a,m);}"; | |
| 107 | + $output .= " })(window,document,'script','//de122v0opjemw.cloudfront.net/vdo.js','vdo'); vdo.add({ o: '$OTP', }); </script>"; | |
| 113 | 108 | return $output; |
| 114 | 109 | } |
| 115 | 110 | |
| 116 | 111 | add_shortcode( 'vdo', 'vdo_shortcode' ); |
| @@ -138,11 +133,11 @@ | ||
| 138 | 133 | add_options_page( 'VdoCipher Options', 'VdoCipher', 'manage_options', 'vdocipher', 'vdo_options' ); |
| 139 | 134 | } |
| 140 | 135 | function vdo_options(){ |
| 141 | 136 | if (!get_option('vdo_default_height')) |
| 142 | - update_option('vdo_default_height', '720'); | |
| 137 | + update_option('vdo_default_height', '360'); | |
| 143 | 138 | if (!get_option('vdo_default_width')) |
| 144 | - update_option('vdo_default_width', '1280'); | |
| 139 | + update_option('vdo_default_width', '640'); | |
| 145 | 140 | $vdo_client_key = get_option('vdo_client_key'); |
| 146 | 141 | if (!$vdo_client_key && strlen($vdo_client_key) != 64) { |
| 147 | 142 | vdo_show_form_client_key(); |
| 148 | 143 | return ""; |