Added : 2.7 @trunk

This commit is contained in:
Fawaz 2013-10-07 12:17:06 +00:00
parent 2ca6204e5b
commit e3b2b6aad9
1278 changed files with 114287 additions and 0 deletions

112
upload/.htaccess Normal file
View file

@ -0,0 +1,112 @@
#<IfModule mod_security.c>
# secfilterengine off
# secfilterscanPOST off
#</IfModule>
Options All -Indexes
FileETag MTime Size
Options +FollowSymlinks
RewriteEngine on
<FilesMatch "\.(db|inc|tmpl|h|ihtml|sql|ini|configuration|config|class|bin|spd|theme|module|cfg|cpl|tmp|log|err|inc.php|class.php)$">
order allow,deny
satisfy all
</FilesMatch>
########## Begin - Rewrite rules to block out some common exploits
#
# Block out any script trying to set a mosConfig value through the URL
RewriteCond %{QUERY_STRING} mosConfig_[a-zA-Z_]{1,21}(=|\%3D) [OR]
# Block out any script trying to base64_encode crap to send via URL
RewriteCond %{QUERY_STRING} base64_encode.*\(.*\) [OR]
# Block out any script that includes a <script> tag in URL
RewriteCond %{QUERY_STRING} (\<|%3C).*script.*(\>|%3E) [NC,OR]
# Block out any script trying to set a PHP GLOBALS variable via URL
RewriteCond %{QUERY_STRING} GLOBALS(=|\[|\%[0-9A-Z]{0,2}) [OR]
# Block out any script trying to modify a _REQUEST variable via URL
RewriteCond %{QUERY_STRING} _REQUEST(=|\[|\%[0-9A-Z]{0,2})
# Send all blocked request to homepage with 403 Forbidden error!
#RewriteRule ^(.*)$ index.php [L]
RewriteRule ^([^.]*)/?$ index.php [L]
#
########## End - Rewrite rules to block out some common exploits
RewriteEngine on
#
#
#
#URL Rewriting for Videos
RewriteRule ^videos/(.*)/(.*)/(.*)/(.*)/(.*) videos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^videos/([0-9]+) videos.php?page=$1 [L]
RewriteRule ^videos/?$ videos.php?%{QUERY_STRING} [L]
RewriteRule ^video/(.*)/(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]
#Alternate watch video links
RewriteRule ^(.*)\_v([0-9]+) watch_video.php?v=$2&%{QUERY_STRING} [L]
RewriteRule ^video/([0-9]+)_(.*) watch_video.php?v=$1&%{QUERY_STRING} [L]
#
#Users, Channel & Management
#
RewriteRule ^channels/(.*)/(.*)/(.*)/(.*)/(.*) channels.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^channels/([0-9]+) channels.php?page=$1 [L]
RewriteRule ^channels/?$ channels.php [L]
RewriteRule ^members/?$ channels.php [nc]
RewriteRule ^users/?$ channels.php [nc]
RewriteRule ^user/(.*) view_channel.php?user=$1 [nc]
RewriteRule ^channel/(.*) view_channel.php?user=$1 [nc]
RewriteRule ^my_account myaccount.php [nc]
#Pages
RewriteRule ^page/([0-9]+)/(.*) view_page.php?pid=$1 [nc]
#
#Miscellenous
RewriteRule ^search/result/?$ search_result.php [nc]
RewriteRule ^upload/?$ upload.php [nc]
RewriteRule ^contact/?$ contact.php [nc]
RewriteRule ^categories/?$ categories.php [nc]
#Group Section
RewriteRule ^group/([a-zA-Z0-9].+) view_group.php?url=$1&%{QUERY_STRING} [L]
RewriteRule ^view_topic/([a-zA-Z0-9].+)_tid_([0-9]+) view_topic.php?tid=$2&%{QUERY_STRING} [L]
RewriteRule ^groups/(.*)/(.*)/(.*)/(.*)/(.*) groups.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^groups/([0-9]+) groups.php?page=$1 [L]
RewriteRule ^groups/?$ groups.php [L]
RewriteRule ^create_group create_group.php [L]
#Collection Section
RewriteRule ^collections/(.*)/(.*)/(.*)/(.*)/(.*) collections.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^collections/([0-9]+) collections.php?page=$1 [L]
RewriteRule ^collections/?$ collections.php [L]
RewriteRule ^photos/(.*)/(.*)/(.*)/(.*)/(.*) photos.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L]
RewriteRule ^photos/([0-9]+) photos.php?page=$1 [L]
RewriteRule ^photos/?$ photos.php [L]
RewriteRule ^collection/(.*)/(.*)/(.*) view_collection.php?cid=$1&type=$2&%{QUERY_STRING} [L]
#Photo Section
RewriteRule ^item/(.*)/(.*)/(.*)/(.*) view_item.php?item=$3&type=$1&collection=$2 [L]
RewriteRule ^photo_upload/(.*) photo_upload.php?collection=$1 [L]
RewriteRule ^photo_upload/?$ photo_upload.php [L]
#
RewriteRule ^sitemap.xml$ sitemap.php
RewriteRule ^signup/?$ signup.php
#Error Pages
ErrorDocument 404 /404.php
ErrorDocument 403 /403.php
########## End - Rewrite rules For SEO urls ######################
RewriteRule ^rss$ rss.php [nc]
RewriteRule ^rss/([a-zA-Z0-9].+)$ rss.php?mode=$1&%{QUERY_STRING} [nc]
########## End - Rewrite rules For SEO urls ######################
RewriteRule ^([a-zA-Z0-9-]+)/?$ view_channel.php?uid=$1&seo_diret=yes [NS]

24
upload/403.php Normal file
View file

@ -0,0 +1,24 @@
<?php
/*
********************************************************************
| Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
********************************************************************
*/
define("THIS_PAGE",'403');
require 'includes/config.inc.php';
if(file_exists(LAYOUT."/403.html")) {
template_files('403.html');
} else {
$data = "403_error";
if(has_access('admin_access'))
e(sprintf(lang("err_warning"),"403","http://docs.clip-bucket.com/?p=154"),"w");
e(lang($data));
}
display_it();
?>

23
upload/404.php Normal file
View file

@ -0,0 +1,23 @@
<?php
/*
********************************************************************
| Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
********************************************************************
*/
define("THIS_PAGE",'404');
require 'includes/config.inc.php';
if(file_exists(LAYOUT."/404.html")) {
template_files('404.html');
} else {
$data = "404_error";
if(has_access('admin_access'))
e(sprintf(lang("err_warning"),"404","http://docs.clip-bucket.com/?p=154"),"w");
e(lang($data));
}
display_it();
?>

47
upload/LICENSE Normal file
View file

@ -0,0 +1,47 @@
Copyright (c) 2007 - 2010 by Arslan Hassan et al
CLIPBUCKET * http://clip-bucket.com
"A way to broadcast yourself - free and opensource video sharing website script"
All Rights Reserved
ATTRIBUTION ASSURANCE LICENSE (adapted from the original BSD license)
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the conditions below are met.
These conditions require a modest attribution to <AUTHOR> (the
"Arslan Hassan"), who hopes that its promotional value may help justify the
thousands of dollars in otherwise billable time invested in writing
this and other freely available, open-source software.
1. Redistributions of source code, in whole or part and with or without
modification (the "Code"), must prominently display this GPG-signed
text in verifiable form.
2. Redistributions of the Code in binary form must be accompanied by
this GPG-signed text in any documentation and, each time the resulting
executable program or a program dependent thereon is launched, a
prominent display (e.g., splash screen or banner text) of the Author's
attribution information, which includes:
(a) Name ("Arslan Hassan"),
(b) Professional identification ("ClipBucket"), and
(c) URL ("http://clip-bucket.com").
3. Neither the name nor any trademark of the Author may be used to
endorse or promote products derived from this software without specific
prior written permission.
4. Users are entirely responsible, to the exclusion of the Author and
any other persons, for compliance with (1) regulations set by owners or
administrators of employed equipment, (2) licensing terms of any other
software, and (3) local regulations regarding use, including those
regarding import, export, and use of encryption software.
THIS FREE SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
EVENT SHALL THE AUTHOR OR ANY CONTRIBUTOR BE LIABLE FOR
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
EFFECTS OF UNAUTHORIZED OR MALICIOUS NETWORK ACCESS;
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

0
upload/actions/.htaccess Normal file
View file

132
upload/actions/admin.php Normal file
View file

@ -0,0 +1,132 @@
<?php
/**
* This file is used to update
* Comment
* Author : Arslan Hassan
* Since : Jan 02 2009
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$mode = $_POST['mode'];
switch($mode)
{
case 'add_note':
{
$value = $_POST['note'];
$myquery->insert_note($value);
$array['note'] = nl2br($value);
$array['id'] = $db->insert_id();
echo json_encode($array);
}
break;
case 'delete_note':
{
$id = mysql_clean($_POST['id']);
$myquery->delete_note($id);
}
break;
case 'delete_comment':
{
$type = $_POST['type'];
switch($type)
{
case 'v':
case 'video':
default:
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$cbvid->update_comments_count($type_id);
}
break;
case 'u':
case 'c':
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$userquery->update_comments_count($type_id);
}
break;
case 't':
case 'topic':
{
$cid = mysql_clean($_POST['cid']);
$type_id = $myquery->delete_comment($cid);
$cbgroup->update_comments_count($type_id);
}
break;
}
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
case 'spam_comment':
{
$cid = mysql_clean($_POST['cid']);
$rating = $myquery->spam_comment($cid);
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
case 'remove_spam':
{
$cid = mysql_clean($_POST['cid']);
$rating = $myquery->remove_spam($cid);
if(msg())
{
$msg = msg_list();
$msg = $msg[0];
}
if(error())
{
$err = error_list();
$err = $err[0];
}
$ajax['msg'] = $msg;
$ajax['err'] = $err;
echo json_encode($ajax);
}
break;
}
?>

View file

@ -0,0 +1,20 @@
<?php
/**
* This file is used to update
* Comment
* Author : Arslan Hassan
* Since : 10 Aug, 2009
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$cid = $_POST['id'];
$value = $_POST['value'];
$myquery->update_comment($cid,$value);
echo mysql_clean($value);
?>

View file

@ -0,0 +1,53 @@
<?php
/**
* This file is used to verify embed form
* @author : Arslan Hassan
*/
include("../includes/config.inc.php");
$mode = $_POST['mode'];
switch($mode)
{
case "remote_play":
{
$duration = $_POST['duration'];
$thumb_file = $_POST['thumb_file'];
$url = $_POST['remote_play_url'];
$ext = strtolower(getExt($thumb_file));
validate_duration($duration);
check_remote_play_link($url);
if(empty($thumb_file) || ( $ext != 'jpg' && $ext != 'png' && $ext !='gif'))
e(lang("pelase_select_img_file_for_vdo"));
if(count($eh->error_list>0))
$array['err'] = $eh->error_list[0];
echo json_encode($array);
}
break;
case "embed":
default:
{
$embed_code = $_POST['embed_code'];
$duration = $_POST['duration'];
$thumb_file = $_POST['thumb_file'];
$ext = strtolower(getExt($thumb_file));
validate_embed_code($embed_code);
validate_duration($duration);
if(empty($thumb_file) || ( $ext != 'jpg' && $ext != 'png' && $ext !='gif'))
e(lang("pelase_select_img_file_for_vdo"));
if(count($eh->error_list>0))
$array['err'] = $eh->error_list[0];
echo json_encode($array);
}
}
?>

View file

@ -0,0 +1,316 @@
<?php
/**
* This file is used to download files
* from one server to our server
* in prior version, this file was not so reliable
* this time it has complete set of instruction
* and proper downloader
* @Author : Arslan Hassan
* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
* @Since : 01 July 2009
*/
include("../includes/config.inc.php");
include("../includes/classes/curl/class.curl.php");
error_reporting(E_ALL ^E_NOTICE);
if(isset($_POST['check_url']))
{
$url = $_POST['check_url'];
$types_array = preg_replace('/,/',' ',strtolower(config('allowed_types')));
$types_array = explode(' ',$types_array);
$file_ext = strtolower(getExt(strtolower($url)));
if(checkRemoteFile($url) && in_array($file_ext,$types_array) )
{
echo json_encode(array('ok'=>'yes'));
}else
echo json_encode(array('err'=>'Invalid remote url'));
exit();
}
/**
* Call back function of cURL handlers
* when it downloads a file, it works with php >= 5.3.0
* @param $download_size total file size of the file
* @param $downloaded total file size that has been downloaded
* @param $upload_size total file size that has to be uploaded
* @param $uploadsed total file size that is uploaded
*
* Writes the log in file
*/
if(!isCurlInstalled())
{
exit(json_encode(array("error"=>"Sorry, we do not support remote upload")));
}
//checking if user is logged in or not
if(!userid())
exit(json_encode(array('error'=>'You are not logged in')));
if($_POST['youtube'])
{
$youtube_url = $_POST['file'];
$filename = $_POST['file_name'];
$ParseUrl = parse_url($youtube_url);
parse_str($ParseUrl['query'], $youtube_url_prop);
$YouTubeId = isset($youtube_url_prop['v']) ? $youtube_url_prop['v'] : '';
if(!$YouTubeId)
{
exit(json_encode(array("error"=>"Invalid youtube url")));
}
$content = xml2array('http://gdata.youtube.com/feeds/api/videos/'.$YouTubeId);
$content = $content['entry'];
/* $match_arr =
array
(
"title"=>"/<meta name=\"title\" content=\"(.*)\">/",
"description"=>"/<meta name=\"description\" content=\"(.*)\">/",
"tags" =>"/<meta name=\"keywords\" content=\"(.*)\">/",
"embed_code" => "/<meta name=\"keywords\" content=\"(.*)\">/",
"duration" => "/<span class=\"video-time\">([0-9\:]+)<\/span>/"
);
$vid_array = array();
foreach($match_arr as $title=> $match)
{
preg_match($match,$content,$matches);
$vid_array[$title] = $matches[1];
}*/
$vid_array['title'] = $content['media:group']['media:title'];
$vid_array['description'] = $content['content'];
$vid_array['tags'] = $content['media:group']['media:keywords'];
$vid_array['duration'] = $content['media:group']['yt:duration_attr']['seconds'];
$vid_array['thumbs'] =
array('http://i3.ytimg.com/vi/'.$YouTubeId.'/1.jpg','http://i3.ytimg.com/vi/'.
$YouTubeId.'/2.jpg','http://i3.ytimg.com/vi/'.$YouTubeId.'/3.jpg',
'big'=>'http://i3.ytimg.com/vi/'.$YouTubeId.'/0.jpg');
$vid_array['embed_code'] = '<object width="425" height="344">
<param name="movie" value="http://www.youtube.com/v/'.$YouTubeId.'">
</param><param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<embed src="http://www.youtube.com/v/'.$YouTubeId.'"
type="application/x-shockwave-flash"
width="425" height="344"
allowscriptaccess="always"
allowfullscreen="true">
</embed></object>';
$vid_array['category'] = array($cbvid->get_default_cid());
$vid_array['file_name'] = $filename;
$vid_array['userid'] = userid();
$duration = $vid_array['duration'];
/* $duration = explode(":",$duration);
$sep = count($duration);
if($sep==3)
$duration = ($duration[0]*60*60)+($duration[1]*60)+($duration[2]);
else
$duration = ($duration[0]*60)+($duration[1]);
*/
$vid = $Upload->submit_upload($vid_array);
if(error())
{
exit(json_encode(array('error'=>error('single'))));
}
if(!function_exists('get_refer_url_from_embed_code'))
{
exit(json_encode(array('error'=>"Clipbucket embed module is not installed")));
}
$ref_url = get_refer_url_from_embed_code(unhtmlentities(stripslashes($vdetails['embed_code'])));
$ref_url = $ref_url['url'];
$db->update(tbl("video"),array("status","refer_url","duration"),array('Successful',$ref_url,$duration)," videoid='$vid'");
//Downloading thumb
foreach($vid_array['thumbs'] as $tid => $thumb)
{
if($tid!='big')
$thumbId = $tid+1;
else
$thumbId = 'big';
snatch_it(urlencode($thumb),THUMBS_DIR,$filename."-$thumbId.jpg");
}
exit(json_encode(array('vid'=>$vid,
'title'=>$vid_array['title'],'desc'=>$vid_array['description'],
'tags'=>$vid_array['tags'])));
}
function callback($download_size, $downloaded, $upload_size, $uploaded)
{
global $curl,$log_file,$file_name,$ext;
$fo = fopen($log_file,'w+');
//Elapsed time CURLINFO_TOTAL_TIME
$info = curl_getinfo($curl->m_handle);
$download_bytes = $download_size - $downloaded;
$cur_speed = $info['speed_download'];
if($cur_speed>0)
$time_eta = $download_bytes/$cur_speed;
else
$time_eta = 0;
$time_took = $info['total_time'];
$curl_info =
array(
'total_size' => $download_size,
'downloaded' => $downloaded,
'speed_download' => $info['speed_download'],
'time_eta' => $time_eta,
'time_took'=> $time_took,
'file_name' => $file_name.'.'.$ext
);
fwrite($fo,json_encode($curl_info));
fclose($fo);
}
$file = $_POST['file'];
$file_name = mysql_clean($_POST['file_name']);
$log_file = TEMP_DIR.'/'.$file_name.'_curl_log.cblog';
//For PHP < 5.3.0
$dummy_file = TEMP_DIR.'/'.$file_name.'_curl_dummy.cblog';
$ext = getExt($file);
$svfile = TEMP_DIR.'/'.$file_name.'.'.$ext;
//Checking for the url
if(empty($file))
{
$array['error'] = "Please enter file url";
echo json_encode($array);
exit();
}
//Checkinf if extension is wrong
$types = strtolower($Cbucket->configs['allowed_types']);
$types_array = preg_replace('/,/',' ',$types);
$types_array = explode(' ',$types_array);
$extension_whitelist = $types_array;
if(!in_array($ext,$extension_whitelist))
{
$array['error'] = "This file type is not allowed";
echo json_encode($array);
exit();
}
$curl = new curl($file);
$curl->setopt(CURLOPT_FOLLOWLOCATION, true) ;
//Checking if file size is not that goood
if(!is_numeric($curl->file_size) || $curl->file_size == '')
{
$array['error'] = "Unknown file size";
echo json_encode($array);
exit();
}
if(phpversion() < '5.3.0')
{
//Here we will get file size and write it in a file
//called dummy_log
$darray = array(
'file_size' => $curl->file_size,
'file_name' => $file_name.'.'.$ext,
'time_started'=>time(),
'byte_size' => 0
);
$do = fopen($dummy_file,'w+');
fwrite($do,json_encode($darray));
fclose($do);
}
//Opening video file
$temp_fo = fopen($svfile,'w+');
$curl->setopt(CURLOPT_FILE, $temp_fo);
// Set up the callback
if(phpversion() >= '5.3.0')
{
$curl->setopt(CURLOPT_NOPROGRESS, false);
$curl->setopt(CURLOPT_PROGRESSFUNCTION, 'callback');
}
$curl->exec();
if ($theError = $curl->hasError())
{
$array['error'] = $theError ;
echo json_encode($array);
}
//Finish Writing File
fclose($temp_fo);
sleep(10);
$details = file_get_contents($log_file);
$details = json_decode($details,true);
$Upload->add_conversion_queue($details['file_name']);
if(file_exists($log_file))
unlink($log_file);
if(file_exists($dummy_file))
unlink($dummy_file);
$quick_conv = config('quick_conv');
$use_crons = config('use_crons');
//Inserting data
$title = urldecode(mysql_clean(getName($file)));
$title = $title ? $title : "Untitled";
$vidDetails = array
(
'title' => $title,
'description' => $title,
'tags' => genTags(str_replace(' ',', ',$title)),
'category' => array($cbvid->get_default_cid()),
'file_name' => $file_name,
'userid' => userid(),
);
$vid = $Upload->submit_upload($vidDetails);
echo json_encode(array('vid'=>$vid));
if($quick_conv=='yes' || $use_crons=='no')
{
$targetFileName = $details['file_name'];
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN')) {
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName sleep");
} else {
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName sleep&> /dev/null &");
}
}
?>

View file

@ -0,0 +1,89 @@
<?php
/**
* This file is used to download files
* from one server to our server
* in prior version, this file was not so reliable
* this time it has complete set of instruction
* and proper downloader
* @Author : Arslan Hassan
* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
* @Since : 01 July 2009
*/
//When we need
define(TEMP_DIR,dirname(__FILE__).'/../files/temp');
error_reporting(E_ALL ^E_NOTICE);
$file_name = $_POST['file_name'];
$log_file = TEMP_DIR.'/'.$file_name.'_curl_log.cblog';
//For PHP < 5.3.0
$dummy_file = TEMP_DIR.'/'.$file_name.'_curl_dummy.cblog';
include("include_functions.php");
if(file_exists($dummy_file))
{
//Read the data
$data = file_get_contents($dummy_file);
$data = json_decode($data,true);
$file = $data['file_name'];
$started = $data['time_started'];
//Total File Size
$total_size = $data['file_size'];
$byte_size = $data['byte_size'];
//Let check whats the file size right now
$data['byte_size'] = $now_file_size = filesize(TEMP_DIR.'/'.$file);
//Bytes Transfered
$cur_speed = $now_file_size - $byte_size;
//Time Eta
$download_bytes = $total_size - $now_file_size;
if($cur_speed>0)
$time_eta = $download_bytes/$cur_speed;
else
$time_eta = 0;
//Time Took
$time_took = time() - $started;
$curl_info =
array(
'total_size' => $total_size,
'downloaded' => $now_file_size,
'speed_download' => $cur_speed,
'time_eta' => $time_eta,
'time_took'=> $time_took,
'file_name'=> $file
);
$fo = fopen($log_file,'w+');
fwrite($fo,json_encode($curl_info));
fclose($fo);
$fo = fopen($dummy_file,'w+');
fwrite($fo,json_encode($data));
fclose($fo);
if($total_size==$now_file_size)
unlink($dummy_file);
}
if(file_exists($log_file))
{
$details = file_get_contents($log_file);
$details = json_decode($details,true);
$details['total_size_fm'] = formatfilesize($details['total_size']);
$details['downloaded_fm'] = formatfilesize($details['downloaded']);
$details['time_eta_fm'] = SetTime($details['time_eta']);
$details['time_took_fm'] = SetTime($details['time_took']);
echo json_encode($details);
}
?>

View file

@ -0,0 +1,175 @@
<?php
/**
* @Author : Arslan Hassan
*/
include('../includes/config.inc.php');
if($_FILES['Filedata'])
$mode = "upload";
if($_POST['insertVideo'])
$mode = "insert_video";
if($_POST['getForm'])
$mode = "get_form";
if($_POST['updateVideo']=='yes')
$mode = "update_video";
switch($mode)
{
case "insert_video":
{
$title = getName($_POST['title']);
$file_name = $_POST['file_name'];
$vidDetails = array
(
'title' => $title,
'description' => $title,
'tags' => genTags(str_replace(' ',', ',$title)),
'category' => array($cbvid->get_default_cid()),
'file_name' => $file_name,
'userid' => userid(),
);
$vid = $Upload->submit_upload($vidDetails);
echo $vid;
}
break;
case "get_form":
{
$title = getName($_POST['title']);
if(!$title)
$title = $_POST['title'];
$desc = $_POST['desc'];
$tags = $_POST['tags'];
if(!$desc)
$desc = $title;
if(!$tags)
$tags = $title;
$vidDetails = array
(
'title' => $title,
'description' => $desc,
'tags' => $tags,
'category' => array($cbvid->get_default_cid()),
);
assign("objId",$_POST['objId']);
assign('input',$vidDetails);
Template('blocks/upload/form.html');
}
break;
case "upload":
{
$file_name = time().RandomString(5);
$tempFile = $_FILES['Filedata']['tmp_name'];
$targetFileName = $file_name.'.'.getExt( $_FILES['Filedata']['name']);
$targetFile = TEMP_DIR."/".$targetFileName;
$max_file_size_in_bytes = config('max_upload_size')*1024*1024;
$types = strtolower(config('allowed_types'));
//Checking filesize
$POST_MAX_SIZE = ini_get('post_max_size');
$unit = strtoupper(substr($POST_MAX_SIZE, -1));
$multiplier = ($unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1)));
if ((int)$_SERVER['CONTENT_LENGTH'] > $multiplier*(int)$POST_MAX_SIZE && $POST_MAX_SIZE) {
header("HTTP/1.1 500 Internal Server Error"); // This will trigger an uploadError event in SWFUpload
upload_error("POST exceeded maximum allowed size.");
exit(0);
}
//Checking uploading errors
$uploadErrors = array(
0=>"There is no error, the file uploaded with success",
1=>"The uploaded file exceeds the upload_max_filesize directive in php.ini",
2=>"The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form",
3=>"The uploaded file was only partially uploaded",
4=>"No file was uploaded",
6=>"Missing a temporary folder"
);
if (!isset($_FILES['Filedata'])) {
upload_error("No file was selected");
exit(0);
} else if (isset($_FILES['Filedata']["error"]) && $_FILES['Filedata']["error"] != 0) {
upload_error($uploadErrors[$_FILES['Filedata']["error"]]);
exit(0);
} else if (!isset($_FILES['Filedata']["tmp_name"]) || !@is_uploaded_file($_FILES['Filedata']["tmp_name"])) {
upload_error("Upload failed is_uploaded_file test.");
exit(0);
} else if (!isset($_FILES['Filedata']['name'])) {
upload_error("File has no name.");
exit(0);
}
//Check file size
$file_size = @filesize($_FILES['Filedata']["tmp_name"]);
if (!$file_size || $file_size > $max_file_size_in_bytes) {
upload_error("File exceeds the maximum allowed size") ;
exit(0);
}
//Checking file type
$types_array = preg_replace('/,/',' ',$types);
$types_array = explode(' ',$types_array);
$file_ext = strtolower(getExt($_FILES['Filedata']['name']));
if(!in_array($file_ext,$types_array))
{
upload_error("Invalid file extension");
exit(0);
}
move_uploaded_file($tempFile,$targetFile);
$Upload->add_conversion_queue($targetFileName);
$quick_conv = config('quick_conv');
$use_crons = config('use_crons');
if($quick_conv=='yes' || $use_crons=='no')
{
//exec(php_path()." -q ".BASEDIR."/actions/video_convert.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN')) {
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName");
} else {
exec(php_path()." -q ".BASEDIR."/actions/video_convert.php $targetFileName &> /dev/null &");
}
}
echo json_encode(array("success"=>"yes","file_name"=>$file_name));
}
break;
case "update_video":
{
$Upload->validate_video_upload_form();
$_POST['videoid'] = trim($_POST['videoid']);
if(empty($eh->error_list))
{
$cbvid->update_video();
}
if(error())
echo json_encode(array('error'=>error('single')));
else
echo json_encode(array('msg'=>msg('single')));
}
}
//function used to display error
function upload_error($error)
{
echo json_encode(array("error"=>$error));
}
?>

View file

@ -0,0 +1,13 @@
<?php
/**
* this file is used to fetch file size
*/
include("../includes/config.inc.php");
$file_name = $_POST['file'];
$file = TEMP_DIR.'/'.$file_name;
if(!empty($file_name) && file_exists($file))
echo filesize($file);
?>

View file

@ -0,0 +1,130 @@
<?php
function RandomString($length)
{
// Generate random 32 charecter string
$string = md5(microtime());
// Position Limiting
$highest_startpoint = 32-$length;
// Take a random starting point in the randomly
// Generated String, not going any higher then $highest_startpoint
$randomString = substr($string,rand(0,$highest_startpoint),$length);
return $randomString;
}
function formatfilesize( $data ) {
// bytes
if( $data < 1024 ) {
return $data . " bytes";
}
// kilobytes
else if( $data < 1024000 ) {
return round( ( $data / 1024 ), 1 ) . "KB";
}
// megabytes
else if($data < 1024000000){
return round( ( $data / 1024000 ), 1 ) . " MB";
}else{
return round( ( $data / 1024000000 ), 1 ) . " GB";
}
}
/**
* Function used to get file name
*/
function GetName($file)
{
if(!is_string($file))
return false;
$path = explode('/',$file);
if(is_array($path))
$file = $path[count($path)-1];
$new_name = substr($file, 0, strrpos($file, '.'));
return $new_name;
}
function get_elapsed_time($ts,$datetime=1)
{
if($datetime == 1)
{
$ts = date('U',strtotime($ts));
}
$mins = floor((time() - $ts) / 60);
$hours = floor($mins / 60);
$mins -= $hours * 60;
$days = floor($hours / 24);
$hours -= $days * 24;
$weeks = floor($days / 7);
$days -= $weeks * 7;
$t = "";
if ($weeks > 0)
return "$weeks week" . ($weeks > 1 ? "s" : "");
if ($days > 0)
return "$days day" . ($days > 1 ? "s" : "");
if ($hours > 0)
return "$hours hour" . ($hours > 1 ? "s" : "");
if ($mins > 0)
return "$mins min" . ($mins > 1 ? "s" : "");
return "< 1 min";
}
//Function Used TO Get Extensio Of File
function GetExt($file){
return substr($file, strrpos($file,'.') + 1);
}
function old_set_time($temps)
{
round($temps);
$heures = floor($temps / 3600);
$minutes = round(floor(($temps - ($heures * 3600)) / 60));
if ($minutes < 10)
$minutes = "0" . round($minutes);
$secondes = round($temps - ($heures * 3600) - ($minutes * 60));
if ($secondes < 10)
$secondes = "0" . round($secondes);
return $minutes . ':' . $secondes;
}
function SetTime($sec, $padHours = true) {
if($sec < 3600)
return old_set_time($sec);
$hms = "";
// there are 3600 seconds in an hour, so if we
// divide total seconds by 3600 and throw away
// the remainder, we've got the number of hours
$hours = intval(intval($sec) / 3600);
// add to $hms, with a leading 0 if asked for
$hms .= ($padHours)
? str_pad($hours, 2, "0", STR_PAD_LEFT). ':'
: $hours. ':';
// dividing the total seconds by 60 will give us
// the number of minutes, but we're interested in
// minutes past the hour: to get that, we need to
// divide by 60 again and keep the remainder
$minutes = intval(($sec / 60) % 60);
// then add to $hms (with a leading 0 if needed)
$hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT). ':';
// seconds are simple - just divide the total
// seconds by 60 and keep the remainder
$seconds = intval($sec % 60);
// add to $hms, again with a leading 0 if needed
$hms .= str_pad($seconds, 2, "0", STR_PAD_LEFT);
return $hms;
}

View file

@ -0,0 +1,177 @@
<?php
/**
* @Author : Fawaz Tahir, Arslan Hassan
*/
include('../includes/config.inc.php');
if($_FILES['photoUpload'])
$mode = "uploadPhoto";
if($_POST['photoForm'])
$mode = "get_photo_form";
if($_POST['insertPhoto'])
$mode = "insert_photo";
if($_POST['updatePhoto'])
$mode = "update_photo";
switch($mode)
{
case "get_photo_form":
{
$name = getName($_POST['name']);
if(!$name)
$name = $_POST['name'];
$desc = $name;
$tags = $name;
$collection = $_POST['collection'];
$photoArray = array
(
"photo_title" => $name,
"photo_description" => $name,
"photo_tags" => $name,
"collection_id" => $collection
);
assign("uniqueID",$_POST['objID']);
assign("photoArray",$photoArray);
$form = Fetch("/blocks/upload/photo_form.html");
echo json_encode(array("form"=>$form));
}
break;
case "insert_photo":
{
$_POST['photo_title'] = genTags(str_replace(array('_','-'),' ',$_POST['photo_title']));
$_POST['photo_description'] = genTags(str_replace(array('_','-'),' ',$_POST['photo_description']));
$_POST['photo_tags'] = genTags(str_replace(array(' ','_','-'),', ',$_POST['photo_tags']));
$_POST['server_url'] = mysql_clean($_POST['server_url']);
$_POST['folder'] = str_replace('..','',mysql_clean($_POST['folder']));
$insert_id = $cbphoto->insert_photo();
if(error())
$response['error'] = error('single');
if(msg())
{
$response['success'] = msg('single');
$response['photoID'] = $insert_id;
$details = $cbphoto->get_photo($insert_id);
$params = array("details"=>$details,"size"=>"m");
$response['photoPreview'] = get_photo($params);
}
echo json_encode($response);
}
break;
case "update_photo":
{
$_POST['photo_title'] = genTags(str_replace(array('_','-'),' ',$_POST['photo_title']));
$_POST['photo_description'] = genTags(str_replace(array('_','-'),' ',$_POST['photo_description']));
$_POST['photo_tags'] = genTags(str_replace(array(' ','_','-'),', ',$_POST['photo_tags']));
$cbphoto->update_photo();
if(error())
$error = error('single');
if(msg())
$success = msg('single');
$updateResponse['error'] = $error;
$updateResponse['success'] = $success;
echo json_encode($updateResponse);
}
break;
case "uploadPhoto":
{
$exts = $cbphoto->exts;
$max_size = 1048576; // 2MB in bytes
$form = "photoUpload";
$path = PHOTOS_DIR."/";
// These are found in $_FILES. We can access them like $_FILES['file']['error'].
$upErrors = array(
0 => "There is no error, the file uploaded with success.",
1 => "The uploaded file exceeds the upload_max_filesize directive in php.ini.",
2 => " The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.",
3 => "The uploaded file was only partially uploaded.",
4 => "No file was uploaded.",
6 => "Missing a temporary folder.",
7 => "Failed to write file to disk."
);
// Let's see if everything is working fine by checking $_FILES.
if(!isset($_FILES[$form])) {
upload_error("No upload found in \$_FILES for " . $form);
exit(0);
}
elseif(isset($_FILES[$form]['error']) && $_FILES[$form]['error'] != 0) {
upload_error($upErrors[$_FILES[$form]['error']]);
exit(0);
}
elseif(!isset($_FILES[$form]["tmp_name"]) || !@is_uploaded_file($_FILES[$form]["tmp_name"])) {
upload_error("Upload failed is_uploaded_file test.");
exit(0);
} elseif(empty($_FILES[$form]['name'])) {
upload_error("File name is empty");
exit(0);
}
// Time to check if Filesize is according to demands
//$filesize = filesize($_FILES[$form]['tmp_name']);
//if(!$filesize || $filesize > $max_size)
//{
// upload_error("File exceeds the maximum allowed size");
// exit(0);
//}
//
//if($filesize < 0)
//{
// upload_error("File size outside allowed lower bound");
// exit(0);
//}
//Checking Extension of File
$info = pathinfo($_FILES[$form]['name']);
$extension = strtolower($info['extension']);
$valid_extension = false;
foreach ($exts as $ext) {
if (strcasecmp($extension, $ext) == 0) {
$valid_extension = true;
break;
}
}
if(!$valid_extension)
{
upload_error("Invalid file extension");
exit(0);
}
$filename = $cbphoto->create_filename();
//Now uploading the file
if(move_uploaded_file($_FILES[$form]['tmp_name'],$path.$filename.".".$extension))
{
echo json_encode(array("success"=>"yes","filename"=>$filename,"extension"=>$extension));
} else {
upload_error("File could not be saved.");
exit(0);
}
}
break;
}
//function used to display error
function upload_error($error)
{
echo json_encode(array("error"=>$error));
}
?>

View file

@ -0,0 +1,28 @@
<?php
/**
* File use to process video files
*
* @Author : Arslan Hassan
* @Software : ClipBucket
* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
* @Since : July 3 2009
*/
include(dirname(__FILE__)."/../includes/config.inc.php");
//Get vid
$vid = $_SERVER['argv'][1];
//Check video exists or not
if($myquery->video_exists($vid))
{
//Get Video Details
//$vdetails = $myquery->get_video_details($vid);
$Upload->do_after_video_upload($vid);
}else{
e(lang("class_vdo_del_err"));
}
?>

View file

@ -0,0 +1,27 @@
<?php
/**
* this file is used to send subscription email
* @Author : Arslan Hassan
* @Date : 2/24/2011
*/
$in_bg_cron = true;
include(dirname(dirname(__FILE__))."/includes/config.inc.php");
$videoid = $argv[1];
$video = $cbvid->get_video($videoid);
if($video)
{
if(
($video['broadcast']=='public' || $video['broadcast'] =="logged")
&& $video['subscription_email']=='pending')
$userquery->sendSubscriptionEmail($video,true);
}
?>

View file

@ -0,0 +1,91 @@
<?php
/**
* This class is used to update clipbucket daily stats
*/
$in_bg_cron = true;
//including config file..
include(dirname(__FILE__)."/../includes/config.inc.php");
//Calling Cron Functions
cb_call_functions('update_cb_stats_cron');
//Now Gathering All Data
$date = date("Y-m-d");
//Videos
$videos['uploads'] = $cbvid->get_videos(array("count_only"=>true,"date_span"=>"today"),TRUE);
$videos['processing'] = $cbvid->get_videos(array("count_only"=>true,"status"=>"Processing","date_span"=>"today"),TRUE);
$videos['active'] = $cbvid->get_videos(array("count_only"=>true,"active"=>"yes","date_span"=>"today"),TRUE);
//Views
$vid_views = $db->select(tbl("video"),"SUM(views) as total_views"," date_added LIKE '%$date%'");
$videos['views'] = $vid_views[0]['total_views'];
//Total Comments
$vid_comments = $db->select(tbl("video"),"SUM(comments_count) as total_comments"," date_added LIKE '%$date%'");
$videos['comments'] = $vid_comments[0]['total_comments'];
/**
* Testing
* * PASSED
*/
echo json_encode($videos);
//Users
$users['signups'] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today"));
$users['inactive'] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today","status"=>'ToActivate'));
$users['active'] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today","status"=>'Ok'));
//Views
$user_views = $db->select(tbl("users"),"SUM(profile_hits) as total_views"," doj LIKE '%$date%'");
$users['views'] = $user_views[0]['total_views'];
//Total Comments
$user_comments = $db->select(tbl("users"),"SUM(comments_count) as total_comments"," doj LIKE '%$date%'");
$users['comments'] = $user_comments[0]['total_comments'];
/**
* Testing
* echo json_encode($users);
* PASSED
*/
//Groups
$groups['created'] = $cbgroup->get_groups(array("count_only"=>true,"date_span"=>"today"));
$groups['active'] = $cbgroup->get_groups(array("count_only"=>true,"date_span"=>"today","active"=>"yes"));
//Total Views
$group_views = $db->select(tbl("groups"),"SUM(total_views) as the_views"," date_added LIKE '%$date%'");
$groups['views'] = $group_views[0]['the_views'];
//Total Discussion
$group_topics = $db->select(tbl("groups"),"SUM(total_topics) as the_topics"," date_added LIKE '%$date%'");
$groups['total_topics'] = $group_topics[0]['the_topics'];
//TOtal Comments
$group_discussions = $db->select(tbl("group_topics"),"SUM(total_replies) as the_discussions"," date_added LIKE '%$date%'");
$groups['total_discussions'] = $group_discussions[0]['the_discussions'];
/**
* TESTING GROUPS
* echo json_encode($groups);
* PASSED
*/
$fields = array('video_stats','user_stats','group_stats');
$values = array('|no_mc|'.json_encode($videos),'|no_mc|'.json_encode($users),'|no_mc|'.json_encode($groups));
//Checking If there is already a row of the same date, then update it otherwise insert data
$result = $db->select(tbl("stats"),"stat_id"," date_added LIKE '%$date%'");
if($db->num_rows>0)
{
$result = $result[0];
$db->update(tbl("stats"),$fields,$values," stat_id='".$result['stat_id']."'");
}else
{
$fields[] = 'date_added';
$values[] = $date;
$db->insert(tbl("stats"),$fields,$values);
}
?>

View file

@ -0,0 +1,36 @@
<?php
/**
* Written by : Arslan Hassan
* Software : ClipBucket v2
* License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
**/
require'../includes/admin_config.php';
$userquery->login_check('admin_access');
if($_POST['update_player_size']=='yes')
{
$height = mysql_clean($_POST['height']);
$width = mysql_clean($_POST['width']);
$config_name = mysql_clean($_POST['width']);
if(!is_numeric($height) || $height <=100)
$height = 100;
if(!is_numeric($width) || $width <=100)
$width = 100;
$myquery->Set_Website_Details('player_height',$height);
$myquery->Set_Website_Details('player_width',$width);
echo "Player size has been updated";
}
if($_POST['update_channel_player_size']=='yes')
{
$height = mysql_clean($_POST['height']);
$width = mysql_clean($_POST['width']);
$config_name = mysql_clean($_POST['width']);
if(!is_numeric($height) || $height <=100)
$height = 100;
if(!is_numeric($width) || $width <=100)
$width = 100;
$myquery->Set_Website_Details('channel_player_height',$height);
$myquery->Set_Website_Details('channel_player_width',$width);
echo "Channel Player size has been updated";
}
?>

View file

@ -0,0 +1,20 @@
<?php
/**
* This file is used to update
* language phrases
* Author : Arslan Hassan
* Since : 10 Aug, 2009
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$phrase_id = $_POST['id'];
$value = $_POST['value'];
$lang_obj->update_phrase($phrase_id,'|no_mc|'.$value);
echo ($value);
?>

View file

@ -0,0 +1,91 @@
<?php
/**
* This file is used to verify weather video is converted or not
* if it is converted then activate it and let it go
*/
//Sleeping..
//sometimes video is inserted after video conversion so in this case, video can get lost
//if($argv[2]=='sleep')
sleep(10);
$in_bg_cron = true;
include(dirname(__FILE__)."/../includes/config.inc.php");
cb_call_functions('verify_converted_videos_cron');
if($argv[1])
$fileName = $argv[1];
else
$fileName = false;
$files = get_video_being_processed($fileName);
if(is_array($files))
foreach($files as $file)
{
$file_details = get_file_details($file['cqueue_name']);
//pr($file_details);
//Thanks to pandusetiawan @ forums.clip-bucket.com
if($file_details['conversion_status']=='failed' or strpos($file_details['conversion_log'],'conversion_status : failed') >0)
{
$db->update(tbl("conversion_queue"),
array("cqueue_conversion"),
array("yes")," cqueue_id = '".$file['cqueue_id']."'");
update_processed_video($file,'Failed',$ffmpeg->failed_reason);
/**
* Calling Functions after converting Video
*/
if(get_functions('after_convert_functions'))
{
foreach(get_functions('after_convert_functions') as $func)
{
if(@function_exists($func))
$func($file_details);
}
}
}elseif($file_details['conversion_status']=='completed' or strpos($file_details['conversion_log'],'conversion_status : completed') >0)
{
$db->update(tbl("conversion_queue"),
array("cqueue_conversion","time_completed"),
array("yes",time())," cqueue_id = '".$file['cqueue_id']."'");
update_processed_video($file,'Successful');
/**
* Calling Functions after converting Video
*/
if(get_functions('after_convert_functions'))
{
foreach(get_functions('after_convert_functions') as $func)
{
if(@function_exists($func))
$func($file_details);
}
}
//Sending Subscription Emails
$videoDetails = $cbvideo->get_video($file['cqueue_name'],true);
if($videoDetails)
{
if( ($videoDetails['broadcast']=='public' ||
$videoDetails['logged']) &&
$videoDetails['active']=='yes')
{
$userquery->sendSubscriptionEmail($videoDetails,true);
}
}
}
}
?>

View file

@ -0,0 +1,214 @@
<?php
/**
* Written by : Arslan Hassan
* Software : ClipBucket v2
* License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
*
* I have done MANY experiments on video conversion
* so these results are the best possible output
* you can further discuss about it on forums.clip-bucket.com
**/
ini_set('mysql.connect_timeout','6000');
$in_bg_cron = true;
include(dirname(__FILE__)."/../includes/config.inc.php");
//Calling Cron Functions
cb_call_functions('video_convert_cron');
$server_friendly = config('server_friendly_conversion');
$use_crons = config('use_crons');
if($server_friendly=='yes' && $use_crons=='yes')
{
/**
*
* Thanks to Erickson Reyes ercbluemonday at yahoo dot com | so processes dont overlap
* ref : http://www.php.net/manual/en/function.getmypid.php#94531*/
// Initialize variables
$found = 0;
$file = basename(__FILE__);
$commands = array();
// Get running processes.
exec("ps w", $commands);
// If processes are found
if (count($commands) > 0) {
foreach ($commands as $command) {
if (strpos($command, $file) === false) {
// Do nothin'
}
else {
// Let's count how many times the file is found.
$found++;
}
}
}
// If the instance of the file is found more than once.
if ($found > 1) {
echo "Another process is running.\n";
die();
}
}
$SYSTEM_OS = $row['sys_os'] ? $row['sys_os'] : 'linux';
//Including FFMPEG CLASS
require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php');
if($argv[1])
$fileName = $argv[1];
else
$fileName = false;
if($argv[2] == 'sleep')
$dosleep = 'sleep';
else
$dosleep = '';
//Get Vido
$queue_details = get_queued_video(TRUE,$fileName);
if(!$queue_details)
exit("Nothing to do");
//Setting up details, moving files
$tmp_file = $queue_details['cqueue_name'];
$tmp_ext = $queue_details['cqueue_tmp_ext'];
$ext = $queue_details['cqueue_ext'];
if(!empty($tmp_file)){
$temp_file = TEMP_DIR.'/'.$tmp_file.'.'.$tmp_ext;
$orig_file = CON_DIR.'/'.$tmp_file.'.'.$ext;
//copy($temp_file,$orig_file);
rename($temp_file,$orig_file);
$res169 = array();
$res169['240'] = array('427','240');
$res169['360'] = array('640','360');
$res169['480'] = array('853','480');
$res169['720'] = array('1280','720');
$res169['1080'] = array('1920','1080');
$res43 = array();
$res43['240'] = array('320','240');
$res43['360'] = array('480','360');
$res43['480'] = array('640','480');
$res43['720'] = array('960','720');
$res43['1080'] = array('1440','1080');
$configs = array
(
'use_video_rate' => true,
'use_video_bit_rate' => true,
'use_audio_rate' => true,
'use_audio_bit_rate' => true,
'use_audio_codec' => true,
'use_video_codec' => true,
'format' => 'flv',
'video_codec'=> config('video_codec'),
'audio_codec'=> config('audio_codec'),
'audio_rate'=> config("srate"),
'audio_bitrate'=> config("sbrate"),
'video_rate'=> config("vrate"),
'video_bitrate'=> config("vbrate"),
'normal_res' => config('normal_resolution'),
'high_res' => config('high_resolution'),
'max_video_duration' => config('max_video_duration'),
'res169' => $res169,
'res43' => $res43,
'resize'=>'max'
);
/**
* Calling Functions before converting Video
*/
if(get_functions('before_convert_functions'))
{
foreach(get_functions('before_convert_functions') as $func)
{
if(@function_exists($func))
$func();
}
}
$ffmpeg = new ffmpeg($orig_file);
$ffmpeg->configs = $configs;
$ffmpeg->gen_thumbs = TRUE;
$ffmpeg->gen_big_thumb = TRUE;
$ffmpeg->num_of_thumbs = config('num_thumbs');
$ffmpeg->thumb_dim = config('thumb_width')."x".config('thumb_height');
$ffmpeg->big_thumb_dim = config('big_thumb_width')."x".config('big_thumb_height');
$ffmpeg->tmp_dir = TEMP_DIR;
$ffmpeg->input_ext = $ext;
$ffmpeg->output_file = VIDEOS_DIR.'/'.$tmp_file.'.flv';
$ffmpeg->hq_output_file = VIDEOS_DIR.'/'.$tmp_file.'.mp4';
$ffmpeg->log_file = LOGS_DIR.'/'.$tmp_file.'.log';
//$ffmpeg->remove_input = TRUE;
$ffmpeg->keep_original = config('keep_original');
$ffmpeg->original_output_path = ORIGINAL_DIR.'/'.$tmp_file.'.'.$ext;
$ffmpeg->ClipBucket();
////exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php &> /dev/null &");
if (stristr(PHP_OS, 'WIN'))
{
exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php $fileName $dosleep");
} else {
exec(php_path()." -q ".BASEDIR."/actions/verify_converted_videos.php $fileName $dosleep &> /dev/null &");
}
//Converting File In HD Format
if($ffmpeg->input_details['video_height']>'719')
$hq_output = config('hq_output');
else
$hq_output = 'no';
if($hq_output=='yes' && !$ffmpeg->failed_reason)
{
while(1)
{
$use_crons = config('use_crons');
if(!$ffmpeg->isLocked(PROCESSESS_AT_ONCE) || $use_crons=='yes' || !$ffmpeg->set_conv_lock)
{
$ffmpeg->convert_to_hd();
if($ffmpeg->lock_file && file_exists($ffmpeg->lock_file))
unlink($ffmpeg->lock_file);
break;
}
if($use_crons=='no')
sleep(10);
else
break;
}
}
unlink($ffmpeg->input_file);
}
?>

44
upload/activation.php Normal file
View file

@ -0,0 +1,44 @@
<?php
/*
**************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
define("THIS_PAGE","activation");
define("PARENT_PAGE",'signup');
require 'includes/config.inc.php';
if($userquery->udetails['usr_status']=='Ok'){
redirect_to(BASEURL);
}
/**
* Activating user account
*/
if(isset($_REQUEST['av_username']) || isset($_POST['activate_user']))
{
$user = mysql_clean($_REQUEST['av_username']);
$avcode = mysql_clean($_REQUEST['avcode']);
$userquery->activate_user_with_avcode($user,$avcode);
}
/**
* Requesting Activation Code
*/
if(isset($_POST['request_avcode']))
{
$email = mysql_clean($_POST['av_email']);
$userquery->send_activation_code($email);
}
template_files('activation.html');
display_it();
?>

View file

@ -0,0 +1,72 @@
<?php
/*
****************************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
*******************************************************************************
*/
define("THIS_PAGE","add_group_videos");
define("PARENT_PAGE","groups");
require 'includes/config.inc.php';
$pages->page_redir();
$url = mysql_clean($_GET['url']);
$details = $cbgroup->group_details_url($url);
assign('group',$details);
if(!$details)
e(lang("grp_exist_error"));
elseif(!$cbgroup->is_viewable($details))
$Cbucket->show_page = false;
elseif(!$cbgroup->is_member(userid(),$details['group_id']))
e(lang("you_not_allowed_add_grp_vids"));
else
{
///Getting User Videos
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,28);
$array = array('user'=>userid(),'limit'=>$get_limit);
$usr_vids = get_videos($array);
//echo $db->db_query;
assign('usr_vids',$usr_vids);
$array['count_only'] = true;
$total_rows = get_videos($array);
$total_pages = count_pages($total_rows,28);
//Pagination
$pages->paginate($total_pages,$page);
//Adding videos to group
if(isset($_POST['add_videos']))
{
$total = count($usr_vids);
for($i=0;$i<$total;$i++)
{
$videoid = $usr_vids[$i]['videoid'];
if($_POST['check_video_'.$videoid]=='yes')
$cbgroup->add_group_video($videoid,$details['group_id'],false);
else
$cbgroup->remove_group_video($videoid,$details['group_id'],false);
}
//Update Group Total Videos
$cbgroup->update_group_videos_count($details['group_id']);
$eh->flush_msg();
e(lang("sel_vids_updated"),"m");
}
assign('group',$details);
subtitle($details['group_name']);
}
template_files('add_group_videos.html');
display_it();
?>

View file

@ -0,0 +1,32 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
//Adding Permission
if(isset($_POST['add_permission']))
{
$userquery->add_new_permission($_POST);
}
//Deleting Permission
if(!empty($_GET['perm_del']))
{
$userquery->remove_permission($_GET['perm_del']);
}
template_files('_permission.html');
display_it();
?>

View file

@ -0,0 +1,30 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
if(isset($_POST['add_field']))
{
$array = $_POST;
$array['add_field'] = '';
add_custom_field($array);
}
Assign('msg',@$msg);
Template('header.html');
Template('leftmenu.html');
Template('message.html');
Template('add_custom_fields.html');
Template('footer.html');
?>

View file

@ -0,0 +1,6 @@
<?php
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
header("location:".cblink(array("name"=>"create_group")));
?>

View file

@ -0,0 +1,30 @@
<?php
/**
* @Software : ClipBucket
* @Author : Arslan Hassan
* @Since : Jan 5 2009
* @Function : Add Member
* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('member_moderation');
$pages->page_redir();
if(isset($_POST['add_member']))
{
if($userquery->signup_user($_POST))
{
e(lang("new_mem_added"),"m");
$_POST = '';
}
}
subtitle("Add New Member");
template_files('add_members.html');
display_it();
?>

View file

@ -0,0 +1,27 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('web_config_access');
$pages->page_redir();
if(isset($_POST['add_phrase']))
{
$name = mysql_clean($_POST['name']);
$text = mysql_real_escape_string($_POST['text']);
$lang_code = mysql_clean($_POST['lang_code']);
$lang_obj->add_phrase($name,$text,$lang_code);
}
subtitle("Add Language Phrase");
template_files('add_phrase.html');
display_it();
?>

View file

@ -0,0 +1,47 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
$userquery->perm_check('ad_manager_access',true);
//Removing Placement
if(isset($_GET['remove'])){
$placement = mysql_clean($_GET['remove']);
$msg =$ads_query->RemovePlacement($placement);
}
//Adding Placement
if(isset($_POST['AddPlacement'])){
$placement_name = mysql_clean($_POST['placement_name']);
$placement_code = mysql_clean($_POST['placement_code']);
$array = array($placement_name,$placement_code);
$msg = $ads_query->AddPlacement($array);
}
//Getting List Of Placement
$sql = "SELECT * FROM ".tbl("ads_placements");
$ads_exec = $db->Execute($sql);
$ads_placements = $ads_exec->getrows();
$total_placements = $ads_exec->recordcount() + 0;
//Getting total Ads in each placement
for($id=0;$id<=$total_placements;$id++)
{
$ads_placements[$id]['total_ads'] = $adsObj->count_ads_in_placement($ads_placements[$id]['placement']);
}
Assign('ads_placements',$ads_placements);
subtitle("Add Advertisment Placement");
template_files('ads_add_placements.html');
display_it();
?>

View file

@ -0,0 +1,61 @@
<?php
/*
***************************************************************
| Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
***************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
$userquery->perm_check('ad_manager_access',true);
//Adding
if(isset($_POST['add']))
{
$adsObj->AddAd();
}
//Updating
if(isset($_POST['update']))
{
$ad_id = mysql_clean($_GET['ad_id']);
$array = $_POST;
$array['ad_id'] = $ad_id;
$adsObj->EditAd($array);
}
//Deleting
if(isset($_GET['delete']))
{
$adsObj->DeleteAd($_GET['delete']);
}
//Chaing Ad Status
if(isset($_GET['activate']))
{
$adid = mysql_clean($_GET['activate']);
$adsObj->ChangeAdStatus(1,$adid);
}
if(isset($_GET['deactivate']))
{
$adid = mysql_clean($_GET['deactivate']);
$adsObj->ChangeAdStatus(0,$adid);
}
//Editing Ad
if(isset($_GET['ad_id']))
{
$ad_id = mysql_clean($_GET['ad_id']);
$ad_data = $adsObj->get_ad_details($ad_id);
if(!$ad_data)
e(lang("ad_exists_error1"));
else
assign('ad_data',$ad_data);
}
subtitle("Advertisments Manager");
template_files('ads_manager.html');
display_it();
?>

View file

@ -0,0 +1,79 @@
<?php
/*
*******************************************
| Copyright (c) 2007-2010 Clip-Bucket.com & (Arslan Hassan). All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
*******************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
//Form Processing
if(isset($_POST['add_cateogry'])){
$cbvid->add_category($_POST);
}
//Making Categoyr as Default
if(isset($_GET['make_default']))
{
$cid = mysql_clean($_GET['make_default']);
$cbvid->make_default_category($cid);
}
//Edit Categoty
if(isset($_GET['category'])){
assign("edit_category","show");
if(isset($_POST['update_category']))
{
$cbvid->update_category($_POST);
}
assign('cat_details',$cbvid->get_category($_GET['category']));
}
//Delete Category
if(isset($_GET['delete_category'])){
$cbvid->delete_category($_GET['delete_category']);
}
$cats = $cbvid->get_categories();
$pid = $cbvid->get_category_field($_GET['category'],'parent_id');
if($pid)
$selected = $pid;
$parent_cats = $cbvid->admin_area_cats($selected);
//Updating Category Order
if(isset($_POST['update_order']))
{
foreach($cats as $cat)
{
if(!empty($cat['category_id']))
{
$order = $_POST['category_order_'.$cat['category_id']];
$cbvid->update_cat_order($cat['category_id'],$order);
}
}
$cats = $cbvid->get_categories();
}
//Assing Category Values
assign('category',$cats);
assign('parent_cats',$parent_cats);
assign('total',$cbvid->total_categories());
subtitle("Video Category Manager");
Assign('msg',@$msg);
template_files('category.html');
display_it();
?>

View file

@ -0,0 +1,64 @@
<?php
/*
***************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
if($_GET['delete_lock'])
{
if(conv_lock_exists())
{
unlink(TEMP_DIR.'/conv_lock.loc');
e("Conversion lock has been deleted","m");
}else
e("There is no conversion lock");
}
if(isset($_POST['delete_selected']))
{
$total = count($_POST['check_queue']);
for($i=0;$i<=$total;$i++)
{
$myquery->queue_action("delete",$_POST['check_queue'][$i]);
}
e("Selected items have been deleted","m");
}
if(isset($_POST['processed']))
{
$total = count($_POST['check_queue']);
for($i=0;$i<=$total;$i++)
{
$myquery->queue_action("processed",$_POST['check_queue'][$i]);
}
e("Selected items have been set changed to processed","m");
}
if(isset($_POST['pending']))
{
$total = count($_POST['check_queue']);
for($i=0;$i<=$total;$i++)
{
$myquery->queue_action("pending",$_POST['check_queue'][$i]);
}
e("Selected items have been set changed to processed","m");
}
//Getting List of Conversion Queue
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,RESULTS);
$queue_list = $myquery->get_conversion_queue(NULL,$get_limit);
assign('queues',$queue_list);
$total_rows = get_videos($vcount);
$total_pages = count_pages($db->count(tbl('conversion_queue'),"cqueue_id"),RESULTS);
$pages->paginate($total_pages,$page);
subtitle("Conversion Queue Manager");
template_files("cb_conversion_queue.html");
display_it();
?>

View file

@ -0,0 +1,17 @@
<?php
/*
***************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
subtitle("ClipBucket Server Module Checker");
template_files("cb_mod_check.html");
display_it();
?>

View file

@ -0,0 +1,111 @@
<?php
include '../../includes/admin_config.php';
include 'ofc-library/open-flash-chart.php';
$days = 10;
$last_week = time()-86400*$days + 86400;
$the_last_week = date('M d', $last_week);
$title = new title("ClipBucket Daily Activity ".$the_last_week." - ".date("M d"));
$title->set_style("{font-size:14px;font-family:Century Gothic;font-weight:bold}");
$vid_stats = $data['video_stats'];
$vid_stats = json_decode($vid_stats);
$year = array();
//Getting This Weeks Data
for($i=0;$i<$days;$i++)
{
if($i<$days-1)
{
$date_pattern = date("Y-m-d",$last_week+($i*86400));
//echo "date_added LIKE '%$date_pattern%'";
$data = $db->select(tbl("stats"),"*"," date_added LIKE '%$date_pattern%' ",1);
$data = $data[0];
$datas[] = $data;
}
$year[] = date("M d",$last_week+($i*86400));
}
for($i=0;$i<$days;$i++)
{
$day[$i]['video'] = json_decode($datas[$i]['video_stats']);
$day[$i]['users'] = json_decode($datas[$i]['user_stats']);
$day[$i]['groups'] = json_decode($datas[$i]['group_stats']);
}
$max = 1;
for($i=0;$i<$days;$i++)
{
if($i==$days-1)
{
$vid_uploads[] = $cbvid->get_videos(array("count_only"=>true,"date_span"=>"today"))+0;
$user_signups[] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today"))+0;
$groups_added[] = $cbgroup->get_groups(array("count_only"=>true,"date_span"=>"today"))+0;
}else{
$vid_uploads[] =$day[$i]['video']->uploads+0;
$user_signups[] =$day[$i]['users']->signups+0;
$groups_added[] =$day[$i]['groups']->created+0;
}
$max = max($max,$vid_uploads[$i],$user_signups[$i],$groups_added[$i]);
}
$vid_line = new line();
$vid_line->set_values($vid_uploads);
$vid_line->colour( '#336600');
$vid_line->set_key('Videos', 14);
$user_line = new line();
$user_line->set_values($user_signups);
$user_line->colour( '#0099cc');
$user_line->set_key('User', 14);
$grp_line = new line();
$grp_line->set_values($groups_added);
$grp_line->colour( '#990000');
$grp_line->set_key('Groups', 14);
$max = $max;
$steps = round($max/5,0.49);
$y = new y_axis();
$y->set_range( 0, $max, $steps);
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $vid_line );
$chart->add_element( $user_line );
$chart->add_element( $grp_line );
$x_labels = new x_axis_labels();
$x_labels->set_steps( 1 );
$x_labels->set_vertical();
$x_labels->set_colour( '#A2ACBA' );
$x_labels->set_labels( $year );
$x = new x_axis();
$x->set_colour( '#A2ACBA' );
$x->set_grid_colour( '#D7E4A3' );
$x->set_offset( false );
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels( $x_labels );
$chart->set_x_axis( $x );
$chart->set_y_axis( $y );
echo $chart->toString();
?>

View file

@ -0,0 +1,109 @@
<?php
include '../../includes/admin_config.php';
include 'ofc-library/open-flash-chart.php';
$days = 7;
$last_week = time()-86400*$days + 86400;
$the_last_week = date('M d', $last_week);
$title = new title("Groups Stats ".$the_last_week." - ".date("M d"));
$title->set_style("{font-size:14px;font-family:Century Gothic;font-weight:bold}");
$vid_stats = $data['video_stats'];
$vid_stats = json_decode($vid_stats);
$year = array();
//Getting This Weeks Data
for($i=0;$i<$days;$i++)
{
if($i<$days-1)
{
$date_pattern = date("Y-m-d",$last_week+($i*86400));
$data = $db->select(tbl("stats"),"*"," date_added LIKE '%$date_pattern%' ",1);
$data = $data[0];
$datas[] = $data;
}
$year[] = date("M d",$last_week+($i*86400));
}
for($i=0;$i<$days;$i++)
{
$day[$i]['video'] = json_decode($datas[$i]['video_stats'],true);
$day[$i]['users'] = json_decode($datas[$i]['user_stats'],true);
$day[$i]['groups'] = json_decode($datas[$i]['group_stats'],true);
}
$max = 1;
for($i=0;$i<$days;$i++)
{
if($i==$days-1)
{
$groups[] = $cbgroup->get_groups(array("count_only"=>true,"date_span"=>"today"))+0;
$active[] = $cbgroup->get_groups(array("count_only"=>true,"date_span"=>"today","active"=>'yes'))+0;
$tota_topics = $db->select(tbl("groups"),"SUM(total_topics) as the_topics"," date_added LIKE '%$date%'");
$topics_bar_data[] = $tota_topics['the_topics']+0;
}else{
$groups[] =$day[$i]['groups']->created+0;
$active[] =$day[$i]['groups']->active+0;
$topics_bar_data[] =$day[$i]['groups']->total_topics+0;
}
$max = max($max,$groups[$i],$active[$i],$topics_bar_data[$i]);
}
$total_bars = new bar_cylinder();
$total_bars->set_values($groups);
$total_bars->colour( '#0066ff');
$total_bars->key('Total', 14);
$active_bars = new bar_cylinder();
$active_bars->set_values($active);
$active_bars->colour( '#99cc00');
$active_bars->key('Active', 14);
$topics_bar = new bar_cylinder();
$topics_bar->set_values($topics_bar_data);
$topics_bar->colour( '#BF3B69');
$topics_bar->key('Topics', 14);
//$max = $max+(round($max/2,0.49));
$steps = round($max/5,0.49);
$y = new y_axis();
$y->set_range( 0, $max, $steps);
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $total_bars );
$chart->add_element( $active_bars );
$chart->add_element( $topics_bar );
$x_labels = new x_axis_labels();
$x_labels->set_steps( 1 );
$x_labels->set_colour( '#A2ACBA' );
$x_labels->set_labels( $year );
$x = new x_axis();
$x->set_colour( '#A2ACBA' );
$x->set_grid_colour( '#D7E4A3' );
$x->set_offset( true );
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels( $x_labels );
$chart->set_x_axis( $x );
$chart->set_bg_colour('#ffffff');
$chart->set_y_axis( $y );
echo $chart->toString();
?>

View file

@ -0,0 +1,806 @@
<?php
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
/**
* Converts to and from JSON format.
*
* JSON (JavaScript Object Notation) is a lightweight data-interchange
* format. It is easy for humans to read and write. It is easy for machines
* to parse and generate. It is based on a subset of the JavaScript
* Programming Language, Standard ECMA-262 3rd Edition - December 1999.
* This feature can also be found in Python. JSON is a text format that is
* completely language independent but uses conventions that are familiar
* to programmers of the C-family of languages, including C, C++, C#, Java,
* JavaScript, Perl, TCL, and many others. These properties make JSON an
* ideal data-interchange language.
*
* This package provides a simple encoder and decoder for JSON notation. It
* is intended for use with client-side Javascript applications that make
* use of HTTPRequest to perform server communication functions - data can
* be encoded into JSON notation for use in a client-side javascript, or
* decoded from incoming Javascript requests. JSON format is native to
* Javascript, and can be directly eval()'ed with no further parsing
* overhead
*
* All strings should be in ASCII or UTF-8 format!
*
* LICENSE: Redistribution and use in source and binary forms, with or
* without modification, are permitted provided that the following
* conditions are met: Redistributions of source code must retain the
* above copyright notice, this list of conditions and the following
* disclaimer. Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
* NO EVENT SHALL CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGE.
*
* @category
* @package Services_JSON
* @author Michal Migurski <mike-json@teczno.com>
* @author Matt Knapp <mdknapp[at]gmail[dot]com>
* @author Brett Stimmerman <brettstimmerman[at]gmail[dot]com>
* @copyright 2005 Michal Migurski
* @version CVS: $Id: JSON.php,v 1.31 2006/06/28 05:54:17 migurski Exp $
* @license http://www.opensource.org/licenses/bsd-license.php
* @link http://pear.php.net/pepr/pepr-proposal-show.php?id=198
*/
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_SLICE', 1);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_STR', 2);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_ARR', 3);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_OBJ', 4);
/**
* Marker constant for Services_JSON::decode(), used to flag stack state
*/
define('SERVICES_JSON_IN_CMT', 5);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_LOOSE_TYPE', 16);
/**
* Behavior switch for Services_JSON::decode()
*/
define('SERVICES_JSON_SUPPRESS_ERRORS', 32);
/**
* Converts to and from JSON format.
*
* Brief example of use:
*
* <code>
* // create a new instance of Services_JSON
* $json = new Services_JSON();
*
* // convert a complexe value to JSON notation, and send it to the browser
* $value = array('foo', 'bar', array(1, 2, 'baz'), array(3, array(4)));
* $output = $json->encode($value);
*
* print($output);
* // prints: ["foo","bar",[1,2,"baz"],[3,[4]]]
*
* // accept incoming POST data, assumed to be in JSON notation
* $input = file_get_contents('php://input', 1000000);
* $value = $json->decode($input);
* </code>
*/
class Services_JSON
{
/**
* constructs a new JSON instance
*
* @param int $use object behavior flags; combine with boolean-OR
*
* possible values:
* - SERVICES_JSON_LOOSE_TYPE: loose typing.
* "{...}" syntax creates associative arrays
* instead of objects in decode().
* - SERVICES_JSON_SUPPRESS_ERRORS: error suppression.
* Values which can't be encoded (e.g. resources)
* appear as NULL instead of throwing errors.
* By default, a deeply-nested resource will
* bubble up with an error, so all return values
* from encode() should be checked with isError()
*/
function Services_JSON($use = 0)
{
$this->use = $use;
}
/**
* convert a string from one UTF-16 char to one UTF-8 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf16 UTF-16 character
* @return string UTF-8 character
* @access private
*/
function utf162utf8($utf16)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf16, 'UTF-8', 'UTF-16');
}
$bytes = (ord($utf16{0}) << 8) | ord($utf16{1});
switch(true) {
case ((0x7F & $bytes) == $bytes):
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x7F & $bytes);
case (0x07FF & $bytes) == $bytes:
// return a 2-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xC0 | (($bytes >> 6) & 0x1F))
. chr(0x80 | ($bytes & 0x3F));
case (0xFFFF & $bytes) == $bytes:
// return a 3-byte UTF-8 character
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0xE0 | (($bytes >> 12) & 0x0F))
. chr(0x80 | (($bytes >> 6) & 0x3F))
. chr(0x80 | ($bytes & 0x3F));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* convert a string from one UTF-8 char to one UTF-16 char
*
* Normally should be handled by mb_convert_encoding, but
* provides a slower PHP-only method for installations
* that lack the multibye string extension.
*
* @param string $utf8 UTF-8 character
* @return string UTF-16 character
* @access private
*/
function utf82utf16($utf8)
{
// oh please oh please oh please oh please oh please
if(function_exists('mb_convert_encoding')) {
return mb_convert_encoding($utf8, 'UTF-16', 'UTF-8');
}
switch(strlen($utf8)) {
case 1:
// this case should never be reached, because we are in ASCII range
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return $utf8;
case 2:
// return a UTF-16 character from a 2-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr(0x07 & (ord($utf8{0}) >> 2))
. chr((0xC0 & (ord($utf8{0}) << 6))
| (0x3F & ord($utf8{1})));
case 3:
// return a UTF-16 character from a 3-byte UTF-8 char
// see: http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
return chr((0xF0 & (ord($utf8{0}) << 4))
| (0x0F & (ord($utf8{1}) >> 2)))
. chr((0xC0 & (ord($utf8{1}) << 6))
| (0x7F & ord($utf8{2})));
}
// ignoring UTF-32 for now, sorry
return '';
}
/**
* encodes an arbitrary variable into JSON format
*
* @param mixed $var any number, boolean, string, array, or object to be encoded.
* see argument 1 to Services_JSON() above for array-parsing behavior.
* if var is a strng, note that encode() always expects it
* to be in ASCII or UTF-8 format!
*
* @return mixed JSON string representation of input var or an error if a problem occurs
* @access public
*/
function encode($var)
{
switch (gettype($var)) {
case 'boolean':
return $var ? 'true' : 'false';
case 'NULL':
return 'null';
case 'integer':
return (int) $var;
case 'double':
case 'float':
return (float) $var;
case 'string':
// STRINGS ARE EXPECTED TO BE IN ASCII OR UTF-8 FORMAT
$ascii = '';
$strlen_var = strlen($var);
/*
* Iterate over every character in the string,
* escaping with a slash or encoding to UTF-8 where necessary
*/
for ($c = 0; $c < $strlen_var; ++$c) {
$ord_var_c = ord($var{$c});
switch (true) {
case $ord_var_c == 0x08:
$ascii .= '\b';
break;
case $ord_var_c == 0x09:
$ascii .= '\t';
break;
case $ord_var_c == 0x0A:
$ascii .= '\n';
break;
case $ord_var_c == 0x0C:
$ascii .= '\f';
break;
case $ord_var_c == 0x0D:
$ascii .= '\r';
break;
case $ord_var_c == 0x22:
case $ord_var_c == 0x2F:
case $ord_var_c == 0x5C:
// double quote, slash, slosh
$ascii .= '\\'.$var{$c};
break;
case (($ord_var_c >= 0x20) && ($ord_var_c <= 0x7F)):
// characters U-00000000 - U-0000007F (same as ASCII)
$ascii .= $var{$c};
break;
case (($ord_var_c & 0xE0) == 0xC0):
// characters U-00000080 - U-000007FF, mask 110XXXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c, ord($var{$c + 1}));
$c += 1;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF0) == 0xE0):
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}));
$c += 2;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xF8) == 0xF0):
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}));
$c += 3;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFC) == 0xF8):
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}));
$c += 4;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
case (($ord_var_c & 0xFE) == 0xFC):
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$char = pack('C*', $ord_var_c,
ord($var{$c + 1}),
ord($var{$c + 2}),
ord($var{$c + 3}),
ord($var{$c + 4}),
ord($var{$c + 5}));
$c += 5;
$utf16 = $this->utf82utf16($char);
$ascii .= sprintf('\u%04s', bin2hex($utf16));
break;
}
}
return '"'.$ascii.'"';
case 'array':
/*
* As per JSON spec if any array key is not an integer
* we must treat the the whole array as an object. We
* also try to catch a sparsely populated associative
* array with numeric keys here because some JS engines
* will create an array with empty indexes up to
* max_index which can cause memory issues and because
* the keys, which may be relevant, will be remapped
* otherwise.
*
* As per the ECMA and JSON specification an object may
* have any string as a property. Unfortunately due to
* a hole in the ECMA specification if the key is a
* ECMA reserved word or starts with a digit the
* parameter is only accessible using ECMAScript's
* bracket notation.
*/
// treat as a JSON object
if (is_array($var) && count($var) && (array_keys($var) !== range(0, sizeof($var) - 1))) {
$properties = array_map(array($this, 'name_value'),
array_keys($var),
array_values($var));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
}
// treat it like a regular array
$elements = array_map(array($this, 'encode'), $var);
foreach($elements as $element) {
if(Services_JSON::isError($element)) {
return $element;
}
}
return '[' . join(',', $elements) . ']';
case 'object':
$vars = get_object_vars($var);
$properties = array_map(array($this, 'name_value'),
array_keys($vars),
array_values($vars));
foreach($properties as $property) {
if(Services_JSON::isError($property)) {
return $property;
}
}
return '{' . join(',', $properties) . '}';
default:
return ($this->use & SERVICES_JSON_SUPPRESS_ERRORS)
? 'null'
: new Services_JSON_Error(gettype($var)." can not be encoded as JSON string");
}
}
/**
* array-walking function for use in generating JSON-formatted name-value pairs
*
* @param string $name name of key to use
* @param mixed $value reference to an array element to be encoded
*
* @return string JSON-formatted name-value pair, like '"name":value'
* @access private
*/
function name_value($name, $value)
{
$encoded_value = $this->encode($value);
if(Services_JSON::isError($encoded_value)) {
return $encoded_value;
}
return $this->encode(strval($name)) . ':' . $encoded_value;
}
/**
* reduce a string by removing leading and trailing comments and whitespace
*
* @param $str string string value to strip of comments and whitespace
*
* @return string string value stripped of comments and whitespace
* @access private
*/
function reduce_string($str)
{
$str = preg_replace(array(
// eliminate single line comments in '// ...' form
'#^\s*//(.+)$#m',
// eliminate multi-line comments in '/* ... */' form, at start of string
'#^\s*/\*(.+)\*/#Us',
// eliminate multi-line comments in '/* ... */' form, at end of string
'#/\*(.+)\*/\s*$#Us'
), '', $str);
// eliminate extraneous space
return trim($str);
}
/**
* decodes a JSON string into appropriate variable
*
* @param string $str JSON-formatted string
*
* @return mixed number, boolean, string, array, or object
* corresponding to given JSON input string.
* See argument 1 to Services_JSON() above for object-output behavior.
* Note that decode() always returns strings
* in ASCII or UTF-8 format!
* @access public
*/
function decode($str)
{
$str = $this->reduce_string($str);
switch (strtolower($str)) {
case 'true':
return true;
case 'false':
return false;
case 'null':
return null;
default:
$m = array();
if (is_numeric($str)) {
// Lookie-loo, it's a number
// This would work on its own, but I'm trying to be
// good about returning integers where appropriate:
// return (float)$str;
// Return float or int, as appropriate
return ((float)$str == (integer)$str)
? (integer)$str
: (float)$str;
} elseif (preg_match('/^("|\').*(\1)$/s', $str, $m) && $m[1] == $m[2]) {
// STRINGS RETURNED IN UTF-8 FORMAT
$delim = substr($str, 0, 1);
$chrs = substr($str, 1, -1);
$utf8 = '';
$strlen_chrs = strlen($chrs);
for ($c = 0; $c < $strlen_chrs; ++$c) {
$substr_chrs_c_2 = substr($chrs, $c, 2);
$ord_chrs_c = ord($chrs{$c});
switch (true) {
case $substr_chrs_c_2 == '\b':
$utf8 .= chr(0x08);
++$c;
break;
case $substr_chrs_c_2 == '\t':
$utf8 .= chr(0x09);
++$c;
break;
case $substr_chrs_c_2 == '\n':
$utf8 .= chr(0x0A);
++$c;
break;
case $substr_chrs_c_2 == '\f':
$utf8 .= chr(0x0C);
++$c;
break;
case $substr_chrs_c_2 == '\r':
$utf8 .= chr(0x0D);
++$c;
break;
case $substr_chrs_c_2 == '\\"':
case $substr_chrs_c_2 == '\\\'':
case $substr_chrs_c_2 == '\\\\':
case $substr_chrs_c_2 == '\\/':
if (($delim == '"' && $substr_chrs_c_2 != '\\\'') ||
($delim == "'" && $substr_chrs_c_2 != '\\"')) {
$utf8 .= $chrs{++$c};
}
break;
case preg_match('/\\\u[0-9A-F]{4}/i', substr($chrs, $c, 6)):
// single, escaped unicode character
$utf16 = chr(hexdec(substr($chrs, ($c + 2), 2)))
. chr(hexdec(substr($chrs, ($c + 4), 2)));
$utf8 .= $this->utf162utf8($utf16);
$c += 5;
break;
case ($ord_chrs_c >= 0x20) && ($ord_chrs_c <= 0x7F):
$utf8 .= $chrs{$c};
break;
case ($ord_chrs_c & 0xE0) == 0xC0:
// characters U-00000080 - U-000007FF, mask 110XXXXX
//see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 2);
++$c;
break;
case ($ord_chrs_c & 0xF0) == 0xE0:
// characters U-00000800 - U-0000FFFF, mask 1110XXXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 3);
$c += 2;
break;
case ($ord_chrs_c & 0xF8) == 0xF0:
// characters U-00010000 - U-001FFFFF, mask 11110XXX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 4);
$c += 3;
break;
case ($ord_chrs_c & 0xFC) == 0xF8:
// characters U-00200000 - U-03FFFFFF, mask 111110XX
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 5);
$c += 4;
break;
case ($ord_chrs_c & 0xFE) == 0xFC:
// characters U-04000000 - U-7FFFFFFF, mask 1111110X
// see http://www.cl.cam.ac.uk/~mgk25/unicode.html#utf-8
$utf8 .= substr($chrs, $c, 6);
$c += 5;
break;
}
}
return $utf8;
} elseif (preg_match('/^\[.*\]$/s', $str) || preg_match('/^\{.*\}$/s', $str)) {
// array, or object notation
if ($str{0} == '[') {
$stk = array(SERVICES_JSON_IN_ARR);
$arr = array();
} else {
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = array();
} else {
$stk = array(SERVICES_JSON_IN_OBJ);
$obj = new stdClass();
}
}
array_push($stk, array('what' => SERVICES_JSON_SLICE,
'where' => 0,
'delim' => false));
$chrs = substr($str, 1, -1);
$chrs = $this->reduce_string($chrs);
if ($chrs == '') {
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} else {
return $obj;
}
}
//print("\nparsing {$chrs}\n");
$strlen_chrs = strlen($chrs);
for ($c = 0; $c <= $strlen_chrs; ++$c) {
$top = end($stk);
$substr_chrs_c_2 = substr($chrs, $c, 2);
if (($c == $strlen_chrs) || (($chrs{$c} == ',') && ($top['what'] == SERVICES_JSON_SLICE))) {
// found a comma that is not inside a string, array, etc.,
// OR we've reached the end of the character list
$slice = substr($chrs, $top['where'], ($c - $top['where']));
array_push($stk, array('what' => SERVICES_JSON_SLICE, 'where' => ($c + 1), 'delim' => false));
//print("Found split at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
if (reset($stk) == SERVICES_JSON_IN_ARR) {
// we are in an array, so just push an element onto the stack
array_push($arr, $this->decode($slice));
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
// we are in an object, so figure
// out the property name and set an
// element in an associative array,
// for now
$parts = array();
if (preg_match('/^\s*(["\'].*[^\\\]["\'])\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// "name":value pair
$key = $this->decode($parts[1]);
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
} elseif (preg_match('/^\s*(\w+)\s*:\s*(\S.*),?$/Uis', $slice, $parts)) {
// name:value pair, where name is unquoted
$key = $parts[1];
$val = $this->decode($parts[2]);
if ($this->use & SERVICES_JSON_LOOSE_TYPE) {
$obj[$key] = $val;
} else {
$obj->$key = $val;
}
}
}
} elseif ((($chrs{$c} == '"') || ($chrs{$c} == "'")) && ($top['what'] != SERVICES_JSON_IN_STR)) {
// found a quote, and we are not inside a string
array_push($stk, array('what' => SERVICES_JSON_IN_STR, 'where' => $c, 'delim' => $chrs{$c}));
//print("Found start of string at {$c}\n");
} elseif (($chrs{$c} == $top['delim']) &&
($top['what'] == SERVICES_JSON_IN_STR) &&
((strlen(substr($chrs, 0, $c)) - strlen(rtrim(substr($chrs, 0, $c), '\\'))) % 2 != 1)) {
// found a quote, we're in a string, and it's not escaped
// we know that it's not escaped becase there is _not_ an
// odd number of backslashes at the end of the string so far
array_pop($stk);
//print("Found end of string at {$c}: ".substr($chrs, $top['where'], (1 + 1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '[') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-bracket, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_ARR, 'where' => $c, 'delim' => false));
//print("Found start of array at {$c}\n");
} elseif (($chrs{$c} == ']') && ($top['what'] == SERVICES_JSON_IN_ARR)) {
// found a right-bracket, and we're in an array
array_pop($stk);
//print("Found end of array at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($chrs{$c} == '{') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a left-brace, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_OBJ, 'where' => $c, 'delim' => false));
//print("Found start of object at {$c}\n");
} elseif (($chrs{$c} == '}') && ($top['what'] == SERVICES_JSON_IN_OBJ)) {
// found a right-brace, and we're in an object
array_pop($stk);
//print("Found end of object at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
} elseif (($substr_chrs_c_2 == '/*') &&
in_array($top['what'], array(SERVICES_JSON_SLICE, SERVICES_JSON_IN_ARR, SERVICES_JSON_IN_OBJ))) {
// found a comment start, and we are in an array, object, or slice
array_push($stk, array('what' => SERVICES_JSON_IN_CMT, 'where' => $c, 'delim' => false));
$c++;
//print("Found start of comment at {$c}\n");
} elseif (($substr_chrs_c_2 == '*/') && ($top['what'] == SERVICES_JSON_IN_CMT)) {
// found a comment end, and we're in one now
array_pop($stk);
$c++;
for ($i = $top['where']; $i <= $c; ++$i)
$chrs = substr_replace($chrs, ' ', $i, 1);
//print("Found end of comment at {$c}: ".substr($chrs, $top['where'], (1 + $c - $top['where']))."\n");
}
}
if (reset($stk) == SERVICES_JSON_IN_ARR) {
return $arr;
} elseif (reset($stk) == SERVICES_JSON_IN_OBJ) {
return $obj;
}
}
}
}
/**
* @todo Ultimately, this should just call PEAR::isError()
*/
function isError($data, $code = null)
{
if (class_exists('pear')) {
return PEAR::isError($data, $code);
} elseif (is_object($data) && (get_class($data) == 'services_json_error' ||
is_subclass_of($data, 'services_json_error'))) {
return true;
}
return false;
}
}
if (class_exists('PEAR_Error')) {
class Services_JSON_Error extends PEAR_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
parent::PEAR_Error($message, $code, $mode, $options, $userinfo);
}
}
} else {
/**
* @todo Ultimately, this class shall be descended from PEAR_Error
*/
class Services_JSON_Error
{
function Services_JSON_Error($message = 'unknown error', $code = null,
$mode = null, $options = null, $userinfo = null)
{
}
}
}
?>

View file

@ -0,0 +1,231 @@
<?php
/**
* A private class. All the other line-dots inherit from this.
* Gives them all some common methods.
*/
class dot_base
{
/**
* @param $type string
* @param $value integer
*/
function dot_base($type, $value=null)
{
$this->type = $type;
if( isset( $value ) )
$this->value( $value );
}
/**
* For line charts that only require a Y position
* for each point.
* @param $value as integer, the Y position
*/
function value( $value )
{
$this->value = $value;
}
/**
* For scatter charts that require an X and Y position for
* each point.
*
* @param $x as integer
* @param $y as integer
*/
function position( $x, $y )
{
$this->x = $x;
$this->y = $y;
}
/**
* @param $colour is a string, HEX colour, e.g. '#FF0000' red
*/
function colour($colour)
{
$this->colour = $colour;
return $this;
}
/**
* The tooltip for this dot.
*/
function tooltip( $tip )
{
$this->tip = $tip;
return $this;
}
/**
* @param $size is an integer. Size of the dot.
*/
function size($size)
{
$tmp = 'dot-size';
$this->$tmp = $size;
return $this;
}
/**
* a private method
*/
function type( $type )
{
$this->type = $type;
return $this;
}
/**
* @param $size is an integer. The size of the hollow 'halo' around the dot that masks the line.
*/
function halo_size( $size )
{
$tmp = 'halo-size';
$this->$tmp = $size;
return $this;
}
/**
* @param $do as string. One of three options (examples):
* - "http://example.com" - browse to this URL
* - "https://example.com" - browse to this URL
* - "trace:message" - print this message in the FlashDevelop debug pane
* - all other strings will be called as Javascript functions, so a string "hello_world"
* will call the JS function "hello_world(index)". It passes in the index of the
* point.
*/
function on_click( $do )
{
$tmp = 'on-click';
$this->$tmp = $do;
}
}
/**
* Draw a hollow dot
*/
class hollow_dot extends dot_base
{
function hollow_dot($value=null)
{
parent::dot_base( 'hollow-dot', $value );
}
}
/**
* Draw a star
*/
class star extends dot_base
{
/**
* The constructor, takes an optional $value
*/
function star($value=null)
{
parent::dot_base( 'star', $value );
}
/**
* @param $angle is an integer.
*/
function rotation($angle)
{
$this->rotation = $angle;
return $this;
}
/**
* @param $is_hollow is a boolean.
*/
function hollow($is_hollow)
{
$this->hollow = $is_hollow;
}
}
/**
* Draw a 'bow tie' shape.
*/
class bow extends dot_base
{
/**
* The constructor, takes an optional $value
*/
function bow($value=null)
{
parent::dot_base( 'bow', $value );
}
/**
* Rotate the anchor object.
* @param $angle is an integer.
*/
function rotation($angle)
{
$this->rotation = $angle;
return $this;
}
}
/**
* An <i><b>n</b></i> sided shape.
*/
class anchor extends dot_base
{
/**
* The constructor, takes an optional $value
*/
function anchor($value=null)
{
parent::dot_base( 'anchor', $value );
}
/**
* Rotate the anchor object.
* @param $angle is an integer.
*/
function rotation($angle)
{
$this->rotation = $angle;
return $this;
}
/**
* @param $sides is an integer. Number of sides this shape has.
*/
function sides($sides)
{
$this->sides = $sides;
return $this;
}
}
/**
* A simple dot
*/
class dot extends dot_base
{
/**
* The constructor, takes an optional $value
*/
function dot($value=null)
{
parent::dot_base( 'dot', $value );
}
}
/**
* A simple dot
*/
class solid_dot extends dot_base
{
/**
* The constructor, takes an optional $value
*/
function solid_dot($value=null)
{
parent::dot_base( 'solid-dot', $value );
}
}

View file

@ -0,0 +1,86 @@
<?php
// Pretty print some JSON
function json_format($json)
{
$tab = " ";
$new_json = "";
$indent_level = 0;
$in_string = false;
/*
commented out by monk.e.boy 22nd May '08
because my web server is PHP4, and
json_* are PHP5 functions...
$json_obj = json_decode($json);
if($json_obj === false)
return false;
$json = json_encode($json_obj);
*/
$len = strlen($json);
for($c = 0; $c < $len; $c++)
{
$char = $json[$c];
switch($char)
{
case '{':
case '[':
if(!$in_string)
{
$new_json .= $char . "\n" . str_repeat($tab, $indent_level+1);
$indent_level++;
}
else
{
$new_json .= $char;
}
break;
case '}':
case ']':
if(!$in_string)
{
$indent_level--;
$new_json .= "\n" . str_repeat($tab, $indent_level) . $char;
}
else
{
$new_json .= $char;
}
break;
case ',':
if(!$in_string)
{
$new_json .= ",\n" . str_repeat($tab, $indent_level);
}
else
{
$new_json .= $char;
}
break;
case ':':
if(!$in_string)
{
$new_json .= ": ";
}
else
{
$new_json .= $char;
}
break;
case '"':
if($c > 0 && $json[$c-1] != '\\')
{
$in_string = !$in_string;
}
default:
$new_json .= $char;
break;
}
}
return $new_json;
}

View file

@ -0,0 +1,40 @@
<?php
/**
* inherits from line
*/
class area extends line
{
function area()
{
$this->type = "area";
}
/**
* the fill colour
*/
function set_fill_colour( $colour )
{
$this->fill = $colour;
}
/**
* sugar: see set_fill_colour
*/
function fill_colour( $colour )
{
$this->set_fill_colour( $colour );
return $this;
}
function set_fill_alpha( $alpha )
{
$tmp = "fill-alpha";
$this->$tmp = $alpha;
}
function set_loop()
{
$this->loop = true;
}
}

View file

@ -0,0 +1,10 @@
<?php
class area_hollow extends area_base
{
function area_hollow()
{
$this->type = "area_hollow";
parent::area_base();
}
}

View file

@ -0,0 +1,10 @@
<?php
class area_line extends area_base
{
function area_line()
{
$this->type = "area_line";
parent::area_base();
}
}

View file

@ -0,0 +1,27 @@
<?php
class ofc_arrow
{
/**
*@param $x as number. Start x position
*@param $y as number. Start y position
*@param $a as number. End x position
*@param $b as number. End y position
*@param $colour as string.
*@param $barb_length as number. Length of the barbs in pixels.
*/
function ofc_arrow($x, $y, $a, $b, $colour, $barb_length=10)
{
$this->type = "arrow";
$this->start = array("x"=>$x, "y"=>$y);
$this->end = array("x"=>$a, "y"=>$b);
$this->colour($colour);
$this->{"barb-length"} = $barb_length;
}
function colour( $colour )
{
$this->colour = $colour;
return $this;
}
}

View file

@ -0,0 +1,34 @@
<?php
include_once 'ofc_bar_base.php';
class bar_value
{
function bar_value( $top, $bottom=null )
{
$this->top = $top;
if( isset( $bottom ) )
$this->bottom = $bottom;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class bar extends bar_base
{
function bar()
{
$this->type = "bar";
parent::bar_base();
}
}

View file

@ -0,0 +1,22 @@
<?php
include_once 'ofc_bar_base.php';
class bar_3d_value
{
function bar_3d_value( $top )
{
$this->top = $top;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}

View file

@ -0,0 +1,97 @@
<?php
/* this is a base class */
class bar_base
{
function bar_base(){}
/**
* @param $text as string the key text
* @param $size as integer, size in pixels
*/
function set_key( $text, $size )
{
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $size;
}
/**
* syntatical sugar.
*/
function key( $text, $size )
{
$this->set_key( $text, $size );
}
/**
* @param $v as an array, a mix of:
* - a bar_value class. You can use this to customise the paramters of each bar.
* - integer. This is the Y position of the top of the bar.
*/
function set_values( $v )
{
$this->values = $v;
}
/**
* see set_values
*/
function append_value( $v )
{
$this->values[] = $v;
}
/**
* @param $colour as string, a HEX colour, e.g. '#ff0000' red
*/
function set_colour( $colour )
{
$this->colour = $colour;
}
/**
*syntatical sugar
*/
function colour( $colour )
{
$this->set_colour( $colour );
}
/**
* @param $alpha as real number (range 0 to 1), e.g. 0.5 is half transparent
*/
function set_alpha( $alpha )
{
$this->alpha = $alpha;
}
/**
* @param $tip as string, the tip to show. May contain various magic variables.
*/
function set_tooltip( $tip )
{
$this->tip = $tip;
}
/**
*@param $on_show as line_on_show object
*/
function set_on_show($on_show)
{
$this->{'on-show'} = $on_show;
}
function set_on_click( $text )
{
$tmp = 'on-click';
$this->$tmp = $text;
}
function attach_to_right_y_axis()
{
$this->axis = 'right';
}
}

View file

@ -0,0 +1,39 @@
<?php
include_once 'ofc_bar_base.php';
class bar_filled_value extends bar_value
{
function bar_filled_value( $top, $bottom=null )
{
parent::bar_value( $top, $bottom );
}
function set_outline_colour( $outline_colour )
{
$tmp = 'outline-colour';
$this->$tmp = $outline_colour;
}
}
class bar_filled extends bar_base
{
function bar_filled( $colour=null, $outline_colour=null )
{
$this->type = "bar_filled";
parent::bar_base();
if( isset( $colour ) )
$this->set_colour( $colour );
if( isset( $outline_colour ) )
$this->set_outline_colour( $outline_colour );
}
function set_outline_colour( $outline_colour )
{
$tmp = 'outline-colour';
$this->$tmp = $outline_colour;
}
}

View file

@ -0,0 +1,131 @@
<?php
include_once 'ofc_bar_base.php';
class bar_on_show
{
/**
*@param $type as string. Can be any one of:
* - 'pop-up'
* - 'drop'
* - 'fade-in'
* - 'grow-up'
* - 'grow-down'
* - 'pop'
*
* @param $cascade as float. Cascade in seconds
* @param $delay as float. Delay before animation starts in seconds.
*/
function __construct($type, $cascade, $delay)
{
$this->type = $type;
$this->cascade = (float)$cascade;
$this->delay = (float)$delay;
}
}
class bar_value
{
/**
* @param $top as integer. The Y value of the top of the bar
* @param OPTIONAL $bottom as integer. The Y value of the bottom of the bar, defaults to Y min.
*/
function bar_value( $top, $bottom=null )
{
$this->top = $top;
if( isset( $bottom ) )
$this->bottom = $bottom;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class bar extends bar_base
{
function bar()
{
$this->type = "bar";
parent::bar_base();
}
}
class bar_glass extends bar_base
{
function bar_glass()
{
$this->type = "bar_glass";
parent::bar_base();
}
}
class bar_cylinder extends bar_base
{
function bar_cylinder()
{
$this->type = "bar_cylinder";
parent::bar_base();
}
}
class bar_cylinder_outline extends bar_base
{
function bar_cylinder_outline()
{
$this->type = "bar_cylinder_outline";
parent::bar_base();
}
}
class bar_rounded_glass extends bar_base
{
function bar_rounded_glass()
{
$this->type = "bar_round_glass";
parent::bar_base();
}
}
class bar_round extends bar_base
{
function bar_round()
{
$this->type = "bar_round";
parent::bar_base();
}
}
class bar_dome extends bar_base
{
function bar_dome()
{
$this->type = "bar_dome";
parent::bar_base();
}
}
class bar_round3d extends bar_base
{
function bar_round3d()
{
$this->type = "bar_round3d";
parent::bar_base();
}
}
class bar_3d extends bar_base
{
function bar_3d()
{
$this->type = "bar_3d";
parent::bar_base();
}
}

View file

@ -0,0 +1,29 @@
<?php
include_once 'ofc_bar_base.php';
class bar_sketch extends bar_base
{
/**
* @param $colour as string, HEX colour e.g. '#00ff00'
* @param $outline_colour as string, HEX colour e.g. '#ff0000'
* @param $fun_factor as integer, range 0 to 10. 0,1 and 2 are pretty boring.
* 4 to 6 is a bit fun, 7 and above is lots of fun.
*/
function bar_sketch( $colour, $outline_colour, $fun_factor )
{
$this->type = "bar_sketch";
parent::bar_base();
$this->set_colour( $colour );
$this->set_outline_colour( $outline_colour );
$this->offset = $fun_factor;
}
function set_outline_colour( $outline_colour )
{
$tmp = 'outline-colour';
$this->$tmp = $outline_colour;
}
}

View file

@ -0,0 +1,55 @@
<?php
include_once 'ofc_bar_base.php';
class bar_stack extends bar_base
{
function bar_stack()
{
$this->type = "bar_stack";
parent::bar_base();
}
function append_stack( $v )
{
$this->append_value( $v );
}
// an array of HEX colours strings
// e.g. array( '#ff0000', '#00ff00' );
function set_colours( $colours )
{
$this->colours = $colours;
}
// an array of bar_stack_value
function set_keys( $keys )
{
$this->keys = $keys;
}
}
class bar_stack_value
{
function bar_stack_value( $val, $colour )
{
$this->val = $val;
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class bar_stack_key
{
function bar_stack_key( $colour, $text, $font_size )
{
$this->colour = $colour;
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $font_size;
}
}

View file

@ -0,0 +1,41 @@
<?php
include_once 'ofc_bar_base.php';
class candle_value
{
/**
*
*/
function candle_value( $high, $open, $close, $low )
{
$this->high = $high;
$this->top = $open;
$this->bottom = $close;
$this->low = $low;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class candle extends bar_base
{
function candle($colour, $negative_colour=null)
{
$this->type = "candle";
parent::bar_base();
$this->set_colour( $colour );
if(!is_null($negative_colour))
$this->{'negative-colour'} = $negative_colour;
}
}

View file

@ -0,0 +1,64 @@
<?php
class hbar_value
{
function hbar_value( $left, $right=null )
{
if( isset( $right ) )
{
$this->left = $left;
$this->right = $right;
}
else
$this->right = $left;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class hbar
{
function hbar( $colour )
{
$this->type = "hbar";
$this->values = array();
$this->set_colour( $colour );
}
function append_value( $v )
{
$this->values[] = $v;
}
function set_values( $v )
{
foreach( $v as $val )
$this->append_value( new hbar_value( $val ) );
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_key( $text, $size )
{
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $size;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}

View file

@ -0,0 +1,157 @@
<?php
class line_on_show
{
/**
*@param $type as string. Can be any one of:
* - 'pop-up'
* - 'explode'
* - 'mid-slide'
* - 'drop'
* - 'fade-in'
* - 'shrink-in'
*
* @param $cascade as float. Cascade in seconds
* @param $delay as float. Delay before animation starts in seconds.
*/
function __construct($type, $cascade, $delay)
{
$this->type = $type;
$this->cascade = (float)$cascade;
$this->delay = (float)$delay;
}
}
class line
{
function line()
{
$this->type = "line";
$this->values = array();
}
/**
* Set the default dot that all the real
* dots inherit their properties from. If you set the
* default dot to be red, all values in your chart that
* do not specify a colour will be red. Same for all the
* other attributes such as tooltip, on-click, size etc...
*
* @param $style as any class that inherits base_dot
*/
function set_default_dot_style( $style )
{
$tmp = 'dot-style';
$this->$tmp = $style;
}
/**
* @param $v as array, can contain any combination of:
* - integer, Y position of the point
* - any class that inherits from dot_base
* - <b>null</b>
*/
function set_values( $v )
{
$this->values = $v;
}
/**
* Append a value to the line.
*
* @param mixed $v
*/
function append_value($v)
{
$this->values[] = $v;
}
function set_width( $width )
{
$this->width = $width;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
/**
* sytnatical sugar for set_colour
*/
function colour( $colour )
{
$this->set_colour( $colour );
return $this;
}
function set_halo_size( $size )
{
$tmp = 'halo-size';
$this->$tmp = $size;
}
function set_key( $text, $font_size )
{
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $font_size;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
/**
* @param $text as string. A javascript function name as a string. The chart will
* try to call this function, it will pass the chart id as the only parameter into
* this function. E.g:
*
*/
function set_on_click( $text )
{
$tmp = 'on-click';
$this->$tmp = $text;
}
function loop()
{
$this->loop = true;
}
function line_style( $s )
{
$tmp = "line-style";
$this->$tmp = $s;
}
/**
* Sets the text for the line.
*
* @param string $text
*/
function set_text($text)
{
$this->text = $text;
}
function attach_to_right_y_axis()
{
$this->axis = 'right';
}
/**
*@param $on_show as line_on_show object
*/
function set_on_show($on_show)
{
$this->{'on-show'} = $on_show;
}
function on_show($on_show)
{
$this->set_on_show($on_show);
return $this;
}
}

View file

@ -0,0 +1,92 @@
<?php
class line_base
{
function line_base()
{
$this->type = "line";
$this->text = "Page views";
$tmp = 'font-size';
$this->$tmp = 10;
$this->values = array();
}
function set_values( $v )
{
$this->values = $v;
}
/**
* Append a value to the line.
*
* @param mixed $v
*/
function append_value($v)
{
$this->values[] = $v;
}
function set_width( $width )
{
$this->width = $width;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_dot_size( $size )
{
$tmp = 'dot-size';
$this->$tmp = $size;
}
function set_halo_size( $size )
{
$tmp = 'halo-size';
$this->$tmp = $size;
}
function set_key( $text, $font_size )
{
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $font_size;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
function set_on_click( $text )
{
$tmp = 'on-click';
$this->$tmp = $text;
}
function loop()
{
$this->loop = true;
}
function line_style( $s )
{
$tmp = "line-style";
$this->$tmp = $s;
}
/**
* Sets the text for the line.
*
* @param string $text
*/
function set_text($text)
{
$this->text = $text;
}
}

View file

@ -0,0 +1,33 @@
<?php
class dot_value
{
function dot_value( $value, $colour )
{
$this->value = $value;
$this->colour = $colour;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_size( $size )
{
$this->size = $size;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
}
class line_dot extends line_base
{
function line_dot()
{
$this->type = "line_dot";
}
}

View file

@ -0,0 +1,9 @@
<?php
class line_hollow extends line_base
{
function line_hollow()
{
$this->type = "line_hollow";
}
}

View file

@ -0,0 +1,11 @@
<?php
class line_style
{
function line_style($on, $off)
{
$this->style = "dash";
$this->on = $on;
$this->off = $off;
}
}

View file

@ -0,0 +1,56 @@
<?php
class ofc_menu_item
{
/**
* @param $text as string. The menu item text.
* @param $javascript_function_name as string. The javascript function name, the
* js function takes one parameter, the chart ID. See ofc_menu_item_camera for
* some example code.
*/
function ofc_menu_item($text, $javascript_function_name)
{
$this->type = "text";
$this->text = $text;
$tmp = 'javascript-function';
$this->$tmp = $javascript_function_name;
}
}
class ofc_menu_item_camera
{
/**
* @param $text as string. The menu item text.
* @param $javascript_function_name as string. The javascript function name, the
* js function takes one parameter, the chart ID. So for example, our js function
* could look like this:
*
* function save_image( chart_id )
* {
* alert( chart_id );
* }
*
* to make a menu item call this: ofc_menu_item_camera('Save chart', 'save_image');
*/
function ofc_menu_item_camera($text, $javascript_function_name)
{
$this->type = "camera-icon";
$this->text = $text;
$tmp = 'javascript-function';
$this->$tmp = $javascript_function_name;
}
}
class ofc_menu
{
function ofc_menu($colour, $outline_colour)
{
$this->colour = $colour;
$this->outline_colour = $outline_colour;
}
function values($values)
{
$this->values = $values;
}
}

View file

@ -0,0 +1,257 @@
<?php
class pie_value
{
function pie_value( $value, $label )
{
$this->value = $value;
$this->label = $label;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_label( $label, $label_colour, $font_size )
{
$this->label = $label;
$tmp = 'label-colour';
$this->$tmp = $label_colour;
$tmp = 'font-size';
$this->$tmp = $font_size;
}
function set_tooltip( $tip )
{
$this->tip = $tip;
}
function on_click( $event )
{
$tmp = 'on-click';
$this->$tmp = $event;
}
/**
* An object that inherits from base_pie_animation
*/
function add_animation( $animation )
{
if( !isset( $this->animate ) )
$this->animate = array();
$this->animate[] = $animation;
return $this;
}
}
class base_pie_animation{}
/**
* fade the pie slice from $alpha (pie set_alpha) to 100% opaque.
*/
class pie_fade extends base_pie_animation
{
function pie_fade()
{
$this->type="fade";
}
}
/**
* Bounce the pie slice out a little
*/
class pie_bounce extends base_pie_animation
{
/**
* @param $distance as integer, distance to bounce in pixels
*/
function pie_bounce( $distance )
{
$this->type="bounce";
$this->distance = $distance;
}
}
/**
* Make a pie chart and fill it with pie slices
*/
class pie
{
function pie()
{
$this->type = 'pie';
}
function set_colours( $colours )
{
$this->colours = $colours;
}
/**
* Sugar wrapped around set_colours
*/
function colours( $colours )
{
$this->set_colours( $colours );
return $this;
}
/**
* @param $alpha as float (0-1) 0.75 = 3/4 visible
*/
function set_alpha( $alpha )
{
$this->alpha = $alpha;
}
/**
*sugar wrapped set_alpha
**/
function alpha( $alpha )
{
$this->set_alpha( $alpha );
return $this;
}
/**
* @param $v as array containing one of
* - null
* - real or integer number
* - a pie_value object
*/
function set_values( $v )
{
$this->values = $v;
}
/**
* sugar for set_values
*/
function values( $v )
{
$this->set_values( $v );
return $this;
}
/**
* HACK to keep old code working.
*/
function set_animate( $bool )
{
if( $bool )
$this->add_animation( new pie_fade() );
}
/**
* An object that inherits from base_pie_animation
*/
function add_animation( $animation )
{
if( !isset( $this->animate ) )
$this->animate = array();
$this->animate[] = $animation;
return $this;
}
/**
* @param $angle as real number
*/
function set_start_angle( $angle )
{
$tmp = 'start-angle';
$this->$tmp = $angle;
}
/**
* sugar for set_start_angle
*/
function start_angle($angle)
{
$this->set_start_angle( $angle );
return $this;
}
/**
* @param $tip as string. The tooltip text. May contain magic varibles
*/
function set_tooltip( $tip )
{
$this->tip = $tip;
}
/**
* sugar for set_tooltip
*/
function tooltip( $tip )
{
$this->set_tooltip( $tip );
return $this;
}
function set_gradient_fill()
{
$tmp = 'gradient-fill';
$this->$tmp = true;
}
function gradient_fill()
{
$this->set_gradient_fill();
return $this;
}
/**
* By default each label is the same colour as the slice,
* but you can ovveride that behaviour using this method.
*
* @param $label_colour as string HEX colour;
*/
function set_label_colour( $label_colour )
{
$tmp = 'label-colour';
$this->$tmp = $label_colour;
}
function label_colour( $label_colour )
{
$this->set_label_colour( $label_colour );
return $this;
}
/**
* Turn off the labels
*/
function set_no_labels()
{
$tmp = 'no-labels';
$this->$tmp = true;
}
function on_click( $event )
{
$tmp = 'on-click';
$this->$tmp = $event;
}
/**
* Fix the radius of the pie chart. Take a look at the magic variable #radius#
* for helping figure out what radius to set it to.
*
* @param $radius as number
*/
function radius( $radius )
{
$this->radius = $radius;
return $this;
}
}

View file

@ -0,0 +1,47 @@
<?php
class radar_axis
{
function radar_axis( $max )
{
$this->set_max( $max );
}
function set_max( $max )
{
$this->max = $max;
}
function set_steps( $steps )
{
$this->steps = $steps;
}
function set_stroke( $s )
{
$this->stroke = $s;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_grid_colour( $colour )
{
$tmp = 'grid-colour';
$this->$tmp = $colour;
}
function set_labels( $labels )
{
$this->labels = $labels;
}
function set_spoke_labels( $labels )
{
$tmp = 'spoke-labels';
$this->$tmp = $labels;
}
}

View file

@ -0,0 +1,15 @@
<?php
class radar_axis_labels
{
// $labels : array
function radar_axis_labels( $labels )
{
$this->labels = $labels;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
}

View file

@ -0,0 +1,15 @@
<?php
class radar_spoke_labels
{
// $labels : array
function radar_spoke_labels( $labels )
{
$this->labels = $labels;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
}

View file

@ -0,0 +1,47 @@
<?php
class scatter_value
{
function scatter_value( $x, $y, $dot_size=-1 )
{
$this->x = $x;
$this->y = $y;
if( $dot_size > 0 )
{
$tmp = 'dot-size';
$this->$tmp = $dot_size;
}
}
}
class scatter
{
function scatter( $colour )
{
$this->type = "scatter";
$this->set_colour( $colour );
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_default_dot_style( $style )
{
$tmp = 'dot-style';
$this->$tmp = $style;
}
/**
* @param $v as array, can contain any combination of:
* - integer, Y position of the point
* - any class that inherits from scatter_value
* - <b>null</b>
*/
function set_values( $values )
{
$this->values = $values;
}
}

View file

@ -0,0 +1,49 @@
<?php
class scatter_line
{
function scatter_line( $colour, $width )
{
$this->type = "scatter_line";
$this->set_colour( $colour );
$this->set_width( $width );
}
function set_default_dot_style( $style )
{
$tmp = 'dot-style';
$this->$tmp = $style;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_width( $width )
{
$this->width = $width;
}
function set_values( $values )
{
$this->values = $values;
}
function set_step_horizontal()
{
$this->stepgraph = 'horizontal';
}
function set_step_vertical()
{
$this->stepgraph = 'vertical';
}
function set_key( $text, $font_size )
{
$this->text = $text;
$tmp = 'font-size';
$this->$tmp = $font_size;
}
}

View file

@ -0,0 +1,25 @@
<?php
class shape_point
{
function shape_point( $x, $y )
{
$this->x = $x;
$this->y = $y;
}
}
class shape
{
function shape( $colour )
{
$this->type = "shape";
$this->colour = $colour;
$this->values = array();
}
function append_value( $p )
{
$this->values[] = $p;
}
}

View file

@ -0,0 +1,43 @@
<?php
/**
* Sugar: to make stars easier sometimes
*/
class s_star extends star
{
/**
* I use this wrapper for default dot types,
* it just makes the code easier to read.
*/
function s_star($colour, $size)
{
parent::star();
$this->colour($colour)->size($size);
}
}
class s_box extends anchor
{
/**
* I use this wrapper for default dot types,
* it just makes the code easier to read.
*/
function s_box($colour, $size)
{
parent::anchor();
$this->colour($colour)->size($size)->rotation(45)->sides(4);
}
}
class s_hollow_dot extends hollow_dot
{
/**
* I use this wrapper for default dot types,
* it just makes the code easier to read.
*/
function s_hollow_dot($colour, $size)
{
parent::hollow_dot();
$this->colour($colour)->size($size);
}
}

View file

@ -0,0 +1,133 @@
<?php
class ofc_tags
{
function ofc_tags()
{
$this->type = "tags";
$this->values = array();
}
function colour( $colour )
{
$this->colour = $colour;
return $this;
}
/**
*@param $font as string. e.g. "Verdana"
*@param $size as integer. Size in px
*/
function font($font, $size)
{
$this->font = $font;
$this->{'font-size'} = $size;
return $this;
}
/**
*@param $x as integer. Size of x padding in px
*@param $y as integer. Size of y padding in px
*/
function padding($x, $y)
{
$this->{"pad-x"} = $x;
$this->{"pad-y"} = $y;
return $this;
}
function rotate($angle)
{
$this->rotate($angle);
return $this;
}
function align_x_center()
{
$this->{"align-x"} = "center";
return $this;
}
function align_x_left()
{
$this->{"align-x"} = "left";
return $this;
}
function align_x_right()
{
$this->{"align-x"} = "right";
return $this;
}
function align_y_above()
{
$this->{"align-y"} = "above";
return $this;
}
function align_y_below()
{
$this->{"align-y"} = "below";
return $this;
}
function align_y_center()
{
$this->{"align-y"} = "center";
return $this;
}
/**
* This can contain some HTML, e.g:
* - "More <a href="javascript:alert(12);">info</a>"
* - "<a href="http://teethgrinder.co.uk">ofc</a>"
*/
function text($text)
{
$this->text = $text;
return $this;
}
/**
* This works, but to get the mouse pointer to change
* to a little hand you need to use "<a href="">stuff</a>"-- see text()
*/
function on_click($on_click)
{
$this->{'on-click'} = $on_click;
return $this;
}
/**
*@param $bold boolean.
*@param $underline boolean.
*@param $border boolean.
*@prarm $alpha real (0 to 1.0)
*/
function style($bold, $underline, $border, $alpha )
{
$this->bold = $bold;
$this->border = $underline;
$this->underline = $border;
$this->alpha = $alpha;
return $this;
}
/**
*@param $tag as ofc_tag
*/
function append_tag($tag)
{
$this->values[] = $tag;
}
}
class ofc_tag extends ofc_tags
{
function ofc_tag($x, $y)
{
$this->x = $x;
$this->y = $y;
}
}

View file

@ -0,0 +1,39 @@
<?php
/**
* Set the title of a chart, make one of these and pass it into
* open_flash_chart set_title
*/
class title
{
function title( $text='' )
{
$this->text = $text;
}
/**
* A css string. Can optionally contain:
* - font-size
* - font-family
* - font-weight
* - color
* - background-color
* - text-align
* - margin
* - margin-left
* - margin-right
* - margin-top
* - margin-bottom
* - padding
* - padding-left
* - padding-right
* - padding-top
* - padding-bottom
* just like the css we use all the time :-)
*/
function set_style( $css )
{
$this->style = $css;
//"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
}
}

View file

@ -0,0 +1,67 @@
<?php
include_once 'ofc_bar_base.php';
class tooltip
{
function tooltip(){}
/**
* @param $shadow as boolean. Enable drop shadow.
*/
function set_shadow( $shadow )
{
$this->shadow = $shadow;
}
/**
* @param $stroke as integer, border width in pixels (e.g. 5 )
*/
function set_stroke( $stroke )
{
$this->stroke = $stroke;
}
/**
* @param $colour as string, HEX colour e.g. '#0000ff'
*/
function set_colour( $colour )
{
$this->colour = $colour;
}
/**
* @param $bg as string, HEX colour e.g. '#0000ff'
*/
function set_background_colour( $bg )
{
$this->background = $bg;
}
/**
* @param $style as string. A css style.
*/
function set_title_style( $style )
{
$this->title = $style;
}
/**
* @param $style as string. A css style.
*/
function set_body_style( $style )
{
$this->body = $style;
}
function set_proximity()
{
$this->mouse = 1;
}
function set_hover()
{
$this->mouse = 2;
}
}

View file

@ -0,0 +1,140 @@
<?php
class x_axis
{
function x_axis(){}
/**
* @param $stroke as integer, with of the line and ticks
*/
function set_stroke( $stroke )
{
$this->stroke = $stroke;
}
function stroke( $stroke )
{
$this->set_stroke( $stroke );
return $this;
}
/**
*@param $colour as string HEX colour
*@param $grid_colour as string HEX colour
*/
function set_colours( $colour, $grid_colour )
{
$this->set_colour( $colour );
$this->set_grid_colour( $grid_colour );
}
/**
*@param $colour as string HEX colour
*/
function set_colour( $colour )
{
$this->colour = $colour;
}
function colour( $colour )
{
$this->set_colour($colour);
return $this;
}
function set_tick_height( $height )
{
$tmp = 'tick-height';
$this->$tmp = $height;
}
function tick_height( $height )
{
$this->set_tick_height($height);
return $this;
}
function set_grid_colour( $colour )
{
$tmp = 'grid-colour';
$this->$tmp = $colour;
}
function grid_colour( $colour )
{
$this->set_grid_colour($colour);
return $this;
}
/**
* @param $o is a boolean. If true, the X axis start half a step in
* This defaults to True
*/
function set_offset( $o )
{
$this->offset = $o?true:false;
}
function offset( $o )
{
$this->set_offset($o);
return $this;
}
/**
* @param $steps as integer. Which grid lines and ticks are visible.
*/
function set_steps( $steps )
{
$this->steps = $steps;
}
function steps( $steps )
{
$this->set_steps($steps);
return $this;
}
/**
* @param $val as an integer, the height in pixels of the 3D bar. Mostly
* used for the 3D bar chart.
*/
function set_3d( $val )
{
$tmp = '3d';
$this->$tmp = $val;
}
/**
* @param $x_axis_labels as an x_axis_labels object
* Use this to customize the labels (colour, font, etc...)
*/
function set_labels( $x_axis_labels )
{
//$this->labels = $v;
$this->labels = $x_axis_labels;
}
/**
* Sugar syntax: helper function to make the examples simpler.
* @param $a is an array of labels
*/
function set_labels_from_array( $a )
{
$x_axis_labels = new x_axis_labels();
$x_axis_labels->set_labels( $a );
$this->labels = $x_axis_labels;
if( isset( $this->steps ) )
$x_axis_labels->set_steps( $this->steps );
}
/**
* min and max.
*/
function set_range( $min, $max )
{
$this->min = $min;
$this->max = $max;
}
}

View file

@ -0,0 +1,45 @@
<?php
/**
* x_axis_label see x_axis_labels
*/
class x_axis_label
{
function x_axis_label( $text, $colour, $size, $rotate )
{
$this->set_text( $text );
$this->set_colour( $colour );
$this->set_size( $size );
$this->set_rotate( $rotate );
}
function set_text( $text )
{
$this->text = $text;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_size( $size )
{
$this->size = $size;
}
function set_rotate( $rotate )
{
$this->rotate = $rotate;
}
function set_vertical()
{
$this->rotate = "vertical";
}
function set_visible()
{
$this->visible = true;
}
}

View file

@ -0,0 +1,69 @@
<?php
class x_axis_labels
{
function x_axis_labels(){}
/**
* @param $steps which labels are generated
*/
function set_steps( $steps )
{
$this->steps = $steps;
}
/**
* @param $steps as integer which labels are visible
*/
function visible_steps( $steps )
{
$this->{"visible-steps"} = $steps;
return $this;
}
/**
*
* @param $labels as an array of [x_axis_label or string]
*/
function set_labels( $labels )
{
$this->labels = $labels;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
/**
* font size in pixels
*/
function set_size( $size )
{
$this->size = $size;
}
/**
* rotate labels
*/
function set_vertical()
{
$this->rotate = 270;
}
/**
* @param @angle as real. The angle of the text.
*/
function rotate( $angle )
{
$this->rotate = $angle;
}
/**
* @param $text as string. Replace and magic variables with actual x axis position.
*/
function text( $text )
{
$this->text = $text;
}
}

View file

@ -0,0 +1,15 @@
<?php
class x_legend
{
function x_legend( $text='' )
{
$this->text = $text;
}
function set_style( $css )
{
$this->style = $css;
//"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
}
}

View file

@ -0,0 +1,17 @@
<?php
class y_axis extends y_axis_base
{
function y_axis(){}
/**
* @param $colour as string. The grid are the lines inside the chart.
* HEX colour, e.g. '#ff0000'
*/
function set_grid_colour( $colour )
{
$tmp = 'grid-colour';
$this->$tmp = $colour;
}
}

View file

@ -0,0 +1,116 @@
<?php
class y_axis_base
{
function y_axis_base(){}
/**
* @param $s as integer, thickness of the Y axis line
*/
function set_stroke( $s )
{
$this->stroke = $s;
}
/**
* @param $val as integer. The length of the ticks in pixels
*/
function set_tick_length( $val )
{
$tmp = 'tick-length';
$this->$tmp = $val;
}
function set_colours( $colour, $grid_colour )
{
$this->set_colour( $colour );
$this->set_grid_colour( $grid_colour );
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_grid_colour( $colour )
{
$tmp = 'grid-colour';
$this->$tmp = $colour;
}
/**
* Set min and max values, also (optionally) set the steps value.
* You can reverse the chart by setting min larger than max, e.g. min = 10
* and max = 0.
*
* @param $min as integer
* @param $max as integer
* @param $steps as integer.
*/
function set_range( $min, $max, $steps=1 )
{
$this->min = $min;
$this->max = $max;
$this->set_steps( $steps );
}
/**
* Sugar for set_range
*/
function range( $min, $max, $steps=1 )
{
$this->set_range( $min, $max, $steps );
return $this;
}
/**
* @param $off as Boolean. If true the Y axis is nudged up half a step.
*/
function set_offset( $off )
{
$this->offset = $off?1:0;
}
/**
* @param $y_axis_labels as an y_axis_labels object
* Use this to customize the labels (colour, font, etc...)
*/
function set_labels( $y_axis_labels )
{
$this->labels = $y_axis_labels;
}
/**
* Pass in some text for each label. This can contain magic variables "#val#" which
* will get replaced with the value for that Y axis label. Useful for:
* - "£#val#"
* - "#val#%"
* - "#val# million"
*
* @param $text as string.
*/
function set_label_text( $text )
{
$tmp = new y_axis_labels();
$tmp->set_text( $text );
$this->labels = $tmp;
}
/**
* @param $steps as integer.
*
* Only show every $steps label, e.g. every 10th
*/
function set_steps( $steps )
{
$this->steps = $steps;
}
/**
* Make the labels show vertical
*/
function set_vertical()
{
$this->rotate = "vertical";
}
}

View file

@ -0,0 +1,38 @@
<?php
/**
* y_axis_label see y_axis_labels
*/
class y_axis_label
{
function y_axis_label( $y, $text)
{
$this->y = $y;
$this->set_text( $text );
}
function set_text( $text )
{
$this->text = $text;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
function set_size( $size )
{
$this->size = $size;
}
function set_rotate( $rotate )
{
$this->rotate = $rotate;
}
function set_vertical()
{
$this->rotate = "vertical";
}
}

View file

@ -0,0 +1,57 @@
<?php
class y_axis_labels
{
function y_axis_labels(){}
/**
* @param $steps which labels are generated
*/
function set_steps( $steps )
{
$this->steps = $steps;
}
/**
*
* @param $labels as an array of [y_axis_label or string]
*/
function set_labels( $labels )
{
$this->labels = $labels;
}
function set_colour( $colour )
{
$this->colour = $colour;
}
/**
* font size in pixels
*/
function set_size( $size )
{
$this->size = $size;
}
/**
* rotate labels
*/
function set_vertical()
{
$this->rotate = 270;
}
function rotate( $angle )
{
$this->rotate = $angle;
}
/**
* @param $text default text that all labels inherit
*/
function set_text( $text )
{
$this->text = $text;
}
}

View file

@ -0,0 +1,6 @@
<?php
class y_axis_right extends y_axis_base
{
function y_axis_right(){}
}

View file

@ -0,0 +1,15 @@
<?php
class y_legend
{
function y_legend( $text='' )
{
$this->text = $text;
}
function set_style( $css )
{
$this->style = $css;
//"{font-size: 20px; color:#0000ff; font-family: Verdana; text-align: center;}";
}
}

View file

@ -0,0 +1,109 @@
<?php
function open_flash_chart_object_str( $width, $height, $url, $use_swfobject=true, $base='' )
{
//
// return the HTML as a string
//
return _ofc( $width, $height, $url, $use_swfobject, $base );
}
function open_flash_chart_object( $width, $height, $url, $use_swfobject=true, $base='' )
{
//
// stream the HTML into the page
//
echo _ofc( $width, $height, $url, $use_swfobject, $base );
}
function _ofc( $width, $height, $url, $use_swfobject, $base )
{
//
// I think we may use swfobject for all browsers,
// not JUST for IE...
//
//$ie = strstr(getenv('HTTP_USER_AGENT'), 'MSIE');
//
// escape the & and stuff:
//
$url = urlencode($url);
//
// output buffer
//
$out = array();
//
// check for http or https:
//
if (isset ($_SERVER['HTTPS']))
{
if (strtoupper ($_SERVER['HTTPS']) == 'ON')
{
$protocol = 'https';
}
else
{
$protocol = 'http';
}
}
else
{
$protocol = 'http';
}
//
// if there are more than one charts on the
// page, give each a different ID
//
global $open_flash_chart_seqno;
$obj_id = 'chart';
$div_name = 'flashcontent';
//$out[] = '<script type="text/javascript" src="'. $base .'js/ofc.js"></script>';
if( !isset( $open_flash_chart_seqno ) )
{
$open_flash_chart_seqno = 1;
$out[] = '<script type="text/javascript" src="'. $base .'js/swfobject.js"></script>';
}
else
{
$open_flash_chart_seqno++;
$obj_id .= '_'. $open_flash_chart_seqno;
$div_name .= '_'. $open_flash_chart_seqno;
}
if( $use_swfobject )
{
// Using library for auto-enabling Flash object on IE, disabled-Javascript proof
$out[] = '<div id="'. $div_name .'"></div>';
$out[] = '<script type="text/javascript">';
$out[] = 'var so = new SWFObject("'. $base .'open-flash-chart.swf", "'. $obj_id .'", "'. $width . '", "' . $height . '", "9", "#FFFFFF");';
$out[] = 'so.addVariable("data-file", "'. $url . '");';
$out[] = 'so.addParam("allowScriptAccess", "always" );//"sameDomain");';
$out[] = 'so.write("'. $div_name .'");';
$out[] = '</script>';
$out[] = '<noscript>';
}
$out[] = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="' . $protocol . '://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" ';
$out[] = 'width="' . $width . '" height="' . $height . '" id="ie_'. $obj_id .'" align="middle">';
$out[] = '<param name="allowScriptAccess" value="sameDomain" />';
$out[] = '<param name="movie" value="'. $base .'open-flash-chart.swf?data='. $url .'" />';
$out[] = '<param name="quality" value="high" />';
$out[] = '<param name="bgcolor" value="#FFFFFF" />';
$out[] = '<embed src="'. $base .'open-flash-chart.swf?data=' . $url .'" quality="high" bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'" name="'. $obj_id .'" align="middle" allowScriptAccess="sameDomain" ';
$out[] = 'type="application/x-shockwave-flash" pluginspage="' . $protocol . '://www.macromedia.com/go/getflashplayer" id="'. $obj_id .'"/>';
$out[] = '</object>';
if ( $use_swfobject ) {
$out[] = '</noscript>';
}
return implode("\n",$out);
}
?>

View file

@ -0,0 +1,178 @@
<?php
// var_dump(debug_backtrace());
//
// Omar Kilani's php C extension for encoding JSON has been incorporated in stock PHP since 5.2.0
// http://www.aurore.net/projects/php-json/
//
// -- Marcus Engene
//
if (! function_exists('json_encode'))
{
include_once 'JSON.php';
}
include_once 'json_format.php';
// ofc classes
include_once 'ofc_title.php';
include_once 'ofc_y_axis_base.php';
include_once 'ofc_y_axis.php';
include_once 'ofc_y_axis_right.php';
include_once 'ofc_y_axis_labels.php';
include_once 'ofc_y_axis_label.php';
include_once 'ofc_x_axis.php';
include_once 'ofc_pie.php';
//include_once 'ofc_bar.php';
include_once 'ofc_bar_glass.php';
include_once 'ofc_bar_filled.php';
include_once 'ofc_bar_stack.php';
//include_once 'ofc_bar_3d.php';
include_once 'ofc_hbar.php';
include_once 'ofc_line_base.php';
include_once 'ofc_line.php';
//include_once 'ofc_line_dot.php';
//include_once 'ofc_line_hollow.php';
include_once 'ofc_candle.php';
include_once 'ofc_area_base.php';
include_once 'ofc_tags.php';
include_once 'ofc_arrow.php';
//include_once 'ofc_area_hollow.php';
//include_once 'ofc_area_line.php';
include_once 'ofc_x_legend.php';
include_once 'ofc_y_legend.php';
include_once 'ofc_bar_sketch.php';
include_once 'ofc_scatter.php';
include_once 'ofc_scatter_line.php';
include_once 'ofc_x_axis_labels.php';
include_once 'ofc_x_axis_label.php';
include_once 'ofc_tooltip.php';
include_once 'ofc_shape.php';
include_once 'ofc_radar_axis.php';
include_once 'ofc_radar_axis_labels.php';
include_once 'ofc_radar_spoke_labels.php';
include_once 'ofc_line_style.php';
include_once 'dot_base.php';
include_once 'ofc_menu.php';
class open_flash_chart
{
function open_flash_chart()
{
//$this->title = new title( "Many data lines" );
$this->elements = array();
}
function set_title( $t )
{
$this->title = $t;
}
function set_x_axis( $x )
{
$this->x_axis = $x;
}
function set_y_axis( $y )
{
$this->y_axis = $y;
}
function add_y_axis( $y )
{
$this->y_axis = $y;
}
function set_y_axis_right( $y )
{
$this->y_axis_right = $y;
}
function add_element( $e )
{
$this->elements[] = $e;
}
function set_x_legend( $x )
{
$this->x_legend = $x;
}
function set_y_legend( $y )
{
$this->y_legend = $y;
}
function set_bg_colour( $colour )
{
$this->bg_colour = $colour;
}
function set_radar_axis( $radar )
{
$this->radar_axis = $radar;
}
function set_tooltip( $tooltip )
{
$this->tooltip = $tooltip;
}
/**
* This is a bit funky :(
*
* @param $num_decimals as integer. Truncate the decimals to $num_decimals, e.g. set it
* to 5 and 3.333333333 will display as 3.33333. 2.0 will display as 2 (or 2.00000 - see below)
* @param $is_fixed_num_decimals_forced as boolean. If true it will pad the decimals.
* @param $is_decimal_separator_comma as boolean
* @param $is_thousand_separator_disabled as boolean
*
* This needs a bit of love and attention
*/
function set_number_format($num_decimals, $is_fixed_num_decimals_forced, $is_decimal_separator_comma, $is_thousand_separator_disabled )
{
$this->num_decimals = $num_decimals;
$this->is_fixed_num_decimals_forced = $is_fixed_num_decimals_forced;
$this->is_decimal_separator_comma = $is_decimal_separator_comma;
$this->is_thousand_separator_disabled = $is_thousand_separator_disabled;
}
/**
* This is experimental and will change as we make it work
*
* @param $m as ofc_menu
*/
function set_menu($m)
{
$this->menu = $m;
}
function toString()
{
if (function_exists('json_encode'))
{
return json_encode($this);
}
else
{
$json = new Services_JSON();
return $json->encode( $this );
}
}
function toPrettyString()
{
return json_format( $this->toString() );
}
}
//
// there is no PHP end tag so we don't mess the headers up!
//

View file

@ -0,0 +1,108 @@
<?php
include '../../includes/admin_config.php';
include 'ofc-library/open-flash-chart.php';
$days = 7;
$last_week = time()-86400*$days + 86400;
$the_last_week = date('M d', $last_week);
$title = new title("User Stats ".$the_last_week." - ".date("M d"));
$title->set_style("{font-size:14px;font-family:Century Gothic;font-weight:bold}");
$vid_stats = $data['video_stats'];
$vid_stats = json_decode($vid_stats);
$year = array();
//Getting This Weeks Data
for($i=0;$i<$days;$i++)
{
if($i<$days-1)
{
$date_pattern = date("Y-m-d",$last_week+($i*86400));
$data = $db->select(tbl("stats"),"*"," date_added LIKE '%$date_pattern%' ",1);
$data = $data[0];
$datas[] = $data;
}
$year[] = date("M d",$last_week+($i*86400));
}
for($i=0;$i<$days;$i++)
{
$day[$i]['video'] = json_decode($datas[$i]['video_stats'],true);
$day[$i]['users'] = json_decode($datas[$i]['user_stats'],true);
$day[$i]['groups'] = json_decode($datas[$i]['group_stats'],true);
}
$max = 1;
for($i=0;$i<$days;$i++)
{
if($i==$days-1)
{
$signups[] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today"))+0;
$active[] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today","status"=>'Ok'))+0;
$inactive[] = $userquery->get_users(array("count_only"=>true,"date_span"=>"today","status"=>'ToActivate'))+0;
}else{
$signups[] =$day[$i]['users']->signups+0;
$active[] =$day[$i]['users']->active+0;
$inactive[] =$day[$i]['users']->inactive+0;
}
$max = max($max,$uploads[$i],$inactive[$i],$active[$i]);
}
$signups_bars = new bar_cylinder();
$signups_bars->set_values($signups);
$signups_bars->colour( '#0066ff');
$signups_bars->key('Signups', 14);
$active_bars = new bar_cylinder();
$active_bars->set_values($active);
$active_bars->colour( '#99cc00');
$active_bars->key('Active', 14);
$inactivebar = new bar_cylinder();
$inactivebar->set_values($inactive);
$inactivebar->colour( '#BF3B69');
$inactivebar->key('Inactive', 14);
$max = $max+(round($max/2,0.49));
$steps = round($max/5,0.49);
$y = new y_axis();
$y->set_range( 0, $max, $steps);
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $signups_bars );
$chart->add_element( $active_bars );
$chart->add_element( $inactivebar );
$x_labels = new x_axis_labels();
$x_labels->set_steps( 1 );
$x_labels->set_colour( '#A2ACBA' );
$x_labels->set_labels( $year );
$x = new x_axis();
$x->set_colour( '#A2ACBA' );
$x->set_grid_colour( '#D7E4A3' );
$x->set_offset( true );
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels( $x_labels );
$chart->set_x_axis( $x );
$chart->set_bg_colour('#ffffff');
$chart->set_y_axis( $y );
echo $chart->toString();
?>

View file

@ -0,0 +1,108 @@
<?php
include '../../includes/admin_config.php';
include 'ofc-library/open-flash-chart.php';
$days = 7;
$last_week = time()-86400*$days + 86400;
$the_last_week = date('M d', $last_week);
$title = new title("Video Stats ".$the_last_week." - ".date("M d"));
$title->set_style("{font-size:14px;font-family:Century Gothic;font-weight:bold}");
$vid_stats = $data['video_stats'];
$vid_stats = json_decode($vid_stats);
$year = array();
//Getting This Weeks Data
for($i=0;$i<$days;$i++)
{
if($i<$days-1)
{
$date_pattern = date("Y-m-d",$last_week+($i*86400));
$data = $db->select(tbl("stats"),"*"," date_added LIKE '%$date_pattern%' ",1);
$data = $data[0];
$datas[] = $data;
}
$year[] = date("M d",$last_week+($i*86400));
}
for($i=0;$i<$days;$i++)
{
$day[$i]['video'] = json_decode($datas[$i]['video_stats'],true);
$day[$i]['users'] = json_decode($datas[$i]['user_stats'],true);
$day[$i]['groups'] = json_decode($datas[$i]['group_stats'],true);
}
$max = 1;
for($i=0;$i<$days;$i++)
{
if($i==$days-1)
{
$uploads[] = $cbvid->get_videos(array("count_only"=>true,"date_span"=>"today"))+0;
$active[] = $cbvid->get_videos(array("count_only"=>true,"date_span"=>"today","active"=>'yes',"status"=>'Successful'))+0;
$processing[] = $cbvid->get_videos(array("count_only"=>true,"date_span"=>"today","status"=>'Processing'))+0;
}else{
$uploads[] =$day[$i]['video']->uploads+0;
$active[] =$day[$i]['video']->active+0;
$processing[] =$day[$i]['video']->processing+0;
}
$max = max($max,$uploads[$i],$active[$i],$processing[$i]);
}
$total_bars = new bar_cylinder();
$total_bars->set_values($uploads);
$total_bars->colour( '#0066ff');
$total_bars->key('Total', 14);
$active_bars = new bar_cylinder();
$active_bars->set_values($active);
$active_bars->colour( '#99cc00');
$active_bars->key('Active', 14);
$processing_bar = new bar_cylinder();
$processing_bar->set_values($processing);
$processing_bar->colour( '#BF3B69');
$processing_bar->key('Processing', 14);
//$max = $max+(round($max/2,0.49));
$steps = round($max/5,0.49);
$y = new y_axis();
$y->set_range( 0, $max, $steps);
$chart = new open_flash_chart();
$chart->set_title( $title );
$chart->add_element( $total_bars );
$chart->add_element( $active_bars );
$chart->add_element( $processing_bar );
$x_labels = new x_axis_labels();
$x_labels->set_steps( 1 );
$x_labels->set_colour( '#A2ACBA' );
$x_labels->set_labels( $year );
$x = new x_axis();
$x->set_colour( '#A2ACBA' );
$x->set_grid_colour( '#D7E4A3' );
$x->set_offset( true );
$x->set_steps(4);
// Add the X Axis Labels to the X Axis
$x->set_labels( $x_labels );
$chart->set_x_axis( $x );
$chart->set_bg_colour('#ffffff');
$chart->set_y_axis( $y );
echo $chart->toString();
?>

View file

@ -0,0 +1,79 @@
<?php
/*
*******************************************
| Copyright (c) 2007-2010 Clip-Bucket.com & (Arslan Hassan). All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
*******************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
//Form Processing
if(isset($_POST['add_cateogry'])){
$cbcollection->add_category($_POST);
}
//Making Categoyr as Default
if(isset($_GET['make_default']))
{
$cid = mysql_clean($_GET['make_default']);
$cbcollection->make_default_category($cid);
}
//Edit Categoty
if(isset($_GET['category'])){
assign("edit_category","show");
if(isset($_POST['update_category']))
{
$cbcollection->update_category($_POST);
}
assign('cat_details',$cbcollection->get_category($_GET['category']));
}
//Delete Category
if(isset($_GET['delete_category'])){
$cbcollection->delete_category($_GET['delete_category']);
}
$cats = $cbcollection->get_categories();
$pid = $cbcollection->get_category_field($_GET['category'],'parent_id');
if($pid)
$selected = $pid;
$parent_cats = $cbcollection->admin_area_cats($selected);
//Updating Category Order
if(isset($_POST['update_order']))
{
foreach($cats as $cat)
{
if(!empty($cat['category_id']))
{
$order = $_POST['category_order_'.$cat['category_id']];
$cbcollection->update_cat_order($cat['category_id'],$order);
}
}
$cats = $cbcollection->get_categories();
}
//Assing Category Values
assign('category',$cats);
assign('parent_cats',$parent_cats);
assign('total',$cbcollection->total_categories());
subtitle("Collection Category Manager");
Assign('msg',@$msg);
template_files('collection_category.html');
display_it();
?>

View file

@ -0,0 +1,154 @@
<?php
/*
**************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
***************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
if(isset($_GET['make_feature']))
{
$id = mysql_clean($_GET['make_feature']);
$cbcollection->collection_actions('mcf',$id);
}
if(isset($_GET['make_unfeature']))
{
$id = mysql_clean($_GET['make_unfeature']);
$cbcollection->collection_actions('mcuf',$id);
}
if(isset($_GET['activate']))
{
$id = mysql_clean($_GET['activate']);
$cbcollection->collection_actions('ac',$id);
}
if(isset($_GET['deactivate']))
{
$id = mysql_clean($_GET['deactivate']);
$cbcollection->collection_actions('dac',$id);
}
if(isset($_GET['delete_collection']))
{
$id = mysql_clean($_GET['delete_collection']);
$cbcollection->delete_collection($id);
}
//pr($cbcollection->collection_delete_functions,TRUE);
/* ACTIONS ON MULTI ITEMS */
if(isset($_POST['activate_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->collection_actions('ac',$_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collections has been activated","m");
}
if(isset($_POST['deactivate_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->collection_actions('dac',$_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collections has been deactivated","m");
}
if(isset($_POST['make_featured_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->collection_actions('mcf',$_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collections has been marked as <strong>Featured</strong>","m");
}
if(isset($_POST['make_unfeatured_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->collection_actions('mcuf',$_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collections has been marked as <strong>Unfeatured</strong>","m");
}
if(isset($_POST['make_unfeatured_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->collection_actions('mcuf',$_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collections has been marked as <strong>Unfeatured</strong>","m");
}
if(isset($_POST['delete_selected']))
{
$total = count($_POST['check_collection']);
for($i=0;$i<$total;$i++)
{
$cbcollection->delete_collection($_POST['check_collection'][$i]);
}
$eh->flush();
e($total." collection(s) has been deleted successfully","m");
}
/* IF SEARCH EXISTS */
if($_GET['search'])
{
$array = array(
'name' => $_GET['title'],
'tags' => $_GET['tags'],
'cid' => $_GET['collectionid'],
'type' => $_GET['collection_type'],
'user' => $_GET['userid'],
'order' => $_GET['order'],
'broadcast' => $_GET['broadcast'],
'featured' => $_GET['featured'],
'active' => $_GET['active']
);
}
$carray = $array;
/* CREATING LIMIT */
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,RESULTS);
$carray['limit'] = $get_limit;
if(!empty($carray['order']))
$carray['order'] = $carray['order']." DESC";
else
$carray['order'] = " collection_id DESC";
$collections = $cbcollection->get_collections($carray);
assign('c',$collections);
/* COUNTING ALL COLLECTIONS */
$ccount = $carray;
$ccount['count_only'] = TRUE;
$total_rows = $cbcollection->get_collections($ccount);
$total_pages = count_pages($total_rows,RESULTS);
$pages->paginate($total_pages,$page);
subtitle("Collection Manager");
template_files('collection_manager.html');
display_it();
?>

View file

@ -0,0 +1,71 @@
<?php
require'../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
if(empty($_GET['type']))
$type = "v";
else
$type = $_GET['type'];
$comment_cond = array();
$comment_cond['order'] = " comment_id DESC";
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,RESULTS);
$comment_cond['limit'] = $get_limit;
assign('type',$type);
switch($type)
{
case "v":
default:
{
$comment_cond['type'] = "v";
$comment_cond['type_id'] = "videoid";
$comment_cond['sectionTable'] = "video";
}
break;
case "c":
{
$comment_cond['type'] = "c";
$comment_cond['type_id'] = "userid";
$comment_cond['sectionTable'] = "users";
}
break;
case "t":
{
$comment_cond['type'] = "t";
$comment_cond['type_id'] = "topic_id";
$comment_cond['sectionTable'] = "group_topics";
}
break;
case "cl":
{
$comment_cond['type'] = "cl";
$comment_cond['type_id'] = "collection_id";
$comment_cond['sectionTable'] = "collections";
}
break;
case "p":
{
$comment_cond['type'] = "p";
$comment_cond['type_id'] = "photo_id";
$comment_cond['sectionTable'] = "photos";
}
break;
}
$comments = getComments($comment_cond);
assign("comments",$comments);
$comment_cond['count_only'] = TRUE;
$total_rows = getComments($comment_cond);
$total_pages = count_pages($total_rows,RESULTS);
$pages->paginate($total_pages,$page);
subtitle("Comments");
template_files('comments.html');
display_it();
?>

View file

@ -0,0 +1,25 @@
<?php
/**
* View User Details
* @author:Arslan
* @Since : Oct 16 09
*/
require'../includes/admin_config.php';
//Getting list of available testing videos
$testVidsDir = ADMINBASEDIR.'/lab_resources/testing_videos';
$vidFiles = glob($testVidsDir.'/*');
$vdoFiles = array();
foreach($vidFiles as $vidFile)
{
$vdoFiles[] = array('path'=>$vidFile,'name'=>getName($vidFile).'.'.getExt($vidFile));
}
assign('vdoFiles',$vdoFiles);
subtitle("Conversion lab for ClipBucket conversion testing");
template_files("conversion_lab.html");
display_it();
?>

View file

@ -0,0 +1,22 @@
<?php
/*
* @since : 2009
* @author : Arslan Hassan
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('admin_access');
$pages->page_redir();
if(isset($_POST['update']))
{
$text = mysql_clean($_POST['text']);
update_announcement($text);
$msg = e("Announcement has been updated",'m');
}
subtitle("Annoucment Manager");
template_files('edit_announcemnent.html');
display_it();
?>

View file

@ -0,0 +1,58 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
$id = mysql_clean($_GET['collection']);
if(isset($_POST['update_collection']))
{
$cbcollection->update_collection();
}
if(isset($_POST['delete_preview']))
{
$id = mysql_clean($_POST['delete_preview']);
$cbcollection->delete_thumbs($id);
}
//Performing Actions
if($_GET['mode']!='')
{
$cbcollection->collection_actions($_GET['mode'],$id);
}
$c = $cbcollection->get_collection($id);
switch($c['type'])
{
case "videos":
case "v":
{
$items = $cbvideo->collection->get_collection_items_with_details($c['collection_id'],NULL,4);
}
break;
case "photos":
case "p":
{
$items = $cbphoto->collection->get_collection_items_with_details($c['collection_id'],NULL,4);
}
break;
}
if(!empty($items))
assign('objects',$items);
assign('data',$c);
subtitle("Edit Collection");
template_files('edit_collection.html');
display_it();
?>

View file

@ -0,0 +1,35 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$gpid = mysql_clean($_GET['group_id']);
$group = $cbgroup->get_details($gpid);
if($group)
{
if(isset($_POST['update_group']))
{
$_POST['group_id'] = $gpid;
$cbgroup->update_group();
$group = $cbgroup->get_group_details($gid);
}
assign('group',$group );
}else
e("Group does not exist");
subtitle("Edit Group");
template_files('edit_group.html');
display_it();
?>

View file

@ -0,0 +1,14 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
header('location:view_user.php?uid='.$_GET['uid']);
?>

View file

@ -0,0 +1,42 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
$id = mysql_clean($_GET['photo']);
if(isset($_POST['update']))
{
$cbphoto->update_photo();
}
//Performing Actions
if($_GET['mode']!='')
{
$cbphoto->photo_actions($_GET['mode'],$id);
}
$p = $cbphoto->get_photo($id);
$p['user'] = $p['userid'];
assign('data',$p);
$requiredFields = $cbphoto->load_required_forms($p);
$otherFields = $cbphoto->load_other_forms($p);
assign('requiredFields',$requiredFields);
assign('otherFields',$otherFields);
subtitle("Edit Photo");
template_files('edit_photo.html');
display_it();
?>

View file

@ -0,0 +1,60 @@
<?php
/*
****************************************************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved. |
| @ Author : ArslanHassan |
| @ Software : ClipBucket , © PHPBucket.com |
****************************************************************************************************
*/
require'../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$pages->page_redir();
if(@$_GET['msg']){
$msg[] = clean($_GET['msg']);
}
$video = mysql_clean($_GET['video']);
//Updating Video Details
if(isset($_POST['update'])){
$Upload->validate_video_upload_form();
if(empty($eh->error_list))
{
$myquery->update_video();
$myquery->set_default_thumb($video,$_POST['default_thumb']);
}
}
//Performing Video Acttions
if($_GET['mode']!='')
{
$cbvid->action($_GET['mode'],$video);
}
//Check Video Exists or Not
if($myquery->VideoExists($video)){
//Deleting Comment
$cid = mysql_clean($_GET['delete_comment']);
if(!empty($cid))
{
$myquery->delete_comment($cid);
}
$data = get_video_details($video);
Assign('udata',$userquery->get_user_details($data['userid']));
Assign('data',$data);
}else{
$msg[] = lang('class_vdo_del_err');
}
subtitle("Edit Video");
template_files('edit_video.html');
display_it();
?>

View file

@ -0,0 +1,55 @@
<?php
/*
***************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
//Removing
if(isset($_GET['remove'])){
$id = mysql_clean($_GET['remove']);
remove_vid_editors_pick($id);
}
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=count($_POST['check_video']);$id++)
{
remove_vid_editors_pick($_POST['check_video'][$id]);
}
$eh->flush();
e("Selected videos have been removed from editors pick","m");
}
$ep_videos = get_ep_videos();
if(isset($_POST['update_order']))
{
if(is_array($ep_videos))
{
foreach($ep_videos as $epvid)
{
$order = $_POST['ep_order_'.$epvid['pick_id']];
move_epick($epvid['videoid'],$order);
}
}
$ep_videos = get_ep_videos();
}
assign('videos',$ep_videos);
assign('max',get_highest_sort_number());
assign('min',get_lowest_sort_number());
subtitle("Editor's Pick");
template_files('editor_pick.html');
display_it();
?>

View file

@ -0,0 +1,59 @@
<?php
/*
***************************************************************
| Copyright (c) 2007-2010 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('web_config_access');
$pages->page_redir();
//Updatingg email templates
if(isset($_POST['update']))
{
$templates = $cbemail->get_templates();
foreach($templates as $template)
{
$params = array('id'=>$template['email_template_id'],'subj'=>$_POST['subject'.$template['email_template_id']],
'msg'=>$_POST['message'.$template['email_template_id']]);
$cbemail->update_template($params);
$eh->flush();
e("Email templates have been updated","m");
}
}
if(isset($_POST['update_settings'])){
$configs = $Cbucket->configs;
$rows = array(
'mail_type',
'smtp_host',
'smtp_user',
'smtp_pass',
'smtp_auth',
'smtp_port'
);
foreach($rows as $field)
{
$value = ($_POST[$field]);
$myquery->Set_Website_Details($field,$value);
}
e("Email Settings Have Been Updated",'m');
}
$row = $myquery->Get_Website_Details();
Assign('row',$row);
subtitle("Email Settings");
template_files('email_settings.html');
display_it();
?>

View file

@ -0,0 +1,90 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
//$userquery->perm_check('group_moderation',true);
$mode = $_GET['mode'];
//Delete Photo
if(isset($_GET['delete_collect'])){
$collect = mysql_clean($_GET['delete_collect']);
$cbcollection->delete_collection($collect);
}
//Deleting Multiple Photos
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=count($_POST['check_collect']);$id++)
{
$cbphoto->delete_photo($_POST['check_collect'][$id]);
}
$eh->flush();
e("Selected collections have been deleted","m");
}
if(isset($_REQUEST['delete_flags']))
{
$collect = mysql_clean($_GET['delete_flags']);
$cbcollection->action->delete_flags($collect);
}
//Deleting Multiple Videos
if(isset($_POST['delete_flags']))
{
for($id=0;$id<=count($_POST['check_collect']);$id++)
{
$eh->flush();
$cbcollection->action->delete_flags($_POST['check_collect'][$id]);
}
}
switch($mode)
{
case "view":
default:
{
assign("mode","view");
//Getting Video List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,5);
$collects = $cbcollection->action->get_flagged_objects($get_limit);
assign('c', $collects);
//Collecting Data for Pagination
$total_rows = $cbcollection->action->count_flagged_objects();
$total_pages = count_pages($total_rows,5);
//Pagination
$pages->paginate($total_pages,$page);
}
break;
case "view_flags":
{
assign("mode","view_flags");
$cid = mysql_clean($_GET['cid']);
$cdetails = $cbcollection->get_collection($cid);
if($cdetails)
{
$flags = $cbcollection->action->get_flags($pid);
assign('flags',$flags);
assign('collection',$cdetails);
}else
e("Collection does not exist");
}
}
subtitle("Flagged Collections");
template_files('flagged_collections.html');
display_it();
?>

View file

@ -0,0 +1,118 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
$userquery->perm_check('group_moderation',true);
$mode = $_GET['mode'];
//Delete Video
if(isset($_GET['delete_group'])){
$group = mysql_clean($_GET['delete_group']);
$cbgroup->delete_group($group);
}
//Deleting Multiple Videos
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=count($_POST['check_group']);$id++)
{
$cbgroup->delete_group($_POST['check_group'][$id]);
}
$eh->flush();
e("Selected groups have been deleted","m");
}
//Activate / Deactivate
if(isset($_GET['activate'])){
$group = mysql_clean($_GET['activate']);
$cbgroup->grp_actions('activate',$group);
}
if(isset($_GET['deactivate'])){
$group = mysql_clean($_GET['deactivate']);
$cbgroup->grp_actions('deactivate',$group);
}
//Using Multple Action
if(isset($_POST['activate_selected'])){
for($id=0;$id<=count($_POST['check_group']);$id++){
$cbgroup->grp_actions('activate',$_POST['check_group'][$id]);
}
e("Selected Groups Have Been Activated","m");
}
if(isset($_POST['deactivate_selected'])){
for($id=0;$id<=count($_POST['check_group']);$id++){
$cbgroup->grp_actions('activate',$_POST['check_group'][$id]);
}
e("Selected Groups Have Been Dectivated","m");
}
if(isset($_REQUEST['delete_flags']))
{
$group = mysql_clean($_GET['delete_flags']);
$cbgroup->action->delete_flags($group);
}
//Deleting Multiple Videos
if(isset($_POST['delete_flags']))
{
for($id=0;$id<=count($_POST['check_group']);$id++)
{
$eh->flush();
$cbgroup->action->delete_flags($_POST['check_group'][$id]);
}
}
switch($mode)
{
case "view":
default:
{
assign("mode","view");
//Getting Video List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,5);
$groups = $cbgroup->action->get_flagged_objects($get_limit);
Assign('groups', $groups);
//Collecting Data for Pagination
$total_rows = $cbgroup->action->count_flagged_objects();
$total_pages = count_pages($total_rows,5);
//Pagination
$pages->paginate($total_pages,$page);
}
break;
case "view_flags":
{
assign("mode","view_flags");
$gid = mysql_clean($_GET['gid']);
$gdetails = $cbgroup->get_details($gid);
if($gdetails)
{
$flags = $cbgroup->action->get_flags($gid);
assign('flags',$flags);
assign('group',$gdetails);
}else
e("Group does not exist");
}
}
subtitle("Flagged Groups");
template_files('flagged_groups.html');
display_it();
?>

View file

@ -0,0 +1,91 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
//$userquery->perm_check('group_moderation',true);
$mode = $_GET['mode'];
//Delete Photo
if(isset($_GET['delete_photo'])){
$photo = mysql_clean($_GET['delete_photo']);
$cbphoto->delete_photo($photo);
}
//Deleting Multiple Photos
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=count($_POST['check_photo']);$id++)
{
$cbphoto->delete_photo($_POST['check_photo'][$id]);
}
$eh->flush();
e("Selected photos have been deleted","m");
}
if(isset($_REQUEST['delete_flags']))
{
$photo = mysql_clean($_GET['delete_flags']);
$cbphoto->action->delete_flags($photo);
}
//Deleting Multiple Videos
if(isset($_POST['delete_flags']))
{
for($id=0;$id<=count($_POST['check_photo']);$id++)
{
$eh->flush();
$cbphoto->action->delete_flags($_POST['check_photo'][$id]);
}
}
switch($mode)
{
case "view":
default:
{
assign("mode","view");
//Getting Video List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,5);
$photos = $cbphoto->action->get_flagged_objects($get_limit);
assign('photos', $photos);
//Collecting Data for Pagination
$total_rows = $cbphoto->action->count_flagged_objects();
$total_pages = count_pages($total_rows,5);
//Pagination
$pages->paginate($total_pages,$page);
}
break;
case "view_flags":
{
assign("mode","view_flags");
$pid = mysql_clean($_GET['pid']);
$pdetails = $cbphoto->get_photo($pid);
if($pdetails)
{
$flags = $cbphoto->action->get_flags($pid);
assign('flags',$flags);
assign('photo',$pdetails);
}else
e("Photo does not exist");
}
}
subtitle("Flagged Photos");
template_files('flagged_photos.html');
display_it();
?>

View file

@ -0,0 +1,117 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$mode = $_GET['mode'];
//Delete Video
if(isset($_GET['delete_user'])){
$user = mysql_clean($_GET['delete_user']);
$userquery->delete_user($user);
}
//Deleting Multiple Videos
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=count($_POST['check_user']);$id++)
{
$userquery->delete_user($_POST['check_user'][$id]);
}
$eh->flush();
e("Selected users have been deleted","m");
}
//Activate / Deactivate
if(isset($_GET['activate'])){
$user = mysql_clean($_GET['activate']);
$userquery->action('activate',$user);
}
if(isset($_GET['deactivate'])){
$user = mysql_clean($_GET['deactivate']);
$userquery->action('deactivate',$user);
}
//Using Multple Action
if(isset($_POST['activate_selected'])){
for($id=0;$id<=count($_POST['check_user']);$id++){
$userquery->action('activate',$_POST['check_user'][$id]);
}
e("Selected users Have Been Activated","m");
}
if(isset($_POST['deactivate_selected'])){
for($id=0;$id<=count($_POST['check_user']);$id++){
$userquery->action('activate',$_POST['check_user'][$id]);
}
e("Selected users Have Been Dectivated","m");
}
if(isset($_REQUEST['delete_flags']))
{
$user = mysql_clean($_GET['delete_flags']);
$userquery->action->delete_flags($user);
}
//Deleting Multiple Videos
if(isset($_POST['delete_flags']))
{
for($id=0;$id<=count($_POST['check_user']);$id++)
{
$eh->flush();
$userquery->action->delete_flags($_POST['check_user'][$id]);
}
}
switch($mode)
{
case "view":
default:
{
assign("mode","view");
//Getting Video List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,5);
$users = $userquery->action->get_flagged_objects($get_limit);
Assign('users', $users);
//Collecting Data for Pagination
$total_rows = $userquery->action->count_flagged_objects();
$total_pages = count_pages($total_rows,5);
//Pagination
$pages->paginate($total_pages,$page);
}
break;
case "view_flags":
{
assign("mode","view_flags");
$uid = mysql_clean($_GET['uid']);
$udetails = $userquery->get_user_details($uid);
if($udetails)
{
$flags = $userquery->action->get_flags($uid);
assign('flags',$flags);
assign('user',$udetails);
}else
e("user does not exist");
}
}
subtitle("Flagged Users");
template_files('flagged_users.html');
display_it();
?>

View file

@ -0,0 +1,117 @@
<?php
/*
****************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
****************************************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$userquery->login_check('video_moderation');
$mode = $_GET['mode'];
//Delete Video
if(isset($_GET['delete_video'])){
$video = mysql_clean($_GET['delete_video']);
$cbvideo->delete_video($video);
}
//Deleting Multiple Videos
if(isset($_POST['delete_selected']))
{
for($id=0;$id<=RESULTS;$id++)
{
$cbvideo->delete_video($_POST['check_video'][$id]);
}
$eh->flush();
e(lang("vdo_multi_del_erro"),"m");
}
//Activate / Deactivate
if(isset($_GET['activate'])){
$video = mysql_clean($_GET['activate']);
$cbvid->action('activate',$video);
}
if(isset($_GET['deactivate'])){
$video = mysql_clean($_GET['deactivate']);
$cbvid->action('deactivate',$video);
}
//Using Multple Action
if(isset($_POST['activate_selected'])){
for($id=0;$id<=RESULTS;$id++){
$cbvid->action('activate',$_POST['check_video'][$id]);
}
e("Selected Videos Have Been Activated","m");
}
if(isset($_POST['deactivate_selected'])){
for($id=0;$id<=RESULTS;$id++){
$cbvid->action('deactivate',$_POST['check_video'][$id]);
}
e("Selected Videos Have Been Dectivated","m");
}
if(isset($_REQUEST['delete_flags']))
{
$video = mysql_clean($_GET['delete_flags']);
$cbvid->action->delete_flags($video);
}
//Deleting Multiple Videos
if(isset($_POST['delete_flags']))
{
for($id=0;$id<=RESULTS;$id++)
{
$eh->flush();
$cbvid->action->delete_flags($_POST['check_video'][$id]);
}
}
switch($mode)
{
case "view":
default:
{
assign("mode","view");
//Getting Video List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,5);
$videos = $cbvid->action->get_flagged_objects($get_limit);
Assign('videos', $videos);
//Collecting Data for Pagination
$total_rows = $cbvid->action->count_flagged_objects();
$total_pages = count_pages($total_rows,5);
//Pagination
$pages->paginate($total_pages,$page);
}
break;
case "view_flags":
{
assign("mode","view_flags");
$vid = mysql_clean($_GET['vid']);
$vdetails = $cbvid->get_video($vid);
if($vdetails)
{
$flags = $cbvid->action->get_flags($vid);
assign('flags',$flags);
assign('video',$vdetails);
}else
e("Video does not exist");
}
}
subtitle("Flagged Videos");
template_files('flagged_videos.html');
display_it();
?>

View file

@ -0,0 +1,63 @@
<?php
/*
*******************************************
| Copyright (c) 2007-2009 Clip-Bucket.com & (Arslan Hassan). All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
*******************************************
*/
require_once '../includes/admin_config.php';
$userquery->admin_login_check();
$pages->page_redir();
$userquery->perm_check('group_moderation',true);
//Form Processing
if(isset($_POST['add_cateogry'])){
$cbgroup->add_category($_POST);
}
//Making Categoyr as Default
if(isset($_GET['make_default']))
{
$cid = mysql_clean($_GET['make_default']);
$cbgroup->make_default_category($cid);
}
//Edit Categoty
if(isset($_GET['category'])){
assign("edit_category","show");
if(isset($_POST['update_category']))
{
$cbgroup->update_category($_POST);
}
assign('cat_details',$cbgroup->get_category($_GET['category']));
}
//Delete Category
if(isset($_GET['delete_category'])){
$cbgroup->delete_category($_GET['delete_category']);
}
$cats = $cbgroup->get_categories();
//Updating Category Order
if(isset($_POST['update_order']))
{
foreach($cats as $cat)
{
if(!empty($cat['category_id']))
{
$order = $_POST['category_order_'.$cat['category_id']];
$cbgroup->update_cat_order($cat['category_id'],$order);
}
}
$cats = $cbgroup->get_categories();
}
//Assing Category Values
assign('category',$cats);
assign('total',$cbgroup->total_categories());
subtitle("Groups Category manager");
template_files('group_category.html'); display_it();
?>

Some files were not shown because too many files have changed in this diff Show more