imported last 2.x commit (Arslan)
This commit is contained in:
parent
f3c9e83b0f
commit
3f2a9aab34
42 changed files with 1030 additions and 101 deletions
|
@ -23,4 +23,6 @@ ADD `sender_id` INT NOT NULL AFTER `outbox_user_id` ,
|
|||
ADD `reciever_id` INT NOT NULL AFTER `sender_id`
|
||||
|
||||
ALTER TABLE `subscriptions` ADD `subscriber_id` INT NOT NULL AFTER `subscribed_user` ,
|
||||
ADD `userid` INT NOT NULL AFTER `subscriber_id`
|
||||
ADD `userid` INT NOT NULL AFTER `subscriber_id`
|
||||
|
||||
ALTER TABLE `plugins` ADD `plugin_folder` TEXT NOT NULL AFTER `plugin_file`
|
|
@ -43,11 +43,11 @@ if($lang_obj->lang_exists(mysql_clean($_GET['edit_language'])))
|
|||
if(!empty($varname))
|
||||
$varname_query = "varname LIKE '%$varname%'";
|
||||
if(!empty($text))
|
||||
$text_query = "varname text '%$text%'";
|
||||
$text_query = "text LIKE '%$text%'";
|
||||
|
||||
if(!empty($text_query) || !empty($varname_query))
|
||||
{
|
||||
if(!empty($text_query))
|
||||
if(!empty($text_query) && !empty($varname_query) )
|
||||
$or = ' OR ';
|
||||
$extra_param = " AND ( $varname_query $or $text_query )";
|
||||
}
|
||||
|
|
|
@ -16,28 +16,32 @@ $pages->page_redir();
|
|||
//unnstalling Plugin
|
||||
if(isset($_GET['uninstall']))
|
||||
{
|
||||
$msg = $cbplugin->uninstallPlugin(mysql_clean($_GET['uninstall']));
|
||||
$folder = $_GET['f'];
|
||||
$msg = $cbplugin->uninstallPlugin(mysql_clean($_GET['uninstall']),$folder);
|
||||
}
|
||||
|
||||
|
||||
//Activation or deactivating plugin
|
||||
if(isset($_GET['activate']))
|
||||
{
|
||||
$folder = $_GET['f'];
|
||||
$id = mysql_clean($_GET['activate']);
|
||||
$msg = $cbplugin->pluginActive($id,'yes');
|
||||
$msg = $cbplugin->pluginActive($id,'yes',$folder);
|
||||
}
|
||||
|
||||
if(isset($_GET['deactivate']))
|
||||
{
|
||||
$folder = $_GET['f'];
|
||||
$id = mysql_clean($_GET['deactivate']);
|
||||
$msg = $cbplugin->pluginActive($id,'no');
|
||||
$msg = $cbplugin->pluginActive($id,'no',$folder);
|
||||
}
|
||||
|
||||
|
||||
//Installing Plugin
|
||||
if(isset($_GET['install_plugin']))
|
||||
{
|
||||
$msg = $cbplugin->installPlugin(mysql_clean($_GET['install_plugin']));
|
||||
$folder = $_GET['f'];
|
||||
$msg = $cbplugin->installPlugin(mysql_clean($_GET['install_plugin']),$folder);
|
||||
}
|
||||
|
||||
//Get New Plugin List
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<!-- Including Global Header -->
|
||||
{include file="$style_dir/global_header.html" }
|
||||
<html>
|
||||
<body>
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
<a href="{$plug.website}">{$plug.website}</a></em><br>
|
||||
Version : {$plug.version}
|
||||
</td>
|
||||
<td height="100" valign="top" class="td_body">{if $plug.plugin_active == 'yes'}<a href="?deactivate={$plug.plugin_file}">Deactivate</a>{else}<a href="?activate={$plug.plugin_file}">Activate</a>{/if}<br>
|
||||
<a href="javascript:Confirm_Uninstall('?uninstall={$plug.plugin_file}')">Uninstall</a></td>
|
||||
<td height="100" valign="top" class="td_body">{if $plug.plugin_active == 'yes'}<a href="?deactivate={$plug.plugin_file}{if $plug.folder!=''}&f={$plug.folder}{/if}">Deactivate</a>{else}<a href="?activate={$plug.plugin_file}{if $plug.folder!=''}&f={$plug.folder}{/if}">Activate</a>{/if}<br>
|
||||
<a href="javascript:Confirm_Uninstall('?uninstall={$plug.plugin_file}{if $plug.folder!=''}&f={$plug.folder}{/if}')">Uninstall</a></td>
|
||||
</tr>
|
||||
{if $bgcolor == ""}
|
||||
{assign var = bgcolor value = "#EEEEEE"}
|
||||
|
@ -52,7 +52,7 @@ Version : {$plug.version}
|
|||
<a href="{$plug.website}">{$plug.website}</a></em><br>
|
||||
Version : {$plug.version}
|
||||
</td>
|
||||
<td height="100" valign="top" class="td_body"><a href="?install_plugin={$plug.file}">Install Plugin</a></td>
|
||||
<td height="100" valign="top" class="td_body"><a href="?install_plugin={$plug.file}{if $plug.folder!=''}&f={$plug.folder}{/if}">Install Plugin</a></td>
|
||||
</tr>
|
||||
{if $bgcolor == ""}
|
||||
{assign var = bgcolor value = "#EEEEEE"}
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
@charset "utf-8";
|
||||
/* CSS Document */
|
||||
|
||||
BODY
|
||||
html,BODY
|
||||
{
|
||||
margin:0px;
|
||||
padding:0px;
|
||||
|
|
|
@ -93,12 +93,12 @@ class myquery {
|
|||
}
|
||||
|
||||
function check_user($username){
|
||||
$query = mysql_query("SELECT * FROM users WHERE username ='".$username."'");
|
||||
if(mysql_num_rows($query) > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
$query = mysql_query("SELECT * FROM users WHERE username ='".$username."'");
|
||||
if(mysql_num_rows($query) > 0){
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function check_email($email){
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
/**
|
||||
Plugin class
|
||||
Author:Arslan Hassan
|
||||
version : 1.1 - 2009 august 26
|
||||
|
||||
Wiget Areas, for multiple places, use "[place]placement[/place]" without quotes
|
||||
-- For including some files in templates, following placements can be set
|
||||
|
@ -62,12 +63,33 @@ class CBPlugin extends ClipBucket
|
|||
if($item=='..' || $item=='.' || substr($item,0,1)=='_'|| substr($item,0,1)=='.')
|
||||
{
|
||||
//Skip $item_list[] = $item;
|
||||
//$sub_dir_list = scandir(PLUG_DIR.'/'.$item);
|
||||
}else{
|
||||
//Now CHecking if its file, not a directory
|
||||
if(!is_dir(PLUG_DIR.'/'.$item))
|
||||
$item_list[] = $item;
|
||||
{
|
||||
$item_list[] = $item;
|
||||
}else{
|
||||
$sub_dir = $item;
|
||||
$sub_dir_list = scandir(PLUG_DIR.'/'.$item);
|
||||
foreach($sub_dir_list as $item)
|
||||
{
|
||||
if($item=='..' || $item=='.' || substr($item,0,1)=='_'|| substr($item,0,1)=='.')
|
||||
{
|
||||
//Skip $item_list[] = $item;
|
||||
//$sub_dir_list = scandir(PLUG_DIR.'/'.$item);
|
||||
}else{
|
||||
//Now CHecking if its file, not a directory
|
||||
if(!is_dir(PLUG_DIR.'/'.$sub_dir.'/'.$item))
|
||||
{
|
||||
$subitem_list[$sub_dir][] = $item;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Our Plugin List has plugin main files only, now star reading files
|
||||
foreach($item_list as $plugin_file)
|
||||
{
|
||||
|
@ -76,6 +98,18 @@ class CBPlugin extends ClipBucket
|
|||
$plugins_array[]= $plugin_details;
|
||||
}
|
||||
|
||||
//Now Reading Sub Dir Files
|
||||
foreach($subitem_list as $sub_dir => $sub_dir_list )
|
||||
{
|
||||
foreach($subitem_list[$sub_dir] as $plugin_file)
|
||||
{
|
||||
$plugin_details = $this->getPluginDetails($plugin_file,$sub_dir);
|
||||
$plugin_details['folder'] = $sub_dir;
|
||||
if(!empty($plugin_details['name']))
|
||||
$plugins_array[] = $plugin_details;
|
||||
}
|
||||
}
|
||||
|
||||
return $plugins_array;
|
||||
}
|
||||
|
||||
|
@ -129,13 +163,16 @@ class CBPlugin extends ClipBucket
|
|||
* Function used to check weather plugin is instlled or not
|
||||
* @param : $plugin_code STRING
|
||||
*/
|
||||
function is_installed($file,$v=NULL)
|
||||
function is_installed($file,$v=NULL,$folder=NULL)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if($v)
|
||||
$version_check = "AND plugin_version='$v'";
|
||||
$query = "SELECT plugin_file FROM plugins WHERE $version_check plugin_file='".$file."'";
|
||||
if($folder)
|
||||
$folder_check = " AND plugin_folder ='$folder'";
|
||||
|
||||
$query = "SELECT plugin_file FROM plugins WHERE plugin_file='".$file."' $version_check $folder_check";
|
||||
$details = $db->Execute($query);
|
||||
if($details->recordcount()>0)
|
||||
return true;
|
||||
|
@ -148,9 +185,12 @@ class CBPlugin extends ClipBucket
|
|||
* get plugin details
|
||||
* @param : $file STRING
|
||||
*/
|
||||
function get_plugin_details($plug_file)
|
||||
function get_plugin_details($plug_file,$sub_dir=NULL)
|
||||
{
|
||||
$file = PLUG_DIR.'/'.$plug_file;
|
||||
if($sub_dir!='')
|
||||
$sub_dir = $sub_dir.'/';
|
||||
|
||||
$file = PLUG_DIR.'/'.$sub_dir.$plug_file;
|
||||
if(file_exists($file) && is_file($file))
|
||||
{
|
||||
// We don't need to write to the file, so just open for reading.
|
||||
|
@ -192,9 +232,9 @@ class CBPlugin extends ClipBucket
|
|||
return false;
|
||||
}
|
||||
}
|
||||
function getPluginDetails($file)
|
||||
function getPluginDetails($file,$sub_dir=NULL)
|
||||
{
|
||||
return $this->get_plugin_details($file);
|
||||
return $this->get_plugin_details($file,$sub_dir);
|
||||
}
|
||||
|
||||
|
||||
|
@ -203,9 +243,12 @@ class CBPlugin extends ClipBucket
|
|||
* Function used to get plugin details from database
|
||||
* @param : plugin_id_code STRING
|
||||
*/
|
||||
function getPlugin($file)
|
||||
function getPlugin($file,$folder=NULL)
|
||||
{
|
||||
$query = mysql_query("SELECT * FROM plugins WHERE plugin_file ='".$file."'");
|
||||
if($folder)
|
||||
$folder_query = " AND plugin_folder = '$folder'";
|
||||
|
||||
$query = mysql_query("SELECT * FROM plugins WHERE plugin_file ='".$file."' $folder_query");
|
||||
return mysql_fetch_assoc($query);
|
||||
}
|
||||
|
||||
|
@ -214,24 +257,26 @@ class CBPlugin extends ClipBucket
|
|||
* ClipBucket Internal Plugin Installer
|
||||
* @param:plugin
|
||||
*/
|
||||
function installPlugin($pluginFile)
|
||||
function installPlugin($pluginFile,$folder=NULL)
|
||||
{
|
||||
global $db,$LANG,$Cbucket;
|
||||
$plug_details = $this->get_plugin_details($pluginFile);
|
||||
$plug_details = $this->get_plugin_details($pluginFile,$folder);
|
||||
if(!$plug_details)
|
||||
$msg = e($LANG['plugin_no_file_err']);
|
||||
if(empty($plug_details['name']))
|
||||
$msg = e($LANG['plugin_file_detail_err']);
|
||||
if($this->is_installed($pluginFile))
|
||||
if($this->is_installed($pluginFile,$folder))
|
||||
$msg = e($LANG['plugin_installed_err']);
|
||||
|
||||
if(empty($msg))
|
||||
{
|
||||
|
||||
$plug_details = $this->getPluginDetails(PLUG_DIR.'/'.$pluginFile);
|
||||
$file_folder = $folder;
|
||||
if($folder!='')
|
||||
$folder = $folder.'/';
|
||||
$plug_details = $this->getPluginDetails(PLUG_DIR.'/'.$folder.$pluginFile);
|
||||
|
||||
if(file_exists(PLUG_DIR.'/install_'.$pluginFile))
|
||||
require_once(PLUG_DIR.'/install_'.$pluginFile);
|
||||
if(file_exists(PLUG_DIR.'/'.$folder.'install_'.$pluginFile))
|
||||
require_once(PLUG_DIR.'/'.$folder.'install_'.$pluginFile);
|
||||
|
||||
dbInsert
|
||||
(
|
||||
|
@ -242,6 +287,7 @@ class CBPlugin extends ClipBucket
|
|||
'plugin_license_key',
|
||||
'plugin_license_code',
|
||||
'plugin_active',
|
||||
'plugin_folder'
|
||||
),
|
||||
array(
|
||||
$pluginFile,
|
||||
|
@ -249,6 +295,7 @@ class CBPlugin extends ClipBucket
|
|||
$plugin_details_array['plugin_license_key'],
|
||||
$plugin_details_array['plugin_license_code'],
|
||||
'yes',
|
||||
$file_folder,
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -262,11 +309,15 @@ class CBPlugin extends ClipBucket
|
|||
/**
|
||||
* Function used to activate plugin
|
||||
*/
|
||||
function pluginActive($plugin_file,$active='yes'){
|
||||
function pluginActive($plugin_file,$active='yes',$folder=NULL){
|
||||
global $LANG;
|
||||
|
||||
if($folder)
|
||||
$folder_query = " AND plugin_folder = '$folder'";
|
||||
|
||||
if($this->is_installed($plugin_file))
|
||||
{
|
||||
mysql_query("UPDATE plugins SET plugin_active='".$active."' WHERE plugin_file='".$plugin_file."'");
|
||||
mysql_query("UPDATE plugins SET plugin_active='".$active."' WHERE plugin_file='".$plugin_file."' $folder_query");
|
||||
$active_msg = $active=='yes' ? 'activated' : 'deactiveted';
|
||||
$msg = e("Plugin has been $active_msg",m);
|
||||
}else{
|
||||
|
@ -278,13 +329,19 @@ class CBPlugin extends ClipBucket
|
|||
/**
|
||||
* Function used to activate plugin
|
||||
*/
|
||||
function uninstallPlugin($file){
|
||||
function uninstallPlugin($file,$folder=NULL){
|
||||
global $LANG;
|
||||
if($this->is_installed($file))
|
||||
{
|
||||
mysql_query("DELETE FROM plugins WHERE plugin_file='".$file."' ");
|
||||
if(file_exists(PLUG_DIR.'/uninstall_'.$file))
|
||||
require_once(PLUG_DIR.'/uninstall_'.$file);
|
||||
if($folder)
|
||||
$folder_query = " AND plugin_folder = '$folder'";
|
||||
|
||||
if($folder!='')
|
||||
$folder = $folder.'/';
|
||||
|
||||
mysql_query("DELETE FROM plugins WHERE plugin_file='".$file."' $folder_query");
|
||||
if(file_exists(PLUG_DIR.'/'.$folder.'uninstall_'.$file))
|
||||
require_once(PLUG_DIR.'/'.$folder.'uninstall_'.$file);
|
||||
$msg = e("Plugin has been Uninstalled",m);
|
||||
}else{
|
||||
$msg = e($LANG['plugin_no_install_err']);
|
||||
|
@ -292,16 +349,6 @@ class CBPlugin extends ClipBucket
|
|||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to add ClipBucket Plugin Menu
|
||||
*/
|
||||
function add_admin_menu($headers,$links)
|
||||
{
|
||||
//This Function used to createa admin menu
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -15,9 +15,12 @@
|
|||
*/
|
||||
class signup {
|
||||
|
||||
var $signup_plugins = array(); //Signup Plugins
|
||||
var $custom_signup_fields = array();
|
||||
|
||||
function load_signup_fields($default=NULL)
|
||||
{
|
||||
global $LANG,$user_signup_fields,$Cbucket;;
|
||||
global $LANG,$Cbucket;
|
||||
/**
|
||||
* this function will create initial array for user fields
|
||||
* this will tell
|
||||
|
@ -37,19 +40,17 @@ class signup {
|
|||
* anchor_after [anchor after field]
|
||||
* )
|
||||
*/
|
||||
if(empty($default))
|
||||
{
|
||||
$username = $_POST['username'];
|
||||
$email = $_POST['email'];
|
||||
$dcountry = $_POST['country'];
|
||||
$dob = $_POST['dob'];
|
||||
}else{
|
||||
$username = $default['username'];
|
||||
$email = $default['email'];
|
||||
$dcountry = $default['country'];
|
||||
$dob = $default['dob'];
|
||||
}
|
||||
$dob = $dob ? date("d M, Y",strtotime($dob)) : '14 Oct, 1989';
|
||||
|
||||
|
||||
if(empty($default))
|
||||
$default = $_POST;
|
||||
|
||||
$username = $default['username'];
|
||||
$email = $default['email'];
|
||||
$dcountry = $default['country'];
|
||||
$dob = $default['dob'];
|
||||
|
||||
$dob = $dob ? date("d-m-Y",strtotime($dob)) : '14-14-1989';
|
||||
|
||||
$user_signup_fields = array
|
||||
(
|
||||
|
@ -60,6 +61,14 @@ class signup {
|
|||
'id'=> "username",
|
||||
'value'=> $username,
|
||||
'hint_2'=> $LANG['user_allowed_format'],
|
||||
'db_field'=>'username',
|
||||
'required'=>'yes',
|
||||
'syntax_type'=> 'username',
|
||||
'validate_function'=> 'username_check',
|
||||
'function_error_msg' => $LANG['user_contains_disallow_err'],
|
||||
'db_value_check_func'=> 'user_exists',
|
||||
'db_value_exists'=>false,
|
||||
'db_value_err'=>$LANG['usr_uname_err2']
|
||||
),
|
||||
'email' => array(
|
||||
'title'=> $LANG['email'],
|
||||
|
@ -67,18 +76,34 @@ class signup {
|
|||
'name'=> "email",
|
||||
'id'=> "email",
|
||||
'value'=> $email,
|
||||
'db_field'=>'email',
|
||||
'required'=>'yes',
|
||||
'syntax_type'=> 'email',
|
||||
'db_value_check_func'=> 'email_exists',
|
||||
'db_value_exists'=>false,
|
||||
'db_value_err'=>$LANG['usr_email_err3']
|
||||
),
|
||||
'password' => array(
|
||||
'title'=> $LANG['password'],
|
||||
'type'=> "password",
|
||||
'name'=> "password",
|
||||
'id'=> "password",
|
||||
'db_field'=>'password',
|
||||
'required'=>'yes',
|
||||
'invalid_err'=>$LANG['usr_pass_err2'],
|
||||
'relative_to' => 'cpassword',
|
||||
'relative_type' => 'exact',
|
||||
'relative_err' => $LANG['usr_pass_err3'],
|
||||
'validate_function' => 'pass_code',
|
||||
'use_func_val'=>true
|
||||
),
|
||||
'cpassword' => array(
|
||||
'title'=> $LANG['user_confirm_pass'],
|
||||
'type'=> "password",
|
||||
'name'=> "cpassword",
|
||||
'id'=> "cpassword",
|
||||
'required'=>'no',
|
||||
'invalid_err'=>$LANG['usr_cpass_err'],
|
||||
),
|
||||
'country' => array(
|
||||
'title'=> $LANG['country'],
|
||||
|
@ -86,7 +111,9 @@ class signup {
|
|||
'value' => $Cbucket->get_countries(iso2),
|
||||
'id' => 'country',
|
||||
'name' => 'country',
|
||||
'checked'=> $dcountry
|
||||
'checked'=> $dcountry,
|
||||
'db_field'=>'country',
|
||||
'required'=>'yes',
|
||||
),
|
||||
'gender' => array(
|
||||
'title' => $LANG['gender'],
|
||||
|
@ -96,6 +123,8 @@ class signup {
|
|||
'value' => array('Male'=>$LANG['male'],'Female'=>$LANG['female']),
|
||||
'sep'=> ' ',
|
||||
'checked'=>'female',
|
||||
'db_field'=>'sex',
|
||||
'required'=>'yes',
|
||||
),
|
||||
'dob' => array(
|
||||
'title' => $LANG['user_date_of_birth'],
|
||||
|
@ -105,6 +134,8 @@ class signup {
|
|||
'class'=>'date_field',
|
||||
'anchor_after' => 'date_picker',
|
||||
'value'=> $dob,
|
||||
'db_field'=>'dob',
|
||||
'required'=>'yes',
|
||||
)
|
||||
);
|
||||
|
||||
|
@ -112,16 +143,228 @@ class signup {
|
|||
}
|
||||
|
||||
|
||||
//Creating DOB field
|
||||
/**
|
||||
* Function used to validate Signup Form
|
||||
*/
|
||||
function validate_form_fields($array=NULL)
|
||||
{
|
||||
$fields = $this->load_signup_fields($array);
|
||||
|
||||
if($array==NULL)
|
||||
$array = $_POST;
|
||||
|
||||
if(is_array($_FILES))
|
||||
$array = array_merge($array,$_FILES);
|
||||
|
||||
//Mergin Array
|
||||
$signup_fields = array_merge($fields,$this->custom_signup_fields);
|
||||
|
||||
//Now Validating Each Field 1 by 1
|
||||
foreach($signup_fields as $field)
|
||||
{
|
||||
$field['name'] = formObj::rmBrackets($field['name']);
|
||||
|
||||
//pr($field);
|
||||
$title = $field['title'];
|
||||
$val = $array[$field['name']];
|
||||
$req = $field['required'];
|
||||
$invalid_err = $field['invalid_err'];
|
||||
$function_error_msg = $field['function_error_msg'];
|
||||
$length = strlen($val);
|
||||
$min_len = $field['min_length'];
|
||||
$min_len = $min_len ? $min_len : 0;
|
||||
$max_len = $field['max_length'] ;
|
||||
$rel_val = $array[$field['relative_to']];
|
||||
|
||||
if(empty($invalid_err))
|
||||
$invalid_err = sprintf("Invalid '%s'",$title);
|
||||
if(is_array($array[$field['name']]))
|
||||
$invalid_err = '';
|
||||
|
||||
//Checking if its required or not
|
||||
if($req == 'yes')
|
||||
{
|
||||
if(empty($val) && !is_array($array[$field['name']]))
|
||||
{
|
||||
e($invalid_err);
|
||||
$block = true;
|
||||
}else{
|
||||
$block = false;
|
||||
}
|
||||
}
|
||||
$funct_err = is_valid_value($field['validate_function'],$val);
|
||||
if($block!=true)
|
||||
{
|
||||
//Checking Syntax
|
||||
if(!$funct_err)
|
||||
{
|
||||
if(!empty($function_error_msg))
|
||||
e($function_error_msg);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}elseif(!is_valid_syntax($field['syntax_type'],$val))
|
||||
{
|
||||
if(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}
|
||||
elseif(isset($max_len))
|
||||
{
|
||||
if($length > $max_len || $length < $min_len)
|
||||
e(sprintf(" please enter '%s' value between '%s' and '%s'",
|
||||
$title,$field['min_length'],$field['max_length']));
|
||||
}elseif(function_exists($field['db_value_check_func']))
|
||||
{
|
||||
$db_val_result = $field['db_value_check_func']($val);
|
||||
if($db_val_result != $field['db_value_exists'])
|
||||
if(!empty($field['db_value_err']))
|
||||
e($field['db_value_err']);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}elseif($field['relative_type']!='')
|
||||
{
|
||||
switch($field['relative_type'])
|
||||
{
|
||||
case 'exact':
|
||||
{
|
||||
if($rel_val != $val)
|
||||
{
|
||||
if(!empty($field['relative_err']))
|
||||
e($field['relative_err']);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to validate signup form
|
||||
*/
|
||||
function signup_user($array=NULL)
|
||||
{
|
||||
global $LANG,$db;
|
||||
if($array==NULL)
|
||||
$array = $_POST;
|
||||
|
||||
if(is_array($_FILES))
|
||||
$array = array_merge($array,$_FILES);
|
||||
$this->validate_form_fields($array);
|
||||
|
||||
//checking terms and policy agreement
|
||||
if($_POST['agree']!='yes')
|
||||
e($LANG['usr_ament_err']);
|
||||
if(!error())
|
||||
{
|
||||
$signup_fields = $this->load_signup_fields($array);
|
||||
|
||||
//Adding Custom Signup Fields
|
||||
if(count($this->custom_signup_fields)>0)
|
||||
$signup_fields = array_merge($signup_fields,$this->custom_signup_fields);
|
||||
|
||||
foreach($signup_fields as $field)
|
||||
{
|
||||
$name = formObj::rmBrackets($field['name']);
|
||||
$val = $array[$name];
|
||||
|
||||
if($field['use_func_val'])
|
||||
$val = $field['validate_function']($val);
|
||||
|
||||
|
||||
if(!empty($field['db_field']))
|
||||
$query_field[] = $field['db_field'];
|
||||
|
||||
if(is_array($val))
|
||||
{
|
||||
$new_val = '';
|
||||
foreach($val as $v)
|
||||
{
|
||||
$new_val .= "#".$v."# ";
|
||||
}
|
||||
$val = $new_val;
|
||||
}
|
||||
if(!$field['clean_func'] || (!function_exists($field['clean_func']) && !is_array($field['clean_func'])))
|
||||
$val = mysql_clean($val);
|
||||
else
|
||||
$val = apply_func($field['clean_func'],$val);
|
||||
|
||||
if(!empty($field['db_field']))
|
||||
$query_val[] = $val;
|
||||
|
||||
}
|
||||
|
||||
// Setting Verification type
|
||||
if(EMAIL_VERIFICATION == '1'){
|
||||
$usr_status = 'ToActivate';
|
||||
}else{
|
||||
$usr_status = 'Ok';
|
||||
}
|
||||
$query_field[] = " usr_status";
|
||||
$query_val[] = $usr_status;
|
||||
|
||||
//Creating AV Code
|
||||
$avcode = RandomString(10);
|
||||
$query_field[] = "avcode";
|
||||
$query_val[] = $avcode;
|
||||
|
||||
//Signup IP
|
||||
$signup_ip = $_SERVER['REMOTE_ADDR'];
|
||||
$query_field[] = "signup_ip";
|
||||
$query_val[] = $signup_ip;
|
||||
|
||||
//Date Joined
|
||||
$now = NOW();
|
||||
$query_field[] = "doj";
|
||||
$query_val[] = $now;
|
||||
|
||||
$query = "INSERT INTO users (";
|
||||
$total_fields = count($query_field);
|
||||
|
||||
//Adding Fields to query
|
||||
$i = 0;
|
||||
foreach($query_field as $qfield)
|
||||
{
|
||||
$i++;
|
||||
$query .= $qfield;
|
||||
if($i<$total_fields)
|
||||
$query .= ',';
|
||||
}
|
||||
|
||||
$query .= ") VALUES (";
|
||||
|
||||
$i = 0;
|
||||
//Adding Fields Values to query
|
||||
foreach($query_val as $qval)
|
||||
{
|
||||
$i++;
|
||||
$query .= "'$qval'";
|
||||
if($i<$total_fields)
|
||||
$query .= ',';
|
||||
}
|
||||
|
||||
//Finalzing Query
|
||||
$query .= ")";
|
||||
|
||||
$db->Execute($query);
|
||||
$insert_id = $db->insert_id();
|
||||
|
||||
return $insert_id;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Duplicate User Check
|
||||
function duplicate_user($name){
|
||||
$myquery = new myquery();
|
||||
global $myquery;
|
||||
if($myquery->check_user($name)){
|
||||
return true;
|
||||
return true;
|
||||
}else{
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -305,7 +548,7 @@ class signup {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//Validate Form Fields And Add Member
|
||||
|
||||
function SignUpUser(){
|
||||
|
|
|
@ -65,10 +65,12 @@
|
|||
$val = $array[$field['name']];
|
||||
$req = $field['required'];
|
||||
$invalid_err = $field['invalid_err'];
|
||||
$function_error_msg = $field['function_error_msg'];
|
||||
$length = strlen($val);
|
||||
$min_len = $field['min_length'];
|
||||
$min_len = $min_len ? $min_len : 0;
|
||||
$max_len = $field['max_length'] ;
|
||||
$rel_val = $array[$field['relative_to']];
|
||||
|
||||
if(empty($invalid_err))
|
||||
$invalid_err = sprintf("Invalid '%s'",$title);
|
||||
|
@ -82,6 +84,8 @@
|
|||
{
|
||||
e($invalid_err);
|
||||
$block = true;
|
||||
}else{
|
||||
$block = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -92,7 +96,9 @@
|
|||
//Checking Syntax
|
||||
if(!$funct_err)
|
||||
{
|
||||
if(!empty($invalid_err))
|
||||
if(!empty($function_error_msg))
|
||||
e($function_error_msg);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}elseif(!is_valid_syntax($field['syntax_type'],$val))
|
||||
{
|
||||
|
@ -104,6 +110,30 @@
|
|||
if($length > $max_len || $length < $min_len)
|
||||
e(sprintf(" please enter '%s' value between '%s' and '%s'",
|
||||
$title,$field['min_length'],$field['max_length']));
|
||||
}elseif(function_exists($field['db_value_check_func']))
|
||||
{
|
||||
$db_val_result = $field['db_value_check_func']($val);
|
||||
if($db_val_result != $field['db_value_exists'])
|
||||
if(!empty($field['db_value_err']))
|
||||
e($field['db_value_err']);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}elseif($field['relative_type']!='')
|
||||
{
|
||||
switch($field['relative_type'])
|
||||
{
|
||||
case 'exact':
|
||||
{
|
||||
if($rel_val != $val)
|
||||
{
|
||||
if(!empty($field['relative_err']))
|
||||
e($field['relative_err']);
|
||||
elseif(!empty($invalid_err))
|
||||
e($invalid_err);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
*******************************************************************
|
||||
*/
|
||||
|
||||
ob_start('ob_gzhandler');
|
||||
ob_start();
|
||||
|
||||
//Setting Cookie Timeout
|
||||
define('COOKIE_TIMEOUT',315360000); // 10 years
|
||||
|
@ -34,7 +34,6 @@ if (!is_dir($sessdir)) { mkdir($sessdir, 0777); }
|
|||
ini_set('session.save_path', $sessdir);*/
|
||||
|
||||
session_start();
|
||||
|
||||
// Check Installation Directory
|
||||
if(file_exists(dirname(__FILE__).'/../install/isinstall.php')){
|
||||
header('location:../install');
|
||||
|
@ -404,4 +403,6 @@ $Smarty->register_function('FlashPlayer','flashPlayer');
|
|||
|
||||
|
||||
$Smarty->register_modifier('get_thumb_num','get_thumb_num');
|
||||
|
||||
|
||||
?>
|
|
@ -1568,6 +1568,25 @@ function SetTime($sec, $padHours = true) {
|
|||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to add custom signup form fields
|
||||
* In this you will provide an array that has a complete
|
||||
* details of the field such as 'name',validate_func etc
|
||||
* please check docs.clip-bucket.com for "how to add custom signup field"
|
||||
*/
|
||||
function register_signup_field($array)
|
||||
{
|
||||
global $signup;
|
||||
$name = key($array);
|
||||
if(is_array($array) && !empty($array[$name]['name']))
|
||||
{
|
||||
foreach($array as $key => $arr)
|
||||
$signup->custom_signup_fields[$key] = $arr;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function used to get PHP Path
|
||||
*/
|
||||
|
@ -1906,5 +1925,73 @@ function SetTime($sec, $padHours = true) {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function used to validate username
|
||||
* @input USERNAME
|
||||
*/
|
||||
function username_check($username)
|
||||
{
|
||||
global $Cbucket;
|
||||
$banned_words = $Cbucket->configs['disallowed_usernames'];
|
||||
$banned_words = explode(',',$banned_words);
|
||||
foreach($banned_words as $word)
|
||||
{
|
||||
preg_match("/$word/Ui",$username,$match);
|
||||
if(!empty($match[0]))
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function used to check weather username already exists or not
|
||||
* @input USERNAME
|
||||
*/
|
||||
function user_exists($user)
|
||||
{
|
||||
global $signup;
|
||||
return $signup->duplicate_user($user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to check weather email already exists or not
|
||||
* @input email
|
||||
*/
|
||||
function email_exists($user)
|
||||
{
|
||||
global $signup;
|
||||
return $signup->duplicate_email($user);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Function used to check weather erro exists or not
|
||||
*/
|
||||
function error()
|
||||
{
|
||||
if(count(error_list())>0)
|
||||
{
|
||||
return error_list();
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to load plugin
|
||||
* please check docs.clip-bucket.com
|
||||
*/
|
||||
function load_plugin()
|
||||
{
|
||||
global $cbplugin;
|
||||
|
||||
}
|
||||
?>
|
|
@ -8,14 +8,19 @@ Simple Plugin System
|
|||
$plug_row = $myquery->Get_Plugin_Details();
|
||||
|
||||
if(!$AdminArea){
|
||||
|
||||
$pluginQueryNA = mysql_query("SELECT * FROM plugins WHERE plugin_active ='yes'");
|
||||
$total_plugins = mysql_num_rows($pluginQueryNA);
|
||||
while($pluginDataNa = mysql_fetch_array($pluginQueryNA)){
|
||||
|
||||
if(file_exists(BASEDIR.'/plugins/'.$pluginDataNa['plugin_file'])
|
||||
if($pluginDataNa['plugin_folder'])
|
||||
$folder = $pluginDataNa['plugin_folder'].'/';
|
||||
else
|
||||
$folder = '';
|
||||
if(file_exists(BASEDIR.'/plugins/'.$folder.$pluginDataNa['plugin_file'])
|
||||
&& !empty($pluginDataNa['plugin_file']))
|
||||
{
|
||||
include(BASEDIR.'/plugins/'.$pluginDataNa['plugin_file']);
|
||||
include(BASEDIR.'/plugins/'.$folder.$pluginDataNa['plugin_file']);
|
||||
$plugin_list[] = $pluginDataNa;
|
||||
}
|
||||
}
|
||||
|
@ -25,9 +30,15 @@ $total_plugins = mysql_num_rows($pluginQueryA);
|
|||
if($total_plugins > 0)
|
||||
{
|
||||
while($pluginDataA = mysql_fetch_array($pluginQueryA)){
|
||||
if(file_exists(BASEDIR.'/plugins/'.$pluginDataA['plugin_file'])
|
||||
|
||||
if($pluginDataA['plugin_folder'])
|
||||
$folder = $pluginDataA['plugin_folder'].'/';
|
||||
else
|
||||
$folder = '';
|
||||
|
||||
if(file_exists(BASEDIR.'/plugins/'.$folder.$pluginDataA['plugin_file'])
|
||||
&& !empty($pluginDataA['plugin_file']))
|
||||
include(BASEDIR.'/plugins/'.$pluginDataA['plugin_file']);
|
||||
include(BASEDIR.'/plugins/'.$folder.$pluginDataA['plugin_file']);
|
||||
//$plugin_list[] = $pluginDataA;
|
||||
$plugin_list[] = $pluginDataA;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,7 @@ function install_custom_fields()
|
|||
)
|
||||
VALUES (
|
||||
NULL , 'en', 'cust_field_err', 'Invalid \'%s\' field value'
|
||||
)";
|
||||
)");
|
||||
|
||||
}
|
||||
install_custom_fields();
|
|
@ -0,0 +1,14 @@
|
|||
<?php
|
||||
require_once('../includes/common.php');
|
||||
|
||||
/**
|
||||
* This file is used to install Embed Video Mod
|
||||
*/
|
||||
|
||||
function uninstall_embed_video_mode()
|
||||
{
|
||||
global $db;
|
||||
$db->Execute("ALTER TABLE `video` DROP `embed_code` ");
|
||||
}
|
||||
uninstall_embed_video_mode();
|
||||
?>
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
/*
|
||||
Plugin Name: JW Player Plugin
|
||||
Description: Adds Jw Player for Clipbucket
|
||||
Description: jw Player for Clipbucket
|
||||
Author: Arslan Hassan
|
||||
ClipBucket Version: 2
|
||||
Plugin Version: 1.0 - JW 4.5.230
|
9
upload/plugins/signup_captcha/captcha.php
Normal file
9
upload/plugins/signup_captcha/captcha.php
Normal file
|
@ -0,0 +1,9 @@
|
|||
<?php
|
||||
require '../../includes/common.php';
|
||||
require "captcha/class.img_validator.php";
|
||||
|
||||
$word = substr(md5(rand(100,999999)),6,6);
|
||||
|
||||
$img = new img_validator();
|
||||
$img->generates_image($word,true);
|
||||
?>
|
116
upload/plugins/signup_captcha/captcha/class.files.php
Normal file
116
upload/plugins/signup_captcha/captcha/class.files.php
Normal file
|
@ -0,0 +1,116 @@
|
|||
<?php
|
||||
class files
|
||||
{
|
||||
function get_file_list($directory, $type = "img_creation", $print_list = false)
|
||||
{
|
||||
// Checks the dir
|
||||
if(!is_dir($directory))
|
||||
{
|
||||
$this->_error("Invalid Directory: " . $diretorio, E_USER_ERROR);
|
||||
}
|
||||
|
||||
// File types regex
|
||||
Switch($type)
|
||||
{
|
||||
Case "img_creation":
|
||||
$types_regex = "jpeg|jpg|png";
|
||||
break;
|
||||
|
||||
Case "img":
|
||||
$types_regex = "gif|jpeg|jpg|png|bmp";
|
||||
break;
|
||||
|
||||
Case "pag":
|
||||
$types_regex = "txt|htm|html|php|asp|aspx";
|
||||
break;
|
||||
|
||||
Case "vid":
|
||||
$types_regex = "avi|swf|mpg|mpeg|wmv|asx|mov";
|
||||
break;
|
||||
|
||||
Case "doc":
|
||||
$types_regex = "txt|doc|rtf|xsl";
|
||||
break;
|
||||
|
||||
Default:
|
||||
$types_regex = false;
|
||||
}
|
||||
|
||||
// Open dir handle
|
||||
if(!$dir_handle = @opendir($directory))
|
||||
{
|
||||
$this->_error("I couldn't open the dir: " . $directory, E_USER_ERROR);
|
||||
}
|
||||
|
||||
// Initilization of the list array
|
||||
$file_list = array();
|
||||
|
||||
// Starts dir navigation
|
||||
while (false !== ($file = @readdir($dir_handle)))
|
||||
{
|
||||
if ($file == "." || $file == "..")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
// The list will be generate with specific types, according to the regex
|
||||
if($types_regex)
|
||||
{
|
||||
if(eregi( "\.(" . $types_regex . ")$", $file))
|
||||
{
|
||||
$file_list[] = $file;
|
||||
}
|
||||
}
|
||||
|
||||
// The list will be generate with all dir's files
|
||||
else
|
||||
{
|
||||
// Add only files to the list
|
||||
if(is_file($directory . $file))
|
||||
{
|
||||
$file_list[] = $file;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Close dir handle
|
||||
@closedir($dir_handle);
|
||||
|
||||
// Has no files in the dir
|
||||
if(!sizeof($file_list))
|
||||
{
|
||||
$this->_error("The directory: " . $directory . " is empty!", E_USER_NOTICE);
|
||||
}
|
||||
|
||||
// If debugging...
|
||||
if($print_list)
|
||||
{
|
||||
echo "<pre>";
|
||||
print_r($file_list);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
// Returns file list
|
||||
return $file_list;
|
||||
}
|
||||
|
||||
function _error($mensagem, $tipo)
|
||||
{
|
||||
if($tipo == E_USER_ERROR)
|
||||
{
|
||||
$topo = "Error!";
|
||||
}
|
||||
else
|
||||
{
|
||||
$topo = "Notification";
|
||||
}
|
||||
|
||||
echo "<span style=\"background-color: #FFD7D7\"><font face=verdana size=2><font color=red><b>" . $topo . "</b></font>: " . $mensagem . "</font></span><br><br>";
|
||||
|
||||
if($tipo == E_USER_ERROR)
|
||||
{
|
||||
exit;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
326
upload/plugins/signup_captcha/captcha/class.img_validator.php
Normal file
326
upload/plugins/signup_captcha/captcha/class.img_validator.php
Normal file
|
@ -0,0 +1,326 @@
|
|||
<?php
|
||||
|
||||
if(!class_exists("files"))
|
||||
{
|
||||
require_once "class.files.php";
|
||||
}
|
||||
|
||||
class img_validator extends files
|
||||
{
|
||||
/**
|
||||
* Fonts folder
|
||||
* @var string $folder
|
||||
*/
|
||||
var $folder;
|
||||
/**
|
||||
* Background images folder
|
||||
* @var string $img_folder
|
||||
*/
|
||||
var $img_folder;
|
||||
/**
|
||||
* Letters limit for the given words
|
||||
* @var integer $letters_limit
|
||||
*/
|
||||
var $letters_limit = 15;
|
||||
/**
|
||||
* The generated image will be JPEG or PNG?
|
||||
* @var string $image_type
|
||||
*/
|
||||
var $image_type = "jpeg";
|
||||
|
||||
/**
|
||||
* Colors themes for the GD generated images. They must be in RGB.
|
||||
* The array must start at index 1
|
||||
*
|
||||
* 0 => background image color
|
||||
* 1 => background image border
|
||||
* 2 => text color
|
||||
* @var array $themes
|
||||
*/
|
||||
var $themes = array (
|
||||
1 => array(array(205, 255, 204), array(205, 255, 204), array(0, 0, 0)),
|
||||
2 => array(array(255, 255, 203), array(255, 255, 203), array(0, 0, 0)),
|
||||
3 => array(array(102, 203, 255), array(102, 203, 255), array(0, 0, 0)),
|
||||
4 => array(array(0, 0, 0), array(82, 82, 82), array(255, 255, 255)),
|
||||
5 => array(array(153, 1, 0), array(0, 0, 0), array(255, 255, 255)),
|
||||
);
|
||||
/**
|
||||
* Colors themes for the done BG images
|
||||
*
|
||||
* 0 => background image name
|
||||
* 1 => Red, 2 => Green, 3 => Blue
|
||||
* @var array $themes
|
||||
*/
|
||||
var $themes_bg_images = array (
|
||||
1 => array("bg1.jpg", 0, 0, 0),
|
||||
2 => array("bg2.jpg", 0, 0, 0),
|
||||
3 => array("bg3.jpg", 0, 0, 0),
|
||||
4 => array("bg4.jpg", 0, 0, 0),
|
||||
|
||||
);
|
||||
/**
|
||||
* Fonts data
|
||||
* 0 => font file,
|
||||
* 1 => initial X position for a letter in size 14 texts
|
||||
* 2 => initial X position for a letter in size 40 texts
|
||||
* 3 => value to reduce of X each new letter in size 14 texts
|
||||
* 4 => value to reduce of X each new letter in size 40 texts
|
||||
*
|
||||
* -> P.S.: The indexes 1, 2, 3 and 4 are used only when the text will be centralized
|
||||
*/
|
||||
var $fonts = array (
|
||||
/* With this font, all letters are uppercase and the characters limit decrease
|
||||
array("acmesab.ttf", 84, 62, 7.0, 18.0),*/
|
||||
array("arial.ttf" , 85, 70, 5.1, 11.6),
|
||||
array("verdana.ttf", 82, 67, 5.6, 12.9),
|
||||
array("comicbd.ttf", 83, 68, 5.1, 11.5),
|
||||
array("impact.ttf" , 80, 55, 5.7, 12.9)
|
||||
);
|
||||
/**
|
||||
* Image Width
|
||||
* @var integer $_width
|
||||
*/
|
||||
var $_width = 180;
|
||||
/**
|
||||
* Image Height
|
||||
* @var integer $_height
|
||||
*/
|
||||
var $_height = 50;
|
||||
|
||||
/**
|
||||
* Checks if the system has GD support
|
||||
*
|
||||
*/
|
||||
function img_validator($folder = false, $img_folder = false)
|
||||
{
|
||||
// If doesn't given, uses the default fonts folder
|
||||
if(!$folder)
|
||||
{
|
||||
$folder = "./img/fonts/";
|
||||
}
|
||||
|
||||
// If doesn't given, uses the default background images folder
|
||||
if(!$img_folder)
|
||||
{
|
||||
$img_folder = "./img/";
|
||||
}
|
||||
|
||||
// Sets the background images and fonts dir
|
||||
$this->folder = $folder;
|
||||
$this->img_folder = $img_folder;
|
||||
|
||||
// Checks if the system has GD loaded on PHP
|
||||
if(!function_exists("ImageCreateTrueColor")) // gd 2.*
|
||||
{
|
||||
if(!function_exists("ImageCreate")) // gd 1.*
|
||||
{
|
||||
$this->_error("You can't run this script because your PHP doesn't have GD library (1.* or 2.*) loaded.", E_USER_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Encrypts a word to record the data
|
||||
*
|
||||
* @param string $word
|
||||
*/
|
||||
function encrypts_word($word)
|
||||
{
|
||||
return substr(md5($word), 1, 10);
|
||||
}
|
||||
|
||||
/**
|
||||
* Record a word in SESSION
|
||||
*
|
||||
* @param string $word
|
||||
*/
|
||||
function records_word($word)
|
||||
{
|
||||
session_register('word_validator');
|
||||
$_SESSION["word_validator"] = base64_encode($this->encrypts_word($word));
|
||||
if(empty($_SESSION['word_validator'])){
|
||||
setcookie('word_validator', base64_encode($this->encrypts_word($word)));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks the recorded word with the given on
|
||||
*
|
||||
* @param string $wordc
|
||||
*/
|
||||
function checks_word($word)
|
||||
{
|
||||
if(isset($_SESSION["word_validator"])){
|
||||
$recorded = base64_decode($_SESSION["word_validator"]);
|
||||
}else{
|
||||
$recorded = base64_decode($_COOKIE["word_validator"]);
|
||||
}
|
||||
$given = $this->encrypts_word($word);
|
||||
if(ereg($given, $recorded))
|
||||
{
|
||||
$msg = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$msg = false;
|
||||
}
|
||||
return $msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a random text, whether a word isn't give or
|
||||
* the given word is more than the letters limit
|
||||
*
|
||||
*/
|
||||
function generates_text()
|
||||
{
|
||||
$temp = md5(uniqid(microtime()));
|
||||
$temp = hexdec($temp);
|
||||
$word = substr($temp, 2, 3) . "-" . substr($temp, 6, 3);
|
||||
|
||||
return $word;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates the validation imagem with a given word.
|
||||
* If the word isn't provide generate a random word.
|
||||
*
|
||||
* @param string $word
|
||||
* @param boolean $use_done_images
|
||||
* @param string $align
|
||||
*/
|
||||
function generates_image($word = false, $use_done_images = false, $align = "center")
|
||||
{
|
||||
/**
|
||||
* Didn't give a word, generates a random text
|
||||
*/
|
||||
if(!$word)
|
||||
{
|
||||
$word = $this->generates_text();
|
||||
}
|
||||
else
|
||||
{
|
||||
$word_size = strlen($word);
|
||||
|
||||
if($word_size > $this->letters_limit)
|
||||
{
|
||||
$word = $this->generates_text();
|
||||
}
|
||||
}
|
||||
|
||||
$this->records_word($word);
|
||||
$word_size = strlen($word);
|
||||
|
||||
srand((double) microtime() * 1000000);
|
||||
|
||||
/**
|
||||
* Chooses a random font
|
||||
*/
|
||||
$fnt = rand(0, count($this->fonts)-1);
|
||||
$font = $this->folder . $this->fonts[$fnt][0];
|
||||
|
||||
/**
|
||||
* Sets the X values according to the chosen alignment
|
||||
*/
|
||||
if($align == "center")
|
||||
{
|
||||
/**
|
||||
* X position value for only 1 letter of the size 14 text
|
||||
*/
|
||||
$x_small = $this->fonts[$fnt][1];
|
||||
$d_small = $this->fonts[$fnt][3];
|
||||
/**
|
||||
* X position value for only 1 letter of the size 40 text
|
||||
*/
|
||||
$x_big = $this->fonts[$fnt][2];
|
||||
$d_big = $this->fonts[$fnt][4];
|
||||
|
||||
/**
|
||||
* For each letter of the given word, decreases $d_small of the size 14 text's X position
|
||||
* and decreases $d_big of the size 40 text's X position.
|
||||
* Remember: if you change the size of the background image, the font and the text's size
|
||||
* you must manually recalculate those numbers ($d_small and $d_big),
|
||||
* so the text will be always right centered
|
||||
*/
|
||||
for($i = 1; $i < $word_size; $x_small -= $d_small, $i++);
|
||||
for($i = 1; $i < $word_size; $x_big -= $d_big, $i++);
|
||||
}
|
||||
/**
|
||||
* Left
|
||||
*/
|
||||
else
|
||||
{
|
||||
$x_small = 2;
|
||||
$x_big = 2;
|
||||
}
|
||||
|
||||
srand((double) microtime() * 1000000);
|
||||
|
||||
/**
|
||||
* The background is already done, so, create the image handle from done BG
|
||||
*/
|
||||
if($use_done_images)
|
||||
{
|
||||
// Chooses randomly a theme
|
||||
$theme = rand(1, count($this->themes_bg_images));
|
||||
// Start image handle from file
|
||||
$background_image = ImageCreateFromJPEG($this->img_folder . $this->themes_bg_images[$theme][0]);
|
||||
// Text's colors
|
||||
$R = $this->themes_bg_images[$theme][1];
|
||||
$G = $this->themes_bg_images[$theme][2];
|
||||
$B = $this->themes_bg_images[$theme][3];
|
||||
}
|
||||
/**
|
||||
* GD Creates the background rectangle
|
||||
*/
|
||||
else
|
||||
{
|
||||
// Chooses randomly a theme
|
||||
$theme = rand(1, count($this->themes));
|
||||
// Start image handle
|
||||
$background_image = imagecreatetruecolor($this->_width, $this->_height);
|
||||
// Alocates the rectangle's colors
|
||||
$fill = ImageColorAllocate($background_image, $this->themes[$theme][0][0], $this->themes[$theme][0][1], $this->themes[$theme][0][2]);
|
||||
$border = ImageColorAllocate($background_image, $this->themes[$theme][1][0], $this->themes[$theme][1][1], $this->themes[$theme][1][2]);
|
||||
// Creates the rectangle
|
||||
ImageFilledRectangle($background_image, 2, 2, 177, 47, $fill);
|
||||
ImageRectangle($background_image, 0, 0, 179, 49, $border);
|
||||
// Text's colors
|
||||
$R = $this->themes[$theme][2][0];
|
||||
$G = $this->themes[$theme][2][1];
|
||||
$B = $this->themes[$theme][2][2];
|
||||
}
|
||||
|
||||
/**
|
||||
* Allocate the texts' colors
|
||||
*/
|
||||
$transp_color = imagecolorallocatealpha($background_image, $R, $G, $B, 100);
|
||||
$color = imagecolorallocate($background_image, $R, $G, $B);
|
||||
|
||||
/**
|
||||
* Writes the word with transparency in the background
|
||||
*/
|
||||
imagettftext($background_image, 40, 0, $x_big, 45, $transp_color, $font, $word);
|
||||
/**
|
||||
* Writes the main word
|
||||
*/
|
||||
imagettftext($background_image, 14, 0, $x_small, 30, $color, $font, $word);
|
||||
|
||||
/**
|
||||
* Prints header and the image
|
||||
*/
|
||||
if($this->image_type == "jpeg")
|
||||
{
|
||||
header("Content-type: image/jpeg");
|
||||
imagejpeg($background_image, false, 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
header("Content-type: image/png");
|
||||
imagepng($background_image);
|
||||
}
|
||||
|
||||
imagedestroy($background_image);
|
||||
}
|
||||
}
|
||||
?>
|
3
upload/plugins/signup_captcha/captcha/index.php
Normal file
3
upload/plugins/signup_captcha/captcha/index.php
Normal file
|
@ -0,0 +1,3 @@
|
|||
<?php
|
||||
header("Location: ../");
|
||||
?>
|
BIN
upload/plugins/signup_captcha/img/bg1.jpg
Normal file
BIN
upload/plugins/signup_captcha/img/bg1.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.7 KiB |
BIN
upload/plugins/signup_captcha/img/bg2.jpg
Normal file
BIN
upload/plugins/signup_captcha/img/bg2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.5 KiB |
BIN
upload/plugins/signup_captcha/img/bg3.jpg
Normal file
BIN
upload/plugins/signup_captcha/img/bg3.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.3 KiB |
BIN
upload/plugins/signup_captcha/img/bg4.jpg
Normal file
BIN
upload/plugins/signup_captcha/img/bg4.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
BIN
upload/plugins/signup_captcha/img/fonts/arial.ttf
Normal file
BIN
upload/plugins/signup_captcha/img/fonts/arial.ttf
Normal file
Binary file not shown.
BIN
upload/plugins/signup_captcha/img/fonts/comicbd.ttf
Normal file
BIN
upload/plugins/signup_captcha/img/fonts/comicbd.ttf
Normal file
Binary file not shown.
BIN
upload/plugins/signup_captcha/img/fonts/impact.ttf
Normal file
BIN
upload/plugins/signup_captcha/img/fonts/impact.ttf
Normal file
Binary file not shown.
BIN
upload/plugins/signup_captcha/img/fonts/monofont.ttf
Normal file
BIN
upload/plugins/signup_captcha/img/fonts/monofont.ttf
Normal file
Binary file not shown.
BIN
upload/plugins/signup_captcha/img/fonts/verdana.ttf
Normal file
BIN
upload/plugins/signup_captcha/img/fonts/verdana.ttf
Normal file
Binary file not shown.
48
upload/plugins/signup_captcha/signup_captcha.php
Normal file
48
upload/plugins/signup_captcha/signup_captcha.php
Normal file
|
@ -0,0 +1,48 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
Plugin Name: Signup Captcha
|
||||
Description: Security Captcha for signup form
|
||||
Author: Arslan Hassan
|
||||
Author Website: http://clip-bucket.com/
|
||||
ClipBucket Version: 2
|
||||
Version: 1.0
|
||||
Website: http://clip-bucket.com/
|
||||
Plugin Type: global
|
||||
*/
|
||||
|
||||
|
||||
|
||||
if(!function_exists("signup_captcha"))
|
||||
{
|
||||
require "captcha/class.img_validator.php";
|
||||
|
||||
function signup_captcha()
|
||||
{
|
||||
return '<img src="'.PLUG_URL.'/signup_captcha/captcha.php" border=1 name="captcha" id="captcha"/><br />
|
||||
<a href="javascript:void(0)" onclick="javascript:reloadImage(\''.PLUG_URL.'/signup_captcha/captcha.php\');"> Refresh</a>';
|
||||
}
|
||||
|
||||
$signup_captcha['signup_captcha'] =
|
||||
array(
|
||||
'title'=> 'Varification Code',
|
||||
'type'=> "textfield",
|
||||
'name'=> "vcode",
|
||||
'id'=> "vcode",
|
||||
'required'=>'yes',
|
||||
'validate_function'=>'signup_captcha_check',
|
||||
'anchor_after'=>'signup_captcha',
|
||||
'invalid_err'=>$LANG['usr_ccode_err']
|
||||
);
|
||||
|
||||
|
||||
function signup_captcha_check($val)
|
||||
{
|
||||
$img = new img_validator();
|
||||
return $img->checks_word($val);
|
||||
}
|
||||
|
||||
register_anchor(signup_captcha(),signup_captcha);
|
||||
register_signup_field($signup_captcha);
|
||||
}
|
||||
?>
|
|
@ -17,17 +17,8 @@ if($userquery->login_check('',true)){
|
|||
if(!$signup->Registration()){
|
||||
$msg = $LANG['usr_reg_err'];
|
||||
}else{
|
||||
if($row['captcha_type']==2){
|
||||
Assign('captcha',BASEURL.'/includes/classes/captcha/img.php');
|
||||
}elseif($row['captcha_type']==1){
|
||||
Assign('captcha',BASEURL.'/includes/classes/captcha_simple.img.php');
|
||||
}
|
||||
|
||||
if(isset($_POST['signup'])){
|
||||
$msg = $signup->SignUpUser();
|
||||
if($msg=='success'){
|
||||
redirect_to(BASEURL.signup_success);
|
||||
}
|
||||
$signup->signup_user($_POST);
|
||||
}
|
||||
}
|
||||
subtitle('signup');
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
{assign var='required_fields' value=$signup->load_signup_fields()}
|
||||
{assign var='custom_field' value=$signup->custom_signup_fields}
|
||||
|
||||
<table width="940" border="0" align="center" cellpadding="0" cellspacing="0">
|
||||
<tr>
|
||||
|
@ -62,22 +63,19 @@
|
|||
{foreach from=$required_fields item=field}
|
||||
<tr>
|
||||
<td width="33%" align="right" valign="top" class="header3">{$field.title}* :</td>
|
||||
<td width="67%">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_before}<br />
|
||||
<td width="67%">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_after}<br />
|
||||
{$field.hint_2}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
{if $captcha_type != 0 }
|
||||
|
||||
{foreach from=$custom_field item=field}
|
||||
<tr>
|
||||
<td align="right" valign="top" class="header3">{$LANG.verification}: </td>
|
||||
<td class="tips"><input name="verification" type="text" id="verification" size="30" />
|
||||
<br />
|
||||
{$LANG.user_enter_text_as_img}<br /></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="right" valign="top" class="header3"> </td>
|
||||
<td class="tips"><img src="{$captcha}" border=1 name="captcha" id="captcha"><br />
|
||||
<a href="javascript:void(0)" onclick="javascript:reloadImage('{$captcha}');"> {$LANG.user_refresh_img}</a></td>{/if}
|
||||
<td width="33%" align="right" valign="top" class="header3">{$field.title}* :</td>
|
||||
<td width="67%">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_after}<br />
|
||||
{$field.hint_2}</td>
|
||||
</tr>
|
||||
{/foreach}
|
||||
|
||||
<tr>
|
||||
<td colspan="2" align="center" valign="top" class="header3"><input name="agree" type="checkbox" id="agree" value="yes" checked="checked" />
|
||||
- {$LANG.user_i_agree_to_the} <a href="{$termsofuse_link}" target="_blank" style="text-decoration:underline">{$LANG.tos_title}</a> and <a href="{$privacy_link}" target="_blank" style="text-decoration:underline">{$LANG.privacy_policy}</a>
|
||||
|
|
Loading…
Add table
Reference in a new issue