Skip to content
This repository has been archived by the owner on Dec 1, 2022. It is now read-only.

ClipBucket-v4 #514

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions README_mass_uploader.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{\rtf1\ansi\ansicpg1252\cocoartf1504\cocoasubrtf830
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\fs24 \cf0 \
\
USE_FOR_ULTIMATE_mass_uploader.php\
\
README FILE \
\
If you are having issues with the mass_uploader.php \{newest file\} then use this one, in which it fixes the Global variable issues that are used via other Add-on/Plugins. Mostly, for Ultimate pack, I\'92m not sure if anyone has fixed this yet or notice this issue. But, it seems it hasn\'92t been fixed in 2.8.3. I\'92m hoping in the next version, someone will troubleshoot this and able to find a fix to help with other add-ons/plugins in the future. \
\
V/r\
\
Scarar\
\
}
192 changes: 192 additions & 0 deletions USE_FOR_ULTIMATE_mass_uploader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
<?php
/*
**************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
**************************************************************
*/

require_once '../includes/admin_config.php';
require_once(dirname(dirname(__FILE__))."/includes/classes/sLog.php");
$userquery->admin_login_check();
$pages->page_redir();
global $Cbucket;
$delMassUpload = config('delete_mass_upload');
/* Assigning page and subpage */
if(!defined('MAIN_PAGE')){
define('MAIN_PAGE', 'Videos');
}
if(!defined('SUB_PAGE')){
define('SUB_PAGE', 'Mass Upload Videos');
}

global $cbvid;
$cats = $cbvid->get_categories();
$total_cats = count($cats);
$category_names = array();
for ($i=0; $i < $total_cats ; $i++) {
$category_values = $cats[$i]['category_id'];
$category_names[$category_values] = $cats[$i]['category_name'];
}
//pr($category_names,true);
assign("cats",$cats);
assign("cat_values",$category_values);
assign("total_cats",$total_cats);

if(isset($_POST['mass_upload_video']))
{
$files = $cbmass->get_video_files();
$vtitle=$_POST['title'];
$total = count($_POST['mass_up']);
for($i=0;$i<$total;$i++)
{
if( !isset($_POST['filesToImport'][$i]) ) // Check if file is checked for import
continue;

$file_key = time().RandomString(5);
$file_arr = $files[$i];
$file_path = $files[$i]['path'];
$file_orgname = $files[$i]['file'];

if($cbmass->is_mass_file($file_arr))
{
$code = $i+1;
//Inserting Video Data...

if (gotPlugin('cb_multiserver.php')) {
// multiserver is installed

$uploadPath = $Cbucket->theUploaderDetails['uploadScriptPath'];
$fullFilePath = $file_arr['path'].$file_arr['file'];
//Initialise the cURL var
$ch = curl_init();

//Get the response from cURL
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the Url
curl_setopt($ch, CURLOPT_URL, $uploadPath);

//Create a POST array with the file in it
$postData = array(
'Filedata' => '@'.$fullFilePath,
);

curl_setopt($ch, CURLOPT_POSTFIELDS, $postData);

// Execute the request
$response = curl_exec($ch);
if ($response) {
$cleaned = json_decode($response,true);
$file_name = $cleaned['file_name'];
if (!empty($file_name)) {
$vCategory = $_POST['category'.$code];
if (empty($vCategory)) {
$vCategory = "#1#";
}
$array = array(
'title' => $_POST['title'][$i],
'description' => $_POST['description'][$i],
'tags' => $_POST['tags'][$i],
'category' => array($cbvid->get_default_cid()),
'file_name' => $file_name,
);

$vid = $Upload->submit_upload($array);
if ($vid) {
goto crapCleanStep;
}
} else {
e("No filename returned from server");
}
} else {
e("Error moving file : ".curl_error($ch));
}
exit("FAILED");
return false;
}

$array = array(
'title' => $_POST['title'][$i],
'description' => $_POST['description'][$i],
'tags' => $_POST['tags'][$i],
'category' => $_POST['category'.$code],
'file_name' => $file_key,
);
$vid = $Upload->submit_upload($array);
}else{
e("\"".$file_arr['title']."\" is not available");
}

if(error())
{
$error_lists[] = "Unable to upload \"".$file_arr['title']."\"";
$errors = error();
foreach($errors as $e)
$error_lists[] = $e;

$eh->flush_error();
}else{
e("\"".$file_arr['title']."\" Has been uploaded successfully","m");
}

if($vid)
{
$dosleep=0;
//Moving file to temp dir and Inserting in conversion queue..

$file_name = $cbmass->move_to_temp($file_arr,$file_key);
$file_directory = createDataFolders();
createDataFolders(LOGS_DIR);
$logFile = LOGS_DIR.'/'.$file_directory.'/'.$file_key.'.log';
//pex($logFile,true);
$log = new SLog($logFile);
$results=$Upload->add_conversion_queue($file_name);
$str = "/".date("Y")."/".date("m")."/".date("d")."/";
$str1 = date("Y")."/".date("m")."/".date("d");
mkdir(FILES_DIR.'/videos'.$str);
$tbl=tbl("video");
$fields_to_update = array();
$fields_to_update['file_directory']=$str1;
$fname=explode('.', $file_name);
$cond='file_name='.'\''.$fname[0].'\'';
$result=db_update($tbl, $fields_to_update, $cond);
$result=exec(php_path()." -q ".BASEDIR."/actions/video_convert.php {$file_name} {$file_key} {$file_directory} {$logFile} > /dev/null &");
if(file_exists(CON_DIR.'/'.$file_name))
{
unlink(CON_DIR.'/'.$file_name);
foreach ($vtitle as &$title)
{
$resul1=glob(FILES_DIR.'/videos/'.$title.".*");
unlink($resul1[0]);
}

}

crapCleanStep:
if ($delMassUpload != 'no') {
unlink($file_path.$file_orgname);
}
}
}
}

if(count($error_lists)>0)
{
foreach($error_lists as $e)
e($e);
}

//Collecting Data for Pagination
$limit = config('comments_per_page');
$total_rows=count($cbmass->get_video_files());
$total_pages = $total_rows/$limit;
$total_pages = round($total_pages+0.49,0);
$pages->paginate($total_pages,$page);

subtitle("Mass Uploader");

template_files("mass_uploader.html");
display_it();
?>