/** * edit videos */ function updateVideoSource() { global $option; $db =& JFactory::getDBO(); $my = & JFactory::getUser(); $app = & JFactory::getApplication(); $c = hwd_vs_Config::get_instance(); $video_type = Jrequest::getVar( 'videotype', '0' ); $video_id = Jrequest::getVar( 'id', '0' ); $updatedetails = Jrequest::getVar( 'updatedetails', '0' ); $admin_import = true; require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'models'.DS.'uploads.php'); $row = new hwdvids_video($db); $row->load( $video_id ); if ($video_type == 1) { $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 ($regs['domain'] == 'youtube.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php')) { require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/youtube.php'); } else if ($regs['domain'] == 'google.com' && file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php')) { require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/google.php'); } else if (file_exists(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php')) { require_once(JPATH_SITE.'/plugins/hwdvs-thirdparty/'.$regs['domain'].'.php'); } else { $pos_flv = strpos($embeddump, ".flv"); if ($pos_flv === false) { $remote_verified = 0; } else { $pos_flv = $pos_flv+4; $datadump = substr($embeddump, 0, $pos_flv); $pos_http = mb_strrpos($datadump, "http://"); if ($pos_http === false) { $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; } else { $url = substr($datadump, $pos_http); } $pru = parse_url($url); $remoteurl = $pru['scheme']."://".$pru['host'].$pru['path']; if(!preg_match("/^[a-zA-Z]+[:\/\/]+[A-Za-z0-9\-_]+\\.+[A-Za-z0-9\.\/%&=\?\-_]+$/i",$remoteurl)) { $remote_verified = 0; } else { $filegrab = @file_get_contents($remoteurl, null, null, 0, 16); $filecheck = @strpos($remoteurl, "flv"); if (isset($remoteurl) && !empty($remoteurl) && $filecheck !== false) { $remote_verified = 1; } else { $remote_verified = 0; } } } } $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_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); $ext_v_title = $tp->$f_processt($embeddump, @$ext_v_code[2]); $ext_v_descr = $tp->$f_processd($embeddump, @$ext_v_code[2]); $ext_v_keywo = $tp->$f_processk($embeddump, @$ext_v_code[2]); $ext_v_durat = $tp->$f_processl($embeddump, @$ext_v_code[2]); if ($ext_v_code[0] == "0") { hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_INFO_TPPROCESSFAIL, "exclamation.png", 0); return; } 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; } else if ($remote_verified == 1) { $ext_v_code[1] = $remoteurl.","; $ext_v_title[1] = _HWDVIDS_UNKNOWN; $ext_v_descr[1] = _HWDVIDS_UNKNOWN; $ext_v_keywo[1] = _HWDVIDS_UNKNOWN; $ext_v_durat[1] = "0:00:00"; $regs['domain'] = "remote"; } //check if already exists $db->SetQuery( 'SELECT count(*) FROM #__hwdvidsvideos WHERE video_id = "'.$ext_v_code[1].'"' ); $duplicatecount = $db->loadResult(); $admin_import = false; 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; } $title = $ext_v_title[1]; $title = stripslashes($title); $title = stripslashes($title); $title = hwdEncoding::charset_decode_utf_8($title); $title = hwdEncoding::charset_encode_utf_8($title); $title = htmlspecialchars_decode($title); $title = addslashes($title); $description = $ext_v_descr[1]; $description = stripslashes($description); $description = stripslashes($description); $description = hwdEncoding::charset_decode_utf_8($description); $description = hwdEncoding::charset_encode_utf_8($description); $description = htmlspecialchars_decode($description); $description = addslashes($description); $raw_tags = $ext_v_keywo[1]; $tags = ''; $tag_arr_co = explode(",", $raw_tags); for ($j=0, $m=count($tag_arr_co); $j < $m; $j++) { $row_co = $tag_arr_co[$j]; $tag_arr_sp = explode(" ", $row_co); for ($k=0, $p=count($tag_arr_sp); $k < $p; $k++) { $row_sp = $tag_arr_sp[$k]; $row_sp = hwdEncoding::charset_decode_utf_8($row_sp); $row_sp = preg_replace("/[^a-zA-Z0-9s_&#;-]/", "", $row_sp); $row_sp = hwdEncoding::charset_encode_utf_8($row_sp); if (!empty($row_sp)) { $tags.= $row_sp.","; } } } if (substr($tags, -2) == ", ") {$tags = substr($tags, 0, -2);} if (empty($title)) { $title = _HWDVIDS_UNKNOWN;} if (empty($description)) { $description = _HWDVIDS_UNKNOWN;} if (empty($tags)) { $tags = _HWDVIDS_UNKNOWN;} $_POST['video_type'] = $regs['domain']; $_POST['video_id'] = $ext_v_code[1]; if ($updatedetails == "on") { $_POST['title'] = $ext_v_title[1]; $_POST['description'] = $ext_v_descr[1]; $_POST['tags'] = $ext_v_keywo[1]; } // 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(); } else if ($video_type == 2) { $data = explode(",", $row->video_id); $thumbnail = @$data[1]; $requestarray = JRequest::get( 'default', 2 ); $videourl = $requestarray['embeddump']; $validated_video_url = hwd_vs_tools::validateUrl($videourl); if (empty($validated_video_url)) { $msg = _HWDVIDS_ALERT_VURLWRONG; $app->enqueueMessage($msg); $app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id); } $new_video_id = $validated_video_url.",".$thumbnail; $_POST['video_type'] = "remote"; $_POST['video_id'] = $new_video_id; if (empty($row->thumbnail) && !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(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } $row->checkin(); } else if ($video_type == 3) { $data = explode(",", $row->video_id); $thumbnail = @$data[1]; $requestarray = JRequest::get( 'default', 2 ); $rtmpurl = $requestarray['embeddump']; $validated_rtmpurl = hwd_vs_tools::validateUrl($rtmpurl); if (empty($validated_rtmpurl)) { $msg = _HWDVIDS_ALERT_VURLWRONG; $app->enqueueMessage($msg); $app->redirect(JURI::root( true )."/administrator/index.php?option=com_hwdvideoshare&task=editvidsA&hidemainmenu=1&cid=".$row->id); } $new_video_id = $validated_rtmpurl; $_POST['video_type'] = "rtmp"; $_POST['video_id'] = $new_video_id; if (empty($row->thumbnail) && !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(); } // store it in the db if (!$row->store()) { echo "<script type=\"text/javascript\">alert('".$row->getError()."');window.history.go(-1);</script>\n"; exit(); } $row->checkin(); } 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); $app->enqueueMessage(_HWDVIDS_ALERT_VIDSAVED); $app->redirect( JURI::root( true ) . '/administrator/index.php?option='.$option.'&task=editvidsA&hidemainmenu=1&cid='.$row->id ); }
/** * addslashes() and prevents double-quoting * * @param array $rows the list from an xml file * @return $code the array prepared for Smarty template */ function generateMetaText($receive) { $output = $receive; $output = strip_tags($output); $output = hwdEncoding::charset_encode_utf_8($output); while(strchr($output,'\"')) { $output = stripslashes($output); } $output = str_replace("\r", "", $output); $output = str_replace("\n", "", $output); $output = str_replace('"', "'", $output); return $output; }