/** * Save editted video details */ function saveVideoInfo() { global $Itemid, $mainframe; $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $c = hwd_vs_Config::get_instance(); $app = & JFactory::getApplication(); $row = new hwdvids_video($db); $uid = JRequest::getInt( 'owner', 0, 'post' ); $rowid = JRequest::getInt( 'id', 0, 'post' ); $referrer = JRequest::getVar( 'referrer', JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid ); // check component access settings and deny those without privileges if (!hwd_vs_access::allowAccess( $c->gtree_mdrt, $c->gtree_mdrt_child, hwd_vs_access::userGID( $my->id ))) { if ($my->id == $uid) { if ($my->id == "0") { $app->enqueueMessage(_HWDVIDS_ALERT_NOPERM); $app->redirect( $referrer ); } if ($c->allowvidedit == "0") { $app->enqueueMessage(_HWDVIDS_ALERT_NOPERM); $app->redirect( $referrer ); } // continue } else { $app->enqueueMessage(_HWDVIDS_ALERT_NOPERM); $app->redirect( $referrer ); } } $row->load( $rowid ); $old_category = $row->category_id; $file_name_org = $_FILES['thumbnail_file']['name']; $file_ext = substr($file_name_org, strrpos($file_name_org, '.') + 1); $thumbnail = ''; if ($_FILES['thumbnail_file']['tmp_name'] !== "") { if ($row->video_type == "local" || $row->video_type == "swf" || $row->video_type == "mp4") { $videocode = $row->video_id; $thumbnail = $file_ext; } else { $videocode = "tp-".$row->id; $thumbnail = "tp-".$row->id.".".$file_ext; } $base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS; $upload_result = hwd_vs_tools::uploadFile("thumbnail_file", $videocode, $base_Dir, 2, "jpg,jpeg", 1); if ($upload_result[0] == "0") { $msg = $upload_result[1]; $app->enqueueMessage($msg); $app->redirect( JURI::root( true ) . '/index.php?option=com_hwdvideoshare&Itemid='.$Itemid.'&task=editvideo&video_id='.$row->id ); } else { require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'thumbnail.inc.php'); $thumb_path_s = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.$videocode.'.'.$file_ext; $thumb_path_l = JPATH_SITE.DS.'hwdvideos'.DS.'thumbs'.DS.'l_'.$videocode.'.'.$file_ext; $twidth_s = round($c->con_thumb_n); $theight_s = round($c->con_thumb_n*$c->tar_fb); $twidth_l = round($c->con_thumb_l); $theight_l = round($c->con_thumb_l*$c->tar_fb); list($width, $height, $type, $attr) = @getimagesize($thumb_path_s); $ratio = $width/$height; //echo $thumb_path_s."<br />".$ratio."<br />".$width."<br />".$height."<br />".$c->tar_fb."<br />".$twidth_s."<br />".$theight_s; if ($ratio > 1) { $resized_l = new Thumbnail($thumb_path_s); $resized_l->resize($twidth_l,$twidth_l); $resized_l->cropFromCenter($twidth_l, $theight_l); $resized_l->save($thumb_path_l); $resized_l->destruct(); $resized_s = new Thumbnail($thumb_path_s); $resized_s->resize($twidth_s,$twidth_s); $resized_s->cropFromCenter($twidth_s, $theight_s); $resized_s->save($thumb_path_s); $resized_s->destruct(); } else { $resized_l = new Thumbnail($thumb_path_s); $resized_l->resize($twidth_l,2000); $resized_l->cropFromCenter($twidth_l, $theight_l); $resized_l->save($thumb_path_l); $resized_l->destruct(); $resized_s = new Thumbnail($thumb_path_s); $resized_s->resize($twidth_s,1000); $resized_s->cropFromCenter($twidth_s, $theight_s); $resized_s->save($thumb_path_s); $resized_s->destruct(); } } } else { //echo "No thumbnail uploaded"; } $title = hwd_vs_tools::generatePostTitle(); $description = hwd_vs_tools::generatePostDescription(); $tags = hwd_vs_tools::generatePostTags(); $password = Jrequest::getVar( 'hwdvspassword', '' ); if (!empty($password)) { $password = md5($password); $_POST['password'] = $password; } $_POST['id'] = $rowid; $_POST['title'] = $title; $_POST['description'] = $description; $_POST['category_id'] = JRequest::getInt( 'category_id', 0 ); $_POST['tags'] = $tags; if (!empty($thumbnail)) { $_POST['thumbnail'] = $thumbnail; } // bind it to the table if (!$row->bind($_POST)) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } // Make sure the record is valid if (!$row->check()) { $this->setError($this->_db->getErrorMsg()); echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); hwd_vs_recount::recountVideosInCategory($row->category_id); hwd_vs_recount::recountVideosInCategory($old_category_id); $msg = _HWDVIDS_ALERT_VIDEDITSAVED; $app->enqueueMessage($msg); $app->redirect( $referrer ); }
/** * Outputs frontpage HTML * * @return Nothing */ function addConfirm($admin_import=false) { global $Itemid, $j15, $j16; $c = hwd_vs_Config::get_instance(); $db = & JFactory::getDBO(); $my = & JFactory::getUser(); $acl= & JFactory::getACL(); $security_code = JRequest::getCmd( 'security_code', '' ); if ($c->disablecaptcha == "1") { $checksecurity = "0"; } else { $checksecurity = "1"; } if ($checksecurity == "1" && !$admin_import) { if(($_SESSION['security_code'] == $security_code) && (!empty($_SESSION['security_code'])) ) { unset($_SESSION['security_code']); } else { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_ERRSC, "exclamation.png", 0); return; } } $requestarray = JRequest::get( 'default', 2 ); $embeddump = $requestarray['embeddump']; $remote_verified = null; $parsedurl = parse_url($embeddump); if (empty($parsedurl['host'])) { $parsedurl['host'] = ''; } preg_match('/(?P<domain>[a-z0-9][a-z0-9\-]{1,63}\.[a-z\.]{2,6})$/i', $parsedurl['host'], $regs); if (empty($regs['domain'])) { $regs['domain'] = ''; } if ($j15) { if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php'); } else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google.php'); } else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.$regs['domain'].'.php'); } else { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube.php'); $regs['domain'] = 'remote'; } } if ($j16) { if ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'youtube'.DS.'youtube.php'); } else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'google'.DS.'google.php'); } else if (file_exists(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php')) { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'thirdpartysupportpack'.DS.$regs['domain'].'.php'); } else { require_once(JPATH_SITE.DS.'plugins'.DS.'hwdvs-thirdparty'.DS.'remote'.DS.'remote.php'); $regs['domain'] = 'remote'; } } $failures = ""; if (!isset($remote_verified)) { $cn = 'hwd_vs_tp_'.preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']); $f_processc = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processCode'; $f_processi = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processThumbnail'; $f_processt = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processTitle'; $f_processd = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDescription'; $f_processk = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processKeywords'; $f_processl = preg_replace("/[^a-zA-Z0-9s_-]/", "", $regs['domain']).'processDuration'; $tp = new $cn(); $ext_v_code = $tp->$f_processc($embeddump); //check if already exists $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' ); $duplicatecount = $db->loadResult(); if ($duplicatecount > 0 && $admin_import == false) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0); return; } else if ($duplicatecount > 0 && $admin_import == true) { return false; } $ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[1]); $ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[1]); $ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[1]); $ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[1]); if ($ext_v_code[0] == "0") { require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/remote.php'); $regs['domain'] = 'remote'; $tp = new hwd_vs_tp_remote(); $ext_v_code = $tp->remoteProcessCode($embeddump); $ext_v_title = $tp->remoteProcessTitle($embeddump, @$ext_v_code[1]); $ext_v_descr = $tp->remoteProcessDescription($embeddump, @$ext_v_code[1]); $ext_v_keywo = $tp->remoteProcessKeywords($embeddump, @$ext_v_code[1]); $ext_v_durat = $tp->remoteProcessDuration($embeddump, @$ext_v_code[1]); if ($ext_v_code[0] == "0") { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0); return; } //check if already exists $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' ); $duplicatecount = $db->loadResult(); if ($duplicatecount > 0 && $admin_import == false) { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ALERT_DUPLICATE, "exclamation.png", 0); return; } else if ($duplicatecount > 0 && $admin_import == true) { return false; } } if ($ext_v_title[0] == 0) {$failures.=_HWDVIDS_INFO_TPTITLEFAIL."<br />";} if ($ext_v_descr[0] == 0) {$failures.=_HWDVIDS_INFO_TPDESCFAIL."<br />";} if ($ext_v_keywo[0] == 0) {$failures.=_HWDVIDS_INFO_TPKWFAIL."<br />";} if ($ext_v_durat[0] == 0) {$failures.=_HWDVIDS_INFO_TPDRFAIL."<br />";} } else if ($remote_verified == 0) { $error_msg = _HWDVIDS_ERROR_UPLDERR11."<br /><br />"._HWDVIDS_INFO_SUPPTPW."<br />".hwd_vs_tools::generateSupportedWebsiteList(); hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, $error_msg, "exclamation.png", 1); return; } $title = hwd_vs_tools::generatePostTitle($ext_v_title[1]); $description = hwd_vs_tools::generatePostDescription($ext_v_descr[1]); $tags = hwd_vs_tools::generatePostTags($ext_v_keywo[1]); $category_id = JRequest::getInt( 'category_id', 0, 'post' ); $public_private = JRequest::getWord( 'public_private' ); $allow_comments = JRequest::getInt( 'allow_comments', 0, 'post' ); $allow_embedding = JRequest::getInt( 'allow_embedding', 0, 'post' ); $allow_ratings = JRequest::getInt( 'allow_ratings', 0, 'post' ); $checkform = hwd_vs_tools::checkFormComplete($title, $description, $category_id, $tags, $public_private, $allow_comments, $allow_embedding, $allow_ratings); if (!$checkform) { return; } $row = new hwdvids_video($db); $password = Jrequest::getVar( 'hwdvspassword', '' ); if (!empty($password)) { $password = md5($password); $_POST['password'] = $password; } $_POST['video_type'] = $regs['domain']; $_POST['video_id'] = $ext_v_code[1]; $_POST['title'] = $title; $_POST['description'] = $description; $_POST['category_id'] = $category_id; $_POST['tags'] = $tags; $_POST['public_private'] = $public_private; $_POST['allow_comments'] = $allow_comments; $_POST['allow_embedding'] = $allow_embedding; $_POST['allow_ratings'] = $allow_ratings; $_POST['video_length'] = $ext_v_durat[1]; $_POST['date_uploaded'] = date('Y-m-d H:i:s'); if ($admin_import) { $_POST['user_id'] = $_REQUEST['user_id']; } else { $_POST['user_id'] = $my->id; } if ($c->aa3v == 1) { $_POST['approved'] = "yes"; $_POST['published'] = "1"; } else { $_POST['approved'] = "pending"; $_POST['published'] = "0"; } // bind it to the table if (!$row->bind($_POST)) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } include_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'helpers'.DS.'events.php'); $params->title = $title; $params->id = $row->id; $params->category_id = $row->category_id; $params->type = $row->video_type; $params->user_id = $row->user_id; hwdvsEvent::onAfterVideoUpload($params); // save remote thumbnail to disk $data = @explode(",", $row->video_id); $thumburl = hwd_vs_tools::get_final_url( @$ext_v_code[2] ); $thumbbase = "tp-".$row->id.".jpg"; $thumbpath = JPATH_SITE.DS."hwdvideos".DS."thumbs".DS.$thumbbase; $ch = curl_init ($thumburl); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_BINARYTRANSFER,1); $rawdata=curl_exec($ch); curl_close ($ch); if(file_exists($thumbpath)) { unlink($thumbpath); } $fp = fopen($thumbpath,'x'); fwrite($fp, $rawdata); fclose($fp); if(file_exists($thumbpath)) { $db->SetQuery( "UPDATE #__hwdvidsvideos SET `thumbnail` = \"$thumbbase\" WHERE id = $row->id" ); $db->Query(); } $video = new hwdvids_video($db); $video->load( $row->id ); if (!$admin_import) { hwd_vs_html::addConfirm($title, $failures, $video); } else { return true; } }
/** * save videos */ function savevideo() { global $option, $task; $app = & JFactory::getApplication(); $db = & JFactory::getDBO(); $row = new hwdvids_video($db); $requestarray = JRequest::get( 'default', 2 ); $rawDescription = trim($requestarray['description']); $id = Jrequest::getInt( 'id', '' ); $title = hwd_vs_tools::generatePostTitle(); $description = hwd_vs_tools::generatePostDescription($rawDescription); $tags = hwd_vs_tools::generatePostTags(); $views = Jrequest::getInt( 'views', '' ); if (!empty($views)) { $db->SetQuery("SELECT count(*) FROM #__hwdvidslogs_views WHERE videoid = ".$id); $unarchived_count = $db->loadResult(); $archived_count = $views - $unarchived_count; $db->SetQuery("SELECT count(*) FROM #__hwdvidslogs_archive WHERE videoid = ".$id); $total = $db->loadResult(); if ($total > 0) { $db->SetQuery("UPDATE #__hwdvidslogs_archive SET views = $archived_count WHERE videoid = ".$id); if ( !$db->query() ) { echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } } else { $row_new = new hwdvidslogs_archive($db); $_POST['id'] = null; $_POST['videoid'] = $id; $_POST['views'] = $archived_count; if (!$row_new->bind($_POST)) { echo "<script> alert('".$row_new->getError()."'); window.history.go(-1); </script>\n"; exit(); } if (!$row_new->store()) { echo "<script> alert('".$row_new -> getError()."'); window.history.go(-1); </script>\n"; exit(); } $_POST['id'] = $id; } } $password = Jrequest::getVar( 'hwdvspassword', '' ); if (!empty($password)) { $password = md5($password); $_POST['password'] = $password; } if ($_POST['public_private'] == "group") { $gtree_video = Jrequest::getVar( 'gtree_video', '' ); if (!empty($gtree_video)) { $_POST['password'] = $gtree_video; } } if ($_POST['public_private'] == "level") { $jacl_video = Jrequest::getVar( 'jacl_video', '' ); if (!empty($jacl_video)) { if (isset($jacl_video) && $jacl_video !== '') { $jacl_video = @implode(",", $jacl_video); } $_POST['password'] = $jacl_video; } } $_POST['title'] = $title; $_POST['description'] = $description; $_POST['tags'] = $tags; $_POST['category_id'] = JRequest::getInt( 'category_id', 0 ); // bind it to the table if (!$row -> bind($_POST)) { echo "<script> alert('" .$row -> getError() ."'); window.history.go(-1); </script>\n"; exit(); } // store it in the db if (!$row -> store()) { echo "<script> alert('" .$row -> getError() ."'); window.history.go(-1); </script>\n"; exit(); } $row->checkin(); include(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'libraries'.DS.'maintenance_recount.class.php'); hwd_vs_recount::recountVideosInCategory($row->category_id); if ($task == "apply") { $app->enqueueMessage(_HWDVIDS_ALERT_VIDSAVED); $app->redirect( JURI::root( true ) . '/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid='.$row->id ); } else { $app->enqueueMessage(_HWDVIDS_ALERT_VIDSAVED); $app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=videos' ); } }
/** * Outputs frontpage HTML * * @param string $option the joomla component name * @param array $rows array of video data * @param array $rowsfeatured array of featured video data * @param object $pageNav page navigation object * @param int $total the total video count * @return Nothing */ function fixVideoDataFormat($videoid=null) { $db = & JFactory::getDBO(); if (isset($videoid)) { $query = 'SELECT id, title, description, tags' . ' FROM #__hwdvidsvideos' . ' WHERE id = '.$videoid ; $db->SetQuery($query); $rows = $db->loadObjectList(); } else { $query = 'SELECT *' . ' FROM #__hwdvidsvideos' ; $db->SetQuery($query); $rows = $db->loadObjectList(); } for ($i=0, $n=count($rows); $i < $n; $i++) { $row = $rows[$i]; $title = hwd_vs_tools::generatePostTitle($row->title); $description = hwd_vs_tools::generatePostDescription($row->description); $tags = hwd_vs_tools::generatePostTags($row->tags); $thumb_snap = $row->thumb_snap; if ($row->thumb_snap == "0:00:00") { $sec = intval(hwd_vs_tools::hms2sec($row->video_length)); if ($sec < 2) { $thumb_snap = "0:00:02"; } else { $thumb_snap = hwd_vs_tools::sec2hms($sec/2); } } // update sql $db->SetQuery("UPDATE #__hwdvidsvideos SET title = \"$title\", description = \"$description\", tags = \"$tags\", thumb_snap = \"$thumb_snap\" WHERE id = $row->id"); $db->Query(); if ( !$db->query() ) { echo "<script> alert('".$db->getErrorMsg()."'); window.history.go(-1); </script>\n"; exit(); } } return true; }