Fixed minor bugs

parent d99c6003
...@@ -9,6 +9,7 @@ based on the ideas I planned for www.sexhack.me: ...@@ -9,6 +9,7 @@ based on the ideas I planned for www.sexhack.me:
- Version 0.0.3: - Version 0.0.3:
* Integration of Ultimate Members plugin for user and model profiles * Integration of Ultimate Members plugin for user and model profiles
* Show thumbnail in video post list in admin
* 404 Not Found page with gallery instead of WC products * 404 Not Found page with gallery instead of WC products
- Version 0.0.4: - Version 0.0.4:
......
...@@ -36,6 +36,7 @@ if(!class_exists('SH_GDrive')) { ...@@ -36,6 +36,7 @@ if(!class_exists('SH_GDrive')) {
function get_download_url($file) function get_download_url($file)
{ {
if(!($file && is_string($file) && strlen($file)>3)) return $file;
if ( function_exists( 'igd_fs' ) ) if ( function_exists( 'igd_fs' ) )
{ {
// Integrate Google Drive Plugin is installed and active, so, filter it! // Integrate Google Drive Plugin is installed and active, so, filter it!
...@@ -47,12 +48,11 @@ if(!class_exists('SH_GDrive')) { ...@@ -47,12 +48,11 @@ if(!class_exists('SH_GDrive')) {
$gparts = explode('/', $gpath); $gparts = explode('/', $gpath);
if(count($gparts) > 0) if(count($gparts) > 0)
{ {
$parent=false; $parent=false;
$gfile=false; $gfile=false;
$success=false; $success=false;
$igd = \IGD\App::instance(); $igd = \IGD\App::instance();
// Try root first // Try root first
foreach($gparts as $k => $part) foreach($gparts as $k => $part)
{ {
...@@ -100,13 +100,12 @@ if(!class_exists('SH_GDrive')) { ...@@ -100,13 +100,12 @@ if(!class_exists('SH_GDrive')) {
if($g['name']==$part) if($g['name']==$part)
{ {
$parent=$g['id']; $parent=$g['id'];
$gf=$g; $gf=$g;
} }
} }
} }
} }
if(count($gparts)-1 == $k) $success=true; if(count($gparts)-1 == $k) $success=true;
if($success) $gfile = $gf; if($success) $gfile = $gf;
......
...@@ -184,7 +184,6 @@ if(!class_exists('SH_Video')) { ...@@ -184,7 +184,6 @@ if(!class_exists('SH_Video')) {
public function get_guests($usedb=true) public function get_guests($usedb=true)
{ {
if(isset($this->attributes['guests'])) return $this->guests; if(isset($this->attributes['guests'])) return $this->guests;
sexhack_log("(TTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTTT");
$this->attributes['guests'] = array(); $this->attributes['guests'] = array();
if($usedb) if($usedb)
{ {
......
...@@ -59,10 +59,10 @@ if(!class_exists("SH_VideoProducts")) { ...@@ -59,10 +59,10 @@ if(!class_exists("SH_VideoProducts")) {
// main product settings // main product settings
$prod->set_name($video->title); $prod->set_name($video->title);
$prod->set_slug($video->slug); // XXX TODO Compose slug with username too to avoid name collisions? $prod->set_slug($video->slug);
// Product description. // Product description.
$video_link=site_url().'/'.get_option('gallery_slug', 'v')."/"; // XXX TODO Get the right product link $video_link=site_url().'/'.get_option('gallery_slug', 'v')."/".$video->slug."/";
$prod->set_short_description('<p>Whach me <a href="'.$video_link.'">ONLINE HERE</a></p>'); $prod->set_short_description('<p>Whach me <a href="'.$video_link.'">ONLINE HERE</a></p>');
$prod->set_description($video->description); $prod->set_description($video->description);
......
...@@ -81,13 +81,13 @@ function save_sexhack_video_meta_box_data( $post_id ) ...@@ -81,13 +81,13 @@ function save_sexhack_video_meta_box_data( $post_id )
// //
// Title and slug // Title and slug
$video->title = $post->post_title; $video->title = $post->post_title;
$video->slug = $post->post_name; $video->slug = uniqidReal()."-".$post->post_name;
// TODO Remove debug // TODO Remove debug
sexhack_log("SAVE post object:"); //sexhack_log("SAVE post object:");
sexhack_log($post); // sexhack_log($post);
sexhack_log(' - $POST:'); // sexhack_log(' - $POST:');
sexhack_log($_POST); // sexhack_log($_POST);
// Model // Model
if(array_key_exists('video_model', $_POST) && is_numeric($_POST['video_model']) && intval($_POST['video_model']) > 0) if(array_key_exists('video_model', $_POST) && is_numeric($_POST['video_model']) && intval($_POST['video_model']) > 0)
......
...@@ -261,6 +261,18 @@ function check_url_or_path($url) ...@@ -261,6 +261,18 @@ function check_url_or_path($url)
return false; return false;
} }
function uniqidReal($lenght = 13) {
// uniqid gives 13 chars, but you could adjust it to your needs.
if (function_exists("random_bytes")) {
$bytes = random_bytes(ceil($lenght / 2));
} elseif (function_exists("openssl_random_pseudo_bytes")) {
$bytes = openssl_random_pseudo_bytes(ceil($lenght / 2));
} else {
throw new Exception("no cryptographically secure random function available");
}
return substr(bin2hex($bytes), 0, $lenght);
}
function html2text($html) function html2text($html)
{ {
// remove comments and any content found in the the comment area (strip_tags only removes the actual tags). // remove comments and any content found in the the comment area (strip_tags only removes the actual tags).
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment