Пример #1
0
function getPostData($up_dir, $tmp_sid)
{
    $param_array = array();
    $buffer = "";
    $key = "";
    $value = "";
    $paramFileName = $up_dir . $tmp_sid . ".params";
    $fh = @fopen($paramFileName, 'r');
    if (!is_resource($fh)) {
        kak("<font color='red'>ERROR</font>: Failed to open {$paramFileName}");
    }
    while (!feof($fh)) {
        $buffer = fgets($fh, 4096);
        list($key, $value) = explode('=', trim($buffer));
        $value = str_replace("~EQLS~", "=", $value);
        $value = str_replace("~NWLN~", "\r\n", $value);
        if (isset($key) && isset($value) && strlen($key) > 0 && strlen($value) > 0) {
            if (preg_match('/(.*)\\[(.*)\\]/i', $key, $match)) {
                $param_array[$match[1]][$match[2]] = $value;
            } else {
                $param_array[$key] = $value;
            }
        }
    }
    fclose($fh);
    if (isset($param_array['delete_param_file']) && $param_array['delete_param_file'] == 1) {
        for ($i = 0; $i < 5; $i++) {
            if (@unlink($paramFileName)) {
                break;
            } else {
                sleep(1);
            }
        }
    }
    return $param_array;
}
Пример #2
0
if (!isset($form_submitted) || $form_submitted == '') {
    $blk_id = 0;
    $template = "themes/{$user_theme}/templates/inner_upload_video_response_form.htm";
    $TBS = new clsTinyButStrong();
    $TBS->NoErr = true;
    $TBS->LoadTemplate("{$template}");
    $TBS->Render = TBS_OUTPUT;
    $TBS->Show();
    @mysql_close();
    die;
}
//================================START OF UPLOAD====================================
if ($procede == true && $form_submitted == 'yes') {
    $THIS_VERSION = "2.0";
    if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
        kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION =  <b>" . $UBER_VERSION . "</b><br>UU_FILE_UPLOAD = <b>" . $THIS_VERSION . "<b><br>\n");
    }
    $tmp_sid = md5(uniqid(mt_rand(), true));
    ///////////////////////////////////////////////////////////////////////
    // This is where you might set your config file eg.                  //
    // if($_SESSION['user'] == "tom"){ $config_file = 'uu_tom_config'; } //
    ///////////////////////////////////////////////////////////////////////
    $config_file = $default_config_file;
    $path_to_upload_script .= '?tmp_sid=' . $tmp_sid;
    $path_to_ini_status_script .= '?tmp_sid=' . $tmp_sid;
    if ($MULTI_CONFIGS_ENABLED) {
        $path_to_upload_script .= "&config_file={$config_file}";
        $path_to_ini_status_script .= "&config_file={$config_file}";
    }
    $blk_id = 0;
    $template = "themes/{$user_theme}/templates/inner_upload_video_response.htm";
Пример #3
0
// Array of 'FileInfo' objects read from the $_XML_DATA array
$_FILE_DATA_TABLE = '';
// String used to store file info results nested between <tr> tags
$_FILE_DATA_EMAIL = '';
// String used to store file info results
$xml_parser = new XML_Parser();
// XML parser
$xml_parser->setXMLFile($TEMP_DIR, $_GET['upload_id']);
// Set upload_id.redirect file
$xml_parser->setXMLFileDelete($_INI['delete_redirect_file']);
// Delete upload_id.redirect file when finished parsing
$xml_parser->parseFeed();
// Parse upload_id.redirect file
// Display message if the XML parser encountered an error
if ($xml_parser->getError()) {
    kak($xml_parser->getErrorMsg(), 1, __LINE__, $_INI['path_to_css_file']);
}
$_XML_DATA = $xml_parser->getXMLData();
// Get xml data from the xml parser
$_CONFIG_DATA = getConfigData($_XML_DATA);
// Get config data from the xml data
$_POST_DATA = getPostData($_XML_DATA);
// Get post data from the xml data
$_FILE_DATA = getFileData($_XML_DATA);
// Get file data from the xml data
// Output XML DATA, CONFIG DATA, POST DATA, FILE DATA to screen and exit if DEBUG_ENABLED.
if ($_INI['debug_finished']) {
    debug("<br><u>XML DATA</u>", $_XML_DATA);
    debug("<u>CONFIG DATA</u>", $_CONFIG_DATA);
    debug("<u>POST DATA</u>", $_POST_DATA);
    debug("<u>FILE DATA</u>", $_FILE_DATA);
Пример #4
0
//***************************************************************************************************************
$THIS_VERSION = '3.0';
// Version of this file
$UPLOAD_ID = '';
// Initialize upload id
require_once 'ubr_ini.php';
require_once 'ubr_lib.php';
if ($_INI['php_error_reporting']) {
    error_reporting(E_ALL);
}
if (isset($_GET['upload_id']) && preg_match("/^[a-zA-Z0-9]{32}\$/", $_GET['upload_id'])) {
    $UPLOAD_ID = $_GET['upload_id'];
} elseif (isset($_GET['about'])) {
    kak("<u><b>UBER UPLOADER SET PROGRESS</b></u><br>UBER UPLOADER VERSION =  <b>" . $_INI['uber_version'] . "</b><br>UBR_SET_PROGRESS = <b>" . $THIS_VERSION . "<b><br>\n", 1, __LINE__, $_INI['path_to_css_file']);
} else {
    kak("<span class='ubrError'>ERROR</span>: Invalid parameters passed<br>", 1, __LINE__, $_INI['path_to_css_file']);
}
$flength_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $UPLOAD_ID . '.flength';
$hook_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $UPLOAD_ID . '.hook';
$found_flength_file = false;
$found_hook_file = false;
// Keep trying to read the flength file until timeout
for ($i = 0; $i < $_INI['flength_timeout_limit']; $i++) {
    if ($total_upload_size = readUbrFile($flength_file, $_INI['debug_ajax'])) {
        $found_flength_file = true;
        $start_time = time();
        break;
    }
    clearstatcache();
    sleep(1);
}
Пример #5
0
//
// 1. ?upload_id=32_alpha_numeric_string
// 2. ?about=1
//***************************************************************************************************************

$THIS_VERSION    = '1.3';        // Version of this file
$UPLOAD_ID = '';                 // Initialize upload id

require 'ubr_ini.php';
require 'ubr_lib.php';

if($PHP_ERROR_REPORTING){ error_reporting(E_ALL); }

if(preg_match("/^[a-zA-Z0-9]{32}$/", $_REQUEST['upload_id'])){ $UPLOAD_ID = $_GET['upload_id']; }
elseif(isset($_GET['about']) && $_GET['about'] == 1){ kak("<u><b>UBER UPLOADER SET PROGRESS</b></u><br>UBER UPLOADER VERSION =  <b>" . $UBER_VERSION . "</b><br>UBR_SET_PROGRESS = <b>" . $THIS_VERSION . "<b><br>\n", 1, __LINE__); }
else{ kak("<font color='red'>ERROR</font>: Invalid parameters passed<br>", 1, __LINE__); }

$flength_file = $TEMP_DIR . $UPLOAD_ID . '.dir/' . $UPLOAD_ID . '.flength';
$found_flength_file = false;

// Keep trying to read the flength file until timeout
for($i = 0; $i < $TIMEOUT_LIMIT; $i++){
	if(file_exists($flength_file)){
		$found_flength_file = true;
		$start_time = @filectime($flength_file);
		$fp = fopen($flength_file, "r");
		$total_upload_size = fread($fp, filesize($flength_file)); //Read the size of the upload from the flength file
		fclose($fp);
		break;
	}
	else{ sleep(1); }
Пример #6
0
//***************************************************************************************************************
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// The following possible query string formats are assumed
//
// 1. ?temp_dir_sid=path_to_temp_dir&start_time=upload_start_time&total_upload=total_upload_size&cedric_progress_bar=1or0&rnd_id=some_random_number
// 2. ?cmd=about
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//load the needed javascripts in inner_main.htm
$which_java1 = "phphomtion_uploader.js";
$which_java2 = "uploader_bar.js";
require "uploader_conlib.php";
$THIS_VERSION = "1.2";
if (isset($_GET['cmd']) && $_GET['cmd'] == 'about') {
    kak("<u><b>UBER UPLOADER GET PROGRESS BAR STATUS</b></u><br>UBER UPLOADER VERSION =  <b>" . $UBER_VERSION . "</b><br>UU_GET_STATUS = <b>" . $THIS_VERSION . "<b><br>\n");
} elseif (!isset($_GET['temp_dir_sid']) || !isset($_GET['start_time']) || !isset($_GET['total_upload_size'])) {
    kak("<font color='red'>ERROR</font>: Invalid parameters passed<br>");
}
$status = GetBytesRead($_GET['temp_dir_sid']);
$uploaded_files = $status[0];
$bRead = $status[1];
$flength_file = $_GET['temp_dir_sid'] . "/flength";
$lapsed = time() - $_GET['start_time'];
$bSpeed = 0;
$remaining = 0;
if ($lapsed > 0) {
    $bSpeed = $bRead / $lapsed;
}
if ($bSpeed > 0) {
    $remaining = round(($_GET['total_upload_size'] - $bRead) / $bSpeed);
}
//If Cedric progress bar is enabled, calculate smooth speeds
Пример #7
0
}
else{ $config_file = $DEFAULT_CONFIG; }

// Load config file
require $config_file;

//***************************************************************************************************************
// The following possible query string formats are assumed
//
// 1. No query string
// 2. ?about=1
//***************************************************************************************************************
if($DEBUG_PHP){ phpinfo(); exit(); }
elseif($DEBUG_CONFIG){ debug($_CONFIG['config_file_name'], $_CONFIG); exit(); }
elseif(isset($_GET['about']) && $_GET['about'] == 1){
	kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION =  " . $UBER_VERSION . "<br>UBR_FILE_UPLOAD = " . $THIS_VERSION . "<br>\n", 1, __LINE__);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <title>Uber-Uploader - Free File Upload Progress Bar</title>
  <meta http-equiv="content-type" content="text/html; charset=utf-8">
  <meta http-equiv="pragma" content="no-cache">
  <meta http-equiv="cache-control" content="no-cache">
  <meta http-equiv="expires" content="-1">
  <meta name="robots" content="index,nofollow">
  <!-- Please do not remove this tag: Uber-Uploader Ver 6.3.1 http://uber-uploader.sourceforge.net -->
  <style>
    .debug {font:16px Arial; background-color:#FFFFFF; border:1px solid #898989; width:700px; height:100px; overflow:auto;}
Пример #8
0
//Declare local values
$_XML_DATA = array();                                          // Array of xml data read from the upload_id.redirect file
$_CONFIG_DATA = array();                                       // Array of config data read from the $_XML_DATA array
$_POST_DATA = array();                                         // Array of posted data read from the $_XML_DATA array
$_FILE_DATA = array();                                         // Array of 'FileInfo' objects read from the $_XML_DATA array
$_FILE_DATA_TABLE = '';                                        // String used to store file info results nested between <tr> tags
$_FILE_DATA_EMAIL = '';                                        // String used to store file info results

$xml_parser = new XML_Parser;                                  // XML parser
$xml_parser->setXMLFile($TEMP_DIR, $_REQUEST['upload_id']);    // Set upload_id.redirect file
$xml_parser->setXMLFileDelete($DELETE_REDIRECT_FILE);          // Delete upload_id.redirect file when finished parsing
$xml_parser->parseFeed();                                      // Parse upload_id.redirect file

// Display message if the XML parser encountered an error
if($xml_parser->getError()){ kak($xml_parser->getErrorMsg(), 1, __LINE__); }

$_XML_DATA = $xml_parser->getXMLData();                        // Get xml data from the xml parser
$_CONFIG_DATA = getConfigData($_XML_DATA);                     // Get config data from the xml data
$_POST_DATA  = getPostData($_XML_DATA);                        // Get post data from the xml data
$_FILE_DATA = getFileData($_XML_DATA);                         // Get file data from the xml data


// Output XML DATA, CONFIG DATA, POST DATA, FILE DATA to screen and exit if DEBUG_ENABLED.
if($DEBUG_FINISHED){
	debug("<br><u>XML DATA</u>", $_XML_DATA);
	debug("<u>CONFIG DATA</u>", $_CONFIG_DATA);
	debug("<u>POST DATA</u>", $_POST_DATA);
	debug("<u>FILE DATA</u><br>", $_FILE_DATA);
	exit;
}
Пример #9
0
// Load config file
require_once $config_file;
//***************************************************************************************************************
//	The following possible query string formats are assumed
//
//	1. No query string
//	2. ?about
//***************************************************************************************************************
if ($_INI['debug_php']) {
    phpinfo();
    exit;
} elseif ($_INI['debug_config']) {
    debug($_CONFIG['config_file_name'], $_CONFIG);
    exit;
} elseif (isset($_GET['about'])) {
    kak("<u><b>UBER UPLOADER FILE UPLOAD</b></u><br>UBER UPLOADER VERSION =  <b>" . $_INI['uber_version'] . "</b><br>UBR_FILE_UPLOAD = <b>" . $THIS_VERSION . "</b><br>\n", 1, __LINE__, $_INI['path_to_css_file']);
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Uber-Uploader - Free File Upload Progress Bar</title>
		<meta http-equiv="content-type" content="text/html; charset=utf-8">
		<meta http-equiv="expires" content="-1">
		<meta name="robots" content="index,nofollow">
		<!-- Please do not remove this tag: Uber-Uploader Ver 6.8 http://uber-uploader.sourceforge.net -->
		<link rel="stylesheet" type="text/css" href="<?php 
print $_INI['path_to_css_file'];
?>
">
		<script language="JavaScript" type="text/JavaScript" src="<?php 
Пример #10
0
// The following possible query string formats are assumed
//
// 1. No query string
// 2. ?config_file=config_file_name
// 3. ?about=1
//***************************************************************************************************************

$THIS_VERSION = '1.4';         // Version of this file
$UPLOAD_ID = '';               // Initialize upload id

require 'ubr_ini.php';
require 'ubr_lib.php';

if($PHP_ERROR_REPORTING){ error_reporting(E_ALL); }

if(isset($_GET['about']) && $_GET['about'] == 1){ kak("<u><b>UBER UPLOADER LINK UPLOAD</b></u><br>UBER UPLOADER VERSION =  <b>" . $UBER_VERSION . "</b><br>UBR_LINK_UPLOAD = <b>" . $THIS_VERSION . "<b><br>\n", 1, __LINE__); }
else{
	////////////////////////////////////////////////////////////////////////
	//                           * ATTENTION *
	//         THIS IS A GOOD PLACE TO PUT YOUR AUTHENTICATION CODE
	////////////////////////////////////////////////////////////////////////
}

// Find config file name if multi configs is enabled else load default config
if($MULTI_CONFIGS_ENABLED){
	if(isset($_GET['config_file']) && strlen($_GET['config_file']) > 0){ $config_file = $_GET['config_file']; }
	else{ showAlertMessage("<font color='red'>ERROR</font>: Failed to find config_file parameter", 1); }
}
else{ $config_file = $DEFAULT_CONFIG; }

// Load config file
Пример #11
0
    /**
     * Outputs frontpage HTML
     *
     * @return       Nothing
     */
    function uploadConfirmPerl()
	{
	global $database, $my, $acl, $mosConfig_absolute_path, $mosConfig_mailfrom, $mosConfig_fromname, $mosConfig_live_site, $Itemid, $mosConfig_sitename;

	$c = hwd_vs_Config::get_instance();
	$db = & JFactory::getDBO();
	$my = & JFactory::getUser();
	$acl= & JFactory::getACL();

	// get server configuration data
	require_once(JPATH_SITE.DS.'administrator'.DS.'components'.DS.'com_hwdvideoshare'.DS.'serverconfig.hwdvideoshare.php');
	$s = hwd_vs_SConfig::get_instance();

	//******************************************************************************************************
	//   ATTENTION: THIS FILE HEADER MUST REMAIN INTACT. DO NOT DELETE OR MODIFY THIS FILE HEADER.
	//
	//   Name: ubr_finished.php
	//   Revision: 1.3
	//   Date: 2/18/2008 5:36:57 PM
	//   Link: http://uber-uploader.sourceforge.net
	//   Initial Developer: Peter Schmandra  http://www.webdice.org
	//   Description: Show successful file uploads.
	//
	//   Licence:
	//   The contents of this file are subject to the Mozilla Public
	//   License Version 1.1 (the "License"); you may not use this file
	//   except in compliance with the License. You may obtain a copy of
	//   the License at http://www.mozilla.org/MPL/
	//
	//   Software distributed under the License is distributed on an "AS
	//   IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
	//   implied. See the License for the specific language governing
	//   rights and limitations under the License.
	//
	//***************************************************************************************************************

	//***************************************************************************************************************
	// The following possible query string formats are assumed
	//
	// 1. ?upload_id=upload_id
	// 2. ?about=1
	//****************************************************************************************************************

	$THIS_VERSION = "1.3";                                // Version of this file
	$UPLOAD_ID = '';                                      // Initialize upload id

	require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'assets'.DS.'uploads'.DS.'perl'.DS.'ubr_ini.php');
	require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'assets'.DS.'uploads'.DS.'perl'.DS.'ubr_lib.php');
	require_once(JPATH_SITE.DS.'components'.DS.'com_hwdvideoshare'.DS.'assets'.DS.'uploads'.DS.'perl'.DS.'ubr_finished_lib.php');

	if($PHP_ERROR_REPORTING){ error_reporting(E_ALL); }

	header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
	header('Last-Modified: '.date('r'));
	header('Cache-Control: no-store, no-cache, must-revalidate');
	header('Cache-Control: post-check=0, pre-check=0', FALSE);
	header('Pragma: no-cache');

	if(preg_match("/^[a-zA-Z0-9]{32}$/", $_GET['upload_id'])){ $UPLOAD_ID = $_GET['upload_id']; }
	elseif(isset($_GET['about']) && $_GET['about'] == 1){ kak("<u><b>UBER UPLOADER FINISHED PAGE</b></u><br>UBER UPLOADER VERSION =  <b>" . $UBER_VERSION . "</b><br>UBR_FINISHED = <b>" . $THIS_VERSION . "<b><br>\n", 1 , __LINE__); }
	else{ kak("<font color='red'>ERROR</font>: Invalid parameters passed<br>", 1, __LINE__); }

	//Declare local values
	$_XML_DATA = array();                                          // Array of xml data read from the upload_id.redirect file
	$_CONFIG_DATA = array();                                       // Array of config data read from the $_XML_DATA array
	$_POST_DATA = array();                                         // Array of posted data read from the $_XML_DATA array
	$_FILE_DATA = array();                                         // Array of 'FileInfo' objects read from the $_XML_DATA array
	$_FILE_DATA_TABLE = '';                                        // String used to store file info results nested between <tr> tags
	$_FILE_DATA_EMAIL = '';                                        // String used to store file info results

	$xml_parser = new XML_Parser;                                  // XML parser
	$xml_parser->setXMLFile($TEMP_DIR, $_REQUEST['upload_id']);    // Set upload_id.redirect file
	$xml_parser->setXMLFileDelete($DELETE_REDIRECT_FILE);          // Delete upload_id.redirect file when finished parsing
	$xml_parser->parseFeed();                                      // Parse upload_id.redirect file

	// Display message if the XML parser encountered an error
	if($xml_parser->getError()){ kak($xml_parser->getErrorMsg(), 1, __LINE__); }

	$_XML_DATA = $xml_parser->getXMLData();                        // Get xml data from the xml parser
	$_CONFIG_DATA = getConfigData($_XML_DATA);                     // Get config data from the xml data
	$_POST_DATA  = getPostData($_XML_DATA);                        // Get post data from the xml data
	$_FILE_DATA = getFileData($_XML_DATA);                         // Get file data from the xml data

	// Output XML DATA, CONFIG DATA, POST DATA, FILE DATA to screen and exit if DEBUG_ENABLED.
	if($DEBUG_FINISHED){
		debug("<br><u>XML DATA</u>", $_XML_DATA);
		debug("<u>CONFIG DATA</u>", $_CONFIG_DATA);
		debug("<u>POST DATA</u>", $_POST_DATA);
		debug("<u>FILE DATA</u><br>", $_FILE_DATA);
		exit;
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////
	//
	//           *** ATTENTION: ENTER YOUR CODE HERE !!! ***
	//
	// This is a good place to put your post upload code. Like saving the
	// uploaded file information to your DB or doing some image
	// manipulation. etc. Everything you need is in the
	// $XML DATA, $_CONFIG_DATA, $_POST_DATA and $_FILE_DATA arrays.
	//
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// NOTE: You can now access all XML values below this comment. eg.
	//   $_XML_DATA['upload_dir']; or $_XML_DATA['link_to_upload'] etc
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// NOTE: You can now access all config values below this comment. eg.
	//   $_CONFIG_DATA['upload_dir']; or $_CONFIG_DATA['link_to_upload'] etc
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// NOTE: You can now access all post values below this comment. eg.
	//   $_POST_DATA['client_id']; or $_POST_DATA['check_box_1_'] etc
	/////////////////////////////////////////////////////////////////////////////////////////////////
	// NOTE: You can now access all file (slot, name, size, type) info below this comment. eg.
	//   $_FILE_DATA[0]->name  or  $_FILE_DATA[0]->getFileInfo('name')
	/////////////////////////////////////////////////////////////////////////////////////////////////

	///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	// Create thumnail example  (must uncomment line 34)
	// if( $_FILE_DATA[0]->type  == 'image/jpeg'){ $success = createThumbFile($_CONFIG_DATA['upload_dir'],  $_FILE_DATA[0]->name, $_CONFIG_DATA['upload_dir'],  120,  100);  }
	////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

	//Create file upload table
	$_FILE_DATA_TABLE = getFileDataTable($_FILE_DATA, $_CONFIG_DATA);

	// Create and send email
	if($_CONFIG_DATA['send_email_on_upload']){ emailUploadResults($_FILE_DATA, $_CONFIG_DATA, $_POST_DATA); }

		$file_name = $_FILE_DATA[0]->name;
		$file_ext = substr($file_name, strrpos($file_name, '.') + 1);
		$file_ext = strtolower($file_ext);
		$file_video_name = $file_name;
		$file_video_id = substr($file_name, 0, -(strlen($file_ext)+1));

		$title 				= hwd_vs_tools::generatePostTitle($_POST_DATA['title']);
		$description 		= hwd_vs_tools::generatePostDescription($_POST_DATA['description']);
		$tags 				= hwd_vs_tools::generatePostTags($_POST_DATA['tags']);
		$category_id 		= intval ($_POST_DATA['category_id']);
		$public_private 	= $_POST_DATA['public_private'];
		$allow_comments 	= intval ($_POST_DATA['allow_comments']);
		$allow_embedding 	= intval ($_POST_DATA['allow_embedding']);
		$allow_ratings 		= intval ($_POST_DATA['allow_ratings']);

		$checkform = hwd_vs_tools::checkFormComplete($title, $description, $category_id, $tags, $public_private, $allow_comments, $allow_embedding, $allow_ratings);
		if (!$checkform) { return; }

		// initialise database
		$row = new hwdvids_video($db);

		if ($file_ext == "swf") {
			$_POST['video_type'] 		= "swf";
		} else if ($file_ext == "mp4") {
			$_POST['video_type'] 		= "mp4";
		} else {
			$_POST['video_type'] 		= "local";
		}

		$password = $_POST_DATA['hwdvspassword'];
		if (!empty($password))
		{
			$_POST['password'] 		= $password;
		}

		$_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['date_uploaded'] 	= date('Y-m-d H:i:s');
		$_POST['user_id'] 			= $my->id;
		$_POST['published'] 		= 1;

		if ($c->requiredins == 1) {
			$_POST['video_id'] 		= $file_video_name;
			// check if we are reprocessing
			if ($c->reconvertflv == 0) {
				if ($file_ext == "flv") {
					$_POST['approved'] = "queuedforthumbnail";
				} else if ($file_ext == "swf") {
					$_POST['approved'] = "queuedforswf";
				} else if ($file_ext == "mp4") {
					$_POST['approved'] = "queuedformp4";
				} else {
					$_POST['approved'] = "queuedforconversion";
				}
			} else {
				if ($file_ext == "swf") {
					$_POST['approved'] = "queuedforswf";
				} else if ($file_ext == "mp4") {
					$_POST['approved'] = "queuedformp4";
				} else {
					$_POST['approved'] = "queuedforconversion";
				}
			}
		} else if ($c->requiredins == 0) {

			$originals_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS.'originals'.DS;
			$base_Dir = JPATH_SITE.DS.'hwdvideos'.DS.'uploads'.DS;

			if ($file_ext !== "flv" && $file_ext !== "mp4" && $file_ext !== "swf") {
				hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR04, "exclamation.png", 0);
				return;
			}

			if (!copy($originals_Dir.$file_name, $base_Dir.$file_video_id.".".strtolower($file_ext))) {

        		hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR01, "exclamation.png", 0);
				return;

			} else {

				if ($c->deleteoriginal == 1) {
					if (file_exists($base_Dir.$file_name)) {
						@unlink($originals_Dir.$file_name);
					}
				}

				if ($c->aav == 1) {
					$_POST['approved'] = "yes";
				} else {
					$_POST['approved'] = "pending";
				}
			}

			$_POST['video_id'] 		= $file_video_id;

		}

		//check if already exists
		$db->SetQuery( 'SELECT count(*)'
						. ' FROM #__hwdvidsvideos'
						. ' WHERE video_id = "'.$file_video_id.'"'
						);
		$duplicatecount = $db->loadResult();
		if ($duplicatecount > 0) {
        	hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR01, "exclamation.png", 0);
			return;
		}

		if(empty($_POST['video_id'])) {
        	hwd_vs_tools::infomessage(4, 0, _HWDVIDS_TITLE_UPLDFAIL, _HWDVIDS_ERROR_UPLDERR01, "exclamation.png", 0);
			return;
		}

		// 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);

		hwd_vs_html::uploadConfirm($title, $row);
	}
Пример #12
0
function ExecActions($action)
{
    /*=============*/
    Lib_myLog("action: ", $action);
    // On recupere la configuration issue de conf.php
    global $lang, $MSG, $secure;
    // On recupere tous les objet contenant les donnees
    global $data_in, $data_out, $data_srv, $session;
    // Initialization des variables
    global $message;
    switch ($action) {
        case "Admin_Utilisateurs":
            /*=============*/
            Lib_myLog("Recuperation de la liste des utilisateurs de la base");
            $data_out['tab_groupes'] = Groupes_chercher('*');
            $data_out['liste_utilisateurs'] = Utilisateurs_chercher('*');
            // On renseigne l'indicateur "code" pour piloter l'affichage du menu javascript
            $data_out['code'] = 'acces_client';
            $data_out['page'] = 'acces.php';
            break;
        case "Utilisateurs_ADD":
            $F5 = Lib_checkF5($session, $data_in['timestamp']);
            $continue = $F5 ? false : true;
            // On intialise une pseudo-transaction qui nous permettre de stocker tous les objets rajoutés à la base
            // pour pouvoir les supprimer si nécessaire
            $transaction = new Collection();
            if ($continue) {
                $utilisateur = Utilisateur_recuperer($data_in['nom_utilisateur']);
                if ($continue && $utilisateur->id_utilisateur) {
                    /*=============*/
                    Lib_myLog("Le code d'utilisateur existe deja");
                    $data_out['message_ko'] = 'Ce code utilisateur existe d&eacute;j&agrave';
                    $continue = false;
                }
                if ($continue) {
                    /*=============*/
                    Lib_myLog("Creation nouvel objet Utilisateur");
                    $utilisateur = new Utilisateur();
                    $utilisateur->societe = $data_in['societe'];
                    $utilisateur->nom_personne = $data_in['nom_personne'];
                    $utilisateur->prenom_personne = $data_in['prenom_personne'];
                    $utilisateur->email = $data_in['email'];
                    $utilisateur->nom_utilisateur = $data_in['nom_utilisateur'];
                    $utilisateur->nom_groupe = 'utilisateur';
                    $utilisateur->password = $data_in['password'];
                    $utilisateur->nb_connect = 10;
                    $utilisateur->etat = 'actif';
                    $id_utilisateur = $utilisateur->ADD();
                    /*=============*/
                    Lib_myLog("Creation d'un repertoire pour l'utilisateur");
                    mkdir("../../documents/{$id_utilisateur}");
                    chmod("../../documents/{$id_utilisateur}", 0705);
                    // On créé un fichier d'index pour que personne ne puisse voir directement le contenu du répertoire
                    $file = "../../documents/{$id_utilisateur}/index.php";
                    $index = fopen($file, "w");
                    fputs($index, "<?");
                    fputs($index, "header('HTTP/1.0 404 Not Found');");
                    fputs($index, "?>");
                    fclose($index);
                }
            }
            if ($continue) {
                $data_out['message_ok'] = "L'acc&eacute;s a bien &eacute;t&eacute; rajout&eacute;";
                ExecActions('Admin_Utilisateurs');
            } else {
                if ($F5) {
                    /*=============*/
                    Lib_myLog("Tentative de F5!");
                    $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Revalidation%%'];
                    ExecActions('Admin_Utilisateurs');
                } else {
                    /*=============*/
                    Lib_myLog("Annulation de l'ajout suite a une erreur");
                    if (!isset($data_out['message_ko'])) {
                        $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Mysql%%'];
                    }
                    // On ré-affiche les données dans la page de saisie...
                    $data_out = array_merge($data_out, $data_in);
                    ExecActions('Admin_Utilisateurs');
                }
            }
            break;
        case "Utilisateurs_UPD":
            /*=============*/
            Lib_myLog("Mise a jour de l'utilisateur");
            $utilisateur = Utilisateur_recuperer($data_in['id_utilisateur']);
            $utilisateur->societe = $data_in['societe'];
            $utilisateur->nom_personne = $data_in['nom_personne'];
            $utilisateur->prenom_personne = $data_in['prenom_personne'];
            $utilisateur->email = $data_in['email'];
            $utilisateur->nom_utilisateur = $data_in['nom_utilisateur'];
            $utilisateur->password = $data_in['password'];
            $utilisateur->UPD();
            $data_out['message_ok'] = "L'utilisateur a bien &eacute;t&eacute; mis &agrave; jour";
            ExecActions("Admin_Utilisateurs");
            break;
        case "Utilisateurs_DEL":
            /*=============*/
            Lib_myLog("Suppression de l'utilisateur avec l'identifiant " . $data_in['id_utilisateur'] . " de la base");
            $utilisateur = Utilisateur_recuperer($data_in['id_utilisateur']);
            $utilisateur->DEL();
            /*=============*/
            Lib_myLog("Suppression du repertoire de l'utilisateur");
            deldir("../../documents/" . $utilisateur->id_utilisateur);
            $data_out['message_ok'] = "L'utilisateur a bien &eacute;t&eacute; &eacute;t&eacute; supprim&eacute;";
            ExecActions("Admin_Utilisateurs");
            break;
        case "POPUP_Utilisateur_UPD":
            // Action utilisée pour la saisie semi-automatique et appelée par la fonction AJAX
            /*=============*/
            Lib_myLog("Recuperation de l'utilisateur");
            $data_out = Utilisateurs_chercher('', $data_in['id_utilisateur']);
            $data_out['tab_groupes'] = Groupes_chercher('*');
            $data_out['page'] = 'acces_popup_utilisateur_upd.php';
            break;
        case "Documents_Accueil":
            /*=============*/
            Lib_myLog("Recuperation de l'arborescence");
            $data_out['liste_fils'] = Docs_construire($data_in['id_utilisateur']);
            $utilisateur = Utilisateur_recuperer($data_in['id_utilisateur']);
            $data_out['nom_personne'] = $utilisateur->nom_personne;
            $data_out['prenom_personne'] = $utilisateur->prenom_personne;
            $data_out['id_utilisateur'] = $data_in['id_utilisateur'];
            // On positionne par défaut les id_pere et les id_grand_pere
            $data_out['id_pere'] = 0;
            $data_out['id_fils'] = 0;
            if (isset($data_in['id_doc'])) {
                /*=============*/
                Lib_myLog("Recuperation de l'ascendance");
                $doc = Doc_recuperer($data_in['id_doc']);
                /*=============*/
                Lib_myLog("Famille: " . $doc->famille);
                $tab_famille = explode('-', $doc->famille);
                /*=============*/
                Lib_myLog("Nb elements: " . count($tab_famille));
                if (count($tab_famille) == 2) {
                    $data_out['id_pere'] = $tab_famille[0];
                }
                if (count($tab_famille) == 3) {
                    $data_out['id_pere'] = $tab_famille[0];
                    $data_out['id_fils'] = $tab_famille[1];
                }
            }
            // On renseigne l'indicateur "code" pour piloter l'affichage du menu javascript
            $data_out['code'] = 'acces_client';
            $data_out['page'] = 'documents.php';
            break;
        case "Element_Bouger":
            $tab_positions = explode("|", $data_in['tab_list']);
            $i = 1;
            foreach ($tab_positions as $position) {
                $projet = Doc_recuperer($position);
                $projet->ordre = $i;
                $projet->UPD();
                $i++;
            }
            $data_out['message_ok'] = $MSG['fr']['%%arbo_UPD%%'];
            ExecActions('Documents_Accueil');
            break;
        case "Element_DEL":
            /*=============*/
            Lib_myLog("Recuperation de l'element");
            $obj_element_initial = Doc_recuperer($data_in['id_doc']);
            $id_utilisateur = $obj_element_initial->id_utilisateur;
            $data_out['message_ok'] = "Le dossier a bien &eacute;t&eacute; supprim&eacute;";
            if ($obj_element_initial->type_pere == 'document') {
                $url = $obj_element_initial->intitule_canonize;
                /*=============*/
                Lib_myLog("Suppression physique du document");
                unlink("../../documents/{$id_utilisateur}/{$url}");
                $data_out['message_ok'] = "Le document a bien &eacute;t&eacute supprim&eacute";
            }
            /*=============*/
            Lib_myLog("Retablissement de l'ordre sans coupure");
            $args_elements['famille'] = $obj_element_initial->famille;
            $args_elements['sup_ordre'] = $obj_element_initial->ordre;
            $args_elements['id_utilisateur'] = $obj_element_initial->id_utilisateur;
            $elements = Docs_chercher($args_elements);
            foreach ($elements as $element) {
                $obj_element = Doc_recuperer($element['id_doc']);
                $obj_element->ordre--;
                $obj_element->UPD();
            }
            $obj_element_initial->DEL();
            $data_in['id_utilisateur'] = $id_utilisateur;
            ExecActions('Documents_Accueil');
            break;
        case "Categorie_ADD":
            $args_arbos['famille'] = '';
            if ($data_in['id_pere'] != '') {
                /*=============*/
                Lib_myLog("Il s'agit d'un ajout de sous-element !");
                $arbo_pere = Doc_recuperer($data_in['id_pere']);
                $args_arbos['famille'] = $arbo_pere->famille . $arbo_pere->id_pere . '-';
            }
            /*=============*/
            Lib_myLog("On determine le nouvel ordre a attribuer au nouvel element");
            $arbos = Docs_chercher($args_arbos);
            $ordre = count($arbos);
            $ordre++;
            /*=============*/
            Lib_myLog("Rajout d'un nouvel element");
            $arbo = new Doc();
            $arbo->id_utilisateur = $data_in['id_utilisateur'];
            if ($data_in['id_pere'] != '') {
                $arbo->famille .= $arbo_pere->famille . $arbo_pere->id_pere . '-';
            }
            $arbo->type_pere = 'arbo';
            $arbo->ordre = $ordre;
            $arbo->etat = 'actif';
            $arbo->intitule = $data_in['intitule'];
            $id_doc = $arbo->ADD();
            // On positionne dans le "data_in" "id_doc" pour piloter l'affichage dans "Documents_Accueil"
            $data_in['id_doc'] = $id_doc;
            $data_out['message_ok'] = "Le dossier a bien &eacute;t&eacute; rajout&eacute;";
            $arbo->id_pere = $id_doc;
            $arbo->UPD();
            ExecActions('Documents_Accueil');
            break;
        case "Categorie_UPD":
            /*=============*/
            Lib_myLog("Modification de l'intitule d'un element");
            $arbo = Doc_recuperer($data_in['id_doc']);
            $arbo->intitule = $data_in['intitule'];
            $arbo->UPD();
            $data_out['message_ok'] = "Le nom du dossier a bien &eacute;t&eacute; modifi&eacute;";
            ExecActions('Documents_Accueil');
            break;
        case "AJAX_RechercherSousCategories":
            $data_out['liste_sous_categories'] = array();
            /*=============*/
            Lib_myLog("Recuperation du pere");
            $arbo_pere = Doc_recuperer($data_in['id_pere']);
            $args_sous['type_pere'] = 'arbo';
            $args_sous['famille'] = $arbo_pere->famille . $arbo_pere->id_pere . '-';
            $data_out['liste_sous_categories'] = Docs_chercher($args_sous);
            $cle = 'ordre';
            $val = usort($data_out['liste_sous_categories'], "Lib_compareUp");
            $data_out['page'] = 'ajax_sous_categories.php';
            break;
        case "Fichier_ADD":
            // DEBUT UBR
            // Je déclare en global les variables suivante intialisées lors du chargement des bibliothèques UBR
            global $TEMP_DIR, $_INI;
            //Declare local values
            $_XML_DATA = array();
            // Array of xml data read from the upload_id.redirect file
            $_CONFIG_DATA = array();
            // Array of config data read from the $_XML_DATA array
            $_POST_DATA = array();
            // Array of posted data read from the $_XML_DATA array
            $_FILE_DATA = array();
            // Array of 'FileInfo' objects read from the $_XML_DATA array
            $_FILE_DATA_TABLE = '';
            // String used to store file info results nested between <tr> tags
            $_FILE_DATA_EMAIL = '';
            // String used to store file info results
            $xml_parser = new XML_Parser();
            // XML parser
            $xml_parser->setXMLFile($TEMP_DIR, $_GET['upload_id']);
            // Set upload_id.redirect file
            $xml_parser->setXMLFileDelete($_INI['delete_redirect_file']);
            // Delete upload_id.redirect file when finished parsing
            $xml_parser->parseFeed();
            // Parse upload_id.redirect file
            // Display message if the XML parser encountered an error
            if ($xml_parser->getError()) {
                kak($xml_parser->getErrorMsg(), 1, __LINE__, $_INI['path_to_css_file']);
            }
            $_XML_DATA = $xml_parser->getXMLData();
            // Get xml data from the xml parser
            $_CONFIG_DATA = getConfigData($_XML_DATA);
            // Get config data from the xml data
            $_POST_DATA = getPostData($_XML_DATA);
            // Get post data from the xml data
            $_FILE_DATA = getFileData($_XML_DATA);
            // Get file data from the xml data
            /*=============*/
            Lib_myLog("UBR POST DATA :", $_POST_DATA);
            // On remet dans data_in les valeurs transmises par UBR
            foreach ($_POST_DATA as $key => $value) {
                $data_in[$key] = $value;
            }
            // On récupère les fichiers téléchargés
            for ($i = 0; $i < count($_FILE_DATA); $i++) {
                $file_slot = $_FILE_DATA[$i]->getFileInfo('slot');
                $file_name = $_FILE_DATA[$i]->getFileInfo('name');
                $file_size = $_FILE_DATA[$i]->getFileInfo('size');
                $file_type = $_FILE_DATA[$i]->getFileInfo('type');
                $file_status = $_FILE_DATA[$i]->getFileInfo('status');
                $file_status_desc = $_FILE_DATA[$i]->getFileInfo('status_desc');
                /*=============*/
                Lib_myLog("UBR Fichier telecharge : file_slot: {$file_slot}, file_name: {$file_name}, file_size: {$file_size}, file_type: {$file_type}, file_status: {$file_status}, file_status_desc: {$file_status_desc}");
            }
            // FIN UBR
            $F5 = Lib_checkF5($session, $data_in['timestamp']);
            $continue = $F5 ? false : true;
            if ($continue) {
                $args_arbos['famille'] = '';
                if ($data_in['id_pere'] != 0) {
                    $arbo = Doc_recuperer($data_in['id_pere']);
                    $args_arbos['famille'] = $arbo->famille . $arbo->id_pere . '-';
                    $args_arbo['id_doc'] = $data_in['id_pere'];
                    $id_categorie = $data_in['id_pere'];
                }
                // Si l'id_fils est positionné, il "surclasse" l'id_pere!
                if (isset($data_in['id_fils']) && $data_in['id_fils'] != 0) {
                    $arbo = Doc_recuperer($data_in['id_fils']);
                    $args_arbos['famille'] = $arbo->famille . $arbo->id_pere . '-';
                    $args_arbo['id_doc'] = $data_in['id_fils'];
                }
                /*=============*/
                Lib_myLog("On determine le nouvel ordre a attribuer au nouvel element dans l'arbo");
                $arbos = Docs_chercher($args_arbos);
                $ordre = count($arbos);
                $ordre++;
                /*=============*/
                Lib_myLog("On recupere le dossier dont va dependre le document");
                $arbo = Docs_chercher($args_arbo);
                if ($continue && $file_name != '') {
                    /*=============*/
                    Lib_myLog("Recuperation du fichier");
                    $nom_fichier = Lib_nettoie($file_name);
                    /*=============*/
                    Lib_myLog("Nom du fichier : {$nom_fichier}");
                    // On rajoute le document à ce niveau pour disposer de l'id_doc et le mettre dans le nom du document
                    /*=============*/
                    Lib_myLog("Rajout du document dans l'arbo");
                    $new_arbo = new Doc();
                    $new_arbo->id_utilisateur = $data_in['id_utilisateur'];
                    $new_arbo->famille .= $arbo['famille'] . $arbo['id_pere'] . '-';
                    $new_arbo->type_pere = 'document';
                    $new_arbo->ordre = $ordre;
                    $new_arbo->etat = 'actif';
                    $new_arbo->intitule = $data_in['intitule'];
                    $new_arbo->intitule_canonize = $nom_fichier;
                    $id_doc = $new_arbo->ADD();
                    $data_in['id_doc'] = $id_doc;
                    $nom_fichier = $id_doc . '_' . $nom_fichier;
                    $doc = Doc_recuperer($id_doc);
                    $doc->intitule_canonize = $nom_fichier;
                    $doc->UPD();
                    // On met le fichier récupéré avec UBR au bon endroit
                    rename("../ubr/ubr_uploads/{$file_name}", "../../documents/{$data_in['id_utilisateur']}/{$nom_fichier}");
                    $data_out['message_ok'] = "Le document a bien &eacute;t&eacute; rajout&eacute;";
                }
            }
            if ($continue) {
                ExecActions('Documents_Accueil');
            } else {
                if ($F5) {
                    /*=============*/
                    Lib_myLog("Tentative de F5!");
                    $data_out['message_ko'] = $MSG[$lang]['%%Erreur_Revalidation%%'];
                    ExecActions('Documents_Accueil');
                } else {
                    ExecActions('Documents_Accueil');
                }
            }
            break;
        case "Fichier_UPD":
            /*=============*/
            Lib_myLog("Modification de l'intitule du fichier");
            $arbo = Doc_recuperer($data_in['id_doc']);
            $arbo->intitule = $data_in['intitule'];
            $arbo->UPD();
            $data_out['message_ok'] = "La description du document a bien &eacute;t&eacute; modifi&eacute;e";
            ExecActions('Documents_Accueil');
            break;
        case "Fichier_Download":
            $doc = Doc_recuperer($data_in['id_doc']);
            $nom_fichier = $doc->intitule_canonize;
            $file = "../../documents/" . $doc->id_utilisateur . "/" . $doc->intitule_canonize;
            $size = filesize($file);
            header("Content-Type: application/octet-stream");
            header("Content-Length: {$size}");
            header("Content-Disposition: attachment; filename={$nom_fichier}");
            header("Content-Transfer-Encoding: binary");
            $fh = fopen("{$file}", "r");
            fpassthru($fh);
            break;
        default:
            ExecActions('Admin_Utilisateurs');
            break;
    }
}