diff --git a/upload/.htaccess b/upload/.htaccess new file mode 100644 index 00000000..c8abead3 --- /dev/null +++ b/upload/.htaccess @@ -0,0 +1,112 @@ +# +# secfilterengine off +# secfilterscanPOST off +# + +Options All -Indexes +FileETag MTime Size +Options +FollowSymlinks +RewriteEngine on + + +order allow,deny +satisfy all + + +########## 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 '; + + if( !isset( $open_flash_chart_seqno ) ) + { + $open_flash_chart_seqno = 1; + $out[] = ''; + } + 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[] = '
'; + $out[] = ''; + $out[] = ''; + } + + return implode("\n",$out); +} +?> \ No newline at end of file diff --git a/upload/admin_area/charts/ofc-library/open-flash-chart.php b/upload/admin_area/charts/ofc-library/open-flash-chart.php new file mode 100644 index 00000000..2a90eaff --- /dev/null +++ b/upload/admin_area/charts/ofc-library/open-flash-chart.php @@ -0,0 +1,178 @@ +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! +// \ No newline at end of file diff --git a/upload/admin_area/charts/users_activity.php b/upload/admin_area/charts/users_activity.php new file mode 100644 index 00000000..43869ac6 --- /dev/null +++ b/upload/admin_area/charts/users_activity.php @@ -0,0 +1,108 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/charts/videos_activity.php b/upload/admin_area/charts/videos_activity.php new file mode 100644 index 00000000..58c4881d --- /dev/null +++ b/upload/admin_area/charts/videos_activity.php @@ -0,0 +1,108 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/collection_category.php b/upload/admin_area/collection_category.php new file mode 100644 index 00000000..f3c8a4d9 --- /dev/null +++ b/upload/admin_area/collection_category.php @@ -0,0 +1,79 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/collection_manager.php b/upload/admin_area/collection_manager.php new file mode 100644 index 00000000..bdd21e7d --- /dev/null +++ b/upload/admin_area/collection_manager.php @@ -0,0 +1,154 @@ +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 Featured","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 Unfeatured","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 Unfeatured","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(); +?> \ No newline at end of file diff --git a/upload/admin_area/comments.php b/upload/admin_area/comments.php new file mode 100644 index 00000000..e64fa695 --- /dev/null +++ b/upload/admin_area/comments.php @@ -0,0 +1,71 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/conversion_lab.php b/upload/admin_area/conversion_lab.php new file mode 100644 index 00000000..ecba6392 --- /dev/null +++ b/upload/admin_area/conversion_lab.php @@ -0,0 +1,25 @@ +$vidFile,'name'=>getName($vidFile).'.'.getExt($vidFile)); +} + +assign('vdoFiles',$vdoFiles); + + +subtitle("Conversion lab for ClipBucket conversion testing"); +template_files("conversion_lab.html"); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/edit_announcement.php b/upload/admin_area/edit_announcement.php new file mode 100644 index 00000000..9ba9cd56 --- /dev/null +++ b/upload/admin_area/edit_announcement.php @@ -0,0 +1,22 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/edit_collection.php b/upload/admin_area/edit_collection.php new file mode 100644 index 00000000..945ab6ff --- /dev/null +++ b/upload/admin_area/edit_collection.php @@ -0,0 +1,58 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/edit_group.php b/upload/admin_area/edit_group.php new file mode 100644 index 00000000..75dc3cdd --- /dev/null +++ b/upload/admin_area/edit_group.php @@ -0,0 +1,35 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/edit_member.php b/upload/admin_area/edit_member.php new file mode 100644 index 00000000..89ec27fb --- /dev/null +++ b/upload/admin_area/edit_member.php @@ -0,0 +1,14 @@ +admin_login_check(); +header('location:view_user.php?uid='.$_GET['uid']); + +?> \ No newline at end of file diff --git a/upload/admin_area/edit_photo.php b/upload/admin_area/edit_photo.php new file mode 100644 index 00000000..0dadf381 --- /dev/null +++ b/upload/admin_area/edit_photo.php @@ -0,0 +1,42 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/edit_video.php b/upload/admin_area/edit_video.php new file mode 100644 index 00000000..37e598f7 --- /dev/null +++ b/upload/admin_area/edit_video.php @@ -0,0 +1,60 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/editor_pick.php b/upload/admin_area/editor_pick.php new file mode 100644 index 00000000..32fb82d9 --- /dev/null +++ b/upload/admin_area/editor_pick.php @@ -0,0 +1,55 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/email_settings.php b/upload/admin_area/email_settings.php new file mode 100644 index 00000000..477fa4d7 --- /dev/null +++ b/upload/admin_area/email_settings.php @@ -0,0 +1,59 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/flagged_collections.php b/upload/admin_area/flagged_collections.php new file mode 100644 index 00000000..cea2f09d --- /dev/null +++ b/upload/admin_area/flagged_collections.php @@ -0,0 +1,90 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/flagged_groups.php b/upload/admin_area/flagged_groups.php new file mode 100644 index 00000000..7077998b --- /dev/null +++ b/upload/admin_area/flagged_groups.php @@ -0,0 +1,118 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/flagged_photos.php b/upload/admin_area/flagged_photos.php new file mode 100644 index 00000000..65c62103 --- /dev/null +++ b/upload/admin_area/flagged_photos.php @@ -0,0 +1,91 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/flagged_users.php b/upload/admin_area/flagged_users.php new file mode 100644 index 00000000..ebe55b83 --- /dev/null +++ b/upload/admin_area/flagged_users.php @@ -0,0 +1,117 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/flagged_videos.php b/upload/admin_area/flagged_videos.php new file mode 100644 index 00000000..99fa3775 --- /dev/null +++ b/upload/admin_area/flagged_videos.php @@ -0,0 +1,117 @@ +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(); +?> \ No newline at end of file diff --git a/upload/admin_area/group_category.php b/upload/admin_area/group_category.php new file mode 100644 index 00000000..24542bd4 --- /dev/null +++ b/upload/admin_area/group_category.php @@ -0,0 +1,63 @@ +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(); + +?> \ No newline at end of file diff --git a/upload/admin_area/groups_manager.php b/upload/admin_area/groups_manager.php new file mode 100644 index 00000000..f8195737 --- /dev/null +++ b/upload/admin_area/groups_manager.php @@ -0,0 +1,147 @@ +admin_login_check(); +$pages->page_redir(); +$userquery->perm_check('group_moderation',true); + + // Deactivate Group + if(isset($_GET['deactivate'])) { + $cbgroup->grp_actions('deactivate',mysql_clean($_GET['deactivate'])); + } + + // Activate Group + if(isset($_GET['activate'])) { + $cbgroup->grp_actions('activate',mysql_clean($_GET['activate'])); + } + + // Feature Group + if(isset($_GET['feature'])) { + $cbgroup->grp_actions('feature',mysql_clean($_GET['feature'])); + } + + // unFeature Group + if(isset($_GET['unfeature'])) { + $cbgroup->grp_actions('unfeature',mysql_clean($_GET['unfeature'])); + } + + //Multiple Activate + if(isset($_POST['activate_selected'])) { + for($i=0; $igrp_actions('activate',$_POST['check_group'][$i],true); + } + $eh->flush(); + e(lang('Selected Groups are activated.'),'m'); + } + + //Multiple Deactivate + if(isset($_POST['deactivate_selected'])) { + for($i=0; $igrp_actions('decativate',$_POST['check_group'][$i],true); + } + $eh->flush(); + e(lang('Selected Groups are deactivated.'),'m'); + } + + //Multiple Feature + if(isset($_POST['make_featured_selected'])) { + for($i=0; $igrp_actions('feature',$_POST['check_group'][$i],true); + } + $eh->flush(); + e(lang('Selected Groups have been set as featured.'),'m'); + } + + //Multiple UnFeature + if(isset($_POST['make_unfeatured_selected'])) { + for($i=0; $igrp_actions('feature',$_POST['check_group'][$i],true); + } + $eh->flush(); + e(lang('Selected Groups have been set as Unfeatured.'),'m'); + } + + // Delete group + if(isset($_GET['delete_group'])) { + $cbgroup->grp_actions("delete",mysql_clean($_GET['delete_group'])); + } + + //Multiple Delete + if(isset($_POST['delete_selected'])) { + for($i=0; $igrp_actions("delete",$_POST['check_group'][$i],true); + } + $eh->flush(); + e(lang('Selected Groups are Deleted.'),'m'); + } + + + //Calling Group Manager Functions + call_functions($cbgroup->group_manager_funcs); + + $page = mysql_clean($_GET['page']); + $get_limit = create_query_limit($page,RESULTS); + + if(isset($_GET['search'])) + { + + $array = array + ( + 'group_id' => $_GET['group_id'], + 'user' => $_GET['userid'], + 'title' => $_GET['title'], + 'tags' => $_GET['tags'], + 'category' => $_GET['category'], + 'featured' => $_GET['featured'], + 'active' => $_GET['active'] + ); + } + + $result_array = $array; + //Getting Video List + $result_array['limit'] = $get_limit; + if(!$array['order']) + $result_array['order'] = " date_added DESC "; + $groups = $cbgroup->get_groups($result_array); + + Assign('groups', $groups); + + //Collecting Data for Pagination + $gcount = $array; + $gcount['count_only'] = true; + $total_rows = $cbgroup->get_groups($gcount); + $total_pages = count_pages($total_rows,RESULTS); + $pages->paginate($total_pages,$page); + + + //Category Array + if(is_array($_GET['category'])) + $cats_array = array($_GET['category']); + else + { + preg_match_all('/#([0-9]+)#/',$_GET['category'],$m); + $cats_array = array($m[1]); + } + $cat_array = array(lang('vdo_cat'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cats_array), + 'hint_1'=> lang('vdo_cat_msg'), + 'display_function' => 'convert_to_categories', + 'category_type'=>'groups'); + assign('cat_array',$cat_array); + + +subtitle("Group Manager"); +template_files('groups_manager.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/index.php b/upload/admin_area/index.php new file mode 100644 index 00000000..8489265a --- /dev/null +++ b/upload/admin_area/index.php @@ -0,0 +1,22 @@ +admin_login_check(); + + +// $latest = get_latest_cb_info(); + $Cbucket->cbinfo['latest'] = $latest; + if($Cbucket->cbinfo['version'] < $Cbucket->cbinfo['latest']['version']) + $Cbucket->cbinfo['new_available'] = true; + + +template_files('index.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/lab_resources/echo.php b/upload/admin_area/lab_resources/echo.php new file mode 100644 index 00000000..70051698 --- /dev/null +++ b/upload/admin_area/lab_resources/echo.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/admin_area/lab_resources/experiments.php b/upload/admin_area/lab_resources/experiments.php new file mode 100644 index 00000000..11f90308 --- /dev/null +++ b/upload/admin_area/lab_resources/experiments.php @@ -0,0 +1,225 @@ +admin_login_check(); + +if(isset($_POST['experiment'])) +{ + $mode = $_POST['mode']; + $victim = $_POST['victim']; + + switch($mode) + { + default: + echo json_encode(array("err"=>"DUDE!!Why The Hell You Are Playing With The Code :/")); + break; + + case "getPreDetails": + { + $err = array(); + $msg = array(); + + if(!function_exists("exec")) + { + $err[] = "
C'mon man! there shuld be some 'exec' functions :("; + $err[] = "
Exec function does not exist
"; + theEnd(); + }else + $msg[] = "
Exec function exists
"; + + //testing php compatiblity + $phpTest = shell_output(php_path()." -q ".ADMINBASEDIR.'/lab_resources/echo.php'); + if(!$phpTest) + { + $err[] = "
OMG! Your host is so chipless that it doesn't even allow you to use PHP CLI , very bad!"; + $err[] = "
PHP CLI is not enabled
"; + theEnd(); + }else + $msg[] = "
PHP CLI is enabled
"; + + //now get ffmpeg details + $ffmpegDetails = shell_output($Cbucket->configs['ffmpegpath']." -version "); + + if(!$ffmpegDetails) + { + $err[] = '
How can human work without brain? same situation is with video conversion, no ffmpeg, no conversion.'; + $err[] = "
FFMPEG does not exist
"; + theEnd(); + }else{ + + $msg[] = "
".nl2br($ffmpegDetails); + $msg[] = "
FFMPEG Exists
"; + } + + $flvtool2Details = shell_output($Cbucket->configs['flvtool2path']." -version "); + + if(!$flvtool2Details) + { + $err[] = '
Ah, no flvtool2 :O, its like a "Salt" for video files..food without salt is tasteless, + so video is streamless without flvtool2'; + $err[] = "
flvtool2 does not exist
"; + theEnd(); + }else{ + + $msg[] = "
".nl2br($flvtool2Details); + $msg[] = "
Flvtool2 Exists
"; + } + + $victimFile = $testVidsDir.'/'.$victim; + //getting video details.. + $ffmpegObj = new ffmpeg($victimFile); + $vidDetails = $ffmpegObj->get_file_info(); + if(!$vidDetails) + { + + $err[] = "
".nl2br(shell_output($Cbucket->configs['ffmpegpath'].' -i '.$victimFile)); + if(!file_exists($victimFile) && $victim) + $err[] = "
File does not exist
"; + else + $err[] = "
What the...post the above ffmpeg log and let scientist do their job
"; + theEnd(); + }else + { + $msg[] = "
".nl2br(shell_output($Cbucket->configs['ffmpegpath'].' -i '.$victimFile)); + $msg[] = "
Video file is convertable..
"; + } + + + theEnd('convertVideo1'); + } + break; + + case "convertVideo1": + { + + + $victimFile = $testVidsDir.'/'.$victim; + $victimOutput = $testVidsDir.'/output.flv'; + $victimOutputHQ = $testVidsDir.'/output.mp4'; + + if(file_exists($victimOutput)) + unlink($victimOutput); + if(file_exists($testVidsDir.'/output.log')) + unlink($testVidsDir.'/output.log'); + + + $res169 = array(); + $res169['240'] = array('427','240'); + $res169['360'] = array('640','360'); + $res169['480'] = array('853','480'); + $res169['720'] = array('1280','1280'); + $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','1280'); + $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, + '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' + ); + + + + $ffmpeg = new ffmpeg($victimFile); + $ffmpeg->configs = $configs; + $ffmpeg->gen_thumbs = false; + $ffmpeg->gen_big_thumb = false; + $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 = $victimOutput; + $ffmpeg->hq_output_file = $victimOutputHQ; + $ffmpeg->log_file = $testVidsDir.'/output.log'; + //$ffmpeg->remove_input = TRUE; + $ffmpeg->keep_original = config('keep_original'); + $ffmpeg->original_output_path = ORIGINAL_DIR.'/'.$tmp_file.'.'.$ext; + $ffmpeg->set_conv_lock = false; + $ffmpeg->showpre=true; + $ffmpeg->ClipBucket(); + + + $ffmpegpath = $Cbucket->configs['ffmpegpath']; + $ffmpegCommand = $ffmpeg->raw_command; + $msg[] = "FFMPEG Command So far
"; + //Lets start conversing videos + $converDetails = shell_output($ffmpegCommand); + $msg[] = "
".nl2br($ffmpeg->log); + + $victimDetails = $ffmpeg->input_details; + $vidDetails = $ffmpeg->output_details; + if(!$vidDetails) + { + + if($victimDetails['audio_codec']=='aac' || $victimDetails['audio_codec']=='ac3') + $err[] = "
A possible reason is beacuse videos with + AAC Audio does not encode without 'libfaac', set audio codec as libfaac and then try again
"; + if(!file_exists($victimFile) && $victim) + $err[] = "
No output file...your ffmpeg is not compatible
"; + else + $err[] = "
No output file...hmm post the log to dev team
"; + if(@filesize($victimOutput)>0 && file_exists($victimFile)) + $err[] = "
".nl2br(shell_output($Cbucket->configs['ffmpegpath'].' -i '.$victimOutput)); + theEnd(); + }else + { + $msg[] = "
".nl2br(shell_output($Cbucket->configs['ffmpegpath'].' -i '.$victimOutput)); + $msg[] = "
Video file is converted =D..
"; + } + + theEnd(); + } + } +} + + + +function theEnd($status=false) +{ + global $msg, $err; + if($err) + $errors = implode('',$err); + if($msg) + $messgs = implode('',$msg); + + echo json_encode(array('err'=>$errors,'msg'=>$messgs,'status'=>$status)); + exit(); +} +?> \ No newline at end of file diff --git a/upload/admin_area/language_settings.php b/upload/admin_area/language_settings.php new file mode 100644 index 00000000..c919fa9d --- /dev/null +++ b/upload/admin_area/language_settings.php @@ -0,0 +1,121 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); +$pages->page_redir(); + +//Making Language Default +if(isset($_POST['make_default'])) +{ + $id = mysql_clean($_POST['make_default']); + $lang_obj->make_default($id); +} + +//Importing language +if(isset($_POST['add_language'])) +{ + $lang_obj->import_lang(); +} + +//Removig Langiage +if(isset($_GET['delete'])) +{ + $id = mysql_clean($_GET['delete']); + $lang_obj->delete_lang($id); +} + +//Updateing Language +if(isset($_POST['update_language'])) +{ + $_POST['lang_id'] = $_GET['edit_language']; + $lang_obj->update_lang($_POST); +} + +//Downloading Language +if(isset($_GET['download'])) +{ + $lang_obj->export_lang(mysql_clean($_GET['download'])); +} + +//Downloading Language +if(isset($_GET['action'])) +{ + $lang_obj->action_lang($_GET['action'],mysql_clean($_GET['id'])); +} + +//Create package +if(isset($_GET['create_package'])) +{ + if($lang_obj->createPack($_GET['create_package'])) + e("Language pack has been re-created","m"); +} + +//Create package +if(isset($_GET['recreate_from_pack'])) +{ + if($lang_obj->updateFromPack($_GET['recreate_from_pack'])) + e("Language database has been updated","m"); +} + + + +//Get List Of Languages +assign('language_list',$lang_obj->get_langs()); +Assign('msg',$msg); + + + +if($lang_obj->lang_exists(mysql_clean($_GET['edit_language']))) +{ + assign('edit_lang','yes'); + assign('lang_details',$lang_obj->lang_exists(mysql_clean($_GET['edit_language']))); + $edit_id = mysql_clean($_GET['edit_language']); + $limit = RESULTS; + + + $current_page = $_GET['page'] ; + $current_page = is_numeric($current_page) && $current_page>0 ? $current_page : 1 ; + + $curr_limit = ($current_page-1)*$limit .','.$limit; + + if(isset($_GET['search_phrase'])) + { + $varname = mysql_clean($_GET['varname']); + $text = mysql_clean($_GET['text']); + + if(!empty($varname)) + $varname_query = "varname LIKE '%$varname%'"; + if(!empty($text)) + $text_query = "text LIKE '%$text%'"; + + if(!empty($text_query) || !empty($varname_query)) + { + if(!empty($text_query) && !empty($varname_query) ) + $or = ' OR '; + $extra_param = " AND ( $varname_query $or $text_query )"; + } + } + + $lang_phrases = $lang_obj->get_phrases($edit_id,'*',$curr_limit,$extra_param); + $total_phrases = $lang_obj->count_phrases($edit_id,$extra_param); + + assign('lang_phrases',$lang_phrases); + + $total_pages = $total_phrases/$limit; + $total_pages = round($total_pages+0.49,0); + $pages->paginate($total_pages,$current_page); +} + + +subtitle("Language Settings"); +template_files('language_settings.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/login.php b/upload/admin_area/login.php new file mode 100644 index 00000000..9ff94eaa --- /dev/null +++ b/upload/admin_area/login.php @@ -0,0 +1,50 @@ +is_admin_logged_as_user()) +{ + $userquery->revert_from_user(); + redirect_to(BASEURL.'/admin_area'); +} + +if($userquery->admin_login_check(TRUE)) +{ + redirect_to(BASEURL."/".ADMINDIR."/index.php"); +} +$eh->flush(); + +$thisurl = $_SERVER['PHP_SELF']; +Assign('THIS_URL', $thisurl); + +if(!empty($_REQUEST['returnto'])) +{ + $return_to = $_REQUEST['returnto']; + Assign('return_to',$return_to); +} + +if(isset($_POST['login'])){ + $username = $_POST['username']; + $username = mysql_clean(clean($username)); + $password = mysql_clean(clean($_POST['password'])); + + //Loggin User + if($userquery->login_user($username,$password)) + redirect_to('index.php'); + +} + + +if(userid() && !has_access('admin_access',true)) + e(lang("you_dont_hv_perms")); + +subtitle('Admin Login'); +Template('global_header.html'); +Template('login.html'); +?> \ No newline at end of file diff --git a/upload/admin_area/login_as_user.php b/upload/admin_area/login_as_user.php new file mode 100644 index 00000000..e3437bab --- /dev/null +++ b/upload/admin_area/login_as_user.php @@ -0,0 +1,27 @@ +is_admin_logged_as_user()) +{ + $userquery->admin_login_check(); + $userquery->login_check('member_moderation'); +} +$pages->page_redir(); + +if($_GET['revert']) +{ + $userquery->revert_from_user(); + redirect_to(BASEURL.'/admin_area'); +} +$uid = $_GET['uid']; + +if($userquery->login_as_user($uid)) + redirect_to(BASEURL); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/logo_change.php b/upload/admin_area/logo_change.php new file mode 100644 index 00000000..6b2a3116 --- /dev/null +++ b/upload/admin_area/logo_change.php @@ -0,0 +1,19 @@ +admin_login_check(); +$pages->page_redir(); + + +subtitle("Logo Changer"); + +template_files('under_development.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/logout.php b/upload/admin_area/logout.php new file mode 100644 index 00000000..390c0105 --- /dev/null +++ b/upload/admin_area/logout.php @@ -0,0 +1,5 @@ +logout(); +redirect_to('index.php'); +?> \ No newline at end of file diff --git a/upload/admin_area/main.php b/upload/admin_area/main.php new file mode 100644 index 00000000..0f08ab90 --- /dev/null +++ b/upload/admin_area/main.php @@ -0,0 +1,298 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); + +$pages->page_redir(); + +if(@$_GET['msg']){ +$msg = mysql_clean($_GET['msg']); +} + +$opt_list = $Upload->load_upload_options(); +assign('opt_list',$opt_list); + +assign('post_max_size',ini_get('post_max_size')); +assign('upload_max_size',ini_get('upload_max_filesize')); + + +if(isset($_POST['update'])){ + $configs = $Cbucket->configs; + + $rows = array( + 'allowed_types', + 'allow_language_change', + 'allow_unicode_usernames', + 'allow_registeration', + 'allow_template_change', + 'allow_upload', + 'anonymous_id', + 'anonym_comments', + 'approve_video_notification', + 'audio_codec', + 'activation', + + 'background_color', + 'background_upload', + 'background_url', + 'big_thumb_width', + 'big_thumb_height', + + 'closed', + 'closed_msg', + 'channel_comments', + 'channels_list_per_page', + 'channels_list_per_tab', + 'channelsSection', + 'channel_rating', + 'collection_rating', + 'collectionsSection', + 'comments_per_page', + 'captcha_type', + 'con_modules_type', + 'comments_captcha', + 'comment_rating', + 'collection_per_page', + 'collection_home_page', + 'collection_search_result', + 'collection_user_collections', + 'collection_items_page', + 'collection_user_favorites', + 'collection_channel_page', + + 'embed_type', + + 'date_format', + 'description', + 'debug_level', + 'default_country_iso2', + 'default_time_zone', + 'disallowed_usernames', + 'use_subs', + + 'embedUpload', + 'email_verification', + 'enable_groups', + + 'ffmpegpath' , + 'flvtool2path', + 'flvtoolpp', + 'ffmpeg_type', + 'facebook_embed', + + 'gravatars', + 'grp_categories', + 'groups_list_per_page', + 'grps_items_search_page', + 'grp_thumb_height', + 'grp_thumb_width', + 'grp_max_title', + 'grp_max_desc', + 'groupsSection', + + 'high_resolution', + 'hq_output', + + 'keywords' , + 'keep_original', + 'keep_mp4_as_is', + + 'r_height', + 'r_width', + + 'max_bg_width', + 'max_bg_size', + 'max_conversion', + 'max_profile_pic_height', + 'max_profile_pic_size', + 'max_profile_pic_width', + 'max_topic_title', + 'max_video_title', + 'max_topic_length', + 'max_video_desc', + 'max_video_tags', + 'max_username', + 'min_video_title', + 'min_video_tags', + 'min_video_desc', + 'mp4boxpath', + 'mplayerpath', + 'min_age_reg', + 'min_username', + 'max_comment_chr', + 'max_time_wait', + 'max_upload_size', + 'max_video_duration', + 'mplayerpath', + + 'normal_resolution', + 'num_thumbs', + + 'own_channel_rating', + 'own_collection_rating', + 'own_video_rating', + + + 'php_path', + 'picture_url', + 'picture_upload', + 'photosSection', + 'photo_main_list', + 'photo_home_tabs', + 'photo_search_result', + 'photo_channel_page', + 'photo_user_photos', + 'photo_user_favorites', + 'photo_other_limit', + + + 'quick_conv', + + 'resize', + 'remoteUpload', + 'recently_viewed_limit', + + 'send_comment_notification', + 'site_title' , + 'sys_os' , + 'sbrate' , + 'srate', + 'site_slogan', + 'seo', + 'seo_vido_url', + 'search_list_per_page', + 'server_friendly_conversion', + 'support_email', + 'show_collapsed_checkboxes', + + 'thumb_width', + 'thumb_height', + + 'use_ffmpeg_vf', + 'use_crons', + 'user_comment_own', + 'user_rate_opt1' , + 'users_items_subscriptions', + 'users_items_subscibers', + 'users_items_contacts_channel', + 'users_items_search_page', + 'users_items_group_page', + 'user_max_chr', + 'use_cached_pagin', + 'cached_pagin_time', + + 'vid_categories', + 'vid_cat_height', + 'vid_cat_width', + 'videosSection', + 'videos_items_grp_page', + 'videos_items_hme_page', + 'videos_items_columns', + 'videos_items_ufav_page', + 'videos_items_uvid_page', + 'videos_items_search_page', + 'videos_item_channel_page', + 'videos_list_per_page', + 'videos_list_per_tab', + 'video_download' , + 'video_embed', + 'video_comments', + 'video_rating', + 'video_comments3', + 'video_categories', + 'video_codec', + 'vrate', + 'vbrate', + 'video_require_login', + + 'website_email', + 'welcome_email', + + + ); + + foreach($opt_list as $optl) + { + $rows[] = $optl['load_func']; + } + + //Numeric Array + $num_array = array( + 'anonymous_id', + + 'channels_list_per_page', + 'channels_list_per_tab', + + 'max_upload_size', + 'max_video_title', + 'max_video_desc', + 'max_video_tags', + 'min_video_title', + 'min_video_tags', + 'min_video_desc', + + 'recently_viewed_limit', + + 'search_list_per_page', + + 'users_items_subscriptions', + 'users_items_subscibers', + 'users_items_contacts_channel', + 'users_items_search_page', + 'users_items_group_page', + + 'videos_items_grp_page', + 'videos_items_hme_page', + 'videos_items_columns', + 'videos_items_ufav_page', + 'videos_items_uvid_page', + 'videos_items_search_page', + 'videos_item_channel_page', + 'videos_list_per_page', + 'videos_list_per_tab', + 'video_categories', + + 'photo_main_list', + 'photo_home_tabs', + 'photo_search_result', + 'photo_channel_page', + 'photo_user_photos', + 'photo_user_favorites', + 'photo_other_limit', + + 'collection_per_page', + 'collection_home_page', + 'collection_search_result', + 'collection_user_collections', + 'collection_items_page', + 'collection_user_favorites', + 'collection_channel_page', + ); + foreach($rows as $field) + { + $value = ($_POST[$field]); + if(in_array($field,$num_array)) + { + if($value <= 0 || !is_numeric($value)) + $value = 1; + } + $myquery->Set_Website_Details($field,$value); + } + e("Website Settings Have Been Updated",'m'); + +} + +$row = $myquery->Get_Website_Details(); +Assign('row',$row); +subtitle("Website Configurations"); +template_files('main.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/maintenance.php b/upload/admin_area/maintenance.php new file mode 100644 index 00000000..fd451993 --- /dev/null +++ b/upload/admin_area/maintenance.php @@ -0,0 +1,146 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); +$pages->page_redir(); + +/** + * Removing Inactive Sessions + */ +if(@$_GET['mode']=='remove_sessions') +{ + $db->Execute("DELETE from ".tbl("sessions")." WHERE + TIMESTAMPDIFF(MINUTE,last_active,now()) + > 5 AND session_string='guest'"); + $guest_sess = $db->Affected_Rows(); + $db->Execute("DELETE from ".tbl("sessions")." WHERE + TIMESTAMPDIFF(MINUTE,last_active,now()) + > ". COOKIE_TIMEOUT/60 ." AND session_string='smart_sess'"); + $smart_sess = $db->Affected_Rows(); + + if($guest_sess) + e("Removed '".$guest_sess."' inactive guest sessions","m"); + if($smart_sess) + e("Removed '".$smart_sess."' inactive user sessions","m"); + + if(!$guest_sess && !$smart_sess) + e("All inactive sessions are already removed","m"); + +} + + +/** + * Removing Old Access log + */ +if(@$_GET['mode']=='remove_access_log') +{ + $days = $_GET['days']; + $days = mysql_clean($days); + if(!is_numeric($days) || $days<1) + $days = 10; + $days = $days-1; + $query = "DELETE from ".tbl("action_log")." WHERE + DATEDIFF(now(),date_added) > ". $days; + + $db->Execute($query); + + $rows = $db->Affected_Rows(); + + $days++; + if($rows) + e($rows. " records removed from action log","m"); + else + e("Not enough action log found older than ".$days." days","m"); +} + + +if(@$_GET['mode']=='remove_activity_feed') +{ + + $start_index = $_GET['start_index'] ? $_GET['start_index'] : 0; + $loop_size = $_GET['loop_size']; + $loop_size = $loop_size ? $loop_size : 5; + assign('loop_size',$loop_size); + $next_index = $start_index+$loop_size; + assign('next_index',$next_index); + + + //Reindex Videos + + $msg = array(); + $users = get_users(array("usr_status"=>"Ok","limit"=>$start_index.",".$loop_size)); + + $total_users = get_users(array("count_only"=>true,"usr_status"=>"Ok")); + $percent = $cbindex->percent(50,$total_users); + $i = 0; + + + $days = $_GET['days']; + $days = mysql_clean($days); + if(!is_numeric($days) || $days<1) + $days = 10; + $days = $days-1; + + assign('total',$total_users); + assign('from',$start_index+1); + assign('days',$days); + + $to = $start_index+$loop_size; + if($to>=$total_users) + { + $to = $total_users; + e($total_users." users have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + while($i < $total_users) + { + if($users[$i]['userid']) + { + $deleted = 0; + $user_feed_dir = USER_FEEDS_DIR.'/'.$users[$i]['userid']; + if($user_feed_dir) + { + $feeds = glob($user_feed_dir.'/*.feed'); + if($feeds) + { + + foreach($feeds as $feed) + { + $fileName = getName($feed); + $now = time(); + + if($now-$fileName >= $days*24*60*60) + { + unlink($feed); + $deleted++; + } + + } + } + } + $msg[] = $users[$i]['userid'].": Removed '".$deleted."' activity feeds of ".$users[$i]['username'].""; + } + $i++; + + } + e($start_index+1 ." - ".$to." Activity feeds have been deleted.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','remove_activity_feed'); +} + + +subtitle("Maintenance"); +template_files('maintenance.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/manage_items.php b/upload/admin_area/manage_items.php new file mode 100644 index 00000000..11f949d1 --- /dev/null +++ b/upload/admin_area/manage_items.php @@ -0,0 +1,94 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +$id = mysql_clean($_GET['collection']); +$type = mysql_clean($_GET['type']); +$data = $cbcollection->get_collection($id); + +switch($type) +{ + case "photos": + { + + if(isset($_POST['remove_selected'])) + { + $total = count($_POST['check_obj']); + for($i=0;$i<$total;$i++) + { + $cbphoto->collection->remove_item($_POST['check_obj'][$i],$id); + $cbphoto->make_photo_orphan($id,$_POST['check_obj'][$i]); + } + $eh->flush(); + e($total." photos have been removed.","m"); + } + + if(isset($_POST['move_selected'])) + { + $total = count($_POST['check_obj']); + $new = mysql_clean($_POST['collection_id']); + for($i=0;$i<$total;$i++) + { + $cbphoto->collection->change_collection($new,$_POST['check_obj'][$i],$id); + $db->update(tbl('photos'),array('collection_id'),array($new)," collection_id = $id AND photo_id = ".$_POST['check_obj'][$i].""); + } + $eh->flush(); + e($total." photo(s) have been moved to '".get_collection_field($new,'collection_name')."'","m"); + + } + + $items = $cbphoto->collection->get_collection_items_with_details($id); + $collection = $cbphoto->collection->get_collections(array("type"=>"photos","user"=>$data['userid'])); + } + break; + + case "videos": + { + + if(isset($_POST['remove_selected'])) + { + $total = count($_POST['check_obj']); + for($i=0;$i<$total;$i) + { + $cbvideo->collection->remove_item($_POST['check_obj'][$i],$id); + } + } + + if(isset($_POST['move_selected'])) + { + $total = count($_POST['check_obj']); + $new = mysql_clean($_POST['collection_id']); + for($i=0;$i<$total;$i++) + { + $cbvideo->collection->change_collection($new,$_POST['check_obj'][$i],$id); + } + $eh->flush(); + e($total." video(s) have been moved to '".get_collection_field($new,'collection_name')."'","m"); + + } + + $items = $cbvideo->collection->get_collection_items_with_details($id); + $collection = $cbvideo->collection->get_collections(array("type"=>"videos","user"=>$data['userid'])); + } +} + + + +assign('data',$data); +assign('obj',$items); +assign('type',$type); +assign('c',$collection); + +subtitle("Manage Items"); +template_files('manage_items.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/manage_pages.php b/upload/admin_area/manage_pages.php new file mode 100644 index 00000000..e36e0124 --- /dev/null +++ b/upload/admin_area/manage_pages.php @@ -0,0 +1,127 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); + +$pages->page_redir(); + +//Activating Page +if(isset($_GET['activate'])) +{ + $pid = mysql_clean($_GET['activate']); + $cbpage->page_actions('activate',$pid); +} + +//Dectivating Page +if(isset($_GET['deactivate'])) +{ + $pid = mysql_clean($_GET['deactivate']); + $cbpage->page_actions('deactivate',$pid); +} +//Deleting +if(isset($_GET['delete'])) +{ + $pid = mysql_clean($_GET['delete']); + $cbpage->page_actions('delete',$pid); +} +//Displaying +if(isset($_GET['display'])) +{ + $pid = mysql_clean($_GET['display']); + $cbpage->page_actions('display',$pid); +} + +//Hiding +if(isset($_GET['hide'])) +{ + $pid = mysql_clean($_GET['hide']); + $cbpage->page_actions('hide',$pid); +} +if(isset($_POST['activate_selected'])){ + for($id=0;$id<=count($_POST['check_page']);$id++){ + $cbpage->page_actions('activate',$_POST['check_page'][$id]); + } + $eh->flush(); + e("Selected pages have been activated","m"); +} + +if(isset($_POST['deactivate_selected'])){ + for($id=0;$id<=count($_POST['check_page']);$id++){ + $cbpage->page_actions('deactivate',$_POST['check_page'][$id]); + } + $eh->flush(); + e("Selected pages have been deactivated","m"); +} +if(isset($_POST['delete_selected'])){ + for($id=0;$id<=count($_POST['check_page']);$id++){ + $cbpage->page_actions('delete',$_POST['check_page'][$id]); + } + $eh->flush(); + e("Selected pages have been deleted","m"); +} + +$mode = $_GET['mode']; + +if(isset($_POST['add_page'])) +{ + if($cbpage->create_page($_POST)) + $mode = 'view'; + if(!error()) + header('location:manage_pages.php?msg='.msg('0')); +} + +//Updating order +if(isset($_POST['update_order'])) +{ + $cbpage->update_order(); + e(lang("Page order has been updated"),"m"); +} + +switch($mode) +{ + case "new": + { + assign("mode","new"); + } + break; + + case "view": + default: + { + if($_GET['msg']) + e(mysql_clean($_GET['msg']),"m"); + + assign("mode","manage"); + assign("cbpages",$cbpage->get_pages()); + } + break; + case "edit": + { + if(isset($_POST['update_page'])) + { + $_POST['page_id'] = $_GET['pid']; + $cbpage->edit_page($_POST); + } + + assign("mode","edit"); + $page = $cbpage->get_page(mysql_clean($_GET['pid'])); + assign('page',$page); + if(!$page) + e("Page does not exist"); + } + +} +subtitle("Manage Pages"); +template_files('manage_pages.html'); +display_it(); + + +?> \ No newline at end of file diff --git a/upload/admin_area/manage_players.php b/upload/admin_area/manage_players.php new file mode 100644 index 00000000..d8ad539a --- /dev/null +++ b/upload/admin_area/manage_players.php @@ -0,0 +1,65 @@ +admin_login_check(); +$pages->page_redir(); +$userquery->login_check('admin_access'); + +//Set Mode +assign('mode',$_GET['mode']); + +if(isset($_POST['update'])){ + $configs = $Cbucket->configs; + + + $rows = array( + 'autoplay_video', + 'buffer_time', + 'logo_placement', + 'use_playlist', + 'youtube_enabled', + 'embed_player_height', + 'embed_player_width','autoplay_embed','pseudostreaming','pak_license','pakplayer_contextmsg' + ); + + //Checking for logo + if(isset($_FILES['logo_file']['name'])) + { + $logo_file = $Upload->upload_website_logo($_FILES['logo_file']); + if($logo_file) + $myquery->Set_Website_Details('player_logo_file',$logo_file); + } + + + if($_POST['pak_license'] && !file_exists(BASEDIR.'/player/pak_player/pakplayer.unlimited.swf')) + $_POST['pak_license'] = ""; + + foreach($rows as $field) + { + $value = mysql_clean($_POST[$field]); + $myquery->Set_Website_Details($field,$value); + } + e("Player Settings Have Been Updated",'m'); + +} + + +if($_GET['set']) +{ + $cbplayer->set_player($_GET); +} + +$row = $myquery->Get_Website_Details(); +Assign('row',$row); + +subtitle("Manage Players"); +template_files('manage_players.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/mass_email.php b/upload/admin_area/mass_email.php new file mode 100644 index 00000000..2e3918a3 --- /dev/null +++ b/upload/admin_area/mass_email.php @@ -0,0 +1,76 @@ +admin_login_check(); +$userquery->login_check('member_moderation'); +$pages->page_redir(); + +if(!empty($_GET['email'])){ + Assign('email',$_GET['email']); +} + +//Creating an mass email +if(isset($_POST['create_email'])) +{ + if($cbemail->add_mass_email()) + { + unset($_POST); + } +} + +//Deleting Email +if(isset($_GET['delete'])) +{ + $del = mysql_clean($_GET['delete']); + $cbemail->action($del,'delete'); +} + +//Sending Email +if(isset($_GET['send_email'])) +{ + $eId = mysql_clean($_GET['send_email']); + $email = $cbemail->get_email($eId); + if($email) + { + $msgs = $cbemail->send_emails($email); + assign('msgs',$msgs); + + $email = $cbemail->get_email($eId); + assign('send_email',$email); + } +} + +//Getting List of emails +$emails = $cbemail->get_mass_emails(); +assign('emails',$emails); + +//Category Array... +if(is_array($_POST['category'])) + $cats_array = array($_POST['category']); +else +{ + preg_match_all('/#([0-9]+)#/',$_POST['category'],$m); + $cats_array = array($m[1]); +} +$cat_array = array(lang('vdo_cat'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cats_array), + 'hint_1'=> lang('vdo_cat_msg'), + 'display_function' => 'convert_to_categories', + 'category_type'=>'user'); +assign('cat_array',$cat_array); + +//Displaying template... +subtitle("Mass Email"); +template_files("mass_email.html"); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/mass_uploader.php b/upload/admin_area/mass_uploader.php new file mode 100644 index 00000000..abeb4846 --- /dev/null +++ b/upload/admin_area/mass_uploader.php @@ -0,0 +1,72 @@ +admin_login_check(); +$pages->page_redir(); + + +if(isset($_POST['mass_upload_video'])) +{ + $files = $cbmass->get_video_files(); + + $total = count($_POST['mass_up']); + for($i=0;$i<$total;$i++) + { + $file_key = time().RandomString(5); + $file_arr = $files[$i]; + + if($cbmass->is_mass_file($file_arr)) + { + $code = $i+1; + //Inserting Video Data... + $array = array + ( + 'title' => $_POST['title'][$i], + 'description' => $_POST['description'][$i], + 'tags' => $_POST['tags'][$i], + 'category' => $_POST['category'.$code], + 'file_name' => $file_key, + ); + $vid = $Upload->submit_upload($array); + }else{ + e("\"".$file_arr['title']."\" is not available"); + } + + if(error()) + { + $error_lists[] = "Unable to upload \"".$file_arr['title']."\""; + $errors = error(); + foreach($errors as $e) + $error_lists[] = $e; + + $eh->flush_error(); + }else{ + e("\"".$file_arr['title']."\" Has been uploaded successfully","m"); + } + + if($vid) + { + //Moving file to temp dir and Inserting in conversion queue.. + $file_name = $cbmass->move_to_temp($file_arr,$file_key); + $Upload->add_conversion_queue($file_name); + } + } +} + +if(count($error_lists)>0) +{ + foreach($error_lists as $e) + e($e); +} + +subtitle("Mass Uploader"); +template_files("mass_uploader.html"); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/members.php b/upload/admin_area/members.php new file mode 100644 index 00000000..6459018d --- /dev/null +++ b/upload/admin_area/members.php @@ -0,0 +1,178 @@ +admin_login_check(); +$userquery->login_check('member_moderation'); +$pages->page_redir(); + + +//Delete User +if(isset($_GET['deleteuser'])){ + $deleteuser = mysql_clean($_GET['deleteuser']); + $userquery->delete_user($deleteuser); +} + +//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 User +if(isset($_GET['activate'])){ + $user = mysql_clean($_GET['activate']); + $userquery->action('activate',$user); +} +//Deactivate 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]); + } + $eh->flush(); + e("Selected users have been activated","m"); +} +if(isset($_POST['deactivate_selected'])){ + for($id=0;$id<=count($_POST['check_user']);$id++){ + $userquery->action('deactivate',$_POST['check_user'][$id]); + } + $eh->flush(); + e("Selected users have been deactivated","m"); +} + +//Make User Featured +if(isset($_GET['featured'])){ + $user = mysql_clean($_GET['featured']); + $userquery->action('featured',$user); +} +//Make User UnFeatured +if(isset($_GET['unfeatured'])){ + $user = mysql_clean($_GET['unfeatured']); + $userquery->action('unfeatured',$user); +} +//Using Multple Action +if(isset($_POST['make_featured_selected'])){ + for($id=0;$id<=count($_POST['check_user']);$id++){ + $userquery->action('featured',$_POST['check_user'][$id]); + } + $eh->flush(); + e("Selected users have been set as featured","m"); +} +if(isset($_POST['make_unfeatured_selected'])){ + for($id=0;$id<=count($_POST['check_user']);$id++){ + $userquery->action('unfeatured',$_POST['check_user'][$id]); + } + $eh->flush(); + e("Selected users have been removed from featured list","m"); +} + +//Ban User +if(isset($_GET['ban'])){ + $user = mysql_clean($_GET['ban']); + $userquery->action('ban',$user); +} +//UnBan User +if(isset($_GET['unban'])){ + $user = mysql_clean($_GET['unban']); + $userquery->action('unban',$user); +} + +//Using Multple Action +if(isset($_POST['ban_selected'])){ + for($id=0;$id<=count($_POST['check_user']);$id++){ + $userquery->action('ban',$_POST['check_user'][$id]); + } + $eh->flush(); + e("Selected users have been banned","m"); +} + +if(isset($_POST['unban_selected'])){ + for($id=0;$id<=count($_POST['check_user']);$id++){ + $userquery->action('unban',$_POST['check_user'][$id]); + } + $eh->flush(); + e("Selected users have been unbanned","m"); +} + + + //Calling Video Manager Functions + call_functions($userquery->user_manager_functions); + + //Getting Member List + $page = mysql_clean($_GET['page']); + $get_limit = create_query_limit($page,RESULTS); + + if(isset($_GET['search'])) + { + + $array = array + ( + 'userid' => $_GET['userid'], + 'username' => $_GET['username'], + 'category' => $_GET['category'], + 'featured' => $_GET['featured'], + 'ban' => $_GET['ban'], + 'status' => $_GET['status'], + 'email' => $_GET['email'], + 'gender' => $_GET['gender'], + 'level' => $_GET['level'] + ); + } + + $result_array = $array; + //Getting Video List + $result_array['limit'] = $get_limit; + if(!$array['order']) + $result_array['order'] = " doj DESC "; + + $users = get_users($result_array); + + Assign('users', $users); + + //Collecting Data for Pagination + $mcount = $array; + $mcount['count_only'] = true; + $total_rows = get_users($mcount); + $total_pages = count_pages($total_rows,RESULTS); + $pages->paginate($total_pages,$page); + + //Pagination + $pages->paginate($total_pages,$page); + + //Category Array + if(is_array($_GET['category'])) + $cats_array = array($_GET['category']); + else + { + preg_match_all('/#([0-9]+)#/',$_GET['category'],$m); + $cats_array = array($m[1]); + } + $cat_array = array(lang('vdo_cat'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cats_array), + 'hint_1'=> lang('vdo_cat_msg'), + 'display_function' => 'convert_to_categories', + 'category_type'=>'user'); + assign('cat_array',$cat_array); + + +subtitle("Members Manager"); +template_files('members.html'); +display_it(); +?> diff --git a/upload/admin_area/module_manager.php b/upload/admin_area/module_manager.php new file mode 100644 index 00000000..b2f8637c --- /dev/null +++ b/upload/admin_area/module_manager.php @@ -0,0 +1,17 @@ +admin_login_check(); +$pages->page_redir(); + + +template_files('under_development.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/notification_settings.php b/upload/admin_area/notification_settings.php new file mode 100644 index 00000000..a548d1ad --- /dev/null +++ b/upload/admin_area/notification_settings.php @@ -0,0 +1,40 @@ +admin_login_check(); +$pages->page_redir(); + + + if($_POST['update_notification']) + { + $rows = array( + 'notification_option'); + + + foreach($rows as $field) + { + $value = $_POST[$field]; + $myquery->Set_Website_Details($field,$value); + } + + + e("Notification Settings Have Been Updated",'m'); + + subtitle("Notification Settings"); + } + + +$row = $myquery->Get_Website_Details(); +assign('row',$row); + +template_files('notification_settings.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/online_users.php b/upload/admin_area/online_users.php new file mode 100644 index 00000000..b9d520f0 --- /dev/null +++ b/upload/admin_area/online_users.php @@ -0,0 +1,31 @@ +admin_login_check(); +$pages->page_redir(); + +if($_GET['kick']) +{ + if($sess->kick(mysql_clean($_GET['kick']))) + { + e("User has been kicked out","m"); + } +} + +$online_users = $userquery->get_online_users(false); +assign('total',count($online_users)); +assign('online_users',$online_users); +assign('queryString',queryString(NULL,'kick')); +subtitle("View online users"); +template_files('online_users.html'); +display_it(); + + +?> \ No newline at end of file diff --git a/upload/admin_area/orphan_photos.php b/upload/admin_area/orphan_photos.php new file mode 100644 index 00000000..34642230 --- /dev/null +++ b/upload/admin_area/orphan_photos.php @@ -0,0 +1,79 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +if(isset($_GET['delete_photo'])) +{ + $id = mysql_clean($_GET['delete_photo']); + $cbphoto->delete_photo($id); +} + +//Thanks to didier.saintes +if(isset($_POST['delete_selected'])) //HACK : delete_selected in place of deleted_selected +{ + + $total = count($_POST['check_photo']); //HACK Add count + for($i=0;$i<$total;$i++)g +{ + $cbphoto->delete_photo($_POST['check_photo'][$i],true); //HACK : Add true + } + $eh->flush(); + e($total." photos has been deleted successfully.","m"); +} + +//Multi-featured +if(isset($_POST['make_featured_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('feature_photo',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been marked as Featured","m"); +} + +//Multi-unfeatured +if(isset($_POST['make_unfeatured_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('unfeature_photo',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been marked as Unfeatured","m"); +} + +if(isset($_POST['move_selected'])) +{ + $total = count($_POST['check_photo']); + $new = mysql_clean($_POST['collection_id']); + for($i=0;$i<$total;$i++) + { + $cbphoto->collection->change_collection($new,$_POST['check_photo'][$i]); + $db->update(tbl('photos'),array('collection_id'),array($new)," photo_id = ".$_POST['check_photo'][$i].""); + } + $eh->flush(); + e($total." photo(s) have been moved to '".get_collection_field($new,'collection_name')."'","m"); + +} + +$photos = $cbphoto->get_photos(array("get_orphans"=>TRUE)); +$collection = $cbphoto->collection->get_collections(array("type"=>"photos")); +assign('photos',$photos); +assign('c',$collection); + +subtitle("Orphan Photos"); +template_files('orphan_photos.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/photo_manager.php b/upload/admin_area/photo_manager.php new file mode 100644 index 00000000..706f280a --- /dev/null +++ b/upload/admin_area/photo_manager.php @@ -0,0 +1,164 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +//Photo Actions are following + +//Feature +if(isset($_GET['make_feature'])) +{ + $id = mysql_clean($_GET['make_feature']); + $cbphoto->photo_actions('feature_photo',$id); +} + +//Unfeature +if(isset($_GET['make_unfeature'])) +{ + $id = mysql_clean($_GET['make_unfeature']); + $cbphoto->photo_actions('unfeature_photo',$id); +} + +//Activate +if(isset($_GET['activate'])) +{ + $id = mysql_clean($_GET['activate']); + $cbphoto->photo_actions('activation',$id); +} + +//Deactivate +if(isset($_GET['deactivate'])) +{ + $id = mysql_clean($_GET['deactivate']); + $cbphoto->photo_actions('deactivation',$id); +} + +//Delete +if(isset($_GET['delete_photo'])) +{ + $id = mysql_clean($_GET['delete_photo']); + $cbphoto->delete_photo($id); +} + +//Multi-Active +if(isset($_POST['deactivate_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('deactivation',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been deactivated","m"); +} + +//Multi-Deactive +if(isset($_POST['activate_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('activation',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been activated","m"); +} + +//Multi-featured +if(isset($_POST['make_featured_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('feature_photo',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been marked as Featured","m"); +} + +//Multi-unfeatured +if(isset($_POST['make_unfeatured_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->photo_actions('unfeature_photo',$_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been marked as Unfeatured","m"); +} + +//Multi-delete +if(isset($_POST['delete_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->delete_photo($_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photos has been deleted successfully","m"); +} + +if(isset($_POST['move_to_selected'])) +{ + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $id_array[] = $_POST['check_photo'][$i]; + } + //$eh->flush(); +} + +if(isset($_GET['search'])) +{ + $array = array( + 'title' => $_GET['title'], + 'pid' => $_GET['photoid'], + 'key' => $_GET['photokey'], + 'tags' => $_GET['tags'], + 'featured' => $_GET['featured'], + 'active' => $_GET['active'], + 'user' => $_GET['userid'], + 'extension' => $_GET['extension'], + 'order' => $_GET['order'] + ); +} + +$parr = $array; + +// Creating Limit +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,RESULTS); + +$parr['limit'] = $get_limit; +if(!$parr['order']) + $parr['order'] = " date_added DESC "; +else + $parr['order'] = $parr['order']." DESC"; + +$collections = $cbcollection->get_collections(array("type"=>"photos")); +$photos = $cbphoto->get_photos($parr); +Assign('photos', $photos); +assign('c',$collections); + +$pcount = $parr; +$pcount['count_only'] = true; +$total_rows = $cbphoto->get_photos($pcount); +$total_pages = count_pages($total_rows,RESULTS); +$pages->paginate($total_pages,$page); + + +subtitle("Photo Manager"); +template_files('photo_manager.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/photo_settings.php b/upload/admin_area/photo_settings.php new file mode 100644 index 00000000..240e0938 --- /dev/null +++ b/upload/admin_area/photo_settings.php @@ -0,0 +1,107 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +$mode = $_GET['mode']; +assign('mode',$mode); + +switch($mode) +{ + case "photo_settings": + default: + { + if($_POST['update']) + { + $rows = array( + 'photo_ratio', + 'photo_thumb_width', + 'photo_thumb_height', + 'photo_med_width', + 'photo_med_height', + 'photo_lar_width', + 'photo_crop', + 'photo_multi_upload', + 'max_photo_size', + 'own_photo_rating', + 'photo_download', + 'photo_comments', + 'photo_rating'); + + $numeric = array( + 'photo_thumb_width', + 'photo_thumb_height', + 'photo_med_width', + 'photo_med_height', + 'photo_lar_width', + 'photo_crop', + 'max_photo_size', + 'photo_multi_upload'); + + foreach($rows as $field) + { + $value = $_POST[$field]; + if(in_array($field,$numeric)) + { + if($value < 0 || !is_numeric($value)) + $value = 1; + } + $myquery->Set_Website_Details($field,$value); + } + e("Photo Settings Have Been Updated",'m'); + } + + + subtitle("Photo Settings"); + } + break; + + case "watermark_settings": + { + if($_POST['update_watermark']) + { + $rows = array( + 'watermark_photo', + 'watermark_max_width', + 'watermark_placement'); + $numeric = array( + 'watermark_max_width' + ); + + foreach($rows as $field) + { + $value = $_POST[$field]; + if(in_array($filed,$numeric)) + { + if($value < 0 || !is_numeric($value)) + $value = 1; + } + $myquery->Set_Website_Details($field,$value); + } + if(!empty($_FILES['watermark_file']['tmp_name'])) + $cbphoto->update_watermark($_FILES['watermark_file']); + + e("Watermark Settings Have Been Updated",'m'); + + subtitle("Watermark Settings"); + } + } + break; +} + +$row = $myquery->Get_Website_Details(); +assign('row',$row); + +template_files('photo_settings.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/phpinfo.php b/upload/admin_area/phpinfo.php new file mode 100644 index 00000000..7fb7d407 --- /dev/null +++ b/upload/admin_area/phpinfo.php @@ -0,0 +1,13 @@ +admin_login_check(); +phpinfo(); +?> \ No newline at end of file diff --git a/upload/admin_area/plugin.php b/upload/admin_area/plugin.php new file mode 100644 index 00000000..f3573743 --- /dev/null +++ b/upload/admin_area/plugin.php @@ -0,0 +1,37 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +$file = get('file'); +$folder = get('folder'); +$player = get('player'); + +$folder = str_replace('..', '', $folder); +$file = str_replace('..', '', $file); +$player = str_replace('..', '', $player); + +if($folder && $file) +{ + if(!$player) + $file = PLUG_DIR.'/'.$folder.'/'.$file; + else + $file = PLAYER_DIR.'/'.$folder.'/'.$file; + + if(file_exists($file)) + { + require($file); + display_it(); + exit(); + } +} + +header('location:plugin_manager.php?err=no_file'); +?> \ No newline at end of file diff --git a/upload/admin_area/plugin_manager.php b/upload/admin_area/plugin_manager.php new file mode 100644 index 00000000..092de581 --- /dev/null +++ b/upload/admin_area/plugin_manager.php @@ -0,0 +1,117 @@ +admin_login_check(); +$pages->page_redir(); + + + +//unnstalling Plugin +if(isset($_GET['uninstall'])) +{ + $folder = $_GET['f']; + $cbplugin->uninstallPlugin(mysql_clean($_GET['uninstall']),$folder); +} + +/** + * Uninstalling Multiple Plugins + */ +if(isset($_POST['uninstall_selected'])) +{ + $plugs = count($_POST['check_plugin']); + for($i=0;$i<$plugs;$i++) + { + $itr = $_POST['check_plugin'][$i]; + $cbplugin->uninstallPlugin($_POST['plugin_file_'.$itr],$_POST['plugin_folder_'.$itr]); + } +} + + + +//Activation or deactivating plugin +if(isset($_GET['activate'])) +{ + $folder = $_GET['f']; + $id = mysql_clean($_GET['activate']); + $msg = $cbplugin->pluginActive($id,'yes',$folder); +} + +/** + * Activating Multiple + */ +if(isset($_POST['activate_selected'])) +{ + $plugs = count($_POST['check_plugin']); + for($i=0;$i<$plugs;$i++) + { + $itr = $_POST['check_plugin'][$i]; + $cbplugin->pluginActive($_POST['plugin_file_'.$itr],'yes',$_POST['plugin_folder_'.$itr]); + } +} + +if(isset($_GET['deactivate'])) +{ + $folder = $_GET['f']; + $id = mysql_clean($_GET['deactivate']); + $msg = $cbplugin->pluginActive($id,'no',$folder); +} + + +/** + * dectivating Multiple + */ +if(isset($_POST['deactivate_selected'])) +{ + $plugs = count($_POST['check_plugin']); + for($i=0;$i<$plugs;$i++) + { + $itr = $_POST['check_plugin'][$i]; + $cbplugin->pluginActive($_POST['plugin_file_'.$itr],'no',$_POST['plugin_folder_'.$itr]); + } +} + +//Installing Plugin +if(isset($_GET['install_plugin'])) +{ + $folder = $_GET['f']; + $installed = $cbplugin->installPlugin(mysql_clean($_GET['install_plugin']),$folder); + if($installed) + include($installed); +} + +/** + * Installing Multiple Plugins + */ +if(isset($_POST['install_selected'])) +{ + $plugs = count($_POST['check_plugin']); + for($i=0;$i<$plugs;$i++) + { + $itr = $_POST['check_plugin'][$i]; + $installed = $cbplugin->installPlugin($_POST['plugin_file_'.$itr],$_POST['plugin_folder_'.$itr]); + if($installed) + include($installed); + } +} + +//Get New Plugin List +$availabe_plugin_list = $cbplugin->getNewPlugins(); +Assign('new_plugin_list',$availabe_plugin_list); + +//Get Installed Plugin List +$installed_plugin_list = $cbplugin->getInstalledPlugins(); + +Assign('installed_plugin_list',$installed_plugin_list); + +Assign('msg', @$msg); +subtitle("Plugin Manager"); +template_files('plugin_manager.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/recreate_thumbs.php b/upload/admin_area/recreate_thumbs.php new file mode 100644 index 00000000..a38d6e2d --- /dev/null +++ b/upload/admin_area/recreate_thumbs.php @@ -0,0 +1,116 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +$mode = $_GET['mode']; +$photo = mysql_clean($_GET['photo']); + + +switch($mode) +{ + case "single": + { + assign('mode',$mode); + if($cbphoto->photo_exists($photo)) + { + + + if($_GET['recreate']) + { + $cbphoto->generate_photos($photo); + e("Photo has been re-created. Please remove cache if you dont see any change.","m"); + } + + $files = $cbphoto->get_image_file($photo,'t',TRUE); + $p = $cbphoto->get_photo($photo); + + assign('files',$files); + assign('p',$p); + } else + e("Photo does not exist"); + } + break; + + case "mass": + default: + { + assign('mode',$mode); + $start_index = $_GET['start_index'] ? $_GET['start_index'] : 0; + $loop_size = $_GET['loop_size']; + $loop_size = $loop_size ? $loop_size : 2; + assign('loop_size',$loop_size); + $next_index = $start_index+$loop_size; + assign('next_index',$next_index); + if(isset($_GET['mass_recreation'])) + { + $photos = $cbphoto->get_photos(array("limit"=>$start_index.",".$loop_size)); + $total = $cbphoto->get_photos(array("count_only"=>true)); + $i = 0; + + assign('total',$total); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total) + { + $to = $total; + e($total." photos image have been recreated.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + while($i < $total) + { + if($photos[$i]['photo_id']) + { + $cbphoto->generate_photos($photos[$i]['photo_id']); + $msg[] = $photos[$i]['photo_id'].": Updating ".$photos[$i]['photo_title'].""; + } + $i++; + } + e($start_index+1 ." - ".$to." photos image have been recreated.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('button','mass_recreation'); + } + } + break; + + case "collection": + { + assign('mode',$mode); + $cid = mysql_clean($_GET['cid']); + if($cbphoto->collection->collection_exists($cid)) + { + if(isset($_POST['recreating'])) + { + $total = count($_POST['check_photo']); + for($i=0;$i<$total;$i++) + { + $cbphoto->generate_photos($_POST['check_photo'][$i]); + } + $eh->flush(); + e($total." photo(s) have been re-created. Please remove browser cache if you don't see any change.","m"); + } + $items = $cbphoto->collection->get_collection_items_with_details($cid); + assign('items',$items); + } else { + e(lang("Collection does not exist")); + } + } + break; +} + +subtitle("Recreate Photos"); +template_files('recreate_thumbs.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/reindex_cb.php b/upload/admin_area/reindex_cb.php new file mode 100644 index 00000000..6cbb4671 --- /dev/null +++ b/upload/admin_area/reindex_cb.php @@ -0,0 +1,232 @@ +admin_login_check(); +$pages->page_redir(); + +$vtbl = tbl("video"); +$utbl = tbl("users"); +$gtbl = tbl("groups"); + +function p_r($array) +{ + echo "
";
+		print_r($array);
+	echo "
"; +} + +$start_index = $_GET['start_index'] ? $_GET['start_index'] : 0; +$loop_size = $_GET['loop_size']; +$loop_size = $loop_size ? $loop_size : 5; +assign('loop_size',$loop_size); +$next_index = $start_index+$loop_size; +assign('next_index',$next_index); + +//Reindex Videos +if(isset($_GET['index_vids'])) +{ + $videos = get_videos(array("active"=>"yes","status"=>"Successful","limit"=>$start_index.",".$loop_size)); + $total_videos = get_videos(array("count_only"=>true,"active"=>"yes","status"=>"Successful")); + $percent = number_format(50 * $total_videos / 100); + $i = 0; + + assign('total',$total_videos); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total_videos) + { + $to = $total_videos; + e($total_videos." videos have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + + + while($i < $total_videos) + { + if($videos[$i]['videoid']) + { + $params = array("video_id"=>$videos[$i]['videoid'],"video_comments"=>true,"favs_count"=>true,"playlist_count"=>true); + $indexes = $cbindex->count_index("vid",$params); + $fields = $cbindex->extract_fields("vid",$params); + $msg[] = $videos[$i]['video'].": Updating ".$videos[$i]['title'].""; + $cbindex->update_index("vid",array("fields"=>$fields,"values"=>$indexes,"video_id"=>$videos[$i]['videoid'])); + } + $i++; + } + e($start_index+1 ." - ".$to." videos have been reindexed successfully.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','index_vids'); +} + +//Reindex Users +if(isset($_GET['index_usrs'])) { + $msg = array(); + $users = get_users(array("usr_status"=>"Ok","limit"=>$start_index.",".$loop_size)); + + $total_users = get_users(array("count_only"=>true,"usr_status"=>"Ok")); + $percent = $cbindex->percent(50,$total_users); + $i = 0; + + + assign('total',$total_users); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total_users) + { + $to = $total_users; + e($total_users." users have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + + while($i < $total_users) + { + if($users[$i]['userid']) + { + $params = array("user"=>$users[$i]['userid'],"comment_added"=>true,"subscriptions_count"=>true,"subscribers_count"=>true, + "video_count"=>true,"groups_count"=>true,"comment_received"=>true,"collections_count"=>true,"photos_count"=>true); + $indexes = $cbindex->count_index("user",$params); + $fields = $cbindex->extract_fields("user",$params); + $msg[] = $users[$i]['userid'].": Updating ".$users[$i]['username'].""; + $cbindex->update_index("user",array("fields"=>$fields,"values"=>$indexes,"user"=>$users[$i]['userid'])); + + } + $i++; + + } + e($start_index+1 ." - ".$to." users have been reindexed successfully.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','index_usrs'); + +} + +//Reindex Grous +if(isset($_GET['index_gps'])) { + $groups = get_groups(array("active"=>"yes")); + $total_groups = get_groups(array("count_only"=>true,"active"=>"yes")); + $percent = $cbindex->percent(50,$total_groups); + $i = 0; + + assign('total',$total_groups); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total_groups) + { + $to = $total_groups; + e($total_groups." groups have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + while ($i < $total_groups) + { + if($groups[$i]['group_id']) + { + $params = array("group_id"=>$groups[$i]['group_id'],"group_videos"=>true,"group_topics"=>true,"group_members"=>true); + $indexes = $cbindex->count_index("group",$params); + $fields = $cbindex->extract_fields("group",$params); + $msg[] = $groups[$i]['group_id'].": Updating ".$groups[$i]['group_name'].""; + $cbindex->update_index("group",array("fields"=>$fields,"values"=>$indexes,"group_id"=>$groups[$i]['group_id'])); + } + $i++; + } + + e($start_index+1 ." - ".$to." groups have been reindexed successfully.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','index_gps'); +} + +if(isset($_GET['index_photos'])) { + $photos = get_photos(array("active"=>"yes","limit"=>$start_index.",".$loop_size)); + $total_photos = get_photos(array("count_only"=>true,"active"=>"yes")); + $percent = $cbindex->percent(50,$total_photos); + $i = 0; + + assign('total',$total_photos); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total_photos) + { + $to = $total_photos; + e($total_photos." photos have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + while ($i < $total_photos) + { + if($photos[$i]['photo_id']) + { + $params = array("photo_id"=>$photos[$i]['photo_id'],"favorite_count"=>true,"total_comments"=>true); + $indexes = $cbindex->count_index("photos",$params); + $fields = $cbindex->extract_fields("photos",$params); + $msg[] = $photos[$i]['photo_id'].": Updating ".$photos[$i]['photo_title'].""; + $cbindex->update_index("photos",array("fields"=>$fields,"values"=>$indexes,"photo_id"=>$photos[$i]['photo_id'])); + } + $i++; + } + + e($start_index+1 ." - ".$to." photos have been reindexed successfully.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','index_photos'); +} + +if(isset($_GET['index_collections'])) { + $collections = get_collections(array("active"=>"yes","limit"=>$start_index.",".$loop_size)); + $total_collections = get_collections(array("count_only"=>true,"active"=>"yes")); + $percent = $cbindex->percent(50,$total_collections); + $i = 0; + + assign('total',$total_collections); + assign('from',$start_index+1); + $to = $start_index+$loop_size; + if($to>$total_collections) + { + $to = $total_collections; + e($total_collections." collections have been reindexed successfully.","m"); + assign("stop_loop","yes"); + } + assign('to',$to); + + while ($i < $total_collections) + { + if($collections[$i]['collection_id']) + { + $params = array("collection_id"=>$collections[$i]['collection_id'],"total_items"=>true,"total_comments"=>true); + $indexes = $cbindex->count_index("collections",$params); + $fields = $cbindex->extract_fields("collections",$params); + $msg[] = $collections[$i]['collection_id'].": Updating ".$collections[$i]['collection_name'].""; + $cbindex->update_index("collections",array("fields"=>$fields,"values"=>$indexes,"photo_id"=>$collections[$i]['collection_id'])); + } + $i++; + } + + e($start_index+1 ." - ".$to." collections have been reindexed successfully.","m"); + assign("index_msgs",$msg); + assign("indexing","yes"); + assign('mode','index_collections'); +} + +subtitle("Re-index Clipbucket"); +template_files('reindex_cb.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/repair_vid_duration.php b/upload/admin_area/repair_vid_duration.php new file mode 100644 index 00000000..3bf0d527 --- /dev/null +++ b/upload/admin_area/repair_vid_duration.php @@ -0,0 +1,66 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); + +$params = array('duration'=>'1','duration_op'=>'<=','status'=>'Successful'); +$videos = get_videos($params); +$fixed_array = array(); +if($_POST['fix_duration'] + || $_POST['mark_failed'] + || $_POST['mark_delete']) +{ + foreach($videos as $video) + { + $log = get_file_details($video['file_name']); + + if($log && $_POST['fix_duration']) + { + //$duration = $log['output_duration']; + //if(!$duration) + // $duration = $log['duration']; + + $duration = parse_duration(LOGS_DIR.'/'.$video['file_name'].'.log'); + + if(!$duration) + e("Can't do anything about \"".$video['title']."\""); + else + { + $db->update(tbl('video'),array('duration'),array($duration),"videoid='".$video['videoid']."'"); + $fixed_array[$video['file_name']] = 'yes'; + e("Succesfully updated duration of \"".$video['title']."\" to ".SetTime($duration),'m'); + } + } + + if(!$log && $_POST['mark_failed']) + { + $db->update(tbl("video"),array("status","failed_reason"), + array('Failed',"Unable to get video duration")," file_name='".$video['file_name']."'"); + e("\"".$video['title']."\" status has been changed to Failed","m"); + } + + if(!$log && $_POST['mark_delete']) + { + $db->update(tbl("video"),array("status","failed_reason"), + array('Failed',"Unable to get video duration")," file_name='".$video['file_name']."'"); + + $cbvideo->delete_video($video['videoid']); + } + } + $videos = get_videos($params); +} + +subtitle("Repair videos duration"); + +assign('videos',$videos); +assign('fixed_array',$fixed_array); +template_files('repair_vid_duration.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/reports.php b/upload/admin_area/reports.php new file mode 100644 index 00000000..9b9b94b1 --- /dev/null +++ b/upload/admin_area/reports.php @@ -0,0 +1,40 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); + + +$vid_dir = get_directory_size(VIDEOS_DIR); +$thumb_dir = get_directory_size(THUMBS_DIR); +$orig_dir = get_directory_size(ORIGINAL_DIR); + +$user_thumbs = get_directory_size(USER_THUMBS_DIR); +$user_bg = get_directory_size(USER_BG_DIR); + +$grp_thumbs = get_directory_size(GP_THUMB_DIR); +$cat_thumbs = get_directory_size(CAT_THUMB_DIR); + + +assign('vid_dir',$vid_dir); +assign('thumb_dir',$thumb_dir); +assign('orig_dir',$orig_dir); + +assign('user_thumbs',$user_thumbs); +assign('user_bg',$user_bg); + +assign('grp_thumbs',$grp_thumbs); +assign('cat_thumbs',$cat_thumbs); + +assign('db_size',formatfilesize(get_db_size())); + +template_files('reports.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/statistics.php b/upload/admin_area/statistics.php new file mode 100644 index 00000000..0e917d37 --- /dev/null +++ b/upload/admin_area/statistics.php @@ -0,0 +1,17 @@ +admin_login_check(); +$userquery->login_check('web_config_access'); + + +template_files('under_development.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/images/alert.png b/upload/admin_area/styles/cbv2/images/alert.png new file mode 100644 index 00000000..16aa3dd4 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/alert.png differ diff --git a/upload/admin_area/styles/cbv2/images/arrow_return.png b/upload/admin_area/styles/cbv2/images/arrow_return.png new file mode 100644 index 00000000..4792abf1 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/arrow_return.png differ diff --git a/upload/admin_area/styles/cbv2/images/arrow_return_invert.png b/upload/admin_area/styles/cbv2/images/arrow_return_invert.png new file mode 100644 index 00000000..390d0ef9 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/arrow_return_invert.png differ diff --git a/upload/admin_area/styles/cbv2/images/bgs/gr_bg.png b/upload/admin_area/styles/cbv2/images/bgs/gr_bg.png new file mode 100644 index 00000000..8b5c20a1 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bgs/gr_bg.png differ diff --git a/upload/admin_area/styles/cbv2/images/bgs/left_menu_head.png b/upload/admin_area/styles/cbv2/images/bgs/left_menu_head.png new file mode 100644 index 00000000..50f9016f Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bgs/left_menu_head.png differ diff --git a/upload/admin_area/styles/cbv2/images/bgs/login.png b/upload/admin_area/styles/cbv2/images/bgs/login.png new file mode 100644 index 00000000..13f414b6 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bgs/login.png differ diff --git a/upload/admin_area/styles/cbv2/images/bgs/pagination_bg.png b/upload/admin_area/styles/cbv2/images/bgs/pagination_bg.png new file mode 100644 index 00000000..e0ecd3c7 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bgs/pagination_bg.png differ diff --git a/upload/admin_area/styles/cbv2/images/bgs/round_bg.png b/upload/admin_area/styles/cbv2/images/bgs/round_bg.png new file mode 100644 index 00000000..1a2218a8 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bgs/round_bg.png differ diff --git a/upload/admin_area/styles/cbv2/images/bot.png b/upload/admin_area/styles/cbv2/images/bot.png new file mode 100644 index 00000000..81c30763 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/bot.png differ diff --git a/upload/admin_area/styles/cbv2/images/botal.png b/upload/admin_area/styles/cbv2/images/botal.png new file mode 100644 index 00000000..15ce9aec Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/botal.png differ diff --git a/upload/admin_area/styles/cbv2/images/browsers.png b/upload/admin_area/styles/cbv2/images/browsers.png new file mode 100644 index 00000000..60fb2a8e Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/browsers.png differ diff --git a/upload/admin_area/styles/cbv2/images/button_bg.png b/upload/admin_area/styles/cbv2/images/button_bg.png new file mode 100644 index 00000000..72b29bcc Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/button_bg.png differ diff --git a/upload/admin_area/styles/cbv2/images/button_ok.png b/upload/admin_area/styles/cbv2/images/button_ok.png new file mode 100644 index 00000000..bb8d3dc4 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/button_ok.png differ diff --git a/upload/admin_area/styles/cbv2/images/catgory_toggler.png b/upload/admin_area/styles/cbv2/images/catgory_toggler.png new file mode 100644 index 00000000..b9ecad8c Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/catgory_toggler.png differ diff --git a/upload/admin_area/styles/cbv2/images/collapse.png b/upload/admin_area/styles/cbv2/images/collapse.png new file mode 100644 index 00000000..3c289918 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/collapse.png differ diff --git a/upload/admin_area/styles/cbv2/images/cross.png b/upload/admin_area/styles/cbv2/images/cross.png new file mode 100644 index 00000000..27bf3f2b Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/cross.png differ diff --git a/upload/admin_area/styles/cbv2/images/dot.gif b/upload/admin_area/styles/cbv2/images/dot.gif new file mode 100644 index 00000000..35d42e80 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/dot.gif differ diff --git a/upload/admin_area/styles/cbv2/images/error.png b/upload/admin_area/styles/cbv2/images/error.png new file mode 100644 index 00000000..b28b24d2 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/error.png differ diff --git a/upload/admin_area/styles/cbv2/images/gradients.png b/upload/admin_area/styles/cbv2/images/gradients.png new file mode 100644 index 00000000..0ca2406f Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/gradients.png differ diff --git a/upload/admin_area/styles/cbv2/images/headerafter.png b/upload/admin_area/styles/cbv2/images/headerafter.png new file mode 100644 index 00000000..065355fb Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/headerafter.png differ diff --git a/upload/admin_area/styles/cbv2/images/help.png b/upload/admin_area/styles/cbv2/images/help.png new file mode 100644 index 00000000..3efe67ed Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/help.png differ diff --git a/upload/admin_area/styles/cbv2/images/icons.png b/upload/admin_area/styles/cbv2/images/icons.png new file mode 100644 index 00000000..0446d29c Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/icons.png differ diff --git a/upload/admin_area/styles/cbv2/images/loading.gif b/upload/admin_area/styles/cbv2/images/loading.gif new file mode 100644 index 00000000..2059c9af Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/loading.gif differ diff --git a/upload/admin_area/styles/cbv2/images/login.png b/upload/admin_area/styles/cbv2/images/login.png new file mode 100644 index 00000000..c10e3abd Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/login.png differ diff --git a/upload/admin_area/styles/cbv2/images/nicEditIcons-latest.gif b/upload/admin_area/styles/cbv2/images/nicEditIcons-latest.gif new file mode 100644 index 00000000..d1add6f1 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/nicEditIcons-latest.gif differ diff --git a/upload/admin_area/styles/cbv2/images/ok.png b/upload/admin_area/styles/cbv2/images/ok.png new file mode 100644 index 00000000..dec9a82e Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/ok.png differ diff --git a/upload/admin_area/styles/cbv2/images/play_icon.png b/upload/admin_area/styles/cbv2/images/play_icon.png new file mode 100644 index 00000000..95ed7d01 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/play_icon.png differ diff --git a/upload/admin_area/styles/cbv2/images/slide_toggle.png b/upload/admin_area/styles/cbv2/images/slide_toggle.png new file mode 100644 index 00000000..10e7949b Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/slide_toggle.png differ diff --git a/upload/admin_area/styles/cbv2/images/slide_toggle_2.png b/upload/admin_area/styles/cbv2/images/slide_toggle_2.png new file mode 100644 index 00000000..4b61217d Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/slide_toggle_2.png differ diff --git a/upload/admin_area/styles/cbv2/images/slide_toggle_3.png b/upload/admin_area/styles/cbv2/images/slide_toggle_3.png new file mode 100644 index 00000000..ecab7086 Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/slide_toggle_3.png differ diff --git a/upload/admin_area/styles/cbv2/images/tick.png b/upload/admin_area/styles/cbv2/images/tick.png new file mode 100644 index 00000000..a8dcaa8a Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/tick.png differ diff --git a/upload/admin_area/styles/cbv2/images/widget_item_border.gif b/upload/admin_area/styles/cbv2/images/widget_item_border.gif new file mode 100644 index 00000000..c920f41a Binary files /dev/null and b/upload/admin_area/styles/cbv2/images/widget_item_border.gif differ diff --git a/upload/admin_area/styles/cbv2/layout/_permission.html b/upload/admin_area/styles/cbv2/layout/_permission.html new file mode 100644 index 00000000..f42f0a6d --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/_permission.html @@ -0,0 +1,63 @@ +{assign var='types' value=$userquery->get_level_types()} +
+{section name=t loop=$types} + + + + + + +
 {$types[t].user_permission_type_name} 
+{assign var=perms value=$userquery->get_permissions($types[t].user_permission_type_id)} + +{assign var = bgcolor value = ""} +{foreach from=$perms item=perm} +{if $perm.permission_id !=""} + + + + + + + + + + + +{else} + +{/if} +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} +{foreachelse} + +{/foreach} +
{$perm.permission_id}{$perm.permission_name}{$perm.permission_code}{$perm.permission_desc}Delete
No Permission Found
No Permission Found
+
+
Add New Permission + +
+ + + + + + + + + + + + +
+
+
+{/section} +
\ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/add_group.html b/upload/admin_area/styles/cbv2/layout/add_group.html new file mode 100644 index 00000000..ae207f1f --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/add_group.html @@ -0,0 +1,66 @@ + + + + + + +
Add New Group  
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 * are required fields
Select User *
Group Title *
Group Description *

+ +
+

Group Tags *
Group Url * Only these characters are allowed. a-z, 0-9, hypen(-), underscore(_), period(.)
Group TypePublic
Private
Only Invited Members
Group Category * +
Group Thumb +
 
+
diff --git a/upload/admin_area/styles/cbv2/layout/add_members.html b/upload/admin_area/styles/cbv2/layout/add_members.html new file mode 100644 index 00000000..009aa3f8 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/add_members.html @@ -0,0 +1,58 @@ +{assign var='required_fields' value=$userquery->load_signup_fields()} +{assign var='custom_field' value=$userquery->custom_signup_fields} + +

Add New Member

+ + + + + + +
 Required Member Details 
+ +
+
+ User Information + + {foreach from=$required_fields item=field} + + + + + {/foreach} + + + + + + + + +
{if $field.hint_1}{$field.hint_1}
{/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_after}{if $field.hint_2}
{$field.hint_2}{/if}
Status +
+
+ + {if $custom_field} +
+ Other + + {foreach from=$custom_field item=field} + + + + + {/foreach} +
{if $field.hint_1}{$field.hint_1}
{/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_after}{if $field.hint_2}
{$field.hint_2}{/if}
+
+ {/if} + +
+
\ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/add_phrase.html b/upload/admin_area/styles/cbv2/layout/add_phrase.html new file mode 100644 index 00000000..16a8767a --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/add_phrase.html @@ -0,0 +1,48 @@ +

Add New Phrase

+
+ +
+ Adding new phrase + + + + + + + + + + + + + + + + + + + + + +
Phrase Code
Phrase Text
Language
  
+ +  
+
+


+ +To display this text in your template , simple add this where you want to display your text {$LANG.phrase_code}
+
+ diff --git a/upload/admin_area/styles/cbv2/layout/ads_add_placements.html b/upload/admin_area/styles/cbv2/layout/ads_add_placements.html new file mode 100644 index 00000000..df91920f --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/ads_add_placements.html @@ -0,0 +1,79 @@ +{if $Cbucket->show_page == true} + + + +
+ + + + + + +
 Add Placement  
+ + + + + + + + + + + + + + + + + + + + + + + +
 
 
+
+
+
+
+ + + Note: if you delete any placement, all ads under it will be deleted + +
+
+ +
+ + + + + + + + +
ID
PlacementName
PlacementCode
TotalAds
Action
+{section name=a_list loop=$ads_placements} +{if $ads_placements[a_list].placement_name !=''} + + + + + + + + +
{$ads_placements[a_list].placement_id}
{$ads_placements[a_list].placement_name}
{literal}{AD place={/literal}{$ads_placements[a_list].placement}{literal}}{/literal}
{$ads_placements[a_list].total_ads}
{if $ads_placements[a_list].disable == no}Remove{else}Default Placement{/if}
+ {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} +{/if} +{/section} + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/ads_manager.html b/upload/admin_area/styles/cbv2/layout/ads_manager.html new file mode 100644 index 00000000..f23623fb --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/ads_manager.html @@ -0,0 +1,163 @@ +{if $ad_data.ad_name !=''} + + + + + + + + + +
 Eid Advertisement 
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 all fields are required
 {$ad_data.ad_code|ad}
+ * + e.g Home Banner
+ Add More Placements
Status +
 
+
+
+
+{else} +{if $edit_ad != "show"} + + + + + + + + + +
 Add Advertisement 
+ + + + + + + + + + + + + + + + + + + + + + + + + +
 all fields are required
+ * + e.g Home Banner
+ Add More Placements
Status +
 
+
+
+ {/if} +
+

Advertisement Manager

+ + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +
+ + + + + + + + + + +
AID
Advertisment name
Advertisment
Impressions
Date Added
Placement
Actions
+
+ + {assign var='ads' value=$adsObj->get_advertisements()} + {if $ads} + {foreach item=ad from=$ads} + + + + + + + + + + {/foreach} + {/if} +
{$ad.ad_id}
{$ad.ad_name}
{$ad.ad_codes}View Advertisment
{$ad.ad_impressions|number_format}
{$ad.date_added|date_format}
{$adsObj->get_placement_name($ad.ad_placement)}
Edit | +Delete | {if $ad.ad_status!=1}Activate{else}Deactivate{/if}
+{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/blocks/access_log.html b/upload/admin_area/styles/cbv2/layout/blocks/access_log.html new file mode 100644 index 00000000..417d63b6 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/blocks/access_log.html @@ -0,0 +1,10 @@ + + + + +Untitled Document + + + + + diff --git a/upload/admin_area/styles/cbv2/layout/blocks/comments.html b/upload/admin_area/styles/cbv2/layout/blocks/comments.html new file mode 100644 index 00000000..c51c3ef0 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/blocks/comments.html @@ -0,0 +1,50 @@ +{assign var=bgcolor value =F2F2F2} +{if $comments} + + + + + + + + + + + +
CIDUIDUsernameEmailCommentDateVotes 
+
+{foreach from=$comments.comments item=comment} + + + + + + + + + + + + + {if $bgcolor == 'F2F2F2'} + {assign var=bgcolor value =FFF} + {elseif $bgcolor == 'FFF'} + {assign var=bgcolor value =F2F2F2} + {/if} + +{/foreach} +
{$comment.comment_id}{$comment.userid}{if $comment.anonym_name}{$comment.anonym_name}{else}{$comment.username}{/if}{if $comment.anonym_email}{$comment.anonym_email}{else}{$comment.email}{/if}
{$comment.comment}
{$comment.date_added|date_format}{$comment.vote}Delete
+
+{else} +
No User Comments
+{/if} + +{literal} + +{/literal} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/blocks/edit_video.html b/upload/admin_area/styles/cbv2/layout/blocks/edit_video.html new file mode 100644 index 00000000..97ab6b72 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/blocks/edit_video.html @@ -0,0 +1,194 @@ +{assign var='requiredFields' value=$Upload->loadRequiredFields($data)} +{assign var='optionFields' value=$Upload->loadOptionFields($data)} +{assign var='locationFields' value=$Upload->loadLocationFields($data)} + +{assign var='custom_fields' value=$Upload->load_custom_upload_fields($data,TRUE)} +{assign var='custom_form_fields' value=$Upload->load_custom_form_fields($data,TRUE)} + + +{if $data.title neq ""} + + + + + + + + + + + +
Editing {$data.title}  
+ +
+ + + + + +
+ +
+ + + + + +
+ User Information + + + + + +
Useid{$data.userid}
+
+ +
+ Important Details + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {foreach from=$requiredFields item=field} + + + + + {/foreach} + + + + + + + + + +
Video Id + +
Video Key + +
File Name + +
Referal URL
Total Video Files{get_all_video_files vdetails=$data count_only=true} - View File Details and Conversion Log
Total Thumbnails{get_thumb vdetails=$data count_only=true}
Thumbnails
+{if $data.embeded !=yes}Regenerate Thumbs{/if}
+ Manage Thumbs
{assign var=vidthumbs value=func->get_thumb($data,1,TRUE)} + + {foreach from=$vidthumbs item=vid_thumb} +
+
+ {if $vid_thumb|getname!='processing'} + Delete + {/if} +
+ {/foreach} + +
{$field.title} :{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +{$field.hint_2}
Status + +
Duration (seconds) + +seconds
+
+ + + +
+ Recording Details + + {foreach from=$locationFields item=field} + + + + + {/foreach} +
{$field.title} {$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +{$field.hint_2}
+
+ + + +
+ Sharing + + {foreach from=$optionFields item=field} + + + + + {/foreach} +
{$field.title} {$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
+ {$field.hint_2}
+
+ + + +
+ Custom Form Fields + + {foreach from=$custom_form_fields item=field} + + + + + {/foreach} +
{$field.title}{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
+ {$field.hint_2}
+
+ + +
+ Custom Upload Fields + + {foreach from=$custom_fields item=field} + + + + + {/foreach} +
{$field.title}{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
+ {$field.hint_2}
+
+
+ +
+
+{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/blocks/pagination.html b/upload/admin_area/styles/cbv2/layout/blocks/pagination.html new file mode 100644 index 00000000..e61558e9 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/blocks/pagination.html @@ -0,0 +1,5 @@ + diff --git a/upload/admin_area/styles/cbv2/layout/body.html b/upload/admin_area/styles/cbv2/layout/body.html new file mode 100644 index 00000000..16131c15 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/body.html @@ -0,0 +1,41 @@ +{include file="$style_dir/global_header.html" } + + +{include file="$style_dir/header.html" } +{include file="$style_dir/msg.html" } + +
+ +{if $smarty.cookies.admin_menu=='hide'} + {assign var='left_menu_class' value='left_menu_0'} + {assign var='contentcolumn_class' value='contentcolumn0'} +{else} + {assign var='left_menu_class' value='left_menu'} + {assign var='contentcolumn_class' value='contentcolumn'} +{/if} + +
+ + +{if $Cbucket->show_page} +
+
+
+ {foreach from=$template_files item=file} + {include_template_file file=$file} + {/foreach} +
+
+
+{/if} + + + + +{include file="$style_dir/left_menu.html" } + +
+
+{include file="$style_dir/footer.html" } + + \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/category.html b/upload/admin_area/styles/cbv2/layout/category.html new file mode 100644 index 00000000..9c395b88 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/category.html @@ -0,0 +1,179 @@ +Video Categories + + + + + + + + +
Manage Video Categories  
+ + +{if $edit_category != "show"} +
+ + + + + + + + + + + + + + + {assign var=useSubs value=func->config(use_subs)} + {if $useSubs == 1} + + + + + {/if} + + + + + + + + + + + + +
 * are required fields
Category Name*
Category Description*
Parent Category + {cbCategories output="dropdown" name="parent_cat" id="parent_cat" blank_option=TRUE echo=TRUE type="video"} +
Make Default Category

+ + +
+

Category Thumb +
 
+
+{/if} +{if $edit_category == "show"} +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
 * are required fields
Category Name*
Category Description*
Parent Category + {cbCategories output="dropdown" selected=$cat_details.parent_id name="parent_cat" id="parent_cat" blank_option=TRUE type="video" echo=TRUE} +
Make Default Category

+ + +
+

Category Thumb
+
+{/if} + + +
+Category List +
+ +{if $total != 0} +
+ + + + + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$category} + + + + + {if $category[list].parent_id == "0"} + {assign var=p_name value="None"} + {else} + {assign var=p_name value=$cbvid->get_category_field($category[list].parent_id,'category_name')} + {/if} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} + +
Category NameOrderParent CategoryDescriptionDefaultAction 
{$category[list].category_name} - View Thumb + {$p_name}{if $category[list].category_desc}{$category[list].category_desc}{else}N/A{/if}{$category[list].isdefault} +
  • Edit
  • +
  • Delete
  • + {if $category[list].isdefault!="yes"}
  • Make Default
  • {/if} +
     
    + + +
    +
    + +{else} +No Category Has Been Created Yet +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/cb_conversion_queue.html b/upload/admin_area/styles/cbv2/layout/cb_conversion_queue.html new file mode 100644 index 00000000..3fa22399 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/cb_conversion_queue.html @@ -0,0 +1,66 @@ +

    ClipBucket Queue Manager

    {if conv_lock_exists()}Delete Conversion Lock{/if} +
    +do not try to change the things here, can cause problems to your Clipbucket conversion system. + + + +
    + + + + + + +
    + + +
    + + + + + + + + + +
    + IDDetails 
    + +{if $queues} + +{foreach from=$queues item=queue} + + + + + + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} +{/foreach} +
    + + {$queue.cqueue_id} + + {$queue.cqueue_name} - + + File Type : {$queue.cqueue_ext} • + Temp Ext : {$queue.cqueue_tmp_ext} • + Conversion Process : {$queue.cqueue_conversion|conv_status} • + {if $queue.time_started} + Started : {"Y-m-d H:i:s"|date:$queue.time_started} • + {/if} + {if $queue.time_completed} + Completed : {"Y-m-d H:i:s"|date:$queue.time_completed} + {/if} +
    +{else} +
    No Conversion Queue File Found
    +{/if} +
    + +{include file="$style_dir/blocks/pagination.html" } \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/cb_mod_check.html b/upload/admin_area/styles/cbv2/layout/cb_mod_check.html new file mode 100644 index 00000000..063e10ed --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/cb_mod_check.html @@ -0,0 +1,94 @@ +

    Server Video Conversion Modules & Tools

    + +

    +A brief test to check weather server modules exist or not and what are there versions and paths +

    + + +
    + Modules and paths +
    + + +
    + + {check_module_path path='ffmpeg' get_path='true' assign='ffmpeg_status'} + FFMPEG +
    FFmpeg is used to covert videos from different versions to FLV , MP4 and many other formats. Learn more
    + + {if $ffmpeg_status.status=='ok'} + Version {$ffmpeg_status.version} • Expected Path {get_binaries path=ffmpeg type=server} + {else} + ffmpeg is not found + {if $ffmpeg_status.error} +
    {$ffmpeg_status.error} + {/if} + {/if} + +
    + + +
    + + {check_module_path path='php' get_path='true' assign='php_status'} + PHP CLI +
    PHP CLI is used to peform video conversion in a background process. + Learn more
    + + {if $php_status.status=='ok'} + Version {$php_status.version} • Expected Path {get_binaries path=php type=server} + {else} + php is not found + {if $php_status.error} +
    {$php_status.error} + {/if} + {/if} + +
    + + + +
    + + {check_module_path path='flvtool2' get_path='true' assign='flvtool2_status'} + FLVTool2 +
    FLVTool2 is a tool to repair FLV files to make them streamable + Learn more
    + + {if $flvtool2_status.status=='ok'} + Version {$flvtool2_status.version} • Expected Path {get_binaries path=flvtool2 type=server} + {else} + flvtool2 is not found + {if $flvtool2_status.error} +
    {$flvtool2_status.error} + {/if} + {/if} + +
    + + + +
    + + {check_module_path path='mp4box' get_path='true' assign='mp4box_status'} + MP4Box +
    MP4Box is a tool used to repair MP4 files to make them streamable + Learn more
    + + {if $mp4box_status.status=='ok'} + Version + {if $mp4box_status.version} + {$mp4box_status.version} + {/if} • Expected Path {get_binaries path=mp4box type=server} + {else} + Mp4box is not found + {if $mp4box_status.error} +
    {$mp4box_status.error} + {/if} + {/if} + +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/collection_category.html b/upload/admin_area/styles/cbv2/layout/collection_category.html new file mode 100644 index 00000000..a7adef70 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/collection_category.html @@ -0,0 +1,167 @@ +Collection Categories + + + + + + + + +
    Manage Collection Categories  
    + + +{if $edit_category != "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb +
     
    +
    +{/if} +{if $edit_category == "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb
    +
    +{/if} + + +
    +Category List +
    + +{if $total != 0} +
    + + + + + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$category} + + + + + {if $category[list].parent_id == "0"} + {assign var=p_name value="None"} + {else} + {assign var=p_name value=$cbvid->get_category_field($category[list].parent_id,'category_name')} + {/if} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} + +
    Category NameOrderParent CategoryDescriptionDefaultAction 
    {$category[list].category_name} - View Thumb + {$p_name}{if $category[list].category_desc}{$category[list].category_desc}{else}N/A{/if}{$category[list].isdefault} +
  • Edit
  • +
  • Delete
  • + {if $category[list].isdefault!="yes"}
  • Make Default
  • {/if} +
     
    + + +
    +
    + +{else} +No Category Has Been Created Yet +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/collection_manager.html b/upload/admin_area/styles/cbv2/layout/collection_manager.html new file mode 100644 index 00000000..d2f33510 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/collection_manager.html @@ -0,0 +1,160 @@ +

    Collection Manager

    + + + +
    + + + + + +
    + + + + + + +
    + + + + + + + + +
    + Collection IDDetails 
    + +{if $c} +{section name=list loop=$c} +
  • +
    +
    +
    +
    {$c[list].collection_id}
    +
    +
    + +
    +
    + {$c[list].collection_name} ({$c[list].total_objects} {$c[list].type}) +
    + + Featured:{$c[list].featured} • + Active:{$c[list].active} • + Type:{$c[list].type} • + Uploaded:{$c[list].date_added|niceTime} • + User:{$c[list].username} + + +
    +
    +
  • +{/section} +{else} +
    No Photo Found
    +{/if} + + + + + + +
    + + + + + + +
    +
    + +{include file="$style_dir/blocks/pagination.html" } \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/comments.html b/upload/admin_area/styles/cbv2/layout/comments.html new file mode 100644 index 00000000..c6e013e3 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/comments.html @@ -0,0 +1,151 @@ +Comments Manager +
    + + +
    + + + + + +
    + + + + +
    + + + + + + + + +
    + CIDComment 
    + +{if $comments} + + +{foreach from=$comments item=comment} + +{if $comment.anonym_name != ""} + {assign var=comment_owner value=$comment.anonym_name} +{else} + {assign var=comment_owner value=$userquery->get_user_details($comment.3)} +{/if} + + + + + + + +{/if} + +{if $type == 't'} + + {if is_array($comment_owner)} {$comment_owner.username} {else} {$comment_owner} {/if} commented on {$comment.date_added|date_format} on a topic named {$comment.topic_title|truncate:40} + +
    +{$comment.comment} + +{/if} + +{if $type == 'c'} + + {if is_array($comment_owner)} {$comment_owner.username} {else} {$comment_owner} {/if} commented on {$comment.date_added|date_format} on a channel named {$comment.username|truncate:40} + +
    +{$comment.comment} + + +{/if} + +{if $type == 'cl'} + + {if is_array($comment_owner)} {$comment_owner.username} {else} {$comment_owner} {/if} commented on {$comment.date_added|date_format} on a collection named {$comment.collection_name|truncate:40} + +
    +{$comment.comment} + + +{/if} + +{if $type == 'p'} + + {if is_array($comment_owner)} {$comment_owner.username} {else} {$comment_owner} {/if} commented on {$comment.date_added|date_format} on a photo named {$comment.photo_title|truncate:40} + +
    +{$comment.comment} + + +{/if} + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEE"} +{else} +{assign var = bgcolor value = ""} +{/if} +{/foreach} +
    {$comment.comment_id} + {if $type == '' || $type == 'v'} + + {if is_array($comment_owner)} {$comment_owner.username} {else} {$comment_owner} {/if} commented on {$comment.date_added|date_format} on a video named {$comment.title|truncate:40} + + +
    +{$comment.comment} + +
     
    +{else} +
    {lang code='no_comments'}
    +{/if} +
    +
    +{include file="$style_dir/blocks/pagination.html" } \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/conversion_lab.html b/upload/admin_area/styles/cbv2/layout/conversion_lab.html new file mode 100644 index 00000000..77251000 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/conversion_lab.html @@ -0,0 +1,86 @@ + +{literal} + +{/literal} + +

    Conversion lab - αlpha

    +
    +
    +Conversion environment for clipbucket users so they can test why their videos are not converting. +This test is in early beta stages, we are hopeful to get best outcome results.
    +
    +Current scientists : Arslan Hassan
    +Current version : 1.0 α
    + +Choose your victim + + + + + + +
    + +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/edit_announcemnent.html b/upload/admin_area/styles/cbv2/layout/edit_announcemnent.html new file mode 100644 index 00000000..43a11842 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/edit_announcemnent.html @@ -0,0 +1,18 @@ +

    Edit Announcement

    + + + + +
    +
    + Announcement
    + + + +
    + +
    diff --git a/upload/admin_area/styles/cbv2/layout/edit_collection.html b/upload/admin_area/styles/cbv2/layout/edit_collection.html new file mode 100644 index 00000000..79d6e5af --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/edit_collection.html @@ -0,0 +1,135 @@ +{assign var=requiredFields value=$cbcollection->load_required_fields($data)} +{assign var=otherFields value=$cbcollection->load_other_fields($data)} + +
    + + + + + +
    + + + + + +
    Editing {$data.collection_name}
     
    +
    + +
    + + +
    + User Information + + + + + +
    Useid{$data.userid|get_username}
    +
    + +
    + Collection Details + + + + + + {foreach from=$requiredFields item=field} + + + + + {/foreach} +
    Collection ID
    {$field.title} :{$field.hint_1}
    + {$formObj->createField($field)}
    + {$field.hint_2}
    +
    +
    + Collection Stats + + + + + + + + + +
    Total Objects
    Total Comments
    +
    + +
    + + + + + + + + +
    Items
     
    + {if $objects} + {section name=list loop=$objects} + {if $data.type == 'photos'} +
    + {get_photo details=$objects[list] output='html' title=$photos[list].photo_title} +
    + {/if} + + {if $data.type == 'videos'} +
    + +
    + {/if} + {/section} +
    + {assign var=rest value=$data.total_objects-4} + Manage Items{if $rest && $rest>0} - {$rest} more item{if $rest>1}s{/if}{/if} + {else} +
    Collection has 0 items
    + {/if} +
    +
    + Other Fields + + {foreach from=$otherFields item=field} + + + + + {/foreach} +
    {$field.title} :{$field.hint_1}
    + {$formObj->createField($field)}
    + {$field.hint_2}
    +
    + +
    + Collection Preview + + + + + + + + + +
    Collection Preview : +
    Upload New :
    +
    +
    +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/edit_group.html b/upload/admin_area/styles/cbv2/layout/edit_group.html new file mode 100644 index 00000000..c468037b --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/edit_group.html @@ -0,0 +1,108 @@ +

    Edit Group

    + +{* Loading Form Fields *} +{assign var='requiredFields' value=$cbgroup->load_required_fields($group,true)} +{assign var='optionFields' value=$cbgroup->load_other_fields($group)} + + + + + + + +
     Editing {$group.title} 
    + + + +
    + + +
    + Thumbs +
    + +
    +
    +
  • {$LANG.grp_must_be} JPG | GIF | PNG
  • +
  • {$LANG.grp_90x90}
  • +
  • {$LANG.grp_thumb_warn}
  • + +
    +
    +
    + + +
    + Required Details + + {foreach from=$requiredFields item=field} + + + + + {/foreach} +
    {$field.title} {if $field.hint_1}{$field.hint_1}
    {/if} +{if $field.anchor_before}{ANCHOR place=$field.anchor_before}
    {/if} +{$formObj->createField($field)}
    + +{$field.hint_2}
    +
    + + + + + +
    + Group Stats + + + + + + + + + + + + + + + + + + + + + + + + +
    Total Views +
    Total Members +
    Total Videos +
    Total Topics +
      
    +
    + + +
    + Other Details + + {foreach from=$optionFields item=field} + + + + + {/foreach} +
    {$field.title} {if $field.hint_1}{$field.hint_1}
    {/if} +{if $field.anchor_before}{ANCHOR place=$field.anchor_before}
    {/if} +{$formObj->createField($field)}
    + +{$field.hint_2}
    +
    + +
    + +
    +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/edit_photo.html b/upload/admin_area/styles/cbv2/layout/edit_photo.html new file mode 100644 index 00000000..ace79ed8 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/edit_photo.html @@ -0,0 +1,150 @@ +
    + + + + + + +
    + + + + + +
    Editing {$data.photo_title}
     
    +
    + +
    + + + + +
    + User Information + + + + + +
    Useid{$data.userid|get_username}
    +
    + +
    + Important Details + + + + + + + + + + + + + + + + + +
    Photo ID + +
    Photo Key + +
    Filename + +
    Extension + +
    +
    + +
    + Photo Details + + {foreach from=$requiredFields item=field} + + + + + {/foreach} +
    {$field.title} :{$field.hint_1}
    + {$formObj->createField($field)} + {$field.hint_2}
    +
    + +
    + Photo Stats + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Views:
    Total Favorites:
    Total Comments:
    Total Downloads:
    Rating:
    Rated By:
    Voters:
    +
    + +
    + + + + + +
    Photo Preview
     
    +
    +
    {get_photo details=$data size='l' output='html' style='max-width:600px'}
    +
    + +
    + Other Fields + + {foreach from=$otherFields item=field} + + + + + {/foreach} +
    {$field.title} :{$field.hint_1}
    + {$formObj->createField($field)} + {$field.hint_2}
    +
    +
    + + +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/edit_video.html b/upload/admin_area/styles/cbv2/layout/edit_video.html new file mode 100644 index 00000000..1337604e --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/edit_video.html @@ -0,0 +1,216 @@ + +{assign var='custom_upload_fields' value=$Upload->load_custom_upload_fields($data,TRUE)} +{assign var='video_fields' value=$Upload->load_video_fields($data)} + +{if $data.title neq ""} + + +
    + + + + + + + + + + + + +
    + + + + + +
    Editing {$data.title}
     
    + +
    + + + +
    + + + + + + +
    + User Information + + + + + +
    Useid{$data.userid|get_username}
    +
    + +
    + Important Details + + + + + + + + + + + + + + + + + + + + + + + + + + + + {foreach from=$requiredFields item=field} + {/foreach} + + + + + + + + + +
    Video Id + +
    Video Key + +
    File Name + +
    Total Video Files{get_all_video_files vdetails=$data count_only=true} - View File Details and Conversion Log
    Total Thumbnails{get_thumb vdetails=$data count_only=true}
    Thumbnails
    +{if $data.embeded !=yes}Regenerate Thumbs{/if}
    + Manage Thumbs
    {assign var=vidthumbs value=func->get_thumb($data,1,TRUE,FALSE,TRUE,FALSE)} + + {foreach from=$vidthumbs item=vid_thumb} +
    +
    + {if $vid_thumb|getname!='processing'} + Delete + {/if} +
    + {/foreach} + +
    Status + +
    Duration (seconds) + +seconds
    +
    + + +
    + Video Stats + + + + + + + + + + + + + +
    Views
    Rating + of 10
    RatedBy
    +
    +
    + Custom Upload Fields + + {foreach from=$custom_upload_fields item=field} + + + + + {/foreach} +
    {$field.title}{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
    + {$field.hint_2}
    +
    + + + + + + + + + + + + +
    + +
    + + +
    + + + + +
    Viewing {$data.title}
     
    +
    + + {FlashPlayer vdetails = $data width='100%' autoplay='false'} + +
    + + {foreach from=$video_fields item=field_group} +
    + {$field_group.group_name} + + {foreach from=$field_group.fields item=field} + + + + + {/foreach} +
    {$field.title} {if $field.hint_1}{$field.hint_1}
    {/if} + {$formObj->createField($field)} + {if $field.hint_2}
    {$field.hint_2}{/if}
    +
    + {/foreach} + + +
    {assign var=id value=$data.videoid}{include file="$style_dir/blocks/comments.html" type=v id=$data.videoid link="video=$id"}
    +
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/editor_pick.html b/upload/admin_area/styles/cbv2/layout/editor_pick.html new file mode 100644 index 00000000..8829f382 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/editor_pick.html @@ -0,0 +1,71 @@ +Editor's Pick + +
    + + + + + +
    + + + +
    + + + + + + + +
    + OrderDetails 
    + + + +{assign var = bgcolor value = ""} +{section name=list loop=$videos} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    + + {$videos[list].title} + Remove from editor's pick— + + Featured:{$videos[list].featured} • + Active:{$videos[list].active} • + Status:{$videos[list].status} + +
    + +
     
    + + + + + +
    + + +
    +
    + + diff --git a/upload/admin_area/styles/cbv2/layout/email_settings.html b/upload/admin_area/styles/cbv2/layout/email_settings.html new file mode 100644 index 00000000..3c11dc9d --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/email_settings.html @@ -0,0 +1,102 @@ +

    Email Settings

    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    + Select Mailer Type php Mail() or SMTP
    +

    +
    If using smtp, please enter its server
    +

    + if using smtp, Set SMTP server port
    +

    + if using smtp, please enter SMTP username
    +

    + Enter SMTP password
    +
    SMTP Auth
    + Enable SMTP Authentication +
      
      
    +
    +
    + +
    +
    +

    Email Templates Settings

    + +
    + +
    +{assign var=templates value=$cbemail->get_templates()} + +{if $templates}
    +
      + + {foreach from=$templates item=template name=etemp} +
    • {$template.email_template_name}
    • + {/foreach} + +
    +
    + {foreach from=$templates item=template name=etemp} + + {/foreach} +
    +
    +{/if} +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/flagged_groups.html b/upload/admin_area/styles/cbv2/layout/flagged_groups.html new file mode 100644 index 00000000..af3a2b0b --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/flagged_groups.html @@ -0,0 +1,148 @@ + +{if $mode=='view'} +Flagged Groups Manager + +
    + + + + + + +
    + + + + + + +
    + + + + + + + + + +
    + GP-IDDetails 
    + + + + + + +{assign var = bgcolor value = ""} +{section name=gp_list loop=$groups} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$groups[gp_list].group_id} +
    + +
    + + {$groups[gp_list].group_name} + — + + Group Owner: {$groups[gp_list].userid|get_username} • + Group Type: {if $groups[gp_list].group_privacy =="0"}Public{elseif $groups[gp_list].group_privacy =="1"}Private{else}Invited{/if} • + Group Status:{if $groups[gp_list].active=="yes"} Active{else}Inactive{/if} • + Group Members:{$groups[gp_list].total_members|number_format} • + Flags:{$groups[gp_list].total_flags} + + +
    + +
     
    + + + + + + + +
    + + + + + + +
    + +
    + + +{include file="$style_dir/blocks/pagination.html" } + +{/if} + + +{if $mode=='view_flags'} + +Viewing {$group.group_name} flagsView GroupEdit GroupDelete FlagsDelete Group +
    + +
    + + + + + + + + +
     Flag Details 
    + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$flags} + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$smarty.section.list.iteration}Reported as "{$flags[list].flag_type|flag_type}" by {$flags[list].userid|get_username} {$flags[list].date_added|niceTime} 
    +
    + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/flagged_photos.html b/upload/admin_area/styles/cbv2/layout/flagged_photos.html new file mode 100644 index 00000000..ddae5016 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/flagged_photos.html @@ -0,0 +1,105 @@ +{if $mode == 'view'} +Flagged Photos Manager +
    + + + + + +
    + + + + +
    + + + + + + + + +
    + Photo-IDDetails 
    + +{if $photos} +{section name=list loop=$photos} +
  • +
    +
    +
    + +
    {$photos[list].photo_id}
    +
    +
    + {get_photo details=$photos[list] id='photo' style='padding:2px; border:1px solid #ccc' output='html'} +
    +
    + {$photos[list].photo_title} +
    + + Featured:{$photos[list].featured} • + {if $photos[list].collection_id} + Collection:{$photos[list].collection_id|get_collection_field} + {else} + Photo is Orphan + {/if} • + Uploaded:{$photos[list].date_added|niceTime} • + Uploader:{$photos[list].userid|get_username} • + Flag: {$photos[list].total_flags} + +
    + +
    +
    +
  • +{/section} +{else} +
    No Flags Found
    +{/if} + + + + + + +
    + + + + +
    + +
    + +{include file="$style_dir/blocks/pagination.html" } +{/if} + +{if $mode == 'view_flags'} +Viewing {$photo.photo_title} flagsView PhotoEdit PhotoDelete FlagsDelete Photo +
    +
    + + + + + + +
     Flag Details 
    + +{section name=list loop=$flags} +
  • +
    {$smarty.section.list.iteration}
    +
    + Reported as "{$flags[list].flag_type|flag_type}" by {$flags[list].userid|get_username} {$flags[list].date_added|niceTime} +
    +
  • +{/section} +
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/flagged_users.html b/upload/admin_area/styles/cbv2/layout/flagged_users.html new file mode 100644 index 00000000..a924b654 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/flagged_users.html @@ -0,0 +1,155 @@ + +{if $mode=='view'} +Flagged Users Manager + +
    + + + + + + +
    + + + + + + +
    + + + + + + + + +
    + UIDUser Details 
    + + + +{if $users} + + +{foreach from=$users item=u} + + + + + + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} +{/foreach} + + + + + + + + +
    {$u.userid} +
    + + {$u.username} + — + Email:{$u.email} • + Status:{$u.usr_status} • + Level:{$u.level|get_user_level} • + Last Active:{$u.last_active} + + +
    + +
     
    + + + + + +{else} +
    NO USER FOUND
    +{/if} + + + + + + + +
    + + + + + + +
    + +
    + + +{include file="$style_dir/blocks/pagination.html" } + +{/if} + + +{if $mode=='view_flags'} + +Viewing {$user.username} flagsView UserEdit UserDelete FlagsDelete User +
    + +
    + + + + + + + + +
     Flag Details 
    + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$flags} + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$smarty.section.list.iteration}Reported as "{$flags[list].flag_type|flag_type}" by {$flags[list].userid|get_username} {$flags[list].date_added|niceTime} 
    +
    + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/flagged_videos.html b/upload/admin_area/styles/cbv2/layout/flagged_videos.html new file mode 100644 index 00000000..36f1da63 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/flagged_videos.html @@ -0,0 +1,136 @@ + +{if $mode=='view'} +Flagged Videos Manager + +
    + + + + + + +
    + + + + + + +
    + + + + + + + + + +
    + VID
    Details
     
    + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$videos} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$videos[list].videoid} + + {$videos[list].title} + — + + Active:{$videos[list].active} • + Status:{$videos[list].status} • + Flags:{$videos[list].total_flags} + + +
    + +
     
    + + + + + + + +
    + + + + + + +
    + +
    + + +{include file="$style_dir/blocks/pagination.html" } + +{/if} + + +{if $mode=='view_flags'} +Viewing {$video.title} flagsView videoEdit videoDelete FlagsDelete Video +
    + +
    + + + + + + + + +
     Flag Details 
    + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$flags} + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$smarty.section.list.iteration}Reported as "{$flags[list].flag_type|flag_type}" by {$flags[list].userid|get_username} {$flags[list].date_added|niceTime} 
    +
    + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/footer.html b/upload/admin_area/styles/cbv2/layout/footer.html new file mode 100644 index 00000000..8714d90f --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/footer.html @@ -0,0 +1,7 @@ +
    + \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/global_header.html b/upload/admin_area/styles/cbv2/layout/global_header.html new file mode 100644 index 00000000..50853a31 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/global_header.html @@ -0,0 +1,217 @@ + + + + +{cbtitle sub_sep='›'} + + + + + + +{if $googleApi} + + + +{else} + + +{/if} + + + + + + + + + + + + + + + + +{if $Cbucket->AdminJSArray} + +{foreach from=$Cbucket->AdminJSArray key=file item=type} + {if $curActive == $type || $type=='global' } + {include_js type=$type file=$file} + {/if} +{/foreach} + +{/if} + +{if $Cbucket->admin_header_files} + + {foreach from=$Cbucket->admin_header_files key=file item=type} + {include_header type=$type file=$file} + {/foreach} + +{/if} + + + + + +{literal} + + +{/literal} + +{literal} + +{/literal} + \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/group_category.html b/upload/admin_area/styles/cbv2/layout/group_category.html new file mode 100644 index 00000000..f91e50df --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/group_category.html @@ -0,0 +1,158 @@ +Group Categories + + + + + + +
    Manage Group Categories  
    + + +{if $edit_category != "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb +
     
    +
    +{/if} +{if $edit_category == "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb
    +
    +{/if} + + +
    +Category List +
    + +{if $total != 0} +
    + + + + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$category} + + + + + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} + +
    Category NameOrderDescriptionDefaultAction 
    {$category[list].category_name} - View Thumb + {if $category[list].category_desc}{$category[list].category_desc}{else}N/A{/if}{$category[list].isdefault} +
  • Edit
  • +
  • Delete
  • + {if $category[list].isdefault!="yes"}
  • Make Default
  • {/if} +
     
    + + +
    +
    +{else} +No Category Has Been Created Yet +{/if} +
    +
    + + diff --git a/upload/admin_area/styles/cbv2/layout/groups_manager.html b/upload/admin_area/styles/cbv2/layout/groups_manager.html new file mode 100644 index 00000000..a0656c9d --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/groups_manager.html @@ -0,0 +1,153 @@ +Groups Manager + + + + + + + +
    + + + + + + +
    + + + + + + +
    + + + + + + + + + +
    + GP-IDDetails 
    + + + + + + +{assign var = bgcolor value = ""} +{section name=gp_list loop=$groups} + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$groups[gp_list].group_id} +
    + +
    + + {$groups[gp_list].group_name} + — + + Group Owner: {$groups[gp_list].userid|get_username} • + Group Type: {if $groups[gp_list].group_privacy =="0"}Public{elseif $groups[gp_list].group_privacy =="1"}Private{else}Invited{/if} • + Group Status:{if $groups[gp_list].active=="yes"} Active{else}Inactive{/if} • + Group Members:{$groups[gp_list].total_members|number_format} + + +
    + +
     
    + + + + + + + +
    + + + + + + +
    + +
    + +{include file="$style_dir/blocks/pagination.html" } diff --git a/upload/admin_area/styles/cbv2/layout/header.html b/upload/admin_area/styles/cbv2/layout/header.html new file mode 100644 index 00000000..f338a4e0 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/header.html @@ -0,0 +1,23 @@ +
    + {$title} +
    + Hello {$userquery->username} +
    +
    + + +
    +
    +
    + Results Per Page : + + +
    +
    +
    diff --git a/upload/admin_area/styles/cbv2/layout/index.html b/upload/admin_area/styles/cbv2/layout/index.html new file mode 100644 index 00000000..b183c6ad --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/index.html @@ -0,0 +1,200 @@ + + + + + + + +
    + +
    + + +
    +

    {$title} Quick Stats

    +
    +
    +
    Videos
    +
    Total : {get_videos count_only=yes} | Active : {get_videos count_only=yes active="yes"} | Flagged : {$cbvid->action->count_flagged_objects()} | Processing : {get_videos count_only=yes status='Processing'}
    +
    + +
    +
    Groups
    +
    Total : {get_groups count_only=yes} | Active : {get_groups count_only=yes active='yes'} | Flagged : {$cbgroup->action->count_flagged_objects()}
    +
    + +
    +
    Members
    +
    Total : {get_users count_only=yes} | Active : {get_users count_only=yes status='Ok'} | Flagged : {$userquery->action->count_flagged_objects()} | Banned : {get_users count_only=yes ban='yes'}
    +
    + + + +
    +
    Photos
    +
    Total : {get_photos count_only=yes} | Active : {get_photos count_only=yes active='yes'} | Flagged : {$cbphoto->action->count_flagged_objects()}
    +
    + + + +
    +
    Collections
    +
    Total : {get_collections count_only=yes} | Active : {get_collections count_only=yes active='yes'} + | Flagged : {$cbcollection->action->count_flagged_objects()} + | Videos : {get_collections count_only=yes type='videos'} | Photos : {get_collections count_only=yes type='photos'} +
    +
    + + +
    + {assign var=users value=$userquery->get_online_users()} + Online Users({$userquery->get_online_users(false,true)})
    + + {if $users} + {foreach from=$users item=user name=onlines} + {if $user.username!=""} + {$user.username}{if $user.logins>1}({$user.logins}){/if}{if !$smarty.foreach.onlines.last}, {/if} {/if} + {/foreach} + + + {foreach from=$users item=user name=onlines} + {if $user.session_string=='guest'} + and {$user.logins} guest{if $user.logins>1}s{/if} + {/if} + {/foreach} + + {else} + No User is Online + {/if} + + +
    + +
    + {if $Cbucket->cbinfo.new_available} +
    Currently you are running {$ClipBucket->cbinfo.version} {$ClipBucket->cbinfo.state}
    +Latest Version {$Cbucket->cbinfo.latest.version} {$Cbucket->cbinfo.latest.state}
    + +
    + {else} +
    + Currently you are running {$Cbucket->cbinfo.version} {$Cbucket->cbinfo.state} - No New Version Available
    + {/if} +
    +
    +
    + + +
    +

    ClipBucket News

    +
    +
    +
    +
    + +
    +
    +

    Words from ClipBucket!

    +

    ClipBucket is developed by Arslan Hassan and Fawaz Tahir, we started with a small website application with only functionality of serving videos to the community later on we decided to add every possible social networking feature to make social communities more interactive. We didn't have any milestones, no road map, no charts, no nothing. Only thing we had was a vision as of our captain Jahanzeb Hassan and plenty of hard work.

    +

    We also have two more members named Ruman Malik and Zomail Tahir who manage sales and support department.

    +

    ClipBucket team gives special thanks to
    +
    + * Frank White for helping us knowing the basics of professional application development
    + * Christian Russemen for keep our community active
    + * BigStack for his great forum support +
    + * You for using ClipBucket.

    +

    What lies head?

    +

    * Easy ClipBucket integeration with other applications
    + * Make more secured, fast and optimized
    + * HTML5 ready with mobile support
    + * Full documentation of our source code +

    +

    Where in the world we belong to?

    +

    We belong to Islamic Republic of Pakistan :) you may have seen many negative news about Pakistan on television but there are still some facts you should know about. Its a great country for us and we will always love it.
    + Pakistan Zindabad
    +
    +

    +
    + +
    + + + +
    + + + + + + + + + + + +
    +

    Personal Notes

    +
    + {assign var=notes value=$myquery->get_notes()} + +
    + {if $notes} +
    + {foreach from=$notes item=note} +
    + + {$note.note|nl2br} +
    + {/foreach} + {else} +
    No notes
    + {/if} +
    +
    + + +
    +
    +
    + + + +
    + + +
    + + + \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/language_settings.html b/upload/admin_area/styles/cbv2/layout/language_settings.html new file mode 100644 index 00000000..5ec0dba6 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/language_settings.html @@ -0,0 +1,113 @@ +{if $edit_lang != 'yes'} +

    Language Settings

    + + + + + + +
    ID
    Default
    Language
    + +
    +{section name=l_list loop=$language_list} +
    + + + + + + +
    {$language_list[l_list].language_id}{$language_list[l_list].language_name}({$language_list[l_list].language_code}) +
    Recreate Pack + - Recreate from pack + - Edit Phrases + - Edit + - Delete + - Export{if $language_list[l_list].language_active!='yes'} + - Activate{/if}{if $language_list[l_list].language_active=='yes'} + - Dectivate{/if}
    +
    +{/section} +
    + +
    +

    Add New Language

    +
    +
    + Upload file + + + + +
    Browse ClipBucket Language File ( must be .xml format ) + +
    +
    +
    +{else} +Edit {$lang_details.language_name} + + + +
    + +
    +Editing {$lang_details.language_name} Phrases + +
    + +
    + + + + + + + + + + + +
    Phrase CodePhrase
    + +{section name=p_list loop=$lang_phrases} +
    + + + + + + + +
    {$lang_phrases[p_list].varname}
    {$lang_phrases[p_list].text}
    +
    +{/section} + + +{include file="$style_dir/blocks/pagination.html" } + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/left_menu.html b/upload/admin_area/styles/cbv2/layout/left_menu.html new file mode 100644 index 00000000..fd7d411a --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/left_menu.html @@ -0,0 +1,25 @@ + +
    + +Toggle Menu +Toggle Menu + + +{assign var='menu' value = $Cbucket->AdminMenu} +{foreach from=$menu key=name item=menu} + +
    +
    {$name}
    +
    + +
    +
    + +{/foreach} + +
    + \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/login.html b/upload/admin_area/styles/cbv2/layout/login.html new file mode 100644 index 00000000..ebc45f3b --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/login.html @@ -0,0 +1,41 @@ + + +
    + {$title} — Back To Main Website +
    +
    + +{include file="$style_dir/msg.html" } + +
    +
    +
    + + + + + + + + + + + + + + + + +
    + +
    + +
    +
    +
    +
    + + + diff --git a/upload/admin_area/styles/cbv2/layout/main.html b/upload/admin_area/styles/cbv2/layout/main.html new file mode 100644 index 00000000..25769db8 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/main.html @@ -0,0 +1,1188 @@ + +
      +
    • Website Settings
    • +
    • Uploading and Conversion Settings
    • +
    • Display and Listing Settings
    • +
    • User Settings & registration
    • +
    +
    + +
    + + +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Website title
    Website slogan
    Website closed
    Closed message
    Meta Description
    Meta Keywords
    SEO Urls
    Allow template change
    Allow language change
    Date Format +
    Default Time Zone + +
    + +
    Use Sub-Categories
    Collpase Category Checkboxes + If selected YES, Categories shown while uploading video will be collapsed. +
      
    Emails
    Website Email
    Support Email
    Send Comment Notification + +
    Send Video Approve Noticfication
      
    Comments
    Allow Channel Comments
    Allow Guests to Comment
    Allow comments rating
    Comments Captcha

    + + + + + +
    +

      
    Videos
    Enable video section +
    Enable facebook embed +
    Allow video download
    Max categories for each video
    Category x + + x + +
    Embed type +
    Seo video url pattern + +
    + +
    + +
    + +
      
    Channels
    Enable channels +
      
    Groups
    Enable group section +
    Group Thumb Height
    Group Thumb Width
    Group Max Title
    Group Max Description
    Max group topic name
    Max group topic content
    Max categories for each group
      
    Photos
    Enable photos +
      
    General
    Enable Collections +
    + Allow videos ratings + + - + + Allow user to rate own videos
    + Allow collection ratings + + - + + Allow user to rate own collections
    + Allow channel ratings + + - + + Allow users to rate own channels
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Upoad Options + {foreach from=$opt_list item=opt} + {assign var=uploadOptId value=$opt.load_func} + + {/foreach} +
    Use Crons + + + +
    FFMPEG Path + +
    + Turn on VF + + +
    PHP Path + +
    MP4Box Path + +
    Flvtool2 Path + +
    Mplayer Path +
    Flvtool++ Path +
      
    Turn on Quick Conversion + +
    Server Friendly Conversion + +
    Max Video Processes at once
    Max time wait after max processes
      
    Allowed extensions
    Max upload file size + in MegaBytes
    + Default PHP Max Upload size is {$upload_max_size} and Post max size is {$post_max_size}, if you set max upload file size larger than this, it will be override by default, however, if set lower than default, it will work fine.
    Max upload duration + in minutes
    Save original file
    Mp4 HQ Output +
    Keep Mp4 As Is +
    Activation required
      
    Video Upload Form Settings
    Min - Max Video title + - +
    Min - Max Video Description +- +
    Min - Max Video Tags +- +
      
     
    Conversion Settings
    Normal video resolution + + +
    HQ video resolution
    Thumb Width
    Thumb Height
    Number of thumbs
    Big Thumb Width
    Big Thumb Height
      
    Change only if you have good knowledge of video conversion
    Select profile +
    Video Codec
    Audio Codec
    Video Rate
    Video Bitrate
    Audio Rate
    Audio Bitrate
      
    +
    +
    + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Current Templatemanage templates
    Current FLV Playermanage flv players
      
    Main Settings
    Use cached pagination
    Pagination chaching time + in minutes
      
    Videos Listing
    Videos Page + - 'videos' page
    Channel Page + - 'view channel' page
    User Videos + - 'user videos' page
    User Favorite + - 'user favorits' page
    Group Page + - videos display in view group page
    Home Tabs + - videos display in home tab
    Search Page + - videos display in search page
    Video Columns + - videos display in right columns ie (Random, Related etc)
      
    Photos Listing
    We use this limit in most of place where photo is displayed like, My Account, Manage Photos, Manage Favotires Photos etc.
    Number of photos to display on Homepage.
    Number of photos to display on Search page.
    Number of photos to display on User's page.
    Number of photos to display on User's photos page.
    Number of photos to display on User's favorites page.
    Use anywhere you want.
      
    Collection Listing
    Number of collections to display on Collections page.
    Number of collections to display on Homepage.
    Number of items to display in a Collection.
    Number of collections to display on Homepage.
    Number of collections to display on Channel page.
    Number of collections to display on User's collection page.
    Number of collections to display on User's favorite page.
      
    Users Listing
    User list per page + - 'users' page
    Subscribers in channel view + - subscribers in view channel page
    Subscriptions in channel view + - subscriptions in view channel page
    Users contacts in channel view + - users contacts in view channel
    View Group Page + - users in view group page
    Search Page + - users in search page
      
    Groups
    Groups Page + - 'groups' page
    Search Page + - groups in search page
      
    General
    Search results per page + - other search results
    Recently viewed videos + - recently viewed videos
    Comments per page
      
    +
    +
    + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Anonymous UserID +
    Turn on registrations
    Email verification
    Image verification (captcha)
    Username maximum characters
    Disallowed usernames
    Allow Special Characters in usernames
    Allow spaces in usernames
    Minimum Username Length
    Maximum Username Length
    Minimum age for registration + leave blank to disable this option
      
    Profile Pictures & Background
    Use Gravatars
    Max Porfile Pic Size + KBs
    Max Porfile Pic Dimension + Pixels
    Allow Picture URL +
    Allow Picture Upload
    Max Background Size + KBs
    Max Background Dimension + Pixels
    Allow Background URL
    Allow Background Upload
    Allow Background Color
    +
    +
    +
    +
    +
    +
    diff --git a/upload/admin_area/styles/cbv2/layout/maintenance.html b/upload/admin_area/styles/cbv2/layout/maintenance.html new file mode 100644 index 00000000..0806ec37 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/maintenance.html @@ -0,0 +1,58 @@ +Website Maintenance +
    +Remove inactive sessions, user access logs, comments cache, more options will be available soon +
    + + + +{if $smarty.get.mode =='remove_activity_feed'} + {if $indexing} +
    {$from} - {$to} of {$total}
    +
      + {foreach from=$index_msgs item=themsg} +
    • {$themsg}
    • + {/foreach} +
    + {if $stop_loop!='yes'} + + redirecting....do not close this window + {else} + Indexing has been completed. + {/if} + {/if} +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/manage_items.html b/upload/admin_area/styles/cbv2/layout/manage_items.html new file mode 100644 index 00000000..a6b9abe4 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/manage_items.html @@ -0,0 +1,115 @@ +

    Manage Items - {$data.collection_name}

    +
    + + + + + +
    + + + +
    +
    + + + + + + + + +
    + Object IDDetails 
    +{if $obj} +{if $type == ''} +
    Unknown Type
    +{else} +{if $type == 'photos'} +
  • +
    + Re-create photos. This will re-create photos found in the collection. +
    +
  • +{/if} +{section name=list loop=$obj} + {if $type == 'photos'} +
  • +
    +
    +
    +
    {$obj[list].photo_id}
    +
    +
    + +
    +
    + {$obj[list].photo_title} +
    + + Featured:{$obj[list].featured} • + Collection:{$obj[list].collection_id|get_collection_field} • + Uploaded:{$obj[list].date_added|niceTime} • + User:{$obj[list].username} + +
    + +
    +
    +
  • + {/if} + + {if $type == 'videos'} +
  • +
    +
    +
    +
    {$obj[list].videoid}
    +
    +
    + +
    +
    + {$obj[list].title} +
    + + Featured:{$obj[list].featured} • + Active:{$obj[list].active} • + Uploaded:{$obj[list].date_added|niceTime} • + User:{$obj[list].username} + +
    + +
    +
    +
  • + + {/if} +{/section} +{/if} +{else} +
    No Object Found
    +{/if} + + + + + +
    + + +
    +
    +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/manage_pages.html b/upload/admin_area/styles/cbv2/layout/manage_pages.html new file mode 100644 index 00000000..71ae23ac --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/manage_pages.html @@ -0,0 +1,197 @@ + +Manage Pages + +{if $mode =="new"} +
    +
    + Add New Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
     
    +
     
    +
    +
    +
    +{/if} + + + + + +{if $mode =="edit" && $page.page_name!=''} +
    +
    + Add New Page + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
     
     
    +
     
    +
    +
    +
    +{/if} + + + + +{if $mode=='manage'} +
    + + + + + + +
    + + + + + +
    + + + + + + + + + + + +
    + PIDOrder
    Details
     
    + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$cbpages} + + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$cbpages[list].page_id} + + {$cbpages[list].page_name} + — + + Active:{$cbpages[list].active} • + Added:{$cbpages[list].date_added|niceTime} + {if $cbpages[list].delete_able =='no'} • UNDELETE-ABLE{/if} + • Display in footer:{$cbpages[list].display} + + +
    + +
     
    + + + + + + +
    + + + + + +
    +
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/manage_players.html b/upload/admin_area/styles/cbv2/layout/manage_players.html new file mode 100644 index 00000000..bad81d72 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/manage_players.html @@ -0,0 +1,278 @@ +{if $mode =='show_settings'} + + + + + +
    ClipBucket Website Player Settings 
    +
    +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Pakplayer license
    + If you have pakplayer license, please enter it here
    + +
    Use Playlist
    +
    By turning this on, player will turn on playlists feature in player (if available)
    +
    Logo File
    + Logo file that will display on your flash player

    +
    Logo Placement
    + Placement of logo, top, left , right or bottom

    + Set logo padding in pixels
    Buffer Time
    + To control the buffer seconds
    Play Youtube Video Inside Player
    + this will let you play youtube videos in your player
    +
    Embed Player Width
    + Enter embedable player width in pixels
    +
    Embed Player Height
    + Enter embedable player width in pixels
    +
    Autoplay Embed
    + Autoplay embeded video by default
    +
    Use PseudoStreaming
    + Let users to play video from anywhere, requires h264 streaming module from webserver
    + + + +
    Pakplayer Context Menu
    + Write what you want to display when user right clicks on pakplayer (only if have pak player license)
      
    +
    +
    + +
    {literal} + + +{/literal} + +
    +In order to change player size, resize the box given below.. +
    + + + + + +
    Main Website Player Size - click here to main website player
     
    + +
    +
    + +
    +

    Original Size of your Main Website Player

    +
    +
    + + + +
    + + +
    + + + + + + +
    Channel Player Settings Size - click here to edit channel player settings
     
    +
    + +
    +

    Original Size of your Main Website Player

    +
    +
    + + + +
    + +
    + + +{else} + + +
    + +

    Selected Player

    +
    +{assign var="player_dir" value=$Cbucket->configs.player_dir} +{assign var="player_file" value=$Cbucket->configs.player_file} + +{assign var="curplayer" value=$cbplayer->getPlayerDetails($player_file,$player_dir)} + + + + + +

    {$curplayer.name}

    {$curplayer.author}
    +{$curplayer.description}
    +Version : {$curplayer.version} Released on {$curplayer.released|date_format}
    +Website : {$curplayer.website}
    + + +
    + +
    +

    Available Players

    + +{* Listing All Avilable Players *} + +{assign var='players' value=$cbplayer->get_players()} + +
    +{foreach from=$players item=player} +{if $player_file !=$player.file && $player_dir != $player.folder} + +
    + +
    + {$player.name}
    by {$player.author}
    + Activate This Player
    +
    +
    +{/if} +{/foreach} +
    + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/mass_email.html b/upload/admin_area/styles/cbv2/layout/mass_email.html new file mode 100644 index 00000000..9ca28541 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/mass_email.html @@ -0,0 +1,229 @@ +

    Send email to users

    + +


    + Send mass email to your users with our new and updated email manager +

    + + +{if $send_email==""} +
    +
    + Email manager +
    + +
    +
    +
    Email to send at once +
    loop size of emails when mass emails are sent
    +
    +
    +
    + + +
    +
    From +
    Enter email address to tell user who sent it
    +
    +
    +
    + +
    +
    Subject +
    Enter your email subject
    +
    +
    +
    + + +
    +
    Message +
    Enter your email message
    +

    +{literal}You can use {username}, {userid}, {email}, {datejoined},{avcode} in your message{/literal}
    +
    +
    + + + + +
    + +
    + More options +
    + +
    +
    +
    Active status +
    + Choose whether to send to active users or non active
    +
    +
    +
    +
    + + +
    +
    Banned status +
    Send email to banned users
    +
    + +
    +
    +
    + + +
    +
    User level +
    Choose which user level to send email
    +
    + + {assign var=levels value=$userquery->get_levels()} + {foreach from=$levels item=level} + {if $level.user_level_id !='4'} + + {/if} + {/foreach} +
    +
    +
    + + + +
    +
    User category +
    User category
    +
    + {assign var=cats value=$userquery->get_categories()} + {foreach from=$cats item=cat} + + + + {/foreach} +
    +
    +
    + + + + + +
    + +
    + +
    + +
    + + +
    +
    + Mass email campaigns +
    +{if $emails} + {foreach from=$emails item=email} +
    +
    + {$email.email_subj} — + Send Email | + Delete | View
    + From + : {$email.email_from} • Method : {$email.method} + • Sent : {$email.sent} • Status : {$email.status}
    + {$email.date_added|niceTime} +
    + +
    +
    + {/foreach} +{else} +
    + No email campaign was found +
    +{/if} + +{literal} + +{/literal} + + +{else} + +
    +Sending emails — Go back to mass email page
    +{if $send_email} +{assign var=email value=$send_email} +
    +
    + {$email.email_subj} — + View
    + From + : {$email.email_from} • Method : {$email.method} + • Sent : {$email.sent} • Status : {$email.status}
    + {$email.date_added|niceTime} +
    + +
    +
    + + + +
    + {$eh->message_list.0} + {if $msgs} +
      + {foreach from=$msgs item=msg} +
    • {$msg}
    • + {/foreach} +
    + {/if} + + + {if ($email.total==$email.sent && $email.sent>0)|| $email.status=='completed'} +
    + Email has been sent to {$email.total} users +
    + {else} +
    + Pelase wait, do not close this window... + + (pause) + +
    + + + {/if} + +{/if} + +{literal} + +{/literal} + + +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/mass_uploader.html b/upload/admin_area/styles/cbv2/layout/mass_uploader.html new file mode 100644 index 00000000..dfd87f53 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/mass_uploader.html @@ -0,0 +1,50 @@ +

    Mass Uploader

    +
    +{assign var=vid_files value=$cbmass->get_video_files()} +{if $vid_files} + +
    + {foreach from=$vid_files item=file name=mass_files} + + + {assign var='requiredFields' value=$Upload->loadRequiredFields($file)} + {assign var='optionFields' value=$Upload->loadOptionFields($file)} + {assign var='locationFields' value=$Upload->loadLocationFields($file)} + {assign var='cust_fields' value=$Upload->custom_form_fields} + + + + + + +
    #{$smarty.foreach.mass_files.iteration}{$file.file} - enter details
    + + + + {foreach from=$requiredFields item=field} + + + + + + {/foreach} + + + {/foreach} + +
    +
    +
    +{else} + + + + + + +
    NO VIDEO FOUND IN MASS UPLOAD FOLDER
    + +{/if} + diff --git a/upload/admin_area/styles/cbv2/layout/members.html b/upload/admin_area/styles/cbv2/layout/members.html new file mode 100644 index 00000000..6edaacb5 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/members.html @@ -0,0 +1,188 @@ +Member Manager + + + + + + +
    + + + + + +
    + + + + + + + + +
    + + + + + + + + +
    + UIDUser Details 
    + + + +{if $users} + + +{foreach from=$users item=u} + + + + + + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} +{/foreach} + + + + + + + + +
    {$u.userid} +
    + + {$u.username} + — + Email:{$u.email} • + Status:{$u.usr_status} • + Level:{$u.level|get_user_level} • + Last Active:{$u.last_active} + + +
    + +
     
    + + + + + +{else} +
    NO USER FOUND
    +{/if} + + + + + + +
    + + + + + + + + +
    +
    + + +{include file="$style_dir/blocks/pagination.html" } diff --git a/upload/admin_area/styles/cbv2/layout/msg.html b/upload/admin_area/styles/cbv2/layout/msg.html new file mode 100644 index 00000000..da71eb66 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/msg.html @@ -0,0 +1,35 @@ +{assign var=msg value=$eh->message_list} +{assign var=err value=$eh->error_list} +{assign var=war value=$eh->warning_list} + +{if $err.0 neq '' || $err.1 neq ''} + +
    +
      + {foreach from=$err item=show_msg} +
    • {$show_msg}
    • + {/foreach} +
    +
    + +{/if} + +{if $msg.0 neq ''} +
    +
      + {foreach from=$msg item=show_msg} +
    • {$show_msg}
    • + {/foreach} +
    +
    +{/if} + +{if $war.0 neq ''} +
    +
      + {foreach from=$war item=show_msg} +
    • {$show_msg}
    • + {/foreach} +
    +
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/notification_settings.html b/upload/admin_area/styles/cbv2/layout/notification_settings.html new file mode 100644 index 00000000..700425e7 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/notification_settings.html @@ -0,0 +1,28 @@ +

    Notification Settings

    +
    +
    +
    + +
    +
    + Notification Settings + + + + + + + + + + + + + +
    Enable Notification
      
     
    +
    +
    +
    + +
    +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/online_users.html b/upload/admin_area/styles/cbv2/layout/online_users.html new file mode 100644 index 00000000..73c6391a --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/online_users.html @@ -0,0 +1,33 @@ +

    {$total} users are online

    +
    + +
    + + + + + + + +
    UserBrowsingAccess timeIP
    +
    + + +{if $online_users} + +{foreach from=$online_users item=user} +{$user.agent|get_browser_details:theBrowser} + + + + + + + + + +{/foreach} +
    {if $user.username}{$user.username}{else}{$user.session_string}{/if} {$user.current_page|truncate:40:'..':false:true} + + {if $user.referer} view referer{/if}{$user.session_date|niceTime}
    KICK
    {$user.ip}
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/orphan_photos.html b/upload/admin_area/styles/cbv2/layout/orphan_photos.html new file mode 100644 index 00000000..eb6de1fa --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/orphan_photos.html @@ -0,0 +1,78 @@ +

    Orphan Photos

    +
    + + + + + + +
    + + + + +
    + + + + + + + + +
    + Photo IDDetails 
    +{if $photos} + +{section name=list loop=$photos} +
  • +
    +
    +
    +
    {$photos[list].photo_id}
    + +
    +
    + +
    +
    + {$photos[list].photo_title} +
    + + Featured:{$photos[list].featured} • + {if $photos[list].collection_id} + Collection:{$photos[list].collection_id|get_collection_field} + {else} + Photo is Orphan + {/if} • + Uploaded:{$photos[list].date_added|niceTime} • + User:{$photos[list].username} + +
    + +
    +
    +
  • +{/section} + + + + + + + +
    + + + +
    + +
    +{else} +
    No Photo Found
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/photo_manager.html b/upload/admin_area/styles/cbv2/layout/photo_manager.html new file mode 100644 index 00000000..5a6130a4 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/photo_manager.html @@ -0,0 +1,148 @@ +

    Photo Manager

    + + +
    + + + + + + +
    + + +
    + +
    + + + + + + + + + +
    + Photo IDDetails 
    + +{if $photos} + +{section name=list loop=$photos} +
  • +
    +
    +
    + +
    {$photos[list].photo_id}
    +
    +
    + {get_photo details=$photos[list] id='photo' style='padding:2px; border:1px solid #ccc' output='html'} +
    +
    + {$photos[list].photo_title} +
    + + Featured:{$photos[list].featured} • + {if $photos[list].collection_id} + Collection:{$photos[list].collection_id|get_collection_field} + {else} + Photo is Orphan + {/if} • + Uploaded:{$photos[list].date_added|niceTime} • + User:{$photos[list].username} + +
    + +
    +
    +
  • +{/section} + + + + + + + +
    + + + + + +
    + +
    +{else} +
    No Photo Found
    +{/if} + +{include file="$style_dir/blocks/pagination.html" } \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/photo_settings.html b/upload/admin_area/styles/cbv2/layout/photo_settings.html new file mode 100644 index 00000000..4cf606c7 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/photo_settings.html @@ -0,0 +1,224 @@ +{if $mode == '' || $mode == 'photo_settings'} + +

    Photo Settings

    +
    +
    +
    +
    +
    + Photo Resizing +
    + + + + + + + + + + + + + + + + + + + +
    + Photo Ratio + Your photo thumb and medium size thumb will be resized according to these ratios + +
    + + + + + + +
    +
    + Photo Width + Height will automatically be updated according to your ratio selected + +
    Thumb Dimensions:
    + + +
    +
    +
    Medium Thumb Dimensions:
    + + +
    + Large Photo Width + + Width of Large Photo + + + +
    + Crop Image + + If Enable, your thumb and medium size will be cropped excatly to above dimensions if required. + + + + +
    +
    + Photo Behavior +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + Multi-upload + + Number of photos, user can upload at once. + + + +
    + Max Photo Size + + Maximum allowed photo size, in MBs. + + + +
    + + + +
    + + + +
    + + + + - User can rate his own photo +
    +
    +
    +
    + +
    +
    + +
    + +{/if} + + +{if $mode == 'watermark_settings'} +

    Watermark Settings

    +
    +
    +
    + +
    +
    + Watermark Settings + + + + + + + + + + + + + + + +
    Enable Watermark
    Maximum Width Maximum Width of watermark image. Recommended is 120.
    Watermark Placement +
    + +
    + +
    + +

    +
    + +
    + +
    + +
    + +

    +
    +
    + +
    + +
    + +
    +
    +
    + +
    + Upload New Watermark + This will over-write your existing watermark file, if exists. +
    + +
    + +
    + Current Watermark +
    + {assign var=file value=$cbphoto->watermark_file()} + {if $file} + + {else} + Watermark not found + {/if} +
    +
    + +
    +
    + +
    +
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/plugin_manager.html b/upload/admin_area/styles/cbv2/layout/plugin_manager.html new file mode 100644 index 00000000..843cae7f --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/plugin_manager.html @@ -0,0 +1,153 @@ +

    Installed Plugins

    +{if $installed_plugin_list} + +
    + + + + + +
    + + + + +
    + + + + + + + +
    + Plugin Details 
    + + +{assign var = bgcolor value = ""} +{foreach from=$installed_plugin_list item=plug name=item} + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/foreach} +
    + + + + {$plug.name} — + + Active:{$plug.plugin_active} • + Author:{$plug.author} • + Version:{$plug.version} +
    {$plug.description}
    + {if $plug.plugin_active == 'yes'}Deactivate{else}Activate{/if} | + Uninstall +
    +
    + + + + + + +
    + + + + +
    +
    + +{else} +
    No Installed Plugin Found
    +{/if} + + + + + + +{* Listing New Plugins *} +
    +

    Available Plugins

    + +{if $new_plugin_list}
    + + + + + + +
    + +
    + + + + + + + + + +
    + Plugin Details 
    + + + + + + +{assign var = bgcolor value = ""} +{foreach from=$new_plugin_list item=plug name=item} + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/foreach} +
    + + + + {$plug.name} — + + Active:{$plug.plugin_active} • + Author:{$plug.author} • + Version:{$plug.version} +
    {$plug.description}
    + Install Plugin +
    +
    + + + + + + + + + +
    + +
    +
    + + + {else} +
    No Plugin is available
    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/recreate_thumbs.html b/upload/admin_area/styles/cbv2/layout/recreate_thumbs.html new file mode 100644 index 00000000..65d160f9 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/recreate_thumbs.html @@ -0,0 +1,246 @@ +{if $mode == 'single'} +

    Re-create Photos

    +
    + « Back to Edit Details +
    + +
    + Settings on which photos will be re-created +
  • +
    Ratio
    +
    +
  • +
  • +
    Thumb Size
    +
    x
    +
  • + +
  • +
    Medium Size
    +
    x
    +
  • + +
  • +
    Large Size
    +
    +
  • +
  • +
    Cropping
    +
    + {assign var=cropping value=$Cbucket->configs.photo_crop} + {if $cropping == 1} + Enabled + {else} + Disabled + {/if} +
    +
  • +
  • +
    Watermarking
    +
    + {assign var=watermark value=$Cbucket->configs.watermark_photo} + {if $watermark == 1} + Enabled | Placement - + {else} + Disabled + {/if} +
    +
  • +
  • +
     
    +
    + Update settings if they are not according to your needs. +
    +
  • +
    +
    + Re-create Photo +
    + {foreach from=$files item=file} +
    +
    + {assign var=size value=$cbphoto->get_image_type($file)} + Filename: {$p.filename}{if $size} - Size: {$size}{/if} +
    +
    + +
    + {/foreach} +
    + +
    +{/if} + +{if $mode == 'mass' || $mode == ''} +

    Mass Re-creation of Photos

    +
    + This will re-create all the photos uploaded on your website, according to the settings shown below +
    Take caution while using Mass Recreation. Use MAX of 5 photos per GO.
    +
    +
    + Settings on which photos will be re-created +
  • +
    Ratio
    +
    +
  • +
  • +
    Thumb Size
    +
    x
    +
  • + +
  • +
    Medium Size
    +
    x
    +
  • + +
  • +
    Large Size
    +
    +
  • +
  • +
    Cropping
    +
    + {assign var=cropping value=$Cbucket->configs.photo_crop} + {if $cropping == 1} + Enabled + {else} + Disabled + {/if} +
    +
  • +
  • +
    Watermarking
    +
    + {assign var=watermark value=$Cbucket->configs.watermark_photo} + {if $watermark == 1} + Enabled | Placement - + {else} + Disabled + {/if} +
    +
  • +
  • +
     
    +
    + Update settings if they are not according to your needs. +
    +
  • +
    +
    +
    + Loop Size -
    +
    Number of photos to re-create in one go.
    +
    +
    + + +
    + + {if $indexing} +
    {$from} - {$to} of {$total}
    +
      + {foreach from=$index_msgs item=themsg} +
    • {$themsg}
    • + {/foreach} +
    + {if $stop_loop!='yes'} + + redirecting....do not close this window + {else} + Re-creation of photos have been completed. + {/if} + {/if} +{/if} + +{if $mode == "collection"} +

    Recreate Photos

    +
    + {if $items} + {assign var=cid value=$items[0].collection_id} + {assign var=c_name value=$items[0].collection_id|get_collection_field} + {$c_name} + + - View Collection - + Edit Collection - + Manage Items + + +
    + Settings on which photos will be re-created +
  • +
    Ratio
    +
    +
  • +
  • +
    Thumb Size
    +
    x
    +
  • + +
  • +
    Medium Size
    +
    x
    +
  • + +
  • +
    Large Size
    +
    +
  • +
  • +
    Cropping
    +
    + {assign var=cropping value=$Cbucket->configs.photo_crop} + {if $cropping == 1} + Enabled + {else} + Disabled + {/if} +
    +
  • +
  • +
    Watermarking
    +
    + {assign var=watermark value=$Cbucket->configs.watermark_photo} + {if $watermark == 1} + Enabled | Placement - + {else} + Disabled + {/if} +
    +
  • +
  • +
     
    +
    + Update settings if they are not according to your needs. +
    +
  • +
    +
    +
    + Photos + + {section name=list loop=$items} + + {/section} +
    +
    + + +
    +
    +
    +
    Select photos you want to re-created |
    + +
    +
    + + {else} + + {/if} +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/reindex_cb.html b/upload/admin_area/styles/cbv2/layout/reindex_cb.html new file mode 100644 index 00000000..4c0f3eff --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/reindex_cb.html @@ -0,0 +1,91 @@ +Re-index Clipbucket +
    +Here you can re-index your videos, users or groups statistics. From below select which thing you want to re-index. + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Loop Size

    + number of items to reindex at once
    +

    Reindex Videos

    + this will reindex total playlists, total favorites and total comments made on video
    +
    + + +

    Reindex Users

    + This will reindex total videos, total comments, total comments made, total subscribers and subscriptions, total groups owned,
    +
    + + +

    Reindex Groups +

    + this will reindex all groups , update total members, total videos , total topics
    +
    + + +

    Reindex Collections +

    + this will reindex all collections , update total objects, total comments
    +
    + + +

    Reindex Photos +

    + this will reindex all photos , update total favorites, total comments
    +
    + + +
    + +{if $indexing} +
    {$from} - {$to} of {$total}
    +
      + {foreach from=$index_msgs item=themsg} +
    • {$themsg}
    • + {/foreach} +
    +{if $stop_loop!='yes'} + +redirecting....do not close this window +{else} + Indexing has been completed. +{/if} +{/if} diff --git a/upload/admin_area/styles/cbv2/layout/repair_vid_duration.html b/upload/admin_area/styles/cbv2/layout/repair_vid_duration.html new file mode 100644 index 00000000..70d92d78 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/repair_vid_duration.html @@ -0,0 +1,29 @@ +

    ClipBucket video duration fix

    +
    + + +Clipbucket repair video duration using file conversion logs of each file, if there is no log, duration fix is likely not possible.
    +* with log => those videos that have file conversion log
    +* with no log => those don't have any conversion log
    +
    {if $videos} +
    + + + +
    +
    + + {foreach from=$videos item=video} + {assign var=filename value=$video.file_name} + {assign var=log value=func->get_file_details($filename)} +
    +
    +
    {if $fixed_array.$filename}[FIXED] {/if}{$video.title} (duration : {$vdo.duration|setTime} | Has Log :{if $log} yes{else}no{/if} )
    +
    +
    + {/foreach} + {else} + No videos found with duration less than or equal to 1 + {/if} +
    diff --git a/upload/admin_area/styles/cbv2/layout/reports.html b/upload/admin_area/styles/cbv2/layout/reports.html new file mode 100644 index 00000000..9b5b30f9 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/reports.html @@ -0,0 +1,218 @@ +
    +
    + +
    + + + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Videos Reports

    All TimeTotal {get_videos count_only=yes} – Active {get_videos count_only=yes active="yes"} – Processing {get_videos count_only=yes status='Processing'}
    Todays VideosTotal {get_videos count_only=yes date_span=today} – Active {get_videos count_only=yes active="yes" date_span=today} – Processing {get_videos count_only=yes status='Processing' date_span=today}
    This WeekTotal {get_videos count_only=yes date_span=this_week} – Active {get_videos count_only=yes active="yes" date_span=this_week} – Processing {get_videos count_only=yes status='Processing' date_span=this_week}
    Last WeekTotal {get_videos count_only=yes date_span=last_week} – Active {get_videos count_only=yes active="yes" date_span=last_week} – Processing {get_videos count_only=yes status='Processing' date_span=last_week}
    This MonthTotal {get_videos count_only=yes date_span=this_month} – Active {get_videos count_only=yes active="yes" date_span=this_month} – Processing {get_videos count_only=yes status='Processing' date_span=this_month}
    Last MonthTotal {get_videos count_only=yes date_span=last_month} – Active {get_videos count_only=yes active="yes" date_span=last_month} – Processing {get_videos count_only=yes status='Processing' date_span=last_month}
      
      
    +
    + + + +
    + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    User Reports

    All TimeTotal {get_users count_only=yes} – Active {get_users count_only=yes status='Ok'} – Inactive {get_users count_only=yes status='ToActivate'}
    Todays UsersTotal {get_users count_only=yes date_span='today'} – Active {get_users count_only=yes status='Ok' date_span='today'} – Inactive {get_users count_only=yes status='ToActivate' date_span='today'}
    This WeekTotal {get_users count_only=yes date_span='this_week'} – Active {get_users count_only=yes status='Ok' date_span='this_week'} – Inactive {get_users count_only=yes status='ToActivate' date_span='this_week'}
    Last WeekTotal {get_users count_only=yes date_span='last_week'} – Active {get_users count_only=yes status='Ok' date_span='last_week'} – Processing {get_users count_only=yes status='ToActivate' date_span='last_week'}
    This MonthTotal {get_users count_only=yes date_span='this_month'} – Active {get_users count_only=yes status='Ok' date_span='this_month'} – Inactive {get_users count_only=yes status='ToActivate' date_span='this_month'}
    Last MonthTotal {get_users count_only=yes date_span='last_month'} – Active {get_users count_only=yes status='Ok' date_span='last_month'} – Inactive {get_users count_only=yes status='ToActivate' date_span='last_month'}
    +
    + + + + + + +
    + + + + + + +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

    Group Reports

    All TimeTotal {get_groups count_only=yes} – + Active {get_groups count_only=yes active='yes'} – + Inactive {get_groups count_only=yes active='no'} +
    TodayTotal {get_groups count_only=yes date_span=today} – + Active {get_groups count_only=yes active='yes' date_span=today} – + Inactive {get_groups count_only=yes active='no' date_span=today}
    This WeekTotal {get_groups count_only=yes date_span=this_week} – + Active {get_groups count_only=yes active='yes' date_span=this_week} – + Inactive {get_groups count_only=yes active='no' date_span=this_week}
    Last WeekTotal {get_groups count_only=yes date_span=last_week} – + Active {get_groups count_only=yes active='yes' date_span=last_week} – + Inactive {get_groups count_only=yes active='no' date_span=last_week}
    This MonthTotal {get_groups count_only=yes date_span=this_month} – + Active {get_groups count_only=yes active='yes' date_span=this_month} – + Inactive {get_groups count_only=yes active='no' date_span=this_month}
    Last MonthTotal {get_groups count_only=yes date_span=last_month} – + Active {get_groups count_only=yes active='yes' date_span=last_month} – + Inactive {get_groups count_only=yes active='no' date_span=last_month}
    +
    + + +
    + + + + + + + + + + + + + + + +

    Comments

    Flags

    Playlists

    Favorites

      +
    • {$myquery->get_comments('wildcard',v,TRUE)} video comments
    • +
    • {$myquery->get_comments('wildcard',t,TRUE)} Group Discussions
    • +
    • {$myquery->get_comments('wildcard',c,TRUE)} Profile Comments
    • +
      +
    • {$cbvid->action->count_flagged_objects()} videos are reported
    • +
    • {$userquery->action->count_flagged_objects()} groups are reported
    • +
    • {$cbgroup->action->count_flagged_objects()} profiles are reported
    • +
    +

     

      +
    • {$cbvid->action->count_total_playlist()} Video Playlists are created
    • +
    • {$cbvid->action->count_total_playlist(true)} Video Items are in playlist
    • +
      +
    • {$cbvid->action->total_favorites()} favorite videos
    • +
    + + + + +
    + + + + + + + + + +

    Files and Sizes

      +
    • Video Files : {$vid_dir.count|number_format} – Folder Size : {$vid_dir.size|formatfilesize}
    • +
    • Thumb Files : {$thumb_dir.count|number_format} – Folder Size : {$thumb_dir.size|formatfilesize}
    • +
    • Original Video Files : {$orig_dir.count|number_format} – Folder Size : {$orig_dir.size|formatfilesize}
    • +
    • User Thumb Files : {$user_thumbs.count|number_format} – Folder Size : {$user_thumbs.size|formatfilesize}
    • +
    • User Background Files {$user_bg.count|number_format} – Folder Size : {$user_bg.size|formatfilesize}
    • +
    • Groups Thumb Files : {$grp_thumbs.count|number_format} – Folder Size : {$grp_thumbs.size|formatfilesize}
    • +
    • Category Thumb Files {$cat_thumbs.count|number_format} – Folder Size : {$cat_thumbs.size|formatfilesize}
    • +
    • Database Size : {$db_size}
    • +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/template_editor.html b/upload/admin_area/styles/cbv2/layout/template_editor.html new file mode 100644 index 00000000..27645707 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/template_editor.html @@ -0,0 +1,52 @@ +

    Edit template

    +
    + + +
    + + {assign var='templates' value=$cbtpl->get_templates()} + {if $templates} +
    + +
    + + {/if} +
    + + + + + + + +
    +

    Layout Files

    +
      + {foreach from=$tpl_files item=tplfile key=folder} + {if !is_array($tplfile)} +
    • {$tplfile}
    • + {/if} + {/foreach} +
    + +

    CSS Files

    +
      + {foreach from=$css_files item=cssfile} + {if !is_array($cssfile)} +
    • {$cssfile}
    • + {/if} + {/foreach} +
    +
    +
    +

    {if $writeable=='no'}This file is not writeable, please set {$smarty.get.file} permissions to 0777 - More Details
    +{else} +
    +{/if} +
    +
    \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/templates.html b/upload/admin_area/styles/cbv2/layout/templates.html new file mode 100644 index 00000000..243024bc --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/templates.html @@ -0,0 +1,41 @@ +

    Selected Template

    +
    +{assign var="selected" value=$Cbucket->configs.template_dir} +{assign var="curtpl" value=$cbtpl->get_template_details($selected)} + + + + + +

    {$curtpl.name}

    {$curtpl.author}
    +{$curtpl.description}
    +Version : {$curtpl.version}, Released on {$curtpl.released|date_format}
    +Website : {$curtpl.website.title}
    + + +
    + +
    + +{* Listing All Avilable Templates *} +{assign var='templates' value=$cbtpl->get_templates()} +{if $templates} +

    Available Templates

    + +
    + {foreach from=$templates item=template} + {if $selected != $template.dir} +
    + +
    + {$template.name}
    by {$template.author}
    + Activate This Template
    + Preview
    + Preview & Activate
    +
    + {/if} + {/foreach} +
    +{else} +
    No New Template Found
    +{/if} diff --git a/upload/admin_area/styles/cbv2/layout/under_development.html b/upload/admin_area/styles/cbv2/layout/under_development.html new file mode 100644 index 00000000..f37b6647 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/under_development.html @@ -0,0 +1 @@ +

    Page Under Development

    diff --git a/upload/admin_area/styles/cbv2/layout/upload_thumbs.html b/upload/admin_area/styles/cbv2/layout/upload_thumbs.html new file mode 100644 index 00000000..33f0d2c1 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/upload_thumbs.html @@ -0,0 +1,40 @@ +{if $data.title neq ""} +

    Manage Video Thumbs

    +
    + « Back to Edit Details | Regenerate Thumbs
    +
    + {assign var=vidthumbs value=func->get_thumb($data,1,TRUE,FLASE,TRUE,FALSE)} + + {foreach from=$vidthumbs item=vid_thumb} + +
    +
    + {if $vid_thumb|getname!='processing'} + Delete + {/if} +
    + {/foreach} +

    +
    +
    + +
    +
    +
    +
    +

    Upload New Thumb

    +
    + +
    + + +
    +
    +
    +
    + +
    +
    +
    + {/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/user_category.html b/upload/admin_area/styles/cbv2/layout/user_category.html new file mode 100644 index 00000000..67e6aa1c --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/user_category.html @@ -0,0 +1,160 @@ +User Categories + + + + + + + + +
    Manage User Categories  
    + + +{if $edit_category != "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb +
     
    +
    +{/if} +{if $edit_category == "show"} +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + +
     * are required fields
    Category Name*
    Category Description*
    Make Default Category

    + + +
    +

    Category Thumb
    +
    +{/if} + + +
    +Category List +
    + +{if $total != 0} +
    + + + + + + + + + +{assign var = bgcolor value = ""} +{section name=list loop=$category} + + + + + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} + +
    Category NameOrderDescriptionDefaultAction 
    {$category[list].category_name} - View Thumb + {if $category[list].category_desc}{$category[list].category_desc}{else}N/A{/if}{$category[list].isdefault} +
  • Edit
  • +
  • Delete
  • + {if $category[list].isdefault!="yes"}
  • Make Default
  • {/if} +
     
    + + +
    +
    +{else} +No Category Has Been Created Yet +{/if} +
    +
    + diff --git a/upload/admin_area/styles/cbv2/layout/user_levels.html b/upload/admin_area/styles/cbv2/layout/user_levels.html new file mode 100644 index 00000000..281577a0 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/user_levels.html @@ -0,0 +1,231 @@ + +

    User Levels

    +{if $view=='view'} + +Add New Level + + + + + + + + + + {assign var=levels value=$userquery->get_levels()} + {section name=l loop=$levels} + + + + + + + + {sectionelse} + + + + {/section} +
    IDNameActiveUsersActions
    {$levels[l].user_level_id}{$levels[l].user_level_name}{$levels[l].user_level_active}{$userquery->get_level_users($levels[l].user_level_id,true)}Edit{if $levels[l].user_level_is_default !=yes} | Remove{/if}
    No Levels Were Found
    + +{elseif $view=='edit'} + +
    + + + + + + +
     Edit Level Permissions 
    + + + + + +
    Level Name + +
    + + +{assign var='types' value=$userquery->get_level_types()} +{section name=t loop=$types} + + + + + + +
     {$types[t].user_permission_type_name} 
    +{assign var=perms value=$userquery->get_permissions($types[t].user_permission_type_id)} + +{assign var = bgcolor value = ""} +{foreach from=$perms item=perm} +{if $perm.permission_id !=""} + + + + + + +{else} + +{/if} + + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} + +{foreachelse} + +{/foreach} +
    {$perm.permission_name}
    +{$perm.permission_desc}
    +{assign var="perm_code" value=$perm.permission_code} + + + + +
    No Permission Found
    No Permission Found
    + + +{/section} + + + +{if $Cbucket->plugins_perms} + + + + + + + +
     Plugins Permissions 
    + + +{assign var=perms value=$Cbucket->plugins_perms} + + +{assign var = bgcolor value = ""} +{foreach from=$perms item=perm} + + + + + + + + + + +{if $bgcolor == ""} +{assign var = bgcolor value = "#EEEEEE"} +{else} +{assign var = bgcolor value = ""} +{/if} + +{foreachelse} + +{/foreach} +
    {$perm.plugin_name}
    +{$perm.plugin_desc}
    + + + + + +
    No Permission Found
    + + + + + + +{/if} + + + + + + +
    +
    +
    +{elseif $view=='add'} +
    + + + + + + +
     User Level Details 
    + + + + + + +
    Level Name + +
    +{assign var='types' value=$userquery->get_level_types()} +{section name=t loop=$types} + + + + + + +
     {$types[t].user_permission_type_name} 
    + {assign var=perms value=$userquery->get_permissions($types[t].user_permission_type_id)} + + {assign var = bgcolor value = ""} + {foreach from=$perms item=perm} + {if $perm.permission_id !=""} + + + + + + + {else} + + {/if} + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + + {foreachelse} + + {/foreach} +
    {$perm.permission_name}
    + {$perm.permission_desc}
    + + +
    No Permission Found
    No Permission Found
    + +{/section} + +
    +{/if} + + + diff --git a/upload/admin_area/styles/cbv2/layout/video_manager.html b/upload/admin_area/styles/cbv2/layout/video_manager.html new file mode 100644 index 00000000..fcf31bb6 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/video_manager.html @@ -0,0 +1,179 @@ + +

    Video Manager

    + + + + + + +
    + + + + + + +
    + + + + + + +
    + + + + + + + + + + +
    + VID Details 
    + + + + +{if $videos} + +{assign var = bgcolor value = ""} +{section name=list loop=$videos} + + + + + + + + + + {if $bgcolor == ""} + {assign var = bgcolor value = "#EEEEEE"} + {else} + {assign var = bgcolor value = ""} + {/if} + +{/section} +
    {$videos[list].videoid} +
    + {$videos[list].title|truncate:80} + ({if $videos[list].duration>1}{$videos[list].duration|SetTime}{else}00:00{/if})
    + + Featured:{$videos[list].featured} • + Active:{$videos[list].active} • + Status:{$videos[list].status} • + Uploaded:{$videos[list].date_added|niceTime} • + User:{$videos[list].username} + + +
    + +
     
    +{else} +
    No Video Found
    +{/if} + + + + + + +
    + + + + + + +
    + +
    + + +{include file="$style_dir/blocks/pagination.html" } \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/view_conversion_log.html b/upload/admin_area/styles/cbv2/layout/view_conversion_log.html new file mode 100644 index 00000000..e2c8d034 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/view_conversion_log.html @@ -0,0 +1,77 @@ +{if $data.File} + +

    Converion Log for file {$data.file_name}.{$data.file_ext}

    + +

    + Reading Conversion log for file {$data.file_name} +

    + + + + +
    Conversion details
    + +
    +{foreach from=$data item=value key=field} + {if $field !='conversion_log' } +
    +
    {$field|replace:'_':' '}
    +
    {$value}
    +
    +
    + {/if} +{/foreach} +
    + +
    Complete conversion log
    + +
    +{literal} + Expand + + + + | + Copy + + + + + +{/literal} +
    + + +
    +{$data.conversion_log|nl2br}
    + + +{else} Log file was not found +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/layout/view_user.html b/upload/admin_area/styles/cbv2/layout/view_user.html new file mode 100644 index 00000000..5f91c563 --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/view_user.html @@ -0,0 +1,343 @@ +Edit User + +{assign var='signup_fields' value=$userquery->load_signup_fields($u)} +{assign var='channel_profile_fields' value=$userquery->load_user_fields($p)} + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + +
     User Info 
    + + + + + +
     ACtions 
    + +
    + ClipBucket User Info + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {assign var=cust_signup value=$userquery->load_custom_signup_fields($u,true)} + {if $cust_signup} + {foreach from=$cust_signup item=field} + + + + + {/foreach} + {/if} + +
    User Id + + +
    User name + + + +
    Email
    Change Password
    Confirm Password
    User Level +
    Country +
    Gender + + + + +

    Category{ANCHOR place=$signup_fields.cat.anchor_before}{$formObj->createField($signup_fields.cat)}{ANCHOR place=$signup_fields.cat.anchor_after}
    {$field.title}{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
    + {$field.hint_2}
    +
    + +{foreach from=$channel_profile_fields item=field_group} +
    + {$field_group.group_name} + + {foreach from=$field_group.fields item=field} + + + + + {/foreach} + +
    {$field.title}{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} +
    + {$field.hint_2}
    +
    +{/foreach} + + + + + + + + +
    + User Links + + + + +
    +
    + + +
    + User Activity + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    Date of birth + YYYY-MM-DD
    Joined - IP + - {$u.signup_ip}
    Last Login - Login IP{$u.last_logged} - {$u.ip}
    Last Active - Online {$u.last_active} - {$u.last_active|is_online}
    Profile Views +
    Videos Watched
    Videos Uploaded
    Comments Made
    Profile Comments
    Profile Rating + 0-10
    Profile Rated by
    Subscribers
    +
    + Recent Activity Log + + + + + + + + + +
    IDUID
    Username
    Date
    Detail
     
    + + +{assign var="logs" value=$userquery->get_user_action_log($u.userid,10)} +{section loop=$logs name=log} + + + + + + + + +{sectionelse} + +{/section} +
    {$logs[log].action_id}{$logs[log].action_userid}
    {$logs[log].action_username}
    {$logs[log].date_added}
    Type : {$logs[log].action_type} –{if $logs[log].action_details!=''}{$logs[log].action_details} –{/if} Success : {$logs[log].action_success} – {$logs[log].action_ip}
    + +
    + User Avatar and Background + + + + + + + + + + + +

    + +
    User Avatar/Profile Pic
    + Please select image file
    + + + OR
    + Please Enter Image URL
    + + + + +
    + + +
     
    {if $userquery->getUserBg($u)}{else}No Bg{/if}User Background Image +
    + Please Select Image File +
    + +OR
    +Please Enter Image URL
    + + +OR
    +Please Enter Background Color
    + + + +
    +Background Repeat Type (if using image as a background)
    + + +
    + +{if $userquery->getUserBg($u)}{/if}
    +
    + + +
      
    +  
    +
    + + + + + + + + +
     
    +
    + {assign var='object_type' value='channel'} + + + +
    +
    + +
    diff --git a/upload/admin_area/styles/cbv2/layout/view_video.html b/upload/admin_area/styles/cbv2/layout/view_video.html new file mode 100644 index 00000000..d3d6f48f --- /dev/null +++ b/upload/admin_area/styles/cbv2/layout/view_video.html @@ -0,0 +1,203 @@ +{if $show=='oyeaaa'} +{assign var='requiredFields' value=$Upload->loadRequiredFields($data)} +{assign var='optionFields' value=$Upload->loadOptionFields($data)} +{assign var='locationFields' value=$Upload->loadLocationFields($data)} + +{assign var='custom_fields' value=$Upload->load_custom_upload_fields($data,TRUE)} +{assign var='custom_form_fields' value=$Upload->load_custom_form_fields($data,TRUE)} + + + + + + + +
    Viewing {$data.title}  
    + + +
    + + +
    + + + + + + + + + + + + + + + + + + +
    + + + + + + + {foreach from=$requiredFields item=field} + + + + + {/foreach} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {foreach from=$optionFields item=field} + + + + + {/foreach} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + {foreach from=$custom_fields item=field} + + + + + + {foreachelse} + + + + + {/foreach} + + + + + + + + {foreach from=$custom_form_fields item=field} + + + + + + {foreachelse} + + + + + {/foreach} + + + + + + + + + + + + + + + + + + + +
     
    Information
    {$field.title}{ANCHOR place=$field.anchor_before}{input_value input=$field}
      
    Important Details and Files information
    Video Id{$data.videoid}
    Video Key{$data.videokey}
    File Name{$data.file_name}
    Video Files{get_all_video_files vdetails=$data count_only=true}
    Thumb Files {get_thumb vdetails=$data count_only=true}
     {assign var=vidthumbs value=func->get_thumb($data,1,TRUE)} + + {foreach from=$vidthumbs item=vid_thumb} +
    +
    + {if $data.default_thumb==$vid_thumb|get_thumb_num}Default{/if} +
    + {/foreach} + +
    View File Details and Conversion Log
      
    Sharing Options
    {$field.title}{ANCHOR place=$field.anchor_before}{input_value input=$field}
      
    Stats
    Views{$data.views}
    Rating{$data.rating} + of 10
    RatedBy{$data.rated_by}
    Duration{$data.duration|SetTime}
      
    Custom Upload Options
    {$field.title}{$field.value|form_val}
    No Custom Fields
      
    Custom Form Fields
    {$field.title}{$field.value|form_val}
    No Custom Fields
      
    User Information
    User id{$udata.userid}
    User name{$udata.username}
    Videos Uploaded{$userquery->get_user_vids($data.userid,'',true)}
    + This content requires JavaScript and Macromedia Flash Player 7 or higher. Get Flash

    +
    +
      
    Video Comments
    {assign var=id value=$data.videoid}{include file="$style_dir/blocks/comments.html" type=v id=$data.videoid link="video=$id"}
    +
    +
    +{else} +

    Page moved

    +{/if} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/theme/cbtab.css b/upload/admin_area/styles/cbv2/theme/cbtab.css new file mode 100644 index 00000000..4cefecaf --- /dev/null +++ b/upload/admin_area/styles/cbv2/theme/cbtab.css @@ -0,0 +1,36 @@ +@charset "utf-8"; +/* CSS Document */ + + +.cbtab{margin:0px; padding:0px} + +.cbtab li +{ + list-style-type:none; + padding:0px 10px; + background-color:#009; + margin:2px; background-image:url(../images/bgs/round_bg.png); + background-position:0px -52px; height:26px; line-height:26px; + font-size:12px; color:#FFF; + font-weight:bold; + -moz-border-radius-topleft:5px; + -webkit-border-top-left-radius:5px; + -moz-border-radius-topright:5px; + -webkit-border-top-right-radius:5px; + border:2px #d2d2d2 solid; + border-bottom:none; + cursor:pointer; + float:left; + margin-bottom:0px; +} + +.cbtab .selected{background:#333} + +.main_page_div{min-height:200px; border:1px solid #d2d2d2; width:95%; margin-left:2px; padding:5px; +-moz-border-radius-bottomleft:5px; +-webkit-border-bottom-left-radius:5px; +-moz-border-radius-bottomright:5px; +-webkit-border-bottom-right-radius:5px; +-moz-border-radius-topright:5px; +-webkit-border-top-right-radius:5px; +} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/theme/main.css b/upload/admin_area/styles/cbv2/theme/main.css new file mode 100644 index 00000000..0a97f2fc --- /dev/null +++ b/upload/admin_area/styles/cbv2/theme/main.css @@ -0,0 +1,366 @@ +@charset "utf-8"; +/* CSS Document */ + +@import url("pagination.css"); +@import url("cbtab.css"); + +body,html {background-color:#fff; margin:0px; padding:0px; font-family:Verdana; color:#333; font-size:11px;} + +/* CLEARS */ +.clearfix { } +.clearfix:after{ content: "."; display:block; height:0; font-size:0; clear:both; visibility:hidden; } + +/* GENERAL CSS */ +a{ color:#0099cc; text-decoration:none; outline:none; } +a:hover,a:active { /*color:#464646; */ color:#d54e21; outline:none; } +a[rel=sponsors] { padding:5px; background:#0099cc; border:1px solid transparent; } +a[rel=sponsors]:hover { background:#555; border:1px solid #232323; } + + +.footer_grey_bar,.header_grey_bar{background-image:url(../images/gradients.png); background-repeat:repeat-x; height:40px; line-height:40px; min-width:1000px} +.header_grey_bar{ color:#fff;font-size: 20px; font-family:"Century Gothic",Verdana,sans-serif;} +.cbicon{background-image:url(../images/icons.png); width:50px; height:28px; background-repeat:no-repeat; margin:6px 10px 0px 10px; float:left} +.header_grey_bar .welcome{font-size:15px; padding-right:10px} +.header_grey_bar .logout_button{background-image:url(../images/icons.png); background-position:-50px 0px; height:25px; width:25px; margin:6px 5px 0px 5px; vertical-align:sub; } + +.sarch_button{width:109px; height:25px; cursor:pointer; background:transparent url(../images/icons.png) 0px -59px no-repeat;} + +.header_menu{ background-image:url(../images/gradients.png); background-repeat:repeat-x; background-position:0px -41px; height:33px; border:1px solid #000; border-left:none; border-right:none;min-width:1000px; position:relative} +.header_menu_after{background:url(../images/headerafter.png) repeat-x; min-height:13px; padding-top:5px} + +.header_menu a{text-decoration:none; color:#fff} +.header_menu ul{list-style:none; margin:0px; padding:0px;} +.header_menu ul li{list-style:none; float:left; width:auto; text-align:center; line-height:31px; color:#fff; border-right:#1577ba solid 1px;border-left:#43a1e1 solid 1px; margin-top:1px; padding:0px 5px} +.header_menu ul li:hover{background-color:#148ada} +.header_menu ul li:first-child{border-left:none} + +.footer_grey_bar{ color:#fff; font:14px/40px Century Gothic; padding-right:10px} +.footer_grey_bar a{color:#fff;; text-decoration:none} +.toggle_menu{height:30px; line-height:30px; font-size:15px; font-weight:bold; margin:3px; display:inline-block; cursor:pointer} +.toggle_menu_icon{background-image:url(../images/icons.png); background-position:0px -29px; height:30px; width:30px; float:left; margin-right:5px} + + +.admin_heading{ font-size:11px; font-weight:bold; color:#fff;background-image:url(../images/bgs/round_bg.png); background-position:right -52px; height:26px;line-height:26px; text-indent:10px;border-radius:5px 5px 0px 0px ;-webkit-border-radius:5px 5px 0px 0px ;-moz-border-radius: 5px 5px 0px 0px;} +.admin_box{border:1px solid #146194; border-top:0px; padding:5px; background-color:#fafafa; color:#666666; border-radius:0px 0px 5px 5px;-webkit-border-radius:0px 0px 5px 5px;-moz-border-radius:0px 0px 5px 5px; margin-bottom:15px} + +.news .news_title{font-size:11px; color:#666} +.news .news_title a{font-size:13px; text-decoration:none; font-weight:bold} +.news .news_title .title{float:left; display:inline} +.news .news_title .date{float:right; display:inline; color:#a2a2a2; font-size:10px} + +.stats .stat{border:0px; border-bottom:1px solid #ccc; padding:2px; background-color:#fafafa} +.stats .stat:last-child{border:none; background-color:#f3f3f3} +.stats .stat:first-child{background-color:#f3f3f3} +.stats .stat span:nth-child(1){float:left;} +.stats .stat span:nth-child(2){float:right;} + +.simple_button{background:url(../images/gradients.png) 0px -86px repeat-x; height:17px; line-height:17px; text-align:center; display:inline-block; padding:0px 5px; border:1px solid #ccc; } +.simple_button,.simple_button a{color:#555; text-decoration:none; font-size:11px; font-weight:bold} + + + +/** + * Page Table Tops + */ +.head_title,.left_head,.head,.right_head,.head_sep_left,.head_sep_right,.left_head a,.head a,.right_head a,.head_sep_left a,.head_sep_right a{line-height:26px; color:#FFF; font-size:12px; font-family:Arial, Helvetica, sans-serif; font-weight:bold} +.left_head{background-image:url(../images/bgs/round_bg.png); background-position:0px 0px; height:26px} +.head_title,.head{background-image:url(../images/bgs/round_bg.png); background-position:right -52px; height:26px} +.right_head{background-image:url(../images/bgs/round_bg.png); background-position:right -26px; height:26px} +.head_sep_left{background-image:url(../images/bgs/round_bg.png); background-position:left -130px; height:26px; text-indent:10px;} +.head_sep_right{background-image:url(../images/bgs/round_bg.png); background-position:right -156px; height:26px} + + +.admin_td,.video_opt_td{color:#333; font-size:12px;} +.video_opt_td{height:55px; border-bottom:1px solid #ccc; padding-top:5px} +.video_opt_td a{font-size:13px; font-weight:bold; color:#0c4469; text-decoration:none} +.vid_opts{ padding:2px; display:inline;-moz-border-radius: 5px; -webkit-border-radius: 5px;} +.vid_opts a { font-weight:bold; font-size:11px; font-family:Tahoma,Verdana,sans-serif; } +.vid_opts a:hover { border-bottom:1px dashed #0099cc; } +.vdo_sets,.vdo_sets a{font-size:11px; text-transform:uppercase; font-family: Consolas, Monaco, Courier, monospace;} + + +h2,.page_title{font-size:18px; margin:5px 0px 5px 0px; display:inline; font-weight:normal} +h2,.page_title a{font-size:18px; } +h4{margin:2px 0px} + +/** + * Forms + */ +.button{background-image:url(../images/button_bg.png); height:30px; color:#FFF; font-weight:bold; border:1px; line-height:30px; -moz-border-radius: 3px; +-webkit-border-radius: 3px;border-radius: 3px; border:1px solid #003366; cursor:pointer;outline:none} + +.button:focus{background-position:-0 -30px; outline:none} + +.fieldset{-moz-border-radius: 5px; +-webkit-border-radius: 5px; border:2px solid #EAEEFF; width:98%; margin:0px; padding:0px; margin:auto; margin-top:15px} + +.fieldset select,.fieldset input[type="text"],.fieldset input[type="textfield"],.fieldset textarea{border:1px solid #CCC; font-size:11px; margin:2px; padding:2px} + +.fieldset .block{margin:5px} +.fieldset legend{margin:2px; font-size:13px; font-weight:bold; color:#147dc3} + +.cbform input[type="text"],.cbform input[type="textfield"],.cbform select,.cbform textarea{width:300px; padding:3px; font-size:12px} + +/** + * Forms End +*/ +.block_head tr td{padding:0px 2px 0px 2px} +.block tr td{padding:2px; border-bottom:1px dotted #eee; } +.block tr:hover{background-color:#f8f8f8} + +.head_title{text-indent:5px; padding:0px} + +.hint{font-size:11px;} + +#login_box{ + height:250px; + width:400px; + background-image:url(../images/login.png); + background-repeat:no-repeat; + margin:auto; + background-position:center; + padding-top: 150px; +} + +#login_box .textfield{ + height:30px; + width: 280px; + margin-bottom: 10px; + -moz-border-radius: 5px; +-webkit-border-radius: 5px; border:1px solid #ccc; +line-height:30px; +padding-left:5px; font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; padding-top:5px; color:#6E6E6E +} +#login_box label{ + font-size:18px; + color: #494949; +} + + +.row_white{border-bottom:1px dotted #646464; width:100%; margin:auto} +.row_white:hover{background-color:#F3F3F3} + + + +.search_box{margin:5px; padding:5px; border:1px solid #e3e3e3; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; background:#f9f9f9} + +.video_search .input,#dp_opts input[type='text']{border:1px solid #666; width:200px} + + +.item_listing td{border-bottom:1px solid #ccc} + +.item_listing li{list-style:none} +.item_listing a{color:#0c4469; font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; font-style:italic} + +.templates_container +{ + font-size:11px; color:#333; +} + +.templates_container .tpl_title{width:80%; margin:auto; font-size:12px;} +.templates_container .template_box{width:250px; height:225px; float:left; margin:10px; padding:10px} +.templates_container .template_box:hover{background-color:#F3E8FF; } + + +.preview_thumb{width:175px; height:100px} +.preview_thumb_template{width:170px; height:130px} + +.mid_user_thumb{max-width:30px; min-height:30px} + +.login_footer{ color:#333;font-size: 15px;font-family:"Century Gothic", Verdana, sans-serif; font-weight:bold} + +.settings_inner_title{font-size:14px; font-weight:bold} + + +/* ADMIN WIDGET */ +.widgets-wrap +{ + min-height:300px; + background:#fff; +} + +.widgets-wrap .dragbox{ + margin:0px 2px 20px; + background:#f8f8f8; + position:relative; + border:1px solid #146194; + -moz-border-radius:5px; + -webkit-border-radius:5px; +} + + +.widgets-wrap .dragbox h2{ + margin:0; + font-size:12px; + padding:5px; + background-image:url(../images/bgs/round_bg.png); background-position:right -53px; height:15px; + color:#fff; + border-bottom:none; + font-family:Verdana; + cursor:move; + display:block; font-weight:bold; +} +.dragbox-content{ + min-height:100px; margin:5px 0px; + font-family:'Lucida Grande', Verdana; font-size:0.8em; line-height:1.5em; +} +.widgets-wrap .placeholder{ + background: #f0f0f0; + border:1px dashed #ddd; +} +.dragbox h2.collapse{ + background:#1488d5 url('../images/collapse.png') no-repeat top right; +} +.dragbox h2 .configure{ + font-size:11px; font-weight:normal; + margin-right:30px; float:right; +} +.dragbox h2 .configure a{color:#fff; text-decoration:none} + +.item img{ cursor:pointer;} +.item{background-image:url(../images/widget_item_border.gif); background-position:bottom; background-repeat:repeat-x; font-size:11px; font-family:Verdana; padding:10px 5px} +.item:first-child{padding-top:0px} +.item:nth-child(2n){ background:#fff url(../images/widget_item_border.gif) repeat-x bottom } +.subitem{background:#fff;} +.index_table:first-child{padding:0px 20px 0px 0px} +.index_table:last-child{padding:0px} + +.delete_note{float:right} + + +.stats_subitem{width:20%;float:left;} +.stats_subitem_d{float:right; width:80%; text-align:right} + + +.msg{ margin:10px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; } +.msg ul{padding:0px} +.msg ul li{list-style:none; padding-left:10px; margin-bottom:5px} +.error{background-color:#fff7f7; border:1px solid #ed0000;} +.blue{background-color:#fafdff; border:1px solid #005d9c;} +.msg img{ margin-right:10px} + + + + + +#contentwrapper{ +float: left; +width: 100%; +z-index:500; +position:relative; +} + + +.contentcolumn{margin-left: 248px;} +.contentcolumn0{margin-left: 25px;} + +.innertube{ /*Margins for inner DIV inside each column (to provide padding)*/ +margin-top: 0; +} + + +.file_content{background-color:#FCFCFC; border:1px solid #CCC; padding:5px; margin:5px } +.file_content textarea{font-size:12px; color:#333; height:500px; overflow:auto;background-color:#FCFCFC; width:100%; border:none; padding:0px; margin:0px} + +.sel_file{ background-color:#FBFBFB} +.sel_file a{color:#d54e21; font-weight:bold} + +.dp_opts{right:0px; top:5px; background-color:#006699; position:absolute; color:#FFF; padding:2px; display:inline; margin:3px; border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;} +.dp_opts a{color:#fff; text-decoration:none; font-weight:bold} +#dp_opts{padding:5px; border:1px solid #e3e3e3; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; background:#f9f9f9; margin-top:0px; margin:5px; padding:5px; display:none} + +.player_dims{background-color:#E2E2E2; border-top:#666 1px solid; margin-top:5px; padding:5px} +.player_dims lable{font-weight:bold;} .player_dims input{border:1px solid #666;} + +.admin_links {margin:0px; padding:0px;} +.admin_links li{list-style:none; display:block; padding:2px 10px; margin:3px 0px; border-bottom:#666 1px dotted} +.admin_links a{font-weight:bold; font-size:12px; color:#09c; display:block} +.admin_links a:hover{color:#d54e21} + +.edit_comment{display:block; } + +.cb_div{border:1px solid #CCC; padding:10px; margin:10px; margin-left:0px } +.cb_div td{border-bottom:1px solid #CCC} +.cb_div .heading{background-color:#F2F2F2; font-weight:bold} +.cb_div input[type=submit]{padding:5px} + +.reindex_tbl .button {width:130px} +.reindex_tbl td{height:60px} + +.RatioBox { background:#0099cc; border:1px solid #026f93; font:bold 11px Tahoma; color:#FFF; text-align:center; display:inline-block; } +.smallText { font:normal 10px Tahoma; color:#7b7b7b; display:inline-block; margin-top:5px; } +.AdminBoldText { font:bold 11px Tahoma; color:#7b7b7b; } +/* I GOT FUKING ANNOYED THOSE TD's TR's SO I HAVE DEDICED TO ADD THIS CSS */ +.moveL { float:left; } +.moveR { float:right; } + +li.myAdminList { list-style:none; padding:5px 0px; border-bottom:1px solid #ccc; position:relative; } +li.myAdminList .PhotoCheckBox { width:30px; } +li.myAdminList .PhotoID { width:75px; font:bold 11px Tahoma; text-align:center; } +li.myAdminList .PhotoDetails { min-height:90px; height:90px; height:auto !important; } +li.myAdminList .PhotoDetails a { color:#0C4469; font-size:13px; font-weight:bold; text-decoration:none; } +li.myAdminList .AdminPhotoThumb { margin-right:8px; } +li.myAdminList .AdminPhotoActions a { font:bold 11px Tahoma; } +li.myAdminList .AdminPhotoActions a:hover { border-bottom:1px dashed #0099cc; } +li.myAdminList input[disabled=disabled].disabled { font:normal 11px Tahoma; padding:1px; } + +.myAdminButton { background:url(../images/gradients.png); border:1px solid #000; padding:4px; margin:0px; font:bold 11px Tahoma; color:#FFF; } +.myAdminButton[disabled] { opacity:0.5 } + +.TabButton { margin-right:25px; position:relative; border-radius:3px; -moz-border-radius:3px; padding:4px 6px; background:url(../images/gradients.png); color:#FFF; font:bold 11px Tahoma; border:1px solid #000; } +.TabButton:hover { cursor:move; } + +.delTab { font:normal 10px Verdana; background:#eee; border:1px solid white; margin:0px; padding:1px; color:#333; } +.delTab:hover { background:#000; border:1px solid white; color:#FFF; cursor:pointer; } + +.TabButton:hover .delTab { display:inline-block; } + +.uploadCategoryCheckBlock { position:relative; width:200px; } +.uploadCategoryCheckBlock br { display:none; } +.CategoryToggler { position:absolute; width:10px; height:10px; top:5px; right:5px; } +.CategoryToggler.none { background: url(../images/catgory_toggler.png) left top no-repeat; } +.CategoryToggler.block { background: url(../images/catgory_toggler.png) right top no-repeat; top:5px; } +.CategoryToggler:hover { cursor:pointer; } +.TabButton:hover .delTab { display:inline-block; } + + +.optionsLists{ + margin:0px; padding:0px; list-style:none; + width:220px; float:left; display:block + } +.optionsLists li{font-size:11px; font-weight:bold; font-family:tahoma; padding:5px; cursor:pointer} +.optionsLists li:hover{color:#09c} +.optionsLists .selected{border:1px solid #09c; border-right:0px; background-color:#fff;color:#09c} + +.optionsListsCont{ border:1px solid #09c; width:auto; margin-left:219px;padding:10px} +.templateCodeCont{ border:1px solid #757575; padding:10px; background-color:#F7F7F7;} +.templateCode{width:100%; height:100%; border:1px solid #F4F4F4; border:0px; background:none; min-height:500px;} + +.browser{background-image:url(../images/browsers.png); width:17px; height:16px; display:inline-block} +.firefox{background-position:-18px 0px} +.opera{background-position:-36px 0px} +.safari{background-position:-52px 0px} +.msie{background-position:-72px 0px} +.bot{background-image:url(../images/bot.png); background-repeat:no-repeat} + +.browsingUsers td{font-weight:bold; font-size:11px; padding:5px 2px;border-bottom:1px solid #ccc} +.browsingUsers tr:nth-child(even) td{background-color:#f3f3f3} +.browsingUsers a.kick{font-size:10px; font-family:Tahoma; color:#ed0000} + +.li_links ul, .li_links li{margin:0px; padding:0px; list-style:none} +.li_links ul{display:block;} +.li_links a{display:block; padding:3px; background-color:#fff;font-size:13px} +.li_links li:nth-child(2n) a{ background-color:#eee} + +.cb_title{background-color:#f3f3f3; font-size:12px; font-weight:bold; color:#333; border-bottom:1px solid #cccccc; height:27px; line-height:27px; padding-left:5px} +.cb_form select,.cb_form input,.cb_form textarea{border:1px solid #bbb; font-size:11px; width:200px; color:#333; padding:3px} +.cb_form textarea{width:auto} +.cb_form .cb_fieldL{float:left; width:300px; margin-right:10px} +.cb_form .cb_fieldR{float:left; width:400px;} +.cb_form .cb_field_cont{margin-bottom:10px;} +.cb_form input[type=radio],.cb_form input[type=checkbox]{width:auto !important} +.cb_form input[type=submit]{width:auto !important; color:#fff; border:1px solid #003} + +.cb_row{margin:5px 0px; padding-left:5px} +.font_12{font-size:12px} +.font_ah{font-family:Arial, Helvetica, sans-serif} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/theme/pagination.css b/upload/admin_area/styles/cbv2/theme/pagination.css new file mode 100644 index 00000000..950e162c --- /dev/null +++ b/upload/admin_area/styles/cbv2/theme/pagination.css @@ -0,0 +1,17 @@ +/* Css Document */ + +.pagination +{ + background-image:url(../images/bgs/pagination_bg.png); + background-repeat:repeat-x; + height:23px; + width:100%; + margin:auto; + line-height:23px; + color:#FFF;font-weight:bold; font-size:12px; font-family:Arial, Helvetica, sans-serif; +} + + +.pagination a, .pagination .selected{color:#FFF; font-weight:bold; font-size:13px; font-family:Arial, Helvetica, sans-serif; text-decoration:none; margin:0px 3px 0px 3px; } + +.pagination .selected{color:#FFFF97; text-decoration:underline;} \ No newline at end of file diff --git a/upload/admin_area/styles/cbv2/theme/slidemenu.css b/upload/admin_area/styles/cbv2/theme/slidemenu.css new file mode 100644 index 00000000..81976212 --- /dev/null +++ b/upload/admin_area/styles/cbv2/theme/slidemenu.css @@ -0,0 +1,117 @@ +.left_menu +{ +width: 232px; /*Width of left column*/ +padding-left: 5px; +position:relative; +} + +.left_menu_0 +{ +width: 15px; /*Width of left column*/ +overflow:hidden; +padding-left: 0px; +margin-left:1px; + +} + +#left_column{ +float: left; +margin-left: -100%; +z-index:5001; +position:relative; +} + +.left_menu .mainDiv +{ + margin-top:3px; + width:211px; + margin-bottom:5px +} +.left_menu_0 .mainDiv +{ + margin-top:3px; + width:0px; + visibility:hidden; + margin-bottom:5px + +} +.topItem,.topItemOver,.topItemClose,.topItemCloseOver +{ + letter-spacing: 0; + background-position:center center; + background-repeat:no-repeat; + border: none; + width: 211px; + height: 26px; + color: #FFFFFF; + cursor:pointer; + text-indent:10px; + font-family: Arial, Helvetica, sans-serif; + font-size: 12px; + font-weight: bold; + line-height:26px; +} +.topItem{background: url("../images/bgs/left_menu_head.png") no-repeat 0 -26px;} +.topItemOver{background: url("../images/bgs/left_menu_head.png") no-repeat 0 -52px;} + +.topItemClose{background: url("../images/bgs/left_menu_head.png") no-repeat 0 0;} +.topItemCloseOver{background: url("../images/bgs/left_menu_head.png") no-repeat 0 -78px;} + + + +.dropMenu +{ + font: bold 11px tahoma,verdana,sans-serif; + color: #000; + filter:alpha(opacity=100); + background-position:bottom; + background-repeat:no-repeat; + padding-bottom:10px; + border:1px solid #0066cc; + overflow:hidden; +} + +.subMenu +{ + display:block; +} + +.subItem,.subItemOver +{ + font: 12px tahoma,verdana,sans-serif; + text-decoration:none; + color: #215dc6; + background-color:#f8f8f8; + border-bottom:1px solid #ccc; height:25px; + +} +.subItem:nth-child(2n),.subItemOver:nth-child(2n) +{ + background-color:#f3f3f3 +} + +.subItem a,.subItemOver a +{ + font:bold 11px tahoma,verdana,sans-serif; + color:#333; + display:block; + padding-left:10px; + text-decoration:none; + font-family:Arial, Helvetica, sans-serif; + height:25px; line-height:25px; +} +.subItem a:hover,.subItemOver a:hover{ +background-color:#e9f6ff; +color:#2b495d; +} + +.drop +{ + border-left:1px solid black; + border-right:1px solid black; +} + +.menu_toggle{ background-image:url(../images/slide_toggle_2.png);position:absolute; right:0px; top:0px; z-index:5002; width:9px; height:100%; cursor:e-resize; border:1px solid #aaa;} +.menu_toggle_arrow{ background:url(../images/slide_toggle_3.png) left no-repeat; position:absolute; right:0px; top:35px; z-index:5003; width:13px; height:51px; cursor:pointer} +.left_menu .menu_toggle_arrow:hover { background:url(../images/slide_toggle_3.png) -13px no-repeat; } +.left_menu_0 .menu_toggle_arrow:hover { background:url(../images/slide_toggle_3.png) right no-repeat; } \ No newline at end of file diff --git a/upload/admin_area/template_editor.php b/upload/admin_area/template_editor.php new file mode 100644 index 00000000..fa9fcb8e --- /dev/null +++ b/upload/admin_area/template_editor.php @@ -0,0 +1,117 @@ +admin_login_check(); +$userquery->perm_check('manage_template_access',true); + + +/** + * Getting List Of Templates + */ +$templates = $cbtpl->get_templates(); + +#Checking if user has selected template for editing, if not, make SELECTED template for editing +$sel_dir = $_GET['dir']; +if(!$sel_dir || !$cbtpl->is_template($sel_dir)) +{ + $sel_dir = TEMPLATE; +} + +//Checking if still there is no template, display error +if(!$cbtpl->is_template($sel_dir)) +{ + e("No Template Found"); +}else +{ + assign('sel_dir',$sel_dir); + //Getting list template layout files , i.e HTML files + $files = $cbtpl->get_template_files($sel_dir ); + assign('tpl_files',$files); + //Getting list of css files + $css_files = $cbtpl->get_template_files($sel_dir,'theme'); + assign('css_files',$css_files); + + //Reading File + if(isset($_GET['file']) && isset($_GET['folder'])) + { + $file = STYLES_DIR.'/'.TEMPLATE.'/'.$_GET['folder'].'/'.$_GET['file']; + + if(file_exists($file)) + { + if(isset($_POST['update_file'])) + { + if(is_writable($file)) + { + //echo $file; + $data = $_POST['thecontent']; + $open_file = fopen($file, "w"); + fwrite($open_file, stripslashes($data)); + e("File has been updated","m"); + }else + e("Unable to write file"); + } + + $content = htmlentities(file_get_contents($file)); + assign('content',$content); + + if(!is_writable($file)) + assign('writeable','no'); + else + assign('writeable','yes'); + } + + } +} + + +//Getting And Listing Files +if(!file_exists(BASEDIR.'/'.TEMPLATEFOLDER.'/'.@$_GET['temp']) || @$_GET['temp']==''){ +$dir = SITETEMPLATEDIR.'/layout/'; +$cur_dir = TEMPLATE; +}else{ +$dir = BASEDIR.'/'.TEMPLATEFOLDER.'/'.$_GET['temp'].'/layout/'; +$cur_dir = $_GET['temp']; +} +if(!($dp = opendir($dir))) die("Cannot open $dir."); +while($file = readdir($dp)){ +$ext = GetExt($file); +if($ext == 'html' || $ext == 'HTML'){ +$files[] = $file; +} +} +closedir($dp +); +sort($files); +Assign('files',$files); + +//Writng File +if(isset($_POST['save'])){ + $file = $dir.$_POST['file']; + $data = stripslashes($_POST['data']); + $open_file = fopen($file, "w"); + fwrite($open_file, $data); + $msg = $_POST['file']." Has Been Saved And Updated"; +} + +//Getting Data from File +if(isset($_POST['file'])){ +$file = $dir.$_POST['file']; +$_file = $_POST['file']; +}else{ +$file = $dir.$files[0]; +$_file = $files[0]; +} +$open_file = fopen($file, "r"); +$data = htmlentities(file_get_contents($file)); + +template_files('template_editor.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/templates.php b/upload/admin_area/templates.php new file mode 100644 index 00000000..86274eb1 --- /dev/null +++ b/upload/admin_area/templates.php @@ -0,0 +1,23 @@ +admin_login_check(); +$pages->page_redir(); +$userquery->perm_check('manage_template_access',true); + +if($_GET['change']) +{ + $myquery->set_template($_GET['change']); +} + +subtitle("Template Manager"); +template_files('templates.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/upload_thumbs.php b/upload/admin_area/upload_thumbs.php new file mode 100644 index 00000000..f44262c9 --- /dev/null +++ b/upload/admin_area/upload_thumbs.php @@ -0,0 +1,75 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +if(@$_GET['msg']){ +$msg[] = clean($_GET['msg']); +} + +$video = mysql_clean($_GET['video']); + + +//Check Video Exists or Not +if($myquery->VideoExists($video)){ + + # Setting Default thumb + if(isset($_POST['update_default_thumb'])) + { + $myquery->set_default_thumb($video,$_POST['default_thumb']); + } + + $data = get_video_details($video);; + $vid_file = VIDEOS_DIR.'/'.get_video_file($data,false,false); + + # Uploading Thumbs + if(isset($_POST['upload_thumbs'])){ + $Upload->upload_thumbs($data['file_name'],$_FILES['vid_thumb']); + } + +// # Uploading Big Thumb +// if(isset($_POST['upload_big_thumb'])) { +// $Upload->upload_big_thumb($data['file_name'],$_FILES['big_thumb']); +// } + + # Delete Thumb + if(isset($_GET['delete'])) + delete_video_thumb($_GET['delete']); + + # Generating more thumbs + if(isset($_GET['gen_more'])) + { + $num = config('num_thumbs'); + $dim = config('thumb_width').'x'.config('thumb_height'); + $big_dim = config('big_thumb_width').'x'.config('big_thumb_height'); + require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php'); + $ffmpeg = new ffmpeg($vid_file); + //Generating Thumbs + $ffmpeg->generate_thumbs($vid_file,$data['duration'],$dim,$num,true); + //Generating Big Thumb + $ffmpeg->generate_thumbs($vid_file,$data['duration'],$big_dim,$num,true,true); + } + + Assign('data',$data); + Assign('rand',rand(44,444)); + +}else{ + $msg[] = lang('class_vdo_del_err'); +} + + + + +subtitle("Video Thumbs Manager"); +template_files('upload_thumbs.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/user_category.php b/upload/admin_area/user_category.php new file mode 100644 index 00000000..8f8ca9f1 --- /dev/null +++ b/upload/admin_area/user_category.php @@ -0,0 +1,67 @@ +admin_login_check(); +$userquery->login_check('admin_access'); +$pages->page_redir(); + + +//Form Processing +if(isset($_POST['add_cateogry'])){ + $userquery->add_category($_POST); +} + +//Making Categoyr as Default +if(isset($_GET['make_default'])) +{ + $cid = mysql_clean($_GET['make_default']); + $userquery->make_default_category($cid); +} + +//Edit Categoty +if(isset($_GET['category'])){ + assign("edit_category","show"); + if(isset($_POST['update_category'])) + { + $userquery->update_category($_POST); + } + assign('cat_details',$userquery->get_category($_GET['category'])); +} + +//Delete Category +if(isset($_GET['delete_category'])){ + $userquery->delete_category($_GET['delete_category']); +} + +$cats = $userquery->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']]; + $userquery->update_cat_order($cat['category_id'],$order); + } + } + $cats = $userquery->get_categories(); +} + +//Assing Category Values +assign('category',$cats); +assign('total',$userquery->total_categories()); + +Assign('msg',@$msg); +subtitle("User Category Manager"); +template_files('user_category.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/user_levels.php b/upload/admin_area/user_levels.php new file mode 100644 index 00000000..0fa05577 --- /dev/null +++ b/upload/admin_area/user_levels.php @@ -0,0 +1,86 @@ +admin_login_check(); +$pages->page_redir(); + + +$userquery->login_check('admin_access'); + + +if(!has_access('allow_manage_user_level') && $userquery->udetails['level'] != 1) +{ + $Cbucket->show_page = false; + e("You are not allowed to manage user levels"); +} + + +$mode = $_GET['mode']; +$lid = mysql_clean($_GET['lid']); +$action = mysql_clean($_GET['action']); + +//Deleteing Level +if($action=='delete') + $userquery->delete_user_level($lid); + +switch($mode) +{ + case 'view': + default: + { + Assign('view','view'); + } + break; + + case 'edit': + { + //Updating Level permissions + if(isset($_POST['update_level_perms'])) + { + $perm_array = $_POST; + $userquery->update_user_level($lid,$perm_array); + } + + + //Getting Details of $level + $levelDetails = $userquery->get_level_details($lid); + Assign('level_details',$levelDetails); + + //GettinG Level Permission + $level_perms = $userquery->get_level_permissions($lid); + + $plugin_perms = $level_perms['plugins_perms']; + $plugin_perms = json_decode($plugin_perms,true); + + assign('plugin_perms',$plugin_perms); + + Assign('level_perms',$level_perms); + + Assign('view','edit'); + } + break; + + case 'add': + { + if(isset($_POST['add_new_level'])) + { + $array = $_POST; + if($userquery->add_user_level($array)) + redirect_to('user_levels.php?added=true'); + } + Assign('view','add'); + } +} + +subtitle("User levels"); +template_files('user_levels.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/video_manager.php b/upload/admin_area/video_manager.php new file mode 100644 index 00000000..5cbe2cb9 --- /dev/null +++ b/upload/admin_area/video_manager.php @@ -0,0 +1,155 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +//Feature / UnFeature Video +if(isset($_GET['make_feature'])){ + $video = mysql_clean($_GET['make_feature']); + $cbvid->action('feature',$video); + $row = $myquery->Get_Website_Details(); + if($row['notification_option']=='1'){ + send_video_notification($video); + } + + +} +if(isset($_GET['make_unfeature'])){ + $video = mysql_clean($_GET['make_unfeature']); + $cbvid->action('unfeature',$video); +} + +//Using Multple Action +if(isset($_POST['make_featured_selected'])){ + for($id=0;$id<=count($_POST['check_video']);$id++){ + $cbvid->action('feature',$_POST['check_video'][$id]); + } + $eh->flush(); + e("Selected videos have been set as featured","m"); +} +if(isset($_POST['make_unfeatured_selected'])){ + for($id=0;$id<=count($_POST['check_video']);$id++){ + $cbvid->action('unfeature',$_POST['check_video'][$id]); + } + $eh->flush(); + e("Selected videos have been removed from featured list","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<=count($_POST['check_video']);$id++){ + $cbvid->action('activate',$_POST['check_video'][$id]); + } + $eh->flush(); + e("Selected Videos Have Been Activated","m"); +} +if(isset($_POST['deactivate_selected'])){ + for($id=0;$id<=count($_POST['check_video']);$id++){ + $cbvid->action('deactivate',$_POST['check_video'][$id]); + } + $eh->flush(); + e("Selected Videos Have Been Dectivated","m"); +} + + +//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<=count($_POST['check_video']);$id++) + { + $cbvideo->delete_video($_POST['check_video'][$id]); + } + $eh->flush(); + e(lang("vdo_multi_del_erro"),"m"); +} + + + //Calling Video Manager Functions + call_functions($cbvid->video_manager_funcs); + + $page = mysql_clean($_GET['page']); + $get_limit = create_query_limit($page,RESULTS); + + if(isset($_GET['search'])) + { + + $array = array + ( + 'videoid' => $_GET['videoid'], + 'videokey' => $_GET['videokey'], + 'title' => $_GET['title'], + 'tags' => $_GET['tags'], + 'user' => $_GET['userid'], + 'category' => $_GET['category'], + 'featured' => $_GET['featured'], + 'active' => $_GET['active'], + 'status' => $_GET['status'], + ); + } + + $result_array = $array; + //Getting Video List + $result_array['limit'] = $get_limit; + if(!$array['order']) + $result_array['order'] = " videoid DESC "; + $videos = get_videos($result_array); + + Assign('videos', $videos); + + //Collecting Data for Pagination + $vcount = $array; + $vcount['count_only'] = true; + $total_rows = get_videos($vcount); + $total_pages = count_pages($total_rows,RESULTS); + $pages->paginate($total_pages,$page); + + + //Category Array + if(is_array($_GET['category'])) + $cats_array = array($_GET['category']); + else + { + preg_match_all('/#([0-9]+)#/',$_GET['category'],$m); + $cats_array = array($m[1]); + } + $cat_array = array(lang('vdo_cat'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cats_array), + 'hint_1'=> lang('vdo_cat_msg'), + 'display_function' => 'convert_to_categories'); + assign('cat_array',$cat_array); + +subtitle("Video Manager"); +template_files('video_manager.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/admin_area/view_conversion_log.php b/upload/admin_area/view_conversion_log.php new file mode 100644 index 00000000..b7c5605e --- /dev/null +++ b/upload/admin_area/view_conversion_log.php @@ -0,0 +1,28 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +$file_name = mysql_clean($_GET['file_name']); +$file_details = $myquery->file_details($file_name); +$file_details['file_name'] = getname($file_details['File']); +$file_details['file_ext'] = getext($file_details['File']); +if($file_details) +{ + assign('data',$file_details); +} + + +subtitle("Conversion Log"); +template_files('view_conversion_log.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/view_lang_vars.php b/upload/admin_area/view_lang_vars.php new file mode 100644 index 00000000..4efbe07f --- /dev/null +++ b/upload/admin_area/view_lang_vars.php @@ -0,0 +1,73 @@ +admin_login_check(); +//$userquery->admin_login_check(); +$pages->page_redir(); + +//Adding new phrase +if(isset($_POST['button'])) +{ + $name = $_POST['name']; + $text = $_POST['text']; + $lang_obj->add_phrase($name,$text); +} + +//Getting lang variables + +$query = mysql_query("SELECT * FROM ".tbl("phrases")." ORDER BY text ASC"); + +?> +
    + + + + + + + + + + + + + + + + + + +
    Add New 
    +
    +  
      
    +
    + + + + + + + + + + + + + +
    Phrase Code +Sentence +
    + +
    diff --git a/upload/admin_area/view_user.php b/upload/admin_area/view_user.php new file mode 100644 index 00000000..0a76092c --- /dev/null +++ b/upload/admin_area/view_user.php @@ -0,0 +1,83 @@ +admin_login_check(); +$pages->page_redir(); +$userquery->login_check('member_moderation'); + +$uid = $_GET['uid']; +$udetails = $userquery->get_user_details($uid); + +if($udetails) +{ + + //Deactivating User + if(isset($_GET['deactivate'])) + { + $userquery->action('deactivate',$uid); + $udetails = $userquery->get_user_details($uid); + } + //Activating User + if(isset($_GET['activate'])) + { + $userquery->action('activate',$uid); + $udetails = $userquery->get_user_details($uid); + } + //Banning User + if(isset($_GET['ban'])) + { + $userquery->action('ban',$uid); + $udetails = $userquery->get_user_details($uid); + } + //Unbanning User + if(isset($_GET['unban'])) + { + $userquery->action('unban',$uid); + $udetails = $userquery->get_user_details($uid); + } + + //Deleting User + if(isset($_GET['delete'])) + $userquery->delete_user($uid); + //Deleting User Videos + if(isset($_GET['delete_vids'])) + $userquery->delete_user_vids($uid); + //Deleting User Contacts + if(isset($_GET['delete_contacts'])) + $userquery->remove_contacts($uid); + //Deleting User Pms + if(isset($_GET['delete_pms'])) + $userquery->remove_user_pms($uid); + + + //Deleting Comment + $cid = mysql_clean($_GET['delete_comment']); + if(!empty($cid)) + { + $myquery->delete_comment($cid); + } + + if(isset($_POST['update_user'])) + { + $userquery->update_user($_POST); + if(!error()) + $udetails = $userquery->get_user_details($uid); + } + + $profile = $userquery->get_user_profile($udetails['userid']); + $user_profile = array_merge($udetails,$profile); + assign('u',$udetails); + assign('p',$user_profile); +}else{ + e("No User Found"); + $CBucket->show_page = false; +} + +subtitle("View User"); +template_files("view_user.html"); +display_it(); +?> \ No newline at end of file diff --git a/upload/admin_area/view_video.php b/upload/admin_area/view_video.php new file mode 100644 index 00000000..d955663f --- /dev/null +++ b/upload/admin_area/view_video.php @@ -0,0 +1,54 @@ +admin_login_check(); +$userquery->login_check('video_moderation'); +$pages->page_redir(); + +if(@$_GET['msg']){ +$msg[] = clean($_GET['msg']); +} + + $video = mysql_clean($_GET['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); + } + + //Get Video Details + $data = get_video_details($video); + Assign('udata',$userquery->get_user_details($data['userid'])); + Assign('data',$data); + }else{ + $msg[] = lang('class_vdo_del_err'); + } + + + + +Assign('msg',@$msg); +/*Template('header.html'); +Template('leftmenu.html'); +Template('message.html'); +Template('view_video.html'); +Template('footer.html');*/ + + +subtitle("View Video"); +template_files('view_video.html'); +display_it(); + + +?> \ No newline at end of file diff --git a/upload/ajax.php b/upload/ajax.php new file mode 100644 index 00000000..b65c8572 --- /dev/null +++ b/upload/ajax.php @@ -0,0 +1,1513 @@ +perm_check('view_videos',false,true) ) + exit(); + + $videos = get_videos(array('limit'=>config('videos_items_hme_page'),'order'=>'last_viewed DESC')); + if($videos) + foreach($videos as $video) + { + assign('video',$video); + Template('blocks/video.html'); + } + } + break; + + case 'most_viewed': + { + if(!isSectionEnabled('videos') || !$userquery->perm_check('view_videos',false,true) ) + exit(); + $videos = get_videos(array('limit'=>config('videos_items_hme_page'),'order'=>'views DESC')); + if($videos) + foreach($videos as $video) + { + assign('video',$video); + Template('blocks/video.html'); + } + } + break; + + case 'recently_added': + { + if(!isSectionEnabled('videos') || !$userquery->perm_check('view_videos',false,true) ) + exit(); + $videos = get_videos(array('limit'=>config('videos_items_hme_page'),'order'=>'date_added DESC')); + if($videos) + foreach($videos as $video) + { + assign('video',$video); + Template('blocks/video.html'); + } + } + break; + + case 'featured_videos': + { + if(!isSectionEnabled('videos') || !$userquery->perm_check('view_videos',false,true) ) + exit(); + $videos = get_videos(array('limit'=>config('videos_items_hme_page'),'featured'=>'yes','order'=>'featured_date DESC')); + if($videos) + foreach($videos as $video) + { + assign('video',$video); + Template('blocks/video.html'); + } + } + break; + + + case 'rating': + { + switch($_POST['type']) + { + case "video": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $cbvid->rate_video($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_video'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + + case "photo": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $cbphoto->rate_photo($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_photo'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + case "collection": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $cbcollection->rate_collection($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_collection'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + + case "user": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $userquery->rate_user($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_user'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + } + } + break; + + + case 'share_object': + { + + $type = strtolower($_POST['type']); + switch($type) + { + case 'v': + case 'video': + default: + { + $id = mysql_clean($_POST['id']); + $vdo = $cbvid->get_video($id); + $cbvid->set_share_email($vdo); + $cbvid->action->share_content($vdo['videoid']); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + echo $msg; + } + break; + + case "p": + case "photo": + { + $id = $_POST['id']; + $ph = $cbphoto->get_photo($id); + $cbphoto->set_share_email($ph); + $cbphoto->action->share_content($ph['photo_id']); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + echo $msg; + } + break; + + case "cl": + case "collection": + { + $id = $_POST['id']; + $cl = $cbcollection->get_collection($id); + $cbcollection->set_share_mail($cl); + $cbcollection->action->share_content($cl['collection_id']); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + echo $msg; + } + break; + } + } + break; + + + case 'add_to_fav': + { + $type = strtolower($_POST['type']); + switch($type) + { + case 'v': + case 'video': + default: + { + $id = $_POST['id']; + $cbvideo->action->add_to_fav($id); + updateObjectStats('fav','video',$id); // Increment in total favs + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + $funcs = cb_get_functions('favorite_video'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + + echo $msg; + } + break; + + case 'p': + case 'photo': + { + $id = $_POST['id']; + $cbphoto->action->add_to_fav($id); + updateObjectStats('fav','photo',$id); // Increment in total favs + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + $funcs = cb_get_functions('favorite_photo'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + + echo $msg; + } + break; + + case "cl": + case "collection": + { + $id = $_POST['id']; + $cbcollection->action->add_to_fav($id); + //updateObjectStats('fav','collection',$id); // Increment in total favs + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + $funcs = cb_get_functions('favorite_collection'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + + echo $msg; + } + break; + } + } + break; + + + case 'flag_object': + { + $type = strtolower($_POST['type']); + switch($type) + { + case 'v': + case 'video': + default: + { + $id = $_POST['id']; + $reported = $cbvideo->action->report_it($id); + /*if(!error()){ + /* SENDING EMAIL TO ADMIN + $template = $cbemail->get_template('flag_template'); + $video = $cbvideo->get_video_details($id); + $emailVars = array( + "{video_link}" => videoLink($video), + "{video_title}" => $video['title'], + "{flag_reason}" => flag_type(post('flag_type')), + "{type}" => "video" + ); + $admins = $userquery->get_level_users(1,false,'userid,email'); + $libs = $userquery->get_level_users(17,false,'userid,email'); + if($libs) + $users = array_merge($admins,$libs); + else + $users = $admins; + foreach ($users as $user) + { + if(isValidEmail($user['email'])) + $emailsArray[] = $user['email']; + } + + if(!is_array($var)) + $var = array(); + $vars = array_merge($emailVars,$var); + $subj = $cbemail->replace($template['email_template_subject'],$vars); + $msg = nl2br($cbemail->replace($template['email_template'],$vars)); + + cbmail(array('to'=>$emailsArray,'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + }*/ + } + break; + + case 'g': + case 'group': + default: + { + $id = $_POST['id']; + $cbgroup->action->report_it($id); + } + break; + + case 'u': + case 'user': + default: + { + $id = $_POST['id']; + $userquery->action->report_it($id); + } + break; + + case 'p': + case 'photo': + { + $id = $_POST['id']; + $cbphoto->action->report_it($id); + } + break; + + case "cl": + case "collection": + { + $id = $_POST['id']; + $cbcollection->action->report_it($id); + } + break; + + } + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + + echo $msg; + } + break; + + + case 'subscribe_user': + { + $subscribe_to = mysql_clean($_POST['subscribe_to']); + $userquery->subscribe_user($subscribe_to); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + echo $msg; + } + break; + + case 'unsubscribe_user': + { + $subscribe_to = mysql_clean($_POST['subscribe_to']); + $userquery->unsubscribe_user($subscribe_to); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + echo $msg; + } + break; + + + case 'add_friend': + { + $friend = mysql_clean($_POST['uid']); + $userid = userid(); + + if($userid) { + $userquery->add_contact($userid,$friend); + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + echo $msg; + } else { + echo '
    '.e(lang('you_not_logged_in')).'
    '; + } + } + break; + + case 'ban_user': + { + $user = $_POST['user']; + $userquery->ban_user($user); + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + if(error()) + { + $msg = error_list(); + $msg = '
    '.$msg[0].'
    '; + } + echo $msg; + + } + break; + + case 'rate_comment': + { + $thumb = $_POST['thumb']; + $cid = mysql_clean($_POST['cid']); + if($thumb!='down') + $rate = 1; + else + $rate = -1; + + $rating = $myquery->rate_comment($rate,$cid); + if(msg()) + { + $msg = msg_list(); + $msg = $msg[0]; + } + if(error()) + { + $msg = error_list(); + $msg = $msg[0]; + } + + $ajax['msg'] = $msg; + $ajax['rate'] = comment_rating($rating); + + //updating last update... + $type = mysql_clean($_POST['type']); + $typeid = mysql_clean($_POST['typeid']); + update_last_commented($type,$typeid); + + + 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; + + $type = mysql_clean($_POST['type']); + $typeid = mysql_clean($_POST['typeid']); + + if($_POST['type'] != 't') + update_last_commented($type,$typeid); + + echo json_encode($ajax); + } + break; + + case 'add_comment'; + { + $type = $_POST['type']; + switch($type) + { + case 'v': + case 'video': + default: + { + $id = mysql_clean($_POST['obj_id']); + $comment = $_POST['comment']; + if($comment=='undefined') + $comment = ''; + $reply_to = $_POST['reply_to']; + + $cid = $cbvid->add_comment($comment,$id,$reply_to); + } + break; + case 'u': + case 'c': + { + + $id = mysql_clean($_POST['obj_id']); + $comment = $_POST['comment']; + if($comment=='undefined') + $comment = ''; + $reply_to = $_POST['reply_to']; + + $cid = $userquery->add_comment($comment,$id,$reply_to); + } + break; + case 't': + case 'topic': + { + + $id = mysql_clean($_POST['obj_id']); + $comment = $_POST['comment']; + if($comment=='undefined') + $comment = ''; + $reply_to = $_POST['reply_to']; + + $cid = $cbgroup->add_comment($comment,$id,$reply_to); + } + break; + + case 'cl': + case 'collection': + { + $id = mysql_clean($_POST['obj_id']); + $comment = $_POST['comment']; + if($comment=='undefined') + $comment = ''; + $reply_to = $_POST['reply_to']; + + $cid = $cbcollection->add_comment($comment,$id,$reply_to); + } + break; + + case "p": + case "photo": + { + $id = mysql_clean($_POST['obj_id']); + $comment = $_POST['comment']; + if($comment=='undefined') + $comment = ''; + $reply_to = $_POST['reply_to']; + $cid = $cbphoto->add_comment($comment,$id,$reply_to); + } + break; + + } + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    ';; + } + if(error()) + { + $err = error_list(); + $err = '
    '.$err[0].'
    ';; + } + + $ajax['msg'] = $msg ? $msg : ''; + $ajax['err'] = $err; + + //Getting Comment + if($cid) + { + $ajax['cid'] = $cid; + } + + echo json_encode($ajax); + + } + break; + + case 'get_comment'; + { + $id = mysql_clean($_POST['cid']); + $new_com = $myquery->get_comment($id); + assign('comment',$new_com); + Template('blocks/comments/comment.html'); + } + break; + + + + /** + * Function used to add item in playlist + */ + case 'add_playlist'; + { + $id = mysql_clean($_POST['id']); + $pid = mysql_clean($_POST['pid']); + + $type = post('objtype'); + + if($type=='video') + { + $cbvid->action->add_playlist_item($pid,$id ); + updateObjectStats('plist','video',$id); + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    ';; + } + if(error()) + { + $err = error_list(); + $err = '
    '.$err[0].'
    ';; + } + + $ajax['msg'] = $msg ? $msg : ''; + $ajax['err'] = $err ? $err : ''; + + + echo json_encode($ajax); + } + + } + break; + + + case 'add_new_playlist'; + { + + if(post('objtype')=='video') + { + $vid = mysql_clean($_POST['id']); + + $params = array('name'=>mysql_clean($_POST['plname'])); + $pid = $cbvid->action->create_playlist($params); + + if($pid) + { + $eh->flush(); + $cbvid->action->add_playlist_item($pid,$vid); + } + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    ';; + } + if(error()) + { + $err = error_list(); + $err = '
    '.$err[0].'
    ';; + } + + $ajax['msg'] = $msg ? $msg : ''; + $ajax['err'] = $err ? $err : ''; + + + echo json_encode($ajax); + } + + } + break; + + + case 'quicklist': + { + + $todo = $_POST['todo']; + $id = mysql_clean($_POST['vid']); + + if($todo == 'add') + { + $return = $cbvid->add_to_quicklist($id); + }else + $return = $cbvid->remove_from_quicklist($id); + + echo $return; + } + break; + + case 'getquicklistbox'; + { + //$cookie = $_COOKIE[QUICK_LIST_SESS]; + //$vids = json_decode($cookie,true); + if($cbvid->total_quicklist()>0) + TEMPLATE('blocks/quicklist/block.html'); + } + break; + + case 'clear_quicklist': + { + $cbvid->clear_quicklist(); + return 'removed'; + } + 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; + case 'cl': + case 'collection': + { + $cid = mysql_clean($_POST['cid']); + $type_id = $myquery->delete_comment($cid); + $cbcollection->update_total_comments($type_id); + } + + } + 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 "add_new_item": + { + $type = $_POST['type']; + + switch($type) + { + case "videos": + case "video": + case "v": + { + $cid = $_POST['cid']; + $id = $_POST['obj_id']; + $cbvideo->collection->add_collection_item($id,$cid); + } + break; + + case "photos": + case "photo": + case "p": + { + $cid = $_POST['cid']; + $id = $_POST['obj_id']; + $cbphoto->collection->add_collection_item($id,$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_collection_item": + { + $type = $_POST['type']; + + switch($type) + { + case "videos": + { + $obj_id = $_POST['obj_id']; + $cid = $_POST['cid']; + $cbvideo->collection->remove_item($obj_id,$cid); + } + break; + + case "photos": + { + $obj_id = $_POST['obj_id']; + $cid = $_POST['cid']; + $cbphoto->collection->remove_item($obj_id,$cid); + $cbphoto->make_photo_orphan($cid,$obj_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 "get_item": + { + $item_id = mysql_clean($_POST['ci_id']); + $cid = mysql_clean($_POST['cid']); + $direc = mysql_clean($_POST['direction']); + $t = mysql_clean($_POST['type']); + + switch($t) + { + case "videos": + case "video": + case "v": + { + $N_item = $cbvideo->collection->get_next_prev_item($item_id,$cid,$direc); + //increment_views($N_item[0]['videoid'],'video'); + $ajax['key'] = $N_item[0]['videokey']; + $ajax['cid'] = $N_item[0]['collection_id']; + } + break; + + case "photos": + case "photo": + case "p": + { + $N_item = $cbphoto->collection->get_next_prev_item($item_id,$cid,$direc); + increment_views($N_item[0]['photo_id'],'photo'); + $ajax['key'] = $N_item[0]['photo_key']; + $ajax['cid'] = $N_item[0]['collection_id']; + + } + break; + } + + if($N_item) + { + assign('type',$t); + assign('user',$userquery->get_user_details($N_item[0]['userid'])); + assign('object',$N_item[0]); + $ajax['content'] = Fetch('view_item.html'); + echo json_encode($ajax); + } else { + return false; + } + } + break; + + case "load_more_items": + case "more_items": + case "moreItems": + { + $cid = mysql_clean($_POST['cid']); + $page = mysql_clean($_POST['page']); + $newPage = $page+1; + $type = mysql_clean($_POST['type']); + $limit = create_query_limit($page,COLLIP); + $order = tbl("collection_items").".ci_id DESC"; + + switch($type) + { + case "videos": + case "video": + case "v": + { + $items = $cbvideo->collection->get_collection_items_with_details($cid,$order,$limit); + } + break; + + case "photos": + case "photo": + case "p": + { + $items = $cbphoto->collection->get_collection_items_with_details($cid,$order,$limit); + } + break; + } + if($items) + { + assign('page_no',$newPage); + assign('type',$type); + assign('cid',$cid); + $itemsArray['pagination'] = Fetch("blocks/new_pagination.html"); + + foreach($items as $item) + { + assign('object',$item); + assign('display_type','view_collection'); + assign('type',$type); + $itemsArray['content'] .= Fetch("blocks/collection.html"); + } + + echo json_encode($itemsArray); + } else + echo json_encode(array("error"=>TRUE)); + } + break; + + + case "add_collection": + { + $name = ($_POST['collection_name']); + $desc = ($_POST['collection_description']); + $tags = (genTags($_POST['collection_tags'])); + $cat = ($_POST['category']); + $type = "photos"; + $CollectParams = + array("collection_name"=>$name,"collection_description"=>$desc,"collection_tags"=>$tags,"category"=>$cat,"type"=>$type,"allow_comments"=>"yes","broadcast"=>"public","public_upload"=>"yes"); + $insert_id = $cbcollection->create_collection($CollectParams); + + if(msg()) + { + $msg = msg_list(); + $msg = '
    '.$msg[0].'
    '; + } + + if(error()) + { + $err = error_list(); + $err = '
    '.$err[0].'
    '; + } + + $ajax['msg'] = $msg; + $ajax['err'] = $err; + $ajax['id'] = $insert_id; + + echo json_encode($ajax); + } + break; + + case "ajaxPhotos": + { + $cbphoto->insert_photo(); + + 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 "viewPhotoRating": + { + $pid = mysql_clean($_POST['photoid']); + $returnedArray = $cbphoto->photo_voters($pid); + echo ($returnedArray); + } + break; + + case "channelFeatured": + { + $contentType = $_POST['contentType']; + if(!$contentType) + echo json_encode(array("error"=>lang("content_type_empty"))); + else + { + switch($contentType) + { + case "videos": case "video": + case "vid": case "v": case "vdo": + { + $video = $cbvideo->get_video_details(mysql_clean($_POST['objID'])); + if($video) + { + assign('object',$video); + $content = Fetch('/blocks/view_channel/channel_item.html'); + } + } + break; + + case "photo": case "photos": + case "foto": case "p": + { + $photo = $cbphoto->get_photo(mysql_clean($_POST['objID'])); + if($photo) + { + assign('object',$photo); + $content = Fetch('/blocks/view_channel/channel_item.html'); + } + } + break; + } + + if($content) + { + echo json_encode(array("data"=>$content)); + } else + echo json_encode(array("error"=>"Nothing Found")); + } + } + break; + + case "channelObjects": + { + $contentType = strtolower(mysql_clean($_POST['content'])); + $u = $userquery->get_user_details($_POST['user']); + $assign = $_POST['assign']; + if(is_array($assign)) + { + foreach($assign as $var=>$value) + assign($var,$value); + } + switch($contentType) + { + case "videos" : + { + $videos = get_videos(array("user"=>$u['userid'],"order"=>" date_added DESC","limit"=>config('videos_item_channel_page'))); + + if($videos) + { + foreach($videos as $video) + { + assign('video',$video); + assign('channelVideo',true); + $content['html'] .= Fetch("/blocks/video.html"); + } + $content['html'] .= ''; + } else { + $content['html'] = '
    '.lang('user_have_no_vide').'
    '; + } + } + break; + + case "photos": + { + $photos = get_photos(array("user"=>$u['userid'],"order"=>" date_added DESC","limit"=>config('photo_channel_page'))); + if($photos) + { + foreach($photos as $photo) + { + assign('photo',$photo); + assign('channelPhoto',true); + $content['html'] .= Fetch("/blocks/photo.html"); + } + $content['html'] .= ''; + } else { + $content['html'] = '
    '.lang('User dont have any photos').'
    '; + } + } + break; + + case "groups": + { + $groups = get_groups(array("user"=>$u['userid'],"order"=>" date_added DESC","limit"=>config('photo_channel_page'))); + if($groups) + { + foreach($groups as $group) + { + assign('group',$group); + assign('channelGroup',true); + $content['html'] .= Fetch("/blocks/group.html"); + } + } else { + $content['html'] = '
    '.lang('User dont have any groups.').'
    '; + } + } + break; + + case "collections": + { + $collections = get_collections(array("user"=>$u['userid'],"order"=>" date_added DESC","limit"=>config('collection_channel_page'))); + if($collections) + { + foreach($collections as $collection) + { + assign('collection',$collection); + assign('channelCollection',true); + $content['html'] .= Fetch("/blocks/collection.html"); + } + $content['html'] .= ''; + } else { + $content['html'] = '
    '.lang('User dont have any collections').'
    '; + } + } + break; + + case "friends": + { + $friends = $userquery->get_contacts($u['userid'],'0','yes'); + if($friends) + { + foreach($friends as $friend) + { + assign('user',$friend); + assign('channelUser','friends'); + $content['html'] .= Fetch("/blocks/user.html"); + } + } else { + $content['html'] = '
    '.lang('User dont any friends yet').'
    '; + } + } + break; + + case "subscriptions": + { + $limit = config('users_items_subscriptions'); + $subscriptions = $userquery->get_user_subscriptions($u['userid'],$limit); + if($subscriptions) + { + foreach($subscriptions as $subscription) + { + assign('user',$subscription); + assign('channelUser','subscriptions'); + $content['html'] .= Fetch("/blocks/user.html"); + } + $content['html'] .= ''; + } else { + $content['html'] = '
    '.sprintf(lang('user_no_subscriptions'),$u['username']).'
    '; + } + } + break; + + case "subscribers": + { + $limit = config('users_items_subscribers'); + $subscribers = $userquery->get_user_subscribers_detail($u['userid'],$limit); + if($subscribers) + { + foreach($subscribers as $subscriber) + { + assign('user',$subscriber); + assign('channelUser','subscribers'); + $content['html'] .= Fetch("/blocks/user.html"); + } + $content['html'] .= ''; + } else { + $content['html'] = '
    '.sprintf(lang('user_no_subscribers'),$u['username']).'
    '; + } + } + break; + + case "info": + { + + } + break; + } + + if($content) + echo json_encode($content); + + } + break; + + case "viewCollectionRating": + { + $cid = mysql_clean($_POST['cid']); + $returnedArray = $cbcollection->collection_voters($cid); + echo ($returnedArray); + } + break; + + case "loadAjaxPhotos": + { + $photosType = $_POST['photosType']; + $cond = array("limit"=>config("photo_home_tabs")); + switch($photosType) + { + case "last_viewed": + default: + { + $cond['order'] = " last_viewed DESC"; + } + break; + + case "most_recent": + { + $cond['order'] = " date_added DESC"; + } + break; + + case "featured": + { + $cond['featured'] = "yes"; + } + break; + + case "most_favorited": + { + $cond['order'] = " total_favorites DESC"; + } + break; + + case "most_commented": + { + $cond['order'] = " total_comments DESC"; + } + break; + + case "highest_rated": + { + $cond['order'] = " rating DESC, rated_by DESC"; + } + break; + + case "most_viewed": + { + $cond['order'] = " views DESC"; + } + break; + + case "most_downloaded": + { + $cond['order'] = " downloaded DESC"; + } + break; + } + + $photos = get_photos($cond); + if($photos) + { + foreach($photos as $photo) + { + assign("photo",$photo); + $cond['photoBlocks'] .= Fetch("/blocks/photo.html"); + } + $cond['completed'] = "successfull"; + } else { + $cond['failed'] = "successfully"; + } + + echo json_encode($cond); + } + break; + + /** + * Getting comments along with template + */ + case "getComments": + { + $params = array(); + $limit = config('comments_per_page'); + $page = $_POST['page']; + $params['type'] = mysql_clean($_POST['type']); + $params['type_id'] = mysql_clean($_POST['type_id']); + $params['last_update'] = mysql_clean($_POST['last_update']); + $params['limit'] = create_query_limit($page,$limit); + + $admin = ""; + if($_POST['admin']=='yes' && has_access('admin_access',true)) + { + $params['cache'] ='no'; + $admin = "yes"; + } + $comments = $myquery->getComments($params); + //Adding Pagination + $total_pages = count_pages($_POST['total_comments'],$limit); + assign('object_type',mysql_clean($_POST['object_type'])); + //Pagination + $pages->paginate($total_pages,$page,NULL,NULL,'#page#'); + + assign('comments',$comments); + assign('type',$params['type']); + assign('type_id',$params['type_id']); + assign('last_update',$params['last_update']); + assign('total',$_POST['total_comments']); + assign('total_pages',$total_pages); + assign('comments_voting',$_POST['comments_voting']); + + if($_POST['admin']=='yes' && has_access('admin_access',true)) + Template(BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/cbv2/layout/blocks/comments.html',false); + else + Template('blocks/comments/comments.html'); + + assign('commentPagination','yes'); + Template('blocks/pagination.html'); + } + break; + + + + case "get_news": + { + $news = $Cbucket->get_cb_news(); + + if($news) + foreach($news as $n) + { + echo '
    '; + echo '
    + '.$n['title'].' + '.date("m-d-Y",strtotime($n['pubDate'])).'
    + '; + echo '
    '; + echo $n['description']; + echo '
    '; + echo '
    '; + } + else + echo '
    Unable to fetch news
    '; + } + break; + + + case "delete_feed": + { + $uid = mysql_clean($_POST['uid']); + $file = mysql_clean($_POST['file']).'.feed'; + if($uid && $file) + { + if($uid==userid() || has_access("admin_access",true)) + { + $cbfeeds->deleteFeed($uid,$file); + $array['msg'] = lang("feed_has_been_deleted"); + }else + $array['err'] = lang("you_cant_del_this_feed"); + } + echo json_encode($array); + } + break; + + + case "become_contributor" : + { + $uid = userid(); + $cid = $_POST['cid']; + + $array = array(); + + if($cbcollection->add_contributor($cid,$uid)) + { + $array['msg'] = 'Successfully added as contributor'; + } else + { + $array['err'] = error('single'); + } + + + echo json_encode($array); + } + break; + + case "remove_contributor" : + { + $uid = userid(); + $cid = $_POST['cid']; + + $array = array(); + + if($cbcollection->remove_contributor($cid,$uid)) + { + $array['msg'] = 'Successfully removed from contributors'; + } else + { + $array['err'] = error('single'); + } + + + echo json_encode($array); + } + break; + + + default: + header('location:'.BASEURL); + + + } +}else + header('location:'.BASEURL); + +?> \ No newline at end of file diff --git a/upload/api/auth.php b/upload/api/auth.php new file mode 100644 index 00000000..aefa9f5b --- /dev/null +++ b/upload/api/auth.php @@ -0,0 +1,132 @@ +api_keys; +if($api_keys) +{ + if(!in_array($request['api_key'],$api_keys)) + { + exit(json_encode(array('err'=>'App authentication error'))); + } +} + +switch($mode) +{ + case "login": + { + $uDetails = array('username','userid','email','total_videos','total_photos','total_collections','total_groups'); + + $userDetails = array(); + foreach($uDetails as $ud) + { + $userDetails[$ud] = $userquery->udetails[$ud]; + } + + $userDetails['sess_id'] = $_COOKIE['PHPSESSID']; + + + $username = $request['username']; + $password = $request['password']; + + if($userquery->userid) + { + $userDetails['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($userDetails); + exit(json_encode(array('status'=>'ok','userid'=>$userquery->userid,'details'=>$userDetails))); + } + + function onLoginMobile() + { + global $userquery; + + $uDetails = array('username','userid','email','total_videos','total_photos','total_collections','total_groups'); + + $userDetails = array(); + foreach($uDetails as $ud) + { + $userDetails[$ud] = $userquery->udetails[$ud]; + } + + $userDetails['sess_id'] = $_COOKIE['PHPSESSID']; + + $userDetails['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($userDetails); + + exit(json_encode(array('status'=>'ok','userid'=>$userquery->userid,'type'=>'custom','details'=>$userDetails))); + } + + $onLogin = 'onLoginMobile'; + + if(cb_get_functions('signup_page')) cb_call_functions('signup_page'); + + + $userquery->login_user($username,$password); + + if(error()) + { + exit(json_encode(array('status'=>'failed','msg'=>error('single')))); + }else + { + $uDetails = array('username','userid','email','total_videos','total_photos','total_collections','total_groups'); + + $userDetails = array(); + foreach($uDetails as $ud) + { + $userDetails[$ud] = $userquery->udetails[$ud]; + } + + $userDetails['sess_id'] = $_COOKIE['PHPSESSID']; + + $userDetails['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($userDetails); + + exit(json_encode(array('status'=>'ok','userid'=>$userquery->userid,'sess_id'=> $_COOKIE['PHPSESSID'],'details'=>$userDetails))); + } + } + break; + + case "getUser": + case "check_auth": + case "is_logged_in": + case "checkAuth": + case "isLoggedIn": + { + $userid = userid(); + if(!userid()) + exit(json_encode(array('status'=>'failed','msg'=>'User is not logged in','session'=>$_COOKIE['PHPSESSID']))); + else + { + $uDetails = array('username','userid','email','total_videos','total_photos','total_collections','total_groups'); + + $userDetails = array(); + foreach($uDetails as $ud) + { + $userDetails[$ud] = $userquery->udetails[$ud]; + } + + $userDetails['sess_id'] = $_COOKIE['PHPSESSID']; + $userDetails['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($userDetails); + exit(json_encode($userDetails)); + } + } + break; + + case "logout": + { + + $userquery->logout(); + if(cb_get_functions('logout')) cb_call_functions('logout'); + setcookie('is_logout','yes',time()+3600,'/'); + } +} +?> \ No newline at end of file diff --git a/upload/api/file_uploader.php b/upload/api/file_uploader.php new file mode 100644 index 00000000..aca10a84 --- /dev/null +++ b/upload/api/file_uploader.php @@ -0,0 +1,108 @@ + $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, $file_directory); + +//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 &"); +} + +$status_array['success'] = 'yes'; +$status_array['file_name'] = $file_name; + +echo json_encode($status_array); + +//function used to display error +function upload_error($error) +{ + echo json_encode(array("error" => $error)); +} + +?> \ No newline at end of file diff --git a/upload/api/get.php b/upload/api/get.php new file mode 100644 index 00000000..08bad370 --- /dev/null +++ b/upload/api/get.php @@ -0,0 +1,676 @@ +api_keys; +if ($api_keys) { + if (!in_array($request['api_key'], $api_keys)) { + exit(json_encode(array('err' => 'App authentication error'))); + } +} + +switch ($mode) { + case "getVideos": + case "get_videos": + default: { + $blacklist_fields = array( + 'password', 'video_password', 'avcode', 'session' + ); + + $get_limit = create_query_limit($page, $videos_limit); + + $request['limit'] = $get_limit; + + if (VERSION < 3) + $request['user'] = $request['userid']; + + //$request['order'] = tbl('video.'.$request['order']); + + $vids = $request['video_id']; + + if ($vids) { + $vids = explode(',', $vids); + + $request['videoids'] = $vids; + } + + if($is_mobile) + $request['has_mobile'] = 'yes'; + + $videos = $cbvid->get_videos($request); + header('Content-Type: text/html; charset=utf-8'); + + $new_videos = array(); + if ($videos) { + foreach ($videos as $video) { + + $video['title'] = utf8_encode($video['title']); + $video['description'] = utf8_encode($video['description']); + $video['thumbs'] = array('default' => get_thumb($video), 'big' => get_thumb($video, 'big')); + + if (function_exists('get_mob_video')) { + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + if (has_hq($video)) { + $video['videos']['hq'] = get_hq_video_file($video); + } + } + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + $video['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($video); + + /* + if (!$video['fullname']) + { + $video['userDetail'] = $userquery->get_user_details($video['userid']); + } + */ + + foreach ($blacklist_fields as $field) + unset($video[$field]); + + $new_videos[] = $video; + } + } + //echo $db->db_query; + echo json_encode($new_videos); + } + break; + + case "getComments": { + $params = array(); + $limit = config('comments_per_page'); + $page = $request['page']; + + if (!$page || !is_numeric($page) || $page < 1) + $page = 1; + + if (!$limit || !is_numeric($limit) || $limit < 1) + $limit = 20; + + + $params['type'] = mysql_clean($request['type']); + $params['type_id'] = mysql_clean($request['type_id']); + $params['last_update'] = mysql_clean($request['last_update']); + $params['limit'] = create_query_limit($page, $limit); + + $comments = $myquery->getComments($params); + + $blacklist_fields = array( + 'password', 'video_password', 'avcode', 'session' + ); + + $the_comments = array(); + + if ($comments) + foreach ($comments['comments'] as $comment) { + if ($comment) { + + foreach ($blacklist_fields as $field) { + unset($comment[$field]); + } + $the_comments[] = $comment; + } + } + + + echo json_encode($the_comments); + } + break; + + case "getCategory": + case "getCategories": { + $type = $request['type']; + switch ($type) { + case "v": + case "video": + case "videos": + default: { + $categories = $cbvid->getCbCategories(arraY('indexes_only' => true)); + } + break; + + case "u": + case "user": + case "users": { + $categories = $userquery->getCbCategories(arraY('indexes_only' => true)); + } + + break; + + case "g": + case "group": + case "groups": { + $categories = $cbgroup->getCbCategories(arraY('indexes_only' => true)); + } + + case "p": + case "photo": + case "photos": { + $categories = $cbcollection->getCbCategories(arraY('indexes_only' => true)); + } + } + echo json_encode($categories); + } + break; + + case 'getFields': + case 'get_fields': { + $groups = $Upload->load_video_fields(null); + + $new_groups = array(); + foreach ($groups as $group) { + $new_fields = array(); + + foreach ($group['fields'] as $field) { + // foreach($fields as $field) + if ($field) + $new_fields[] = $field; + } + + $group['fields'] = $new_fields; + $new_groups[] = $group; + } + + //pr($new_groups,true); + echo json_encode($new_groups); + } + break; + case "get_playlists": + case "getPlaylists": { + $uid = mysql_clean($request['userid']); + + $playlists = $cbvid->action->get_playlists($uid); + + if (VERSION < 3) { + $new_playlists = array(); + foreach ($playlists as $playlist) { + $playlist['total_items'] = $cbvid->action->count_playlist_items($playlist['playlist_id']); + $new_playlists[] = $playlist; + } + + $playlists = $new_playlists; + } + + if ($playlists) + echo json_encode($playlists); + else + echo json_encode(array('err' => 'No playlist was found')); + } + + break; + case "get_playlist_items": + case "getPlaylistItems": { + $pid = mysql_clean($request['playlist_id']); + $items = $cbvid->get_playlist_items($pid); + + $blacklist_fields = array( + 'password', 'video_password', 'avcode', 'session' + ); + + if ($items) { + $new_videos = array(); + + foreach ($items as $video) { + if (!$video['email']) { + $udetails = $userquery->get_user_details($video['userid']); + } + + $video = array_merge($video, $udetails); + + $video['thumbs'] = array('default' => get_thumb($video)); + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + $video['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($video); + + foreach ($blacklist_fields as $field) + unset($video[$field]); + + $new_videos[] = $video; + } + echo json_encode($new_videos); + }else + echo json_encode(array('err' => 'No items in this playlist')); + } + break; + + case "getConfigs": + case "get_configs": + case "configs": { + $upload_path = ''; + + if (function_exists('get_file_uploader_path')) + $upload_path = get_file_uploader_path(); + + $array = array( + 'baseurl' => BASEURL, + 'title' => TITLE, + 'file_upload_url' => BASEURL . '/api/file_uploader.php', + 'session' => session_id() + ); + + echo json_encode($array); + } + + break; + + case "videoFlagOptions": + case "video_flag_options": { + $type = $request['type']; + $type = $type ? $type : 'v'; + + $flags = get_flag_options($type); + + echo json_encode($flags); + } + + + break; + case "getSubscribers": { + $uid = $request['userid']; + if (!$uid) + $uid = userid(); + + if (!$uid) + exit(json_encode(array('err' => lang('Please login')))); + + $subscribers = $userquery->get_user_subscribers_detail($uid); + + if ($subscribers) { + $the_subscribers = array(); + foreach ($subscribers as $subscriber) { + foreach ($blacklist_fields as $field) { + unset($subscriber[$field]); + } + $the_subscribers[] = $subscriber; + } + + $subscribers = $the_subscribers; + } + + + if ($the_subscribers) + echo json_encode($the_subscribers); + else + echo json_encode(array('err' => lang('No Subscribers'))); + + exit(); + } + break; + + case "getSubscriptions": { + $uid = $request['userid']; + if (!$uid) + $uid = userid(); + + if (!$uid) + exit(json_encode(array('err' => lang('Please login')))); + + $subscribers = $userquery->get_user_subscriptions($uid); + + if ($subscribers) { + $the_subscribers = array(); + foreach ($subscribers as $subscriber) { + foreach ($blacklist_fields as $field) { + unset($subscriber[$field]); + } + $the_subscribers[] = $subscriber; + } + + $subscribers = $the_subscribers; + } + + if ($the_subscribers) + echo json_encode($the_subscribers); + else + echo json_encode(array('err' => lang('No Subscriptions'))); + + exit(); + } + break; + + + case "get_favorite_videos": + case "getFavoriteVideos": { + $limit = 20; + + $get_limit = create_query_limit($page, $limit); + $uid = $request['userid']; + if (!$uid) + $uid = userid(); + + $params = array('userid' => $uid, 'limit' => $get_limit); + $videos = $cbvid->action->get_favorites($params); + $params['count_only'] = "yes"; + $total_rows = $cbvid->action->get_favorites($params); + $total_pages = count_pages($total_rows, $get_limit); + + if ($total_rows > 0) { + $new_videos = array(); + foreach ($videos as $video) { + if (!$video['email']) { + $udetails = $userquery->get_user_details($video['userid']); + } + + $video = array_merge($video, $udetails); + + $video['thumbs'] = array('default' => get_thumb($video)); + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + $video['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($video); + + foreach ($blacklist_fields as $field) + unset($video[$field]); + + + $new_videos[] = $video; + } + echo json_encode($new_videos); + } else { + echo json_encode(array('err' => lang('No favorite videos were found'))); + } + } + break; + + case "get_users": + case "get_channels": + case "getChannels": + case "getUsers": { + $get_limit = create_query_limit($page, $videos_limit); + + $request['limit'] = $get_limit; + + $users = get_users($request); + + $new_users = array(); + if ($users) { + foreach ($users as $user) { + $user['avatar'] = $user['user_photo'] = $userquery->avatar($user); + $new_users[] = $user; + } + } + + + $user_api_fields = array( + 'username', 'first_name', 'last_name', 'fullname', + 'avatar', 'avatar_url', + 'userid', 'email', + 'total_videos', + 'total_photos', 'total_collections', + 'total_groups'); + + + $final_users = array(); + if ($new_users) + foreach ($new_users as $user) { + $final_user = array(); + + foreach ($user_api_fields as $field) + $final_user[$field] = $user[$field]; + + $final_users[] = $final_user; + } + + //echo $db->db_query; + echo json_encode($final_users); + } + break; + + case "getPhotos": + case "get_photos": { + + $get_limit = create_query_limit($page, $videos_limit); + + $request['limit'] = $get_limit; + + if (VERSION < 3) + $request['user'] = $request['userid']; + + //$request['order'] = tbl('video.'.$request['order']); + + $photos = $cbphoto->get_photos($request); + header('Content-Type: text/html; charset=utf-8'); + + $new_photos = array(); + if ($photos) { + foreach ($photos as $photo) { + + $photo['photo_title'] = utf8_encode($photo['photo_title']); + $photo['photo_description'] = utf8_encode($photo['photo_description']); + $photo['photo_link'] = $cbphoto->photo_links($photo, 'view_photo'); + + $photo['photo_thumb'] = array( + 'm' => get_image_file(array( + 'details' => $photo, + 'size' => 'm', + 'output' => 'non_html' + )), + 'l' => get_image_file(array( + 'details' => $photo, + 'size' => 'l', + 'output' => 'non_html' + )) + ); + + //$photo['thumbs'] = array('default' => get_thumb($photo), 'big' => get_thumb($photo, 'big')); + + $new_photos[] = $photo; + } + } + //echo $db->db_query; + echo json_encode($new_photos); + } + break; + + case "getFriends": + { + $uid = $request['userid']; + if (!$uid) + $uid = userid(); + + if (!$uid) + exit(json_encode(array('err' => lang('Please Login')))); + + $friends = $userquery->get_contacts($uid); + + if ($friends) + echo json_encode($friends); + else + echo json_encode(array('err' => error('single'))); + } + break; + + case "get_groups": + case "getGroups": + { + $get_limit = create_query_limit($page, $content_limit); + + $request['limit'] = $get_limit; + + $groups = $cbgroup->get_groups($request); + + if ($groups) + echo json_encode($groups); + else + echo json_encode(array('err' => error('single'))); + } + break; + + + case "get_topics": + case "getTopics": + { + $gid = mysql_clean($request['group_id']); + $page = mysql_clean($request['page']); + + $topics_limit = 20; + $get_limit = create_query_limit($page, $topics_limit); + + $params = array('group' => $gid,'limit' => $get_limit); + $topics = $cbgroup->get_group_topics($params); + + if ($topics) + echo json_encode($topics); + else + echo json_encode(array('err' => error())); + } + break; + + case "get_feeds": + case "getFeeds": + { + $id = mysql_clean($request['id']); + $page = mysql_clean($request['page']); + $type = mysql_clean($request['type']); + + $limit = 20; + $get_limit = create_query_limit($page, $limit); + + $params = array('id' => $id,'limit' => $get_limit,'type'=> $type); + $feeds = $cbfeeds->get_feeds($params); + $the_feeds = array(); + if ($feeds) + { + foreach ($feeds as $feed) + { + $feed['comments'] = json_encode($feed['comments']); + $the_feeds[] = $feed; + } + echo json_encode($the_feeds); + } + + else + echo json_encode(array('err' => error())); + } + break; + + + case "home_page": { + define('API_HOME_PAGE','yes'); + + $videos = $cbvid->get_videos(array('featured' => 'yes', 'limit' => 10, 'order' => 'featured_date DESC' + ,'has_mobile'=>'yes')); + + $new_videos = array(); + if ($videos) { + foreach ($videos as $video) { + + $video['title'] = utf8_encode($video['title']); + $video['description'] = utf8_encode($video['description']); + $video['thumbs'] = array('default' => get_thumb($video), 'big' => get_thumb($video, 'big'),'640x480'=>get_thumb($video, '640x480')); + + if (function_exists('get_mob_video')) + { + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + if ($video['has_hd']=='yes') { + $video['videos']['hq'] = get_hq_video_file($video); + } + } + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + $video['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($video); + $video['avatars']['medium'] = $userquery->avatar($video,'small'); + $video['avatars']['xmedium'] = $userquery->avatar($video,'xmedium'); + $video['avatars']['large'] = $userquery->avatar($video,'large'); + $new_videos[] = $video; + } + } + + $featured = $new_videos; + + $categories = $cbvid->getCbCategories(array( + 'cond' => " ( category_id = '1' OR category_id = '16' OR category_id = '26' OR category_id = '15' ) ", + 'limit' => 4, + 'type' => 'v' + )); + + + $cat_videos = array(); + + foreach($categories as $category) + { + $cat_vid = array( + 'name' => $category['category_name'], + 'id' => $category['category_id'], + ); + + $videos = $cbvid->get_videos(array('limit'=>10,'category'=>$category['category_id'],'order'=>' date_added desc ')); + + $new_videos = array(); + if ($videos) { + foreach ($videos as $video) { + + $video['title'] = utf8_encode($video['title']); + $video['description'] = utf8_encode($video['description']); + $video['thumbs'] = array('default' => get_thumb($video), 'big' => get_thumb($video, 'big'),'640x480'=>get_thumb($video, '640x480')); + + if (function_exists('get_mob_video')) + { + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + if ($video['has_hd']=='yes') { + $video['videos']['hq'] = get_hq_video_file($video); + } + } + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + $video['avatar'] = $video['user_photo'] = $video['displayPic'] = $userquery->avatar($video); + $video['avatars']['medium'] = $userquery->avatar($video,'medium'); + $video['avatars']['xmedium'] = $userquery->avatar($video,'xmedium'); + $video['avatars']['large'] = $userquery->avatar($video,'large'); + + $new_videos[] = $video; + } + } + $cat_vid['videos'] = $new_videos; + $cat_videos[] = $cat_vid; + } + + $home = array( + 'featured' => $featured, + 'categories' => $cat_videos + ); + + echo json_encode($home); + } + break; + + case "get_user": + case "get_channel": + case "getChannel": + case "getUser": { + + $userid = mysql_clean($request['userid']); + $user = array(); + if($userid) + $user = $userquery->get_user_details_with_profile($userid); + + + if ($user) { + + $user['avatar'] = $user['user_photo'] = $userquery->avatar($user); + $user['avatars']['medium'] = $userquery->avatar($user,'medium'); + $user['avatars']['xmedium'] = $userquery->avatar($user,'xmedium'); + $user['avatars']['large'] = $userquery->avatar($user,'large'); + // $user['name'] = name($user); + echo json_encode($user); + }else + echo json_encode(array('err'=>'User does not exist')); + } + break; + +} +?> \ No newline at end of file diff --git a/upload/api/global.php b/upload/api/global.php new file mode 100644 index 00000000..ee39c86c --- /dev/null +++ b/upload/api/global.php @@ -0,0 +1,45 @@ + \ No newline at end of file diff --git a/upload/api/pm.php b/upload/api/pm.php new file mode 100644 index 00000000..654a74b6 --- /dev/null +++ b/upload/api/pm.php @@ -0,0 +1,132 @@ +api_keys; +if ($api_keys) { + if (!in_array($request['api_key'], $api_keys)) { + exit(json_encode(array('err' => 'App authentication error'))); + } +} + +if (!userid()) { + exit(json_encode(array('err' => 'User not logged in'))); +} + +switch ($mode) { + + case "getThreads": + case "get_threads": + { + $get_limit = create_query_limit($page, $content_limit); + + $request['limit'] = $get_limit; + + $threads = $cbpm->get_threads($request); + + if ($threads) + echo json_encode($threads); + else + echo json_encode (array('err' => 'No Threads were Found')); + } + break; + + case "getThread": + case "get_thread": + { + + $tid = $request['thread_id']; + $thread = $cbpm->get_thread($tid); + + if ($thread) + echo json_encode($thread); + else + echo json_encode (array('err' => 'Thread Not Found')); + } + break; + + case "getMessages": + case "get_messages": + { + $get_limit = create_query_limit($page, $content_limit); + + $request['limit'] = $get_limit; + + $messages = $cbpm->get_messages($request); + + if ($messages) + echo json_encode($messages); + else + echo json_encode (array('err' => 'No Messages were Found')); + } + break; + + case "getNewMessages": + case "get_new_messages": + { + $get_limit = create_query_limit($page, $content_limit); + + $request['limit'] = $get_limit; + + $messages = $cbpm->get_new_messages($request); + + if ($messages) + echo json_encode($messages); + else + echo json_encode (array('err' => 'No New Messages were Found')); + } + break; + + case "sendMessage":case "send_message":case "send_msg":case "sndMsg": + + { + + //recipients[]=11 + //message=tessttttinggggg + //thread_id=xyz + + $tid = $request['thread_id']; + if (!$tid) + { + //create new thread + $recipients = json_decode ($request['recipients']); + + $new_thread_id = $cbpm->create_thread(array('recipients'=>$recipients)); + + if (!$new_thread_id) + { + echo json_encode (array('err' => error())); + exit(); + } + + echo json_encode(array('thread_id' => $response)); + $request['thread_id'] = $new_thread_id; + } + + $response = $cbpm->send_message($request); + + if ($response) + echo json_encode(array('message_id' => $response)); + else + echo json_encode (array('err' => error())); + } + break; + + default: + echo json_encode(array('err' => array(lang('Invalid request')))); + break; +} +?> \ No newline at end of file diff --git a/upload/api/push.php b/upload/api/push.php new file mode 100644 index 00000000..003feaaa --- /dev/null +++ b/upload/api/push.php @@ -0,0 +1,87 @@ +insert(tbl('token'),array('token'),array($token)); + if ($response) + echo json_encode(array('success'=>'yes','msg'=>'token saved successfully')); + else + echo json_encode(array('err'=> lang(error('single')))); + } + break; + default:{ + + + } + +} + +function send_video_notification($videoId){ + global $myquery ,$db; + #checking if we have vid , so fetch the details + if(!empty($videoId)) + $vdetails = $myquery->get_video_details($videoId); + + $title=$vdetails['title']; + // Put your private key's passphrase here: + $passphrase = 'janjuajanjua'; + + //////////////////////////////////////////////////////////////////////////////// + + $ctx = stream_context_create(); + stream_context_set_option($ctx, 'ssl', 'local_cert', 'E:\wamp\www\clipbucket_bug1\api\apns-dev.pem'); + stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); + + // Open a connection to the APNS server + $fp = stream_socket_client( + 'ssl://gateway.sandbox.push.apple.com:2195', $err, + $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); + + if (!$fp) + exit("Failed to connect: $err $errstr" . PHP_EOL); + + echo 'Connected to APNS' . PHP_EOL; + + + + $token_result = $db->select(tbl('token'),'token'); + if($token_result){ + foreach($token_result as $token_value) + { + // Create the pahanyload body + + $payload['aps'] = array('alert' => "'".$title."' has been Featured.", 'sound' => 'default'); + $payload['details'] = array('type' => 'featured','videoId' => $videoId, 'title' => $title); + $output = json_encode($payload); + + + + // Build the binary notification + $msg = chr(0) . pack('n', 32) . pack('H*', $token_value['token']) . pack('n', strlen($output)) . $output; + + // Send it to the server + $result = fwrite($fp, $msg, strlen($msg)); + + } + if (!$result) + echo 'Messages not delivered' . PHP_EOL; + else + echo 'Messages successfully delivered' . PHP_EOL; + + } + else + return json_encode(array('err'=> lang(error('single')))); + + // Close the connection to the server + fclose($fp); + +} + diff --git a/upload/api/put.php b/upload/api/put.php new file mode 100644 index 00000000..248baca0 --- /dev/null +++ b/upload/api/put.php @@ -0,0 +1,595 @@ +api_keys; +if($api_keys) +{ + if(!in_array($request['api_key'],$api_keys)) + { + exit(json_encode(array('err'=>'App authentication error'))); + } +} + +switch ($mode) { + case "upload_video": { + echo json_encode($_POST,$_FILES); + } + break; + + case "addComment": { + $type = $request['type']; + switch ($type) { + case 'v': + case 'video': + { + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + + $cid = $cbvid->add_comment($comment, $id, $reply_to); + } + break; + case 'u': + case 'c': { + + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + + $cid = $userquery->add_comment($comment, $id, $reply_to); + } + break; + case 't': + case 'topic': { + + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + + $cid = $cbgroup->add_comment($comment, $id, $reply_to); + } + break; + + case 'cl': + case 'collection': { + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + + $cid = $cbcollection->add_comment($comment, $id, $reply_to); + } + break; + + case "p": + case "photo": { + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + $cid = $cbphoto->add_comment($comment, $id, $reply_to); + } + break; + + case 'f': + case 'feed': { + + $id = mysql_clean($request['obj_id']); + $comment = $request['comment']; + if ($comment == 'undefined') + $comment = ''; + $reply_to = $request['reply_to']; + + $cid = $cbfeeds->add_comment($comment, $id, $reply_to); + } + break; + default: + echo json_encode(array('err' => 'Invalid Type')); + exit(); + break; + } + + + if (error()) { + exit(json_encode(array('err' => error(), 'session' => $_COOKIE['PHPSESSID']))); + } + + $comment = $myquery->get_comment($cid); + + $array = array( + 'msg' => msg(), + 'comment' => $comment, + 'success' => 'ok', + 'cid' => $cid + ); + + echo json_encode($array); + } + break; + + case "create_playlist": + case "addPlaylist": + case "add_playlist": + { + $array = array( + 'name', + 'description', + 'tags', + 'playlist_type', + 'privacy', + 'allow_comments', + 'allow_rating', + 'type', + ); + + $type = $request['type']; + + $input = array(); + foreach ($array as $ar) { + $input[$ar] = mysql_clean($request[$ar]); + } + + + if ($type == 'v' || !isset($type)) + $pid = $cbvid->action->create_playlist($input); + + if (!$type) + e(lang("Invalid playlist type")); + + if(VERSION>2.7) + $rel = get_rel_list(); + + + if (error()) { + + $rel = array(); + + + + echo json_encode(array('err' => error(), 'rel' => $rel)); + } else { + $playlist = $cbvid->action->get_playlist($pid); + + echo json_encode(array('success' => 'yes', 'rel' => $rel, + 'pid' => $pid, 'playlist' => $playlist, + 'msg' => msg())); + } + } + break; + + case "delete_playlist": { + $pid = mysql_clean($request['playlist_id']); + $cbvid->action->delete_playlist($pid); + + if (error()) { + echo json_encode(array('err' => error())); + } else { + echo json_encode(array('msg' => array(lang('Playlist has been removed')))); + } + } + break; + + + case "add_playlist_item": { + + $type = $request['type']; + $pid = mysql_clean($request['playlist_id']); + $id = mysql_clean($request['object_id']); + // $note = mysql_clean(post('note')); + + switch ($type) { + case 'v': + default: { + $item_id = $cbvid->action->add_playlist_item($pid, $id); + + if (!error()) { + updateObjectStats('plist', 'video', $id); + echo json_encode(array('status' => 'ok', + 'msg' => msg(), 'item_id' => $item_id, 'updated' => nicetime(now()))); + } else { + echo json_encode(array('err' => error())); + } + } + } + } + break; + + case "remove_playlist_item": + { + $item_id = mysql_clean($request['item_id']); + $cbvid->action->delete_playlist_item($item_id); + if(error()) + echo json_encode(array('err'=>error())); + else + echo json_encode(array('success'=>'ok')); + } + break; + + case "delete_favorite": + { + $video_id = mysql_clean($request['videoid']); + $cbvid->action->remove_favorite($video_id); + if(error()) + echo json_encode(array('err'=>error())); + else + echo json_encode(array('success'=>'ok','msg' => lang('Video has been removed'))); + } + break; + + case "add_favorite": + { + $video_id = mysql_clean($request['videoid']); + $cbvid->action->add_to_fav($video_id); + if(error()) + echo json_encode(array('err'=>error())); + else + echo json_encode(array('success'=>'ok','msg' => lang('Video has been added'))); + } + break; + + case "insert_video": { + $title = $request['title']; + $file_name = time(). RandomString(5); + + $file_directory = createDataFolders(); + + $vidDetails = array + ( + 'title' => $title, + 'description' => $title, + 'tags' => genTags(str_replace(' ', ', ', $title)), + 'category' => array($cbvid->get_default_cid()), + 'file_name' => $file_name, + 'file_directory' => $file_directory, + 'userid' => userid(), + ); + + $vid = $Upload->submit_upload($vidDetails); + + echo json_encode(array('success' => 'yes', + 'vid' => $vid,'file_directory'=>$file_directory, + 'file_name'=>$file_name)); + } + break; + + case "update_video":{ + + //Setting up the categories.. + $request['category'] = explode(',',$request['category']); + $request['videoid'] = trim($request['videoid']); + + $_POST = $request; + + $Upload->validate_video_upload_form(); + + 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'))); + + } + + + break; + case "rating": + { + + $type = mysql_clean($request['type']); + $id = mysql_clean($request['id']); + $rating = mysql_clean($request['rating']); + + switch($type){ + case "video": + case "v": + { + $result = $cbvid->rate_video($id,$rating); + echo json_encode(array('success'=>'ok')); + } + break; + + case "photo": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $cbphoto->rate_photo($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_photo'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + case "collection": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $cbcollection->rate_collection($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_collection'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + + case "user": + { + $rating = $_POST['rating']*2; + $id = $_POST['id']; + $result = $userquery->rate_user($id,$rating); + $result['is_rating'] = true; + $cbvid->show_video_rating($result); + + $funcs = cb_get_functions('rate_user'); + if($funcs) + foreach($funcs as $func) + { + $func['func']($id); + } + } + break; + } + } + break; + + case 'flag_object': + { + $type = strtolower($request['type']); + $id = $request['id']; + switch($type) + { + case 'v': + case 'video': + default: + { + + $reported = $cbvideo->action->report_it($id); + } + break; + + case 'g': + case 'group': + default: + { + // $id = $_POST['id']; + $cbgroup->action->report_it($id); + } + break; + + case 'u': + case 'user': + default: + { + //$id = $_POST['id']; + $userquery->action->report_it($id); + } + break; + + case 'p': + case 'photo': + { + //$id = $_POST['id']; + $cbphoto->action->report_it($id); + } + break; + + case "cl": + case "collection": + { + //$id = $_POST['id']; + $cbcollection->action->report_it($id); + } + break; + + } + + if(msg()) + { + $msg = msg_list(); + echo json_encode(array('success'=>'yes','msg'=>$msg[0])); + } + if(error()) + { + $msg = error_list(); + echo json_encode(array('err'=>$msg[0])); + } + + } + break; + + + case "removeVideo": + case "remove_video": + case "deleteVideo": + case "delete_video": + { + $vid = $request['vid']; + $vid = mysql_clean($vid); + $cbvideo->delete_video($vid); + + if(error()) + { + $error = error_list(); + $the_error = $error[0]; + echo json_encode(array('err'=>$the_error)); + }else + { + $msg = msg_list(); + $the_msg = $msg[0]; + + echo json_encode(array('msg'=>$the_msg,'success'=>'yes')); + } + } + break; + + case "subscribe": + { + $to = $request['to']; + $to = mysql_clean($to); + $subscribe_to = $to; + $userquery->subscribe_user($subscribe_to); + + if(msg()) + { + $msg = msg_list(); + echo json_encode(array('msg' => $msg[0],'success'=>'yes')); + + } + if(error()) + { + $msg = error_list(); + echo json_encode(array('err' => $msg[0])); + } + } + break; + + case "unsubscribe": + { + $to = $request['to']; + $to = mysql_clean($to); + $subscribe_to = $to; + $userquery->unsubscribe_user($subscribe_to); + + if(msg()) + { + $msg = msg_list(); + echo json_encode(array('msg' => $msg[0],'success'=>'yes')); + + } + if(error()) + { + $msg = error_list(); + echo json_encode(array('err' => $msg[0])); + } + } + break; + + case "edit_video": + case "editVideo": + { + $vid = mysql_clean($request['videoid']); + $Upload->validate_video_upload_form(); + if(empty($eh->error_list)) + { + $_POST = $request; + $cbvid->update_video(); + + //$cbvid->set_default_thumb($vid,mysql_clean(post('default_thumb'))); + $vdetails = $cbvid->get_video_details($vid); + echo json_encode(array('success'=>'yes','vdetails'=>$vdetails)); + } + else + { + echo json_encode(array('err'=>error())); + } + } + break; + + + case addFriend: + case add_friend: + { + $uid = mysql_clean($request['userid']); + $fid = mysql_clean($request['fid']); + $message = mysql_clean($request['message']); + + if (!$uid) + $uid = userid(); + + if (!$uid) + exit(json_encode(array('err' => lang('Please Login')))); + + if (!$fid) + exit(json_encode(array('err' => lang('Please Select a User')))); + + + $params = array('userid'=>$uid,'friend_id'=>$fid,'message'=>$message); + + $request_id = $userquery->add_friend_request($params); + + if ($request_id) + echo json_encode(array('success'=>'yes','request_id'=>$request_id)); + else + echo json_encode(array('err'=> lang(error('single')))); + } + break; + + case removeFriend: + case remove_friend: + case unFriend: + case unfriend: + { + $uid = mysql_clean($request['userid']); + $fid = mysql_clean($request['fid']); + + if (!$uid) + $uid = userid(); + + if (!$uid) + exit(json_encode(array('err' => lang('Please Login')))); + + if (!$fid) + exit(json_encode(array('err' => lang('Please Select a User')))); + + if ($fid == $uid) + exit(json_encode(array('err' => lang('Invalid User')))); + + $response = $userquery->unfriend($fid,$uid); + + if ($response) + echo json_encode(array('success'=>'yes','msg'=>'Removed from Friends')); + else + echo json_encode(array('err'=> lang(error('single')))); + } + break; + + case "like_feed": + case "addLike": + { + $liked = mysql_clean($request['liked']); + $feed_id = mysql_clean($request['feed_id']); + + $response = $cbfeeds->like_feed(array('feed_id' => $feed_id, 'liked' => $liked)); + if ($response) + echo json_encode(array('success'=>'yes','msg'=>'Like/Unlike saved')); + else + echo json_encode(array('err'=> lang(error('single')))); + } + break; + + default: + exit(json_encode(array('err'=>lang('Invalid request')))); +} +?> \ No newline at end of file diff --git a/upload/api/sample_getVideos.json b/upload/api/sample_getVideos.json new file mode 100644 index 00000000..61d04562 --- /dev/null +++ b/upload/api/sample_getVideos.json @@ -0,0 +1,73 @@ +{ + "videoid":"1245", + "videokey":"RY5kpDO6BvoO", + "slug_id":"63", + "video_password":"", + "video_users":" ", + "username":"admin", + "userid":"1", + "title":"Test4", + "flv":"", + "file_name":"1342165436bcc04", + "description":"Test4", + "tags":"Test4", + "category":"#20# ", + "category_parents":"", + "broadcast":"private", + "location":"", + "datecreated":"2012-07-13", + "country":"0", + "allow_embedding":"yes", + "rating":"0", + "rated_by":"0", + "voter_ids":"", + "allow_comments":"yes", + "comment_voting":"yes", + "comments_count":"0", + "last_commented":"0000-00-00 00:00:00", + "subscription_email":"pending", + "featured":"no", + "featured_date":"0000-00-00 00:00:00", + "featured_description":"", + "allow_rating":"yes", + "active":"yes", + "favourite_count":"0", + "playlist_count":"0", + "views":"0", + "last_viewed":"2012-07-25 23:42:29", + "date_added":"2012-07-13 12:43:59", + "flagged":"no", + "duration":"1", + "status":"Processing", + "failed_reason":"none", + "flv_file_url":null, + "default_thumb":"0", + "aspect_ratio":"", + "embed_code":"none", + "refer_url":"", + "downloads":"0", + "uploader_ip":"127.0.0.1", + "has_sprite":"0", + "sprite_thumbs_no":"0", + "tr_stored_thumbs":"0", + "mass_embed_status":"no", + "is_hd":"no", + "ebay_epn_keywords":"", + "ebay_pre_desc":"", + "unique_embed_code":"", + "mature_content":"no", + "remote_play_url":"", + "has_mobile":"no", + "file_directory":"", + "is_premium":"no", + "credits_required":"0", + "premium_cid":"0", + "avatar":"1.jpg", + "avatar_url":"", + "email":"webmaster@localhost5.com", + "total_videos":"485", + "object_type":"v", + "object_id":"1245", + "in_use":"yes", + "slug":"test4" +} \ No newline at end of file diff --git a/upload/api/search.php b/upload/api/search.php new file mode 100644 index 00000000..fd97c20d --- /dev/null +++ b/upload/api/search.php @@ -0,0 +1,81 @@ +limit = create_query_limit($page, $limit); +$search->key = mysql_clean($request['query']); + +$results = $search->search(); + + + +if ($results) +{ + $the_results = array(); + switch ($type) + { + case "video": + default: + { + if($results) + foreach ($results as $video) + { + + $hq_file = get_hq_video_file($video); + $video['title'] = title($video['title']); + $video['description'] = mob_description($video['description']); + + $video['thumbs'] = array('default' => get_thumb($video), 'big' => getSmartyThumb(array( + 'vdetails' => $video, 'size' => 'big' + ))); + $video['videos'] = array('mobile' => get_mob_video(array('video' => $video))); + $video['url'] = $video['video_link'] = $video['videoLink'] = videoLink($video); + + if (has_hq($video)) + $video['videos']['hd'] = $hq_file; + + foreach ($blacklist_fields as $field) + unset($video[$field]); + + $the_results[] = $video; + } + } + break; + + case "users": + { + + if($results) + { + foreach ($results as $user) + { + $user['avatar'] = $user['user_photo'] = $userquery->avatar($user); + + foreach ($blacklist_fields as $field) + unset($user[$field]); + + $the_results[] = $user; + } + } + //echo $db->db_query; + } + break; + } + + echo json_encode($the_results); +}else + echo json_encode(array('err' => 'Nothing found!')); +?> \ No newline at end of file diff --git a/upload/api/thumb-sample.php b/upload/api/thumb-sample.php new file mode 100644 index 00000000..b50be5ec --- /dev/null +++ b/upload/api/thumb-sample.php @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/upload/captcha.php b/upload/captcha.php new file mode 100644 index 00000000..623e87d0 --- /dev/null +++ b/upload/captcha.php @@ -0,0 +1,12 @@ +generates_image($word,true); +?> \ No newline at end of file diff --git a/upload/cb_install/LICENSE b/upload/cb_install/LICENSE new file mode 100644 index 00000000..905bb4d0 --- /dev/null +++ b/upload/cb_install/LICENSE @@ -0,0 +1,47 @@ +Copyright (c) 2007 - {this_year} 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 (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. \ No newline at end of file diff --git a/upload/cb_install/ajax.php b/upload/cb_install/ajax.php new file mode 100644 index 00000000..4d2298fb --- /dev/null +++ b/upload/cb_install/ajax.php @@ -0,0 +1,322 @@ +Unable to connect to mysql : ".mysql_error().''; + else + { + $dbselect = @mysql_select_db($dbname,$cnnct); + if(!$dbselect) + $result['err'] = "Unable to select database : ".mysql_error().''; + } + echo json_encode($result); + } + + + if($mode=='register') + { + $version = @curl_version(); + if($version) + { + $website = $_POST['website']; + $email = $_POST['email']; + $ch = curl_init('http://clip-bucket.com/register.php'); + curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch,CURLOPT_POST,true); + curl_setopt($ch,CURLOPT_POSTFIELDS,array('website'=>$website,'email'=>$email)); + $data = curl_exec($ch); + echo $data; + } + } + + if($mode=='adminsettings') + { + $dbhost = $_POST['dbhost']; + $dbpass = $_POST['dbpass']; + $dbuser = $_POST['dbuser']; + $dbname = $_POST['dbname']; + $dbprefix = $_POST['dbprefix']; + + $cnnct = @mysql_connect($dbhost,$dbuser,$dbpass); + + if(!$cnnct) + $result['err'] = "Unable to connect to mysql : ".mysql_error().''; + else + { + $dbselect = @mysql_select_db($dbname,$cnnct); + if(!$dbselect) + $result['err'] = "Unable to select database : ".mysql_error().''; + } + + if(@$result['err']) + { + exit(json_encode($result)); + } + + $step = $_POST['step']; + $files = array + ( + 'structure' => 'structure.sql', + 'configs' => 'configs.sql', + 'ads_placements' => 'ads_placements.sql', + 'countries' => 'countries.sql', + 'email_templates' => 'email_templates.sql', + 'pages' => 'pages.sql', + 'user_levels' => 'user_levels.sql' + ); + + $next = false; + if(array_key_exists($step,$files) && $step) + { + $total = count($files); + $count = 0; + foreach($files as $key => $file) + { + $count++; + if($next) + { + $next = $key; + break; + } + if($key==$step) + { + $current = $step; + if($count<$total) + $next = true; + } + } + + if(!$next) + { + $next = 'add_categories'; + $next_msg = 'Creating categories'; + } + + if($current) + { + $lines = file(BASEDIR."/cb_install/sql/".$files[$current]); + foreach ($lines as $line_num => $line) + { + if (substr($line, 0, 2) != '--' && $line != '') + { + @$templine .= $line; + if (substr(trim($line), -1, 1) == ';') + { + @$templine = preg_replace("/{tbl_prefix}/",$dbprefix,$templine); + mysql_query($templine); + $templine = ''; + } + } + } + } + + $return = array(); + $return['msg'] = '
    '.$files[$current].' has been imported successfully
    '; + + if(@$files[$next]) + $return['status'] = 'importing '.$files[$next]; + else + $return['status'] = $next_msg; + + $return['step'] = $next; + }else + { + switch($step) + { + case 'add_categories': + { + $lines = file(BASEDIR."/cb_install/sql/categories.sql"); + foreach ($lines as $line_num => $line) + { + if (substr($line, 0, 2) != '--' && $line != '') + { + @$templine .= $line; + if (substr(trim($line), -1, 1) == ';') + { + @$templine = preg_replace("/{tbl_prefix}/",$dbprefix,$templine); + mysql_query($templine); + $templine = ''; + } + } + } + $return['msg'] = '
    Videos, Users, Groups and Collections Categories have been created
    '; + $return['status'] = 'adding admin account..'; + $return['step'] = 'add_admin'; + } + break; + + case "add_admin": + { + + + $lines = file(BASEDIR."/cb_install/sql/add_admin.sql"); + foreach ($lines as $line_num => $line) + { + if (substr($line, 0, 2) != '--' && $line != '') + { + @$templine .= $line; + if (substr(trim($line), -1, 1) == ';') + { + @$templine = preg_replace("/{tbl_prefix}/",$dbprefix,$templine); + mysql_query($templine); + $templine = ''; + } + } + } + $return['msg'] = '
    Admin account has been created
    '; + $return['status'] = 'Creating config files...'; + $return['step'] = 'create_files'; + } + break; + + case "create_files": + { + mysql_close($cnnct); + $dbconnect = file_get_contents(BASEDIR.'/cb_install/dbconnect.php'); + $dbconnect = str_replace('_DB_HOST_', $dbhost, $dbconnect); + $dbconnect = str_replace('_DB_NAME_', $dbname, $dbconnect); + $dbconnect = str_replace('_DB_USER_', $dbuser, $dbconnect); + $dbconnect = str_replace('_DB_PASS_', $dbpass, $dbconnect); + $dbconnect = str_replace('_TABLE_PREFIX_', $dbprefix, $dbconnect); + + $fp = fopen(BASEDIR.'/includes/dbconnect.php', 'w'); + fwrite($fp, $dbconnect); + fclose($fp); + + copy(BASEDIR."/cb_install/clipbucket.php",BASEDIR."/includes/clipbucket.php"); + + $return['msg'] = '
    DBconnect and Clipbucket files have been created
    '; + $return['status'] = 'forwarding you to admin settings..'; + $return['step'] = 'forward'; + } + break; + } + + } + + echo json_encode($return); + } + + if($mode=='finish_upgrade') + { + chdir(".."); + $configIncluded = true; + require_once 'includes/config.inc.php'; + chdir("cb_install"); + include("functions.php"); + $files = getUpgradeFiles(); + + if($files) + { + $step = $_POST['step']; + if($step=='upgrade') + $index = 0; + else + $index = $step; + + $total = count($files); + + if($index >= $total) + { + $return['msg'] = '
    Upgrade clipbucket
    '; + $return['status'] = 'finalizing upgrade...'; + $return['step'] = 'forward'; + } + + if($index+1 >= $total) + $next = 'forward'; + else + $next = $index+1; + + if($next=='forward') + $status = 'finalizing upgrade...'; + else + $status = 'Importing upgrade_'.$files[$next].'.sql'; + + $sqlfile = BASEDIR."/cb_install/sql/upgrade_".$files[$index].".sql"; + if(file_exists($sqlfile)) + { + + $lines = file($sqlfile); + foreach ($lines as $line_num => $line) + { + if (substr($line, 0, 2) != '--' && $line != '') + { + @$templine .= $line; + if (substr(trim($line), -1, 1) == ';') + { + @$templine = preg_replace("/{tbl_prefix}/",TABLE_PREFIX,$templine); + $templine; + mysql_query($templine); + $templine = ''; + } + } + } + } + + //There were problems with email templates with version lower than 2.4 + //therefore we are dumping all existing email templates and re-import them + if($upgrade<'2.4.5') + { + mysql_query('TRUNCATE '.TABLE_PREFIX.'email_templates'); + //Dumping + $sqlfile = BASEDIR."/cb_install/sql/email_templates.sql"; + if(file_exists($sqlfile)) + { + + $lines = file($sqlfile); + foreach ($lines as $line_num => $line) + { + if (substr($line, 0, 2) != '--' && $line != '') + { + @$templine .= $line; + if (substr(trim($line), -1, 1) == ';') + { + @$templine = preg_replace("/{tbl_prefix}/",TABLE_PREFIX,$templine); + $templine; + mysql_query($templine); + $templine = ''; + } + } + } + } + } + //Dumping finished + + $return['msg'] = '
    upgrade_'.$files[$index].'.sql has been imported
    '; + $return['status'] = $status; + $return['step'] = $next; + + }else + { + $return['msg'] = '
    Upgrade clipbucket
    '; + $return['status'] = 'finalizing upgrade...'; + $return['step'] = 'forward'; + } + + echo json_encode($return); + } + +?> \ No newline at end of file diff --git a/upload/cb_install/clipbucket.php b/upload/cb_install/clipbucket.php new file mode 100644 index 00000000..fa644cb1 --- /dev/null +++ b/upload/cb_install/clipbucket.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/upload/cb_install/dbconnect.php b/upload/cb_install/dbconnect.php new file mode 100644 index 00000000..5c7c23e0 --- /dev/null +++ b/upload/cb_install/dbconnect.php @@ -0,0 +1,39 @@ +debug = false; + $db->charpage = 'cp_utf8'; + $db->charset = 'utf8'; + if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) + { + exit($db->ErrorMsg()); + } + $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); + + $db->SetFetchMode(ADODB_FETCH_ASSOC); + + $db->Execute('SET NAMES utf8'); + $db->Execute('SET CHARACTER SET utf8'); + $db->Execute('SET COLLATION_CONNECTION="utf8_general_ci"'); + +?> \ No newline at end of file diff --git a/upload/cb_install/favicon.ico b/upload/cb_install/favicon.ico new file mode 100644 index 00000000..3b630f90 Binary files /dev/null and b/upload/cb_install/favicon.ico differ diff --git a/upload/cb_install/functions.js b/upload/cb_install/functions.js new file mode 100644 index 00000000..73f095cd --- /dev/null +++ b/upload/cb_install/functions.js @@ -0,0 +1,81 @@ +var p = 'ajax.php'; +var img = ''; + + +function dbconnect() +{ + $('#loading').html(img); + var formData = $('#installation').serialize(); + $.post(p,formData,function(data) + { + if(data.err) + { + $('#dbresult').show().html(data.err) + $('#loading').html(''); + }else + { + $('#installation').submit(); + } + },"json"); +} + + +function dodatabase(step) +{ + var formData = $('#installation').serialize(); + + formData += '&step='+step; + $.post(p,formData,function(data) + { + + if(data.msg) + $('#resultsDiv').before(data.msg); + if(data.err) + $('#resultsDiv').before(data.err); + if(data.status) + $('#current').html(data.status); + + if(data.step=='forward') + { + $('#installation').submit(); + } + if(data.step && data.step!='forward') + dodatabase(data.step) + },"json"); +} + +function password(length, special) { + var iteration = 0; + var password = ""; + var randomNumber; + if(special == undefined){ + var special = false; + } + while(iteration < length){ + randomNumber = (Math.floor((Math.random() * 100)) % 94) + 33; + if(!special){ + if ((randomNumber >=33) && (randomNumber <=47)) { continue; } + if ((randomNumber >=58) && (randomNumber <=64)) { continue; } + if ((randomNumber >=91) && (randomNumber <=96)) { continue; } + if ((randomNumber >=123) && (randomNumber <=126)) { continue; } + } + iteration++; + password += String.fromCharCode(randomNumber); + } + return password; +} + +function register(email,website) +{ + $('#loadingReg').html(img); + $.ajax({ + url : p, + type : 'POST', + data : ({mode:'register',website:website,email:email}), + dataType: "html", + success:function(data){$('#installation').submit()} + + }) + + +} \ No newline at end of file diff --git a/upload/cb_install/functions.php b/upload/cb_install/functions.php new file mode 100644 index 00000000..11f04a42 --- /dev/null +++ b/upload/cb_install/functions.php @@ -0,0 +1,291 @@ +',$license); + $license = str_replace("{this_year}",date("Y",time()),$license); + } + return $license; + } + + + function button($text,$params=NULL,$alt=false) + { + echo ' '; + echo ''.$text.''; + if(!$alt) + echo ' '; + else + echo ' '; + } + + function msg_arr($arr) + { + if(@$arr['msg']) + return emsg($arr['msg'],'ok'); + else + return emsg($arr['err'],'alert'); + } + + if(!function_exists('emsg')) + { + function emsg($text,$type='ok') + { + return ''.$text.''; + } + } + + + function check_module($type) + { + $return = array(); + switch($type) + { + case "php": + { + + $v = phpversion(); + $req = '5.2.1'; + if($v<$req) + $return['err'] = sprintf(_("Found PHP %s but required is PHP %s "),$v,$req); + else + $return['msg'] = sprintf(_("Found PHP %s "),$v); + } + break; + + case "ffmpeg": + { + $ffmpeg_path = exec("which ffmpeg"); + $ffmpeg_version = shell_output("$ffmpeg_path -version"); + + $version = false; + preg_match("/SVN-r([0-9]+)/i",$ffmpeg_version,$matches); + if(@$matches[1]) + $version = 'r'.$matches[1]; + preg_match("/version ([0-9.]+)/i",$ffmpeg_version,$matches); + if(@$matches[1]) + $version = $matches[1]; + + if(!$version) + $return['err'] = _("Unable to find ffmpeg"); + else + $return['msg'] = sprintf(_("Found FFMPEG %s : %s"),$version,$$ffmpeg_path); + } + break; + + case "flvtool2": + { + $flvtool2_path = exec("which flvtool2"); + $flvtool2_version = shell_output("$flvtool2_path -version"); + $version = false; + preg_match("/flvtool2 ([0-9.]+)/i",$flvtool2_version,$matches); + if(@$matches[1]) + $version = $matches[1]; + if(!$version) + $return['err'] = _("Unable to find flvtool2"); + else + $return['msg'] = sprintf(_("Found flvtool2 %s : %s"),$version,$flvtool2_path); + + } + break; + + case "mp4box": + { + $mp4boxpath = exec("which MP4Box"); + $mp4box_version = shell_output("$mp4boxpath -version"); + $version = false; + preg_match("/GPAC version ([0-9.]+)/i",$mp4box_version,$matches); + if(@$matches[1]) + $version = $matches[1]; + if(!$version) + $return['err'] = _("Unable to find MP4Box"); + else + $return['msg'] = sprintf(_("Found MP4Box %s : %s"),$version,$mp4boxpath); + + + } + break; + + case "curl": + { + $version = false; + if(function_exists('curl_version')) + $version = @curl_version(); + + if(!$version) + $return['err'] = _("cURL library is not neabled"); + else + $return['msg'] = sprintf(_("cURL %s found"),$version['version']); + + } + break; + + case "phpshield": + { + if(!function_exists('phpshield_load')) + $return['err'] = _("PHPShield loaders are not installed (optional)"); + else + $return['msg'] = _("PHPShield loaders are working (optional)"); + } + break; + + + + } + + return $return; + } + + if(!function_exists('_')) + { + function _($in) + { + return $in; + } + } + + + if(!function_exists('shell_output')) + { + function shell_output($cmd) + { + if (stristr(PHP_OS, 'WIN')) { + $cmd = $cmd; + }else{ + $cmd = "PATH=\$PATH:/bin:/usr/bin:/usr/local/bin bash -c \"$cmd\" 2>&1"; + } + $data = shell_exec( $cmd ); + return $data; + } + } + + + /** + * Short form of print_r as pr + */ + if(!function_exists('pr')) + { + function pr($text,$wrap_pre=false) + { + if(!$wrap_pre) + print_r($text); + else + { + echo "
    ";
    +				print_r($text);
    +				echo "
    "; + } + } + } + + + /** + * Function used to check folder permissions + */ + function checkPermissions() + { + $files = array + ( + 'cache', + 'cache/comments', + 'cache/userfeeds', + 'files', + 'files/conversion_queue', + 'files/logs', + 'files/mass_uploads', + 'files/original', + 'files/photos', + 'files/temp', + 'files/temp/install.me', + 'files/thumbs', + 'files/videos', + 'images', + 'images/avatars', + 'images/backgrounds', + 'images/category_thumbs', + 'images/collection_thumbs', + 'images/groups_thumbs', + 'includes', + 'includes/langs/en.lang' + ); + + $permsArray = array(); + foreach($files as $file) + { + if(is_writeable(BASEDIR.'/'.$file)) + { + $permsArray[] = array('path'=>$file,'msg'=>'writeable'); + }else + $permsArray[] = array('path'=>$file,'err'=>'please chmod this file/directory to 777'); + } + return $permsArray; + } + + + /** + * FUNCTION USED TO CLEAN VALUES THAT CAN BE USED IN FORMS + */ + if(!function_exists('cleanForm')) + { + function cleanForm($string) + { + if(is_string($string)) + $string = htmlspecialchars($string); + if(get_magic_quotes_gpc()) + $string = stripslashes($string); + return $string; + } + function form_val($string){return cleanForm($string); } + } + + + + function selected($selected) + { + global $mode; + if($mode==$selected) + return "class='selected'"; + } + + /** + * Function used to create list of files + * that have to be executed while upgrade + */ + function getUpgradeFiles() + { + global $versions,$upgrade; + $version = VERSION; + $oldVer = $upgrade; + if($oldVer) + { + $total = count($versions); + $files = array(); + + $found = false; + foreach($versions as $ver) + { + if($found) + $files[] = $ver; + if($ver==$oldVer) + $found = true; + } + return $files; + } + + return false; + } + +?> \ No newline at end of file diff --git a/upload/cb_install/images/alert.png b/upload/cb_install/images/alert.png new file mode 100644 index 00000000..16aa3dd4 Binary files /dev/null and b/upload/cb_install/images/alert.png differ diff --git a/upload/cb_install/images/bttncenter.png b/upload/cb_install/images/bttncenter.png new file mode 100644 index 00000000..974406da Binary files /dev/null and b/upload/cb_install/images/bttncenter.png differ diff --git a/upload/cb_install/images/bttnleft.png b/upload/cb_install/images/bttnleft.png new file mode 100644 index 00000000..8e5065d9 Binary files /dev/null and b/upload/cb_install/images/bttnleft.png differ diff --git a/upload/cb_install/images/bttnright.png b/upload/cb_install/images/bttnright.png new file mode 100644 index 00000000..9c6211f2 Binary files /dev/null and b/upload/cb_install/images/bttnright.png differ diff --git a/upload/cb_install/images/bttnrightalt.png b/upload/cb_install/images/bttnrightalt.png new file mode 100644 index 00000000..8df709c7 Binary files /dev/null and b/upload/cb_install/images/bttnrightalt.png differ diff --git a/upload/cb_install/images/header_grad.png b/upload/cb_install/images/header_grad.png new file mode 100644 index 00000000..367d5e5c Binary files /dev/null and b/upload/cb_install/images/header_grad.png differ diff --git a/upload/cb_install/images/header_grad_line.png b/upload/cb_install/images/header_grad_line.png new file mode 100644 index 00000000..7cec8147 Binary files /dev/null and b/upload/cb_install/images/header_grad_line.png differ diff --git a/upload/cb_install/images/loading.gif b/upload/cb_install/images/loading.gif new file mode 100644 index 00000000..48a7197a Binary files /dev/null and b/upload/cb_install/images/loading.gif differ diff --git a/upload/cb_install/images/tick.png b/upload/cb_install/images/tick.png new file mode 100644 index 00000000..a8dcaa8a Binary files /dev/null and b/upload/cb_install/images/tick.png differ diff --git a/upload/cb_install/index.php b/upload/cb_install/index.php new file mode 100644 index 00000000..2fa6908a --- /dev/null +++ b/upload/cb_install/index.php @@ -0,0 +1,40 @@ + \ No newline at end of file diff --git a/upload/cb_install/modes/adminsettings.php b/upload/cb_install/modes/adminsettings.php new file mode 100644 index 00000000..633fca45 --- /dev/null +++ b/upload/cb_install/modes/adminsettings.php @@ -0,0 +1,77 @@ +

    Admin Settings

    +All major steps are done, now enter username and password for your admin, +by default its username : admin | pass : admin
    +we now update installation details and insert language phrases +

    +cbinfo; + +$baseurl = dirname(GetServerURL()); +if(substr($baseurl,strlen($baseurl)-1,1)=='/') + $baseurl = substr($baseurl,0,strlen($baseurl)-1); + +$db->update(tbl("config"),array("value"),array($baseurl)," name='baseurl'"); +$db->update(tbl("config"),array("value"),array(BASEDIR)," name='basedir'"); +$db->update(tbl("config"),array("value"),array($released['release_date'])," name='date_released'"); +$db->update(tbl("config"),array("value"),array(now())," name='date_updated'"); +$db->update(tbl("config"),array("value"),array(now())," name='date_installed'"); +$db->update(tbl("config"),array("value"),array($released['version'])," name='version'"); +$db->update(tbl("config"),array("value"),array($released['state'])," name='type'"); + +$arr['msg'] = "Installation details have been updated"; +echo msg_arr($arr); + +$lang_obj->updateFromPack('en'); + +$arr['msg'] = "Language phrases have been imported"; +echo "
    ".msg_arr($arr); + +?> + + +

    + +
    + + +
    +
    + + + Generate | Current : admin +
    +
    + + +
    + + + + +
    +

    \ No newline at end of file diff --git a/upload/cb_install/modes/agreement.php b/upload/cb_install/modes/agreement.php new file mode 100644 index 00000000..5f0621a2 --- /dev/null +++ b/upload/cb_install/modes/agreement.php @@ -0,0 +1,10 @@ +

    Welcome to ClipBucket 2.1 Installer, this will let you install clipbucket with few clicks :), please read this documentation for further info and help

    + Clipbucket is indeed an open-source software under Attirubte assurance license and you must follow this license. Its not scary, it just states that one who did all the tought job should get credit for his work in form of his name in the footer, you can edit, sell, use this script but you must keep author's and product name on your website. +

    License

    +
    + +
    + +
    +
    \ No newline at end of file diff --git a/upload/cb_install/modes/body.php b/upload/cb_install/modes/body.php new file mode 100644 index 00000000..d60bc7ac --- /dev/null +++ b/upload/cb_install/modes/body.php @@ -0,0 +1,52 @@ + + + + + +ClipBucket v<?=VERSION?> <?=STATE?> Installer + + + + + + + + + + + + + +
    + +
    + +
    + ClipBucket is an effort of Arslan Hassan, Fawaz Tahir and some great supporters.
    +© ClipBucket 2007 - | Code written by Arslan & his team +
    + + + + \ No newline at end of file diff --git a/upload/cb_install/modes/database.php b/upload/cb_install/modes/database.php new file mode 100644 index 00000000..740456c6 --- /dev/null +++ b/upload/cb_install/modes/database.php @@ -0,0 +1,53 @@ +

    Database Settings

    + +To setup ClipBucket, we need some information on the database. You will need to know the following items before proceeding.

    +
      +
    1. Database name
    2. +
    3. Database username
    4. +
    5. Database password
    6. +
    7. Database host
    8. +
    9. Table prefix (if you want to run more than one ClipBucket in a single database)
    10. +
    +

    In all likelihood, these items were supplied to you by your Web Host. If you do not have this information, then you will need to contact them before you can continue. If you’re all ready…Below you should enter your database connection details + + +

    +
    + +
    + + +
    + +
    + + +
    + +
    + + + +
    + +
    + + +
    + +
    + + + +
    + + + +
    +
    \ No newline at end of file diff --git a/upload/cb_install/modes/dataimport.php b/upload/cb_install/modes/dataimport.php new file mode 100644 index 00000000..4c64ad38 --- /dev/null +++ b/upload/cb_install/modes/dataimport.php @@ -0,0 +1,47 @@ +

    Creating Database Tables and Importing data

    + + +
    + + + creating database structure... + + upgrading clipbucket... + +
    + +
    + + + + + + + + + + +
    + + \ No newline at end of file diff --git a/upload/cb_install/modes/finish.php b/upload/cb_install/modes/finish.php new file mode 100644 index 00000000..acdc5a52 --- /dev/null +++ b/upload/cb_install/modes/finish.php @@ -0,0 +1,72 @@ + +

    ClipBucket has been installed successfully

    +

    +

    + +
    +'Please delete cb_install directory'))?>
    +
    + + + + + +
    + +
    now you have succesfully installed clipbucket, you may be insterested in following plugins to enhance your website
    + + +
    + +
    Let you popluate your website with thousands of Youtube videos entirely based on your + queries with autocategorization and auto wordpress poster. it also embed videos from dailymotion, metacafe and revver.com
    +
    + +
    + +
    Facebook Connect allows your users to login to your website using Facebook account, They will first register and than login. Facebook connect is running on many websites, it can turn your user signup process alot quick and easier.
    +
    + +
    + +
    if you want to remove "powered by ClipBucket" from ClipBucket v2 Website, by purchasing this service, you can do that easily
    +
    + +
    + +
    Removes "Powered by ClipBucket" message and Pakplayer name from your flv player and Let you set your own logo and message on Pakplayer
    +
    + +
    + +
    ClipBucket Multi-server gives your website a new edge with more powerful video conversion option and data delivery.With Clipbucket Multi-server, you will have following options +
    +
    + + + +
    + +
    Paid Subscription module let you transform your website into an online video sharing market with a reliable source of income. Our module comes with very best features that let you control and distribute your content commercially. +
    +
    + +
    + + +
    + Please read our "what to do after installation" guide... +
    +

    + diff --git a/upload/cb_install/modes/finish_upgrade.php b/upload/cb_install/modes/finish_upgrade.php new file mode 100644 index 00000000..f2996dd5 --- /dev/null +++ b/upload/cb_install/modes/finish_upgrade.php @@ -0,0 +1,80 @@ +update(tbl("config"),array("value"),array(now())," name='date_updated' "); + +?> + +

    Your Clipbucket has been successfully upgraded to

    +

    +

    +'Please delete cb_install directory'))?>
    +
    + + + + + +
    + +
    now you have succesfully installed clipbucket, you may be insterested in following plugins to enhance your website
    + + +
    + +
    Let you popluate your website with thousands of Youtube videos entirely based on your + queries with autocategorization and auto wordpress poster. it also embed videos from dailymotion, metacafe and revver.com
    +
    + +
    + +
    Facebook Connect allows your users to login to your website using Facebook account, They will first register and than login. Facebook connect is running on many websites, it can turn your user signup process alot quick and easier.
    +
    + +
    + +
    if you want to remove "powered by ClipBucket" from ClipBucket v2 Website, by purchasing this service, you can do that easily
    +
    + +
    + +
    Removes "Powered by ClipBuclet" message and Pakplayer name from your flv player and Let you set your own logo and message on Pakplayer
    +
    + +
    + +
    ClipBucket Multi-server gives your website a new edge with more powerful video conversion option and data delivery.With Clipbucket Multi-server, you will have following options +
    +
    + + + +
    + +
    Paid Subscription module let you transform your website into an online video sharing market with a reliable source of income. Our module comes with very best features that let you control and distribute your content commercially. +
    +
    + +
    + + +
    + Please read our "what to do after installation" guide... +
    +

    + diff --git a/upload/cb_install/modes/lock.php b/upload/cb_install/modes/lock.php new file mode 100644 index 00000000..fb089b46 --- /dev/null +++ b/upload/cb_install/modes/lock.php @@ -0,0 +1,3 @@ +

    Installation is locked

    + +please create file "install.me" in folder /files/temp in order to install ClipBucket \ No newline at end of file diff --git a/upload/cb_install/modes/permission.php b/upload/cb_install/modes/permission.php new file mode 100644 index 00000000..1583a5d6 --- /dev/null +++ b/upload/cb_install/modes/permission.php @@ -0,0 +1,37 @@ + +

    Checking File & Directories Permissions

    + ClipBucket need some files and folders permissions in order to store files properly, please make sure all files given below are chmod properly
    +CHMOD : the chmod command (abbreviated from change mode) is a shell command and C language function in Unix and Unix-like environments.

    + +

    + + +
    + + +
    + +
    + + +
    + + +
    +
    + + +
    + + + + + + +
    diff --git a/upload/cb_install/modes/precheck.php b/upload/cb_install/modes/precheck.php new file mode 100644 index 00000000..f7c37caa --- /dev/null +++ b/upload/cb_install/modes/precheck.php @@ -0,0 +1,35 @@ +

    Prechecking

    +Clipbucket requires following modules in order to work properly, we are performing some initial search to find modules. +Click here for why we need these modules +

    + +

    + +
    +
    PHP
    + +
    +
    FFMPEG
    + +
    +
    FLVtool2
    + +
    + +
    MP4Box
    + +
    +
    cURL
    + +
    +
    PHPShield
    + +
    +
    +

    + + +
    + +
    +
    diff --git a/upload/cb_install/modes/register.php b/upload/cb_install/modes/register.php new file mode 100644 index 00000000..c8ee3aee --- /dev/null +++ b/upload/cb_install/modes/register.php @@ -0,0 +1,38 @@ +get_user_details(); +$adminemail = $userquery->get_user_field_only(1,'email'); + +$title = mysql_clean(post('title')); +$slogan = mysql_clean(post('slogan')); +$baseurl = mysql_clean(post('baseurl')); + +//First update website settings +$myquery->Set_Website_Details('site_title',$title); +$myquery->Set_Website_Details('site_slogan',$slogan); +$myquery->Set_Website_Details('baseurl',$baseurl); + +?>

    Registeration (Optional)

    +As you have installed ClipBucket Succesffuly, we highly recommend you to register your website on our Clipbucket. its really simple, just click on Register and continue and your website will be register on Clipbucket website
    +
    +

    Why we suggest registeration?

    +
      +
    • Get imediate security updates
    • +
    • Help us count how many websites are using Clipbucket
    • +
    • Grow our community
    • +
    • Easy interaction between Clipbucket and Webmasters
    • +
    + +
      +
    • We only save your email and website url
    • +
    • We will not share your email to anyone
    • +
    • We will integerate bug tracker pretty soon and you will be able to report bugs easily if you are registered
    • +
    + +
    + + + + + +
    + diff --git a/upload/cb_install/modes/sitesettings.php b/upload/cb_install/modes/sitesettings.php new file mode 100644 index 00000000..ed8d80a2 --- /dev/null +++ b/upload/cb_install/modes/sitesettings.php @@ -0,0 +1,47 @@ +update(tbl("users"),array +('username','password','email','doj','num_visits','ip','signup_ip','background_color','total_groups','banned_users'),array +(post('username'),$pass,post('email'),now(),1,$_SERVER['REMOTE_ADDR'],$_SERVER['REMOTE_ADDR'],'',0,''),"userid='$uid'"); + +//Login user +$userquery->login_user(post('username'),post('password')) + +?>'Admin details have been updated'))?> +

    Website basic configurations

    +here you can set basic configuration of your website, you can change them later by going to Admin area > Website Configurations + +

    + + +

    + +
    + + +
    + +
    + + +
    + +
    + +
    + without trailing slash '/' +
    + + + +

    + Please read this documentation for complete website configurations guide

    + +
    + +

    \ No newline at end of file diff --git a/upload/cb_install/modes/upgrade.php b/upload/cb_install/modes/upgrade.php new file mode 100644 index 00000000..c3a3f3af --- /dev/null +++ b/upload/cb_install/modes/upgrade.php @@ -0,0 +1,16 @@ + +

    You are now going to upgrade from to , please read this documentation for further info and help, please click continue upgrade

    + +
    + +
    +
    + +
    +'Please first login as Website adminstrator by going to admin_area and then try upgrading your website'))?>
    \ No newline at end of file diff --git a/upload/cb_install/round_arrow_right.png b/upload/cb_install/round_arrow_right.png new file mode 100644 index 00000000..c03ddfe0 Binary files /dev/null and b/upload/cb_install/round_arrow_right.png differ diff --git a/upload/cb_install/sql/add_admin.sql b/upload/cb_install/sql/add_admin.sql new file mode 100644 index 00000000..b08d2971 --- /dev/null +++ b/upload/cb_install/sql/add_admin.sql @@ -0,0 +1,7 @@ + +INSERT INTO `{tbl_prefix}users` (`userid`, `category`, `featured_video`, `username`, `user_session_key`, `user_session_code`, `password`, `email`, `usr_status`, `msg_notify`, `avatar`, `avatar_url`, `sex`, `dob`, `country`, `level`, `avcode`, `doj`, `last_logged`, `num_visits`, `session`, `ip`, `signup_ip`, `time_zone`, `featured`, `featured_date`, `profile_hits`, `total_watched`, `total_videos`, `total_comments`, `total_photos`, `total_collections`, `comments_count`, `last_commented`, `ban_status`, `upload`, `subscribers`, `total_subscriptions`, `background`, `background_color`, `background_url`, `background_repeat`, `background_attachement`, `total_groups`, `last_active`, `banned_users`, `welcome_email_sent`, `total_downloads`) VALUES +(1, 2, '', 'admin', '777750fea4d3bd585bf47dc1873619fc', 10192, '777750fea4d3bd585bf47dc1873619fc', 'webmaster@website', 'Ok', 'yes', '0', '', 'male', '1989-10-14', 'PK', 1, '08c5a7bd48', '0000-00-00 00:00:00', '2011-02-10 10:22:41', 86, 'pub6e7fq5oj76vakuov2j03hm1', '127.0.0.1', '', 0, 'No', '2009-12-03 15:14:20', 0, 0, 0, 0, 0, 0, 0, '2011-02-07 12:56:46', 'no', '0', 0, 1, '0', '#ed0000', '', 'no-repeat', 'yes', 3, '2011-02-14 08:43:25', 'test', 'yes', 0); + + +INSERT INTO `{tbl_prefix}user_profile` (`user_profile_id`, `show_my_collections`, `userid`, `profile_title`, `profile_desc`, `featured_video`, `first_name`, `last_name`, `avatar`, `show_dob`, `postal_code`, `time_zone`, `profile_tags`, `web_url`, `hometown`, `city`, `online_status`, `show_profile`, `allow_comments`, `allow_ratings`, `allow_subscription`, `content_filter`, `icon_id`, `browse_criteria`, `about_me`, `education`, `schools`, `occupation`, `companies`, `relation_status`, `hobbies`, `fav_movies`, `fav_music`, `fav_books`, `background`, `profile_video`, `profile_item`, `rating`, `voters`, `rated_by`, `show_my_videos`, `show_my_photos`, `show_my_subscriptions`, `show_my_subscribers`, `show_my_friends`) VALUES +(1, 'yes', 1, '', '', '', '', '', 'no_avatar.jpg', 'yes', '', 0, '', '', '', '', 'online', 'all', 'Yes', 'Yes', 'yes', 'Nothing', 0, NULL, '', '0', '', '', '', '0', '', '', '', '', '', 0, '', 0, '', 2, 'yes', 'yes', 'yes', 'yes', 'yes'); \ No newline at end of file diff --git a/upload/cb_install/sql/ads_placements.sql b/upload/cb_install/sql/ads_placements.sql new file mode 100644 index 00000000..742fdeea --- /dev/null +++ b/upload/cb_install/sql/ads_placements.sql @@ -0,0 +1,9 @@ + +-- Advertisement Placements + +INSERT INTO `{tbl_prefix}ads_placements` (`placement_id`, `placement`, `placement_name`, `disable`) VALUES +(1, 'ad_160x600', 'Wide Skyscrapper 160 x 600', 'yes'), +(2, 'ad_468x60', 'Banner 468 x 60', 'yes'), +(3, 'ad_300x250', 'Medium Rectangle 300 x 250', 'yes'), +(4, 'ad_728x90', 'Leader Board 728 x 90', 'yes'), +(5, 'ad_120x600', 'Skyscrapper 120 x 600', 'yes'); \ No newline at end of file diff --git a/upload/cb_install/sql/categories.sql b/upload/cb_install/sql/categories.sql new file mode 100644 index 00000000..e22aa21f --- /dev/null +++ b/upload/cb_install/sql/categories.sql @@ -0,0 +1,16 @@ +INSERT INTO `{tbl_prefix}collection_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Uncategorized', 0, 'Uncategorized', now(), 0, 'yes'); + + +INSERT INTO `{tbl_prefix}group_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Uncategorized', 1, 'Uncategorized', now(), '', 'yes'); + + +INSERT INTO `{tbl_prefix}user_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Basic User', 1, '', now(), '', 'yes'), +(2, 'Gurus', 1, '', now(), '', 'no'), +(3, 'Comedian', 1, '', now(), '', 'no'); + + +INSERT INTO `{tbl_prefix}video_categories` (`category_id`, `parent_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 0, 'Uncategorized', 1, '', now(), '', 'yes'); \ No newline at end of file diff --git a/upload/cb_install/sql/configs.sql b/upload/cb_install/sql/configs.sql new file mode 100644 index 00000000..820e1c24 --- /dev/null +++ b/upload/cb_install/sql/configs.sql @@ -0,0 +1,248 @@ +-- Configurations + +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES +(1, 'site_title', 'ClipBucket v2'), +(2, 'site_slogan', 'A way to broadcast yourself'), +(3, 'baseurl', ''), +(4, 'basedir', ''), +(5, 'template_dir', 'cbv2new'), +(6, 'player_file', 'pak_player.php'), +(7, 'closed', '0'), +(8, 'closed_msg', 'We Are Updating Our Website, Please Visit us after few hours.'), +(9, 'description', 'Clip Bucket is an ultimate Video Sharing script'), +(10, 'keywords', 'clip bucket video sharing website script'), +(11, 'ffmpegpath', '/usr/local/bin/ffmpeg'), +(12, 'flvtool2path', '/usr/local/bin/flvtool2'), +(13, 'mp4boxpath', '/usr/local/bin/MP4Box'), +(14, 'vbrate', '512000'), +(15, 'srate', '22050'), +(16, 'r_height', ''), +(17, 'r_width', ''), +(18, 'resize', ''), +(19, 'mencoderpath', ''), +(20, 'keep_original', '1'), +(21, 'activation', ''), +(22, 'mplayerpath', ''), +(23, 'email_verification', '1'), +(24, 'allow_registeration', '1'), +(25, 'php_path', '/usr/bin/php'), +(26, 'videos_list_per_page', '30'), +(27, 'channels_list_per_page', '25'), +(28, 'videos_list_per_tab', '1'), +(29, 'channels_list_per_tab', '1'), +(30, 'video_comments', '1'), +(31, 'video_rating', '1'), +(32, 'comment_rating', '1'), +(33, 'video_download', '1'), +(34, 'video_embed', '1'), +(35, 'groups_list_per_page', '25'), +(36, 'seo', 'no'), +(37, 'admin_pages', '100'), +(38, 'search_list_per_page', '25'), +(39, 'recently_viewed_limit', '10'), +(40, 'max_upload_size', '1000'), +(41, 'sbrate', '128000'), +(42, 'thumb_width', '120'), +(43, 'thumb_height', '90'), +(45, 'user_comment_opt1', ''), +(44, 'ffmpeg_type', ''), +(46, 'user_comment_opt2', ''), +(47, 'user_comment_opt3', ''), +(48, 'user_comment_opt4', ''), +(49, 'user_rate_opt1', ''), +(50, 'captcha_type', '0'), +(51, 'allow_upload', ''), +(52, 'allowed_types', 'wmv,avi,divx,3gp,mov,mpeg,mpg,xvid,flv,asf,rm,dat,mp4,jpg'), +(53, 'version', '2.0.1'), +(54, 'version_type', 'Alpha'), +(55, 'allow_template_change', '1'), +(56, 'allow_language_change', '1'), +(57, 'default_site_lang', ''), +(58, 'video_require_login', ''), +(59, 'audio_codec', 'libfaac'), +(60, 'con_modules_type', ''), +(61, 'remoteUpload', ''), +(62, 'embedUpload', ''), +(63, 'player_div_id', ''), +(64, 'code_dev', '(Powered by ClipBucket)'), +(65, 'sys_os', ''), +(66, 'debug_level', ''), +(67, 'enable_troubleshooter', '1'), +(68, 'vrate', '25'), +(69, 'num_thumbs', '5'), +(70, 'big_thumb_width', '320'), +(71, 'big_thumb_height', '240'), +(72, 'user_max_chr', '15'), +(73, 'disallowed_usernames', 'shit, asshole, fucker'), +(74, 'min_age_reg', '0'), +(75, 'max_comment_chr', '800'), +(76, 'user_comment_own', ''), +(77, 'anonym_comments', 'yes'), +(78, 'player_dir', 'pak_player'), +(79, 'player_width', '661'), +(80, 'player_height', '360'), +(81, 'default_country_iso2', 'PK'), +(82, 'channel_player_width', '600'), +(83, 'channel_player_height', '281'), +(84, 'videos_items_grp_page', '24'), +(85, 'videos_items_hme_page', '25'), +(86, 'videos_items_columns', '12'), +(87, 'videos_items_ufav_page', '25'), +(88, 'videos_items_uvid_page', '25'), +(89, 'videos_items_search_page', '30'), +(90, 'videos_item_channel_page', '25'), +(91, 'users_items_subscriptions', '5'), +(92, 'users_items_subscibers', '5'), +(93, 'users_items_contacts_channel', '5'), +(94, 'users_items_search_page', '12'), +(95, 'users_items_group_page', '15'), +(96, 'cbhash', 'PGRpdiBhbGlnbj0iY2VudGVyIj48IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPg0KUG93ZXJlZCBieSA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tLyI+Q2xpcEJ1Y2tldDwvYT4gJXMgfCA8YSBocmVmPSJodHRwOi8vY2xpcC1idWNrZXQuY29tL2Fyc2xhbi1oYXNzYW4iPkFyc2xhbiBIYXNzYW48L2E+DQo8IS0tIERvIG5vdCByZW1vdmUgdGhpcyBjb3B5cmlnaHQgbm90aWNlIC0tPjwvZGl2Pg=='), +(97, 'min_video_title', '4'), +(98, 'max_video_title', '60'), +(99, 'min_video_desc', '5'), +(100, 'max_video_desc', '300'), +(101, 'video_categories', '4'), +(102, 'min_video_tags', '3'), +(103, 'max_video_tags', '30'), +(104, 'video_codec', 'libx264'), +(105, 'date_released', '01-05-2010'), +(106, 'date_installed', '01-05-2010'), +(107, 'date_updated', '2010-01-09 18:36:16'), +(108, 'support_email', 'webmaster@localhost'), +(109, 'website_email', 'webmaster@localhost'), +(110, 'welcome_email', 'webmaster@localhost'), +(112, 'anonymous_id', '99'), +(113, 'date_format', 'Y-m-d'), +(114, 'default_time_zone', '5'), +(156, 'use_crons', 'no'), +(115, 'autoplay_video', 'no'), +(116, 'default_country_iso2', 'PK'), +(117, 'channel_comments', '1'), +(118, 'max_profile_pic_size', '2500'), +(119, 'max_profile_pic_height', ''), +(120, 'max_profile_pic_width', '230'), +(121, 'gravatars', ''), +(122, 'picture_url', 'yes'), +(123, 'picture_upload', 'yes'), +(124, 'background_url', 'yes'), +(125, 'background_upload', 'yes'), +(126, 'max_bg_size', '2500'), +(127, 'max_bg_width', '1600'), +(128, 'max_bg_height', ''), +(129, 'background_color', 'yes'), +(130, 'send_comment_notification', 'yes'), +(131, 'approve_video_notification', 'yes'), +(132, 'keep_mp4_as_is', 'yes'), +(133, 'hq_output', 'yes'), +(134, 'grp_categories', '3'), +(136, 'grps_items_search_page', '25'), +(137, 'grp_thumb_height', '140'), +(138, 'grp_thumb_width', '140'), +(139, 'grp_max_title', '20'), +(140, 'grp_max_desc', '500'), +(141, 'quick_conv', ''), +(142, 'server_friendly_conversion', ''), +(143, 'max_conversion', '2'), +(144, 'max_time_wait', '7200'), +(145, 'allow_unicode_usernames', 'yes'), +(146, 'min_username', '3'), +(147, 'max_username', '15'), +(154, 'youtube_enabled', 'yes'), +(148, 'allow_username_spaces', 'yes'), +(149, 'use_playlist', 'yes'), +(150, 'comments_captcha', 'guests'), +(151, 'player_logo_file', 'logo.jpg'), +(152, 'logo_placement', 'tl'), +(153, 'buffer_time', '5'), +(155, 'use_ffmpeg_vf', 'no'), +(224, 'own_photo_rating', ''), +(157, 'mail_type', 'mail'), +(158, 'smtp_host', ''), +(159, 'smtp_user', ''), +(160, 'smtp_pass', ''), +(161, 'smtp_auth', 'no'), +(162, 'smtp_port', ''), +(163, 'use_subs', '1'), +(164, 'pak_license', ''), +(165, 'photo_ratio', '16:10'), +(166, 'photo_thumb_width', '120'), +(167, 'photo_thumb_height', '75'), +(168, 'photo_med_width', '185'), +(169, 'photo_med_height', '116'), +(170, 'photo_lar_width', '600'), +(171, 'photo_crop', '1'), +(172, 'photo_multi_upload', '5'), +(173, 'photo_download', '1'), +(174, 'photo_comments', '1'), +(175, 'photo_rating', '1'), +(176, 'max_photo_size', '2'), +(177, 'watermark_photo', '0'), +(178, 'watermark_max_width', '120'), +(179, 'watermark_placement', 'left:top'), +(180, 'load_upload_form', 'yes'), +(181, 'load_remote_upload_form', 'yes'), +(182, 'load_embed_form', 'yes'), +(183, 'load_link_video_form', 'yes'), +(184, 'enable_groups', ''), +(185, 'groupsSection', 'yes'), +(186, 'videosSection', 'yes'), +(187, 'photosSection', 'yes'), +(188, 'homeSection', 'yes'), +(189, 'signupSection', 'yes'), +(190, 'uploadSection', 'yes'), +(191, 'collectionsSection', 'yes'), +(192, 'channelsSection', 'yes'), +(193, 'flvtoolpp', ''), +(194, 'normal_resolution', '480'), +(195, 'high_resolution', '720'), +(196, 'max_video_duration', '320'), +(197, 'embed_player_height', '250'), +(198, 'embed_player_width', '300'), +(199, 'autoplay_embed', 'yes'), +(200, 'playlistsSection', 'yes'), +(201, 'photo_main_list', '10'), +(202, 'photo_home_tabs', '30'), +(203, 'photo_search_result', '30'), +(204, 'photo_channel_page', '10'), +(205, 'photo_user_photos', '20'), +(206, 'photo_user_favorites', '20'), +(207, 'photo_other_limit', '8'), +(208, 'collection_per_page', '30'), +(209, 'collection_home_page', '10'), +(210, 'collection_search_result', '20'), +(211, 'collection_channel_page', '10'), +(212, 'collection_user_collections', '20'), +(213, 'collection_user_favorites', '20'), +(214, 'collection_items_page', '20'), +(218, 'reCaptcha_private_key', '6LcQI8ESAAAAALc_oz1xuNsBVRNx554CaJHjcoXt'), +(217, 'reCaptcha_public_key', '6LcQI8ESAAAAALN1vYQovst9c6nlU52iHdqWExp8'), +(219, 'channel_rating', '1'), +(220, 'own_channel_rating', '1'), +(221, 'collection_rating', '1'), +(222, 'own_collection_rating', '1'), +(223, 'own_video_rating', '1'), +(NULL,'feedsSection','yes'), +(NULL,'max_topic_length','1500'), +(NULL,'max_topic_title','300'); + + + +INSERT INTO `{tbl_prefix}languages` (`language_id`, `language_code`, `language_name`, `language_regex`, `language_active`, `language_default`) VALUES +(5, 'en', 'English', '/^en/i', 'yes', 'yes'); + + +INSERT INTO `{tbl_prefix}validation_re` (`re_id`, `re_name`, `re_code`, `re_syntax`) VALUES +(1, 'Username', 'username', '^^[a-zA-Z0-9_]+$'), +(2, 'Email', 'email', '^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,10})$'), +(3, 'Field Text', 'field_text', '^^[_a-z0-9-]+$'); + + +INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`)VALUES +(NULL , 'comments_per_page', '15'), +(NULL, 'embed_type', 'iframe'); + +-- Addition for 2.6 +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'facebook_embed', 'yes'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'seo_vido_url', '1'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'use_cached_pagin', 'yes'), +(NULL, 'cached_pagin_time', '5'); diff --git a/upload/cb_install/sql/countries.sql b/upload/cb_install/sql/countries.sql new file mode 100644 index 00000000..e6aa1451 --- /dev/null +++ b/upload/cb_install/sql/countries.sql @@ -0,0 +1,245 @@ + +-- +-- Dumping data for table `countries` +-- + +INSERT INTO `{tbl_prefix}countries` (`country_id`, `iso2`, `name`, `name_en`, `iso3`, `numcode`) VALUES +(1, 'AF', 'AFGHANISTAN', 'Afghanistan', 'AFG', 4), +(2, 'AL', 'ALBANIA', 'Albania', 'ALB', 8), +(3, 'DZ', 'ALGERIA', 'Algeria', 'DZA', 12), +(4, 'AS', 'AMERICAN SAMOA', 'American Samoa', 'ASM', 16), +(5, 'AD', 'ANDORRA', 'Andorra', 'AND', 20), +(6, 'AO', 'ANGOLA', 'Angola', 'AGO', 24), +(7, 'AI', 'ANGUILLA', 'Anguilla', 'AIA', 660), +(8, 'AQ', 'ANTARCTICA', 'Antarctica', NULL, NULL), +(9, 'AG', 'ANTIGUA AND BARBUDA', 'Antigua and Barbuda', 'ATG', 28), +(10, 'AR', 'ARGENTINA', 'Argentina', 'ARG', 32), +(11, 'AM', 'ARMENIA', 'Armenia', 'ARM', 51), +(12, 'AW', 'ARUBA', 'Aruba', 'ABW', 533), +(13, 'AU', 'AUSTRALIA', 'Australia', 'AUS', 36), +(14, 'AT', 'AUSTRIA', 'Austria', 'AUT', 40), +(15, 'AZ', 'AZERBAIJAN', 'Azerbaijan', 'AZE', 31), +(16, 'BS', 'BAHAMAS', 'Bahamas', 'BHS', 44), +(17, 'BH', 'BAHRAIN', 'Bahrain', 'BHR', 48), +(18, 'BD', 'BANGLADESH', 'Bangladesh', 'BGD', 50), +(19, 'BB', 'BARBADOS', 'Barbados', 'BRB', 52), +(20, 'BY', 'BELARUS', 'Belarus', 'BLR', 112), +(21, 'BE', 'BELGIUM', 'Belgium', 'BEL', 56), +(22, 'BZ', 'BELIZE', 'Belize', 'BLZ', 84), +(23, 'BJ', 'BENIN', 'Benin', 'BEN', 204), +(24, 'BM', 'BERMUDA', 'Bermuda', 'BMU', 60), +(25, 'BT', 'BHUTAN', 'Bhutan', 'BTN', 64), +(26, 'BO', 'BOLIVIA', 'Bolivia', 'BOL', 68), +(27, 'BA', 'BOSNIA AND HERZEGOVINA', 'Bosnia and Herzegovina', 'BIH', 70), +(28, 'BW', 'BOTSWANA', 'Botswana', 'BWA', 72), +(29, 'BV', 'BOUVET ISLAND', 'Bouvet Island', NULL, NULL), +(30, 'BR', 'BRAZIL', 'Brazil', 'BRA', 76), +(31, 'IO', 'BRITISH INDIAN OCEAN TERRITORY', 'British Indian Ocean Territory', NULL, NULL), +(32, 'BN', 'BRUNEI DARUSSALAM', 'Brunei Darussalam', 'BRN', 96), +(33, 'BG', 'BULGARIA', 'Bulgaria', 'BGR', 100), +(34, 'BF', 'BURKINA FASO', 'Burkina Faso', 'BFA', 854), +(35, 'BI', 'BURUNDI', 'Burundi', 'BDI', 108), +(36, 'KH', 'CAMBODIA', 'Cambodia', 'KHM', 116), +(37, 'CM', 'CAMEROON', 'Cameroon', 'CMR', 120), +(38, 'CA', 'CANADA', 'Canada', 'CAN', 124), +(39, 'CV', 'CAPE VERDE', 'Cape Verde', 'CPV', 132), +(40, 'KY', 'CAYMAN ISLANDS', 'Cayman Islands', 'CYM', 136), +(41, 'CF', 'CENTRAL AFRICAN REPUBLIC', 'Central African Republic', 'CAF', 140), +(42, 'TD', 'CHAD', 'Chad', 'TCD', 148), +(43, 'CL', 'CHILE', 'Chile', 'CHL', 152), +(44, 'CN', 'CHINA', 'China', 'CHN', 156), +(45, 'CX', 'CHRISTMAS ISLAND', 'Christmas Island', NULL, NULL), +(46, 'CC', 'COCOS (KEELING) ISLANDS', 'Cocos (Keeling) Islands', NULL, NULL), +(47, 'CO', 'COLOMBIA', 'Colombia', 'COL', 170), +(48, 'KM', 'COMOROS', 'Comoros', 'COM', 174), +(49, 'CG', 'CONGO', 'Congo', 'COG', 178), +(50, 'CD', 'CONGO, THE DEMOCRATIC REPUBLIC OF THE', 'Congo, the Democratic Republic of the', 'COD', 180), +(51, 'CK', 'COOK ISLANDS', 'Cook Islands', 'COK', 184), +(52, 'CR', 'COSTA RICA', 'Costa Rica', 'CRI', 188), +(53, 'CI', 'COTE D''IVOIRE', 'Cote D''Ivoire', 'CIV', 384), +(54, 'HR', 'CROATIA', 'Croatia', 'HRV', 191), +(55, 'CU', 'CUBA', 'Cuba', 'CUB', 192), +(56, 'CY', 'CYPRUS', 'Cyprus', 'CYP', 196), +(57, 'CZ', 'CZECH REPUBLIC', 'Czech Republic', 'CZE', 203), +(58, 'DK', 'DENMARK', 'Denmark', 'DNK', 208), +(59, 'DJ', 'DJIBOUTI', 'Djibouti', 'DJI', 262), +(60, 'DM', 'DOMINICA', 'Dominica', 'DMA', 212), +(61, 'DO', 'DOMINICAN REPUBLIC', 'Dominican Republic', 'DOM', 214), +(62, 'EC', 'ECUADOR', 'Ecuador', 'ECU', 218), +(63, 'EG', 'EGYPT', 'Egypt', 'EGY', 818), +(64, 'SV', 'EL SALVADOR', 'El Salvador', 'SLV', 222), +(65, 'GQ', 'EQUATORIAL GUINEA', 'Equatorial Guinea', 'GNQ', 226), +(66, 'ER', 'ERITREA', 'Eritrea', 'ERI', 232), +(67, 'EE', 'ESTONIA', 'Estonia', 'EST', 233), +(68, 'ET', 'ETHIOPIA', 'Ethiopia', 'ETH', 231), +(69, 'FK', 'FALKLAND ISLANDS (MALVINAS)', 'Falkland Islands (Malvinas)', 'FLK', 238), +(70, 'FO', 'FAROE ISLANDS', 'Faroe Islands', 'FRO', 234), +(71, 'FJ', 'FIJI', 'Fiji', 'FJI', 242), +(72, 'FI', 'FINLAND', 'Finland', 'FIN', 246), +(73, 'FR', 'FRANCE', 'France', 'FRA', 250), +(74, 'GF', 'FRENCH GUIANA', 'French Guiana', 'GUF', 254), +(75, 'PF', 'FRENCH POLYNESIA', 'French Polynesia', 'PYF', 258), +(76, 'TF', 'FRENCH SOUTHERN TERRITORIES', 'French Southern Territories', NULL, NULL), +(77, 'GA', 'GABON', 'Gabon', 'GAB', 266), +(78, 'GM', 'GAMBIA', 'Gambia', 'GMB', 270), +(79, 'GE', 'GEORGIA', 'Georgia', 'GEO', 268), +(80, 'DE', 'GERMANY', 'Germany', 'DEU', 276), +(81, 'GH', 'GHANA', 'Ghana', 'GHA', 288), +(82, 'GI', 'GIBRALTAR', 'Gibraltar', 'GIB', 292), +(83, 'GR', 'GREECE', 'Greece', 'GRC', 300), +(84, 'GL', 'GREENLAND', 'Greenland', 'GRL', 304), +(85, 'GD', 'GRENADA', 'Grenada', 'GRD', 308), +(86, 'GP', 'GUADELOUPE', 'Guadeloupe', 'GLP', 312), +(87, 'GU', 'GUAM', 'Guam', 'GUM', 316), +(88, 'GT', 'GUATEMALA', 'Guatemala', 'GTM', 320), +(89, 'GN', 'GUINEA', 'Guinea', 'GIN', 324), +(90, 'GW', 'GUINEA-BISSAU', 'Guinea-Bissau', 'GNB', 624), +(91, 'GY', 'GUYANA', 'Guyana', 'GUY', 328), +(92, 'HT', 'HAITI', 'Haiti', 'HTI', 332), +(93, 'HM', 'HEARD ISLAND AND MCDONALD ISLANDS', 'Heard Island and Mcdonald Islands', NULL, NULL), +(94, 'VA', 'HOLY SEE (VATICAN CITY STATE)', 'Holy See (Vatican City State)', 'VAT', 336), +(95, 'HN', 'HONDURAS', 'Honduras', 'HND', 340), +(96, 'HK', 'HONG KONG', 'Hong Kong', 'HKG', 344), +(97, 'HU', 'HUNGARY', 'Hungary', 'HUN', 348), +(98, 'IS', 'ICELAND', 'Iceland', 'ISL', 352), +(99, 'IN', 'INDIA', 'India', 'IND', 356), +(100, 'ID', 'INDONESIA', 'Indonesia', 'IDN', 360), +(101, 'IR', 'IRAN, ISLAMIC REPUBLIC OF', 'Iran, Islamic Republic of', 'IRN', 364), +(102, 'IQ', 'IRAQ', 'Iraq', 'IRQ', 368), +(103, 'IE', 'IRELAND', 'Ireland', 'IRL', 372), +(104, 'IL', 'ISRAEL', 'Israel', 'ISR', 376), +(105, 'IT', 'ITALY', 'Italy', 'ITA', 380), +(106, 'JM', 'JAMAICA', 'Jamaica', 'JAM', 388), +(107, 'JP', 'JAPAN', 'Japan', 'JPN', 392), +(108, 'JO', 'JORDAN', 'Jordan', 'JOR', 400), +(109, 'KZ', 'KAZAKHSTAN', 'Kazakhstan', 'KAZ', 398), +(110, 'KE', 'KENYA', 'Kenya', 'KEN', 404), +(111, 'KI', 'KIRIBATI', 'Kiribati', 'KIR', 296), +(112, 'KP', 'KOREA, DEMOCRATIC PEOPLE''S REPUBLIC OF', 'Korea, Democratic People''s Republic of', 'PRK', 408), +(113, 'KR', 'KOREA, REPUBLIC OF', 'Korea, Republic of', 'KOR', 410), +(114, 'KW', 'KUWAIT', 'Kuwait', 'KWT', 414), +(115, 'KG', 'KYRGYZSTAN', 'Kyrgyzstan', 'KGZ', 417), +(116, 'LA', 'LAO PEOPLE''S DEMOCRATIC REPUBLIC', 'Lao People''s Democratic Republic', 'LAO', 418), +(117, 'LV', 'LATVIA', 'Latvia', 'LVA', 428), +(118, 'LB', 'LEBANON', 'Lebanon', 'LBN', 422), +(119, 'LS', 'LESOTHO', 'Lesotho', 'LSO', 426), +(120, 'LR', 'LIBERIA', 'Liberia', 'LBR', 430), +(121, 'LY', 'LIBYAN ARAB JAMAHIRIYA', 'Libyan Arab Jamahiriya', 'LBY', 434), +(122, 'LI', 'LIECHTENSTEIN', 'Liechtenstein', 'LIE', 438), +(123, 'LT', 'LITHUANIA', 'Lithuania', 'LTU', 440), +(124, 'LU', 'LUXEMBOURG', 'Luxembourg', 'LUX', 442), +(125, 'MO', 'MACAO', 'Macao', 'MAC', 446), +(126, 'MK', 'MACEDONIA, THE FORMER YUGOSLAV REPUBLIC OF', 'Macedonia, the Former Yugoslav Republic of', 'MKD', 807), +(127, 'MG', 'MADAGASCAR', 'Madagascar', 'MDG', 450), +(128, 'MW', 'MALAWI', 'Malawi', 'MWI', 454), +(129, 'MY', 'MALAYSIA', 'Malaysia', 'MYS', 458), +(130, 'MV', 'MALDIVES', 'Maldives', 'MDV', 462), +(131, 'ML', 'MALI', 'Mali', 'MLI', 466), +(132, 'MT', 'MALTA', 'Malta', 'MLT', 470), +(133, 'MH', 'MARSHALL ISLANDS', 'Marshall Islands', 'MHL', 584), +(134, 'MQ', 'MARTINIQUE', 'Martinique', 'MTQ', 474), +(135, 'MR', 'MAURITANIA', 'Mauritania', 'MRT', 478), +(136, 'MU', 'MAURITIUS', 'Mauritius', 'MUS', 480), +(137, 'YT', 'MAYOTTE', 'Mayotte', NULL, NULL), +(138, 'MX', 'MEXICO', 'Mexico', 'MEX', 484), +(139, 'FM', 'MICRONESIA, FEDERATED STATES OF', 'Micronesia, Federated States of', 'FSM', 583), +(140, 'MD', 'MOLDOVA, REPUBLIC OF', 'Moldova, Republic of', 'MDA', 498), +(141, 'MC', 'MONACO', 'Monaco', 'MCO', 492), +(142, 'MN', 'MONGOLIA', 'Mongolia', 'MNG', 496), +(143, 'MS', 'MONTSERRAT', 'Montserrat', 'MSR', 500), +(144, 'MA', 'MOROCCO', 'Morocco', 'MAR', 504), +(145, 'MZ', 'MOZAMBIQUE', 'Mozambique', 'MOZ', 508), +(146, 'MM', 'MYANMAR', 'Myanmar', 'MMR', 104), +(147, 'NA', 'NAMIBIA', 'Namibia', 'NAM', 516), +(148, 'NR', 'NAURU', 'Nauru', 'NRU', 520), +(149, 'NP', 'NEPAL', 'Nepal', 'NPL', 524), +(150, 'NL', 'NETHERLANDS', 'Netherlands', 'NLD', 528), +(151, 'AN', 'NETHERLANDS ANTILLES', 'Netherlands Antilles', 'ANT', 530), +(152, 'NC', 'NEW CALEDONIA', 'New Caledonia', 'NCL', 540), +(153, 'NZ', 'NEW ZEALAND', 'New Zealand', 'NZL', 554), +(154, 'NI', 'NICARAGUA', 'Nicaragua', 'NIC', 558), +(155, 'NE', 'NIGER', 'Niger', 'NER', 562), +(156, 'NG', 'NIGERIA', 'Nigeria', 'NGA', 566), +(157, 'NU', 'NIUE', 'Niue', 'NIU', 570), +(158, 'NF', 'NORFOLK ISLAND', 'Norfolk Island', 'NFK', 574), +(159, 'MP', 'NORTHERN MARIANA ISLANDS', 'Northern Mariana Islands', 'MNP', 580), +(160, 'NO', 'NORWAY', 'Norway', 'NOR', 578), +(161, 'OM', 'OMAN', 'Oman', 'OMN', 512), +(162, 'PK', 'PAKISTAN', 'Pakistan', 'PAK', 586), +(163, 'PW', 'PALAU', 'Palau', 'PLW', 585), +(164, 'PS', 'PALESTINIAN TERRITORY, OCCUPIED', 'Palestinian Territory, Occupied', NULL, NULL), +(165, 'PA', 'PANAMA', 'Panama', 'PAN', 591), +(166, 'PG', 'PAPUA NEW GUINEA', 'Papua New Guinea', 'PNG', 598), +(167, 'PY', 'PARAGUAY', 'Paraguay', 'PRY', 600), +(168, 'PE', 'PERU', 'Peru', 'PER', 604), +(169, 'PH', 'PHILIPPINES', 'Philippines', 'PHL', 608), +(170, 'PN', 'PITCAIRN', 'Pitcairn', 'PCN', 612), +(171, 'PL', 'POLAND', 'Poland', 'POL', 616), +(172, 'PT', 'PORTUGAL', 'Portugal', 'PRT', 620), +(173, 'PR', 'PUERTO RICO', 'Puerto Rico', 'PRI', 630), +(174, 'QA', 'QATAR', 'Qatar', 'QAT', 634), +(175, 'RE', 'REUNION', 'Reunion', 'REU', 638), +(176, 'RO', 'ROMANIA', 'Romania', 'ROM', 642), +(177, 'RU', 'RUSSIAN FEDERATION', 'Russian Federation', 'RUS', 643), +(178, 'RW', 'RWANDA', 'Rwanda', 'RWA', 646), +(179, 'SH', 'SAINT HELENA', 'Saint Helena', 'SHN', 654), +(180, 'KN', 'SAINT KITTS AND NEVIS', 'Saint Kitts and Nevis', 'KNA', 659), +(181, 'LC', 'SAINT LUCIA', 'Saint Lucia', 'LCA', 662), +(182, 'PM', 'SAINT PIERRE AND MIQUELON', 'Saint Pierre and Miquelon', 'SPM', 666), +(183, 'VC', 'SAINT VINCENT AND THE GRENADINES', 'Saint Vincent and the Grenadines', 'VCT', 670), +(184, 'WS', 'SAMOA', 'Samoa', 'WSM', 882), +(185, 'SM', 'SAN MARINO', 'San Marino', 'SMR', 674), +(186, 'ST', 'SAO TOME AND PRINCIPE', 'Sao Tome and Principe', 'STP', 678), +(187, 'SA', 'SAUDI ARABIA', 'Saudi Arabia', 'SAU', 682), +(188, 'SN', 'SENEGAL', 'Senegal', 'SEN', 686), +(189, 'CS', 'SERBIA AND MONTENEGRO', 'Serbia and Montenegro', NULL, NULL), +(190, 'SC', 'SEYCHELLES', 'Seychelles', 'SYC', 690), +(191, 'SL', 'SIERRA LEONE', 'Sierra Leone', 'SLE', 694), +(192, 'SG', 'SINGAPORE', 'Singapore', 'SGP', 702), +(193, 'SK', 'SLOVAKIA', 'Slovakia', 'SVK', 703), +(194, 'SI', 'SLOVENIA', 'Slovenia', 'SVN', 705), +(195, 'SB', 'SOLOMON ISLANDS', 'Solomon Islands', 'SLB', 90), +(196, 'SO', 'SOMALIA', 'Somalia', 'SOM', 706), +(197, 'ZA', 'SOUTH AFRICA', 'South Africa', 'ZAF', 710), +(198, 'GS', 'SOUTH GEORGIA AND THE SOUTH SANDWICH ISLANDS', 'South Georgia and the South Sandwich Islands', NULL, NULL), +(199, 'ES', 'SPAIN', 'Spain', 'ESP', 724), +(200, 'LK', 'SRI LANKA', 'Sri Lanka', 'LKA', 144), +(201, 'SD', 'SUDAN', 'Sudan', 'SDN', 736), +(202, 'SR', 'SURINAME', 'Suriname', 'SUR', 740), +(203, 'SJ', 'SVALBARD AND JAN MAYEN', 'Svalbard and Jan Mayen', 'SJM', 744), +(204, 'SZ', 'SWAZILAND', 'Swaziland', 'SWZ', 748), +(205, 'SE', 'SWEDEN', 'Sweden', 'SWE', 752), +(206, 'CH', 'SWITZERLAND', 'Switzerland', 'CHE', 756), +(207, 'SY', 'SYRIAN ARAB REPUBLIC', 'Syrian Arab Republic', 'SYR', 760), +(208, 'TW', 'TAIWAN, PROVINCE OF CHINA', 'Taiwan, Province of China', 'TWN', 158), +(209, 'TJ', 'TAJIKISTAN', 'Tajikistan', 'TJK', 762), +(210, 'TZ', 'TANZANIA, UNITED REPUBLIC OF', 'Tanzania, United Republic of', 'TZA', 834), +(211, 'TH', 'THAILAND', 'Thailand', 'THA', 764), +(212, 'TL', 'TIMOR-LESTE', 'Timor-Leste', NULL, NULL), +(213, 'TG', 'TOGO', 'Togo', 'TGO', 768), +(214, 'TK', 'TOKELAU', 'Tokelau', 'TKL', 772), +(215, 'TO', 'TONGA', 'Tonga', 'TON', 776), +(216, 'TT', 'TRINIDAD AND TOBAGO', 'Trinidad and Tobago', 'TTO', 780), +(217, 'TN', 'TUNISIA', 'Tunisia', 'TUN', 788), +(218, 'TR', 'TURKEY', 'Turkey', 'TUR', 792), +(219, 'TM', 'TURKMENISTAN', 'Turkmenistan', 'TKM', 795), +(220, 'TC', 'TURKS AND CAICOS ISLANDS', 'Turks and Caicos Islands', 'TCA', 796), +(221, 'TV', 'TUVALU', 'Tuvalu', 'TUV', 798), +(222, 'UG', 'UGANDA', 'Uganda', 'UGA', 800), +(223, 'UA', 'UKRAINE', 'Ukraine', 'UKR', 804), +(224, 'AE', 'UNITED ARAB EMIRATES', 'United Arab Emirates', 'ARE', 784), +(225, 'GB', 'UNITED KINGDOM', 'United Kingdom', 'GBR', 826), +(226, 'US', 'UNITED STATES', 'United States', 'USA', 840), +(227, 'UM', 'UNITED STATES MINOR OUTLYING ISLANDS', 'United States Minor Outlying Islands', NULL, NULL), +(228, 'UY', 'URUGUAY', 'Uruguay', 'URY', 858), +(229, 'UZ', 'UZBEKISTAN', 'Uzbekistan', 'UZB', 860), +(230, 'VU', 'VANUATU', 'Vanuatu', 'VUT', 548), +(231, 'VE', 'VENEZUELA', 'Venezuela', 'VEN', 862), +(232, 'VN', 'VIET NAM', 'Viet Nam', 'VNM', 704), +(233, 'VG', 'VIRGIN ISLANDS, BRITISH', 'Virgin Islands, British', 'VGB', 92), +(234, 'VI', 'VIRGIN ISLANDS, U.S.', 'Virgin Islands, U.s.', 'VIR', 850), +(235, 'WF', 'WALLIS AND FUTUNA', 'Wallis and Futuna', 'WLF', 876), +(236, 'EH', 'WESTERN SAHARA', 'Western Sahara', 'ESH', 732), +(237, 'YE', 'YEMEN', 'Yemen', 'YEM', 887), +(238, 'ZM', 'ZAMBIA', 'Zambia', 'ZMB', 894), +(239, 'ZW', 'ZIMBABWE', 'Zimbabwe', 'ZWE', 716); \ No newline at end of file diff --git a/upload/cb_install/sql/email_templates.sql b/upload/cb_install/sql/email_templates.sql new file mode 100644 index 00000000..ef116999 --- /dev/null +++ b/upload/cb_install/sql/email_templates.sql @@ -0,0 +1,19 @@ + +INSERT INTO `{tbl_prefix}email_templates` (`email_template_id`, `email_template_name`, `email_template_code`, `email_template_subject`, `email_template`, `email_template_allowed_tags`) VALUES +(1, 'Share Video Template', 'share_video_template', '[{website_title}] - {username} wants to share a video with you', '\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    {website_title}share video
    {username} wants to share Video With You\r\n
    Video Description
    \r\n {video_description}
    Personal Message
    \r\n {user_message}\r\n
    \r\n
    \r\nThanks,
    \r\n{username}
    copyrights {date_year} {website_title}
    \r\n\r\n', '{website_title},{'), +(2, 'Email Verification Template', 'email_verify_template', '[{website_title}] - Account activation email', 'Hello {username},\r\nThank you for joining {website_title}, one last step is required in order to activate your account\r\n\r\nClick Here\r\n{baseurl}/activation.php?av_username={username}&avcode={avcode}\r\n\r\nEmail : {email}\r\nUsername : {username}\r\nActivation code : {avcode}\r\n\r\nif above given is not working , please go here and activate it\r\n{baseurl}/activation.php\r\n\r\n====================\r\nRegards\r\n{website_title}', ''), +(3, 'Private Message Notification', 'pm_email_message', '[{website_title}] - {sender} has sent you a private message', '{sender} has sent you a private message, \r\n\r\n{subject}\r\n"{content}"\r\n\r\nclick here to view your inbox {baseurl}/private_message.php?mode=inbox&mid={msg_id}\r\n\r\n{website_title}', ''), +(4, 'Acitvation code request template', 'avcode_request_template', '[{website_title}] - Account activation code request', 'Hello {username},\r\n\r\nYour Activation Code is : {avcode}\r\nClick Here To goto Activation Page\r\n\r\nDirect Activation\r\n==========================================\r\nClick Here or Copy & Paste the following link in your browser\r\n{baseurl}/activation.php?av_username={username}&avcode={avcode}\r\n\r\nif above given links are not working, please go here and activate it\r\n\r\nEmail : {email}\r\nUsername : {username}\r\nActivation code : {avcode}\r\n\r\nif above given is not working , please go here and activate it\r\n{baseurl}/activation.php\r\n\r\n----------------\r\nRegards\r\n{website_title}', 'username,email,avcode,doj'), +(5, 'Welcome Message Template', 'welcome_message_template', 'Welcome {username} to {website_title}', 'Hello {username},\r\nThanks for joining at {website_title}!, you are now part of our community and we hope you will enjoy your stay\r\n\r\nAll the best,\r\n{website_title}', 'username,email'), +(6, 'Password Reset Request', 'password_reset_request', '[{website_title}] - Password reset confirmation', 'Dear {username}\r\nyou have requested a password reset, please follow the link in order to reset your password\r\n{baseurl}/forgot.php?mode=reset_pass&user={userid}&avcode={avcode}\r\n\r\n-----------------------------------------\r\nIF YOU HAVE NOT REQUESTED A PASSWORD RESET - PLEASE IGNORE THIS MESSAGE\r\n-----------------------------------------\r\nRegards\r\n{website_title}', 'username,userid,avcode'), +(7, 'Password Reset Details', 'password_reset_details', '[{website_title}] - Password reset details', 'Dear {username}\r\nyour password has been reset\r\nyour new password is : {password}\r\n\r\nclick here to login to website\r\n<{login_link}>\r\n\r\n---------------\r\nRegards\r\n{website_title}', 'username,password'), +(8, 'Forgot username request', 'forgot_username_request', '[{website_title}] - your {website_title} username', 'Hello,\r\nyour {website_title} username is : {username}\r\n\r\n--------------\r\nRegards\r\n{website_title}', '{username}'), +(9, 'Friend Request Email', 'friend_request_email', '[{website_title}] {username} add you as friend', 'Hi {reciever},\r\n{sender} added you as a friend on {website_title}. We need to confirm that you know {sender} in order for you to be friends on {website_title}.\r\n\r\nView profile of {sender} \r\nclick here to respond to friendship request\r\n\r\nThanks,\r\n{website_title} Team', 'reciever,sender,sender_link,request_link'), +(10, 'Friend Confirmation Email', 'friend_confirmation_email', '[{website_title}] - {sender} has confirmed you as a friend', 'Hi {reciever},\r\n{sender} confirmed you as a friend on {website_title}.\r\n\r\nView {sender} profile\r\n\r\nThanks,\r\nThe {website_title} Team', 'sender,reciever,sender_link'), +(11, 'Group Invitation', 'group_invitation', '[{website_title}] {sender} has invited you to join group "{group_name}"', '{sender} invited you to join the {website_title} group "{group_name}".\r\n\r\n{group_description}\r\n\r\nTo see more details and confirm this group invitation, follow the link below:\r\n{group_url}\r\n\r\nThanks,\r\n{website_title}', 'sender,reciever,group_name,group_url'), +(12, 'Contact Form', 'contact_form', '[{website_title} - Contact] {reason} from {name}', 'Name : {name}\r\nEmail : {email}\r\nReason : {reason}\r\n\r\nMessage:\r\n{message}\r\n\r\n===============\r\nIp : {ip_address}\r\ndate : {now}', ''), +(13, 'Video Acitvation Email', 'video_activation_email', '[{website_title}] - Your video has been activated', 'Hello {username},\r\nYour video has been reviewed and activated by one of our staff, thanks for uploading this video. You can view this video here.\r\n{video_link}\r\n\r\nThanks\r\n{website_title} Team', ''), +(14, 'User Comment Email', 'user_comment_email', '[{website_title}] {username} made comment on your {obj}', '{username} has commented on your {obj}\r\n"{comment}"\r\n\r\n{obj_link}\r\n\r\n{website_title} team', ''), +(15, 'Photo Share Template', 'photo_share_template', '{username} wants to share photo with you', '\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    {website_title}
    {username} wants to share this photo with you
    \r\n
    Photo Description
    \r\n {photo_description}
    Personal Message
    \r\n {user_message}\r\n
    \r\n
    \r\nThanks,
    \r\n{website_title}
    copyrights {date_year} {website_title}
    \r\n\r\n', ''), +(16, 'Video Subscription Email', 'video_subscription_email', '{uploader} has uploaded new video on {website_title}', 'Hello {username}\r\n\r\nYou have been notified by {website_title} that {uploader} has uploaded new video \r\n\r\nVideo Title : {video_title}\r\nVideo Description : {video_description}\r\n\r\n\r\n\r\n
    \r\nclick here to watch this video
    \r\n\r\n\r\nYou are notified because you are subscribed to {uploader}, you can manage your subscriptions by going to your account and click on manage subscriptions.\r\n{website_title}', ''), +(17, 'Collection Share Template', 'collection_share_template', '{username} wants to share collection with you', '\r\n\r\n\r\n\r\n\r\n\r\n \r\n \r\n \r\n\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
    {website_title}
    {username} wants to share this collection with you.
    \r\n
    Collection Description
    \r\n {description}
    Personal Message
    \r\n {user_message}\r\n
    \r\n
    \r\nThanks,
    \r\n{website_title}
    copyrights {date_year} {website_title}
    \r\n\r\n', ''); diff --git a/upload/cb_install/sql/import_categories.sql b/upload/cb_install/sql/import_categories.sql new file mode 100644 index 00000000..cb3c3844 --- /dev/null +++ b/upload/cb_install/sql/import_categories.sql @@ -0,0 +1,26 @@ + +INSERT INTO `{tbl_prefix}collection_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Uncategorized', 0, 'Uncategorized', '2010-12-29 19:21:47', 0, 'yes'); + +-- +-- Dumping data for table `group_categories` +-- + +INSERT INTO `{tbl_prefix}group_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Uncategorized', 1, 'Uncategorized', '2010-01-14 06:26:47', '', 'yes'); + +-- +-- Dumping data for table `user_categories` +-- + +INSERT INTO `{tbl_prefix}user_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Basic User', 1, '', '2009-12-03 12:18:15', '', 'yes'), +(2, 'Gurus', 1, '', '2009-12-03 12:18:21', '', 'no'), +(3, 'Comedian', 1, '', '2009-12-03 12:18:25', '', 'no'); + +-- +-- Dumping data for table `video_categories` +-- + +INSERT INTO `{tbl_prefix}video_categories` (`category_id`, `parent_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(12, 0, 'Uncategorized', 1, '', '2011-02-12 16:40:32', '', 'yes'); \ No newline at end of file diff --git a/upload/cb_install/sql/pages.sql b/upload/cb_install/sql/pages.sql new file mode 100644 index 00000000..42bb301c --- /dev/null +++ b/upload/cb_install/sql/pages.sql @@ -0,0 +1,19 @@ + + +INSERT INTO `{tbl_prefix}pages` (`page_id`, `page_name`, `page_title`, `page_content`, `userid`, `active`, `delete_able`, `date_added`) VALUES +(1, 'About us', 'About us', '
    About Us
    \r\n \r\n \r\n

    ClipBucket is one of the world''s best video sites . We specialize in short-form\r\noriginal content - from new, emerging talents and established Hollywood\r\nheavyweights alike. We''re committed to delivering an exceptional\r\nentertainment experience, and we do so by engaging and empowering our\r\naudience every step of the way.

    \r\n

    Everyone can Watch Videos\r\non ClipBucket. People can see first-hand accounts of current events, find\r\nvideos about their hobbies and interests, and discover the\r\nquirky and unusual. As more people capture special moments on\r\nvideo,ClipBucket is empowering them to become the broadcasters of\r\ntomorrow.

    \r\n

    ClipBucket not only a video sharing website but\r\nalso has social network features, you can make friends,\r\nand send them videos and private messages. ClipBucket also has built in\r\nrating system and comment system so that people can discuss on there\r\ninterested videos, not only comment but also, people can rate Comments.

    ', 1, 'yes', 'no', '2010-01-01 08:47:56'), +(2, 'Privacy Policy', 'Privacy Policy', '

    ClipBucket Privacy Notice - YT Version\r\n

    \r\n

    Personal Information

    \r\n
      \r\n
    • Browsing ClipBucket You can watch videos on ClipBucket without having a ClipBucket Account or a PHPBucket Account. You also can contact us through the ClipBucket Help Center or by emailing us directly without having to register for an account.
    • \r\n
    • Your ClipBucket Account. For some activities on ClipBucket, like uploading videos, posting comments, flagging videos, or watching restricted videos, you need a ClipBucket or PHPBucket Account. We ask for some personal information when you create an account, including your email address and a password, which is used to protect your account from unauthorized access. A PHPBucket Account, additionally, allows you to access other PHPBucket services that require registration.
    • \r\n
    • Usage Information. When you use ClipBucket, we may record information about your usage of the site, such as the channels, groups and favorites you subscribe to, which other users you communicate with, the videos you watch, the frequency and size of data transfers, and information you display about yourself as well as information you click on in ClipBucket (including UI elements, settings). If you are logged in, we may associate that information with your ClipBucket Account. In order to ensure the quality of our service to you, we may place a tag (also called a "web beacon") in HTML-based customer support emails or other communications with you in order to confirm delivery.
    • \r\n
    • Content Uploaded to Site. Any personal information or video content that you voluntarily disclose online (e.g., video comments, your profile page) may be collected and used by others. If you download the ClipBucket Uploader, your copy includes a unique application number. This number, and information about your installation of the Uploader (version number, language) will be sent to ClipBucket when the Uploader automatically checks for updates and will be used to update your version of the Uploader.
    • \r\n
    \r\n

    Uses

    \r\n
      \r\n
    • If you submit personal information to ClipBucket, we may use that information to operate, maintain, and improve the features and functionality of ClipBucket, and to process any flagging activity or other communication you send to us.
    • \r\n
    • We do not use your email address or other personal information to send commercial or marketing messages without your consent. We may use your email address without further consent for non-marketing or administrative purposes (such as notifying you of major ClipBucket changes or for customer service purposes). You also can choose how often ClipBucket sends you email updates in your ClipBucket Account settings page.
    • \r\n
    • We use cookies, web beacons, and log file information to: (a) store information so that you will not have to re-enter it during your visit or the next time you visit ClipBucket; (b) provide custom, personalized content and information; (c) monitor the effectiveness of our marketing campaigns; (d) monitor aggregate metrics such as total number of visitors and pages viewed; and (e) track your entries, submissions, and status in promotions, sweepstakes, and contests.
    • \r\n
    \r\n

    Information That is Publicly Available

    \r\n
      \r\n
    • When you create a ClipBucket Account, some information about your ClipBucket Account and your account activity will be provided to other users of ClipBucket. This may include the date you opened your ClipBucket Account, the date you last logged into your ClipBucket Account, your age (if you choose to make it public), the country and the number of videos you have watched.
    • \r\n
    • Your ClipBucket Account name, not your email address, is displayed to other users when you engage in certain activities on ClipBucket, such as when you upload videos or send messages through ClipBucket. Other users can contact you by leaving a message or comment on the site.
    • \r\n
    • Any videos that you submit to ClipBucket may be redistributed through the internet and other media channels, and may be viewed by other ClipBucket users or the general public.
    • \r\n
    • You may also choose to add personal information which may include your name, gender, profile picture or other details, that will be visible to other users on your ClipBucket Account channel page. If you choose to add certain features to your ClipBucket Account channel page, then these features and your activity associated with these features will be displayed to other users and may be aggregated and shared with your friends or other users. Such shared activity may include your favorite videos, videos you rated and videos that you have uploaded.
    • \r\n
    \r\n

    Your Choices

    \r\n
      \r\n
    • If you have a ClipBucket Account, you may update or correct your personal profile information, email preferences and privacy settings at any time by visiting your account profile page.
    • \r\n
    • You may control the information that is available to other users and your confirmed friends at any time by editing your ClipBucket Account and the features that are included on your channel page. If you have enabled Active Sharing, other users may see that you, as identified by your account name, not your email address, are watching the same video.
    • \r\n
    • You may, of course, decline to submit personal information through ClipBucket, in which case you can still view videos and explore ClipBucket, but ClipBucket may not be able to provide certain services to you. Some advanced ClipBucket features may use other PHPBucket services like PHPBucket Checkout or AdSense. The privacy notices of those services govern the use of your personal information associated with them.
    • \r\n
    \r\n', 1, 'no', 'no', '2010-01-01 08:52:46'), +(3, 'Terms of Serivce', 'Terms of Service', 'Write your own terms of service...', 1, 'yes', 'no', '2010-01-01 08:53:57'), +(4, 'Help', 'Help', 'How to use ClipBucket
    1. Articles will be written pretty soon
    ', 1, 'yes', 'no', '2010-01-01 09:17:36'), +(5, '403 Error', '403 Forbidden', '

    403 Access Denied

    \r\nSorry, you cannot access this page...', 1, 'yes', 'no', '0000-00-00 00:00:00'), +(6, '404 Error', '404 Not Found', '

    404 Not Found

    \r\nwe are unable to find requested URL on server..', 1, 'yes', 'no', '0000-00-00 00:00:00'); + +UPDATE `{tbl_prefix}pages` SET `display` = 'no' WHERE `page_id` =5 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `display` = 'no' WHERE`page_id` =6 LIMIT 1 ; + +UPDATE `{tbl_prefix}pages` SET `page_order` = '1' WHERE `page_id` =1 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '2' WHERE `page_id` =2 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '3' WHERE `page_id` =3 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '4' WHERE `page_id` =4 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '5' WHERE `page_id` =5 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '6' WHERE `page_id` =6 LIMIT 1 ; \ No newline at end of file diff --git a/upload/cb_install/sql/structure.sql b/upload/cb_install/sql/structure.sql new file mode 100644 index 00000000..9d959db8 --- /dev/null +++ b/upload/cb_install/sql/structure.sql @@ -0,0 +1,1116 @@ +-- -------------------------------------------------------- + +-- +-- Table structure for table `action_log` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}action_log` ( + `action_id` int(255) NOT NULL AUTO_INCREMENT, + `action_type` varchar(60) CHARACTER SET utf8 NOT NULL, + `action_username` varchar(60) CHARACTER SET utf8 NOT NULL, + `action_userid` int(30) NOT NULL, + `action_useremail` varchar(200) CHARACTER SET utf8 NOT NULL, + `action_userlevel` int(11) NOT NULL, + `action_ip` varchar(15) CHARACTER SET utf8 NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `action_success` enum('yes','no') CHARACTER SET utf8 NOT NULL, + `action_details` text CHARACTER SET utf8 NOT NULL, + `action_link` text NOT NULL, + `action_obj_id` int(255) NOT NULL, + `action_done_id` int(255) NOT NULL, + PRIMARY KEY (`action_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2687 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `admin_notes` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}admin_notes` ( + `note_id` int(225) NOT NULL AUTO_INCREMENT, + `note` text CHARACTER SET ucs2 NOT NULL, + `date_added` datetime NOT NULL, + `userid` int(225) NOT NULL, + PRIMARY KEY (`note_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=84 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `ads_data` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}ads_data` ( + `ad_id` int(50) NOT NULL AUTO_INCREMENT, + `ad_name` mediumtext NOT NULL, + `ad_code` mediumtext NOT NULL, + `ad_placement` varchar(50) NOT NULL DEFAULT '', + `ad_category` int(11) NOT NULL DEFAULT '0', + `ad_status` enum('0','1') NOT NULL DEFAULT '0', + `ad_impressions` bigint(255) NOT NULL DEFAULT '0', + `last_viewed` datetime NOT NULL, + `date_added` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + PRIMARY KEY (`ad_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `ads_placements` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}ads_placements` ( + `placement_id` int(20) NOT NULL AUTO_INCREMENT, + `placement` varchar(26) NOT NULL, + `placement_name` varchar(50) NOT NULL, + `disable` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`placement_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `collections` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collections` ( + `collection_id` bigint(25) NOT NULL AUTO_INCREMENT, + `collection_name` varchar(225) NOT NULL, + `collection_description` text NOT NULL, + `collection_tags` text NOT NULL, + `category` varchar(100) NOT NULL, + `userid` int(10) NOT NULL, + `views` bigint(20) NOT NULL, + `date_added` datetime NOT NULL, + `featured` varchar(4) NOT NULL DEFAULT 'no', + `broadcast` varchar(10) NOT NULL, + `allow_comments` varchar(4) NOT NULL, + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` bigint(20) NOT NULL, + `last_commented` datetime NOT NULL, + `total_objects` bigint(20) NOT NULL, + `rating` bigint(20) NOT NULL, + `rated_by` bigint(20) NOT NULL, + `voters` longtext NOT NULL, + `active` varchar(4) NOT NULL, + `public_upload` varchar(4) NOT NULL, + `type` varchar(10) NOT NULL, + PRIMARY KEY (`collection_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `collection_categories` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_categories` ( + `category_id` int(255) NOT NULL AUTO_INCREMENT, + `category_name` varchar(30) NOT NULL, + `category_order` int(5) NOT NULL, + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumint(9) NOT NULL, + `isdefault` enum('yes','no') NOT NULL, + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `collection_items` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_items` ( + `ci_id` bigint(20) NOT NULL AUTO_INCREMENT, + `collection_id` bigint(20) NOT NULL, + `object_id` bigint(20) NOT NULL, + `userid` bigint(20) NOT NULL, + `type` varchar(10) NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`ci_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=30 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `comments` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}comments` ( + `comment_id` int(60) NOT NULL AUTO_INCREMENT, + `type` varchar(3) NOT NULL, + `comment` text NOT NULL, + `userid` int(60) NOT NULL, + `anonym_name` varchar(255) NOT NULL, + `anonym_email` varchar(255) NOT NULL, + `parent_id` int(60) NOT NULL, + `type_id` int(225) NOT NULL, + `type_owner_id` int(255) NOT NULL, + `vote` varchar(225) NOT NULL, + `voters` text NOT NULL, + `spam_votes` bigint(20) NOT NULL, + `spam_voters` text NOT NULL, + `date_added` datetime NOT NULL, + `comment_ip` text NOT NULL, + PRIMARY KEY (`comment_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=535 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `config` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}config` ( + `configid` int(20) NOT NULL AUTO_INCREMENT, + `name` varchar(100) NOT NULL DEFAULT '', + `value` mediumtext NOT NULL, + PRIMARY KEY (`configid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=225 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `contacts` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}contacts` ( + `contact_id` int(225) NOT NULL AUTO_INCREMENT, + `userid` int(225) NOT NULL, + `contact_userid` int(225) NOT NULL, + `confirmed` enum('yes','no') NOT NULL DEFAULT 'no', + `contact_group_id` int(225) NOT NULL, + `request_type` enum('in','out') NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`contact_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `conversion_queue` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}conversion_queue` ( + `cqueue_id` int(11) NOT NULL AUTO_INCREMENT, + `cqueue_name` varchar(32) CHARACTER SET utf8 NOT NULL, + `cqueue_ext` varchar(5) CHARACTER SET utf8 NOT NULL, + `cqueue_tmp_ext` varchar(3) CHARACTER SET utf8 NOT NULL, + `cqueue_conversion` enum('yes','no','p') CHARACTER SET utf8 NOT NULL DEFAULT 'no', + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `time_started` varchar(32) NOT NULL, + `time_completed` varchar(32) NOT NULL, + PRIMARY KEY (`cqueue_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=262 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `countries` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}countries` ( + `country_id` int(80) NOT NULL AUTO_INCREMENT, + `iso2` char(2) CHARACTER SET utf8 NOT NULL, + `name` varchar(80) CHARACTER SET utf8 NOT NULL, + `name_en` varchar(80) CHARACTER SET utf8 NOT NULL, + `iso3` char(3) CHARACTER SET utf8 DEFAULT NULL, + `numcode` smallint(6) DEFAULT NULL, + PRIMARY KEY (`country_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=240 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `editors_picks` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}editors_picks` ( + `pick_id` int(225) NOT NULL AUTO_INCREMENT, + `videoid` int(225) NOT NULL, + `sort` bigint(5) NOT NULL DEFAULT '1', + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`pick_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `email_templates` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}email_templates` ( + `email_template_id` int(11) NOT NULL AUTO_INCREMENT, + `email_template_name` varchar(225) CHARACTER SET utf8 NOT NULL, + `email_template_code` varchar(225) CHARACTER SET utf8 NOT NULL, + `email_template_subject` mediumtext CHARACTER SET utf8 NOT NULL, + `email_template` text CHARACTER SET utf8 NOT NULL, + `email_template_allowed_tags` mediumtext CHARACTER SET utf8 NOT NULL, + PRIMARY KEY (`email_template_id`), + UNIQUE KEY `email_template_code` (`email_template_code`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `favorites` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}favorites` ( + `favorite_id` int(225) NOT NULL AUTO_INCREMENT, + `type` varchar(4) CHARACTER SET utf8 NOT NULL, + `id` int(225) NOT NULL, + `userid` int(225) NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`favorite_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=36 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `flags` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}flags` ( + `flag_id` int(225) NOT NULL AUTO_INCREMENT, + `type` varchar(4) CHARACTER SET utf8 NOT NULL, + `id` int(225) NOT NULL, + `userid` int(225) NOT NULL, + `flag_type` bigint(25) NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`flag_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `groups` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}groups` ( + `group_id` int(225) NOT NULL AUTO_INCREMENT, + `group_name` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `userid` int(255) NOT NULL, + `group_description` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `group_tags` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `group_url` mediumtext CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `category` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `group_privacy` enum('0','1','2') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `video_type` enum('0','1','2') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `post_type` enum('0','1','2') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `active` enum('yes','no') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'yes', + `date_added` datetime NOT NULL, + `featured` enum('yes','no') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT 'no', + `total_views` bigint(225) NOT NULL, + `total_videos` int(225) NOT NULL, + `total_members` int(225) NOT NULL, + `total_topics` int(225) NOT NULL, + PRIMARY KEY (`group_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_categories` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_categories` ( + `category_id` int(225) NOT NULL AUTO_INCREMENT, + `category_name` varchar(30) NOT NULL DEFAULT '', + `category_order` int(5) NOT NULL DEFAULT '1', + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumtext NOT NULL, + `isdefault` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_invitations` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_invitations` ( + `invitation_id` int(225) NOT NULL AUTO_INCREMENT, + `group_id` int(225) NOT NULL, + `userid` int(255) NOT NULL, + `invited` int(225) NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`invitation_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_members` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_members` ( + `group_mid` int(225) NOT NULL AUTO_INCREMENT, + `group_id` int(225) NOT NULL, + `userid` int(11) NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `active` enum('yes','no') NOT NULL DEFAULT 'yes', + PRIMARY KEY (`group_mid`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_posts` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_posts` ( + `post_id` int(11) NOT NULL AUTO_INCREMENT, + `userid` int(11) NOT NULL, + `topic_id` int(11) NOT NULL, + `post_content` text NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`post_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_topics` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_topics` ( + `topic_id` int(225) NOT NULL AUTO_INCREMENT, + `topic_title` text NOT NULL, + `userid` int(225) NOT NULL, + `group_id` int(225) NOT NULL, + `topic_post` text NOT NULL, + `date_added` datetime NOT NULL, + `last_poster` int(225) NOT NULL, + `last_post_time` datetime NOT NULL, + `total_views` bigint(225) NOT NULL, + `total_replies` bigint(225) NOT NULL, + `topic_icon` varchar(225) NOT NULL, + `approved` enum('yes','no') NOT NULL DEFAULT 'yes', + PRIMARY KEY (`topic_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=14 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `group_videos` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}group_videos` ( + `group_video_id` int(225) NOT NULL AUTO_INCREMENT, + `videoid` int(255) NOT NULL, + `group_id` int(225) NOT NULL, + `userid` int(255) NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `approved` enum('yes','no') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`group_video_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `languages` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}languages` ( + `language_id` int(9) NOT NULL AUTO_INCREMENT, + `language_code` varchar(8) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '', + `language_name` varchar(20) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '0', + `language_regex` varchar(64) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + `language_active` enum('yes','no') NOT NULL DEFAULT 'yes', + `language_default` enum('yes','no') CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL, + PRIMARY KEY (`language_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=7 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `messages` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}messages` ( + `message_id` int(225) NOT NULL AUTO_INCREMENT, + `message_from` int(20) NOT NULL, + `message_to` varchar(200) NOT NULL, + `message_content` mediumtext NOT NULL, + `message_type` enum('pm','notification') NOT NULL DEFAULT 'pm', + `message_attachments` mediumtext NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `message_subject` mediumtext NOT NULL, + `message_status` enum('unread','read') NOT NULL DEFAULT 'unread', + `reply_to` int(225) NOT NULL DEFAULT '0', + `message_box` enum('in','out') NOT NULL DEFAULT 'in', + PRIMARY KEY (`message_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=53 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `modules` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}modules` ( + `module_id` int(25) NOT NULL AUTO_INCREMENT, + `module_name` varchar(25) NOT NULL, + `module_file` varchar(60) NOT NULL, + `active` varchar(5) NOT NULL, + `module_include_file` text NOT NULL, + PRIMARY KEY (`module_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `pages` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}pages` ( + `page_id` int(11) NOT NULL AUTO_INCREMENT, + `page_name` varchar(225) NOT NULL, + `page_title` varchar(225) NOT NULL, + `page_content` text NOT NULL, + `userid` int(225) NOT NULL, + `active` enum('yes','no') NOT NULL, + `delete_able` enum('yes','no') NOT NULL DEFAULT 'yes', + `date_added` datetime NOT NULL, + PRIMARY KEY (`page_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=19 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `photos` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}photos` ( + `photo_id` bigint(255) NOT NULL AUTO_INCREMENT, + `photo_key` mediumtext NOT NULL, + `photo_title` mediumtext NOT NULL, + `photo_description` mediumtext NOT NULL, + `photo_tags` mediumtext NOT NULL, + `userid` int(255) NOT NULL, + `collection_id` int(255) NOT NULL, + `date_added` datetime NOT NULL, + `last_viewed` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `views` bigint(255) NOT NULL, + `allow_comments` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_embedding` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_tagging` enum('yes','no') NOT NULL DEFAULT 'yes', + `featured` enum('yes','no') NOT NULL DEFAULT 'no', + `reported` enum('yes','no') NOT NULL DEFAULT 'no', + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `broadcast` enum('public','private') NOT NULL DEFAULT 'public', + `active` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` int(255) NOT NULL, + `last_commented` datetime NOT NULL, + `total_favorites` int(255) NOT NULL, + `rating` int(15) NOT NULL, + `rated_by` int(25) NOT NULL, + `voters` mediumtext NOT NULL, + `filename` varchar(100) NOT NULL, + `ext` char(5) NOT NULL, + `downloaded` bigint(255) NOT NULL, + `server_url` text NOT NULL, + `owner_ip` varchar(20) NOT NULL, + PRIMARY KEY (`photo_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=20 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `phrases` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}phrases` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `lang_iso` varchar(5) NOT NULL DEFAULT 'en', + `varname` varchar(250) NOT NULL DEFAULT '', + `text` text CHARACTER SET utf8 COLLATE utf8_unicode_ci, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=9392 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `playlists` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}playlists` ( + `playlist_id` int(11) NOT NULL AUTO_INCREMENT, + `playlist_name` varchar(225) CHARACTER SET utf8 NOT NULL, + `userid` int(11) NOT NULL, + `playlist_type` varchar(10) CHARACTER SET utf8 NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`playlist_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=9 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `playlist_items` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}playlist_items` ( + `playlist_item_id` int(225) NOT NULL AUTO_INCREMENT, + `object_id` int(225) NOT NULL, + `playlist_id` int(225) NOT NULL, + `playlist_item_type` varchar(10) CHARACTER SET utf8 NOT NULL, + `userid` int(255) NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + PRIMARY KEY (`playlist_item_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=21 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `plugins` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}plugins` ( + `plugin_id` int(255) NOT NULL AUTO_INCREMENT, + `plugin_file` text NOT NULL, + `plugin_folder` text NOT NULL, + `plugin_version` float NOT NULL, + `plugin_license_type` varchar(10) NOT NULL DEFAULT 'GPL', + `plugin_license_key` varchar(5) NOT NULL, + `plugin_license_code` text NOT NULL, + `plugin_active` enum('yes','no') NOT NULL, + PRIMARY KEY (`plugin_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=78 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `plugin_config` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}plugin_config` ( + `plugin_config_id` int(223) NOT NULL AUTO_INCREMENT, + `plugin_id_code` varchar(25) CHARACTER SET utf8 NOT NULL, + `plugin_config_name` text CHARACTER SET utf8 NOT NULL, + `plugin_config_value` text CHARACTER SET utf8 NOT NULL, + `player_type` enum('built-in','plugin') CHARACTER SET utf8 NOT NULL DEFAULT 'built-in', + `player_admin_file` text CHARACTER SET utf8 NOT NULL, + `player_include_file` text CHARACTER SET utf8 NOT NULL, + PRIMARY KEY (`plugin_config_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `sessions` +-- +CREATE TABLE `{tbl_prefix}sessions` ( + `session_id` int(11) NOT NULL AUTO_INCREMENT, + `session` varchar(100) NOT NULL, + `session_user` int(11) NOT NULL, + `session_string` varchar(60) NOT NULL, + `session_value` varchar(32) NOT NULL, + `ip` varchar(20) NOT NULL, + `session_date` datetime NOT NULL, + `current_page` text NOT NULL, + `referer` text NOT NULL, + `agent` text NOT NULL, + `last_active` datetime NOT NULL, + PRIMARY KEY (`session_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `stats` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}stats` ( + `stat_id` int(255) NOT NULL AUTO_INCREMENT, + `date_added` date NOT NULL, + `video_stats` text NOT NULL, + `user_stats` text NOT NULL, + `group_stats` text NOT NULL, + PRIMARY KEY (`stat_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `subscriptions` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}subscriptions` ( + `subscription_id` int(225) NOT NULL AUTO_INCREMENT, + `userid` int(11) NOT NULL, + `subscribed_to` mediumtext NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`subscription_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=29 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `template` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}template` ( + `template_id` int(20) NOT NULL AUTO_INCREMENT, + `template_name` varchar(25) NOT NULL, + `template_dir` varchar(30) NOT NULL, + PRIMARY KEY (`template_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `users` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}users` ( + `userid` bigint(20) NOT NULL AUTO_INCREMENT, + `category` int(20) NOT NULL, + `featured_video` mediumtext NOT NULL, + `username` text NOT NULL, + `user_session_key` varchar(32) NOT NULL, + `user_session_code` int(5) NOT NULL, + `password` varchar(40) NOT NULL DEFAULT '', + `email` varchar(80) NOT NULL DEFAULT '', + `usr_status` enum('Ok','ToActivate') NOT NULL DEFAULT 'ToActivate', + `msg_notify` enum('yes','no') NOT NULL DEFAULT 'yes', + `avatar` varchar(225) NOT NULL DEFAULT '', + `avatar_url` text NOT NULL, + `sex` enum('male','female') NOT NULL DEFAULT 'male', + `dob` date NOT NULL DEFAULT '0000-00-00', + `country` varchar(20) NOT NULL DEFAULT 'PK', + `level` int(6) NOT NULL DEFAULT '2', + `avcode` mediumtext NOT NULL, + `doj` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + `last_logged` datetime NOT NULL DEFAULT '0000-00-00 00:00:00', + `num_visits` bigint(20) NOT NULL DEFAULT '0', + `session` varchar(32) NOT NULL DEFAULT '', + `ip` varchar(15) NOT NULL DEFAULT '', + `signup_ip` varchar(15) NOT NULL DEFAULT '', + `time_zone` tinyint(4) NOT NULL DEFAULT '0', + `featured` enum('No','Yes') NOT NULL DEFAULT 'No', + `featured_date` datetime NOT NULL, + `profile_hits` bigint(20) DEFAULT '0', + `total_watched` bigint(20) NOT NULL DEFAULT '0', + `total_videos` bigint(20) NOT NULL, + `total_comments` bigint(20) NOT NULL, + `total_photos` bigint(255) NOT NULL, + `total_collections` bigint(255) NOT NULL, + `comments_count` bigint(20) NOT NULL, + `last_commented` datetime NOT NULL, + `ban_status` enum('yes','no') NOT NULL DEFAULT 'no', + `upload` varchar(20) NOT NULL DEFAULT '1', + `subscribers` bigint(225) NOT NULL DEFAULT '0', + `total_subscriptions` bigint(255) NOT NULL, + `background` mediumtext NOT NULL, + `background_color` varchar(25) NOT NULL, + `background_url` text NOT NULL, + `background_repeat` enum('no-repeat','repeat','repeat-x','repeat-y') NOT NULL DEFAULT 'repeat', + `background_attachement` enum('yes','no') NOT NULL DEFAULT 'no', + `total_groups` bigint(20) NOT NULL, + `last_active` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `banned_users` text NOT NULL, + `welcome_email_sent` enum('yes','no') NOT NULL DEFAULT 'no', + `total_downloads` bigint(255) NOT NULL, + PRIMARY KEY (`userid`), + KEY `ind_status_doj` (`doj`), + KEY `ind_status_id` (`userid`), + KEY `ind_hits_doj` (`profile_hits`,`doj`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2; +ALTER TABLE `{tbl_prefix}users` ADD `album_privacy` ENUM( 'public', 'private', 'friends' ) NOT NULL DEFAULT 'private' ; +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_categories` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_categories` ( + `category_id` int(225) NOT NULL AUTO_INCREMENT, + `category_name` varchar(30) NOT NULL DEFAULT '', + `category_order` int(5) NOT NULL DEFAULT '1', + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumtext NOT NULL, + `isdefault` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_levels` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_levels` ( + `user_level_id` int(20) NOT NULL AUTO_INCREMENT, + `user_level_active` enum('yes','no') CHARACTER SET utf8 NOT NULL DEFAULT 'yes', + `user_level_name` varchar(100) CHARACTER SET utf8 NOT NULL, + `user_level_is_default` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`user_level_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=17 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_levels_permissions` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_levels_permissions` ( + `user_level_permission_id` int(22) NOT NULL AUTO_INCREMENT, + `user_level_id` int(22) NOT NULL, + `admin_access` enum('yes','no') NOT NULL DEFAULT 'no', + `allow_video_upload` enum('yes','no') NOT NULL DEFAULT 'yes', + `view_video` enum('yes','no') NOT NULL DEFAULT 'yes', + `view_channel` enum('yes','no') NOT NULL DEFAULT 'yes', + `view_group` enum('yes','no') NOT NULL DEFAULT 'yes', + `view_videos` enum('yes','no') NOT NULL DEFAULT 'yes', + `avatar_upload` enum('yes','no') NOT NULL DEFAULT 'yes', + `video_moderation` enum('yes','no') NOT NULL DEFAULT 'no', + `member_moderation` enum('yes','no') NOT NULL DEFAULT 'no', + `ad_manager_access` enum('yes','no') NOT NULL DEFAULT 'no', + `manage_template_access` enum('yes','no') NOT NULL DEFAULT 'no', + `group_moderation` enum('yes','no') NOT NULL DEFAULT 'no', + `web_config_access` enum('yes','no') NOT NULL DEFAULT 'no', + `view_channels` enum('yes','no') NOT NULL DEFAULT 'yes', + `view_groups` enum('yes','no') NOT NULL DEFAULT 'yes', + `playlist_access` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_channel_bg` enum('yes','no') NOT NULL DEFAULT 'yes', + `private_msg_access` enum('yes','no') NOT NULL DEFAULT 'yes', + `edit_video` enum('yes','no') NOT NULL DEFAULT 'yes', + `download_video` enum('yes','no') NOT NULL DEFAULT 'yes', + `admin_del_access` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`user_level_permission_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=15 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_permissions` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_permissions` ( + `permission_id` int(225) NOT NULL AUTO_INCREMENT, + `permission_type` int(225) NOT NULL, + `permission_name` varchar(225) CHARACTER SET utf8 NOT NULL, + `permission_code` varchar(225) CHARACTER SET utf8 NOT NULL, + `permission_desc` mediumtext CHARACTER SET utf8 NOT NULL, + `permission_default` enum('yes','no') CHARACTER SET utf8 NOT NULL DEFAULT 'yes', + PRIMARY KEY (`permission_id`), + UNIQUE KEY `permission_code` (`permission_code`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=34 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_permission_types` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_permission_types` ( + `user_permission_type_id` int(225) NOT NULL AUTO_INCREMENT, + `user_permission_type_name` varchar(225) CHARACTER SET utf8 NOT NULL, + `user_permission_type_desc` mediumtext CHARACTER SET utf8 NOT NULL, + PRIMARY KEY (`user_permission_type_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `user_profile` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}user_profile` ( + `user_profile_id` int(11) NOT NULL AUTO_INCREMENT, + `show_my_collections` enum('yes','no') NOT NULL DEFAULT 'yes', + `userid` bigint(20) NOT NULL, + `profile_title` mediumtext NOT NULL, + `profile_desc` mediumtext NOT NULL, + `featured_video` mediumtext NOT NULL, + `first_name` varchar(100) NOT NULL DEFAULT '', + `last_name` varchar(100) NOT NULL DEFAULT '', + `avatar` varchar(225) NOT NULL DEFAULT 'no_avatar.jpg', + `show_dob` enum('no','yes') DEFAULT 'no', + `postal_code` varchar(20) NOT NULL DEFAULT '', + `time_zone` tinyint(4) NOT NULL DEFAULT '0', + `profile_tags` mediumtext, + `web_url` varchar(200) NOT NULL DEFAULT '', + `hometown` varchar(100) NOT NULL DEFAULT '', + `city` varchar(100) NOT NULL DEFAULT '', + `online_status` enum('online','offline','custom') NOT NULL DEFAULT 'online', + `show_profile` enum('all','members','friends') NOT NULL DEFAULT 'all', + `allow_comments` enum('Yes','No') NOT NULL DEFAULT 'Yes', + `allow_ratings` enum('Yes','No') NOT NULL DEFAULT 'Yes', + `allow_subscription` enum('yes','no') NOT NULL DEFAULT 'yes', + `content_filter` enum('Nothing','On','Off') NOT NULL DEFAULT 'Nothing', + `icon_id` bigint(20) NOT NULL DEFAULT '0', + `browse_criteria` mediumtext, + `about_me` mediumtext NOT NULL, + `education` varchar(3) DEFAULT NULL, + `schools` mediumtext NOT NULL, + `occupation` mediumtext NOT NULL, + `companies` mediumtext NOT NULL, + `relation_status` varchar(15) DEFAULT NULL, + `hobbies` mediumtext NOT NULL, + `fav_movies` mediumtext NOT NULL, + `fav_music` mediumtext NOT NULL, + `fav_books` mediumtext NOT NULL, + `background` mediumtext NOT NULL, + `profile_video` int(255) NOT NULL, + `profile_item` varchar(25) NOT NULL, + `rating` tinyint(2) NOT NULL, + `voters` text NOT NULL, + `rated_by` int(150) NOT NULL, + `show_my_videos` enum('yes','no') NOT NULL DEFAULT 'yes', + `show_my_photos` enum('yes','no') NOT NULL DEFAULT 'yes', + `show_my_subscriptions` enum('yes','no') NOT NULL DEFAULT 'yes', + `show_my_subscribers` enum('yes','no') NOT NULL DEFAULT 'yes', + `show_my_friends` enum('yes','no') NOT NULL DEFAULT 'yes', + PRIMARY KEY (`user_profile_id`), + KEY `ind_status_id` (`userid`), + FULLTEXT KEY `profile_tags` (`profile_tags`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `validation_re` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}validation_re` ( + `re_id` int(25) NOT NULL AUTO_INCREMENT, + `re_name` varchar(60) NOT NULL, + `re_code` varchar(60) NOT NULL, + `re_syntax` text NOT NULL, + PRIMARY KEY (`re_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `video` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}video` ( + `videoid` bigint(20) NOT NULL AUTO_INCREMENT, + `videokey` mediumtext NOT NULL, + `username` text NOT NULL, + `userid` int(11) NOT NULL, + `title` text, + `flv` mediumtext NOT NULL, + `file_name` varchar(32) NOT NULL, + `description` text, + `tags` mediumtext NOT NULL, + `category` varchar(100) NOT NULL DEFAULT '0', + `broadcast` varchar(10) NOT NULL DEFAULT '', + `location` mediumtext, + `datecreated` date DEFAULT NULL, + `country` mediumtext, + `allow_embedding` char(3) NOT NULL DEFAULT '', + `rating` int(15) NOT NULL DEFAULT '0', + `rated_by` varchar(20) NOT NULL DEFAULT '0', + `voter_ids` mediumtext NOT NULL, + `allow_comments` char(3) NOT NULL DEFAULT '', + `comment_voting` char(3) NOT NULL DEFAULT '', + `comments_count` int(15) NOT NULL DEFAULT '0', + `last_commented` datetime NOT NULL, + `featured` char(3) NOT NULL DEFAULT 'no', + `featured_date` datetime NOT NULL, + `featured_description` mediumtext NOT NULL, + `allow_rating` char(3) NOT NULL DEFAULT '', + `active` char(3) NOT NULL DEFAULT '0', + `favourite_count` varchar(15) NOT NULL DEFAULT '0', + `playlist_count` varchar(15) NOT NULL DEFAULT '0', + `views` bigint(22) NOT NULL DEFAULT '0', + `last_viewed` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, + `date_added` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00', + `flagged` varchar(3) NOT NULL DEFAULT 'no', + `duration` varchar(20) NOT NULL DEFAULT '00', + `status` enum('Successful','Processing','Failed') NOT NULL DEFAULT 'Processing', + `failed_reason` enum('none','max_duration','max_file','invalid_format','invalid_upload') NOT NULL DEFAULT 'none', + `flv_file_url` text, + `default_thumb` int(3) NOT NULL DEFAULT '1', + `aspect_ratio` varchar(10) NOT NULL, + `embed_code` text NOT NULL, + `refer_url` text NOT NULL, + `downloads` bigint(255) NOT NULL, + `uploader_ip` varchar(20) NOT NULL, + `mass_embed_status` enum('no','pending','approved') NOT NULL DEFAULT 'no', + `is_hd` enum('yes','no') NOT NULL DEFAULT 'no', + `ebay_epn_keywords` varchar(255) NOT NULL, + `ebay_pre_desc` text NOT NULL, + `unique_embed_code` varchar(50) NOT NULL, + `mature_content` enum('yes','no') NOT NULL DEFAULT 'no', + `remote_play_url` text NOT NULL, + `server_ip` varchar(20) NOT NULL, + `file_server_path` text NOT NULL, + `files_thumbs_path` text NOT NULL, + `file_thumbs_count` varchar(30) NOT NULL, + `has_hq` enum('yes','no') NOT NULL DEFAULT 'no', + `has_mobile` enum('yes','no') NOT NULL DEFAULT 'no', + `filegrp_size` varchar(30) NOT NULL, + `process_status` bigint(30) NOT NULL DEFAULT '0', + `has_hd` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`videoid`), + FULLTEXT KEY `description` (`description`,`title`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=960 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `video_categories` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}video_categories` ( + `category_id` int(225) NOT NULL AUTO_INCREMENT, + `parent_id` int(255) NOT NULL DEFAULT '0', + `category_name` varchar(30) NOT NULL DEFAULT '', + `category_order` int(5) NOT NULL DEFAULT '1', + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumtext NOT NULL, + `isdefault` enum('yes','no') NOT NULL DEFAULT 'no', + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `video_favourites` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}video_favourites` ( + `fav_id` int(11) NOT NULL AUTO_INCREMENT, + `videoid` int(11) NOT NULL, + `userid` int(11) NOT NULL, + `date_added` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP, + PRIMARY KEY (`fav_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +-- -------------------------------------------------------- + +-- +-- Table structure for table `video_files` +-- + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}video_files` ( + `id` int(10) unsigned NOT NULL AUTO_INCREMENT, + `status` int(2) NOT NULL, + `file_conversion_log` text CHARACTER SET utf8 NOT NULL, + `encoder` char(16) CHARACTER SET utf8 NOT NULL, + `command_used` text CHARACTER SET utf8 NOT NULL, + `src_path` text CHARACTER SET utf8 NOT NULL, + `src_name` char(64) CHARACTER SET utf8 NOT NULL, + `src_ext` char(8) CHARACTER SET utf8 NOT NULL, + `src_format` char(32) CHARACTER SET utf8 NOT NULL, + `src_duration` char(10) CHARACTER SET utf8 NOT NULL, + `src_size` char(10) CHARACTER SET utf8 NOT NULL, + `src_bitrate` char(6) CHARACTER SET utf8 NOT NULL, + `src_video_width` char(5) CHARACTER SET utf8 NOT NULL, + `src_video_height` char(5) CHARACTER SET utf8 NOT NULL, + `src_video_wh_ratio` char(10) CHARACTER SET utf8 NOT NULL, + `src_video_codec` char(16) CHARACTER SET utf8 NOT NULL, + `src_video_rate` char(10) CHARACTER SET utf8 NOT NULL, + `src_video_bitrate` char(10) CHARACTER SET utf8 NOT NULL, + `src_video_color` char(16) CHARACTER SET utf8 NOT NULL, + `src_audio_codec` char(16) CHARACTER SET utf8 NOT NULL, + `src_audio_bitrate` char(10) CHARACTER SET utf8 NOT NULL, + `src_audio_rate` char(10) CHARACTER SET utf8 NOT NULL, + `src_audio_channels` char(16) CHARACTER SET utf8 NOT NULL, + `output_path` text CHARACTER SET utf8 NOT NULL, + `output_format` char(32) CHARACTER SET utf8 NOT NULL, + `output_duration` char(10) CHARACTER SET utf8 NOT NULL, + `output_size` char(10) CHARACTER SET utf8 NOT NULL, + `output_bitrate` char(6) CHARACTER SET utf8 NOT NULL, + `output_video_width` char(5) CHARACTER SET utf8 NOT NULL, + `output_video_height` char(5) CHARACTER SET utf8 NOT NULL, + `output_video_wh_ratio` char(10) CHARACTER SET utf8 NOT NULL, + `output_video_codec` char(16) CHARACTER SET utf8 NOT NULL, + `output_video_rate` char(10) CHARACTER SET utf8 NOT NULL, + `output_video_bitrate` char(10) CHARACTER SET utf8 NOT NULL, + `output_video_color` char(16) CHARACTER SET utf8 NOT NULL, + `output_audio_codec` char(16) CHARACTER SET utf8 NOT NULL, + `output_audio_bitrate` char(10) CHARACTER SET utf8 NOT NULL, + `output_audio_rate` char(10) CHARACTER SET utf8 NOT NULL, + `output_audio_channels` char(16) CHARACTER SET utf8 NOT NULL, + `hd` enum('yes','no') CHARACTER SET utf8 NOT NULL DEFAULT 'no', + `hq` enum('yes','no') CHARACTER SET utf8 NOT NULL DEFAULT 'no', + PRIMARY KEY (`id`), + FULLTEXT KEY `src_bitrate` (`src_bitrate`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + + +-- Alterations + +ALTER TABLE `{tbl_prefix}video` ADD `video_password` VARCHAR( 255 ) NOT NULL AFTER `videokey` ; +ALTER TABLE `{tbl_prefix}video` ADD `video_users` TEXT NOT NULL AFTER `video_password`; +ALTER TABLE `{tbl_prefix}video` ADD `category_parents` TEXT NOT NULL AFTER `category` ; + +ALTER TABLE `{tbl_prefix}_video` ADD `subscription_email` ENUM( "pending", "sent" ) NOT NULL DEFAULT 'pending' AFTER `last_commented` ; +ALTER TABLE `{tbl_prefix}_groups` ADD `group_admins` TEXT NOT NULL AFTER `userid` ; + +-- Alterations for 2.4.5 + +ALTER TABLE `{tbl_prefix}pages` ADD `page_order` BIGINT( 100 ) NOT NULL AFTER `page_id` , +ADD `display` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes' AFTER `page_order` ; +ALTER TABLE `{tbl_prefix}users` ADD `voted` TEXT NOT NULL AFTER `last_commented`; + +-- Alterations for 2.5.5 +ALTER TABLE `{tbl_prefix}groups` ADD `group_admins` TEXT NOT NULL AFTER `userid`; + +-- Alterations for 2.6 +ALTER TABLE `{tbl_prefix}video` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0'; +ALTER TABLE `{tbl_prefix}collections` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}counters` ( + `counter_id` int(100) NOT NULL AUTO_INCREMENT, + `section` varchar(200) NOT NULL, + `query` text NOT NULL, + `query_md5` varchar(200) NOT NULL, + `counts` bigint(200) NOT NULL, + `date_added` varchar(200) NOT NULL, + PRIMARY KEY (`counter_id`), + UNIQUE KEY `query_md5` (`query_md5`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + + +ALTER TABLE `{tbl_prefix}user_levels_permissions` ADD `photos_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no', +ADD `collection_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `photos_moderation` , +ADD `plugins_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `collection_moderation` , +ADD `tool_box` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_moderation` , +ADD `plugins_perms` TEXT NOT NULL AFTER `tool_box` ; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}mass_emails` ( + `id` int(255) NOT NULL AUTO_INCREMENT, + `email_subj` varchar(255) NOT NULL, + `email_from` varchar(255) NOT NULL, + `email_msg` text NOT NULL, + `configs` text NOT NULL, + `sent` bigint(255) NOT NULL, + `total` bigint(20) NOT NULL, + `users` text NOT NULL, + `start_index` bigint(255) NOT NULL, + `method` enum('browser','background') NOT NULL, + `status` enum('completed','pending','sending') NOT NULL, + `date_added` datetime NOT NULL, + `last_update` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +-- naveed +-- added photo_details +ALTER TABLE `photos` ADD `{tbl_prefix}photo_details` TEXT NOT NULL AFTER `photo_id`; + +-- 2.7 +-- Added Collection contributors + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_contributors` ( + `contributor_id` int(200) NOT NULL AUTO_INCREMENT, + `collection_id` int(255) NOT NULL, + `userid` int(255) NOT NULL, + `can_edit` enum('yes','no') NOT NULL DEFAULT 'no', + `date_added` datetime NOT NULL, + PRIMARY KEY (`contributor_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.0.5.sql b/upload/cb_install/sql/upgrade_2.0.5.sql new file mode 100644 index 00000000..485b46a5 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.0.5.sql @@ -0,0 +1,30 @@ +INSERT INTO `{tbl_prefix}config` ( +`name` , +`value` +) +VALUES +('default_country_iso2', 'PK'), +('channel_comments', '1'), +('max_profile_pic_size', '25'), +('max_profile_pic_height', ''), +('max_profile_pic_width', '140'), +('gravatars', 'yes'), +('picture_url', 'yes'), +('picture_upload', 'yes'), +('background_url', 'yes'), +('background_upload', 'yes'), +('max_bg_size', '25'), +('max_bg_width', ''), +('max_bg_height', '600'), +('background_color', 'yes'), +('send_comment_notification', 'no'), +('approve_video_notification', 'yes'), +('keep_mp4_as_is', 'yes'), +('hq_output', 'yes'), +('grp_categories', '3'), +('grps_items_search_page', '24'), +('grp_thumb_height', '140'), +('grp_thumb_width', '140'), +('grp_max_title', '20'), +('grp_max_desc', '500'); +ALTER TABLE `{tbl_prefix}languages` ADD `language_active` ENUM( "yes", "no" ) NOT NULL DEFAULT 'yes' AFTER `language_regex` ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.0.6.sql b/upload/cb_install/sql/upgrade_2.0.6.sql new file mode 100644 index 00000000..94710f9f --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.0.6.sql @@ -0,0 +1,9 @@ +INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`) VALUES +(NULL , 'quick_conv', 'yes'), +(NULL, 'server_friendly_conversion', 'yes'), +(NULL, 'max_conversion', '2'), +(NULL, 'max_time_wait', '7200'), +(NULL , 'allow_unicode_usernames', 'yes'), +(NULL, 'min_username', '3'), +(NULL, 'max_username', '15'); +UPDATE `{tbl_prefix}config` SET `name` = 'allow_registration' WHERE `name` = 'allow_registeration' LIMIT 1 ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.0.7.sql b/upload/cb_install/sql/upgrade_2.0.7.sql new file mode 100644 index 00000000..f9384dbf --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.0.7.sql @@ -0,0 +1,8 @@ +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'allow_username_spaces', 'yes'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'use_playlist', 'yes'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'comments_captcha', 'all'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'player_logo_file', 'logo.png'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'logo_placement', 'br'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'buffer_time', '3'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'youtube_enabled', 'yes'); +ALTER TABLE `{tbl_prefix}contacts` ADD `request_type` ENUM( 'in', 'out' ) NOT NULL AFTER `contact_group_id` ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.0.8.sql b/upload/cb_install/sql/upgrade_2.0.8.sql new file mode 100644 index 00000000..3854541c --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.0.8.sql @@ -0,0 +1,11 @@ +-- NEW CONFIGS +INSERT INTO {tbl_prefix}config (name,value) VALUES +('use_ffmpeg_vf','no'), +('use_crons','no'), +('mail_type','mail'), +('smtp_host','mail.myserver.com'), +('smtp_user','user@myserver.com'), +('smtp_pass','password'), +('smtp_auth','yes'), +('smtp_port','26'); +UPDATE `{table_prefix}config` SET date_format='Y-m-d' WHERE date_format='m-d-Y'; diff --git a/upload/cb_install/sql/upgrade_2.0.9.sql b/upload/cb_install/sql/upgrade_2.0.9.sql new file mode 100644 index 00000000..74e6bef5 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.0.9.sql @@ -0,0 +1,8 @@ +UPDATE `{table_prefix}phrases` SET text='register_as_our_website_member' WHERE text='register_as_our_website_member' ; +UPDATE `{table_prefix}phrases` SET text='Register as a member, it`s free and easy just ' WHERE text='Register as a member, it's free and easy just ' ; +UPDATE `{table_prefix}phrases` SET text='email_wont_display' WHERE text='email_wont_display' ; +UPDATE `{table_prefix}phrases` SET text='Email (Wont` display)' WHERE text='Email (Wont' display)' ; + +INSERT INTO {tbl_prefix}config (name,value) VALUES ('use_subs','0'); + +ALTER TABLE {tbl_prefix}video_categories ADD `parent_id` INT( 255 ) NOT NULL DEFAULT '0' AFTER `category_id`; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.0.91.sql b/upload/cb_install/sql/upgrade_2.0.91.sql new file mode 100644 index 00000000..e69de29b diff --git a/upload/cb_install/sql/upgrade_2.1.sql b/upload/cb_install/sql/upgrade_2.1.sql new file mode 100644 index 00000000..68cf4d5f --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.1.sql @@ -0,0 +1,163 @@ +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collections` ( + `collection_id` bigint(25) NOT NULL AUTO_INCREMENT, + `collection_name` varchar(225) NOT NULL, + `collection_description` text NOT NULL, + `collection_tags` text NOT NULL, + `category` varchar(20) NOT NULL, + `userid` int(10) NOT NULL, + `views` bigint(20) NOT NULL, + `date_added` datetime NOT NULL, + `featured` varchar(4) NOT NULL DEFAULT 'no', + `broadcast` varchar(10) NOT NULL, + `allow_comments` varchar(4) NOT NULL, + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` bigint(20) NOT NULL, + `last_commented` datetime NOT NULL, + `total_objects` bigint(20) NOT NULL, + `rating` bigint(20) NOT NULL, + `rated_by` bigint(20) NOT NULL, + `voters` longtext NOT NULL, + `active` varchar(4) NOT NULL, + `public_upload` varchar(4) NOT NULL, + `type` varchar(10) NOT NULL, + PRIMARY KEY (`collection_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=9 ; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_categories` ( + `category_id` int(255) NOT NULL AUTO_INCREMENT, + `category_name` varchar(30) NOT NULL, + `category_order` int(5) NOT NULL, + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumint(9) NOT NULL, + `isdefault` enum('yes','no') NOT NULL, + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ; + + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_items` ( + `ci_id` bigint(20) NOT NULL AUTO_INCREMENT, + `collection_id` bigint(20) NOT NULL, + `object_id` bigint(20) NOT NULL, + `userid` bigint(20) NOT NULL, + `type` varchar(10) NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`ci_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=30 ; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}photos` ( + `photo_id` bigint(255) NOT NULL AUTO_INCREMENT, + `photo_key` mediumtext NOT NULL, + `photo_title` mediumtext NOT NULL, + `photo_description` mediumtext NOT NULL, + `photo_tags` mediumtext NOT NULL, + `userid` int(255) NOT NULL, + `collection_id` int(255) NOT NULL, + `date_added` datetime NOT NULL, + `last_viewed` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `views` bigint(255) NOT NULL, + `allow_comments` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_embedding` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_tagging` enum('yes','no') NOT NULL DEFAULT 'yes', + `featured` enum('yes','no') NOT NULL DEFAULT 'no', + `reported` enum('yes','no') NOT NULL DEFAULT 'no', + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `broadcast` enum('public','private') NOT NULL DEFAULT 'public', + `active` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` int(255) NOT NULL, + `last_commented` datetime NOT NULL, + `total_favorites` int(255) NOT NULL, + `rating` int(15) NOT NULL, + `rated_by` int(25) NOT NULL, + `voters` mediumtext NOT NULL, + `filename` varchar(100) NOT NULL, + `ext` char(5) NOT NULL, + `downloaded` bigint(255) NOT NULL, + `server_url` text NOT NULL, + `owner_ip` varchar(20) NOT NULL, + PRIMARY KEY (`photo_id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=20 ; + +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'photo_ratio', '16:10'), (NULL, 'photo_thumb_width', '120'), (NULL, 'photo_thumb_height', '75'), (NULL, 'photo_med_width', '185'), (NULL, 'photo_med_height', '116'), (NULL, 'photo_lar_width', '600'), (NULL, 'photo_crop', '1'), (NULL, 'photo_multi_upload', '5'), (NULL, 'photo_download', '1'), (NULL, 'photo_comments', '1'), (NULL, 'photo_rating', '1'); + +INSERT into {tbl_prefix}config (name,value) VALUES +('load_upload_form','yes'), +('load_remote_upload_form','yes'), +('load_embed_form','yes'), +('load_link_video_form','yes'), +('groupsSection','yes'), +('videosSection','yes'), +('photosSection','yes'), +('homeSection','yes'), +('uploadSection','yes'), +('signupSection','yes'), +('collectionsSection','yes'), +('channelsSection','yes'); + +INSERT into {tbl_prefix}config (name,value) VALUES +('flvtool++',''), +('normal_resolution', '480'), +('high_resolution', '720'), +('max_video_duration','320'); + +ALTER TABLE `{tbl_prefix}video` ADD `aspect_ratio` VARCHAR( 10 ) NOT NULL AFTER `default_thumb` ; +ALTER TABLE `{tbl_prefix}video` ADD `failed_reason` ENUM( 'max_duration', 'max_file', 'invalid_format', 'invalid_upload' ) NOT NULL AFTER `status` ; +ALTER TABLE `{tbl_prefix}users` CHANGE `subscribers` `subscribers` BIGINT( 225 ) NOT NULL DEFAULT '0'; + +INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`) +VALUES (NULL , 'embed_player_height', '250'), +(NULL , 'embed_player_width', '300'); + +INSERT into {tbl_prefix}config (name,value) VALUES +('photo_main_list','20'), +('photo_home_tabs','10'), +('photo_search_result','20'), +('photo_channel_page','10'), +('photo_user_photos','20'), +('photo_user_favorites','20'), +('photo_other_limit','8'), +('collection_per_page','20'), +('collection_home_page','10'), +('collection_search_result','20'), +('collection_channel_page','10'), +('collection_user_collections','20'), +('collection_user_favorites','20'), +('collection_items_page','20'), +('channel_rating','1'), +('own_channel_rating','1'), +('collection_rating','1'), +('own_collection_rating','1'), +('own_video_rating','1'); + +ALTER TABLE `{tbl_prefix}users` ADD `total_photos` BIGINT( 255 ) NOT NULL AFTER `total_comments` , +ADD `total_collections` BIGINT( 255 ) NOT NULL AFTER `total_photos`; + + +ALTER TABLE `{tbl_prefix}user_profile` ADD `profile_item` VARCHAR( 25 ) NOT NULL AFTER `profile_video` ; +ALTER TABLE `{tbl_prefix}video` ADD `last_commented` DATETIME NOT NULL AFTER `comments_count` ; +ALTER TABLE `{tbl_prefix}users` ADD `last_commented` DATETIME NOT NULL AFTER `comments_count` ; + +ALTER TABLE `{tbl_prefix}user_profile` ADD `allow_subscription` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes' AFTER `allow_ratings`; + +ALTER TABLE `{tbl_prefix}user_profile` ADD `show_my_videos` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes', +ADD `show_my_photos` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes', +ADD `show_my_subscriptions` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes', +ADD `show_my_subscribers` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes', +ADD `show_my_friends` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes'; + +ALTER TABLE `{tbl_prefix}users` ADD `voters` TEXT NOT NULL AFTER `rating`; + +ALTER TABLE `{tbl_prefix}user_profile` ADD `show_my_collections` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes' AFTER `user_profile_id`; + +ALTER TABLE `{tbl_prefix}users` DROP `rating` , +DROP `voters` , +DROP `rated_by` ; + +ALTER TABLE `{tbl_prefix}user_profile` ADD `rating` TINYINT( 2 ) NOT NULL AFTER `profile_item` , +ADD `voters` TEXT NOT NULL AFTER `rating` , +ADD `rated_by` INT( 150 ) NOT NULL AFTER `voters`; + +ALTER TABLE `{tbl_prefix}comments` CHANGE `date_added` `date_added` DATETIME NOT NULL ; + +INSERT INTO `{tbl_prefix}collection_categories` (`category_id`, `category_name`, `category_order`, `category_desc`, `date_added`, `category_thumb`, `isdefault`) VALUES +(1, 'Uncategorized', 0, 'Uncategorized', now(), 0, 'yes'); diff --git a/upload/cb_install/sql/upgrade_2.2.sql b/upload/cb_install/sql/upgrade_2.2.sql new file mode 100644 index 00000000..1e76a476 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.2.sql @@ -0,0 +1,23 @@ +ALTER TABLE `{tbl_prefix}video` ADD `video_password` VARCHAR( 255 ) NOT NULL AFTER `videokey` ; +ALTER TABLE `{tbl_prefix}video` ADD `video_users` TEXT NOT NULL AFTER `video_password`; +ALTER TABLE `{tbl_prefix}video` ADD `category_parents` TEXT NOT NULL AFTER `category`; + +INSERT INTO `{tbl_prefix}config` (`configid` ,`name` ,`value`)VALUES +(NULL , 'comments_per_page', '15'), +(NULL, 'feedsSection', 'yes'); + + +INSERT INTO `{tbl_prefix}email_templates` ( +`email_template_id` , +`email_template_name` , +`email_template_code` , +`email_template_subject` , +`email_template` , +`email_template_allowed_tags` +) +VALUES ( +NULL , 'Video Subscription Email', 'video_subscription_email', '{uploader} has uploaded new video on {website_title}', 'Hello {username} You have been notified by {website_title} that {uploader} has uploaded new video Video Title : {video_title} Video Description : {video_description}
    click here to watch this video
    You are notified because you are subscribed to {uploader}, you can manage your subscriptions by going to your account and click on manage subscriptions. {website_title}', '' +); + +ALTER TABLE `{tbl_prefix}video` ADD `subscription_email` ENUM( "pending", "sent" ) NOT NULL DEFAULT 'pending' AFTER `last_commented` ; +ALTER TABLE `{tbl_prefix}groups` ADD `group_admins` TEXT NOT NULL AFTER `userid` ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.3.sql b/upload/cb_install/sql/upgrade_2.3.sql new file mode 100644 index 00000000..9a638ea2 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.3.sql @@ -0,0 +1,17 @@ +DROP TABLE IF EXISTS `{tbl_prefix}sessions`; +CREATE TABLE `{tbl_prefix}sessions` ( + `session_id` int(11) NOT NULL AUTO_INCREMENT, + `session` varchar(100) NOT NULL, + `session_user` int(11) NOT NULL, + `session_string` varchar(60) NOT NULL, + `session_value` varchar(32) NOT NULL, + `ip` varchar(20) NOT NULL, + `session_date` datetime NOT NULL, + `current_page` text NOT NULL, + `referer` text NOT NULL, + `agent` text NOT NULL, + `last_active` datetime NOT NULL, + PRIMARY KEY (`session_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +ALTER TABLE `{tbl_prefix}users` ADD `album_privacy` ENUM( 'public', 'private', 'friends' ) NOT NULL DEFAULT 'private' ; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.4.5.sql b/upload/cb_install/sql/upgrade_2.4.5.sql new file mode 100644 index 00000000..f9f138c9 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.4.5.sql @@ -0,0 +1,96 @@ +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collections` ( + `collection_id` bigint(25) NOT NULL AUTO_INCREMENT, + `collection_name` varchar(225) NOT NULL, + `collection_description` text NOT NULL, + `collection_tags` text NOT NULL, + `category` varchar(20) NOT NULL, + `userid` int(10) NOT NULL, + `views` bigint(20) NOT NULL, + `date_added` datetime NOT NULL, + `featured` varchar(4) NOT NULL DEFAULT 'no', + `broadcast` varchar(10) NOT NULL, + `allow_comments` varchar(4) NOT NULL, + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` bigint(20) NOT NULL, + `last_commented` datetime NOT NULL, + `total_objects` bigint(20) NOT NULL, + `rating` bigint(20) NOT NULL, + `rated_by` bigint(20) NOT NULL, + `voters` longtext NOT NULL, + `active` varchar(4) NOT NULL, + `public_upload` varchar(4) NOT NULL, + `type` varchar(10) NOT NULL, + PRIMARY KEY (`collection_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_categories` ( + `category_id` int(255) NOT NULL AUTO_INCREMENT, + `category_name` varchar(30) NOT NULL, + `category_order` int(5) NOT NULL, + `category_desc` text NOT NULL, + `date_added` mediumtext NOT NULL, + `category_thumb` mediumint(9) NOT NULL, + `isdefault` enum('yes','no') NOT NULL, + PRIMARY KEY (`category_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_items` ( + `ci_id` bigint(20) NOT NULL AUTO_INCREMENT, + `collection_id` bigint(20) NOT NULL, + `object_id` bigint(20) NOT NULL, + `userid` bigint(20) NOT NULL, + `type` varchar(10) NOT NULL, + `date_added` datetime NOT NULL, + PRIMARY KEY (`ci_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}photos` ( + `photo_id` bigint(255) NOT NULL AUTO_INCREMENT, + `photo_key` mediumtext NOT NULL, + `photo_title` mediumtext NOT NULL, + `photo_description` mediumtext NOT NULL, + `photo_tags` mediumtext NOT NULL, + `userid` int(255) NOT NULL, + `collection_id` int(255) NOT NULL, + `date_added` datetime NOT NULL, + `last_viewed` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' ON UPDATE CURRENT_TIMESTAMP, + `views` bigint(255) NOT NULL, + `allow_comments` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_embedding` enum('yes','no') NOT NULL DEFAULT 'yes', + `allow_tagging` enum('yes','no') NOT NULL DEFAULT 'yes', + `featured` enum('yes','no') NOT NULL DEFAULT 'no', + `reported` enum('yes','no') NOT NULL DEFAULT 'no', + `allow_rating` enum('yes','no') NOT NULL DEFAULT 'yes', + `broadcast` enum('public','private') NOT NULL DEFAULT 'public', + `active` enum('yes','no') NOT NULL DEFAULT 'yes', + `total_comments` int(255) NOT NULL, + `last_commented` datetime NOT NULL, + `total_favorites` int(255) NOT NULL, + `rating` int(15) NOT NULL, + `rated_by` int(25) NOT NULL, + `voters` mediumtext NOT NULL, + `filename` varchar(100) NOT NULL, + `ext` char(5) NOT NULL, + `downloaded` bigint(255) NOT NULL, + `server_url` text NOT NULL, + `owner_ip` varchar(20) NOT NULL, + PRIMARY KEY (`photo_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ; + + + +ALTER TABLE `{tbl_prefix}pages` ADD `page_order` BIGINT( 100 ) NOT NULL AFTER `page_id` , +ADD `display` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'yes' AFTER `page_order` ; + +UPDATE `{tbl_prefix}pages` SET `display` = 'no' WHERE `page_id` =5 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `display` = 'no' WHERE`page_id` =6 LIMIT 1 ; + +UPDATE `{tbl_prefix}pages` SET `page_order` = '1' WHERE `page_id` =1 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '2' WHERE `page_id` =2 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '3' WHERE `page_id` =3 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '4' WHERE `page_id` =4 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '5' WHERE `page_id` =5 LIMIT 1 ; +UPDATE `{tbl_prefix}pages` SET `page_order` = '6' WHERE `page_id` =6 LIMIT 1 ; + +ALTER TABLE `{tbl_prefix}users` ADD `voted` TEXT NOT NULL AFTER `last_commented`; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.4.sql b/upload/cb_install/sql/upgrade_2.4.sql new file mode 100644 index 00000000..e69de29b diff --git a/upload/cb_install/sql/upgrade_2.5.1.sql b/upload/cb_install/sql/upgrade_2.5.1.sql new file mode 100644 index 00000000..1ae380fe --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.5.1.sql @@ -0,0 +1,9 @@ +ALTER TABLE `{tbl_prefix}groups` ADD `group_admins` TEXT NOT NULL AFTER `userid`; + +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'embed_type', 'iframe'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'playlistsSection', 'yes'); + +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'vid_cat_height', '120'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'vid_cat_width', '120'); + +ALTER TABLE `{tbl_prefix}photos` ADD `photo_details` TEXT NOT NULL AFTER `photo_tags`; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.5.sql b/upload/cb_install/sql/upgrade_2.5.sql new file mode 100644 index 00000000..e69de29b diff --git a/upload/cb_install/sql/upgrade_2.6.sql b/upload/cb_install/sql/upgrade_2.6.sql new file mode 100644 index 00000000..1ff7e69c --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.6.sql @@ -0,0 +1,64 @@ +ALTER TABLE `{tbl_prefix}video` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '0'; +ALTER TABLE `{tbl_prefix}collections` CHANGE `category` `category` VARCHAR( 200 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL ; +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'facebook_embed', 'yes'); +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'seo_vido_url', '0'); + +INSERT INTO `{tbl_prefix}config` (`configid`, `name`, `value`) VALUES (NULL, 'use_cached_pagin', 'yes'), +(NULL, 'cached_pagin_time', '5'); + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}counters` ( + `counter_id` int(100) NOT NULL AUTO_INCREMENT, + `section` varchar(200) NOT NULL, + `query` text NOT NULL, + `query_md5` varchar(200) NOT NULL, + `counts` bigint(200) NOT NULL, + `date_added` varchar(200) NOT NULL, + PRIMARY KEY (`counter_id`), + UNIQUE KEY `query_md5` (`query_md5`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + + +ALTER TABLE `{tbl_prefix}user_levels_permissions` ADD `photos_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' , +ADD `collection_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `photos_moderation` , +ADD `plugins_moderation` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `collection_moderation` , +ADD `tool_box` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_moderation` , +ADD `plugins_perms` TEXT NOT NULL AFTER `tool_box` ; + +INSERT INTO `{tbl_prefix}user_permissions` ( +`permission_id` , +`permission_type` , +`permission_name` , +`permission_code` , +`permission_desc` , +`permission_default` +)VALUES ( +NULL , '3', 'Allow photo moderation', 'photos_moderation', 'Allow user to moderation photos from admin panel', 'yes'), ( +NULL , '3', 'Collection modetaion', 'collection_moderation', 'Allow users to moderate collection', 'yes'), ( +NULL , '3', 'Plugins moderation', 'plugins_moderation', 'Allow user to moderate plugins', 'yes'), ( +NULL , '3', 'Tool Box', 'tool_box', 'Allow users to access tool box', 'yes'); + +UPDATE `{tbl_prefix}user_levels_permissions` SET `photos_moderation` = 'yes', +`collection_moderation` = 'yes', +`plugins_moderation` = 'yes', +`tool_box` = 'yes' WHERE `user_level_permission_id` =1; + +UPDATE {tbl_prefix}video SET rating='10' WHERE rating>10; + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}mass_emails` ( + `id` int(255) NOT NULL AUTO_INCREMENT, + `email_subj` varchar(255) NOT NULL, + `email_from` varchar(255) NOT NULL, + `email_msg` text NOT NULL, + `configs` text NOT NULL, + `sent` bigint(255) NOT NULL, + `total` bigint(20) NOT NULL, + `users` text NOT NULL, + `start_index` bigint(255) NOT NULL, + `method` enum('browser','background') NOT NULL, + `status` enum('completed','pending','sending') NOT NULL, + `date_added` datetime NOT NULL, + `last_update` datetime NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; + +ALTER TABLE `{tbl_prefix}photos` ADD `photo_details` TEXT NOT NULL AFTER `photo_tags`; \ No newline at end of file diff --git a/upload/cb_install/sql/upgrade_2.7.sql b/upload/cb_install/sql/upgrade_2.7.sql new file mode 100644 index 00000000..483b6635 --- /dev/null +++ b/upload/cb_install/sql/upgrade_2.7.sql @@ -0,0 +1,17 @@ +-- Adding new user level permission +-- Author Arslan +ALTER TABLE `{tbl_prefix}user_levels_permissions` ADD `allow_manage_user_level` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_perms`; +UPDATE `{tbl_prefix}user_levels_permissions` SET `allow_manage_user_level` = 'yes' WHERE `cb_user_levels_permissions`.`user_level_permission_id` =1; +INSERT INTO `{tbl_prefix}user_permissions` (`permission_id`, `permission_type`, `permission_name`, `permission_code`, `permission_desc`, `permission_default`) VALUES (NULL, '3', 'Allow manage user levels', 'allow_manage_user_level', 'Allow user to edit user levels', 'no'); + + +-- Adding Collection contributors + +CREATE TABLE IF NOT EXISTS `{tbl_prefix}collection_contributors` ( + `contributor_id` int(200) NOT NULL AUTO_INCREMENT, + `collection_id` int(255) NOT NULL, + `userid` int(255) NOT NULL, + `can_edit` enum('yes','no') NOT NULL DEFAULT 'no', + `date_added` datetime NOT NULL, + PRIMARY KEY (`contributor_id`) +) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ; \ No newline at end of file diff --git a/upload/cb_install/sql/user_levels.sql b/upload/cb_install/sql/user_levels.sql new file mode 100644 index 00000000..743c3eb6 --- /dev/null +++ b/upload/cb_install/sql/user_levels.sql @@ -0,0 +1,88 @@ + +-- +-- Dumping data for table `user_levels` +-- + +INSERT INTO `{tbl_prefix}user_levels` (`user_level_id`, `user_level_active`, `user_level_name`, `user_level_is_default`) VALUES +(4, 'yes', 'Guest', 'yes'), +(2, 'yes', 'Registered User', 'yes'), +(3, 'yes', 'Inactive User', 'yes'), +(1, 'yes', 'Administrator', 'yes'), +(5, 'yes', 'Global Moderator', 'yes'), +(6, 'yes', 'Anonymous', 'yes'); + +-- +-- Dumping data for table `user_levels_permissions` +-- + +INSERT INTO `{tbl_prefix}user_levels_permissions` (`user_level_permission_id`, `user_level_id`, `admin_access`, `allow_video_upload`, `view_video`, `view_channel`, `view_group`, `view_videos`, `avatar_upload`, `video_moderation`, `member_moderation`, `ad_manager_access`, `manage_template_access`, `group_moderation`, `web_config_access`, `view_channels`, `view_groups`, `playlist_access`, `allow_channel_bg`, `private_msg_access`, `edit_video`, `download_video`, `admin_del_access`) VALUES +(1, 1, 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes'), +(2, 2, 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no'), +(3, 3, 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no'), +(4, 4, 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no'), +(5, 5, 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no', 'no', 'no', 'no', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'yes', 'no'), +(6, 6, 'no', 'yes', 'no', 'no', 'no', 'no', 'yes', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'no', 'yes', 'no', 'no', 'yes', 'no'); + +-- +-- Dumping data for table `user_permissions` +-- + +INSERT INTO `{tbl_prefix}user_permissions` (`permission_id`, `permission_type`, `permission_name`, `permission_code`, `permission_desc`, `permission_default`) VALUES +(12, 3, 'Admin Access', 'admin_access', 'User can access admin panel', 'no'), +(13, 1, 'View Video', 'view_video', 'User can view videos', 'yes'), +(11, 2, 'Allow Video Upload', 'allow_video_upload', 'Allow user to upload videos', 'yes'), +(14, 1, 'View Channel', 'view_channel', 'User Can View Channel', 'yes'), +(15, 1, 'View Group', 'view_group', 'User Can View Group', 'yes'), +(16, 1, 'View Videos Page', 'view_videos', 'User Can view videos page', 'yes'), +(17, 2, 'Allow Avatar Upload', 'avatar_upload', 'User can upload video', 'yes'), +(19, 3, 'Video Moderation', 'video_moderation', 'User Can Moderate Videos', 'no'), +(20, 3, 'Member Moderation', 'member_moderation', 'User Can Moderate Members', 'no'), +(21, 3, 'Advertisment Manager', 'ad_manager_access', 'User can change advertisment', 'no'), +(22, 3, 'Manage Templates', 'manage_template_access', 'User can manage website templates', 'no'), +(23, 3, 'Groups Moderation', 'group_moderation', 'User can moderate group', 'no'), +(24, 3, 'Website Configurations', 'web_config_access', 'User can change website settings', 'no'), +(25, 1, 'View channels', 'view_channels', 'User can channels', 'yes'), +(26, 1, 'View Groups', 'view_groups', 'User can view groups', 'yes'), +(28, 4, 'Playlist Access', 'playlist_access', 'User can access playlists', 'yes'), +(29, 2, 'Allow Channel Background', 'allow_channel_bg', 'Allow user to change channel background', 'yes'), +(30, 4, 'Private Messages', 'private_msg_access', 'User can use private messaging system', 'yes'), +(31, 4, 'Edit Video', 'edit_video', 'User can edit video', 'yes'), +(32, 4, 'Download Video', 'download_video', 'User can download videos', 'yes'), +(33, 3, 'Admin Delete Access', 'admin_del_access', 'User can delete comments if has admin access', 'no'); + +-- +-- Dumping data for table `user_permission_types` +-- + +INSERT INTO `{tbl_prefix}user_permission_types` (`user_permission_type_id`, `user_permission_type_name`, `user_permission_type_desc`) VALUES +(1, 'Viewing Permission', ''), +(2, 'Uploading Permission', ''), +(3, 'Administrator Permission', ''), +(4, 'General Permission', ''); + +-- 2.6 + +INSERT INTO `{tbl_prefix}user_permissions` ( +`permission_id` , +`permission_type` , +`permission_name` , +`permission_code` , +`permission_desc` , +`permission_default` +)VALUES ( +NULL , '3', 'Allow photo moderation', 'photos_moderation', 'Allow user to moderation photos from admin panel', 'yes'), ( +NULL , '3', 'Collection modetaion', 'collection_moderation', 'Allow users to moderate collection', 'yes'), ( +NULL , '3', 'Plugins moderation', 'plugins_moderation', 'Allow user to moderate plugins', 'yes'), ( +NULL , '3', 'Tool Box', 'tool_box', 'Allow users to access tool box', 'yes'); + +UPDATE `{tbl_prefix}user_levels_permissions` SET `photos_moderation` = 'yes', +`collection_moderation` = 'yes', +`plugins_moderation` = 'yes', +`tool_box` = 'yes' WHERE `user_level_permission_id` =1; + +-- 2.7 +-- Adding new user level permission +-- Author Arslan +ALTER TABLE `{tbl_prefix}user_levels_permissions` ADD `allow_manage_user_level` ENUM( 'yes', 'no' ) NOT NULL DEFAULT 'no' AFTER `plugins_perms`; +UPDATE `{tbl_prefix}user_levels_permissions` SET `allow_manage_user_level` = 'yes' WHERE `cb_user_levels_permissions`.`user_level_permission_id` =1; +INSERT INTO `{tbl_prefix}user_permissions` (`permission_id`, `permission_type`, `permission_name`, `permission_code`, `permission_desc`, `permission_default`) VALUES (NULL, '3', 'Allow manage user levels', 'allow_manage_user_level', 'Allow user to edit user levels', 'no'); \ No newline at end of file diff --git a/upload/cb_install/style.css b/upload/cb_install/style.css new file mode 100644 index 00000000..76ca422c --- /dev/null +++ b/upload/cb_install/style.css @@ -0,0 +1,110 @@ +body +{ + margin:10px; padding:0px; + font-family:tahoma; + font-size:11px; + color:#000; +} + +a{color:#06c} + +#container +{ + margin:auto; + width:880px; + border:2px solid #eee; + padding:10px; +} + +#head{margin:auto;width:900px; margin-bottom:10px} + +#header +{ + height:25px; width:900px; border:1px solid #d4d4d4; + line-height:25px; background-image:url(images/header_grad.png); background-repeat:repeat-x; + background-position:center; + margin:auto; margin-bottom:5px; +} + + +.br5px +{ + border-radius:5px; + -webkist-border-radius:5px; + -moz-border-radius:5px; +} + +.headstatus +{ + padding:0px; margin:0px; + background-image:url(images/header_grad_line.png); + background-repeat:repeat-x; + background-position:center; + width:98%; margin:auto +} + +.headstatus li +{ + height:25px;line-height:25px;background-image:url(images/header_grad.png); + background-repeat:repeat-x; + background-position:center; + display:inline-block; + margin:0px 5px; + padding:0px 5px; + color:#999 +} + +.headstatus .selected { color:#09c; font-weight:bold} + +#logo{font-family: 'Cabin', arial, serif; font-size:28px; font-weight:bold} + +.bttnleft,.bttncenter,.bttnright,.bttnrightalt +{ + height:34px; display:inline-block;line-height:32px; font-size:14px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; color:#fff; + cursor:pointer; +} +.bttnleft{background-image:url(images/bttnleft.png); width:14px; } +.bttncenter{background-image:url(images/bttncenter.png);min-width:50px;padding-right:10px; } +.bttnright{background-image:url(images/bttnright.png);width:37px; } +.bttnrightalt{background-image:url(images/bttnrightalt.png); width:14px; } + +dt{font-weight:bold; float:left; width:80px; display:inline-block;border-bottom:1px dotted #999; padding:5px 3px; line-height:20px; } +dd{ width:auto; border-bottom:1px dotted #999; padding:5px 3px; margin:0px; line-height:20px;} +dd .red{color:ed0000} dd .green{color:#060; } +dd .ok{background-image:url(images/tick.png); background-repeat:no-repeat; height:20px; padding-left:23px; display:inline-block} +dd .alert{background-image:url(images/alert.png); background-repeat:no-repeat; height:20px; padding-left:23px; display:inline-block} + +dd:last-child{border-bottom:none} +dl{background-color:#F7F7F7; padding:0px; border:1px dotted #999} + +.inside_shadow +{ + -moz-box-shadow: inset -5px -5px 5px #ccc; + -webkit-box-shadow: inset -5px -5px 5px #ccc; + box-shadow: inset -5px -5px 5px #ccc; +} + +.field{margin-bottom:10px} +.field input{border:1px solid #ccc; padding:5px 3px; font-size:13px; color:#666; width:300px} +.field label{display:block; margin-top:10px; font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif} + +.errorDiv +{ + padding:5px; margin:10px 0px; + background-color:#FFFDCA; + border:1px solid #FA7C80; +} + +.alert{background-image:url(images/alert.png); background-repeat:no-repeat; height:20px; + padding-left:23px; display:inline-block; +line-height:20px} + +.ok{background-image:url(images/tick.png); background-repeat:no-repeat; height:20px; padding-left:23px; display:inline-block;line-height:20px} + +.green{display:block; margin-bottom:10px} + +.product{margin-top:10px; width:400px; padding:5px; background-color:#f3f3f3; border:1px solid #d6d6d6; float:left; margin:5px 10px} +.product a{font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; color:#0099CC; text-decoration:none; display:block} +.product .desc{color:#666; margin-top:5px} + +.product:hover{background-color:#eaeaea; border:1px solid #09c} \ No newline at end of file diff --git a/upload/cb_install/upgradeable.php b/upload/cb_install/upgradeable.php new file mode 100644 index 00000000..a02b6546 --- /dev/null +++ b/upload/cb_install/upgradeable.php @@ -0,0 +1,37 @@ + \ No newline at end of file diff --git a/upload/channels.php b/upload/channels.php new file mode 100644 index 00000000..72cea86e --- /dev/null +++ b/upload/channels.php @@ -0,0 +1,83 @@ +perm_check('view_channels',true); + +//Setting Sort +$sort = $_GET['sort']; +//$u_cond = array('category'=>mysql_clean($_GET['cat']),'date_span'=>$_GET['time']); +//Thanks to florin.mandache + +$u_cond = array('category'=>mysql_clean($_GET['cat']),'date_span'=>mysql_clean($_GET['time'])); + +switch($sort) +{ + case "most_recent": + default: + { + $u_cond['order'] = " doj DESC "; + } + break; + case "most_viewed": + { + $u_cond['order'] = " profile_hits DESC "; + } + break; + case "featured": + { + $u_cond['featured'] = "yes"; + } + break; + case "top_rated": + { + $u_cond['order'] = " rating DESC"; + } + break; + case "most_commented": + { + $u_cond['order'] = " total_comments DESC"; + } + break; +} + +//Getting User List +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,CLISTPP); +$count_query = $ulist = $u_cond; +$ulist['limit'] = $get_limit; +$users = get_users($ulist); +Assign('users', $users); + + +$counter = get_counter('channel',$count_query); + +if(!$counter) +{ + //Collecting Data for Pagination + $ucount = $u_cond; + $ucount['count_only'] = true; + $total_rows = get_users($ucount); + $counter = $total_rows; + update_counter('channel',$count_query,$counter); +} + +$total_pages = count_pages($counter,CLISTPP); +//Pagination +$pages->paginate($total_pages,$page); + +subtitle(lang('channels')); +template_files('channels.html'); +display_it(); + + +?> \ No newline at end of file diff --git a/upload/collections.php b/upload/collections.php new file mode 100644 index 00000000..825340b8 --- /dev/null +++ b/upload/collections.php @@ -0,0 +1,91 @@ +page_redir(); + +$sort = $_GET['sort']; +$cond = array("category"=>mysql_clean($_GET['cat']),"date_span"=>mysql_clean($_GET['time'])); +$content = mysql_clean($_GET['content']); + +switch($sort) +{ + case "most_recent": + default: + { + $cond['order'] = " date_added DESC"; + } + break; + + case "featured": + { + $cond['featured'] = "yes"; + } + break; + + case "most_viewed": + { + $cond['order'] = " views DESC"; + } + break; + + case "most_commented": + { + $cond['order'] = " total_comments DESC"; + } + break; + + case "most_items": + { + $cond['order'] = " total_objects DESC"; + } + break; +} + +switch($content) +{ + case "videos": + { + $cond['type'] = "videos"; + } + break; + + case "photos": + { + $cond['type'] = "photos"; + } +} + +//$cond['has_items'] = true; + +//Getting Collection List +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,COLLPP); +$clist = $cond; +$clist['limit'] = $get_limit; +$collections = $cbcollection->get_collections($clist); + +Assign('collections', $collections); + +//Collecting Data for Pagination +$ccount = $cond; +$ccount['count_only'] = true; +$total_rows = $cbcollection->get_collections($ccount); +$total_pages = count_pages($total_rows,COLLPP); + +//Pagination +$pages->paginate($total_pages,$page); + +subtitle(lang('collections')); +//Displaying The Template +template_files('collections.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/contact.php b/upload/contact.php new file mode 100644 index 00000000..13382f1f --- /dev/null +++ b/upload/contact.php @@ -0,0 +1,61 @@ +get_template('contact_form'); + $more_var = array + ('{name}' => substr($name,0,100), + '{email}' => substr($email,0,100), + '{reason}' => substr($reason,0,300), + '{message}' => $message, + '{ip_address}' => $_SERVER['REMOTE_ADDR'], + '{now}' => now(), + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + if(cbmail(array('to'=>SUPPORT_EMAIL,'from'=>$email,'subject'=>$subj,'content'=>$msg))) + e(lang("email_send_confirm"),"m"); + } +} + +subtitle(lang("contact_us")); + +template_files('contact.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/create_group.php b/upload/create_group.php new file mode 100644 index 00000000..29cb536f --- /dev/null +++ b/upload/create_group.php @@ -0,0 +1,28 @@ +logincheck(); +$pages->page_redir(); + + +// Creating Group if button is pressed +if(isset($_POST['create_group'])) { + $cbgroup->create_group($_POST,userid(),true); +} + +subtitle(lang('grp_crt_grp')); + +template_files('create_group.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/download.php b/upload/download.php new file mode 100644 index 00000000..57ffda8a --- /dev/null +++ b/upload/download.php @@ -0,0 +1,46 @@ +perm_check('download_video',true); +$pages->page_redir(); + +//Getting Video Key +$vkey = @$_GET['v']; +$vdo = $cbvid->get_video($vkey); + +if($vdo && video_playable($vkey)) +{ + //Calling Functions When Video Is going to download + call_download_video_function($vdo); + + $file = get_video_file($vdo,false); + + if($file) + $vdo['download_file'] = $file; + else + { + $Cbucket->show_page = false; + e(lang("unable_find_download_file")); + } + assign('vdo',$vdo); + subtitle("Download ".$vdo['title']); + +} + + +//Displaying The Template +template_files('download.html'); +display_it(); +?> diff --git a/upload/download_photo.php b/upload/download_photo.php new file mode 100644 index 00000000..27f9c04c --- /dev/null +++ b/upload/download_photo.php @@ -0,0 +1,29 @@ +perm_check('download_video',true); +$pages->page_redir(); + +$key = $cbphoto->decode_key($_GET['download']); + +if(empty($key)) + header("location:".BASEURL); +else +{ + $cbphoto->download_photo($key); +} + +display_it(); +?> \ No newline at end of file diff --git a/upload/edit_account.php b/upload/edit_account.php new file mode 100644 index 00000000..d41449d4 --- /dev/null +++ b/upload/edit_account.php @@ -0,0 +1,126 @@ +logincheck(); + +//Updating Profile +if(isset($_POST['update_profile'])) +{ + $array = $_POST; + $array['userid'] = userid(); + $userquery->update_user($array); +} + +//Updating Avatar +if(isset($_POST['update_avatar_bg'])) +{ + $array = $_POST; + $array['userid'] = userid(); + $userquery->update_user_avatar_bg($array); +} + +//Changing Email +if(isset($_POST['change_email'])) +{ + $array = $_POST; + $array['userid'] = userid(); + $userquery->change_email($array); +} + +//Changing User Password +if(isset($_POST['change_password'])) +{ + $array = $_POST; + $array['userid'] = userid(); + $userquery->change_password($array); +} + +//Banning Users +if(isset($_POST['block_users'])) +{ + $userquery->block_users($_POST['users']); +} + +$mode = $_GET['mode']; + +switch($mode) +{ + case 'account': + { + assign('on','account'); + assign('mode','profile_settings'); + } + break; + case 'profile': + { + assign('on','profile'); + assign('mode','profile_settings'); + } + break; + + case 'avatar_bg': + { + assign('mode','avatar_bg'); + } + break; + + case 'change_email': + { + assign('mode','change_email'); + } + break; + + case 'change_password': + { + assign('mode','change_password'); + } + break; + + case 'block_users': + { + assign('mode','block_users'); + } + break; + + case 'subscriptions': + { + //Removing subscription + if(isset($_GET['delete_subs'])) + { + $sid = mysql_clean($_GET['delete_subs']); + $userquery->unsubscribe_user($sid); + } + assign('mode','subs'); + assign('subs',$userquery->get_user_subscriptions(userid())); + } + break; + + default: + { + assign('on','account'); + assign('mode','profile_settings'); + } +} + + +$udetails = $userquery->get_user_details(userid()); +$profile = $userquery->get_user_profile($udetails['userid']); +$user_profile = array_merge($udetails,$profile); +//pr($Cbucket->header_files); +assign('user',$udetails); +assign('p',$user_profile); + + +subtitle(lang("user_manage_my_account")); +template_files('edit_account.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/edit_group.php b/upload/edit_group.php new file mode 100644 index 00000000..5804a147 --- /dev/null +++ b/upload/edit_group.php @@ -0,0 +1,54 @@ +logincheck(); +$udetails = $userquery->get_user_details(userid()); +assign('user',$udetails); +assign('p',$userquery->get_user_profile($udetails['userid'])); + +$gid = mysql_clean($_GET['gid']); +//get group details +$gdetails = $cbgroup->get_group_details($gid); + +$gArray = + array + ( + 'group' => $gdetails, + 'groupid' => $gid, + 'uid' => userid(), + 'user' => $userquery->udetails, + 'checkowner' => 'yes' + ); + +if(!$cbgroup->is_admin($gArray) && !has_access('admin_access',true)) +{ + e(lang("you_cant_edit_group")); + $Cbucket->show_page = false; +}else{ + + //Updating Video Details + if(isset($_POST['update_group'])) + { + $_POST['group_id'] = $gid; + $cbgroup->update_group(); + $gdetails = $cbgroup->get_group_details($gid); + + } + + assign('group',$gdetails); +} + +subtitle(lang("grp_edit_grp_title")); +template_files('edit_group.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/edit_photo.php b/upload/edit_photo.php new file mode 100644 index 00000000..92145670 --- /dev/null +++ b/upload/edit_photo.php @@ -0,0 +1,42 @@ +login_check('edit_video'); + +$udetails = $userquery->get_user_details(userid()); +assign('user',$udetails); +assign('p',$userquery->get_user_profile($udetails['userid'])); + +$pid = mysql_clean($_GET['photo']); +$photo = $cbphoto->get_photo($pid); + +if(empty($photo)) + e(lang("photo_not_exists")); +elseif($photo['userid'] != userid()) +{ + e(lang("You can not edit this photo.")); + $Cbucket->show_page = false; +} else { + if(isset($_POST['update_photo'])) + { + $cbphoto->update_photo(); + $photo = $cbphoto->get_photo($pid); + } + + assign('p',$photo); +} + +subtitle(lang("Edit Photo")); +template_files('edit_photo.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/edit_video.php b/upload/edit_video.php new file mode 100644 index 00000000..d61d6582 --- /dev/null +++ b/upload/edit_video.php @@ -0,0 +1,48 @@ +login_check('edit_video'); + +$udetails = $userquery->get_user_details(userid()); +assign('user',$udetails); +assign('p',$userquery->get_user_profile($udetails['userid'])); + +$vid = mysql_clean($_GET['vid']); +//get video details +$vdetails = $cbvid->get_video_details($vid); + +if($vdetails['userid'] != userid()) +{ + e(lang('no_edit_video')); + $Cbucket->show_page = false; +}else{ + + //Updating Video Details + if(isset($_POST['update_video'])){ + $Upload->validate_video_upload_form(); + if(empty($eh->error_list)) + { + $_POST['videoid'] = $vid; + $cbvid->update_video(); + $cbvid->set_default_thumb($vid,mysql_clean(post('default_thumb'))); + $vdetails = $cbvid->get_video_details($vid); + } + } + + assign('v',$vdetails); +} + +subtitle(lang("vdo_edit_vdo")); +template_files('edit_video.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/favicon.ico b/upload/favicon.ico new file mode 100644 index 00000000..e85c3dd2 Binary files /dev/null and b/upload/favicon.ico differ diff --git a/upload/files/.htaccess b/upload/files/.htaccess new file mode 100644 index 00000000..502a99ff --- /dev/null +++ b/upload/files/.htaccess @@ -0,0 +1,2 @@ +Options -ExecCGI +AddHandler cgi-script .php .pl .py .jsp .asp .htm .shtml .sh .cgi .exe .html .ruby .pearl \ No newline at end of file diff --git a/upload/files/photos/no-photo_m.png b/upload/files/photos/no-photo_m.png new file mode 100644 index 00000000..d5f346c4 Binary files /dev/null and b/upload/files/photos/no-photo_m.png differ diff --git a/upload/files/photos/no-photo_t.png b/upload/files/photos/no-photo_t.png new file mode 100644 index 00000000..f5a6db31 Binary files /dev/null and b/upload/files/photos/no-photo_t.png differ diff --git a/upload/files/thumbs/processing.jpg b/upload/files/thumbs/processing.jpg new file mode 100644 index 00000000..a4efc6ee Binary files /dev/null and b/upload/files/thumbs/processing.jpg differ diff --git a/upload/files/videos/no_video.flv b/upload/files/videos/no_video.flv new file mode 100644 index 00000000..327ee7c7 Binary files /dev/null and b/upload/files/videos/no_video.flv differ diff --git a/upload/forgot.php b/upload/forgot.php new file mode 100644 index 00000000..3f94af7f --- /dev/null +++ b/upload/forgot.php @@ -0,0 +1,53 @@ +reset_password(1,$input); + } + + /** + * Reseting Password + * Real Reseting ;) + */ + $user = get('user'); + if($mode =='reset_pass' && $user) + { + $input = mysql_clean(get('user')); + $avcode = mysql_clean(get('avcode')); + if($userquery->reset_password(2,$input,$avcode)) + assign('pass_recover','success'); + } + + /** + * Recovering username + */ + if(isset($_POST['recover_username'])) + { + $email = mysql_clean($_POST['forgot_email']); + $msg = $userquery->recover_username($email); + } + +assign('mode',$mode); + +subtitle(lang("com_forgot_username")); +template_files('forgot.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/groups.php b/upload/groups.php new file mode 100644 index 00000000..f32bdb35 --- /dev/null +++ b/upload/groups.php @@ -0,0 +1,71 @@ +page_redir(); +$userquery->perm_check('view_groups',true); + +//Setting Sort +$sort = $_GET['sort']; +$g_cond = array('category'=>mysql_clean($_GET['cat']),'date_span'=>mysql_clean($_GET['time'])); + +switch($sort) +{ + case "most_recent": + default: + { + $g_cond['order'] = " date_added DESC "; + } + break; + case "most_viewed": + { + $g_cond['order'] = " total_views DESC "; + } + break; + case "featured": + { + $g_cond['featured'] = "yes"; + } + break; + case "top_rated": + { + $g_cond['order'] = " total_members DESC"; + } + break; + case "most_commented": + { + $g_cond['order'] = " total_topics DESC"; + } + break; +} + +//Getting User List +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,GLISTPP); + +$glist = $g_cond; + +$glist['limit'] = $get_limit; +$groups = $cbgroup->get_groups($glist); +Assign('groups', $groups); + +//Collecting Data for Pagination +$gcount = $g_cond; +$gcount['count_only'] = true; +$total_rows = $cbgroup->get_groups($gcount); +$total_pages = count_pages($total_rows,GLISTPP); + +//Pagination +$pages->paginate($total_pages,$page); + +subtitle(lang('groups')); +template_files('groups.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/images/avatars/no_avatar-small.jpg b/upload/images/avatars/no_avatar-small.jpg new file mode 100644 index 00000000..e40158db Binary files /dev/null and b/upload/images/avatars/no_avatar-small.jpg differ diff --git a/upload/images/avatars/no_avatar-small.png b/upload/images/avatars/no_avatar-small.png new file mode 100644 index 00000000..8f0af01b Binary files /dev/null and b/upload/images/avatars/no_avatar-small.png differ diff --git a/upload/images/avatars/no_avatar.jpg b/upload/images/avatars/no_avatar.jpg new file mode 100644 index 00000000..02e363a2 Binary files /dev/null and b/upload/images/avatars/no_avatar.jpg differ diff --git a/upload/images/avatars/no_avatar.png b/upload/images/avatars/no_avatar.png new file mode 100644 index 00000000..2e3b8a5f Binary files /dev/null and b/upload/images/avatars/no_avatar.png differ diff --git a/upload/images/category_thumbs/no_thumb.jpg b/upload/images/category_thumbs/no_thumb.jpg new file mode 100644 index 00000000..509366f1 Binary files /dev/null and b/upload/images/category_thumbs/no_thumb.jpg differ diff --git a/upload/images/collection_thumbs/no_thumb-small.png b/upload/images/collection_thumbs/no_thumb-small.png new file mode 100644 index 00000000..7efd99ec Binary files /dev/null and b/upload/images/collection_thumbs/no_thumb-small.png differ diff --git a/upload/images/collection_thumbs/no_thumb.png b/upload/images/collection_thumbs/no_thumb.png new file mode 100644 index 00000000..db3507dc Binary files /dev/null and b/upload/images/collection_thumbs/no_thumb.png differ diff --git a/upload/images/groups_thumbs/no_thumb-small.png b/upload/images/groups_thumbs/no_thumb-small.png new file mode 100644 index 00000000..72ee185a Binary files /dev/null and b/upload/images/groups_thumbs/no_thumb-small.png differ diff --git a/upload/images/groups_thumbs/no_thumb.png b/upload/images/groups_thumbs/no_thumb.png new file mode 100644 index 00000000..22278422 Binary files /dev/null and b/upload/images/groups_thumbs/no_thumb.png differ diff --git a/upload/images/icons/XPButton.png b/upload/images/icons/XPButton.png new file mode 100644 index 00000000..df7aa6ea Binary files /dev/null and b/upload/images/icons/XPButton.png differ diff --git a/upload/images/icons/cb_powered.gif b/upload/images/icons/cb_powered.gif new file mode 100644 index 00000000..7af31cad Binary files /dev/null and b/upload/images/icons/cb_powered.gif differ diff --git a/upload/images/icons/country/ac.png b/upload/images/icons/country/ac.png new file mode 100644 index 00000000..ff701e19 Binary files /dev/null and b/upload/images/icons/country/ac.png differ diff --git a/upload/images/icons/country/ad.png b/upload/images/icons/country/ad.png new file mode 100644 index 00000000..625ca84f Binary files /dev/null and b/upload/images/icons/country/ad.png differ diff --git a/upload/images/icons/country/ae.png b/upload/images/icons/country/ae.png new file mode 100644 index 00000000..ef3a1ecf Binary files /dev/null and b/upload/images/icons/country/ae.png differ diff --git a/upload/images/icons/country/af.png b/upload/images/icons/country/af.png new file mode 100644 index 00000000..a4742e29 Binary files /dev/null and b/upload/images/icons/country/af.png differ diff --git a/upload/images/icons/country/ag.png b/upload/images/icons/country/ag.png new file mode 100644 index 00000000..556d5504 Binary files /dev/null and b/upload/images/icons/country/ag.png differ diff --git a/upload/images/icons/country/ai.png b/upload/images/icons/country/ai.png new file mode 100644 index 00000000..74ed29d9 Binary files /dev/null and b/upload/images/icons/country/ai.png differ diff --git a/upload/images/icons/country/al.png b/upload/images/icons/country/al.png new file mode 100644 index 00000000..92354cb6 Binary files /dev/null and b/upload/images/icons/country/al.png differ diff --git a/upload/images/icons/country/am.png b/upload/images/icons/country/am.png new file mode 100644 index 00000000..344a2a86 Binary files /dev/null and b/upload/images/icons/country/am.png differ diff --git a/upload/images/icons/country/an.png b/upload/images/icons/country/an.png new file mode 100644 index 00000000..633e4b89 Binary files /dev/null and b/upload/images/icons/country/an.png differ diff --git a/upload/images/icons/country/ao.png b/upload/images/icons/country/ao.png new file mode 100644 index 00000000..bcbd1d6d Binary files /dev/null and b/upload/images/icons/country/ao.png differ diff --git a/upload/images/icons/country/aq.png b/upload/images/icons/country/aq.png new file mode 100644 index 00000000..544f443a Binary files /dev/null and b/upload/images/icons/country/aq.png differ diff --git a/upload/images/icons/country/ar.png b/upload/images/icons/country/ar.png new file mode 100644 index 00000000..e5ef8f1f Binary files /dev/null and b/upload/images/icons/country/ar.png differ diff --git a/upload/images/icons/country/as.png b/upload/images/icons/country/as.png new file mode 100644 index 00000000..32f30e4c Binary files /dev/null and b/upload/images/icons/country/as.png differ diff --git a/upload/images/icons/country/at.png b/upload/images/icons/country/at.png new file mode 100644 index 00000000..0f15f34f Binary files /dev/null and b/upload/images/icons/country/at.png differ diff --git a/upload/images/icons/country/au.png b/upload/images/icons/country/au.png new file mode 100644 index 00000000..a01389a7 Binary files /dev/null and b/upload/images/icons/country/au.png differ diff --git a/upload/images/icons/country/aw.png b/upload/images/icons/country/aw.png new file mode 100644 index 00000000..a3579c2d Binary files /dev/null and b/upload/images/icons/country/aw.png differ diff --git a/upload/images/icons/country/ax.png b/upload/images/icons/country/ax.png new file mode 100644 index 00000000..1eea80a7 Binary files /dev/null and b/upload/images/icons/country/ax.png differ diff --git a/upload/images/icons/country/az.png b/upload/images/icons/country/az.png new file mode 100644 index 00000000..4ee9fe5c Binary files /dev/null and b/upload/images/icons/country/az.png differ diff --git a/upload/images/icons/country/ba.png b/upload/images/icons/country/ba.png new file mode 100644 index 00000000..c7749924 Binary files /dev/null and b/upload/images/icons/country/ba.png differ diff --git a/upload/images/icons/country/bb.png b/upload/images/icons/country/bb.png new file mode 100644 index 00000000..0df19c71 Binary files /dev/null and b/upload/images/icons/country/bb.png differ diff --git a/upload/images/icons/country/bd.png b/upload/images/icons/country/bd.png new file mode 100644 index 00000000..076a8bf8 Binary files /dev/null and b/upload/images/icons/country/bd.png differ diff --git a/upload/images/icons/country/be.png b/upload/images/icons/country/be.png new file mode 100644 index 00000000..d86ebc80 Binary files /dev/null and b/upload/images/icons/country/be.png differ diff --git a/upload/images/icons/country/bf.png b/upload/images/icons/country/bf.png new file mode 100644 index 00000000..ab5ce8fe Binary files /dev/null and b/upload/images/icons/country/bf.png differ diff --git a/upload/images/icons/country/bg.png b/upload/images/icons/country/bg.png new file mode 100644 index 00000000..0469f060 Binary files /dev/null and b/upload/images/icons/country/bg.png differ diff --git a/upload/images/icons/country/bh.png b/upload/images/icons/country/bh.png new file mode 100644 index 00000000..ea8ce687 Binary files /dev/null and b/upload/images/icons/country/bh.png differ diff --git a/upload/images/icons/country/bi.png b/upload/images/icons/country/bi.png new file mode 100644 index 00000000..5cc2e30c Binary files /dev/null and b/upload/images/icons/country/bi.png differ diff --git a/upload/images/icons/country/bj.png b/upload/images/icons/country/bj.png new file mode 100644 index 00000000..1cc8b458 Binary files /dev/null and b/upload/images/icons/country/bj.png differ diff --git a/upload/images/icons/country/bm.png b/upload/images/icons/country/bm.png new file mode 100644 index 00000000..c0c7aead Binary files /dev/null and b/upload/images/icons/country/bm.png differ diff --git a/upload/images/icons/country/bn.png b/upload/images/icons/country/bn.png new file mode 100644 index 00000000..8fb09849 Binary files /dev/null and b/upload/images/icons/country/bn.png differ diff --git a/upload/images/icons/country/bo.png b/upload/images/icons/country/bo.png new file mode 100644 index 00000000..ce7ba522 Binary files /dev/null and b/upload/images/icons/country/bo.png differ diff --git a/upload/images/icons/country/br.png b/upload/images/icons/country/br.png new file mode 100644 index 00000000..9b1a5538 Binary files /dev/null and b/upload/images/icons/country/br.png differ diff --git a/upload/images/icons/country/bs.png b/upload/images/icons/country/bs.png new file mode 100644 index 00000000..639fa6cf Binary files /dev/null and b/upload/images/icons/country/bs.png differ diff --git a/upload/images/icons/country/bt.png b/upload/images/icons/country/bt.png new file mode 100644 index 00000000..1d512dff Binary files /dev/null and b/upload/images/icons/country/bt.png differ diff --git a/upload/images/icons/country/bv.png b/upload/images/icons/country/bv.png new file mode 100644 index 00000000..160b6b5b Binary files /dev/null and b/upload/images/icons/country/bv.png differ diff --git a/upload/images/icons/country/bw.png b/upload/images/icons/country/bw.png new file mode 100644 index 00000000..fcb10394 Binary files /dev/null and b/upload/images/icons/country/bw.png differ diff --git a/upload/images/icons/country/by.png b/upload/images/icons/country/by.png new file mode 100644 index 00000000..504774ec Binary files /dev/null and b/upload/images/icons/country/by.png differ diff --git a/upload/images/icons/country/bz.png b/upload/images/icons/country/bz.png new file mode 100644 index 00000000..be63ee1c Binary files /dev/null and b/upload/images/icons/country/bz.png differ diff --git a/upload/images/icons/country/ca.png b/upload/images/icons/country/ca.png new file mode 100644 index 00000000..1f204193 Binary files /dev/null and b/upload/images/icons/country/ca.png differ diff --git a/upload/images/icons/country/cc.png b/upload/images/icons/country/cc.png new file mode 100644 index 00000000..aed3d3b4 Binary files /dev/null and b/upload/images/icons/country/cc.png differ diff --git a/upload/images/icons/country/cd.png b/upload/images/icons/country/cd.png new file mode 100644 index 00000000..5e489424 Binary files /dev/null and b/upload/images/icons/country/cd.png differ diff --git a/upload/images/icons/country/cf.png b/upload/images/icons/country/cf.png new file mode 100644 index 00000000..da687bdc Binary files /dev/null and b/upload/images/icons/country/cf.png differ diff --git a/upload/images/icons/country/cg.png b/upload/images/icons/country/cg.png new file mode 100644 index 00000000..a859792e Binary files /dev/null and b/upload/images/icons/country/cg.png differ diff --git a/upload/images/icons/country/ch.png b/upload/images/icons/country/ch.png new file mode 100644 index 00000000..242ec01a Binary files /dev/null and b/upload/images/icons/country/ch.png differ diff --git a/upload/images/icons/country/ci.png b/upload/images/icons/country/ci.png new file mode 100644 index 00000000..3f2c62eb Binary files /dev/null and b/upload/images/icons/country/ci.png differ diff --git a/upload/images/icons/country/ck.png b/upload/images/icons/country/ck.png new file mode 100644 index 00000000..746d3d6f Binary files /dev/null and b/upload/images/icons/country/ck.png differ diff --git a/upload/images/icons/country/cl.png b/upload/images/icons/country/cl.png new file mode 100644 index 00000000..29c6d61b Binary files /dev/null and b/upload/images/icons/country/cl.png differ diff --git a/upload/images/icons/country/cm.png b/upload/images/icons/country/cm.png new file mode 100644 index 00000000..f65c5bd5 Binary files /dev/null and b/upload/images/icons/country/cm.png differ diff --git a/upload/images/icons/country/cn.png b/upload/images/icons/country/cn.png new file mode 100644 index 00000000..89144146 Binary files /dev/null and b/upload/images/icons/country/cn.png differ diff --git a/upload/images/icons/country/co.png b/upload/images/icons/country/co.png new file mode 100644 index 00000000..a118ff4a Binary files /dev/null and b/upload/images/icons/country/co.png differ diff --git a/upload/images/icons/country/cr.png b/upload/images/icons/country/cr.png new file mode 100644 index 00000000..c7a37317 Binary files /dev/null and b/upload/images/icons/country/cr.png differ diff --git a/upload/images/icons/country/cu.png b/upload/images/icons/country/cu.png new file mode 100644 index 00000000..083f1d61 Binary files /dev/null and b/upload/images/icons/country/cu.png differ diff --git a/upload/images/icons/country/cv.png b/upload/images/icons/country/cv.png new file mode 100644 index 00000000..a63f7eaf Binary files /dev/null and b/upload/images/icons/country/cv.png differ diff --git a/upload/images/icons/country/cx.png b/upload/images/icons/country/cx.png new file mode 100644 index 00000000..48e31adb Binary files /dev/null and b/upload/images/icons/country/cx.png differ diff --git a/upload/images/icons/country/cy.png b/upload/images/icons/country/cy.png new file mode 100644 index 00000000..5b1ad6c0 Binary files /dev/null and b/upload/images/icons/country/cy.png differ diff --git a/upload/images/icons/country/cz.png b/upload/images/icons/country/cz.png new file mode 100644 index 00000000..c8403dd2 Binary files /dev/null and b/upload/images/icons/country/cz.png differ diff --git a/upload/images/icons/country/de.png b/upload/images/icons/country/de.png new file mode 100644 index 00000000..ac4a9773 Binary files /dev/null and b/upload/images/icons/country/de.png differ diff --git a/upload/images/icons/country/dj.png b/upload/images/icons/country/dj.png new file mode 100644 index 00000000..582af364 Binary files /dev/null and b/upload/images/icons/country/dj.png differ diff --git a/upload/images/icons/country/dk.png b/upload/images/icons/country/dk.png new file mode 100644 index 00000000..e2993d3c Binary files /dev/null and b/upload/images/icons/country/dk.png differ diff --git a/upload/images/icons/country/dm.png b/upload/images/icons/country/dm.png new file mode 100644 index 00000000..5fbffcba Binary files /dev/null and b/upload/images/icons/country/dm.png differ diff --git a/upload/images/icons/country/do.png b/upload/images/icons/country/do.png new file mode 100644 index 00000000..5a04932d Binary files /dev/null and b/upload/images/icons/country/do.png differ diff --git a/upload/images/icons/country/dz.png b/upload/images/icons/country/dz.png new file mode 100644 index 00000000..335c2391 Binary files /dev/null and b/upload/images/icons/country/dz.png differ diff --git a/upload/images/icons/country/ec.png b/upload/images/icons/country/ec.png new file mode 100644 index 00000000..0caa0b1e Binary files /dev/null and b/upload/images/icons/country/ec.png differ diff --git a/upload/images/icons/country/ee.png b/upload/images/icons/country/ee.png new file mode 100644 index 00000000..0c82efb7 Binary files /dev/null and b/upload/images/icons/country/ee.png differ diff --git a/upload/images/icons/country/eg.png b/upload/images/icons/country/eg.png new file mode 100644 index 00000000..8a3f7a10 Binary files /dev/null and b/upload/images/icons/country/eg.png differ diff --git a/upload/images/icons/country/eh.png b/upload/images/icons/country/eh.png new file mode 100644 index 00000000..90a1195b Binary files /dev/null and b/upload/images/icons/country/eh.png differ diff --git a/upload/images/icons/country/er.png b/upload/images/icons/country/er.png new file mode 100644 index 00000000..13065ae9 Binary files /dev/null and b/upload/images/icons/country/er.png differ diff --git a/upload/images/icons/country/es.png b/upload/images/icons/country/es.png new file mode 100644 index 00000000..c2de2d71 Binary files /dev/null and b/upload/images/icons/country/es.png differ diff --git a/upload/images/icons/country/et.png b/upload/images/icons/country/et.png new file mode 100644 index 00000000..2e893fa0 Binary files /dev/null and b/upload/images/icons/country/et.png differ diff --git a/upload/images/icons/country/fi.png b/upload/images/icons/country/fi.png new file mode 100644 index 00000000..14ec091b Binary files /dev/null and b/upload/images/icons/country/fi.png differ diff --git a/upload/images/icons/country/fj.png b/upload/images/icons/country/fj.png new file mode 100644 index 00000000..cee99889 Binary files /dev/null and b/upload/images/icons/country/fj.png differ diff --git a/upload/images/icons/country/fk.png b/upload/images/icons/country/fk.png new file mode 100644 index 00000000..ceaeb27d Binary files /dev/null and b/upload/images/icons/country/fk.png differ diff --git a/upload/images/icons/country/fm.png b/upload/images/icons/country/fm.png new file mode 100644 index 00000000..066bb247 Binary files /dev/null and b/upload/images/icons/country/fm.png differ diff --git a/upload/images/icons/country/fo.png b/upload/images/icons/country/fo.png new file mode 100644 index 00000000..cbceb809 Binary files /dev/null and b/upload/images/icons/country/fo.png differ diff --git a/upload/images/icons/country/fr.png b/upload/images/icons/country/fr.png new file mode 100644 index 00000000..8332c4ec Binary files /dev/null and b/upload/images/icons/country/fr.png differ diff --git a/upload/images/icons/country/ga.png b/upload/images/icons/country/ga.png new file mode 100644 index 00000000..0e0d4343 Binary files /dev/null and b/upload/images/icons/country/ga.png differ diff --git a/upload/images/icons/country/gb.png b/upload/images/icons/country/gb.png new file mode 100644 index 00000000..ff701e19 Binary files /dev/null and b/upload/images/icons/country/gb.png differ diff --git a/upload/images/icons/country/gd.png b/upload/images/icons/country/gd.png new file mode 100644 index 00000000..9ab57f54 Binary files /dev/null and b/upload/images/icons/country/gd.png differ diff --git a/upload/images/icons/country/ge.png b/upload/images/icons/country/ge.png new file mode 100644 index 00000000..728d9707 Binary files /dev/null and b/upload/images/icons/country/ge.png differ diff --git a/upload/images/icons/country/gf.png b/upload/images/icons/country/gf.png new file mode 100644 index 00000000..8332c4ec Binary files /dev/null and b/upload/images/icons/country/gf.png differ diff --git a/upload/images/icons/country/gg.png b/upload/images/icons/country/gg.png new file mode 100644 index 00000000..af444f09 Binary files /dev/null and b/upload/images/icons/country/gg.png differ diff --git a/upload/images/icons/country/gh.png b/upload/images/icons/country/gh.png new file mode 100644 index 00000000..4e2f8965 Binary files /dev/null and b/upload/images/icons/country/gh.png differ diff --git a/upload/images/icons/country/gi.png b/upload/images/icons/country/gi.png new file mode 100644 index 00000000..e76797f6 Binary files /dev/null and b/upload/images/icons/country/gi.png differ diff --git a/upload/images/icons/country/gl.png b/upload/images/icons/country/gl.png new file mode 100644 index 00000000..ef12a73b Binary files /dev/null and b/upload/images/icons/country/gl.png differ diff --git a/upload/images/icons/country/gm.png b/upload/images/icons/country/gm.png new file mode 100644 index 00000000..0720b667 Binary files /dev/null and b/upload/images/icons/country/gm.png differ diff --git a/upload/images/icons/country/gn.png b/upload/images/icons/country/gn.png new file mode 100644 index 00000000..ea660b01 Binary files /dev/null and b/upload/images/icons/country/gn.png differ diff --git a/upload/images/icons/country/gp.png b/upload/images/icons/country/gp.png new file mode 100644 index 00000000..dbb086d0 Binary files /dev/null and b/upload/images/icons/country/gp.png differ diff --git a/upload/images/icons/country/gq.png b/upload/images/icons/country/gq.png new file mode 100644 index 00000000..ebe20a28 Binary files /dev/null and b/upload/images/icons/country/gq.png differ diff --git a/upload/images/icons/country/gr.png b/upload/images/icons/country/gr.png new file mode 100644 index 00000000..8651ade7 Binary files /dev/null and b/upload/images/icons/country/gr.png differ diff --git a/upload/images/icons/country/gs.png b/upload/images/icons/country/gs.png new file mode 100644 index 00000000..7ef0bf59 Binary files /dev/null and b/upload/images/icons/country/gs.png differ diff --git a/upload/images/icons/country/gt.png b/upload/images/icons/country/gt.png new file mode 100644 index 00000000..c43a70d3 Binary files /dev/null and b/upload/images/icons/country/gt.png differ diff --git a/upload/images/icons/country/gu.png b/upload/images/icons/country/gu.png new file mode 100644 index 00000000..92f37c05 Binary files /dev/null and b/upload/images/icons/country/gu.png differ diff --git a/upload/images/icons/country/gw.png b/upload/images/icons/country/gw.png new file mode 100644 index 00000000..b37bcf06 Binary files /dev/null and b/upload/images/icons/country/gw.png differ diff --git a/upload/images/icons/country/gy.png b/upload/images/icons/country/gy.png new file mode 100644 index 00000000..22cbe2f5 Binary files /dev/null and b/upload/images/icons/country/gy.png differ diff --git a/upload/images/icons/country/hk.png b/upload/images/icons/country/hk.png new file mode 100644 index 00000000..d5c380ca Binary files /dev/null and b/upload/images/icons/country/hk.png differ diff --git a/upload/images/icons/country/hm.png b/upload/images/icons/country/hm.png new file mode 100644 index 00000000..a01389a7 Binary files /dev/null and b/upload/images/icons/country/hm.png differ diff --git a/upload/images/icons/country/hn.png b/upload/images/icons/country/hn.png new file mode 100644 index 00000000..96f83885 Binary files /dev/null and b/upload/images/icons/country/hn.png differ diff --git a/upload/images/icons/country/hr.png b/upload/images/icons/country/hr.png new file mode 100644 index 00000000..696b5154 Binary files /dev/null and b/upload/images/icons/country/hr.png differ diff --git a/upload/images/icons/country/ht.png b/upload/images/icons/country/ht.png new file mode 100644 index 00000000..416052af Binary files /dev/null and b/upload/images/icons/country/ht.png differ diff --git a/upload/images/icons/country/hu.png b/upload/images/icons/country/hu.png new file mode 100644 index 00000000..7baafe44 Binary files /dev/null and b/upload/images/icons/country/hu.png differ diff --git a/upload/images/icons/country/id.png b/upload/images/icons/country/id.png new file mode 100644 index 00000000..c6bc0faf Binary files /dev/null and b/upload/images/icons/country/id.png differ diff --git a/upload/images/icons/country/ie.png b/upload/images/icons/country/ie.png new file mode 100644 index 00000000..26baa31e Binary files /dev/null and b/upload/images/icons/country/ie.png differ diff --git a/upload/images/icons/country/il.png b/upload/images/icons/country/il.png new file mode 100644 index 00000000..2ca772d0 Binary files /dev/null and b/upload/images/icons/country/il.png differ diff --git a/upload/images/icons/country/im.png b/upload/images/icons/country/im.png new file mode 100644 index 00000000..243024de Binary files /dev/null and b/upload/images/icons/country/im.png differ diff --git a/upload/images/icons/country/in.png b/upload/images/icons/country/in.png new file mode 100644 index 00000000..e4d7e81a Binary files /dev/null and b/upload/images/icons/country/in.png differ diff --git a/upload/images/icons/country/io.png b/upload/images/icons/country/io.png new file mode 100644 index 00000000..3e74b6a3 Binary files /dev/null and b/upload/images/icons/country/io.png differ diff --git a/upload/images/icons/country/iq.png b/upload/images/icons/country/iq.png new file mode 100644 index 00000000..878a3514 Binary files /dev/null and b/upload/images/icons/country/iq.png differ diff --git a/upload/images/icons/country/ir.png b/upload/images/icons/country/ir.png new file mode 100644 index 00000000..c5fd136a Binary files /dev/null and b/upload/images/icons/country/ir.png differ diff --git a/upload/images/icons/country/is.png b/upload/images/icons/country/is.png new file mode 100644 index 00000000..b8f6d0f0 Binary files /dev/null and b/upload/images/icons/country/is.png differ diff --git a/upload/images/icons/country/it.png b/upload/images/icons/country/it.png new file mode 100644 index 00000000..89692f74 Binary files /dev/null and b/upload/images/icons/country/it.png differ diff --git a/upload/images/icons/country/je.png b/upload/images/icons/country/je.png new file mode 100644 index 00000000..7d7e23a4 Binary files /dev/null and b/upload/images/icons/country/je.png differ diff --git a/upload/images/icons/country/jm.png b/upload/images/icons/country/jm.png new file mode 100644 index 00000000..7be119e0 Binary files /dev/null and b/upload/images/icons/country/jm.png differ diff --git a/upload/images/icons/country/jo.png b/upload/images/icons/country/jo.png new file mode 100644 index 00000000..11bd4972 Binary files /dev/null and b/upload/images/icons/country/jo.png differ diff --git a/upload/images/icons/country/jp.png b/upload/images/icons/country/jp.png new file mode 100644 index 00000000..325fbad3 Binary files /dev/null and b/upload/images/icons/country/jp.png differ diff --git a/upload/images/icons/country/ke.png b/upload/images/icons/country/ke.png new file mode 100644 index 00000000..51879adf Binary files /dev/null and b/upload/images/icons/country/ke.png differ diff --git a/upload/images/icons/country/kg.png b/upload/images/icons/country/kg.png new file mode 100644 index 00000000..0a818f67 Binary files /dev/null and b/upload/images/icons/country/kg.png differ diff --git a/upload/images/icons/country/kh.png b/upload/images/icons/country/kh.png new file mode 100644 index 00000000..30f6bb1b Binary files /dev/null and b/upload/images/icons/country/kh.png differ diff --git a/upload/images/icons/country/ki.png b/upload/images/icons/country/ki.png new file mode 100644 index 00000000..2dcce4b3 Binary files /dev/null and b/upload/images/icons/country/ki.png differ diff --git a/upload/images/icons/country/km.png b/upload/images/icons/country/km.png new file mode 100644 index 00000000..812b2f56 Binary files /dev/null and b/upload/images/icons/country/km.png differ diff --git a/upload/images/icons/country/kn.png b/upload/images/icons/country/kn.png new file mode 100644 index 00000000..febd5b48 Binary files /dev/null and b/upload/images/icons/country/kn.png differ diff --git a/upload/images/icons/country/kp.png b/upload/images/icons/country/kp.png new file mode 100644 index 00000000..d3d509aa Binary files /dev/null and b/upload/images/icons/country/kp.png differ diff --git a/upload/images/icons/country/kr.png b/upload/images/icons/country/kr.png new file mode 100644 index 00000000..9c0a78eb Binary files /dev/null and b/upload/images/icons/country/kr.png differ diff --git a/upload/images/icons/country/kw.png b/upload/images/icons/country/kw.png new file mode 100644 index 00000000..96546da3 Binary files /dev/null and b/upload/images/icons/country/kw.png differ diff --git a/upload/images/icons/country/ky.png b/upload/images/icons/country/ky.png new file mode 100644 index 00000000..15c5f8e4 Binary files /dev/null and b/upload/images/icons/country/ky.png differ diff --git a/upload/images/icons/country/kz.png b/upload/images/icons/country/kz.png new file mode 100644 index 00000000..45a8c887 Binary files /dev/null and b/upload/images/icons/country/kz.png differ diff --git a/upload/images/icons/country/la.png b/upload/images/icons/country/la.png new file mode 100644 index 00000000..e28acd01 Binary files /dev/null and b/upload/images/icons/country/la.png differ diff --git a/upload/images/icons/country/lb.png b/upload/images/icons/country/lb.png new file mode 100644 index 00000000..d0d452bf Binary files /dev/null and b/upload/images/icons/country/lb.png differ diff --git a/upload/images/icons/country/lc.png b/upload/images/icons/country/lc.png new file mode 100644 index 00000000..a47d0655 Binary files /dev/null and b/upload/images/icons/country/lc.png differ diff --git a/upload/images/icons/country/li.png b/upload/images/icons/country/li.png new file mode 100644 index 00000000..6469909c Binary files /dev/null and b/upload/images/icons/country/li.png differ diff --git a/upload/images/icons/country/lk.png b/upload/images/icons/country/lk.png new file mode 100644 index 00000000..088aad6d Binary files /dev/null and b/upload/images/icons/country/lk.png differ diff --git a/upload/images/icons/country/lr.png b/upload/images/icons/country/lr.png new file mode 100644 index 00000000..89a5bc7e Binary files /dev/null and b/upload/images/icons/country/lr.png differ diff --git a/upload/images/icons/country/ls.png b/upload/images/icons/country/ls.png new file mode 100644 index 00000000..33fdef10 Binary files /dev/null and b/upload/images/icons/country/ls.png differ diff --git a/upload/images/icons/country/lt.png b/upload/images/icons/country/lt.png new file mode 100644 index 00000000..c8ef0da0 Binary files /dev/null and b/upload/images/icons/country/lt.png differ diff --git a/upload/images/icons/country/lu.png b/upload/images/icons/country/lu.png new file mode 100644 index 00000000..4cabba98 Binary files /dev/null and b/upload/images/icons/country/lu.png differ diff --git a/upload/images/icons/country/lv.png b/upload/images/icons/country/lv.png new file mode 100644 index 00000000..49b69981 Binary files /dev/null and b/upload/images/icons/country/lv.png differ diff --git a/upload/images/icons/country/ly.png b/upload/images/icons/country/ly.png new file mode 100644 index 00000000..b163a9f8 Binary files /dev/null and b/upload/images/icons/country/ly.png differ diff --git a/upload/images/icons/country/ma.png b/upload/images/icons/country/ma.png new file mode 100644 index 00000000..f3867702 Binary files /dev/null and b/upload/images/icons/country/ma.png differ diff --git a/upload/images/icons/country/mc.png b/upload/images/icons/country/mc.png new file mode 100644 index 00000000..1aa830f1 Binary files /dev/null and b/upload/images/icons/country/mc.png differ diff --git a/upload/images/icons/country/md.png b/upload/images/icons/country/md.png new file mode 100644 index 00000000..4e92c189 Binary files /dev/null and b/upload/images/icons/country/md.png differ diff --git a/upload/images/icons/country/me.png b/upload/images/icons/country/me.png new file mode 100644 index 00000000..ac725355 Binary files /dev/null and b/upload/images/icons/country/me.png differ diff --git a/upload/images/icons/country/mg.png b/upload/images/icons/country/mg.png new file mode 100644 index 00000000..d2715b3d Binary files /dev/null and b/upload/images/icons/country/mg.png differ diff --git a/upload/images/icons/country/mh.png b/upload/images/icons/country/mh.png new file mode 100644 index 00000000..fb523a8c Binary files /dev/null and b/upload/images/icons/country/mh.png differ diff --git a/upload/images/icons/country/mk.png b/upload/images/icons/country/mk.png new file mode 100644 index 00000000..db173aaf Binary files /dev/null and b/upload/images/icons/country/mk.png differ diff --git a/upload/images/icons/country/ml.png b/upload/images/icons/country/ml.png new file mode 100644 index 00000000..2cec8ba4 Binary files /dev/null and b/upload/images/icons/country/ml.png differ diff --git a/upload/images/icons/country/mm.png b/upload/images/icons/country/mm.png new file mode 100644 index 00000000..f464f67f Binary files /dev/null and b/upload/images/icons/country/mm.png differ diff --git a/upload/images/icons/country/mn.png b/upload/images/icons/country/mn.png new file mode 100644 index 00000000..9396355d Binary files /dev/null and b/upload/images/icons/country/mn.png differ diff --git a/upload/images/icons/country/mo.png b/upload/images/icons/country/mo.png new file mode 100644 index 00000000..deb801dd Binary files /dev/null and b/upload/images/icons/country/mo.png differ diff --git a/upload/images/icons/country/mp.png b/upload/images/icons/country/mp.png new file mode 100644 index 00000000..298d588b Binary files /dev/null and b/upload/images/icons/country/mp.png differ diff --git a/upload/images/icons/country/mq.png b/upload/images/icons/country/mq.png new file mode 100644 index 00000000..010143b3 Binary files /dev/null and b/upload/images/icons/country/mq.png differ diff --git a/upload/images/icons/country/mr.png b/upload/images/icons/country/mr.png new file mode 100644 index 00000000..319546b1 Binary files /dev/null and b/upload/images/icons/country/mr.png differ diff --git a/upload/images/icons/country/ms.png b/upload/images/icons/country/ms.png new file mode 100644 index 00000000..d4cbb433 Binary files /dev/null and b/upload/images/icons/country/ms.png differ diff --git a/upload/images/icons/country/mt.png b/upload/images/icons/country/mt.png new file mode 100644 index 00000000..00af9487 Binary files /dev/null and b/upload/images/icons/country/mt.png differ diff --git a/upload/images/icons/country/mu.png b/upload/images/icons/country/mu.png new file mode 100644 index 00000000..b7fdce1b Binary files /dev/null and b/upload/images/icons/country/mu.png differ diff --git a/upload/images/icons/country/mv.png b/upload/images/icons/country/mv.png new file mode 100644 index 00000000..5073d9ec Binary files /dev/null and b/upload/images/icons/country/mv.png differ diff --git a/upload/images/icons/country/mw.png b/upload/images/icons/country/mw.png new file mode 100644 index 00000000..13886e9f Binary files /dev/null and b/upload/images/icons/country/mw.png differ diff --git a/upload/images/icons/country/mx.png b/upload/images/icons/country/mx.png new file mode 100644 index 00000000..5bc58ab3 Binary files /dev/null and b/upload/images/icons/country/mx.png differ diff --git a/upload/images/icons/country/my.png b/upload/images/icons/country/my.png new file mode 100644 index 00000000..9034cbab Binary files /dev/null and b/upload/images/icons/country/my.png differ diff --git a/upload/images/icons/country/mz.png b/upload/images/icons/country/mz.png new file mode 100644 index 00000000..76405e06 Binary files /dev/null and b/upload/images/icons/country/mz.png differ diff --git a/upload/images/icons/country/na.png b/upload/images/icons/country/na.png new file mode 100644 index 00000000..63358c67 Binary files /dev/null and b/upload/images/icons/country/na.png differ diff --git a/upload/images/icons/country/nc.png b/upload/images/icons/country/nc.png new file mode 100644 index 00000000..2cad2837 Binary files /dev/null and b/upload/images/icons/country/nc.png differ diff --git a/upload/images/icons/country/ne.png b/upload/images/icons/country/ne.png new file mode 100644 index 00000000..d85f424f Binary files /dev/null and b/upload/images/icons/country/ne.png differ diff --git a/upload/images/icons/country/nf.png b/upload/images/icons/country/nf.png new file mode 100644 index 00000000..f9bcdda1 Binary files /dev/null and b/upload/images/icons/country/nf.png differ diff --git a/upload/images/icons/country/ng.png b/upload/images/icons/country/ng.png new file mode 100644 index 00000000..3eea2e02 Binary files /dev/null and b/upload/images/icons/country/ng.png differ diff --git a/upload/images/icons/country/ni.png b/upload/images/icons/country/ni.png new file mode 100644 index 00000000..3969aaaa Binary files /dev/null and b/upload/images/icons/country/ni.png differ diff --git a/upload/images/icons/country/nl.png b/upload/images/icons/country/nl.png new file mode 100644 index 00000000..fe44791e Binary files /dev/null and b/upload/images/icons/country/nl.png differ diff --git a/upload/images/icons/country/no.png b/upload/images/icons/country/no.png new file mode 100644 index 00000000..160b6b5b Binary files /dev/null and b/upload/images/icons/country/no.png differ diff --git a/upload/images/icons/country/np.png b/upload/images/icons/country/np.png new file mode 100644 index 00000000..aeb058b7 Binary files /dev/null and b/upload/images/icons/country/np.png differ diff --git a/upload/images/icons/country/nr.png b/upload/images/icons/country/nr.png new file mode 100644 index 00000000..705fc337 Binary files /dev/null and b/upload/images/icons/country/nr.png differ diff --git a/upload/images/icons/country/nu.png b/upload/images/icons/country/nu.png new file mode 100644 index 00000000..c3ce4aed Binary files /dev/null and b/upload/images/icons/country/nu.png differ diff --git a/upload/images/icons/country/nz.png b/upload/images/icons/country/nz.png new file mode 100644 index 00000000..10d6306d Binary files /dev/null and b/upload/images/icons/country/nz.png differ diff --git a/upload/images/icons/country/om.png b/upload/images/icons/country/om.png new file mode 100644 index 00000000..2ffba7e8 Binary files /dev/null and b/upload/images/icons/country/om.png differ diff --git a/upload/images/icons/country/pa.png b/upload/images/icons/country/pa.png new file mode 100644 index 00000000..9b2ee9a7 Binary files /dev/null and b/upload/images/icons/country/pa.png differ diff --git a/upload/images/icons/country/pe.png b/upload/images/icons/country/pe.png new file mode 100644 index 00000000..62a04977 Binary files /dev/null and b/upload/images/icons/country/pe.png differ diff --git a/upload/images/icons/country/pf.png b/upload/images/icons/country/pf.png new file mode 100644 index 00000000..771a0f65 Binary files /dev/null and b/upload/images/icons/country/pf.png differ diff --git a/upload/images/icons/country/pg.png b/upload/images/icons/country/pg.png new file mode 100644 index 00000000..10d62334 Binary files /dev/null and b/upload/images/icons/country/pg.png differ diff --git a/upload/images/icons/country/ph.png b/upload/images/icons/country/ph.png new file mode 100644 index 00000000..b89e1593 Binary files /dev/null and b/upload/images/icons/country/ph.png differ diff --git a/upload/images/icons/country/pk.png b/upload/images/icons/country/pk.png new file mode 100644 index 00000000..e9df70ca Binary files /dev/null and b/upload/images/icons/country/pk.png differ diff --git a/upload/images/icons/country/pl.png b/upload/images/icons/country/pl.png new file mode 100644 index 00000000..d413d010 Binary files /dev/null and b/upload/images/icons/country/pl.png differ diff --git a/upload/images/icons/country/pm.png b/upload/images/icons/country/pm.png new file mode 100644 index 00000000..ba91d2c7 Binary files /dev/null and b/upload/images/icons/country/pm.png differ diff --git a/upload/images/icons/country/pn.png b/upload/images/icons/country/pn.png new file mode 100644 index 00000000..aa9344f5 Binary files /dev/null and b/upload/images/icons/country/pn.png differ diff --git a/upload/images/icons/country/pr.png b/upload/images/icons/country/pr.png new file mode 100644 index 00000000..82d9130d Binary files /dev/null and b/upload/images/icons/country/pr.png differ diff --git a/upload/images/icons/country/ps.png b/upload/images/icons/country/ps.png new file mode 100644 index 00000000..f5f54776 Binary files /dev/null and b/upload/images/icons/country/ps.png differ diff --git a/upload/images/icons/country/pt.png b/upload/images/icons/country/pt.png new file mode 100644 index 00000000..ece79801 Binary files /dev/null and b/upload/images/icons/country/pt.png differ diff --git a/upload/images/icons/country/pw.png b/upload/images/icons/country/pw.png new file mode 100644 index 00000000..6178b254 Binary files /dev/null and b/upload/images/icons/country/pw.png differ diff --git a/upload/images/icons/country/py.png b/upload/images/icons/country/py.png new file mode 100644 index 00000000..cb8723c0 Binary files /dev/null and b/upload/images/icons/country/py.png differ diff --git a/upload/images/icons/country/qa.png b/upload/images/icons/country/qa.png new file mode 100644 index 00000000..ed4c621f Binary files /dev/null and b/upload/images/icons/country/qa.png differ diff --git a/upload/images/icons/country/re.png b/upload/images/icons/country/re.png new file mode 100644 index 00000000..8332c4ec Binary files /dev/null and b/upload/images/icons/country/re.png differ diff --git a/upload/images/icons/country/ro.png b/upload/images/icons/country/ro.png new file mode 100644 index 00000000..57e74a65 Binary files /dev/null and b/upload/images/icons/country/ro.png differ diff --git a/upload/images/icons/country/rs.png b/upload/images/icons/country/rs.png new file mode 100644 index 00000000..9439a5b6 Binary files /dev/null and b/upload/images/icons/country/rs.png differ diff --git a/upload/images/icons/country/ru.png b/upload/images/icons/country/ru.png new file mode 100644 index 00000000..47da4214 Binary files /dev/null and b/upload/images/icons/country/ru.png differ diff --git a/upload/images/icons/country/rw.png b/upload/images/icons/country/rw.png new file mode 100644 index 00000000..53564917 Binary files /dev/null and b/upload/images/icons/country/rw.png differ diff --git a/upload/images/icons/country/sa.png b/upload/images/icons/country/sa.png new file mode 100644 index 00000000..b4641c7e Binary files /dev/null and b/upload/images/icons/country/sa.png differ diff --git a/upload/images/icons/country/sb.png b/upload/images/icons/country/sb.png new file mode 100644 index 00000000..a9937ccf Binary files /dev/null and b/upload/images/icons/country/sb.png differ diff --git a/upload/images/icons/country/sc.png b/upload/images/icons/country/sc.png new file mode 100644 index 00000000..39ee3718 Binary files /dev/null and b/upload/images/icons/country/sc.png differ diff --git a/upload/images/icons/country/sd.png b/upload/images/icons/country/sd.png new file mode 100644 index 00000000..eaab69eb Binary files /dev/null and b/upload/images/icons/country/sd.png differ diff --git a/upload/images/icons/country/se.png b/upload/images/icons/country/se.png new file mode 100644 index 00000000..1994653d Binary files /dev/null and b/upload/images/icons/country/se.png differ diff --git a/upload/images/icons/country/sg.png b/upload/images/icons/country/sg.png new file mode 100644 index 00000000..dd34d612 Binary files /dev/null and b/upload/images/icons/country/sg.png differ diff --git a/upload/images/icons/country/sh.png b/upload/images/icons/country/sh.png new file mode 100644 index 00000000..4b1d2a29 Binary files /dev/null and b/upload/images/icons/country/sh.png differ diff --git a/upload/images/icons/country/si.png b/upload/images/icons/country/si.png new file mode 100644 index 00000000..bb1476ff Binary files /dev/null and b/upload/images/icons/country/si.png differ diff --git a/upload/images/icons/country/sj.png b/upload/images/icons/country/sj.png new file mode 100644 index 00000000..160b6b5b Binary files /dev/null and b/upload/images/icons/country/sj.png differ diff --git a/upload/images/icons/country/sk.png b/upload/images/icons/country/sk.png new file mode 100644 index 00000000..7ccbc827 Binary files /dev/null and b/upload/images/icons/country/sk.png differ diff --git a/upload/images/icons/country/sl.png b/upload/images/icons/country/sl.png new file mode 100644 index 00000000..12d812d2 Binary files /dev/null and b/upload/images/icons/country/sl.png differ diff --git a/upload/images/icons/country/sm.png b/upload/images/icons/country/sm.png new file mode 100644 index 00000000..3df2fdcf Binary files /dev/null and b/upload/images/icons/country/sm.png differ diff --git a/upload/images/icons/country/sn.png b/upload/images/icons/country/sn.png new file mode 100644 index 00000000..eabb71db Binary files /dev/null and b/upload/images/icons/country/sn.png differ diff --git a/upload/images/icons/country/so.png b/upload/images/icons/country/so.png new file mode 100644 index 00000000..4a1ea4b2 Binary files /dev/null and b/upload/images/icons/country/so.png differ diff --git a/upload/images/icons/country/sr.png b/upload/images/icons/country/sr.png new file mode 100644 index 00000000..5eff9271 Binary files /dev/null and b/upload/images/icons/country/sr.png differ diff --git a/upload/images/icons/country/st.png b/upload/images/icons/country/st.png new file mode 100644 index 00000000..2978557b Binary files /dev/null and b/upload/images/icons/country/st.png differ diff --git a/upload/images/icons/country/sv.png b/upload/images/icons/country/sv.png new file mode 100644 index 00000000..24987990 Binary files /dev/null and b/upload/images/icons/country/sv.png differ diff --git a/upload/images/icons/country/sy.png b/upload/images/icons/country/sy.png new file mode 100644 index 00000000..f5ce30dc Binary files /dev/null and b/upload/images/icons/country/sy.png differ diff --git a/upload/images/icons/country/sz.png b/upload/images/icons/country/sz.png new file mode 100644 index 00000000..914ee861 Binary files /dev/null and b/upload/images/icons/country/sz.png differ diff --git a/upload/images/icons/country/tc.png b/upload/images/icons/country/tc.png new file mode 100644 index 00000000..8fc1156b Binary files /dev/null and b/upload/images/icons/country/tc.png differ diff --git a/upload/images/icons/country/td.png b/upload/images/icons/country/td.png new file mode 100644 index 00000000..667f21fd Binary files /dev/null and b/upload/images/icons/country/td.png differ diff --git a/upload/images/icons/country/tf.png b/upload/images/icons/country/tf.png new file mode 100644 index 00000000..80529a43 Binary files /dev/null and b/upload/images/icons/country/tf.png differ diff --git a/upload/images/icons/country/tg.png b/upload/images/icons/country/tg.png new file mode 100644 index 00000000..3aa00ad4 Binary files /dev/null and b/upload/images/icons/country/tg.png differ diff --git a/upload/images/icons/country/th.png b/upload/images/icons/country/th.png new file mode 100644 index 00000000..dd8ba917 Binary files /dev/null and b/upload/images/icons/country/th.png differ diff --git a/upload/images/icons/country/tj.png b/upload/images/icons/country/tj.png new file mode 100644 index 00000000..617bf645 Binary files /dev/null and b/upload/images/icons/country/tj.png differ diff --git a/upload/images/icons/country/tk.png b/upload/images/icons/country/tk.png new file mode 100644 index 00000000..67b8c8cb Binary files /dev/null and b/upload/images/icons/country/tk.png differ diff --git a/upload/images/icons/country/tl.png b/upload/images/icons/country/tl.png new file mode 100644 index 00000000..77da181e Binary files /dev/null and b/upload/images/icons/country/tl.png differ diff --git a/upload/images/icons/country/tm.png b/upload/images/icons/country/tm.png new file mode 100644 index 00000000..828020ec Binary files /dev/null and b/upload/images/icons/country/tm.png differ diff --git a/upload/images/icons/country/tn.png b/upload/images/icons/country/tn.png new file mode 100644 index 00000000..183cdd3d Binary files /dev/null and b/upload/images/icons/country/tn.png differ diff --git a/upload/images/icons/country/to.png b/upload/images/icons/country/to.png new file mode 100644 index 00000000..f89b8ba7 Binary files /dev/null and b/upload/images/icons/country/to.png differ diff --git a/upload/images/icons/country/tr.png b/upload/images/icons/country/tr.png new file mode 100644 index 00000000..be32f77e Binary files /dev/null and b/upload/images/icons/country/tr.png differ diff --git a/upload/images/icons/country/tt.png b/upload/images/icons/country/tt.png new file mode 100644 index 00000000..2a11c1e2 Binary files /dev/null and b/upload/images/icons/country/tt.png differ diff --git a/upload/images/icons/country/tv.png b/upload/images/icons/country/tv.png new file mode 100644 index 00000000..28274c5f Binary files /dev/null and b/upload/images/icons/country/tv.png differ diff --git a/upload/images/icons/country/tw.png b/upload/images/icons/country/tw.png new file mode 100644 index 00000000..f31c654c Binary files /dev/null and b/upload/images/icons/country/tw.png differ diff --git a/upload/images/icons/country/tz.png b/upload/images/icons/country/tz.png new file mode 100644 index 00000000..c00ff796 Binary files /dev/null and b/upload/images/icons/country/tz.png differ diff --git a/upload/images/icons/country/ua.png b/upload/images/icons/country/ua.png new file mode 100644 index 00000000..09563a21 Binary files /dev/null and b/upload/images/icons/country/ua.png differ diff --git a/upload/images/icons/country/ug.png b/upload/images/icons/country/ug.png new file mode 100644 index 00000000..33f4affa Binary files /dev/null and b/upload/images/icons/country/ug.png differ diff --git a/upload/images/icons/country/uk.png b/upload/images/icons/country/uk.png new file mode 100644 index 00000000..ff701e19 Binary files /dev/null and b/upload/images/icons/country/uk.png differ diff --git a/upload/images/icons/country/um.png b/upload/images/icons/country/um.png new file mode 100644 index 00000000..c1dd9654 Binary files /dev/null and b/upload/images/icons/country/um.png differ diff --git a/upload/images/icons/country/us.png b/upload/images/icons/country/us.png new file mode 100644 index 00000000..10f451fe Binary files /dev/null and b/upload/images/icons/country/us.png differ diff --git a/upload/images/icons/country/uy.png b/upload/images/icons/country/uy.png new file mode 100644 index 00000000..31d948a0 Binary files /dev/null and b/upload/images/icons/country/uy.png differ diff --git a/upload/images/icons/country/uz.png b/upload/images/icons/country/uz.png new file mode 100644 index 00000000..fef5dc17 Binary files /dev/null and b/upload/images/icons/country/uz.png differ diff --git a/upload/images/icons/country/va.png b/upload/images/icons/country/va.png new file mode 100644 index 00000000..b31eaf22 Binary files /dev/null and b/upload/images/icons/country/va.png differ diff --git a/upload/images/icons/country/vc.png b/upload/images/icons/country/vc.png new file mode 100644 index 00000000..8fa17b06 Binary files /dev/null and b/upload/images/icons/country/vc.png differ diff --git a/upload/images/icons/country/ve.png b/upload/images/icons/country/ve.png new file mode 100644 index 00000000..00c90f9a Binary files /dev/null and b/upload/images/icons/country/ve.png differ diff --git a/upload/images/icons/country/vg.png b/upload/images/icons/country/vg.png new file mode 100644 index 00000000..41569079 Binary files /dev/null and b/upload/images/icons/country/vg.png differ diff --git a/upload/images/icons/country/vi.png b/upload/images/icons/country/vi.png new file mode 100644 index 00000000..ed26915a Binary files /dev/null and b/upload/images/icons/country/vi.png differ diff --git a/upload/images/icons/country/vn.png b/upload/images/icons/country/vn.png new file mode 100644 index 00000000..ec7cd48a Binary files /dev/null and b/upload/images/icons/country/vn.png differ diff --git a/upload/images/icons/country/vu.png b/upload/images/icons/country/vu.png new file mode 100644 index 00000000..b3397bc6 Binary files /dev/null and b/upload/images/icons/country/vu.png differ diff --git a/upload/images/icons/country/wf.png b/upload/images/icons/country/wf.png new file mode 100644 index 00000000..9f955873 Binary files /dev/null and b/upload/images/icons/country/wf.png differ diff --git a/upload/images/icons/country/ws.png b/upload/images/icons/country/ws.png new file mode 100644 index 00000000..c1695080 Binary files /dev/null and b/upload/images/icons/country/ws.png differ diff --git a/upload/images/icons/country/ye.png b/upload/images/icons/country/ye.png new file mode 100644 index 00000000..468dfad0 Binary files /dev/null and b/upload/images/icons/country/ye.png differ diff --git a/upload/images/icons/country/yt.png b/upload/images/icons/country/yt.png new file mode 100644 index 00000000..c298f378 Binary files /dev/null and b/upload/images/icons/country/yt.png differ diff --git a/upload/images/icons/country/za.png b/upload/images/icons/country/za.png new file mode 100644 index 00000000..57c58e21 Binary files /dev/null and b/upload/images/icons/country/za.png differ diff --git a/upload/images/icons/country/zm.png b/upload/images/icons/country/zm.png new file mode 100644 index 00000000..c25b07be Binary files /dev/null and b/upload/images/icons/country/zm.png differ diff --git a/upload/images/icons/country/zw.png b/upload/images/icons/country/zw.png new file mode 100644 index 00000000..53c97259 Binary files /dev/null and b/upload/images/icons/country/zw.png differ diff --git a/upload/images/icons/error.png b/upload/images/icons/error.png new file mode 100644 index 00000000..628cf2da Binary files /dev/null and b/upload/images/icons/error.png differ diff --git a/upload/images/icons/ico_lightsoff.gif b/upload/images/icons/ico_lightsoff.gif new file mode 100644 index 00000000..5caf4b3c Binary files /dev/null and b/upload/images/icons/ico_lightsoff.gif differ diff --git a/upload/images/icons/info.png b/upload/images/icons/info.png new file mode 100644 index 00000000..12cd1aef Binary files /dev/null and b/upload/images/icons/info.png differ diff --git a/upload/images/icons/no_thumb.png b/upload/images/icons/no_thumb.png new file mode 100644 index 00000000..336f3ada Binary files /dev/null and b/upload/images/icons/no_thumb.png differ diff --git a/upload/images/icons/no_thumb_player.png b/upload/images/icons/no_thumb_player.png new file mode 100644 index 00000000..7add40b6 Binary files /dev/null and b/upload/images/icons/no_thumb_player.png differ diff --git a/upload/images/icons/no_thumb_template.png b/upload/images/icons/no_thumb_template.png new file mode 100644 index 00000000..c3d25060 Binary files /dev/null and b/upload/images/icons/no_thumb_template.png differ diff --git a/upload/images/icons/progIndicator.gif b/upload/images/icons/progIndicator.gif new file mode 100644 index 00000000..c1eb1c9a Binary files /dev/null and b/upload/images/icons/progIndicator.gif differ diff --git a/upload/images/icons/settings.gif b/upload/images/icons/settings.gif new file mode 100644 index 00000000..7a08bf03 Binary files /dev/null and b/upload/images/icons/settings.gif differ diff --git a/upload/images/icons/topic_icons/award_star_silver_3.png b/upload/images/icons/topic_icons/award_star_silver_3.png new file mode 100644 index 00000000..58a538dc Binary files /dev/null and b/upload/images/icons/topic_icons/award_star_silver_3.png differ diff --git a/upload/images/icons/topic_icons/bell.png b/upload/images/icons/topic_icons/bell.png new file mode 100644 index 00000000..663e246b Binary files /dev/null and b/upload/images/icons/topic_icons/bell.png differ diff --git a/upload/images/icons/topic_icons/book_open.png b/upload/images/icons/topic_icons/book_open.png new file mode 100644 index 00000000..1086fbeb Binary files /dev/null and b/upload/images/icons/topic_icons/book_open.png differ diff --git a/upload/images/icons/topic_icons/cake.png b/upload/images/icons/topic_icons/cake.png new file mode 100644 index 00000000..25c27e0e Binary files /dev/null and b/upload/images/icons/topic_icons/cake.png differ diff --git a/upload/images/icons/topic_icons/camera.png b/upload/images/icons/topic_icons/camera.png new file mode 100644 index 00000000..e8608c23 Binary files /dev/null and b/upload/images/icons/topic_icons/camera.png differ diff --git a/upload/images/icons/topic_icons/cart.png b/upload/images/icons/topic_icons/cart.png new file mode 100644 index 00000000..9130dffb Binary files /dev/null and b/upload/images/icons/topic_icons/cart.png differ diff --git a/upload/images/icons/topic_icons/comment.png b/upload/images/icons/topic_icons/comment.png new file mode 100644 index 00000000..30968ff5 Binary files /dev/null and b/upload/images/icons/topic_icons/comment.png differ diff --git a/upload/images/icons/topic_icons/dot.gif b/upload/images/icons/topic_icons/dot.gif new file mode 100644 index 00000000..35d42e80 Binary files /dev/null and b/upload/images/icons/topic_icons/dot.gif differ diff --git a/upload/images/icons/topic_icons/emotion_grin.png b/upload/images/icons/topic_icons/emotion_grin.png new file mode 100644 index 00000000..97626625 Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_grin.png differ diff --git a/upload/images/icons/topic_icons/emotion_happy.png b/upload/images/icons/topic_icons/emotion_happy.png new file mode 100644 index 00000000..515f90d9 Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_happy.png differ diff --git a/upload/images/icons/topic_icons/emotion_smile.png b/upload/images/icons/topic_icons/emotion_smile.png new file mode 100644 index 00000000..ad09a526 Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_smile.png differ diff --git a/upload/images/icons/topic_icons/emotion_suprised.png b/upload/images/icons/topic_icons/emotion_suprised.png new file mode 100644 index 00000000..fa50968c Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_suprised.png differ diff --git a/upload/images/icons/topic_icons/emotion_tongue.png b/upload/images/icons/topic_icons/emotion_tongue.png new file mode 100644 index 00000000..d728e8e5 Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_tongue.png differ diff --git a/upload/images/icons/topic_icons/emotion_wink.png b/upload/images/icons/topic_icons/emotion_wink.png new file mode 100644 index 00000000..87f3dfc4 Binary files /dev/null and b/upload/images/icons/topic_icons/emotion_wink.png differ diff --git a/upload/images/icons/topic_icons/error.png b/upload/images/icons/topic_icons/error.png new file mode 100644 index 00000000..14776e2d Binary files /dev/null and b/upload/images/icons/topic_icons/error.png differ diff --git a/upload/images/icons/topic_icons/newspaper.png b/upload/images/icons/topic_icons/newspaper.png new file mode 100644 index 00000000..06a2902f Binary files /dev/null and b/upload/images/icons/topic_icons/newspaper.png differ diff --git a/upload/images/icons/topic_icons/television.png b/upload/images/icons/topic_icons/television.png new file mode 100644 index 00000000..40116333 Binary files /dev/null and b/upload/images/icons/topic_icons/television.png differ diff --git a/upload/images/logo.png b/upload/images/logo.png new file mode 100644 index 00000000..9ea2109a Binary files /dev/null and b/upload/images/logo.png differ diff --git a/upload/includes/.htaccess b/upload/includes/.htaccess new file mode 100644 index 00000000..e69de29b diff --git a/upload/includes/active.php b/upload/includes/active.php new file mode 100644 index 00000000..e6dd20b2 --- /dev/null +++ b/upload/includes/active.php @@ -0,0 +1,32 @@ +register_function('current_page','current_page'); + +?> \ No newline at end of file diff --git a/upload/includes/admin.functions.php b/upload/includes/admin.functions.php new file mode 100644 index 00000000..e2aba87f --- /dev/null +++ b/upload/includes/admin.functions.php @@ -0,0 +1,28 @@ +Edit Video'; + } + + function show_view_channel_link($data) + { + echo 'Edit User'; + } + + register_anchor_function('show_video_admin_link','watch_admin_options'); + register_anchor_function('show_view_channel_link','view_channel_admin_options'); +} + +?> \ No newline at end of file diff --git a/upload/includes/admin_config.php b/upload/includes/admin_config.php new file mode 100644 index 00000000..2be09c4b --- /dev/null +++ b/upload/includes/admin_config.php @@ -0,0 +1,78 @@ +update(tbl("config"),array("value"),array($num)," name='admin_pages'"); + $ClipBucket->configs = $Cbucket->configs = $Cbucket->get_configs(); + } + + define('RESULTS', $admin_pages); + Assign('admin_pages',$admin_pages); + + //Do No Edit Below This Line + + define('TEMPLATEDIR',BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/cbv2'); + define('SITETEMPLATEDIR',BASEDIR.'/'.TEMPLATEFOLDER.'/'.$row['template_dir']); + define('TEMPLATEURL',BASEURL.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/cbv2'); + define('LAYOUT',TEMPLATEDIR.'/layout'); + + define('TEMPLATE',$row['template_dir']); + + + + Assign('baseurl',BASEURL); + Assign('admindir',ADMINDIR); + Assign('imageurl',TEMPLATEURL.'/images'); + Assign('layout',TEMPLATEURL.'/layout'); + Assign('theme',TEMPLATEURL.'/theme'); + Assign('style_dir',LAYOUT); + + + Assign('logged_user',@$_SESSION['username']); + Assign('superadmin',@$_SESSION['superadmin']); + + $AdminArea = true; + + //Including Plugins + include('plugins.php'); + + //Including Flv Players + include('flv_player.php'); + + +$Smarty->assign_by_ref('cbmass',$cbmass) + +?> \ No newline at end of file diff --git a/upload/includes/adminfunctions.php b/upload/includes/adminfunctions.php new file mode 100644 index 00000000..369f2712 --- /dev/null +++ b/upload/includes/adminfunctions.php @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/upload/includes/adodb/adodb-active-record.inc.php b/upload/includes/adodb/adodb-active-record.inc.php new file mode 100644 index 00000000..92836be7 --- /dev/null +++ b/upload/includes/adodb/adodb-active-record.inc.php @@ -0,0 +1,626 @@ +_dbat +$_ADODB_ACTIVE_DBS = array(); +$ACTIVE_RECORD_SAFETY = true; + +class ADODB_Active_DB { + var $db; // ADOConnection + var $tables; // assoc array of ADODB_Active_Table objects, indexed by tablename +} + +class ADODB_Active_Table { + var $name; // table name + var $flds; // assoc array of adofieldobjs, indexed by fieldname + var $keys; // assoc array of primary keys, indexed by fieldname + var $_created; // only used when stored as a cached file +} + +// returns index into $_ADODB_ACTIVE_DBS +function ADODB_SetDatabaseAdapter(&$db) +{ + global $_ADODB_ACTIVE_DBS; + + foreach($_ADODB_ACTIVE_DBS as $k => $d) { + if (PHP_VERSION >= 5) { + if ($d->db === $db) return $k; + } else { + if ($d->db->_connectionID === $db->_connectionID && $db->database == $d->db->database) + return $k; + } + } + + $obj = new ADODB_Active_DB(); + $obj->db =& $db; + $obj->tables = array(); + + $_ADODB_ACTIVE_DBS[] = $obj; + + return sizeof($_ADODB_ACTIVE_DBS)-1; +} + + +class ADODB_Active_Record { + var $_dbat; // associative index pointing to ADODB_Active_DB eg. $ADODB_Active_DBS[_dbat] + var $_table; // tablename, if set in class definition then use it as table name + var $_tableat; // associative index pointing to ADODB_Active_Table, eg $ADODB_Active_DBS[_dbat]->tables[$this->_tableat] + var $_where; // where clause set in Load() + var $_saved = false; // indicates whether data is already inserted. + var $_lasterr = false; // last error message + var $_original = false; // the original values loaded or inserted, refreshed on update + + // should be static + function SetDatabaseAdapter(&$db) + { + return ADODB_SetDatabaseAdapter($db); + } + + // php4 constructor + function ADODB_Active_Record($table = false, $pkeyarr=false, $db=false) + { + ADODB_Active_Record::__construct($table,$pkeyarr,$db); + } + + // php5 constructor + function __construct($table = false, $pkeyarr=false, $db=false) + { + global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS; + + if ($db == false && is_object($pkeyarr)) { + $db = $pkeyarr; + $pkeyarr = false; + } + + if (!$table) { + if (!empty($this->_table)) $table = $this->_table; + else $table = $this->_pluralize(get_class($this)); + } + if ($db) { + $this->_dbat = ADODB_Active_Record::SetDatabaseAdapter($db); + } else + $this->_dbat = sizeof($_ADODB_ACTIVE_DBS)-1; + + + if ($this->_dbat < 0) $this->Error("No database connection set; use ADOdb_Active_Record::SetDatabaseAdapter(\$db)",'ADODB_Active_Record::__constructor'); + + $this->_table = $table; + $this->_tableat = $table; # reserved for setting the assoc value to a non-table name, eg. the sql string in future + $this->UpdateActiveTable($pkeyarr); + } + + function __wakeup() + { + $class = get_class($this); + new $class; + } + + function _pluralize($table) + { + $ut = strtoupper($table); + $len = strlen($table); + $lastc = $ut[$len-1]; + $lastc2 = substr($ut,$len-2); + switch ($lastc) { + case 'S': + return $table.'es'; + case 'Y': + return substr($table,0,$len-1).'ies'; + case 'X': + return $table.'es'; + case 'H': + if ($lastc2 == 'CH' || $lastc2 == 'SH') + return $table.'es'; + default: + return $table.'s'; + } + } + + ////////////////////////////////// + + // update metadata + function UpdateActiveTable($pkeys=false,$forceUpdate=false) + { + global $ADODB_ASSOC_CASE,$_ADODB_ACTIVE_DBS , $ADODB_CACHE_DIR, $ADODB_ACTIVE_CACHESECS; + + $activedb =& $_ADODB_ACTIVE_DBS[$this->_dbat]; + + $table = $this->_table; + $tables = $activedb->tables; + $tableat = $this->_tableat; + if (!$forceUpdate && !empty($tables[$tableat])) { + $tobj =& $tables[$tableat]; + foreach($tobj->flds as $name => $fld) + $this->$name = null; + return; + } + + $db =& $activedb->db; + $fname = $ADODB_CACHE_DIR . '/adodb_' . $db->databaseType . '_active_'. $table . '.cache'; + if (!$forceUpdate && $ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR && file_exists($fname)) { + $fp = fopen($fname,'r'); + @flock($fp, LOCK_SH); + $acttab = unserialize(fread($fp,100000)); + fclose($fp); + if ($acttab->_created + $ADODB_ACTIVE_CACHESECS - (abs(rand()) % 16) > time()) { + // abs(rand()) randomizes deletion, reducing contention to delete/refresh file + // ideally, you should cache at least 32 secs + $activedb->tables[$table] = $acttab; + + //if ($db->debug) ADOConnection::outp("Reading cached active record file: $fname"); + return; + } else if ($db->debug) { + ADOConnection::outp("Refreshing cached active record file: $fname"); + } + } + $activetab = new ADODB_Active_Table(); + $activetab->name = $table; + + + $cols = $db->MetaColumns($table); + if (!$cols) { + $this->Error("Invalid table name: $table",'UpdateActiveTable'); + return false; + } + $fld = reset($cols); + if (!$pkeys) { + if (isset($fld->primary_key)) { + $pkeys = array(); + foreach($cols as $name => $fld) { + if (!empty($fld->primary_key)) $pkeys[] = $name; + } + } else + $pkeys = $this->GetPrimaryKeys($db, $table); + } + if (empty($pkeys)) { + $this->Error("No primary key found for table $table",'UpdateActiveTable'); + return false; + } + + $attr = array(); + $keys = array(); + + switch($ADODB_ASSOC_CASE) { + case 0: + foreach($cols as $name => $fldobj) { + $name = strtolower($name); + $this->$name = null; + $attr[$name] = $fldobj; + } + foreach($pkeys as $k => $name) { + $keys[strtolower($name)] = strtolower($name); + } + break; + + case 1: + foreach($cols as $name => $fldobj) { + $name = strtoupper($name); + $this->$name = null; + $attr[$name] = $fldobj; + } + + foreach($pkeys as $k => $name) { + $keys[strtoupper($name)] = strtoupper($name); + } + break; + default: + foreach($cols as $name => $fldobj) { + $name = ($fldobj->name); + $this->$name = null; + $attr[$name] = $fldobj; + } + foreach($pkeys as $k => $name) { + $keys[$name] = $cols[$name]->name; + } + break; + } + + $activetab->keys = $keys; + $activetab->flds = $attr; + + if ($ADODB_ACTIVE_CACHESECS && $ADODB_CACHE_DIR) { + $activetab->_created = time(); + $s = serialize($activetab); + if (!function_exists('adodb_write_file')) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + adodb_write_file($fname,$s); + } + $activedb->tables[$table] = $activetab; + } + + function GetPrimaryKeys(&$db, $table) + { + return $db->MetaPrimaryKeys($table); + } + + // error handler for both PHP4+5. + function Error($err,$fn) + { + global $_ADODB_ACTIVE_DBS; + + $fn = get_class($this).'::'.$fn; + $this->_lasterr = $fn.': '.$err; + + if ($this->_dbat < 0) $db = false; + else { + $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; + $db =& $activedb->db; + } + + if (function_exists('adodb_throw')) { + if (!$db) adodb_throw('ADOdb_Active_Record', $fn, -1, $err, 0, 0, false); + else adodb_throw($db->databaseType, $fn, -1, $err, 0, 0, $db); + } else + if (!$db || $db->debug) ADOConnection::outp($this->_lasterr); + + } + + // return last error message + function ErrorMsg() + { + if (!function_exists('adodb_throw')) { + if ($this->_dbat < 0) $db = false; + else $db = $this->DB(); + + // last error could be database error too + if ($db && $db->ErrorMsg()) return $db->ErrorMsg(); + } + return $this->_lasterr; + } + + function ErrorNo() + { + if ($this->_dbat < 0) return -9999; // no database connection... + $db = $this->DB(); + + return (int) $db->ErrorNo(); + } + + + // retrieve ADOConnection from _ADODB_Active_DBs + function &DB() + { + global $_ADODB_ACTIVE_DBS; + + if ($this->_dbat < 0) { + $false = false; + $this->Error("No database connection set: use ADOdb_Active_Record::SetDatabaseAdaptor(\$db)", "DB"); + return $false; + } + $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; + $db =& $activedb->db; + return $db; + } + + // retrieve ADODB_Active_Table + function &TableInfo() + { + global $_ADODB_ACTIVE_DBS; + + $activedb = $_ADODB_ACTIVE_DBS[$this->_dbat]; + $table =& $activedb->tables[$this->_tableat]; + return $table; + } + + // set a numeric array (using natural table field ordering) as object properties + function Set(&$row) + { + global $ACTIVE_RECORD_SAFETY; + + $db =& $this->DB(); + + if (!$row) { + $this->_saved = false; + return false; + } + + $this->_saved = true; + + $table =& $this->TableInfo(); + if ($ACTIVE_RECORD_SAFETY && sizeof($table->flds) != sizeof($row)) { + $this->Error("Table structure of $this->_table has changed","Load"); + return false; + } + + $keys = array_keys($row); + $cnt = 0; + foreach($table->flds as $name=>$fld) { + $this->$name = $row[$keys[$cnt]]; + $cnt += 1; + } + $this->_original = $row; + return true; + } + + // get last inserted id for INSERT + function LastInsertID(&$db,$fieldname) + { + if ($db->hasInsertID) + $val = $db->Insert_ID($this->_table,$fieldname); + else + $val = false; + + if (is_null($val) || $val === false) { + // this might not work reliably in multi-user environment + return $db->GetOne("select max(".$fieldname.") from ".$this->_table); + } + return $val; + } + + // quote data in where clause + function doquote(&$db, $val,$t) + { + switch($t) { + case 'D': + case 'T': + if (empty($val)) return 'null'; + + case 'C': + case 'X': + if (is_null($val)) return 'null'; + + if (strncmp($val,"'",1) != 0 && substr($val,strlen($val)-1,1) != "'") { + return $db->qstr($val); + break; + } + default: + return $val; + break; + } + } + + // generate where clause for an UPDATE/SELECT + function GenWhere(&$db, &$table) + { + $keys = $table->keys; + $parr = array(); + + foreach($keys as $k) { + $f = $table->flds[$k]; + if ($f) { + $parr[] = $k.' = '.$this->doquote($db,$this->$k,$db->MetaType($f->type)); + } + } + return implode(' and ', $parr); + } + + + //------------------------------------------------------------ Public functions below + + function Load($where,$bindarr=false) + { + $db =& $this->DB(); if (!$db) return false; + $this->_where = $where; + + $save = $db->SetFetchMode(ADODB_FETCH_NUM); + $row = $db->GetRow("select * from ".$this->_table.' WHERE '.$where,$bindarr); + $db->SetFetchMode($save); + + return $this->Set($row); + } + + // false on error + function Save() + { + if ($this->_saved) $ok = $this->Update(); + else $ok = $this->Insert(); + + return $ok; + } + + // false on error + function Insert() + { + $db =& $this->DB(); if (!$db) return false; + $cnt = 0; + $table =& $this->TableInfo(); + + $valarr = array(); + $names = array(); + $valstr = array(); + + foreach($table->flds as $name=>$fld) { + $val = $this->$name; + if(!is_null($val) || !array_key_exists($name, $table->keys)) { + $valarr[] = $val; + $names[] = $name; + $valstr[] = $db->Param($cnt); + $cnt += 1; + } + } + + if (empty($names)){ + foreach($table->flds as $name=>$fld) { + $valarr[] = null; + $names[] = $name; + $valstr[] = $db->Param($cnt); + $cnt += 1; + } + } + $sql = 'INSERT INTO '.$this->_table."(".implode(',',$names).') VALUES ('.implode(',',$valstr).')'; + $ok = $db->Execute($sql,$valarr); + + if ($ok) { + $this->_saved = true; + $autoinc = false; + foreach($table->keys as $k) { + if (is_null($this->$k)) { + $autoinc = true; + break; + } + } + if ($autoinc && sizeof($table->keys) == 1) { + $k = reset($table->keys); + $this->$k = $this->LastInsertID($db,$k); + } + } + + $this->_original = $valarr; + return !empty($ok); + } + + function Delete() + { + $db =& $this->DB(); if (!$db) return false; + $table =& $this->TableInfo(); + + $where = $this->GenWhere($db,$table); + $sql = 'DELETE FROM '.$this->_table.' WHERE '.$where; + $ok = $db->Execute($sql); + + return $ok ? true : false; + } + + // returns an array of active record objects + function &Find($whereOrderBy,$bindarr=false,$pkeysArr=false) + { + $db =& $this->DB(); if (!$db || empty($this->_table)) return false; + $arr =& $db->GetActiveRecordsClass(get_class($this),$this->_table, $whereOrderBy,$bindarr,$pkeysArr); + return $arr; + } + + // returns 0 on error, 1 on update, 2 on insert + function Replace() + { + global $ADODB_ASSOC_CASE; + + $db =& $this->DB(); if (!$db) return false; + $table =& $this->TableInfo(); + + $pkey = $table->keys; + + foreach($table->flds as $name=>$fld) { + $val = $this->$name; + /* + if (is_null($val)) { + if (isset($fld->not_null) && $fld->not_null) { + if (isset($fld->default_value) && strlen($fld->default_value)) continue; + else { + $this->Error("Cannot update null into $name","Replace"); + return false; + } + } + }*/ + if (is_null($val) && !empty($fld->auto_increment)) { + continue; + } + $t = $db->MetaType($fld->type); + $arr[$name] = $this->doquote($db,$val,$t); + $valarr[] = $val; + } + + if (!is_array($pkey)) $pkey = array($pkey); + + + if ($ADODB_ASSOC_CASE == 0) + foreach($pkey as $k => $v) + $pkey[$k] = strtolower($v); + elseif ($ADODB_ASSOC_CASE == 0) + foreach($pkey as $k => $v) + $pkey[$k] = strtoupper($v); + + $ok = $db->Replace($this->_table,$arr,$pkey); + if ($ok) { + $this->_saved = true; // 1= update 2=insert + if ($ok == 2) { + $autoinc = false; + foreach($table->keys as $k) { + if (is_null($this->$k)) { + $autoinc = true; + break; + } + } + if ($autoinc && sizeof($table->keys) == 1) { + $k = reset($table->keys); + $this->$k = $this->LastInsertID($db,$k); + } + } + + $this->_original =& $valarr; + } + return $ok; + } + + // returns 0 on error, 1 on update, -1 if no change in data (no update) + function Update() + { + $db =& $this->DB(); if (!$db) return false; + $table =& $this->TableInfo(); + + $where = $this->GenWhere($db, $table); + + if (!$where) { + $this->error("Where missing for table $table", "Update"); + return false; + } + $valarr = array(); + $neworig = array(); + $pairs = array(); + $i = -1; + $cnt = 0; + foreach($table->flds as $name=>$fld) { + $i += 1; + $val = $this->$name; + $neworig[] = $val; + + if (isset($table->keys[$name])) { + continue; + } + + if (is_null($val)) { + if (isset($fld->not_null) && $fld->not_null) { + if (isset($fld->default_value) && strlen($fld->default_value)) continue; + else { + $this->Error("Cannot set field $name to NULL","Update"); + return false; + } + } + } + + if (isset($this->_original[$i]) && $val == $this->_original[$i]) { + continue; + } + $valarr[] = $val; + $pairs[] = $name.'='.$db->Param($cnt); + $cnt += 1; + } + + + if (!$cnt) return -1; + $sql = 'UPDATE '.$this->_table." SET ".implode(",",$pairs)." WHERE ".$where; + $ok = $db->Execute($sql,$valarr); + if ($ok) { + $this->_original =& $neworig; + return 1; + } + return 0; + } + + function GetAttributeNames() + { + $table =& $this->TableInfo(); + if (!$table) return false; + return array_keys($table->flds); + } + +}; + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-csvlib.inc.php b/upload/includes/adodb/adodb-csvlib.inc.php new file mode 100644 index 00000000..5662b6e0 --- /dev/null +++ b/upload/includes/adodb/adodb-csvlib.inc.php @@ -0,0 +1,312 @@ +FieldCount() : 0; + + if ($sql) $sql = urlencode($sql); + // metadata setup + + if ($max <= 0 || $rs->dataProvider == 'empty') { // is insert/update/delete + if (is_object($conn)) { + $sql .= ','.$conn->Affected_Rows(); + $sql .= ','.$conn->Insert_ID(); + } else + $sql .= ',,'; + + $text = "====-1,0,$sql\n"; + return $text; + } + $tt = ($rs->timeCreated) ? $rs->timeCreated : time(); + + ## changed format from ====0 to ====1 + $line = "====1,$tt,$sql\n"; + + if ($rs->databaseType == 'array') { + $rows =& $rs->_array; + } else { + $rows = array(); + while (!$rs->EOF) { + $rows[] = $rs->fields; + $rs->MoveNext(); + } + } + + for($i=0; $i < $max; $i++) { + $o =& $rs->FetchField($i); + $flds[] = $o; + } + + $savefetch = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode; + $class = $rs->connection->arrayClass; + $rs2 = new $class(); + $rs2->sql = $rs->sql; + $rs2->oldProvider = $rs->dataProvider; + $rs2->InitArrayFields($rows,$flds); + $rs2->fetchMode = $savefetch; + return $line.serialize($rs2); + } + + +/** +* Open CSV file and convert it into Data. +* +* @param url file/ftp/http url +* @param err returns the error message +* @param timeout dispose if recordset has been alive for $timeout secs +* +* @return recordset, or false if error occured. If no +* error occurred in sql INSERT/UPDATE/DELETE, +* empty recordset is returned +*/ + function &csv2rs($url,&$err,$timeout=0, $rsclass='ADORecordSet_array') + { + $false = false; + $err = false; + $fp = @fopen($url,'rb'); + if (!$fp) { + $err = $url.' file/URL not found'; + return $false; + } + @flock($fp, LOCK_SH); + $arr = array(); + $ttl = 0; + + if ($meta = fgetcsv($fp, 32000, ",")) { + // check if error message + if (strncmp($meta[0],'****',4) === 0) { + $err = trim(substr($meta[0],4,1024)); + fclose($fp); + return $false; + } + // check for meta data + // $meta[0] is -1 means return an empty recordset + // $meta[1] contains a time + + if (strncmp($meta[0], '====',4) === 0) { + + if ($meta[0] == "====-1") { + if (sizeof($meta) < 5) { + $err = "Corrupt first line for format -1"; + fclose($fp); + return $false; + } + fclose($fp); + + if ($timeout > 0) { + $err = " Illegal Timeout $timeout "; + return $false; + } + + $rs = new $rsclass($val=true); + $rs->fields = array(); + $rs->timeCreated = $meta[1]; + $rs->EOF = true; + $rs->_numOfFields = 0; + $rs->sql = urldecode($meta[2]); + $rs->affectedrows = (integer)$meta[3]; + $rs->insertid = $meta[4]; + return $rs; + } + # Under high volume loads, we want only 1 thread/process to _write_file + # so that we don't have 50 processes queueing to write the same data. + # We use probabilistic timeout, ahead of time. + # + # -4 sec before timeout, give processes 1/32 chance of timing out + # -2 sec before timeout, give processes 1/16 chance of timing out + # -1 sec after timeout give processes 1/4 chance of timing out + # +0 sec after timeout, give processes 100% chance of timing out + if (sizeof($meta) > 1) { + if($timeout >0){ + $tdiff = (integer)( $meta[1]+$timeout - time()); + if ($tdiff <= 2) { + switch($tdiff) { + case 4: + case 3: + if ((rand() & 31) == 0) { + fclose($fp); + $err = "Timeout 3"; + return $false; + } + break; + case 2: + if ((rand() & 15) == 0) { + fclose($fp); + $err = "Timeout 2"; + return $false; + } + break; + case 1: + if ((rand() & 3) == 0) { + fclose($fp); + $err = "Timeout 1"; + return $false; + } + break; + default: + fclose($fp); + $err = "Timeout 0"; + return $false; + } // switch + + } // if check flush cache + }// (timeout>0) + $ttl = $meta[1]; + } + //================================================ + // new cache format - use serialize extensively... + if ($meta[0] === '====1') { + // slurp in the data + $MAXSIZE = 128000; + + $text = fread($fp,$MAXSIZE); + if (strlen($text)) { + while ($txt = fread($fp,$MAXSIZE)) { + $text .= $txt; + } + } + fclose($fp); + $rs = unserialize($text); + if (is_object($rs)) $rs->timeCreated = $ttl; + else { + $err = "Unable to unserialize recordset"; + //echo htmlspecialchars($text),' !--END--!

    '; + } + return $rs; + } + + $meta = false; + $meta = fgetcsv($fp, 32000, ","); + if (!$meta) { + fclose($fp); + $err = "Unexpected EOF 1"; + return $false; + } + } + + // Get Column definitions + $flds = array(); + foreach($meta as $o) { + $o2 = explode(':',$o); + if (sizeof($o2)!=3) { + $arr[] = $meta; + $flds = false; + break; + } + $fld = new ADOFieldObject(); + $fld->name = urldecode($o2[0]); + $fld->type = $o2[1]; + $fld->max_length = $o2[2]; + $flds[] = $fld; + } + } else { + fclose($fp); + $err = "Recordset had unexpected EOF 2"; + return $false; + } + + // slurp in the data + $MAXSIZE = 128000; + + $text = ''; + while ($txt = fread($fp,$MAXSIZE)) { + $text .= $txt; + } + + fclose($fp); + @$arr = unserialize($text); + //var_dump($arr); + if (!is_array($arr)) { + $err = "Recordset had unexpected EOF (in serialized recordset)"; + if (get_magic_quotes_runtime()) $err .= ". Magic Quotes Runtime should be disabled!"; + return $false; + } + $rs = new $rsclass(); + $rs->timeCreated = $ttl; + $rs->InitArrayFields($arr,$flds); + return $rs; + } + + + /** + * Save a file $filename and its $contents (normally for caching) with file locking + */ + function adodb_write_file($filename, $contents,$debug=false) + { + # http://www.php.net/bugs.php?id=9203 Bug that flock fails on Windows + # So to simulate locking, we assume that rename is an atomic operation. + # First we delete $filename, then we create a $tempfile write to it and + # rename to the desired $filename. If the rename works, then we successfully + # modified the file exclusively. + # What a stupid need - having to simulate locking. + # Risks: + # 1. $tempfile name is not unique -- very very low + # 2. unlink($filename) fails -- ok, rename will fail + # 3. adodb reads stale file because unlink fails -- ok, $rs timeout occurs + # 4. another process creates $filename between unlink() and rename() -- ok, rename() fails and cache updated + if (strncmp(PHP_OS,'WIN',3) === 0) { + // skip the decimal place + $mtime = substr(str_replace(' ','_',microtime()),2); + // getmypid() actually returns 0 on Win98 - never mind! + $tmpname = $filename.uniqid($mtime).getmypid(); + if (!($fd = @fopen($tmpname,'a'))) return false; + $ok = ftruncate($fd,0); + if (!fwrite($fd,$contents)) $ok = false; + fclose($fd); + chmod($tmpname,0644); + // the tricky moment + @unlink($filename); + if (!@rename($tmpname,$filename)) { + unlink($tmpname); + $ok = false; + } + if (!$ok) { + if ($debug) ADOConnection::outp( " Rename $tmpname ".($ok? 'ok' : 'failed')); + } + return $ok; + } + if (!($fd = @fopen($filename, 'a'))) return false; + if (flock($fd, LOCK_EX) && ftruncate($fd, 0)) { + $ok = fwrite( $fd, $contents ); + fclose($fd); + chmod($filename,0644); + }else { + fclose($fd); + if ($debug)ADOConnection::outp( " Failed acquiring lock for $filename
    \n"); + $ok = false; + } + + return $ok; + } +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-datadict.inc.php b/upload/includes/adodb/adodb-datadict.inc.php new file mode 100644 index 00000000..cadea1d8 --- /dev/null +++ b/upload/includes/adodb/adodb-datadict.inc.php @@ -0,0 +1,997 @@ +$str

    "; +$a= Lens_ParseArgs($str); +print "
    ";
    +print_r($a);
    +print "
    "; +} + + +if (!function_exists('ctype_alnum')) { + function ctype_alnum($text) { + return preg_match('/^[a-z0-9]*$/i', $text); + } +} + +//Lens_ParseTest(); + +/** + Parse arguments, treat "text" (text) and 'text' as quotation marks. + To escape, use "" or '' or )) + + Will read in "abc def" sans quotes, as: abc def + Same with 'abc def'. + However if `abc def`, then will read in as `abc def` + + @param endstmtchar Character that indicates end of statement + @param tokenchars Include the following characters in tokens apart from A-Z and 0-9 + @returns 2 dimensional array containing parsed tokens. +*/ +function Lens_ParseArgs($args,$endstmtchar=',',$tokenchars='_.-') +{ + $pos = 0; + $intoken = false; + $stmtno = 0; + $endquote = false; + $tokens = array(); + $tokens[$stmtno] = array(); + $max = strlen($args); + $quoted = false; + $tokarr = array(); + + while ($pos < $max) { + $ch = substr($args,$pos,1); + switch($ch) { + case ' ': + case "\t": + case "\n": + case "\r": + if (!$quoted) { + if ($intoken) { + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + } + break; + } + + $tokarr[] = $ch; + break; + + case '`': + if ($intoken) $tokarr[] = $ch; + case '(': + case ')': + case '"': + case "'": + + if ($intoken) { + if (empty($endquote)) { + $tokens[$stmtno][] = implode('',$tokarr); + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + } else if ($endquote == $ch) { + $ch2 = substr($args,$pos+1,1); + if ($ch2 == $endquote) { + $pos += 1; + $tokarr[] = $ch2; + } else { + $quoted = false; + $intoken = false; + $tokens[$stmtno][] = implode('',$tokarr); + $endquote = ''; + } + } else + $tokarr[] = $ch; + + }else { + + if ($ch == '(') $endquote = ')'; + else $endquote = $ch; + $quoted = true; + $intoken = true; + $tokarr = array(); + if ($ch == '`') $tokarr[] = '`'; + } + break; + + default: + + if (!$intoken) { + if ($ch == $endstmtchar) { + $stmtno += 1; + $tokens[$stmtno] = array(); + break; + } + + $intoken = true; + $quoted = false; + $endquote = false; + $tokarr = array(); + + } + + if ($quoted) $tokarr[] = $ch; + else if (ctype_alnum($ch) || strpos($tokenchars,$ch) !== false) $tokarr[] = $ch; + else { + if ($ch == $endstmtchar) { + $tokens[$stmtno][] = implode('',$tokarr); + $stmtno += 1; + $tokens[$stmtno] = array(); + $intoken = false; + $tokarr = array(); + break; + } + $tokens[$stmtno][] = implode('',$tokarr); + $tokens[$stmtno][] = $ch; + $intoken = false; + } + } + $pos += 1; + } + if ($intoken) $tokens[$stmtno][] = implode('',$tokarr); + + return $tokens; +} + + +class ADODB_DataDict { + var $connection; + var $debug = false; + var $dropTable = 'DROP TABLE %s'; + var $renameTable = 'RENAME TABLE %s TO %s'; + var $dropIndex = 'DROP INDEX %s'; + var $addCol = ' ADD'; + var $alterCol = ' ALTER COLUMN'; + var $dropCol = ' DROP COLUMN'; + var $renameColumn = 'ALTER TABLE %s RENAME COLUMN %s TO %s'; // table, old-column, new-column, column-definitions (not used by default) + var $nameRegex = '\w'; + var $nameRegexBrackets = 'a-zA-Z0-9_\(\)'; + var $schema = false; + var $serverInfo = array(); + var $autoIncrement = false; + var $dataProvider; + var $invalidResizeTypes4 = array('CLOB','BLOB','TEXT','DATE','TIME'); // for changetablesql + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob + /// in other words, we use a text area for editting. + + function GetCommentSQL($table,$col) + { + return false; + } + + function SetCommentSQL($table,$col,$cmt) + { + return false; + } + + function MetaTables() + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaTables(); + } + + function MetaColumns($tab, $upper=true, $schema=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaColumns($this->TableName($tab), $upper, $schema); + } + + function MetaPrimaryKeys($tab,$owner=false,$intkey=false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaPrimaryKeys($this->TableName($tab), $owner, $intkey); + } + + function MetaIndexes($table, $primary = false, $owner = false) + { + if (!$this->connection->IsConnected()) return array(); + return $this->connection->MetaIndexes($this->TableName($table), $primary, $owner); + } + + + function MetaType($t,$len=-1,$fieldobj=false) + { + static $typeMap = array( + 'VARCHAR' => 'C', + 'VARCHAR2' => 'C', + 'CHAR' => 'C', + 'C' => 'C', + 'STRING' => 'C', + 'NCHAR' => 'C', + 'NVARCHAR' => 'C', + 'VARYING' => 'C', + 'BPCHAR' => 'C', + 'CHARACTER' => 'C', + 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres + ## + 'LONGCHAR' => 'X', + 'TEXT' => 'X', + 'NTEXT' => 'X', + 'M' => 'X', + 'X' => 'X', + 'CLOB' => 'X', + 'NCLOB' => 'X', + 'LVARCHAR' => 'X', + ## + 'BLOB' => 'B', + 'IMAGE' => 'B', + 'BINARY' => 'B', + 'VARBINARY' => 'B', + 'LONGBINARY' => 'B', + 'B' => 'B', + ## + 'YEAR' => 'D', // mysql + 'DATE' => 'D', + 'D' => 'D', + ## + 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server + ## + 'TIME' => 'T', + 'TIMESTAMP' => 'T', + 'DATETIME' => 'T', + 'TIMESTAMPTZ' => 'T', + 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql + ## + 'BOOL' => 'L', + 'BOOLEAN' => 'L', + 'BIT' => 'L', + 'L' => 'L', + ## + 'COUNTER' => 'R', + 'R' => 'R', + 'SERIAL' => 'R', // ifx + 'INT IDENTITY' => 'R', + ## + 'INT' => 'I', + 'INT2' => 'I', + 'INT4' => 'I', + 'INT8' => 'I', + 'INTEGER' => 'I', + 'INTEGER UNSIGNED' => 'I', + 'SHORT' => 'I', + 'TINYINT' => 'I', + 'SMALLINT' => 'I', + 'I' => 'I', + ## + 'LONG' => 'N', // interbase is numeric, oci8 is blob + 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers + 'DECIMAL' => 'N', + 'DEC' => 'N', + 'REAL' => 'N', + 'DOUBLE' => 'N', + 'DOUBLE PRECISION' => 'N', + 'SMALLFLOAT' => 'N', + 'FLOAT' => 'N', + 'NUMBER' => 'N', + 'NUM' => 'N', + 'NUMERIC' => 'N', + 'MONEY' => 'N', + + ## informix 9.2 + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X', + ## informix 10 + "SQLINT8" => 'I8', + "SQLSERIAL8" => 'I8', + "SQLNCHAR" => 'C', + "SQLNVCHAR" => 'C', + "SQLLVARCHAR" => 'X', + "SQLBOOL" => 'L' + ); + + if (!$this->connection->IsConnected()) { + $t = strtoupper($t); + if (isset($typeMap[$t])) return $typeMap[$t]; + return 'N'; + } + return $this->connection->MetaType($t,$len,$fieldobj); + } + + function NameQuote($name = NULL,$allowBrackets=false) + { + if (!is_string($name)) { + return FALSE; + } + + $name = trim($name); + + if ( !is_object($this->connection) ) { + return $name; + } + + $quote = $this->connection->nameQuote; + + // if name is of the form `name`, quote it + if ( preg_match('/^`(.+)`$/', $name, $matches) ) { + return $quote . $matches[1] . $quote; + } + + // if name contains special characters, quote it + $regex = ($allowBrackets) ? $this->nameRegexBrackets : $this->nameRegex; + + if ( !preg_match('/^[' . $regex . ']+$/', $name) ) { + return $quote . $name . $quote; + } + + return $name; + } + + function TableName($name) + { + if ( $this->schema ) { + return $this->NameQuote($this->schema) .'.'. $this->NameQuote($name); + } + return $this->NameQuote($name); + } + + // Executes the sql array returned by GetTableSQL and GetIndexSQL + function ExecuteSQLArray($sql, $continueOnError = true) + { + $rez = 2; + $conn = &$this->connection; + $saved = $conn->debug; + foreach($sql as $line) { + + if ($this->debug) $conn->debug = true; + $ok = $conn->Execute($line); + $conn->debug = $saved; + if (!$ok) { + if ($this->debug) ADOConnection::outp($conn->ErrorMsg()); + if (!$continueOnError) return 0; + $rez = 1; + } + } + return $rez; + } + + /** + Returns the actual type given a character code. + + C: varchar + X: CLOB (character large object) or largest varchar size if CLOB is not supported + C2: Multibyte varchar + X2: Multibyte CLOB + + B: BLOB (binary large object) + + D: Date + T: Date-time + L: Integer field suitable for storing booleans (0 or 1) + I: Integer + F: Floating point number + N: Numeric or decimal number + */ + + function ActualType($meta) + { + return $meta; + } + + function CreateDatabase($dbname,$options=false) + { + $options = $this->_Options($options); + $sql = array(); + + $s = 'CREATE DATABASE ' . $this->NameQuote($dbname); + if (isset($options[$this->upperName])) + $s .= ' '.$options[$this->upperName]; + + $sql[] = $s; + return $sql; + } + + /* + Generates the SQL to create index. Returns an array of sql strings. + */ + function CreateIndexSQL($idxname, $tabname, $flds, $idxoptions = false) + { + if (!is_array($flds)) { + $flds = explode(',',$flds); + } + + foreach($flds as $key => $fld) { + # some indexes can use partial fields, eg. index first 32 chars of "name" with NAME(32) + $flds[$key] = $this->NameQuote($fld,$allowBrackets=true); + } + + return $this->_IndexSQL($this->NameQuote($idxname), $this->TableName($tabname), $flds, $this->_Options($idxoptions)); + } + + function DropIndexSQL ($idxname, $tabname = NULL) + { + return array(sprintf($this->dropIndex, $this->NameQuote($idxname), $this->TableName($tabname))); + } + + function SetSchema($schema) + { + $this->schema = $schema; + } + + function AddColumnSQL($tabname, $flds) + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->addCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } + return $sql; + } + + /** + * Change the definition of one column + * + * As some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function AlterColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + $sql = array(); + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->alterCol . ' '; + foreach($lines as $v) { + $sql[] = $alter . $v; + } + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + + } + return $sql; + } + + /** + * Rename one column + * + * Some DBM's can only do this together with changeing the type of the column (even if that stays the same, eg. mysql) + * @param string $tabname table-name + * @param string $oldcolumn column-name to be renamed + * @param string $newcolumn new column-name + * @param string $flds='' complete column-defintion-string like for AddColumnSQL, only used by mysql atm., default='' + * @return array with SQL strings + */ + function RenameColumnSQL($tabname,$oldcolumn,$newcolumn,$flds='') + { + $tabname = $this->TableName ($tabname); + if ($flds) { + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + list(,$first) = each($lines); + list(,$column_def) = split("[\t ]+",$first,2); + } + return array(sprintf($this->renameColumn,$tabname,$this->NameQuote($oldcolumn),$this->NameQuote($newcolumn),$column_def)); + } + + /** + * Drop one column + * + * Some DBM's can't do that on there own, you need to supply the complete defintion of the new table, + * to allow, recreating the table and copying the content over to the new table + * @param string $tabname table-name + * @param string $flds column-name and type for the changed column + * @param string $tableflds='' complete defintion of the new table, eg. for postgres, default '' + * @param array/string $tableoptions='' options for the new table see CreateTableSQL, default '' + * @return array with SQL strings + */ + function DropColumnSQL($tabname, $flds, $tableflds='',$tableoptions='') + { + $tabname = $this->TableName ($tabname); + if (!is_array($flds)) $flds = explode(',',$flds); + $sql = array(); + $alter = 'ALTER TABLE ' . $tabname . $this->dropCol . ' '; + foreach($flds as $v) { + $sql[] = $alter . $this->NameQuote($v); + } + return $sql; + } + + function DropTableSQL($tabname) + { + return array (sprintf($this->dropTable, $this->TableName($tabname))); + } + + function RenameTableSQL($tabname,$newname) + { + return array (sprintf($this->renameTable, $this->TableName($tabname),$this->TableName($newname))); + } + + /** + Generate the SQL to create table. Returns an array of sql strings. + */ + function CreateTableSQL($tabname, $flds, $tableoptions=array()) + { + list($lines,$pkey,$idxs) = $this->_GenFields($flds, true); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + + $taboptions = $this->_Options($tableoptions); + $tabname = $this->TableName ($tabname); + $sql = $this->_TableSQL($tabname,$lines,$pkey,$taboptions); + + // ggiunta - 2006/10/12 - KLUDGE: + // if we are on autoincrement, and table options includes REPLACE, the + // autoincrement sequence has already been dropped on table creation sql, so + // we avoid passing REPLACE to trigger creation code. This prevents + // creating sql that double-drops the sequence + if ($this->autoIncrement && isset($taboptions['REPLACE'])) + unset($taboptions['REPLACE']); + $tsql = $this->_Triggers($tabname,$taboptions); + foreach($tsql as $s) $sql[] = $s; + + if (is_array($idxs)) { + foreach($idxs as $idx => $idxdef) { + $sql_idxs = $this->CreateIndexSql($idx, $tabname, $idxdef['cols'], $idxdef['opts']); + $sql = array_merge($sql, $sql_idxs); + } + } + + return $sql; + } + + function _GenFields($flds,$widespacing=false) + { + if (is_string($flds)) { + $padding = ' '; + $txt = $flds.$padding; + $flds = array(); + $flds0 = Lens_ParseArgs($txt,','); + $hasparam = false; + foreach($flds0 as $f0) { + $f1 = array(); + foreach($f0 as $token) { + switch (strtoupper($token)) { + case 'INDEX': + $f1['INDEX'] = ''; + // fall through intentionally + case 'CONSTRAINT': + case 'DEFAULT': + $hasparam = $token; + break; + default: + if ($hasparam) $f1[$hasparam] = $token; + else $f1[] = $token; + $hasparam = false; + break; + } + } + // 'index' token without a name means single column index: name it after column + if (array_key_exists('INDEX', $f1) && $f1['INDEX'] == '') { + $f1['INDEX'] = isset($f0['NAME']) ? $f0['NAME'] : $f0[0]; + // check if column name used to create an index name was quoted + if (($f1['INDEX'][0] == '"' || $f1['INDEX'][0] == "'" || $f1['INDEX'][0] == "`") && + ($f1['INDEX'][0] == substr($f1['INDEX'], -1))) { + $f1['INDEX'] = $f1['INDEX'][0].'idx_'.substr($f1['INDEX'], 1, -1).$f1['INDEX'][0]; + } + else + $f1['INDEX'] = 'idx_'.$f1['INDEX']; + } + // reset it, so we don't get next field 1st token as INDEX... + $hasparam = false; + + $flds[] = $f1; + + } + } + $this->autoIncrement = false; + $lines = array(); + $pkey = array(); + $idxs = array(); + foreach($flds as $fld) { + $fld = _array_change_key_case($fld); + + $fname = false; + $fdefault = false; + $fautoinc = false; + $ftype = false; + $fsize = false; + $fprec = false; + $fprimary = false; + $fnoquote = false; + $fdefts = false; + $fdefdate = false; + $fconstraint = false; + $fnotnull = false; + $funsigned = false; + $findex = ''; + $funiqueindex = false; + + //----------------- + // Parse attributes + foreach($fld as $attr => $v) { + if ($attr == 2 && is_numeric($v)) $attr = 'SIZE'; + else if (is_numeric($attr) && $attr > 1 && !is_numeric($v)) $attr = strtoupper($v); + + switch($attr) { + case '0': + case 'NAME': $fname = $v; break; + case '1': + case 'TYPE': $ty = $v; $ftype = $this->ActualType(strtoupper($v)); break; + + case 'SIZE': + $dotat = strpos($v,'.'); if ($dotat === false) $dotat = strpos($v,','); + if ($dotat === false) $fsize = $v; + else { + $fsize = substr($v,0,$dotat); + $fprec = substr($v,$dotat+1); + } + break; + case 'UNSIGNED': $funsigned = true; break; + case 'AUTOINCREMENT': + case 'AUTO': $fautoinc = true; $fnotnull = true; break; + case 'KEY': + // a primary key col can be non unique in itself (if key spans many cols...) + case 'PRIMARY': $fprimary = $v; $fnotnull = true; /*$funiqueindex = true;*/ break; + case 'DEF': + case 'DEFAULT': $fdefault = $v; break; + case 'NOTNULL': $fnotnull = $v; break; + case 'NOQUOTE': $fnoquote = $v; break; + case 'DEFDATE': $fdefdate = $v; break; + case 'DEFTIMESTAMP': $fdefts = $v; break; + case 'CONSTRAINT': $fconstraint = $v; break; + // let INDEX keyword create a 'very standard' index on column + case 'INDEX': $findex = $v; break; + case 'UNIQUE': $funiqueindex = true; break; + } //switch + } // foreach $fld + + //-------------------- + // VALIDATE FIELD INFO + if (!strlen($fname)) { + if ($this->debug) ADOConnection::outp("Undefined NAME"); + return false; + } + + $fid = strtoupper(preg_replace('/^`(.+)`$/', '$1', $fname)); + $fname = $this->NameQuote($fname); + + if (!strlen($ftype)) { + if ($this->debug) ADOConnection::outp("Undefined TYPE for field '$fname'"); + return false; + } else { + $ftype = strtoupper($ftype); + } + + $ftype = $this->_GetSize($ftype, $ty, $fsize, $fprec); + + if ($ty == 'X' || $ty == 'X2' || $ty == 'B') $fnotnull = false; // some blob types do not accept nulls + + if ($fprimary) $pkey[] = $fname; + + // some databases do not allow blobs to have defaults + if ($ty == 'X') $fdefault = false; + + // build list of indexes + if ($findex != '') { + if (array_key_exists($findex, $idxs)) { + $idxs[$findex]['cols'][] = ($fname); + if (in_array('UNIQUE', $idxs[$findex]['opts']) != $funiqueindex) { + if ($this->debug) ADOConnection::outp("Index $findex defined once UNIQUE and once not"); + } + if ($funiqueindex && !in_array('UNIQUE', $idxs[$findex]['opts'])) + $idxs[$findex]['opts'][] = 'UNIQUE'; + } + else + { + $idxs[$findex] = array(); + $idxs[$findex]['cols'] = array($fname); + if ($funiqueindex) + $idxs[$findex]['opts'] = array('UNIQUE'); + else + $idxs[$findex]['opts'] = array(); + } + } + + //-------------------- + // CONSTRUCT FIELD SQL + if ($fdefts) { + if (substr($this->connection->databaseType,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysTimeStamp; + } + } else if ($fdefdate) { + if (substr($this->connection->databaseType,0,5) == 'mysql') { + $ftype = 'TIMESTAMP'; + } else { + $fdefault = $this->connection->sysDate; + } + } else if ($fdefault !== false && !$fnoquote) { + if ($ty == 'C' or $ty == 'X' or + ( substr($fdefault,0,1) != "'" && !is_numeric($fdefault))) { + + if (($ty == 'D' || $ty == 'T') && strtolower($fdefault) != 'null') { + // convert default date into database-aware code + if ($ty == 'T') + { + $fdefault = $this->connection->DBTimeStamp($fdefault); + } + else + { + $fdefault = $this->connection->DBDate($fdefault); + } + } + else + if (strlen($fdefault) != 1 && substr($fdefault,0,1) == ' ' && substr($fdefault,strlen($fdefault)-1) == ' ') + $fdefault = trim($fdefault); + else if (strtolower($fdefault) != 'null') + $fdefault = $this->connection->qstr($fdefault); + } + } + $suffix = $this->_CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint,$funsigned); + + // add index creation + if ($widespacing) $fname = str_pad($fname,24); + + // check for field names appearing twice + if (array_key_exists($fid, $lines)) { + ADOConnection::outp("Field '$fname' defined twice"); + } + + $lines[$fid] = $fname.' '.$ftype.$suffix; + + if ($fautoinc) $this->autoIncrement = true; + } // foreach $flds + + return array($lines,$pkey,$idxs); + } + + /** + GENERATE THE SIZE PART OF THE DATATYPE + $ftype is the actual type + $ty is the type defined originally in the DDL + */ + function _GetSize($ftype, $ty, $fsize, $fprec) + { + if (strlen($fsize) && $ty != 'X' && $ty != 'B' && strpos($ftype,'(') === false) { + $ftype .= "(".$fsize; + if (strlen($fprec)) $ftype .= ",".$fprec; + $ftype .= ')'; + } + return $ftype; + } + + + // return string must begin with space + function _CreateSuffix($fname,$ftype,$fnotnull,$fdefault,$fautoinc,$fconstraint) + { + $suffix = ''; + if (strlen($fdefault)) $suffix .= " DEFAULT $fdefault"; + if ($fnotnull) $suffix .= ' NOT NULL'; + if ($fconstraint) $suffix .= ' '.$fconstraint; + return $suffix; + } + + function _IndexSQL($idxname, $tabname, $flds, $idxoptions) + { + $sql = array(); + + if ( isset($idxoptions['REPLACE']) || isset($idxoptions['DROP']) ) { + $sql[] = sprintf ($this->dropIndex, $idxname); + if ( isset($idxoptions['DROP']) ) + return $sql; + } + + if ( empty ($flds) ) { + return $sql; + } + + $unique = isset($idxoptions['UNIQUE']) ? ' UNIQUE' : ''; + + $s = 'CREATE' . $unique . ' INDEX ' . $idxname . ' ON ' . $tabname . ' '; + + if ( isset($idxoptions[$this->upperName]) ) + $s .= $idxoptions[$this->upperName]; + + if ( is_array($flds) ) + $flds = implode(', ',$flds); + $s .= '(' . $flds . ')'; + $sql[] = $s; + + return $sql; + } + + function _DropAutoIncrement($tabname) + { + return false; + } + + function _TableSQL($tabname,$lines,$pkey,$tableoptions) + { + $sql = array(); + + if (isset($tableoptions['REPLACE']) || isset ($tableoptions['DROP'])) { + $sql[] = sprintf($this->dropTable,$tabname); + if ($this->autoIncrement) { + $sInc = $this->_DropAutoIncrement($tabname); + if ($sInc) $sql[] = $sInc; + } + if ( isset ($tableoptions['DROP']) ) { + return $sql; + } + } + $s = "CREATE TABLE $tabname (\n"; + $s .= implode(",\n", $lines); + if (sizeof($pkey)>0) { + $s .= ",\n PRIMARY KEY ("; + $s .= implode(", ",$pkey).")"; + } + if (isset($tableoptions['CONSTRAINTS'])) + $s .= "\n".$tableoptions['CONSTRAINTS']; + + if (isset($tableoptions[$this->upperName.'_CONSTRAINTS'])) + $s .= "\n".$tableoptions[$this->upperName.'_CONSTRAINTS']; + + $s .= "\n)"; + if (isset($tableoptions[$this->upperName])) $s .= $tableoptions[$this->upperName]; + $sql[] = $s; + + return $sql; + } + + /** + GENERATE TRIGGERS IF NEEDED + used when table has auto-incrementing field that is emulated using triggers + */ + function _Triggers($tabname,$taboptions) + { + return array(); + } + + /** + Sanitize options, so that array elements with no keys are promoted to keys + */ + function _Options($opts) + { + if (!is_array($opts)) return array(); + $newopts = array(); + foreach($opts as $k => $v) { + if (is_numeric($k)) $newopts[strtoupper($v)] = $v; + else $newopts[strtoupper($k)] = $v; + } + return $newopts; + } + + /** + "Florian Buzin [ easywe ]" + + This function changes/adds new fields to your table. You don't + have to know if the col is new or not. It will check on its own. + */ + function ChangeTableSQL($tablename, $flds, $tableoptions = false) + { + global $ADODB_FETCH_MODE; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC; + if ($this->connection->fetchMode !== false) $savem = $this->connection->SetFetchMode(false); + + // check table exists + $save_handler = $this->connection->raiseErrorFn; + $this->connection->raiseErrorFn = ''; + $cols = $this->MetaColumns($tablename); + $this->connection->raiseErrorFn = $save_handler; + + if (isset($savem)) $this->connection->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ( empty($cols)) { + return $this->CreateTableSQL($tablename, $flds, $tableoptions); + } + + if (is_array($flds)) { + // Cycle through the update fields, comparing + // existing fields to fields to update. + // if the Metatype and size is exactly the + // same, ignore - by Mark Newham + $holdflds = array(); + foreach($flds as $k=>$v) { + if ( isset($cols[$k]) && is_object($cols[$k]) ) { + // If already not allowing nulls, then don't change + $obj = $cols[$k]; + if (isset($obj->not_null) && $obj->not_null) + $v = str_replace('NOT NULL','',$v); + + $c = $cols[$k]; + $ml = $c->max_length; + $mt = $this->MetaType($c->type,$ml); + if ($ml == -1) $ml = ''; + if ($mt == 'X') $ml = $v['SIZE']; + if (($mt != $v['TYPE']) || $ml != $v['SIZE']) { + $holdflds[$k] = $v; + } + } else { + $holdflds[$k] = $v; + } + } + $flds = $holdflds; + } + + + // already exists, alter table instead + list($lines,$pkey,$idxs) = $this->_GenFields($flds); + // genfields can return FALSE at times + if ($lines == null) $lines = array(); + $alter = 'ALTER TABLE ' . $this->TableName($tablename); + $sql = array(); + + foreach ( $lines as $id => $v ) { + if ( isset($cols[$id]) && is_object($cols[$id]) ) { + + $flds = Lens_ParseArgs($v,','); + + // We are trying to change the size of the field, if not allowed, simply ignore the request. + if ($flds && in_array(strtoupper(substr($flds[0][1],0,4)),$this->invalidResizeTypes4)) { + echo "

    $this->alterCol cannot be changed to $flds currently

    "; + continue; + } + $sql[] = $alter . $this->alterCol . ' ' . $v; + } else { + $sql[] = $alter . $this->addCol . ' ' . $v; + } + } + + return $sql; + } +} // class +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-error.inc.php b/upload/includes/adodb/adodb-error.inc.php new file mode 100644 index 00000000..fc8fd004 --- /dev/null +++ b/upload/includes/adodb/adodb-error.inc.php @@ -0,0 +1,258 @@ + DB_ERROR_NOSUCHTABLE, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*/' => DB_ERROR_ALREADY_EXISTS, + '/divide by zero$/' => DB_ERROR_DIVZERO, + '/pg_atoi: error in .*: can\'t parse /' => DB_ERROR_INVALID_NUMBER, + '/ttribute [\"\'].*[\"\'] not found|Relation [\"\'].*[\"\'] does not have attribute [\"\'].*[\"\']/' => DB_ERROR_NOSUCHFIELD, + '/parser: parse error at or near \"/' => DB_ERROR_SYNTAX, + '/referential integrity violation/' => DB_ERROR_CONSTRAINT, + '/Relation [\"\'].*[\"\'] already exists|Cannot insert a duplicate key into (a )?unique index.*|duplicate key violates unique constraint/' + => DB_ERROR_ALREADY_EXISTS + ); + reset($error_regexps); + while (list($regexp,$code) = each($error_regexps)) { + if (preg_match($regexp, $errormsg)) { + return $code; + } + } + // Fall back to DB_ERROR if there was no mapping. + return DB_ERROR; +} + +function adodb_error_odbc() +{ +static $MAP = array( + '01004' => DB_ERROR_TRUNCATED, + '07001' => DB_ERROR_MISMATCH, + '21S01' => DB_ERROR_MISMATCH, + '21S02' => DB_ERROR_MISMATCH, + '22003' => DB_ERROR_INVALID_NUMBER, + '22008' => DB_ERROR_INVALID_DATE, + '22012' => DB_ERROR_DIVZERO, + '23000' => DB_ERROR_CONSTRAINT, + '24000' => DB_ERROR_INVALID, + '34000' => DB_ERROR_INVALID, + '37000' => DB_ERROR_SYNTAX, + '42000' => DB_ERROR_SYNTAX, + 'IM001' => DB_ERROR_UNSUPPORTED, + 'S0000' => DB_ERROR_NOSUCHTABLE, + 'S0001' => DB_ERROR_NOT_FOUND, + 'S0002' => DB_ERROR_NOSUCHTABLE, + 'S0011' => DB_ERROR_ALREADY_EXISTS, + 'S0012' => DB_ERROR_NOT_FOUND, + 'S0021' => DB_ERROR_ALREADY_EXISTS, + 'S0022' => DB_ERROR_NOT_FOUND, + 'S1000' => DB_ERROR_NOSUCHTABLE, + 'S1009' => DB_ERROR_INVALID, + 'S1090' => DB_ERROR_INVALID, + 'S1C00' => DB_ERROR_NOT_CAPABLE + ); + return $MAP; +} + +function adodb_error_ibase() +{ +static $MAP = array( + -104 => DB_ERROR_SYNTAX, + -150 => DB_ERROR_ACCESS_VIOLATION, + -151 => DB_ERROR_ACCESS_VIOLATION, + -155 => DB_ERROR_NOSUCHTABLE, + -157 => DB_ERROR_NOSUCHFIELD, + -158 => DB_ERROR_VALUE_COUNT_ON_ROW, + -170 => DB_ERROR_MISMATCH, + -171 => DB_ERROR_MISMATCH, + -172 => DB_ERROR_INVALID, + -204 => DB_ERROR_INVALID, + -205 => DB_ERROR_NOSUCHFIELD, + -206 => DB_ERROR_NOSUCHFIELD, + -208 => DB_ERROR_INVALID, + -219 => DB_ERROR_NOSUCHTABLE, + -297 => DB_ERROR_CONSTRAINT, + -530 => DB_ERROR_CONSTRAINT, + -803 => DB_ERROR_CONSTRAINT, + -551 => DB_ERROR_ACCESS_VIOLATION, + -552 => DB_ERROR_ACCESS_VIOLATION, + -922 => DB_ERROR_NOSUCHDB, + -923 => DB_ERROR_CONNECT_FAILED, + -924 => DB_ERROR_CONNECT_FAILED + ); + + return $MAP; +} + +function adodb_error_ifx() +{ +static $MAP = array( + '-201' => DB_ERROR_SYNTAX, + '-206' => DB_ERROR_NOSUCHTABLE, + '-217' => DB_ERROR_NOSUCHFIELD, + '-329' => DB_ERROR_NODBSELECTED, + '-1204' => DB_ERROR_INVALID_DATE, + '-1205' => DB_ERROR_INVALID_DATE, + '-1206' => DB_ERROR_INVALID_DATE, + '-1209' => DB_ERROR_INVALID_DATE, + '-1210' => DB_ERROR_INVALID_DATE, + '-1212' => DB_ERROR_INVALID_DATE + ); + + return $MAP; +} + +function adodb_error_oci8() +{ +static $MAP = array( + 1 => DB_ERROR_ALREADY_EXISTS, + 900 => DB_ERROR_SYNTAX, + 904 => DB_ERROR_NOSUCHFIELD, + 923 => DB_ERROR_SYNTAX, + 942 => DB_ERROR_NOSUCHTABLE, + 955 => DB_ERROR_ALREADY_EXISTS, + 1476 => DB_ERROR_DIVZERO, + 1722 => DB_ERROR_INVALID_NUMBER, + 2289 => DB_ERROR_NOSUCHTABLE, + 2291 => DB_ERROR_CONSTRAINT, + 2449 => DB_ERROR_CONSTRAINT + ); + + return $MAP; +} + +function adodb_error_mssql() +{ +static $MAP = array( + 208 => DB_ERROR_NOSUCHTABLE, + 2601 => DB_ERROR_ALREADY_EXISTS + ); + + return $MAP; +} + +function adodb_error_sqlite() +{ +static $MAP = array( + 1 => DB_ERROR_SYNTAX + ); + + return $MAP; +} + +function adodb_error_mysql() +{ +static $MAP = array( + 1004 => DB_ERROR_CANNOT_CREATE, + 1005 => DB_ERROR_CANNOT_CREATE, + 1006 => DB_ERROR_CANNOT_CREATE, + 1007 => DB_ERROR_ALREADY_EXISTS, + 1008 => DB_ERROR_CANNOT_DROP, + 1045 => DB_ERROR_ACCESS_VIOLATION, + 1046 => DB_ERROR_NODBSELECTED, + 1049 => DB_ERROR_NOSUCHDB, + 1050 => DB_ERROR_ALREADY_EXISTS, + 1051 => DB_ERROR_NOSUCHTABLE, + 1054 => DB_ERROR_NOSUCHFIELD, + 1062 => DB_ERROR_ALREADY_EXISTS, + 1064 => DB_ERROR_SYNTAX, + 1100 => DB_ERROR_NOT_LOCKED, + 1136 => DB_ERROR_VALUE_COUNT_ON_ROW, + 1146 => DB_ERROR_NOSUCHTABLE, + 1048 => DB_ERROR_CONSTRAINT, + 2002 => DB_ERROR_CONNECT_FAILED, + 2005 => DB_ERROR_CONNECT_FAILED + ); + + return $MAP; +} +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-errorhandler.inc.php b/upload/includes/adodb/adodb-errorhandler.inc.php new file mode 100644 index 00000000..0eac241a --- /dev/null +++ b/upload/includes/adodb/adodb-errorhandler.inc.php @@ -0,0 +1,79 @@ +$s

    "; + trigger_error($s,ADODB_ERROR_HANDLER_TYPE); +} +?> diff --git a/upload/includes/adodb/adodb-errorpear.inc.php b/upload/includes/adodb/adodb-errorpear.inc.php new file mode 100644 index 00000000..d2f39c4c --- /dev/null +++ b/upload/includes/adodb/adodb-errorpear.inc.php @@ -0,0 +1,88 @@ +!$s

    "; +} + +/** +* Returns last PEAR_Error object. This error might be for an error that +* occured several sql statements ago. +*/ +function &ADODB_PEAR_Error() +{ +global $ADODB_Last_PEAR_Error; + + return $ADODB_Last_PEAR_Error; +} + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-exceptions.inc.php b/upload/includes/adodb/adodb-exceptions.inc.php new file mode 100644 index 00000000..2eb0f84a --- /dev/null +++ b/upload/includes/adodb/adodb-exceptions.inc.php @@ -0,0 +1,82 @@ +sql = $p1; + $this->params = $p2; + $s = "$dbms error: [$errno: $errmsg] in $fn(\"$p1\")\n"; + break; + + case 'PCONNECT': + case 'CONNECT': + $user = $thisConnection->user; + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, '$user', '****', $p2)\n"; + break; + default: + $s = "$dbms error: [$errno: $errmsg] in $fn($p1, $p2)\n"; + break; + } + + $this->dbms = $dbms; + if ($thisConnection) { + $this->host = $thisConnection->host; + $this->database = $thisConnection->database; + } + $this->fn = $fn; + $this->msg = $errmsg; + + if (!is_numeric($errno)) $errno = -1; + parent::__construct($s,$errno); + } +} + +/** +* Default Error Handler. This will be called with the following params +* +* @param $dbms the RDBMS you are connecting to +* @param $fn the name of the calling function (in uppercase) +* @param $errno the native error number from the database +* @param $errmsg the native error msg from the database +* @param $p1 $fn specific parameter - see below +* @param $P2 $fn specific parameter - see below +*/ + +function adodb_throw($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection) +{ +global $ADODB_EXCEPTION; + + if (error_reporting() == 0) return; // obey @ protocol + if (is_string($ADODB_EXCEPTION)) $errfn = $ADODB_EXCEPTION; + else $errfn = 'ADODB_EXCEPTION'; + throw new $errfn($dbms, $fn, $errno, $errmsg, $p1, $p2, $thisConnection); +} + + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-iterator.inc.php b/upload/includes/adodb/adodb-iterator.inc.php new file mode 100644 index 00000000..4cdb821c --- /dev/null +++ b/upload/includes/adodb/adodb-iterator.inc.php @@ -0,0 +1,85 @@ +Execute("select * from adoxyz"); + foreach($rs as $k => $v) { + echo $k; print_r($v); echo "
    "; + } + + + Iterator code based on http://cvs.php.net/cvs.php/php-src/ext/spl/examples/cachingiterator.inc?login=2 + */ + + + class ADODB_Iterator implements Iterator { + + private $rs; + + function __construct($rs) + { + $this->rs = $rs; + } + function rewind() + { + $this->rs->MoveFirst(); + } + + function valid() + { + return !$this->rs->EOF; + } + + function key() + { + return $this->rs->_currentRow; + } + + function current() + { + return $this->rs->fields; + } + + function next() + { + $this->rs->MoveNext(); + } + + function __call($func, $params) + { + return call_user_func_array(array($this->rs, $func), $params); + } + + + function hasMore() + { + return !$this->rs->EOF; + } + +} + + +class ADODB_BASE_RS implements IteratorAggregate { + function getIterator() { + return new ADODB_Iterator($this); + } + + /* this is experimental - i don't really know what to return... */ + function __toString() + { + include_once(ADODB_DIR.'/toexport.inc.php'); + return _adodb_export($this,',',',',false,true); + } +} + + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-lib.inc.php b/upload/includes/adodb/adodb-lib.inc.php new file mode 100644 index 00000000..f752dcf0 --- /dev/null +++ b/upload/includes/adodb/adodb-lib.inc.php @@ -0,0 +1,1174 @@ + sizeof($array)) $max = sizeof($array); + else $max = $probe; + + + for ($j=0;$j < $max; $j++) { + $row =& $array[$j]; + if (!$row) break; + $i = -1; + foreach($row as $v) { + $i += 1; + + if (isset($types[$i]) && $types[$i]=='C') continue; + + //print " ($i ".$types[$i]. "$v) "; + $v = trim($v); + + if (!preg_match('/^[+-]{0,1}[0-9\.]+$/',$v)) { + $types[$i] = 'C'; // once C, always C + + continue; + } + if ($j == 0) { + // If empty string, we presume is character + // test for integer for 1st row only + // after that it is up to testing other rows to prove + // that it is not an integer + if (strlen($v) == 0) $types[$i] = 'C'; + if (strpos($v,'.') !== false) $types[$i] = 'N'; + else $types[$i] = 'I'; + continue; + } + + if (strpos($v,'.') !== false) $types[$i] = 'N'; + + } + } + +} + +function adodb_transpose(&$arr, &$newarr, &$hdr, &$fobjs) +{ + $oldX = sizeof(reset($arr)); + $oldY = sizeof($arr); + + if ($hdr) { + $startx = 1; + $hdr = array('Fields'); + for ($y = 0; $y < $oldY; $y++) { + $hdr[] = $arr[$y][0]; + } + } else + $startx = 0; + + for ($x = $startx; $x < $oldX; $x++) { + if ($fobjs) { + $o = $fobjs[$x]; + $newarr[] = array($o->name); + } else + $newarr[] = array(); + + for ($y = 0; $y < $oldY; $y++) { + $newarr[$x-$startx][] = $arr[$y][$x]; + } + } +} + +// Force key to upper. +// See also http://www.php.net/manual/en/function.array-change-key-case.php +function _array_change_key_case($an_array) +{ + if (is_array($an_array)) { + $new_array = array(); + foreach($an_array as $key=>$value) + $new_array[strtoupper($key)] = $value; + + return $new_array; + } + + return $an_array; +} + +function _adodb_replace(&$zthis, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc) +{ + if (count($fieldArray) == 0) return 0; + $first = true; + $uSet = ''; + + if (!is_array($keyCol)) { + $keyCol = array($keyCol); + } + foreach($fieldArray as $k => $v) { + if ($v === null) { + $v = 'NULL'; + $fieldArray[$k] = $v; + } else if ($autoQuote && !is_numeric($v) /*and strncmp($v,"'",1) !== 0 -- sql injection risk*/ and strcasecmp($v,$zthis->null2null)!=0) { + $v = $zthis->qstr($v); + $fieldArray[$k] = $v; + } + if (in_array($k,$keyCol)) continue; // skip UPDATE if is key + + if ($first) { + $first = false; + $uSet = "$k=$v"; + } else + $uSet .= ",$k=$v"; + } + + $where = false; + foreach ($keyCol as $v) { + if (isset($fieldArray[$v])) { + if ($where) $where .= ' and '.$v.'='.$fieldArray[$v]; + else $where = $v.'='.$fieldArray[$v]; + } + } + + if ($uSet && $where) { + $update = "UPDATE $table SET $uSet WHERE $where"; + + $rs = $zthis->Execute($update); + + + if ($rs) { + if ($zthis->poorAffectedRows) { + /* + The Select count(*) wipes out any errors that the update would have returned. + http://phplens.com/lens/lensforum/msgs.php?id=5696 + */ + if ($zthis->ErrorNo()<>0) return 0; + + # affected_rows == 0 if update field values identical to old values + # for mysql - which is silly. + + $cnt = $zthis->GetOne("select count(*) from $table where $where"); + if ($cnt > 0) return 1; // record already exists + } else { + if (($zthis->Affected_Rows()>0)) return 1; + } + } else + return 0; + } + + // print "

    Error=".$this->ErrorNo().'

    '; + $first = true; + foreach($fieldArray as $k => $v) { + if ($has_autoinc && in_array($k,$keyCol)) continue; // skip autoinc col + + if ($first) { + $first = false; + $iCols = "$k"; + $iVals = "$v"; + } else { + $iCols .= ",$k"; + $iVals .= ",$v"; + } + } + $insert = "INSERT INTO $table ($iCols) VALUES ($iVals)"; + $rs = $zthis->Execute($insert); + return ($rs) ? 2 : 0; +} + +// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM +function _adodb_getmenu(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) +{ + $hasvalue = false; + + if ($multiple or is_array($defstr)) { + if ($size==0) $size=5; + $attr = ' multiple size="'.$size.'"'; + if (!strpos($name,'[]')) $name .= '[]'; + } else if ($size) $attr = ' size="'.$size.'"'; + else $attr =''; + + $s = '\n"; +} + +// Requires $ADODB_FETCH_MODE = ADODB_FETCH_NUM +function _adodb_getmenu_gp(&$zthis, $name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) +{ + $hasvalue = false; + + if ($multiple or is_array($defstr)) { + if ($size==0) $size=5; + $attr = ' multiple size="'.$size.'"'; + if (!strpos($name,'[]')) $name .= '[]'; + } else if ($size) $attr = ' size="'.$size.'"'; + else $attr =''; + + $s = '\n"; +} + + +/* + Count the number of records this sql statement will return by using + query rewriting heuristics... + + Does not work with UNIONs, except with postgresql and oracle. + + Usage: + + $conn->Connect(...); + $cnt = _adodb_getcount($conn, $sql); + +*/ +function _adodb_getcount(&$zthis, $sql,$inputarr=false,$secs2cache=0) +{ + $qryRecs = 0; + + if (!empty($zthis->_nestedSQL) || preg_match("/^\s*SELECT\s+DISTINCT/is", $sql) || + preg_match('/\s+GROUP\s+BY\s+/is',$sql) || + preg_match('/\s+UNION\s+/is',$sql)) { + + $rewritesql = adodb_strip_order_by($sql); + + // ok, has SELECT DISTINCT or GROUP BY so see if we can use a table alias + // but this is only supported by oracle and postgresql... + if ($zthis->dataProvider == 'oci8') { + // Allow Oracle hints to be used for query optimization, Chris Wrye + if (preg_match('#/\\*+.*?\\*\\/#', $sql, $hint)) { + $rewritesql = "SELECT ".$hint[0]." COUNT(*) FROM (".$rewritesql.")"; + } else + $rewritesql = "SELECT COUNT(*) FROM (".$rewritesql.")"; + + } else if (strncmp($zthis->databaseType,'postgres',8) == 0) { + $rewritesql = "SELECT COUNT(*) FROM ($rewritesql) _ADODB_ALIAS_"; + } + } else { + // now replace SELECT ... FROM with SELECT COUNT(*) FROM + $rewritesql = preg_replace( + '/^\s*SELECT\s.*\s+FROM\s/Uis','SELECT COUNT(*) FROM ',$sql); + // fix by alexander zhukov, alex#unipack.ru, because count(*) and 'order by' fails + // with mssql, access and postgresql. Also a good speedup optimization - skips sorting! + // also see http://phplens.com/lens/lensforum/msgs.php?id=12752 + $rewritesql = adodb_strip_order_by($rewritesql); + } + + if (isset($rewritesql) && $rewritesql != $sql) { + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + + if ($secs2cache) { + // we only use half the time of secs2cache because the count can quickly + // become inaccurate if new records are added + $qryRecs = $zthis->CacheGetOne($secs2cache/2,$rewritesql,$inputarr); + + } else { + $qryRecs = $zthis->GetOne($rewritesql,$inputarr); + } + if ($qryRecs !== false) return $qryRecs; + } + //-------------------------------------------- + // query rewrite failed - so try slower way... + + + // strip off unneeded ORDER BY if no UNION + if (preg_match('/\s*UNION\s*/is', $sql)) $rewritesql = $sql; + else $rewritesql = $rewritesql = adodb_strip_order_by($sql); + + if (preg_match('/\sLIMIT\s+[0-9]+/i',$sql,$limitarr)) $rewritesql .= $limitarr[0]; + + $rstest = &$zthis->Execute($rewritesql,$inputarr); + if (!$rstest) $rstest = $zthis->Execute($sql,$inputarr); + + if ($rstest) { + $qryRecs = $rstest->RecordCount(); + if ($qryRecs == -1) { + global $ADODB_EXTENSION; + // some databases will return -1 on MoveLast() - change to MoveNext() + if ($ADODB_EXTENSION) { + while(!$rstest->EOF) { + adodb_movenext($rstest); + } + } else { + while(!$rstest->EOF) { + $rstest->MoveNext(); + } + } + $qryRecs = $rstest->_currentRow; + } + $rstest->Close(); + if ($qryRecs == -1) return 0; + } + return $qryRecs; +} + +/* + Code originally from "Cornel G" + + This code might not work with SQL that has UNION in it + + Also if you are using CachePageExecute(), there is a strong possibility that + data will get out of synch. use CachePageExecute() only with tables that + rarely change. +*/ +function &_adodb_pageexecute_all_rows(&$zthis, $sql, $nrows, $page, + $inputarr=false, $secs2cache=0) +{ + $atfirstpage = false; + $atlastpage = false; + $lastpageno=1; + + // If an invalid nrows is supplied, + // we assume a default value of 10 rows per page + if (!isset($nrows) || $nrows <= 0) $nrows = 10; + + $qryRecs = false; //count records for no offset + + $qryRecs = _adodb_getcount($zthis,$sql,$inputarr,$secs2cache); + $lastpageno = (int) ceil($qryRecs / $nrows); + $zthis->_maxRecordCount = $qryRecs; + + + + // ***** Here we check whether $page is the last page or + // whether we are trying to retrieve + // a page number greater than the last page number. + if ($page >= $lastpageno) { + $page = $lastpageno; + $atlastpage = true; + } + + // If page number <= 1, then we are at the first page + if (empty($page) || $page <= 1) { + $page = 1; + $atfirstpage = true; + } + + // We get the data we want + $offset = $nrows * ($page-1); + if ($secs2cache > 0) + $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + else + $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + + + // Before returning the RecordSet, we set the pagination properties we need + if ($rsreturn) { + $rsreturn->_maxRecordCount = $qryRecs; + $rsreturn->rowsPerPage = $nrows; + $rsreturn->AbsolutePage($page); + $rsreturn->AtFirstPage($atfirstpage); + $rsreturn->AtLastPage($atlastpage); + $rsreturn->LastPageNo($lastpageno); + } + return $rsreturn; +} + +// Ivn Oliva version +function &_adodb_pageexecute_no_last_page(&$zthis, $sql, $nrows, $page, $inputarr=false, $secs2cache=0) +{ + + $atfirstpage = false; + $atlastpage = false; + + if (!isset($page) || $page <= 1) { // If page number <= 1, then we are at the first page + $page = 1; + $atfirstpage = true; + } + if ($nrows <= 0) $nrows = 10; // If an invalid nrows is supplied, we assume a default value of 10 rows per page + + // ***** Here we check whether $page is the last page or whether we are trying to retrieve a page number greater than + // the last page number. + $pagecounter = $page + 1; + $pagecounteroffset = ($pagecounter * $nrows) - $nrows; + if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + if ($rstest) { + while ($rstest && $rstest->EOF && $pagecounter>0) { + $atlastpage = true; + $pagecounter--; + $pagecounteroffset = $nrows * ($pagecounter - 1); + $rstest->Close(); + if ($secs2cache>0) $rstest = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $pagecounteroffset, $inputarr); + else $rstest = &$zthis->SelectLimit($sql, $nrows, $pagecounteroffset, $inputarr, $secs2cache); + } + if ($rstest) $rstest->Close(); + } + if ($atlastpage) { // If we are at the last page or beyond it, we are going to retrieve it + $page = $pagecounter; + if ($page == 1) $atfirstpage = true; // We have to do this again in case the last page is the same as the first + //... page, that is, the recordset has only 1 page. + } + + // We get the data we want + $offset = $nrows * ($page-1); + if ($secs2cache > 0) $rsreturn = &$zthis->CacheSelectLimit($secs2cache, $sql, $nrows, $offset, $inputarr); + else $rsreturn = &$zthis->SelectLimit($sql, $nrows, $offset, $inputarr, $secs2cache); + + // Before returning the RecordSet, we set the pagination properties we need + if ($rsreturn) { + $rsreturn->rowsPerPage = $nrows; + $rsreturn->AbsolutePage($page); + $rsreturn->AtFirstPage($atfirstpage); + $rsreturn->AtLastPage($atlastpage); + } + return $rsreturn; +} + +function _adodb_getupdatesql(&$zthis,&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=2) +{ + global $ADODB_QUOTE_FIELDNAMES; + + if (!$rs) { + printf(ADODB_BAD_RS,'GetUpdateSQL'); + return false; + } + + $fieldUpdatedCount = 0; + $arrFields = _array_change_key_case($arrFields); + + $hasnumeric = isset($rs->fields[0]); + $setFields = ''; + + // Loop through all of the fields in the recordset + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { + // Get the field from the recordset + $field = $rs->FetchField($i); + + // If the recordset field is one + // of the fields passed in then process. + $upperfname = strtoupper($field->name); + if (adodb_key_exists($upperfname,$arrFields,$force)) { + + // If the existing field value in the recordset + // is different from the value passed in then + // go ahead and append the field name and new value to + // the update query. + + if ($hasnumeric) $val = $rs->fields[$i]; + else if (isset($rs->fields[$upperfname])) $val = $rs->fields[$upperfname]; + else if (isset($rs->fields[$field->name])) $val = $rs->fields[$field->name]; + else if (isset($rs->fields[strtolower($upperfname)])) $val = $rs->fields[strtolower($upperfname)]; + else $val = ''; + + + if ($forceUpdate || strcmp($val, $arrFields[$upperfname])) { + // Set the counter for the number of fields that will be updated. + $fieldUpdatedCount++; + + // Based on the datatype of the field + // Format the value properly for the database + $type = $rs->MetaType($field->type); + + + if ($type == 'null') { + $type = 'C'; + } + + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; + + + // is_null requires php 4.0.4 + //********************************************************// + if (is_null($arrFields[$upperfname]) + || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) + || $arrFields[$upperfname] === $zthis->null2null + ) + { + switch ($force) { + + //case 0: + // //Ignore empty values. This is allready handled in "adodb_key_exists" function. + //break; + + case 1: + //Set null + $setFields .= $field->name . " = null, "; + break; + + case 2: + //Set empty + $arrFields[$upperfname] = ""; + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq); + break; + default: + case 3: + //Set the value that was given in array, so you can give both null and empty values + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { + $setFields .= $field->name . " = null, "; + } else { + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq,$arrFields, $magicq); + } + break; + } + //********************************************************// + } else { + //we do this so each driver can customize the sql for + //DB specific column types. + //Oracle needs BLOB types to be handled with a returning clause + //postgres has special needs as well + $setFields .= _adodb_column_sql($zthis, 'U', $type, $upperfname, $fnameq, + $arrFields, $magicq); + } + } + } + } + + // If there were any modified fields then build the rest of the update query. + if ($fieldUpdatedCount > 0 || $forceUpdate) { + // Get the table name from the existing query. + if (!empty($rs->tableName)) $tableName = $rs->tableName; + else { + preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName); + $tableName = $tableName[1]; + } + // Get the full where clause excluding the word "WHERE" from + // the existing query. + preg_match('/\sWHERE\s(.*)/is', $rs->sql, $whereClause); + + $discard = false; + // not a good hack, improvements? + if ($whereClause) { + #var_dump($whereClause); + if (preg_match('/\s(ORDER\s.*)/is', $whereClause[1], $discard)); + else if (preg_match('/\s(LIMIT\s.*)/is', $whereClause[1], $discard)); + else if (preg_match('/\s(FOR UPDATE.*)/is', $whereClause[1], $discard)); + else preg_match('/\s.*(\) WHERE .*)/is', $whereClause[1], $discard); # see http://sourceforge.net/tracker/index.php?func=detail&aid=1379638&group_id=42718&atid=433976 + } else + $whereClause = array(false,false); + + if ($discard) + $whereClause[1] = substr($whereClause[1], 0, strlen($whereClause[1]) - strlen($discard[1])); + + $sql = 'UPDATE '.$tableName.' SET '.substr($setFields, 0, -2); + if (strlen($whereClause[1]) > 0) + $sql .= ' WHERE '.$whereClause[1]; + + return $sql; + + } else { + return false; + } +} + +function adodb_key_exists($key, &$arr,$force=2) +{ + if ($force<=0) { + // the following is the old behaviour where null or empty fields are ignored + return (!empty($arr[$key])) || (isset($arr[$key]) && strlen($arr[$key])>0); + } + + if (isset($arr[$key])) return true; + ## null check below + if (ADODB_PHPVER >= 0x4010) return array_key_exists($key,$arr); + return false; +} + +/** + * There is a special case of this function for the oci8 driver. + * The proper way to handle an insert w/ a blob in oracle requires + * a returning clause with bind variables and a descriptor blob. + * + * + */ +function _adodb_getinsertsql(&$zthis,&$rs,$arrFields,$magicq=false,$force=2) +{ +static $cacheRS = false; +static $cacheSig = 0; +static $cacheCols; + global $ADODB_QUOTE_FIELDNAMES; + + $tableName = ''; + $values = ''; + $fields = ''; + $recordSet = null; + $arrFields = _array_change_key_case($arrFields); + $fieldInsertedCount = 0; + + if (is_string($rs)) { + //ok we have a table name + //try and get the column info ourself. + $tableName = $rs; + + //we need an object for the recordSet + //because we have to call MetaType. + //php can't do a $rsclass::MetaType() + $rsclass = $zthis->rsPrefix.$zthis->databaseType; + $recordSet = new $rsclass(-1,$zthis->fetchMode); + $recordSet->connection = &$zthis; + + if (is_string($cacheRS) && $cacheRS == $rs) { + $columns =& $cacheCols; + } else { + $columns = $zthis->MetaColumns( $tableName ); + $cacheRS = $tableName; + $cacheCols = $columns; + } + } else if (is_subclass_of($rs, 'adorecordset')) { + if (isset($rs->insertSig) && is_integer($cacheRS) && $cacheRS == $rs->insertSig) { + $columns =& $cacheCols; + } else { + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) + $columns[] = $rs->FetchField($i); + $cacheRS = $cacheSig; + $cacheCols = $columns; + $rs->insertSig = $cacheSig++; + } + $recordSet =& $rs; + + } else { + printf(ADODB_BAD_RS,'GetInsertSQL'); + return false; + } + + // Loop through all of the fields in the recordset + foreach( $columns as $field ) { + $upperfname = strtoupper($field->name); + if (adodb_key_exists($upperfname,$arrFields,$force)) { + $bad = false; + if ((strpos($upperfname,' ') !== false) || ($ADODB_QUOTE_FIELDNAMES)) + $fnameq = $zthis->nameQuote.$upperfname.$zthis->nameQuote; + else + $fnameq = $upperfname; + + $type = $recordSet->MetaType($field->type); + + /********************************************************/ + if (is_null($arrFields[$upperfname]) + || (empty($arrFields[$upperfname]) && strlen($arrFields[$upperfname]) == 0) + || $arrFields[$upperfname] === $zthis->null2null + ) + { + switch ($force) { + + case 0: // we must always set null if missing + $bad = true; + break; + + case 1: + $values .= "null, "; + break; + + case 2: + //Set empty + $arrFields[$upperfname] = ""; + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq,$arrFields, $magicq); + break; + + default: + case 3: + //Set the value that was given in array, so you can give both null and empty values + if (is_null($arrFields[$upperfname]) || $arrFields[$upperfname] === $zthis->null2null) { + $values .= "null, "; + } else { + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, $arrFields, $magicq); + } + break; + } // switch + + /*********************************************************/ + } else { + //we do this so each driver can customize the sql for + //DB specific column types. + //Oracle needs BLOB types to be handled with a returning clause + //postgres has special needs as well + $values .= _adodb_column_sql($zthis, 'I', $type, $upperfname, $fnameq, + $arrFields, $magicq); + } + + if ($bad) continue; + // Set the counter for the number of fields that will be inserted. + $fieldInsertedCount++; + + + // Get the name of the fields to insert + $fields .= $fnameq . ", "; + } + } + + + // If there were any inserted fields then build the rest of the insert query. + if ($fieldInsertedCount <= 0) return false; + + // Get the table name from the existing query. + if (!$tableName) { + if (!empty($rs->tableName)) $tableName = $rs->tableName; + else if (preg_match("/FROM\s+".ADODB_TABLE_REGEX."/is", $rs->sql, $tableName)) + $tableName = $tableName[1]; + else + return false; + } + + // Strip off the comma and space on the end of both the fields + // and their values. + $fields = substr($fields, 0, -2); + $values = substr($values, 0, -2); + + // Append the fields and their values to the insert query. + return 'INSERT INTO '.$tableName.' ( '.$fields.' ) VALUES ( '.$values.' )'; +} + + +/** + * This private method is used to help construct + * the update/sql which is generated by GetInsertSQL and GetUpdateSQL. + * It handles the string construction of 1 column -> sql string based on + * the column type. We want to do 'safe' handling of BLOBs + * + * @param string the type of sql we are trying to create + * 'I' or 'U'. + * @param string column data type from the db::MetaType() method + * @param string the column name + * @param array the column value + * + * @return string + * + */ +function _adodb_column_sql_oci8(&$zthis,$action, $type, $fname, $fnameq, $arrFields, $magicq) +{ + $sql = ''; + + // Based on the datatype of the field + // Format the value properly for the database + switch($type) { + case 'B': + //in order to handle Blobs correctly, we need + //to do some magic for Oracle + + //we need to create a new descriptor to handle + //this properly + if (!empty($zthis->hasReturningInto)) { + if ($action == 'I') { + $sql = 'empty_blob(), '; + } else { + $sql = $fnameq. '=empty_blob(), '; + } + //add the variable to the returning clause array + //so the user can build this later in + //case they want to add more to it + $zthis->_returningArray[$fname] = ':xx'.$fname.'xx'; + } else if (empty($arrFields[$fname])){ + if ($action == 'I') { + $sql = 'empty_blob(), '; + } else { + $sql = $fnameq. '=empty_blob(), '; + } + } else { + //this is to maintain compatibility + //with older adodb versions. + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + } + break; + + case "X": + //we need to do some more magic here for long variables + //to handle these correctly in oracle. + + //create a safe bind var name + //to avoid conflicts w/ dupes. + if (!empty($zthis->hasReturningInto)) { + if ($action == 'I') { + $sql = ':xx'.$fname.'xx, '; + } else { + $sql = $fnameq.'=:xx'.$fname.'xx, '; + } + //add the variable to the returning clause array + //so the user can build this later in + //case they want to add more to it + $zthis->_returningArray[$fname] = ':xx'.$fname.'xx'; + } else { + //this is to maintain compatibility + //with older adodb versions. + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + } + break; + + default: + $sql = _adodb_column_sql($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq,false); + break; + } + + return $sql; +} + +function _adodb_column_sql(&$zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq, $recurse=true) +{ + + if ($recurse) { + switch($zthis->dataProvider) { + case 'postgres': + if ($type == 'L') $type = 'C'; + break; + case 'oci8': + return _adodb_column_sql_oci8($zthis, $action, $type, $fname, $fnameq, $arrFields, $magicq); + + } + } + + switch($type) { + case "C": + case "X": + case 'B': + $val = $zthis->qstr($arrFields[$fname],$magicq); + break; + + case "D": + $val = $zthis->DBDate($arrFields[$fname]); + break; + + + case "T": + $val = $zthis->DBTimeStamp($arrFields[$fname]); + break; + + case "N": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = str_replace(',', '.', (float)$val); + break; + + case "I": + case "R": + $val = $arrFields[$fname]; + if (!is_numeric($val)) $val = (integer) $val; + break; + + default: + $val = str_replace(array("'"," ","("),"",$arrFields[$fname]); // basic sql injection defence + if (empty($val)) $val = '0'; + break; + } + + if ($action == 'I') return $val . ", "; + + + return $fnameq . "=" . $val . ", "; + +} + + + +function _adodb_debug_execute(&$zthis, $sql, $inputarr) +{ + $ss = ''; + if ($inputarr) { + foreach($inputarr as $kk=>$vv) { + if (is_string($vv) && strlen($vv)>64) $vv = substr($vv,0,64).'...'; + if (is_null($vv)) $ss .= "($kk=>null) "; + else $ss .= "($kk=>'$vv') "; + } + $ss = "[ $ss ]"; + } + $sqlTxt = is_array($sql) ? $sql[0] : $sql; + /*str_replace(', ','##1#__^LF',is_array($sql) ? $sql[0] : $sql); + $sqlTxt = str_replace(',',', ',$sqlTxt); + $sqlTxt = str_replace('##1#__^LF', ', ' ,$sqlTxt); + */ + // check if running from browser or command-line + $inBrowser = isset($_SERVER['HTTP_USER_AGENT']); + + $dbt = $zthis->databaseType; + if (isset($zthis->dsnType)) $dbt .= '-'.$zthis->dsnType; + if ($inBrowser) { + if ($ss) { + $ss = ''.htmlspecialchars($ss).''; + } + if ($zthis->debug === -1) + ADOConnection::outp( "
    \n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
    \n",false); + else + ADOConnection::outp( "


    \n($dbt): ".htmlspecialchars($sqlTxt)."   $ss\n
    \n",false); + } else { + ADOConnection::outp("-----\n($dbt): ".$sqlTxt."\n-----\n",false); + } + + $qID = $zthis->_query($sql,$inputarr); + + /* + Alexios Fakios notes that ErrorMsg() must be called before ErrorNo() for mssql + because ErrorNo() calls Execute('SELECT @ERROR'), causing recursion + */ + if ($zthis->databaseType == 'mssql') { + // ErrorNo is a slow function call in mssql, and not reliable in PHP 4.0.6 + if($emsg = $zthis->ErrorMsg()) { + if ($err = $zthis->ErrorNo()) ADOConnection::outp($err.': '.$emsg); + } + } else if (!$qID) { + ADOConnection::outp($zthis->ErrorNo() .': '. $zthis->ErrorMsg()); + } + + if ($zthis->debug === 99) _adodb_backtrace(true,9999,2); + return $qID; +} + +# pretty print the debug_backtrace function +function _adodb_backtrace($printOrArr=true,$levels=9999,$skippy=0) +{ + if (!function_exists('debug_backtrace')) return ''; + + $html = (isset($_SERVER['HTTP_USER_AGENT'])); + $fmt = ($html) ? " %% line %4d, file: %s" : "%% line %4d, file: %s"; + + $MAXSTRLEN = 128; + + $s = ($html) ? '
    ' : '';
    +	
    +	if (is_array($printOrArr)) $traceArr = $printOrArr;
    +	else $traceArr = debug_backtrace();
    +	array_shift($traceArr);
    +	array_shift($traceArr);
    +	$tabs = sizeof($traceArr)-2;
    +	
    +	foreach ($traceArr as $arr) {
    +		if ($skippy) {$skippy -= 1; continue;}
    +		$levels -= 1;
    +		if ($levels < 0) break;
    +		
    +		$args = array();
    +		for ($i=0; $i < $tabs; $i++) $s .=  ($html) ? '   ' : "\t";
    +		$tabs -= 1;
    +		if ($html) $s .= '';
    +		if (isset($arr['class'])) $s .= $arr['class'].'.';
    +		if (isset($arr['args']))
    +		 foreach($arr['args'] as $v) {
    +			if (is_null($v)) $args[] = 'null';
    +			else if (is_array($v)) $args[] = 'Array['.sizeof($v).']';
    +			else if (is_object($v)) $args[] = 'Object:'.get_class($v);
    +			else if (is_bool($v)) $args[] = $v ? 'true' : 'false';
    +			else {
    +				$v = (string) @$v;
    +				$str = htmlspecialchars(substr($v,0,$MAXSTRLEN));
    +				if (strlen($v) > $MAXSTRLEN) $str .= '...';
    +				$args[] = $str;
    +			}
    +		}
    +		$s .= $arr['function'].'('.implode(', ',$args).')';
    +		
    +		
    +		$s .= @sprintf($fmt, $arr['line'],$arr['file'],basename($arr['file']));
    +			
    +		$s .= "\n";
    +	}	
    +	if ($html) $s .= '
    '; + if ($printOrArr) print $s; + + return $s; +} +/* +function _adodb_find_from($sql) +{ + + $sql = str_replace(array("\n","\r"), ' ', $sql); + $charCount = strlen($sql); + + $inString = false; + $quote = ''; + $parentheseCount = 0; + $prevChars = ''; + $nextChars = ''; + + + for($i = 0; $i < $charCount; $i++) { + + $char = substr($sql,$i,1); + $prevChars = substr($sql,0,$i); + $nextChars = substr($sql,$i+1); + + if((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === false) { + $quote = $char; + $inString = true; + } + + elseif((($char == "'" || $char == '"' || $char == '`') && substr($prevChars,-1,1) != '\\') && $inString === true && $quote == $char) { + $quote = ""; + $inString = false; + } + + elseif($char == "(" && $inString === false) + $parentheseCount++; + + elseif($char == ")" && $inString === false && $parentheseCount > 0) + $parentheseCount--; + + elseif($parentheseCount <= 0 && $inString === false && $char == " " && strtoupper(substr($prevChars,-5,5)) == " FROM") + return $i; + + } +} +*/ + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-memcache.lib.inc.php b/upload/includes/adodb/adodb-memcache.lib.inc.php new file mode 100644 index 00000000..bc6b420b --- /dev/null +++ b/upload/includes/adodb/adodb-memcache.lib.inc.php @@ -0,0 +1,118 @@ +pconnect($host, $port)) { + $err = 'Can\'t connect to memcache server on: '.$host.':'.$port; + return $false; + } + + $rs = $memcache->get($key); + if (!$rs) { + $err = 'Item with such key doesn\'t exists on the memcached server.'; + return $false; + } + + $tdiff = intval($rs->timeCreated+$timeout - time()); + if ($tdiff <= 2) { + switch($tdiff) { + case 2: + if ((rand() & 15) == 0) { + $err = "Timeout 2"; + return $false; + } + break; + case 1: + if ((rand() & 3) == 0) { + $err = "Timeout 1"; + return $false; + } + break; + default: + $err = "Timeout 0"; + return $false; + } + } + return $rs; + } + + function putmemcache($key, $rs, $host, $port, $compress, $debug=false) + { + $false = false; + $true = true; + + if (!function_exists('memcache_pconnect')) { + if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!
    \n"); + return $false; + } + + $memcache = new Memcache; + if (!@$memcache->pconnect($host, $port)) { + if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port
    \n"); + return $false; + } + + $rs->timeCreated = time(); + if (!$memcache->set($key, $rs, $compress, 0)) { + if ($debug) ADOConnection::outp(" Failed to save data at the memcached server!
    \n"); + return $false; + } + return $true; + } + + function flushmemcache($key=false, $host, $port, $debug=false) + { + if (!function_exists('memcache_pconnect')) { + if ($debug) ADOConnection::outp(" Memcache module PECL extension not found!
    \n"); + return; + } + + $memcache = new Memcache; + if (!@$memcache->pconnect($host, $port)) { + if ($debug) ADOConnection::outp(" Can't connect to memcache server on: $host:$port
    \n"); + return; + } + + if ($key) { + if (!$memcache->delete($key)) { + if ($debug) ADOConnection::outp("CacheFlush: $key entery doesn't exist on memcached server!
    \n"); + } else { + if ($debug) ADOConnection::outp("CacheFlush: $key entery flushed from memcached server!
    \n"); + } + } else { + if (!$memcache->flush()) { + if ($debug) ADOConnection::outp("CacheFlush: Failure flushing all enteries from memcached server!
    \n"); + } else { + if ($debug) ADOConnection::outp("CacheFlush: All enteries flushed from memcached server!
    \n"); + } + } + return; + } +?> diff --git a/upload/includes/adodb/adodb-pager.inc.php b/upload/includes/adodb/adodb-pager.inc.php new file mode 100644 index 00000000..cefadac8 --- /dev/null +++ b/upload/includes/adodb/adodb-pager.inc.php @@ -0,0 +1,290 @@ + implemented Render_PageLinks(). + + Please note, this class is entirely unsupported, + and no free support requests except for bug reports + will be entertained by the author. + +*/ +class ADODB_Pager { + var $id; // unique id for pager (defaults to 'adodb') + var $db; // ADODB connection object + var $sql; // sql used + var $rs; // recordset generated + var $curr_page; // current page number before Render() called, calculated in constructor + var $rows; // number of rows per page + var $linksPerPage=10; // number of links per page in navigation bar + var $showPageLinks; + + var $gridAttributes = 'width=100% border=1 bgcolor=white'; + + // Localize text strings here + var $first = '|<'; + var $prev = '<<'; + var $next = '>>'; + var $last = '>|'; + var $moreLinks = '...'; + var $startLinks = '...'; + var $gridHeader = false; + var $htmlSpecialChars = true; + var $page = 'Page'; + var $linkSelectedColor = 'red'; + var $cache = 0; #secs to cache with CachePageExecute() + + //---------------------------------------------- + // constructor + // + // $db adodb connection object + // $sql sql statement + // $id optional id to identify which pager, + // if you have multiple on 1 page. + // $id should be only be [a-z0-9]* + // + function ADODB_Pager(&$db,$sql,$id = 'adodb', $showPageLinks = false) + { + global $PHP_SELF; + + $curr_page = $id.'_curr_page'; + if (empty($PHP_SELF)) $PHP_SELF = htmlspecialchars($_SERVER['PHP_SELF']); // htmlspecialchars() to prevent XSS attacks + + $this->sql = $sql; + $this->id = $id; + $this->db = $db; + $this->showPageLinks = $showPageLinks; + + $next_page = $id.'_next_page'; + + if (isset($_GET[$next_page])) { + $_SESSION[$curr_page] = (integer) $_GET[$next_page]; + } + if (empty($_SESSION[$curr_page])) $_SESSION[$curr_page] = 1; ## at first page + + $this->curr_page = $_SESSION[$curr_page]; + + } + + //--------------------------- + // Display link to first page + function Render_First($anchor=true) + { + global $PHP_SELF; + if ($anchor) { + ?> + first;?>   + first   "; + } + } + + //-------------------------- + // Display link to next page + function render_next($anchor=true) + { + global $PHP_SELF; + + if ($anchor) { + ?> + next;?>   + next   "; + } + } + + //------------------ + // Link to last page + // + // for better performance with large recordsets, you can set + // $this->db->pageExecuteCountRows = false, which disables + // last page counting. + function render_last($anchor=true) + { + global $PHP_SELF; + + if (!$this->db->pageExecuteCountRows) return; + + if ($anchor) { + ?> + last;?>   + last   "; + } + } + + //--------------------------------------------------- + // original code by "Pablo Costa" + function render_pagelinks() + { + global $PHP_SELF; + $pages = $this->rs->LastPageNo(); + $linksperpage = $this->linksPerPage ? $this->linksPerPage : $pages; + for($i=1; $i <= $pages; $i+=$linksperpage) + { + if($this->rs->AbsolutePage() >= $i) + { + $start = $i; + } + } + $numbers = ''; + $end = $start+$linksperpage-1; + $link = $this->id . "_next_page"; + if($end > $pages) $end = $pages; + + + if ($this->startLinks && $start > 1) { + $pos = $start - 1; + $numbers .= "$this->startLinks "; + } + + for($i=$start; $i <= $end; $i++) { + if ($this->rs->AbsolutePage() == $i) + $numbers .= "linkSelectedColor>$i "; + else + $numbers .= "$i "; + + } + if ($this->moreLinks && $end < $pages) + $numbers .= "$this->moreLinks "; + print $numbers . '   '; + } + // Link to previous page + function render_prev($anchor=true) + { + global $PHP_SELF; + if ($anchor) { + ?> + prev;?>   + prev   "; + } + } + + //-------------------------------------------------------- + // Simply rendering of grid. You should override this for + // better control over the format of the grid + // + // We use output buffering to keep code clean and readable. + function RenderGrid() + { + global $gSQLBlockRows; // used by rs2html to indicate how many rows to display + include_once(ADODB_DIR.'/tohtml.inc.php'); + ob_start(); + $gSQLBlockRows = $this->rows; + rs2html($this->rs,$this->gridAttributes,$this->gridHeader,$this->htmlSpecialChars); + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + + //------------------------------------------------------- + // Navigation bar + // + // we use output buffering to keep the code easy to read. + function RenderNav() + { + ob_start(); + if (!$this->rs->AtFirstPage()) { + $this->Render_First(); + $this->Render_Prev(); + } else { + $this->Render_First(false); + $this->Render_Prev(false); + } + if ($this->showPageLinks){ + $this->Render_PageLinks(); + } + if (!$this->rs->AtLastPage()) { + $this->Render_Next(); + $this->Render_Last(); + } else { + $this->Render_Next(false); + $this->Render_Last(false); + } + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + + //------------------- + // This is the footer + function RenderPageCount() + { + if (!$this->db->pageExecuteCountRows) return ''; + $lastPage = $this->rs->LastPageNo(); + if ($lastPage == -1) $lastPage = 1; // check for empty rs. + if ($this->curr_page > $lastPage) $this->curr_page = 1; + return "$this->page ".$this->curr_page."/".$lastPage.""; + } + + //----------------------------------- + // Call this class to draw everything. + function Render($rows=10) + { + global $ADODB_COUNTRECS; + + $this->rows = $rows; + + if ($this->db->dataProvider == 'informix') $this->db->cursorType = IFX_SCROLL; + + $savec = $ADODB_COUNTRECS; + if ($this->db->pageExecuteCountRows) $ADODB_COUNTRECS = true; + if ($this->cache) + $rs = &$this->db->CachePageExecute($this->cache,$this->sql,$rows,$this->curr_page); + else + $rs = &$this->db->PageExecute($this->sql,$rows,$this->curr_page); + $ADODB_COUNTRECS = $savec; + + $this->rs = &$rs; + if (!$rs) { + print "

    Query failed: $this->sql

    "; + return; + } + + if (!$rs->EOF && (!$rs->AtFirstPage() || !$rs->AtLastPage())) + $header = $this->RenderNav(); + else + $header = " "; + + $grid = $this->RenderGrid(); + $footer = $this->RenderPageCount(); + + $this->RenderLayout($header,$grid,$footer); + + $rs->Close(); + $this->rs = false; + } + + //------------------------------------------------------ + // override this to control overall layout and formating + function RenderLayout($header,$grid,$footer,$attributes='border=1 bgcolor=beige') + { + echo "
    ", + $header, + "
    ", + $grid, + "
    ", + $footer, + "
    "; + } +} + + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-pear.inc.php b/upload/includes/adodb/adodb-pear.inc.php new file mode 100644 index 00000000..7edee370 --- /dev/null +++ b/upload/includes/adodb/adodb-pear.inc.php @@ -0,0 +1,374 @@ + | + * and Tomas V.V.Cox . Portions (c)1997-2002 The PHP Group. + */ + + /* + We support: + + DB_Common + --------- + query - returns PEAR_Error on error + limitQuery - return PEAR_Error on error + prepare - does not return PEAR_Error on error + execute - does not return PEAR_Error on error + setFetchMode - supports ASSOC and ORDERED + errorNative + quote + nextID + disconnect + + getOne + getAssoc + getRow + getCol + getAll + + DB_Result + --------- + numRows - returns -1 if not supported + numCols + fetchInto - does not support passing of fetchmode + fetchRows - does not support passing of fetchmode + free + */ + +define('ADODB_PEAR',dirname(__FILE__)); +include_once "PEAR.php"; +include_once ADODB_PEAR."/adodb-errorpear.inc.php"; +include_once ADODB_PEAR."/adodb.inc.php"; + +if (!defined('DB_OK')) { +define("DB_OK", 1); +define("DB_ERROR",-1); + +// autoExecute constants +define('DB_AUTOQUERY_INSERT', 1); +define('DB_AUTOQUERY_UPDATE', 2); + +/** + * This is a special constant that tells DB the user hasn't specified + * any particular get mode, so the default should be used. + */ + +define('DB_FETCHMODE_DEFAULT', 0); + +/** + * Column data indexed by numbers, ordered from 0 and up + */ + +define('DB_FETCHMODE_ORDERED', 1); + +/** + * Column data indexed by column names + */ + +define('DB_FETCHMODE_ASSOC', 2); + +/* for compatibility */ + +define('DB_GETMODE_ORDERED', DB_FETCHMODE_ORDERED); +define('DB_GETMODE_ASSOC', DB_FETCHMODE_ASSOC); + +/** + * these are constants for the tableInfo-function + * they are bitwised or'ed. so if there are more constants to be defined + * in the future, adjust DB_TABLEINFO_FULL accordingly + */ + +define('DB_TABLEINFO_ORDER', 1); +define('DB_TABLEINFO_ORDERTABLE', 2); +define('DB_TABLEINFO_FULL', 3); +} + +/** + * The main "DB" class is simply a container class with some static + * methods for creating DB objects as well as some utility functions + * common to all parts of DB. + * + */ + +class DB +{ + /** + * Create a new DB object for the specified database type + * + * @param $type string database type, for example "mysql" + * + * @return object a newly created DB object, or a DB error code on + * error + */ + + function &factory($type) + { + include_once(ADODB_DIR."/drivers/adodb-$type.inc.php"); + $obj = &NewADOConnection($type); + if (!is_object($obj)) $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + return $obj; + } + + /** + * Create a new DB object and connect to the specified database + * + * @param $dsn mixed "data source name", see the DB::parseDSN + * method for a description of the dsn format. Can also be + * specified as an array of the format returned by DB::parseDSN. + * + * @param $options mixed if boolean (or scalar), tells whether + * this connection should be persistent (for backends that support + * this). This parameter can also be an array of options, see + * DB_common::setOption for more information on connection + * options. + * + * @return object a newly created DB connection object, or a DB + * error object on error + * + * @see DB::parseDSN + * @see DB::isError + */ + function &connect($dsn, $options = false) + { + if (is_array($dsn)) { + $dsninfo = $dsn; + } else { + $dsninfo = DB::parseDSN($dsn); + } + switch ($dsninfo["phptype"]) { + case 'pgsql': $type = 'postgres7'; break; + case 'ifx': $type = 'informix9'; break; + default: $type = $dsninfo["phptype"]; break; + } + + if (is_array($options) && isset($options["debug"]) && + $options["debug"] >= 2) { + // expose php errors with sufficient debug level + @include_once("adodb-$type.inc.php"); + } else { + @include_once("adodb-$type.inc.php"); + } + + @$obj =& NewADOConnection($type); + if (!is_object($obj)) { + $obj =& new PEAR_Error('Unknown Database Driver: '.$dsninfo['phptype'],-1); + return $obj; + } + if (is_array($options)) { + foreach($options as $k => $v) { + switch(strtolower($k)) { + case 'persist': + case 'persistent': $persist = $v; break; + #ibase + case 'dialect': $obj->dialect = $v; break; + case 'charset': $obj->charset = $v; break; + case 'buffers': $obj->buffers = $v; break; + #ado + case 'charpage': $obj->charPage = $v; break; + #mysql + case 'clientflags': $obj->clientFlags = $v; break; + } + } + } else { + $persist = false; + } + + if (isset($dsninfo['socket'])) $dsninfo['hostspec'] .= ':'.$dsninfo['socket']; + else if (isset($dsninfo['port'])) $dsninfo['hostspec'] .= ':'.$dsninfo['port']; + + if($persist) $ok = $obj->PConnect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); + else $ok = $obj->Connect($dsninfo['hostspec'], $dsninfo['username'],$dsninfo['password'],$dsninfo['database']); + + if (!$ok) $obj = ADODB_PEAR_Error(); + return $obj; + } + + /** + * Return the DB API version + * + * @return int the DB API version number + */ + function apiVersion() + { + return 2; + } + + /** + * Tell whether a result code from a DB method is an error + * + * @param $value int result code + * + * @return bool whether $value is an error + */ + function isError($value) + { + if (!is_object($value)) return false; + $class = get_class($value); + return $class == 'pear_error' || is_subclass_of($value, 'pear_error') || + $class == 'db_error' || is_subclass_of($value, 'db_error'); + } + + + /** + * Tell whether a result code from a DB method is a warning. + * Warnings differ from errors in that they are generated by DB, + * and are not fatal. + * + * @param $value mixed result value + * + * @return bool whether $value is a warning + */ + function isWarning($value) + { + return false; + /* + return is_object($value) && + (get_class( $value ) == "db_warning" || + is_subclass_of($value, "db_warning"));*/ + } + + /** + * Parse a data source name + * + * @param $dsn string Data Source Name to be parsed + * + * @return array an associative array with the following keys: + * + * phptype: Database backend used in PHP (mysql, odbc etc.) + * dbsyntax: Database used with regards to SQL syntax etc. + * protocol: Communication protocol to use (tcp, unix etc.) + * hostspec: Host specification (hostname[:port]) + * database: Database to use on the DBMS server + * username: User name for login + * password: Password for login + * + * The format of the supplied DSN is in its fullest form: + * + * phptype(dbsyntax)://username:password@protocol+hostspec/database + * + * Most variations are allowed: + * + * phptype://username:password@protocol+hostspec:110//usr/db_file.db + * phptype://username:password@hostspec/database_name + * phptype://username:password@hostspec + * phptype://username@hostspec + * phptype://hostspec/database + * phptype://hostspec + * phptype(dbsyntax) + * phptype + * + * @author Tomas V.V.Cox + */ + function parseDSN($dsn) + { + if (is_array($dsn)) { + return $dsn; + } + + $parsed = array( + 'phptype' => false, + 'dbsyntax' => false, + 'protocol' => false, + 'hostspec' => false, + 'database' => false, + 'username' => false, + 'password' => false + ); + + // Find phptype and dbsyntax + if (($pos = strpos($dsn, '://')) !== false) { + $str = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 3); + } else { + $str = $dsn; + $dsn = NULL; + } + + // Get phptype and dbsyntax + // $str => phptype(dbsyntax) + if (preg_match('|^(.+?)\((.*?)\)$|', $str, $arr)) { + $parsed['phptype'] = $arr[1]; + $parsed['dbsyntax'] = (empty($arr[2])) ? $arr[1] : $arr[2]; + } else { + $parsed['phptype'] = $str; + $parsed['dbsyntax'] = $str; + } + + if (empty($dsn)) { + return $parsed; + } + + // Get (if found): username and password + // $dsn => username:password@protocol+hostspec/database + if (($at = strpos($dsn,'@')) !== false) { + $str = substr($dsn, 0, $at); + $dsn = substr($dsn, $at + 1); + if (($pos = strpos($str, ':')) !== false) { + $parsed['username'] = urldecode(substr($str, 0, $pos)); + $parsed['password'] = urldecode(substr($str, $pos + 1)); + } else { + $parsed['username'] = urldecode($str); + } + } + + // Find protocol and hostspec + // $dsn => protocol+hostspec/database + if (($pos=strpos($dsn, '/')) !== false) { + $str = substr($dsn, 0, $pos); + $dsn = substr($dsn, $pos + 1); + } else { + $str = $dsn; + $dsn = NULL; + } + + // Get protocol + hostspec + // $str => protocol+hostspec + if (($pos=strpos($str, '+')) !== false) { + $parsed['protocol'] = substr($str, 0, $pos); + $parsed['hostspec'] = urldecode(substr($str, $pos + 1)); + } else { + $parsed['hostspec'] = urldecode($str); + } + + // Get dabase if any + // $dsn => database + if (!empty($dsn)) { + $parsed['database'] = $dsn; + } + + return $parsed; + } + + /** + * Load a PHP database extension if it is not loaded already. + * + * @access public + * + * @param $name the base name of the extension (without the .so or + * .dll suffix) + * + * @return bool true if the extension was already or successfully + * loaded, false if it could not be loaded + */ + function assertExtension($name) + { + if (!extension_loaded($name)) { + $dlext = (strncmp(PHP_OS,'WIN',3) === 0) ? '.dll' : '.so'; + @dl($name . $dlext); + } + if (!extension_loaded($name)) { + return false; + } + return true; + } +} + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-perf.inc.php b/upload/includes/adodb/adodb-perf.inc.php new file mode 100644 index 00000000..f6eb10d7 --- /dev/null +++ b/upload/includes/adodb/adodb-perf.inc.php @@ -0,0 +1,1079 @@ +=2) return (integer) $memarr[1]; + + return 0; +} + +// avoids localization problems where , is used instead of . +function adodb_round($n,$prec) +{ + return number_format($n, $prec, '.', ''); +} + +/* return microtime value as a float */ +function adodb_microtime() +{ + $t = microtime(); + $t = explode(' ',$t); + return (float)$t[1]+ (float)$t[0]; +} + +/* sql code timing */ +function& adodb_log_sql(&$connx,$sql,$inputarr) +{ + $perf_table = adodb_perf::table(); + $connx->fnExecute = false; + $t0 = microtime(); + $rs =& $connx->Execute($sql,$inputarr); + $t1 = microtime(); + + if (!empty($connx->_logsql) && (empty($connx->_logsqlErrors) || !$rs)) { + global $ADODB_LOG_CONN; + + if (!empty($ADODB_LOG_CONN)) { + $conn = &$ADODB_LOG_CONN; + if ($conn->databaseType != $connx->databaseType) + $prefix = '/*dbx='.$connx->databaseType .'*/ '; + else + $prefix = ''; + } else { + $conn =& $connx; + $prefix = ''; + } + + $conn->_logsql = false; // disable logsql error simulation + $dbT = $conn->databaseType; + + $a0 = split(' ',$t0); + $a0 = (float)$a0[1]+(float)$a0[0]; + + $a1 = split(' ',$t1); + $a1 = (float)$a1[1]+(float)$a1[0]; + + $time = $a1 - $a0; + + if (!$rs) { + $errM = $connx->ErrorMsg(); + $errN = $connx->ErrorNo(); + $conn->lastInsID = 0; + $tracer = substr('ERROR: '.htmlspecialchars($errM),0,250); + } else { + $tracer = ''; + $errM = ''; + $errN = 0; + $dbg = $conn->debug; + $conn->debug = false; + if (!is_object($rs) || $rs->dataProvider == 'empty') + $conn->_affected = $conn->affected_rows(true); + $conn->lastInsID = @$conn->Insert_ID(); + $conn->debug = $dbg; + } + if (isset($_SERVER['HTTP_HOST'])) { + $tracer .= '
    '.$_SERVER['HTTP_HOST']; + if (isset($_SERVER['PHP_SELF'])) $tracer .= $_SERVER['PHP_SELF']; + } else + if (isset($_SERVER['PHP_SELF'])) $tracer .= '
    '.$_SERVER['PHP_SELF']; + //$tracer .= (string) adodb_backtrace(false); + + $tracer = (string) substr($tracer,0,500); + + if (is_array($inputarr)) { + if (is_array(reset($inputarr))) $params = 'Array sizeof='.sizeof($inputarr); + else { + // Quote string parameters so we can see them in the + // performance stats. This helps spot disabled indexes. + $xar_params = $inputarr; + foreach ($xar_params as $xar_param_key => $xar_param) { + if (gettype($xar_param) == 'string') + $xar_params[$xar_param_key] = '"' . $xar_param . '"'; + } + $params = implode(', ', $xar_params); + if (strlen($params) >= 3000) $params = substr($params, 0, 3000); + } + } else { + $params = ''; + } + + if (is_array($sql)) $sql = $sql[0]; + if ($prefix) $sql = $prefix.$sql; + $arr = array('b'=>strlen($sql).'.'.crc32($sql), + 'c'=>substr($sql,0,3900), 'd'=>$params,'e'=>$tracer,'f'=>adodb_round($time,6)); + //var_dump($arr); + $saved = $conn->debug; + $conn->debug = 0; + + $d = $conn->sysTimeStamp; + if (empty($d)) $d = date("'Y-m-d H:i:s'"); + if ($conn->dataProvider == 'oci8' && $dbT != 'oci8po') { + $isql = "insert into $perf_table values($d,:b,:c,:d,:e,:f)"; + } else if ($dbT == 'odbc_mssql' || $dbT == 'informix' || strncmp($dbT,'odbtp',4)==0) { + $timer = $arr['f']; + if ($dbT == 'informix') $sql2 = substr($sql2,0,230); + + $sql1 = $conn->qstr($arr['b']); + $sql2 = $conn->qstr($arr['c']); + $params = $conn->qstr($arr['d']); + $tracer = $conn->qstr($arr['e']); + + $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values($d,$sql1,$sql2,$params,$tracer,$timer)"; + if ($dbT == 'informix') $isql = str_replace(chr(10),' ',$isql); + $arr = false; + } else { + if ($dbT == 'db2') $arr['f'] = (float) $arr['f']; + $isql = "insert into $perf_table (created,sql0,sql1,params,tracer,timer) values( $d,?,?,?,?,?)"; + } + $ok = $conn->Execute($isql,$arr); + $conn->debug = $saved; + + if ($ok) { + $conn->_logsql = true; + } else { + $err2 = $conn->ErrorMsg(); + $conn->_logsql = true; // enable logsql error simulation + $perf =& NewPerfMonitor($conn); + if ($perf) { + if ($perf->CreateLogTable()) $ok = $conn->Execute($isql,$arr); + } else { + $ok = $conn->Execute("create table $perf_table ( + created varchar(50), + sql0 varchar(250), + sql1 varchar(4000), + params varchar(3000), + tracer varchar(500), + timer decimal(16,6))"); + } + if (!$ok) { + ADOConnection::outp( "

    LOGSQL Insert Failed: $isql
    $err2

    "); + $conn->_logsql = false; + } + } + $connx->_errorMsg = $errM; + $connx->_errorCode = $errN; + } + $connx->fnExecute = 'adodb_log_sql'; + return $rs; +} + + +/* +The settings data structure is an associative array that database parameter per element. + +Each database parameter element in the array is itself an array consisting of: + +0: category code, used to group related db parameters +1: either + a. sql string to retrieve value, eg. "select value from v\$parameter where name='db_block_size'", + b. array holding sql string and field to look for, e.g. array('show variables','table_cache'), + c. a string prefixed by =, then a PHP method of the class is invoked, + e.g. to invoke $this->GetIndexValue(), set this array element to '=GetIndexValue', +2: description of the database parameter +*/ + +class adodb_perf { + var $conn; + var $color = '#F0F0F0'; + var $table = ''; + var $titles = ''; + var $warnRatio = 90; + var $tablesSQL = false; + var $cliFormat = "%32s => %s \r\n"; + var $sql1 = 'sql1'; // used for casting sql1 to text for mssql + var $explain = true; + var $helpurl = "LogSQL help"; + var $createTableSQL = false; + var $maxLength = 2000; + + // Sets the tablename to be used + function table($newtable = false) + { + static $_table; + + if (!empty($newtable)) $_table = $newtable; + if (empty($_table)) $_table = 'adodb_logsql'; + return $_table; + } + + // returns array with info to calculate CPU Load + function _CPULoad() + { +/* + +cpu 524152 2662 2515228 336057010 +cpu0 264339 1408 1257951 168025827 +cpu1 259813 1254 1257277 168031181 +page 622307 25475680 +swap 24 1891 +intr 890153570 868093576 6 0 4 4 0 6 1 2 0 0 0 124 0 8098760 2 13961053 0 0 0 0 0 0 0 0 0 0 0 0 0 16 16 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 +disk_io: (3,0):(3144904,54369,610378,3090535,50936192) (3,1):(3630212,54097,633016,3576115,50951320) +ctxt 66155838 +btime 1062315585 +processes 69293 + +*/ + // Algorithm is taken from + // http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/example__obtaining_raw_performance_data.asp + if (strncmp(PHP_OS,'WIN',3)==0) { + if (PHP_VERSION == '5.0.0') return false; + if (PHP_VERSION == '5.0.1') return false; + if (PHP_VERSION == '5.0.2') return false; + if (PHP_VERSION == '5.0.3') return false; + if (PHP_VERSION == '4.3.10') return false; # see http://bugs.php.net/bug.php?id=31737 + + @$c = new COM("WinMgmts:{impersonationLevel=impersonate}!Win32_PerfRawData_PerfOS_Processor.Name='_Total'"); + if (!$c) return false; + + $info[0] = $c->PercentProcessorTime; + $info[1] = 0; + $info[2] = 0; + $info[3] = $c->TimeStamp_Sys100NS; + //print_r($info); + return $info; + } + + // Algorithm - Steve Blinch (BlitzAffe Online, http://www.blitzaffe.com) + $statfile = '/proc/stat'; + if (!file_exists($statfile)) return false; + + $fd = fopen($statfile,"r"); + if (!$fd) return false; + + $statinfo = explode("\n",fgets($fd, 1024)); + fclose($fd); + foreach($statinfo as $line) { + $info = explode(" ",$line); + if($info[0]=="cpu") { + array_shift($info); // pop off "cpu" + if(!$info[0]) array_shift($info); // pop off blank space (if any) + return $info; + } + } + + return false; + + } + + /* NOT IMPLEMENTED */ + function MemInfo() + { + /* + + total: used: free: shared: buffers: cached: +Mem: 1055289344 917299200 137990144 0 165437440 599773184 +Swap: 2146775040 11055104 2135719936 +MemTotal: 1030556 kB +MemFree: 134756 kB +MemShared: 0 kB +Buffers: 161560 kB +Cached: 581384 kB +SwapCached: 4332 kB +Active: 494468 kB +Inact_dirty: 322856 kB +Inact_clean: 24256 kB +Inact_target: 168316 kB +HighTotal: 131064 kB +HighFree: 1024 kB +LowTotal: 899492 kB +LowFree: 133732 kB +SwapTotal: 2096460 kB +SwapFree: 2085664 kB +Committed_AS: 348732 kB + */ + } + + + /* + Remember that this is client load, not db server load! + */ + var $_lastLoad; + function CPULoad() + { + $info = $this->_CPULoad(); + if (!$info) return false; + + if (empty($this->_lastLoad)) { + sleep(1); + $this->_lastLoad = $info; + $info = $this->_CPULoad(); + } + + $last = $this->_lastLoad; + $this->_lastLoad = $info; + + $d_user = $info[0] - $last[0]; + $d_nice = $info[1] - $last[1]; + $d_system = $info[2] - $last[2]; + $d_idle = $info[3] - $last[3]; + + //printf("Delta - User: %f Nice: %f System: %f Idle: %f
    ",$d_user,$d_nice,$d_system,$d_idle); + + if (strncmp(PHP_OS,'WIN',3)==0) { + if ($d_idle < 1) $d_idle = 1; + return 100*(1-$d_user/$d_idle); + }else { + $total=$d_user+$d_nice+$d_system+$d_idle; + if ($total<1) $total=1; + return 100*($d_user+$d_nice+$d_system)/$total; + } + } + + function Tracer($sql) + { + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $sqlq = $this->conn->qstr($sql); + $arr = $this->conn->GetArray( +"select count(*),tracer + from $perf_table where sql1=$sqlq + group by tracer + order by 1 desc"); + $s = ''; + if ($arr) { + $s .= '

    Scripts Affected

    '; + foreach($arr as $k) { + $s .= sprintf("%4d",$k[0]).'   '.strip_tags($k[1]).'
    '; + } + } + + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_CACHE_MODE = $save; + $this->conn->fnExecute = $saveE; + return $s; + } + + /* + Explain Plan for $sql. + If only a snippet of the $sql is passed in, then $partial will hold the crc32 of the + actual sql. + */ + function Explain($sql,$partial=false) + { + return false; + } + + function InvalidSQL($numsql = 10) + { + + if (isset($_GET['sql'])) return; + $s = '

    Invalid SQL

    '; + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + $perf_table = adodb_perf::table(); + $rs =& $this->conn->SelectLimit("select distinct count(*),sql1,tracer as error_msg from $perf_table where tracer like 'ERROR:%' group by sql1,tracer order by 1 desc",$numsql);//,$numsql); + $this->conn->fnExecute = $saveE; + if ($rs) { + $s .= rs2html($rs,false,false,false,false); + } else + return "

    $this->helpurl. ".$this->conn->ErrorMsg()."

    "; + + return $s; + } + + + /* + This script identifies the longest running SQL + */ + function _SuspiciousSQL($numsql = 10) + { + global $ADODB_FETCH_MODE; + + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + if (isset($_GET['exps']) && isset($_GET['sql'])) { + $partial = !empty($_GET['part']); + echo "".$this->Explain($_GET['sql'],$partial)."\n"; + } + + if (isset($_GET['sql'])) return; + $sql1 = $this->sql1; + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + //$this->conn->debug=1; + $rs =& $this->conn->SelectLimit( + "select avg(timer) as avg_timer,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer + from $perf_table + where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT') + and (tracer is null or tracer not like 'ERROR:%') + group by sql1 + order by 1 desc",$numsql); + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + $this->conn->fnExecute = $saveE; + + if (!$rs) return "

    $this->helpurl. ".$this->conn->ErrorMsg()."

    "; + $s = "

    Suspicious SQL

    +The following SQL have high average execution times
    +
    ParameterValueDescription
    \n"; + $max = $this->maxLength; + while (!$rs->EOF) { + $sql = $rs->fields[1]; + $raw = urlencode($sql); + if (strlen($raw)>$max-100) { + $sql2 = substr($sql,0,$max-500); + $raw = urlencode($sql2).'&part='.crc32($sql); + } + $prefix = ""; + $suffix = ""; + if ($this->explain == false || strlen($prefix)>$max) { + $suffix = ' ... String too long for GET parameter: '.strlen($prefix).''; + $prefix = ''; + } + $s .= ""; + $rs->MoveNext(); + } + return $s."
    Avg TimeCountSQLMaxMin
    ".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + "".$rs->fields[3]."".$rs->fields[4]."
    "; + + } + + function CheckMemory() + { + return ''; + } + + + function SuspiciousSQL($numsql=10) + { + return adodb_perf::_SuspiciousSQL($numsql); + } + + function ExpensiveSQL($numsql=10) + { + return adodb_perf::_ExpensiveSQL($numsql); + } + + + /* + This reports the percentage of load on the instance due to the most + expensive few SQL statements. Tuning these statements can often + make huge improvements in overall system performance. + */ + function _ExpensiveSQL($numsql = 10) + { + global $ADODB_FETCH_MODE; + + $perf_table = adodb_perf::table(); + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + + if (isset($_GET['expe']) && isset($_GET['sql'])) { + $partial = !empty($_GET['part']); + echo "".$this->Explain($_GET['sql'],$partial)."\n"; + } + + if (isset($_GET['sql'])) return; + + $sql1 = $this->sql1; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $rs =& $this->conn->SelectLimit( + "select sum(timer) as total,$sql1,count(*),max(timer) as max_timer,min(timer) as min_timer + from $perf_table + where {$this->conn->upperCase}({$this->conn->substr}(sql0,1,5)) not in ('DROP ','INSER','COMMI','CREAT') + and (tracer is null or tracer not like 'ERROR:%') + group by sql1 + having count(*)>1 + order by 1 desc",$numsql); + if (isset($savem)) $this->conn->SetFetchMode($savem); + $this->conn->fnExecute = $saveE; + $ADODB_FETCH_MODE = $save; + if (!$rs) return "

    $this->helpurl. ".$this->conn->ErrorMsg()."

    "; + $s = "

    Expensive SQL

    +Tuning the following SQL could reduce the server load substantially
    +\n"; + $max = $this->maxLength; + while (!$rs->EOF) { + $sql = $rs->fields[1]; + $raw = urlencode($sql); + if (strlen($raw)>$max-100) { + $sql2 = substr($sql,0,$max-500); + $raw = urlencode($sql2).'&part='.crc32($sql); + } + $prefix = ""; + $suffix = ""; + if($this->explain == false || strlen($prefix>$max)) { + $prefix = ''; + $suffix = ''; + } + $s .= ""; + $rs->MoveNext(); + } + return $s."
    LoadCountSQLMaxMin
    ".adodb_round($rs->fields[0],6)."".$rs->fields[2]."".$prefix.htmlspecialchars($sql).$suffix."". + "".$rs->fields[3]."".$rs->fields[4]."
    "; + } + + /* + Raw function to return parameter value from $settings. + */ + function DBParameter($param) + { + if (empty($this->settings[$param])) return false; + $sql = $this->settings[$param][1]; + return $this->_DBParameter($sql); + } + + /* + Raw function returning array of poll paramters + */ + function &PollParameters() + { + $arr[0] = (float)$this->DBParameter('data cache hit ratio'); + $arr[1] = (float)$this->DBParameter('data reads'); + $arr[2] = (float)$this->DBParameter('data writes'); + $arr[3] = (integer) $this->DBParameter('current connections'); + return $arr; + } + + /* + Low-level Get Database Parameter + */ + function _DBParameter($sql) + { + $savelog = $this->conn->LogSQL(false); + if (is_array($sql)) { + global $ADODB_FETCH_MODE; + + $sql1 = $sql[0]; + $key = $sql[1]; + if (sizeof($sql)>2) $pos = $sql[2]; + else $pos = 1; + if (sizeof($sql)>3) $coef = $sql[3]; + else $coef = false; + $ret = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->conn->fetchMode !== false) $savem = $this->conn->SetFetchMode(false); + + $rs = $this->conn->Execute($sql1); + + if (isset($savem)) $this->conn->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if ($rs) { + while (!$rs->EOF) { + $keyf = reset($rs->fields); + if (trim($keyf) == $key) { + $ret = $rs->fields[$pos]; + if ($coef) $ret *= $coef; + break; + } + $rs->MoveNext(); + } + $rs->Close(); + } + $this->conn->LogSQL($savelog); + return $ret; + } else { + if (strncmp($sql,'=',1) == 0) { + $fn = substr($sql,1); + return $this->$fn(); + } + $sql = str_replace('$DATABASE',$this->conn->database,$sql); + $ret = $this->conn->GetOne($sql); + $this->conn->LogSQL($savelog); + + return $ret; + } + } + + /* + Warn if cache ratio falls below threshold. Displayed in "Description" column. + */ + function WarnCacheRatio($val) + { + if ($val < $this->warnRatio) + return 'Cache ratio should be at least '.$this->warnRatio.'%'; + else return ''; + } + + function clearsql() + { + $perf_table = adodb_perf::table(); + $this->conn->Execute("delete from $perf_table where created<".$this->conn->sysTimeStamp); + } + + /***********************************************************************************************/ + // HIGH LEVEL UI FUNCTIONS + /***********************************************************************************************/ + + + function UI($pollsecs=5) + { + global $ADODB_LOG_CONN; + + $perf_table = adodb_perf::table(); + $conn = $this->conn; + + $app = $conn->host; + if ($conn->host && $conn->database) $app .= ', db='; + $app .= $conn->database; + + if ($app) $app .= ', '; + $savelog = $this->conn->LogSQL(false); + $info = $conn->ServerInfo(); + if (isset($_GET['clearsql'])) { + $this->clearsql(); + } + $this->conn->LogSQL($savelog); + + // magic quotes + + if (isset($_GET['sql']) && get_magic_quotes_gpc()) { + $_GET['sql'] = $_GET['sql'] = str_replace(array("\\'",'\"'),array("'",'"'),$_GET['sql']); + } + + if (!isset($_SESSION['ADODB_PERF_SQL'])) $nsql = $_SESSION['ADODB_PERF_SQL'] = 10; + else $nsql = $_SESSION['ADODB_PERF_SQL']; + + $app .= $info['description']; + + + if (isset($_GET['do'])) $do = $_GET['do']; + else if (isset($_POST['do'])) $do = $_POST['do']; + else if (isset($_GET['sql'])) $do = 'viewsql'; + else $do = 'stats'; + + if (isset($_GET['nsql'])) { + if ($_GET['nsql'] > 0) $nsql = $_SESSION['ADODB_PERF_SQL'] = (integer) $_GET['nsql']; + } + echo "ADOdb Performance Monitor on $app"; + if ($do == 'viewsql') $form = "
    # SQL:
    "; + else $form = " "; + + $allowsql = !defined('ADODB_PERF_NO_RUN_SQL'); + + if (empty($_GET['hidem'])) + echo "
    + ADOdb Performance Monitor for $app
    + Performance Stats   View SQL +   View Tables   Poll Stats", + $allowsql ? '   Run SQL' : '', + "$form", + "
    "; + + + switch ($do) { + default: + case 'stats': + + if (empty($ADODB_LOG_CONN)) + echo "

      Clear SQL Log
    "; + echo $this->HealthCheck(); + //$this->conn->debug=1; + echo $this->CheckMemory(); + global $ADODB_LOG_CONN; + break; + case 'poll': + echo ""; + break; + case 'poll2': + echo "

    ";
    +			$this->Poll($pollsecs);
    +			break;
    +		
    +		case 'dosql':
    +			if (!$allowsql) break;
    +			
    +			$this->DoSQLForm();
    +			break;
    +		case 'viewsql':
    +			if (empty($_GET['hidem']))
    +				echo "  Clear SQL Log
    "; + echo($this->SuspiciousSQL($nsql)); + echo($this->ExpensiveSQL($nsql)); + echo($this->InvalidSQL($nsql)); + break; + case 'tables': + echo $this->Tables(); break; + } + global $ADODB_vers; + echo "

    $ADODB_vers Sponsored by phpLens
    "; + } + + /* + Runs in infinite loop, returning real-time statistics + */ + function Poll($secs=5) + { + $this->conn->fnExecute = false; + //$this->conn->debug=1; + if ($secs <= 1) $secs = 1; + echo "Accumulating statistics, every $secs seconds...\n";flush(); + $arro =& $this->PollParameters(); + $cnt = 0; + set_time_limit(0); + sleep($secs); + while (1) { + + $arr =& $this->PollParameters(); + + $hits = sprintf('%2.2f',$arr[0]); + $reads = sprintf('%12.4f',($arr[1]-$arro[1])/$secs); + $writes = sprintf('%12.4f',($arr[2]-$arro[2])/$secs); + $sess = sprintf('%5d',$arr[3]); + + $load = $this->CPULoad(); + if ($load !== false) { + $oslabel = 'WS-CPU%'; + $osval = sprintf(" %2.1f ",(float) $load); + }else { + $oslabel = ''; + $osval = ''; + } + if ($cnt % 10 == 0) echo " Time ".$oslabel." Hit% Sess Reads/s Writes/s\n"; + $cnt += 1; + echo date('H:i:s').' '.$osval."$hits $sess $reads $writes\n"; + flush(); + + if (connection_aborted()) return; + + sleep($secs); + $arro = $arr; + } + } + + /* + Returns basic health check in a command line interface + */ + function HealthCheckCLI() + { + return $this->HealthCheck(true); + } + + + /* + Returns basic health check as HTML + */ + function HealthCheck($cli=false) + { + $saveE = $this->conn->fnExecute; + $this->conn->fnExecute = false; + if ($cli) $html = ''; + else $html = $this->table.'

    '.$this->conn->databaseType.'

    '.$this->titles; + + $oldc = false; + $bgc = ''; + foreach($this->settings as $name => $arr) { + if ($arr === false) break; + + if (!is_string($name)) { + if ($cli) $html .= " -- $arr -- \n"; + else $html .= "color>$arr  "; + continue; + } + + if (!is_array($arr)) break; + $category = $arr[0]; + $how = $arr[1]; + if (sizeof($arr)>2) $desc = $arr[2]; + else $desc = '   '; + + + if ($category == 'HIDE') continue; + + $val = $this->_DBParameter($how); + + if ($desc && strncmp($desc,"=",1) === 0) { + $fn = substr($desc,1); + $desc = $this->$fn($val); + } + + if ($val === false) { + $m = $this->conn->ErrorMsg(); + $val = "Error: $m"; + } else { + if (is_numeric($val) && $val >= 256*1024) { + if ($val % (1024*1024) == 0) { + $val /= (1024*1024); + $val .= 'M'; + } else if ($val % 1024 == 0) { + $val /= 1024; + $val .= 'K'; + } + //$val = htmlspecialchars($val); + } + } + if ($category != $oldc) { + $oldc = $category; + //$bgc = ($bgc == ' bgcolor='.$this->color) ? ' bgcolor=white' : ' bgcolor='.$this->color; + } + if (strlen($desc)==0) $desc = ' '; + if (strlen($val)==0) $val = ' '; + if ($cli) { + $html .= str_replace(' ','',sprintf($this->cliFormat,strip_tags($name),strip_tags($val),strip_tags($desc))); + + }else { + $html .= "".$name.''.$val.''.$desc."\n"; + } + } + + if (!$cli) $html .= "\n"; + $this->conn->fnExecute = $saveE; + + return $html; + } + + function Tables($orderby='1') + { + if (!$this->tablesSQL) return false; + + $savelog = $this->conn->LogSQL(false); + $rs = $this->conn->Execute($this->tablesSQL.' order by '.$orderby); + $this->conn->LogSQL($savelog); + $html = rs2html($rs,false,false,false,false); + return $html; + } + + + function CreateLogTable() + { + if (!$this->createTableSQL) return false; + + $table = $this->table(); + $sql = str_replace('adodb_logsql',$table,$this->createTableSQL); + $savelog = $this->conn->LogSQL(false); + $ok = $this->conn->Execute($sql); + $this->conn->LogSQL($savelog); + return ($ok) ? true : false; + } + + function DoSQLForm() + { + + + $PHP_SELF = $_SERVER['PHP_SELF']; + $sql = isset($_REQUEST['sql']) ? $_REQUEST['sql'] : ''; + + if (isset($_SESSION['phplens_sqlrows'])) $rows = $_SESSION['phplens_sqlrows']; + else $rows = 3; + + if (isset($_REQUEST['SMALLER'])) { + $rows /= 2; + if ($rows < 3) $rows = 3; + $_SESSION['phplens_sqlrows'] = $rows; + } + if (isset($_REQUEST['BIGGER'])) { + $rows *= 2; + $_SESSION['phplens_sqlrows'] = $rows; + } + +?> + +
    + + + + + + +
    Form size: + + +
    +
    +
    + +undomq(trim($sql)); + if (substr($sql,strlen($sql)-1) === ';') { + $print = true; + $sqla = $this->SplitSQL($sql); + } else { + $print = false; + $sqla = array($sql); + } + foreach($sqla as $sqls) { + + if (!$sqls) continue; + + if ($print) { + print "

    ".htmlspecialchars($sqls)."

    "; + flush(); + } + $savelog = $this->conn->LogSQL(false); + $rs = $this->conn->Execute($sqls); + $this->conn->LogSQL($savelog); + if ($rs && is_object($rs) && !$rs->EOF) { + rs2html($rs); + while ($rs->NextRecordSet()) { + print "
     
    "; + rs2html($rs); + } + } else { + $e1 = (integer) $this->conn->ErrorNo(); + $e2 = $this->conn->ErrorMsg(); + if (($e1) || ($e2)) { + if (empty($e1)) $e1 = '-1'; // postgresql fix + print '   '.$e1.': '.$e2; + } else { + print "

    No Recordset returned

    "; + } + } + } // foreach + } + + function SplitSQL($sql) + { + $arr = explode(';',$sql); + return $arr; + } + + function undomq($m) + { + if (get_magic_quotes_gpc()) { + // undo the damage + $m = str_replace('\\\\','\\',$m); + $m = str_replace('\"','"',$m); + $m = str_replace('\\\'','\'',$m); + } + return $m; +} + + + /************************************************************************/ + + /** + * Reorganise multiple table-indices/statistics/.. + * OptimizeMode could be given by last Parameter + * + * @example + *
    +     *          optimizeTables( 'tableA');
    +     *      
    + *
    +     *          optimizeTables( 'tableA', 'tableB', 'tableC');
    +     *      
    + *
    +     *          optimizeTables( 'tableA', 'tableB', ADODB_OPT_LOW);
    +     *      
    + * + * @param string table name of the table to optimize + * @param int mode optimization-mode + * ADODB_OPT_HIGH for full optimization + * ADODB_OPT_LOW for CPU-less optimization + * Default is LOW ADODB_OPT_LOW + * @author Markus Staab + * @return Returns true on success and false on error + */ + function OptimizeTables() + { + $args = func_get_args(); + $numArgs = func_num_args(); + + if ( $numArgs == 0) return false; + + $mode = ADODB_OPT_LOW; + $lastArg = $args[ $numArgs - 1]; + if ( !is_string($lastArg)) { + $mode = $lastArg; + unset( $args[ $numArgs - 1]); + } + + foreach( $args as $table) { + $this->optimizeTable( $table, $mode); + } + } + + /** + * Reorganise the table-indices/statistics/.. depending on the given mode. + * Default Implementation throws an error. + * + * @param string table name of the table to optimize + * @param int mode optimization-mode + * ADODB_OPT_HIGH for full optimization + * ADODB_OPT_LOW for CPU-less optimization + * Default is LOW ADODB_OPT_LOW + * @author Markus Staab + * @return Returns true on success and false on error + */ + function OptimizeTable( $table, $mode = ADODB_OPT_LOW) + { + ADOConnection::outp( sprintf( "

    %s: '%s' not implemented for driver '%s'

    ", __CLASS__, __FUNCTION__, $this->conn->databaseType)); + return false; + } + + /** + * Reorganise current database. + * Default implementation loops over all MetaTables() and + * optimize each using optmizeTable() + * + * @author Markus Staab + * @return Returns true on success and false on error + */ + function optimizeDatabase() + { + $conn = $this->conn; + if ( !$conn) return false; + + $tables = $conn->MetaTables( 'TABLES'); + if ( !$tables ) return false; + + foreach( $tables as $table) { + if ( !$this->optimizeTable( $table)) { + return false; + } + } + + return true; + } + // end hack +} + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb-php4.inc.php b/upload/includes/adodb/adodb-php4.inc.php new file mode 100644 index 00000000..9547027c --- /dev/null +++ b/upload/includes/adodb/adodb-php4.inc.php @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/upload/includes/adodb/adodb-time.inc.php b/upload/includes/adodb/adodb-time.inc.php new file mode 100644 index 00000000..e0a6a5de --- /dev/null +++ b/upload/includes/adodb/adodb-time.inc.php @@ -0,0 +1,1409 @@ + 4 digit year conversion. The maximum is billions of years in the +future, but this is a theoretical limit as the computation of that year +would take too long with the current implementation of adodb_mktime(). + +This library replaces native functions as follows: + +
    	
    +	getdate()  with  adodb_getdate()
    +	date()     with  adodb_date() 
    +	gmdate()   with  adodb_gmdate()
    +	mktime()   with  adodb_mktime()
    +	gmmktime() with  adodb_gmmktime()
    +	strftime() with  adodb_strftime()
    +	strftime() with  adodb_gmstrftime()
    +
    + +The parameters are identical, except that adodb_date() accepts a subset +of date()'s field formats. Mktime() will convert from local time to GMT, +and date() will convert from GMT to local time, but daylight savings is +not handled currently. + +This library is independant of the rest of ADOdb, and can be used +as standalone code. + +PERFORMANCE + +For high speed, this library uses the native date functions where +possible, and only switches to PHP code when the dates fall outside +the 32-bit signed integer range. + +GREGORIAN CORRECTION + +Pope Gregory shortened October of A.D. 1582 by ten days. Thursday, +October 4, 1582 (Julian) was followed immediately by Friday, October 15, +1582 (Gregorian). + +Since 0.06, we handle this correctly, so: + +adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582) + == 24 * 3600 (1 day) + +============================================================================= + +COPYRIGHT + +(c) 2003-2005 John Lim and released under BSD-style license except for code by +jackbbs, which includes adodb_mktime, adodb_get_gmt_diff, adodb_is_leap_year +and originally found at http://www.php.net/manual/en/function.mktime.php + +============================================================================= + +BUG REPORTS + +These should be posted to the ADOdb forums at + + http://phplens.com/lens/lensforum/topics.php?id=4 + +============================================================================= + +FUNCTION DESCRIPTIONS + + +** FUNCTION adodb_getdate($date=false) + +Returns an array containing date information, as getdate(), but supports +dates greater than 1901 to 2038. The local date/time format is derived from a +heuristic the first time adodb_getdate is called. + + +** FUNCTION adodb_date($fmt, $timestamp = false) + +Convert a timestamp to a formatted local date. If $timestamp is not defined, the +current timestamp is used. Unlike the function date(), it supports dates +outside the 1901 to 2038 range. + +The format fields that adodb_date supports: + +
    +	a - "am" or "pm" 
    +	A - "AM" or "PM" 
    +	d - day of the month, 2 digits with leading zeros; i.e. "01" to "31" 
    +	D - day of the week, textual, 3 letters; e.g. "Fri" 
    +	F - month, textual, long; e.g. "January" 
    +	g - hour, 12-hour format without leading zeros; i.e. "1" to "12" 
    +	G - hour, 24-hour format without leading zeros; i.e. "0" to "23" 
    +	h - hour, 12-hour format; i.e. "01" to "12" 
    +	H - hour, 24-hour format; i.e. "00" to "23" 
    +	i - minutes; i.e. "00" to "59" 
    +	j - day of the month without leading zeros; i.e. "1" to "31" 
    +	l (lowercase 'L') - day of the week, textual, long; e.g. "Friday"  
    +	L - boolean for whether it is a leap year; i.e. "0" or "1" 
    +	m - month; i.e. "01" to "12" 
    +	M - month, textual, 3 letters; e.g. "Jan" 
    +	n - month without leading zeros; i.e. "1" to "12" 
    +	O - Difference to Greenwich time in hours; e.g. "+0200" 
    +	Q - Quarter, as in 1, 2, 3, 4 
    +	r - RFC 2822 formatted date; e.g. "Thu, 21 Dec 2000 16:01:07 +0200" 
    +	s - seconds; i.e. "00" to "59" 
    +	S - English ordinal suffix for the day of the month, 2 characters; 
    +	   			i.e. "st", "nd", "rd" or "th" 
    +	t - number of days in the given month; i.e. "28" to "31"
    +	T - Timezone setting of this machine; e.g. "EST" or "MDT" 
    +	U - seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)  
    +	w - day of the week, numeric, i.e. "0" (Sunday) to "6" (Saturday) 
    +	Y - year, 4 digits; e.g. "1999" 
    +	y - year, 2 digits; e.g. "99" 
    +	z - day of the year; i.e. "0" to "365" 
    +	Z - timezone offset in seconds (i.e. "-43200" to "43200"). 
    +	   			The offset for timezones west of UTC is always negative, 
    +				and for those east of UTC is always positive. 
    +
    + +Unsupported: +
    +	B - Swatch Internet time 
    +	I (capital i) - "1" if Daylight Savings Time, "0" otherwise.
    +	W - ISO-8601 week number of year, weeks starting on Monday 
    +
    +
    + + +** FUNCTION adodb_date2($fmt, $isoDateString = false) +Same as adodb_date, but 2nd parameter accepts iso date, eg. + + adodb_date2('d-M-Y H:i','2003-12-25 13:01:34'); + + +** FUNCTION adodb_gmdate($fmt, $timestamp = false) + +Convert a timestamp to a formatted GMT date. If $timestamp is not defined, the +current timestamp is used. Unlike the function date(), it supports dates +outside the 1901 to 2038 range. + + +** FUNCTION adodb_mktime($hr, $min, $sec[, $month, $day, $year]) + +Converts a local date to a unix timestamp. Unlike the function mktime(), it supports +dates outside the 1901 to 2038 range. All parameters are optional. + + +** FUNCTION adodb_gmmktime($hr, $min, $sec [, $month, $day, $year]) + +Converts a gmt date to a unix timestamp. Unlike the function gmmktime(), it supports +dates outside the 1901 to 2038 range. Differs from gmmktime() in that all parameters +are currently compulsory. + +** FUNCTION adodb_gmstrftime($fmt, $timestamp = false) +Convert a timestamp to a formatted GMT date. + +** FUNCTION adodb_strftime($fmt, $timestamp = false) + +Convert a timestamp to a formatted local date. Internally converts $fmt into +adodb_date format, then echo result. + +For best results, you can define the local date format yourself. Define a global +variable $ADODB_DATE_LOCALE which is an array, 1st element is date format using +adodb_date syntax, and 2nd element is the time format, also in adodb_date syntax. + + eg. $ADODB_DATE_LOCALE = array('d/m/Y','H:i:s'); + + Supported format codes: + +
    +	%a - abbreviated weekday name according to the current locale 
    +	%A - full weekday name according to the current locale 
    +	%b - abbreviated month name according to the current locale 
    +	%B - full month name according to the current locale 
    +	%c - preferred date and time representation for the current locale 
    +	%d - day of the month as a decimal number (range 01 to 31) 
    +	%D - same as %m/%d/%y 
    +	%e - day of the month as a decimal number, a single digit is preceded by a space (range ' 1' to '31') 
    +	%h - same as %b
    +	%H - hour as a decimal number using a 24-hour clock (range 00 to 23) 
    +	%I - hour as a decimal number using a 12-hour clock (range 01 to 12) 
    +	%m - month as a decimal number (range 01 to 12) 
    +	%M - minute as a decimal number 
    +	%n - newline character 
    +	%p - either `am' or `pm' according to the given time value, or the corresponding strings for the current locale 
    +	%r - time in a.m. and p.m. notation 
    +	%R - time in 24 hour notation 
    +	%S - second as a decimal number 
    +	%t - tab character 
    +	%T - current time, equal to %H:%M:%S 
    +	%x - preferred date representation for the current locale without the time 
    +	%X - preferred time representation for the current locale without the date 
    +	%y - year as a decimal number without a century (range 00 to 99) 
    +	%Y - year as a decimal number including the century 
    +	%Z - time zone or name or abbreviation 
    +	%% - a literal `%' character 
    +
    + + Unsupported codes: +
    +	%C - century number (the year divided by 100 and truncated to an integer, range 00 to 99) 
    +	%g - like %G, but without the century. 
    +	%G - The 4-digit year corresponding to the ISO week number (see %V). 
    +	     This has the same format and value as %Y, except that if the ISO week number belongs 
    +		 to the previous or next year, that year is used instead. 
    +	%j - day of the year as a decimal number (range 001 to 366) 
    +	%u - weekday as a decimal number [1,7], with 1 representing Monday 
    +	%U - week number of the current year as a decimal number, starting 
    +	    with the first Sunday as the first day of the first week 
    +	%V - The ISO 8601:1988 week number of the current year as a decimal number, 
    +	     range 01 to 53, where week 1 is the first week that has at least 4 days in the 
    +		 current year, and with Monday as the first day of the week. (Use %G or %g for 
    +		 the year component that corresponds to the week number for the specified timestamp.) 
    +	%w - day of the week as a decimal, Sunday being 0 
    +	%W - week number of the current year as a decimal number, starting with the 
    +	     first Monday as the first day of the first week 
    +
    + +============================================================================= + +NOTES + +Useful url for generating test timestamps: + http://www.4webhelp.net/us/timestamp.php + +Possible future optimizations include + +a. Using an algorithm similar to Plauger's in "The Standard C Library" +(page 428, xttotm.c _Ttotm() function). Plauger's algorithm will not +work outside 32-bit signed range, so i decided not to implement it. + +b. Implement daylight savings, which looks awfully complicated, see + http://webexhibits.org/daylightsaving/ + + +CHANGELOG +- 15 July 2007 0.30 +Added PHP 5.2.0 compatability fixes. + * gmtime behaviour for 1970 has changed. We use the actual date if it is between 1970 to 2038 to get the + * timezone, otherwise we use the current year as the baseline to retrieve the timezone. + * Also the timezone's in php 5.2.* support historical data better, eg. if timezone today was +8, but + in 1970 it was +7:30, then php 5.2 return +7:30, while this library will use +8. + * + +- 19 March 2006 0.24 +Changed strftime() locale detection, because some locales prepend the day of week to the date when %c is used. + +- 10 Feb 2006 0.23 +PHP5 compat: when we detect PHP5, the RFC2822 format for gmt 0000hrs is changed from -0000 to +0000. + In PHP4, we will still use -0000 for 100% compat with PHP4. + +- 08 Sept 2005 0.22 +In adodb_date2(), $is_gmt not supported properly. Fixed. + +- 18 July 2005 0.21 +In PHP 4.3.11, the 'r' format has changed. Leading 0 in day is added. Changed for compat. +Added support for negative months in adodb_mktime(). + +- 24 Feb 2005 0.20 +Added limited strftime/gmstrftime support. x10 improvement in performance of adodb_date(). + +- 21 Dec 2004 0.17 +In adodb_getdate(), the timestamp was accidentally converted to gmt when $is_gmt is false. +Also adodb_mktime(0,0,0) did not work properly. Both fixed thx Mauro. + +- 17 Nov 2004 0.16 +Removed intval typecast in adodb_mktime() for secs, allowing: + adodb_mktime(0,0,0 + 2236672153,1,1,1934); +Suggested by Ryan. + +- 18 July 2004 0.15 +All params in adodb_mktime were formerly compulsory. Now only the hour, min, secs is compulsory. +This brings it more in line with mktime (still not identical). + +- 23 June 2004 0.14 + +Allow you to define your own daylights savings function, adodb_daylight_sv. +If the function is defined (somewhere in an include), then you can correct for daylights savings. + +In this example, we apply daylights savings in June or July, adding one hour. This is extremely +unrealistic as it does not take into account time-zone, geographic location, current year. + +function adodb_daylight_sv(&$arr, $is_gmt) +{ + if ($is_gmt) return; + $m = $arr['mon']; + if ($m == 6 || $m == 7) $arr['hours'] += 1; +} + +This is only called by adodb_date() and not by adodb_mktime(). + +The format of $arr is +Array ( + [seconds] => 0 + [minutes] => 0 + [hours] => 0 + [mday] => 1 # day of month, eg 1st day of the month + [mon] => 2 # month (eg. Feb) + [year] => 2102 + [yday] => 31 # days in current year + [leap] => # true if leap year + [ndays] => 28 # no of days in current month + ) + + +- 28 Apr 2004 0.13 +Fixed adodb_date to properly support $is_gmt. Thx to Dimitar Angelov. + +- 20 Mar 2004 0.12 +Fixed month calculation error in adodb_date. 2102-June-01 appeared as 2102-May-32. + +- 26 Oct 2003 0.11 +Because of daylight savings problems (some systems apply daylight savings to +January!!!), changed adodb_get_gmt_diff() to ignore daylight savings. + +- 9 Aug 2003 0.10 +Fixed bug with dates after 2038. +See http://phplens.com/lens/lensforum/msgs.php?id=6980 + +- 1 July 2003 0.09 +Added support for Q (Quarter). +Added adodb_date2(), which accepts ISO date in 2nd param + +- 3 March 2003 0.08 +Added support for 'S' adodb_date() format char. Added constant ADODB_ALLOW_NEGATIVE_TS +if you want PHP to handle negative timestamps between 1901 to 1969. + +- 27 Feb 2003 0.07 +All negative numbers handled by adodb now because of RH 7.3+ problems. +See http://bugs.php.net/bug.php?id=20048&edit=2 + +- 4 Feb 2003 0.06 +Fixed a typo, 1852 changed to 1582! This means that pre-1852 dates +are now correctly handled. + +- 29 Jan 2003 0.05 + +Leap year checking differs under Julian calendar (pre 1582). Also +leap year code optimized by checking for most common case first. + +We also handle month overflow correctly in mktime (eg month set to 13). + +Day overflow for less than one month's days is supported. + +- 28 Jan 2003 0.04 + +Gregorian correction handled. In PHP5, we might throw an error if +mktime uses invalid dates around 5-14 Oct 1582. Released with ADOdb 3.10. +Added limbo 5-14 Oct 1582 check, when we set to 15 Oct 1582. + +- 27 Jan 2003 0.03 + +Fixed some more month problems due to gmt issues. Added constant ADODB_DATE_VERSION. +Fixed calculation of days since start of year for <1970. + +- 27 Jan 2003 0.02 + +Changed _adodb_getdate() to inline leap year checking for better performance. +Fixed problem with time-zones west of GMT +0000. + +- 24 Jan 2003 0.01 + +First implementation. +*/ + + +/* Initialization */ + +/* + Version Number +*/ +define('ADODB_DATE_VERSION',0.30); + +$ADODB_DATETIME_CLASS = (PHP_VERSION >= 5.2); + +/* + This code was originally for windows. But apparently this problem happens + also with Linux, RH 7.3 and later! + + glibc-2.2.5-34 and greater has been changed to return -1 for dates < + 1970. This used to work. The problem exists with RedHat 7.3 and 8.0 + echo (mktime(0, 0, 0, 1, 1, 1960)); // prints -1 + + References: + http://bugs.php.net/bug.php?id=20048&edit=2 + http://lists.debian.org/debian-glibc/2002/debian-glibc-200205/msg00010.html +*/ + +if (!defined('ADODB_ALLOW_NEGATIVE_TS')) define('ADODB_NO_NEGATIVE_TS',1); + +function adodb_date_test_date($y1,$m,$d=13) +{ + $h = round(rand()% 24); + $t = adodb_mktime($h,0,0,$m,$d,$y1); + $rez = adodb_date('Y-n-j H:i:s',$t); + if ($h == 0) $h = '00'; + else if ($h < 10) $h = '0'.$h; + if ("$y1-$m-$d $h:00:00" != $rez) { + print "$y1 error, expected=$y1-$m-$d $h:00:00, adodb=$rez
    "; + return false; + } + return true; +} + +function adodb_date_test_strftime($fmt) +{ + $s1 = strftime($fmt); + $s2 = adodb_strftime($fmt); + + if ($s1 == $s2) return true; + + echo "error for $fmt, strftime=$s1, adodb=$s2
    "; + return false; +} + +/** + Test Suite +*/ +function adodb_date_test() +{ + + error_reporting(E_ALL); + print "

    Testing adodb_date and adodb_mktime. version=".ADODB_DATE_VERSION.' PHP='.PHP_VERSION."

    "; + @set_time_limit(0); + $fail = false; + + // This flag disables calling of PHP native functions, so we can properly test the code + if (!defined('ADODB_TEST_DATES')) define('ADODB_TEST_DATES',1); + + $t = time(); + + + $fmt = 'Y-m-d H:i:s'; + echo '
    ';
    +	echo 'adodb: ',adodb_date($fmt,$t),'
    '; + echo 'php : ',date($fmt,$t),'
    '; + echo '
    '; + + adodb_date_test_strftime('%Y %m %x %X'); + adodb_date_test_strftime("%A %d %B %Y"); + adodb_date_test_strftime("%H %M S"); + + $t = adodb_mktime(0,0,0); + if (!(adodb_date('Y-m-d') == date('Y-m-d'))) print 'Error in '.adodb_mktime(0,0,0).'
    '; + + $t = adodb_mktime(0,0,0,6,1,2102); + if (!(adodb_date('Y-m-d',$t) == '2102-06-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
    '; + + $t = adodb_mktime(0,0,0,2,1,2102); + if (!(adodb_date('Y-m-d',$t) == '2102-02-01')) print 'Error in '.adodb_date('Y-m-d',$t).'
    '; + + + print "

    Testing gregorian <=> julian conversion

    "; + $t = adodb_mktime(0,0,0,10,11,1492); + //http://www.holidayorigins.com/html/columbus_day.html - Friday check + if (!(adodb_date('D Y-m-d',$t) == 'Fri 1492-10-11')) print 'Error in Columbus landing
    '; + + $t = adodb_mktime(0,0,0,2,29,1500); + if (!(adodb_date('Y-m-d',$t) == '1500-02-29')) print 'Error in julian leap years
    '; + + $t = adodb_mktime(0,0,0,2,29,1700); + if (!(adodb_date('Y-m-d',$t) == '1700-03-01')) print 'Error in gregorian leap years
    '; + + print adodb_mktime(0,0,0,10,4,1582).' '; + print adodb_mktime(0,0,0,10,15,1582); + $diff = (adodb_mktime(0,0,0,10,15,1582) - adodb_mktime(0,0,0,10,4,1582)); + if ($diff != 3600*24) print " Error in gregorian correction = ".($diff/3600/24)." days
    "; + + print " 15 Oct 1582, Fri=".(adodb_dow(1582,10,15) == 5 ? 'Fri' : 'Error')."
    "; + print " 4 Oct 1582, Thu=".(adodb_dow(1582,10,4) == 4 ? 'Thu' : 'Error')."
    "; + + print "

    Testing overflow

    "; + + $t = adodb_mktime(0,0,0,3,33,1965); + if (!(adodb_date('Y-m-d',$t) == '1965-04-02')) print 'Error in day overflow 1
    '; + $t = adodb_mktime(0,0,0,4,33,1971); + if (!(adodb_date('Y-m-d',$t) == '1971-05-03')) print 'Error in day overflow 2
    '; + $t = adodb_mktime(0,0,0,1,60,1965); + if (!(adodb_date('Y-m-d',$t) == '1965-03-01')) print 'Error in day overflow 3 '.adodb_date('Y-m-d',$t).'
    '; + $t = adodb_mktime(0,0,0,12,32,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-01-01')) print 'Error in day overflow 4 '.adodb_date('Y-m-d',$t).'
    '; + $t = adodb_mktime(0,0,0,12,63,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-02-01')) print 'Error in day overflow 5 '.adodb_date('Y-m-d',$t).'
    '; + $t = adodb_mktime(0,0,0,13,3,1965); + if (!(adodb_date('Y-m-d',$t) == '1966-01-03')) print 'Error in mth overflow 1
    '; + + print "Testing 2-digit => 4-digit year conversion

    "; + if (adodb_year_digit_check(00) != 2000) print "Err 2-digit 2000
    "; + if (adodb_year_digit_check(10) != 2010) print "Err 2-digit 2010
    "; + if (adodb_year_digit_check(20) != 2020) print "Err 2-digit 2020
    "; + if (adodb_year_digit_check(30) != 2030) print "Err 2-digit 2030
    "; + if (adodb_year_digit_check(40) != 1940) print "Err 2-digit 1940
    "; + if (adodb_year_digit_check(50) != 1950) print "Err 2-digit 1950
    "; + if (adodb_year_digit_check(90) != 1990) print "Err 2-digit 1990
    "; + + // Test string formating + print "

    Testing date formating

    "; + + $fmt = '\d\a\t\e T Y-m-d H:i:s a A d D F g G h H i j l L m M n O \R\F\C2822 r s t U w y Y z Z 2003'; + $s1 = date($fmt,0); + $s2 = adodb_date($fmt,0); + if ($s1 != $s2) { + print " date() 0 failed
    $s1
    $s2
    "; + } + flush(); + for ($i=100; --$i > 0; ) { + + $ts = 3600.0*((rand()%60000)+(rand()%60000))+(rand()%60000); + $s1 = date($fmt,$ts); + $s2 = adodb_date($fmt,$ts); + //print "$s1
    $s2

    "; + $pos = strcmp($s1,$s2); + + if (($s1) != ($s2)) { + for ($j=0,$k=strlen($s1); $j < $k; $j++) { + if ($s1[$j] != $s2[$j]) { + print substr($s1,$j).' '; + break; + } + } + print "Error date(): $ts

     
    +  \"$s1\" (date len=".strlen($s1).")
    +  \"$s2\" (adodb_date len=".strlen($s2).")

    "; + $fail = true; + } + + $a1 = getdate($ts); + $a2 = adodb_getdate($ts); + $rez = array_diff($a1,$a2); + if (sizeof($rez)>0) { + print "Error getdate() $ts
    "; + print_r($a1); + print "
    "; + print_r($a2); + print "

    "; + $fail = true; + } + } + + // Test generation of dates outside 1901-2038 + print "

    Testing random dates between 100 and 4000

    "; + adodb_date_test_date(100,1); + for ($i=100; --$i >= 0;) { + $y1 = 100+rand(0,1970-100); + $m = rand(1,12); + adodb_date_test_date($y1,$m); + + $y1 = 3000-rand(0,3000-1970); + adodb_date_test_date($y1,$m); + } + print '

    '; + $start = 1960+rand(0,10); + $yrs = 12; + $i = 365.25*86400*($start-1970); + $offset = 36000+rand(10000,60000); + $max = 365*$yrs*86400; + $lastyear = 0; + + // we generate a timestamp, convert it to a date, and convert it back to a timestamp + // and check if the roundtrip broke the original timestamp value. + print "Testing $start to ".($start+$yrs).", or $max seconds, offset=$offset: "; + $cnt = 0; + for ($max += $i; $i < $max; $i += $offset) { + $ret = adodb_date('m,d,Y,H,i,s',$i); + $arr = explode(',',$ret); + if ($lastyear != $arr[2]) { + $lastyear = $arr[2]; + print " $lastyear "; + flush(); + } + $newi = adodb_mktime($arr[3],$arr[4],$arr[5],$arr[0],$arr[1],$arr[2]); + if ($i != $newi) { + print "Error at $i, adodb_mktime returned $newi ($ret)"; + $fail = true; + break; + } + $cnt += 1; + } + echo "Tested $cnt dates
    "; + if (!$fail) print "

    Passed !

    "; + else print "

    Failed :-(

    "; +} + +/** + Returns day of week, 0 = Sunday,... 6=Saturday. + Algorithm from PEAR::Date_Calc +*/ +function adodb_dow($year, $month, $day) +{ +/* +Pope Gregory removed 10 days - October 5 to October 14 - from the year 1582 and +proclaimed that from that time onwards 3 days would be dropped from the calendar +every 400 years. + +Thursday, October 4, 1582 (Julian) was followed immediately by Friday, October 15, 1582 (Gregorian). +*/ + if ($year <= 1582) { + if ($year < 1582 || + ($year == 1582 && ($month < 10 || ($month == 10 && $day < 15)))) $greg_correction = 3; + else + $greg_correction = 0; + } else + $greg_correction = 0; + + if($month > 2) + $month -= 2; + else { + $month += 10; + $year--; + } + + $day = floor((13 * $month - 1) / 5) + + $day + ($year % 100) + + floor(($year % 100) / 4) + + floor(($year / 100) / 4) - 2 * + floor($year / 100) + 77 + $greg_correction; + + return $day - 7 * floor($day / 7); +} + + +/** + Checks for leap year, returns true if it is. No 2-digit year check. Also + handles julian calendar correctly. +*/ +function _adodb_is_leap_year($year) +{ + if ($year % 4 != 0) return false; + + if ($year % 400 == 0) { + return true; + // if gregorian calendar (>1582), century not-divisible by 400 is not leap + } else if ($year > 1582 && $year % 100 == 0 ) { + return false; + } + + return true; +} + + +/** + checks for leap year, returns true if it is. Has 2-digit year check +*/ +function adodb_is_leap_year($year) +{ + return _adodb_is_leap_year(adodb_year_digit_check($year)); +} + +/** + Fix 2-digit years. Works for any century. + Assumes that if 2-digit is more than 30 years in future, then previous century. +*/ +function adodb_year_digit_check($y) +{ + if ($y < 100) { + + $yr = (integer) date("Y"); + $century = (integer) ($yr /100); + + if ($yr%100 > 50) { + $c1 = $century + 1; + $c0 = $century; + } else { + $c1 = $century; + $c0 = $century - 1; + } + $c1 *= 100; + // if 2-digit year is less than 30 years in future, set it to this century + // otherwise if more than 30 years in future, then we set 2-digit year to the prev century. + if (($y + $c1) < $yr+30) $y = $y + $c1; + else $y = $y + $c0*100; + } + return $y; +} + +function adodb_get_gmt_diff_ts($ts) +{ + if (0 <= $ts && $ts <= 0x7FFFFFFF) { // check if number in 32-bit signed range) { + $arr = getdate($ts); + $y = $arr['year']; + $m = $arr['mon']; + $d = $arr['mday']; + return adodb_get_gmt_diff($y,$m,$d); +} else { + return adodb_get_gmt_diff(false,false,false); + } + +} + +/** + get local time zone offset from GMT. Does not handle historical timezones before 1970. +*/ +function adodb_get_gmt_diff($y,$m,$d) +{ +static $TZ,$tzo; +global $ADODB_DATETIME_CLASS; + + if (!defined('ADODB_TEST_DATES')) $y = false; + else if ($y < 1970 || $y >= 2038) $y = false; + + if ($ADODB_DATETIME_CLASS && $y !== false) { + $dt = new DateTime(); + $dt->setISODate($y,$m,$d); + if (empty($tzo)) { + $tzo = new DateTimeZone(date_default_timezone_get()); + # $tzt = timezone_transitions_get( $tzo ); + } + return -$tzo->getOffset($dt); + } else { + if (isset($TZ)) return $TZ; + $y = date('Y'); + $TZ = mktime(0,0,0,12,2,$y,0) - gmmktime(0,0,0,12,2,$y,0); + } + + return $TZ; +} + +/** + Returns an array with date info. +*/ +function adodb_getdate($d=false,$fast=false) +{ + if ($d === false) return getdate(); + if (!defined('ADODB_TEST_DATES')) { + if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer + return @getdate($d); + } + } + return _adodb_getdate($d); +} + +/* +// generate $YRS table for _adodb_getdate() +function adodb_date_gentable($out=true) +{ + + for ($i=1970; $i >= 1600; $i-=10) { + $s = adodb_gmmktime(0,0,0,1,1,$i); + echo "$i => $s,
    "; + } +} +adodb_date_gentable(); + +for ($i=1970; $i > 1500; $i--) { + +echo "
    $i "; + adodb_date_test_date($i,1,1); +} + +*/ + + +$_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); +$_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + +function adodb_validdate($y,$m,$d) +{ +global $_month_table_normal,$_month_table_leaf; + + if (_adodb_is_leap_year($y)) $marr = $_month_table_leaf; + else $marr = $_month_table_normal; + + if ($m > 12 || $m < 1) return false; + + if ($d > 31 || $d < 1) return false; + + if ($marr[$m] < $d) return false; + + if ($y < 1000 && $y > 3000) return false; + + return true; +} + +/** + Low-level function that returns the getdate() array. We have a special + $fast flag, which if set to true, will return fewer array values, + and is much faster as it does not calculate dow, etc. +*/ +function _adodb_getdate($origd=false,$fast=false,$is_gmt=false) +{ +static $YRS; +global $_month_table_normal,$_month_table_leaf; + + $d = $origd - ($is_gmt ? 0 : adodb_get_gmt_diff_ts($origd)); + $_day_power = 86400; + $_hour_power = 3600; + $_min_power = 60; + + if ($d < -12219321600) $d -= 86400*10; // if 15 Oct 1582 or earlier, gregorian correction + + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); + $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + + $d366 = $_day_power * 366; + $d365 = $_day_power * 365; + + if ($d < 0) { + + if (empty($YRS)) $YRS = array( + 1970 => 0, + 1960 => -315619200, + 1950 => -631152000, + 1940 => -946771200, + 1930 => -1262304000, + 1920 => -1577923200, + 1910 => -1893456000, + 1900 => -2208988800, + 1890 => -2524521600, + 1880 => -2840140800, + 1870 => -3155673600, + 1860 => -3471292800, + 1850 => -3786825600, + 1840 => -4102444800, + 1830 => -4417977600, + 1820 => -4733596800, + 1810 => -5049129600, + 1800 => -5364662400, + 1790 => -5680195200, + 1780 => -5995814400, + 1770 => -6311347200, + 1760 => -6626966400, + 1750 => -6942499200, + 1740 => -7258118400, + 1730 => -7573651200, + 1720 => -7889270400, + 1710 => -8204803200, + 1700 => -8520336000, + 1690 => -8835868800, + 1680 => -9151488000, + 1670 => -9467020800, + 1660 => -9782640000, + 1650 => -10098172800, + 1640 => -10413792000, + 1630 => -10729324800, + 1620 => -11044944000, + 1610 => -11360476800, + 1600 => -11676096000); + + if ($is_gmt) $origd = $d; + // The valid range of a 32bit signed timestamp is typically from + // Fri, 13 Dec 1901 20:45:54 GMT to Tue, 19 Jan 2038 03:14:07 GMT + // + + # old algorithm iterates through all years. new algorithm does it in + # 10 year blocks + + /* + # old algo + for ($a = 1970 ; --$a >= 0;) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; + else $d += $d365; + + if ($d >= 0) { + $year = $a; + break; + } + } + */ + + $lastsecs = 0; + $lastyear = 1970; + foreach($YRS as $year => $secs) { + if ($d >= $secs) { + $a = $lastyear; + break; + } + $lastsecs = $secs; + $lastyear = $year; + } + + $d -= $lastsecs; + if (!isset($a)) $a = $lastyear; + + //echo ' yr=',$a,' ', $d,'.'; + + for (; --$a >= 0;) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d += $d366; + else $d += $d365; + + if ($d >= 0) { + $year = $a; + break; + } + } + /**/ + + $secsInYear = 86400 * ($leaf ? 366 : 365) + $lastd; + + $d = $lastd; + $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; + for ($a = 13 ; --$a > 0;) { + $lastd = $d; + $d += $mtab[$a] * $_day_power; + if ($d >= 0) { + $month = $a; + $ndays = $mtab[$a]; + break; + } + } + + $d = $lastd; + $day = $ndays + ceil(($d+1) / ($_day_power)); + + $d += ($ndays - $day+1)* $_day_power; + $hour = floor($d/$_hour_power); + + } else { + for ($a = 1970 ;; $a++) { + $lastd = $d; + + if ($leaf = _adodb_is_leap_year($a)) $d -= $d366; + else $d -= $d365; + if ($d < 0) { + $year = $a; + break; + } + } + $secsInYear = $lastd; + $d = $lastd; + $mtab = ($leaf) ? $_month_table_leaf : $_month_table_normal; + for ($a = 1 ; $a <= 12; $a++) { + $lastd = $d; + $d -= $mtab[$a] * $_day_power; + if ($d < 0) { + $month = $a; + $ndays = $mtab[$a]; + break; + } + } + $d = $lastd; + $day = ceil(($d+1) / $_day_power); + $d = $d - ($day-1) * $_day_power; + $hour = floor($d /$_hour_power); + } + + $d -= $hour * $_hour_power; + $min = floor($d/$_min_power); + $secs = $d - $min * $_min_power; + if ($fast) { + return array( + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'leap' => $leaf, + 'ndays' => $ndays + ); + } + + + $dow = adodb_dow($year,$month,$day); + + return array( + 'seconds' => $secs, + 'minutes' => $min, + 'hours' => $hour, + 'mday' => $day, + 'wday' => $dow, + 'mon' => $month, + 'year' => $year, + 'yday' => floor($secsInYear/$_day_power), + 'weekday' => gmdate('l',$_day_power*(3+$dow)), + 'month' => gmdate('F',mktime(0,0,0,$month,2,1971)), + 0 => $origd + ); +} +/* + if ($isphp5) + $dates .= sprintf('%s%04d',($gmt<=0)?'+':'-',abs($gmt)/36); + else + $dates .= sprintf('%s%04d',($gmt<0)?'+':'-',abs($gmt)/36); + break;*/ +function adodb_tz_offset($gmt,$isphp5) +{ + $zhrs = abs($gmt)/3600; + $hrs = floor($zhrs); + if ($isphp5) + return sprintf('%s%02d%02d',($gmt<=0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + else + return sprintf('%s%02d%02d',($gmt<0)?'+':'-',floor($zhrs),($zhrs-$hrs)*60); + break; +} + + +function adodb_gmdate($fmt,$d=false) +{ + return adodb_date($fmt,$d,true); +} + +// accepts unix timestamp and iso date format in $d +function adodb_date2($fmt, $d=false, $is_gmt=false) +{ + if ($d !== false) { + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ -]?(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + ($d), $rr)) return adodb_date($fmt,false,$is_gmt); + + if ($rr[1] <= 100 && $rr[2]<= 1) return adodb_date($fmt,false,$is_gmt); + + // h-m-s-MM-DD-YY + if (!isset($rr[5])) $d = adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1],false,$is_gmt); + else $d = @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1],false,$is_gmt); + } + + return adodb_date($fmt,$d,$is_gmt); +} + + +/** + Return formatted date based on timestamp $d +*/ +function adodb_date($fmt,$d=false,$is_gmt=false) +{ +static $daylight; +global $ADODB_DATETIME_CLASS; + + if ($d === false) return ($is_gmt)? @gmdate($fmt): @date($fmt); + if (!defined('ADODB_TEST_DATES')) { + if ((abs($d) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $d >= 0) // if windows, must be +ve integer + return ($is_gmt)? @gmdate($fmt,$d): @date($fmt,$d); + + } + } + $_day_power = 86400; + + $arr = _adodb_getdate($d,true,$is_gmt); + + if (!isset($daylight)) $daylight = function_exists('adodb_daylight_sv'); + if ($daylight) adodb_daylight_sv($arr, $is_gmt); + + $year = $arr['year']; + $month = $arr['mon']; + $day = $arr['mday']; + $hour = $arr['hours']; + $min = $arr['minutes']; + $secs = $arr['seconds']; + + $max = strlen($fmt); + $dates = ''; + + $isphp5 = PHP_VERSION >= 5; + + /* + at this point, we have the following integer vars to manipulate: + $year, $month, $day, $hour, $min, $secs + */ + for ($i=0; $i < $max; $i++) { + switch($fmt[$i]) { + case 'T': + if ($ADODB_DATETIME_CLASS) { + $dt = new DateTime(); + $dt->SetDate($year,$month,$day); + $dates .= $dt->Format('T'); + } else + $dates .= date('T'); + break; + // YEAR + case 'L': $dates .= $arr['leap'] ? '1' : '0'; break; + case 'r': // Thu, 21 Dec 2000 16:01:07 +0200 + + // 4.3.11 uses '04 Jun 2004' + // 4.3.8 uses ' 4 Jun 2004' + $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))).', ' + . ($day<10?'0'.$day:$day) . ' '.date('M',mktime(0,0,0,$month,2,1971)).' '.$year.' '; + + if ($hour < 10) $dates .= '0'.$hour; else $dates .= $hour; + + if ($min < 10) $dates .= ':0'.$min; else $dates .= ':'.$min; + + if ($secs < 10) $dates .= ':0'.$secs; else $dates .= ':'.$secs; + + $gmt = adodb_get_gmt_diff($year,$month,$day); + + $dates .= ' '.adodb_tz_offset($gmt,$isphp5); + break; + + case 'Y': $dates .= $year; break; + case 'y': $dates .= substr($year,strlen($year)-2,2); break; + // MONTH + case 'm': if ($month<10) $dates .= '0'.$month; else $dates .= $month; break; + case 'Q': $dates .= ($month+3)>>2; break; + case 'n': $dates .= $month; break; + case 'M': $dates .= date('M',mktime(0,0,0,$month,2,1971)); break; + case 'F': $dates .= date('F',mktime(0,0,0,$month,2,1971)); break; + // DAY + case 't': $dates .= $arr['ndays']; break; + case 'z': $dates .= $arr['yday']; break; + case 'w': $dates .= adodb_dow($year,$month,$day); break; + case 'l': $dates .= gmdate('l',$_day_power*(3+adodb_dow($year,$month,$day))); break; + case 'D': $dates .= gmdate('D',$_day_power*(3+adodb_dow($year,$month,$day))); break; + case 'j': $dates .= $day; break; + case 'd': if ($day<10) $dates .= '0'.$day; else $dates .= $day; break; + case 'S': + $d10 = $day % 10; + if ($d10 == 1) $dates .= 'st'; + else if ($d10 == 2 && $day != 12) $dates .= 'nd'; + else if ($d10 == 3) $dates .= 'rd'; + else $dates .= 'th'; + break; + + // HOUR + case 'Z': + $dates .= ($is_gmt) ? 0 : -adodb_get_gmt_diff($year,$month,$day); break; + case 'O': + $gmt = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$month,$day); + + $dates .= adodb_tz_offset($gmt,$isphp5); + break; + + case 'H': + if ($hour < 10) $dates .= '0'.$hour; + else $dates .= $hour; + break; + case 'h': + if ($hour > 12) $hh = $hour - 12; + else { + if ($hour == 0) $hh = '12'; + else $hh = $hour; + } + + if ($hh < 10) $dates .= '0'.$hh; + else $dates .= $hh; + break; + + case 'G': + $dates .= $hour; + break; + + case 'g': + if ($hour > 12) $hh = $hour - 12; + else { + if ($hour == 0) $hh = '12'; + else $hh = $hour; + } + $dates .= $hh; + break; + // MINUTES + case 'i': if ($min < 10) $dates .= '0'.$min; else $dates .= $min; break; + // SECONDS + case 'U': $dates .= $d; break; + case 's': if ($secs < 10) $dates .= '0'.$secs; else $dates .= $secs; break; + // AM/PM + // Note 00:00 to 11:59 is AM, while 12:00 to 23:59 is PM + case 'a': + if ($hour>=12) $dates .= 'pm'; + else $dates .= 'am'; + break; + case 'A': + if ($hour>=12) $dates .= 'PM'; + else $dates .= 'AM'; + break; + default: + $dates .= $fmt[$i]; break; + // ESCAPE + case "\\": + $i++; + if ($i < $max) $dates .= $fmt[$i]; + break; + } + } + return $dates; +} + +/** + Returns a timestamp given a GMT/UTC time. + Note that $is_dst is not implemented and is ignored. +*/ +function adodb_gmmktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false) +{ + return adodb_mktime($hr,$min,$sec,$mon,$day,$year,$is_dst,true); +} + +/** + Return a timestamp given a local time. Originally by jackbbs. + Note that $is_dst is not implemented and is ignored. + + Not a very fast algorithm - O(n) operation. Could be optimized to O(1). +*/ +function adodb_mktime($hr,$min,$sec,$mon=false,$day=false,$year=false,$is_dst=false,$is_gmt=false) +{ + if (!defined('ADODB_TEST_DATES')) { + + if ($mon === false) { + return $is_gmt? @gmmktime($hr,$min,$sec): @mktime($hr,$min,$sec); + } + + // for windows, we don't check 1970 because with timezone differences, + // 1 Jan 1970 could generate negative timestamp, which is illegal + if (1971 < $year && $year < 2038 + || !defined('ADODB_NO_NEGATIVE_TS') && (1901 < $year && $year < 2038) + ) { + return $is_gmt ? + @gmmktime($hr,$min,$sec,$mon,$day,$year): + @mktime($hr,$min,$sec,$mon,$day,$year); + } + } + + $gmt_different = ($is_gmt) ? 0 : adodb_get_gmt_diff($year,$mon,$day); + + /* + # disabled because some people place large values in $sec. + # however we need it for $mon because we use an array... + $hr = intval($hr); + $min = intval($min); + $sec = intval($sec); + */ + $mon = intval($mon); + $day = intval($day); + $year = intval($year); + + + $year = adodb_year_digit_check($year); + + if ($mon > 12) { + $y = floor($mon / 12); + $year += $y; + $mon -= $y*12; + } else if ($mon < 1) { + $y = ceil((1-$mon) / 12); + $year -= $y; + $mon += $y*12; + } + + $_day_power = 86400; + $_hour_power = 3600; + $_min_power = 60; + + $_month_table_normal = array("",31,28,31,30,31,30,31,31,30,31,30,31); + $_month_table_leaf = array("",31,29,31,30,31,30,31,31,30,31,30,31); + + $_total_date = 0; + if ($year >= 1970) { + for ($a = 1970 ; $a <= $year; $a++) { + $leaf = _adodb_is_leap_year($a); + if ($leaf == true) { + $loop_table = $_month_table_leaf; + $_add_date = 366; + } else { + $loop_table = $_month_table_normal; + $_add_date = 365; + } + if ($a < $year) { + $_total_date += $_add_date; + } else { + for($b=1;$b<$mon;$b++) { + $_total_date += $loop_table[$b]; + } + } + } + $_total_date +=$day-1; + $ret = $_total_date * $_day_power + $hr * $_hour_power + $min * $_min_power + $sec + $gmt_different; + + } else { + for ($a = 1969 ; $a >= $year; $a--) { + $leaf = _adodb_is_leap_year($a); + if ($leaf == true) { + $loop_table = $_month_table_leaf; + $_add_date = 366; + } else { + $loop_table = $_month_table_normal; + $_add_date = 365; + } + if ($a > $year) { $_total_date += $_add_date; + } else { + for($b=12;$b>$mon;$b--) { + $_total_date += $loop_table[$b]; + } + } + } + $_total_date += $loop_table[$mon] - $day; + + $_day_time = $hr * $_hour_power + $min * $_min_power + $sec; + $_day_time = $_day_power - $_day_time; + $ret = -( $_total_date * $_day_power + $_day_time - $gmt_different); + if ($ret < -12220185600) $ret += 10*86400; // if earlier than 5 Oct 1582 - gregorian correction + else if ($ret < -12219321600) $ret = -12219321600; // if in limbo, reset to 15 Oct 1582. + } + //print " dmy=$day/$mon/$year $hr:$min:$sec => " .$ret; + return $ret; +} + +function adodb_gmstrftime($fmt, $ts=false) +{ + return adodb_strftime($fmt,$ts,true); +} + +// hack - convert to adodb_date +function adodb_strftime($fmt, $ts=false,$is_gmt=false) +{ +global $ADODB_DATE_LOCALE; + + if (!defined('ADODB_TEST_DATES')) { + if ((abs($ts) <= 0x7FFFFFFF)) { // check if number in 32-bit signed range + if (!defined('ADODB_NO_NEGATIVE_TS') || $ts >= 0) // if windows, must be +ve integer + return ($is_gmt)? @gmstrftime($fmt,$ts): @strftime($fmt,$ts); + + } + } + + if (empty($ADODB_DATE_LOCALE)) { + /* + $tstr = strtoupper(gmstrftime('%c',31366800)); // 30 Dec 1970, 1 am + $sep = substr($tstr,2,1); + $hasAM = strrpos($tstr,'M') !== false; + */ + # see http://phplens.com/lens/lensforum/msgs.php?id=14865 for reasoning, and changelog for version 0.24 + $dstr = gmstrftime('%x',31366800); // 30 Dec 1970, 1 am + $sep = substr($dstr,2,1); + $tstr = strtoupper(gmstrftime('%X',31366800)); // 30 Dec 1970, 1 am + $hasAM = strrpos($tstr,'M') !== false; + + $ADODB_DATE_LOCALE = array(); + $ADODB_DATE_LOCALE[] = strncmp($tstr,'30',2) == 0 ? 'd'.$sep.'m'.$sep.'y' : 'm'.$sep.'d'.$sep.'y'; + $ADODB_DATE_LOCALE[] = ($hasAM) ? 'h:i:s a' : 'H:i:s'; + + } + $inpct = false; + $fmtdate = ''; + for ($i=0,$max = strlen($fmt); $i < $max; $i++) { + $ch = $fmt[$i]; + if ($ch == '%') { + if ($inpct) { + $fmtdate .= '%'; + $inpct = false; + } else + $inpct = true; + } else if ($inpct) { + + $inpct = false; + switch($ch) { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case 'E': + case 'O': + /* ignore format modifiers */ + $inpct = true; + break; + + case 'a': $fmtdate .= 'D'; break; + case 'A': $fmtdate .= 'l'; break; + case 'h': + case 'b': $fmtdate .= 'M'; break; + case 'B': $fmtdate .= 'F'; break; + case 'c': $fmtdate .= $ADODB_DATE_LOCALE[0].$ADODB_DATE_LOCALE[1]; break; + case 'C': $fmtdate .= '\C?'; break; // century + case 'd': $fmtdate .= 'd'; break; + case 'D': $fmtdate .= 'm/d/y'; break; + case 'e': $fmtdate .= 'j'; break; + case 'g': $fmtdate .= '\g?'; break; //? + case 'G': $fmtdate .= '\G?'; break; //? + case 'H': $fmtdate .= 'H'; break; + case 'I': $fmtdate .= 'h'; break; + case 'j': $fmtdate .= '?z'; $parsej = true; break; // wrong as j=1-based, z=0-basd + case 'm': $fmtdate .= 'm'; break; + case 'M': $fmtdate .= 'i'; break; + case 'n': $fmtdate .= "\n"; break; + case 'p': $fmtdate .= 'a'; break; + case 'r': $fmtdate .= 'h:i:s a'; break; + case 'R': $fmtdate .= 'H:i:s'; break; + case 'S': $fmtdate .= 's'; break; + case 't': $fmtdate .= "\t"; break; + case 'T': $fmtdate .= 'H:i:s'; break; + case 'u': $fmtdate .= '?u'; $parseu = true; break; // wrong strftime=1-based, date=0-based + case 'U': $fmtdate .= '?U'; $parseU = true; break;// wrong strftime=1-based, date=0-based + case 'x': $fmtdate .= $ADODB_DATE_LOCALE[0]; break; + case 'X': $fmtdate .= $ADODB_DATE_LOCALE[1]; break; + case 'w': $fmtdate .= '?w'; $parseu = true; break; // wrong strftime=1-based, date=0-based + case 'W': $fmtdate .= '?W'; $parseU = true; break;// wrong strftime=1-based, date=0-based + case 'y': $fmtdate .= 'y'; break; + case 'Y': $fmtdate .= 'Y'; break; + case 'Z': $fmtdate .= 'T'; break; + } + } else if (('A' <= ($ch) && ($ch) <= 'Z' ) || ('a' <= ($ch) && ($ch) <= 'z' )) + $fmtdate .= "\\".$ch; + else + $fmtdate .= $ch; + } + //echo "fmt=",$fmtdate,"
    "; + if ($ts === false) $ts = time(); + $ret = adodb_date($fmtdate, $ts, $is_gmt); + return $ret; +} + + +?> \ No newline at end of file diff --git a/upload/includes/adodb/adodb.inc.php b/upload/includes/adodb/adodb.inc.php new file mode 100644 index 00000000..176c45ec --- /dev/null +++ b/upload/includes/adodb/adodb.inc.php @@ -0,0 +1,4244 @@ +fields is available on EOF + $ADODB_FETCH_MODE, // DEFAULT, NUM, ASSOC or BOTH. Default follows native driver default... + $ADODB_QUOTE_FIELDNAMES; // Allows you to force quotes (backticks) around field names in queries generated by getinsertsql and getupdatesql. + + //============================================================================================== + // GLOBAL SETUP + //============================================================================================== + + $ADODB_EXTENSION = defined('ADODB_EXTENSION'); + + //********************************************************// + /* + Controls $ADODB_FORCE_TYPE mode. Default is ADODB_FORCE_VALUE (3). + Used in GetUpdateSql and GetInsertSql functions. Thx to Niko, nuko#mbnet.fi + + 0 = ignore empty fields. All empty fields in array are ignored. + 1 = force null. All empty, php null and string 'null' fields are changed to sql NULL values. + 2 = force empty. All empty, php null and string 'null' fields are changed to sql empty '' or 0 values. + 3 = force value. Value is left as it is. Php null and string 'null' are set to sql NULL values and empty fields '' are set to empty '' sql values. + */ + define('ADODB_FORCE_IGNORE',0); + define('ADODB_FORCE_NULL',1); + define('ADODB_FORCE_EMPTY',2); + define('ADODB_FORCE_VALUE',3); + //********************************************************// + + + if (!$ADODB_EXTENSION || ADODB_EXTENSION < 4.0) { + + define('ADODB_BAD_RS','

    Bad $rs in %s. Connection or SQL invalid. Try using $connection->debug=true;

    '); + + // allow [ ] @ ` " and . in table names + define('ADODB_TABLE_REGEX','([]0-9a-z_\:\"\`\.\@\[-]*)'); + + // prefetching used by oracle + if (!defined('ADODB_PREFETCH_ROWS')) define('ADODB_PREFETCH_ROWS',10); + + + /* + Controls ADODB_FETCH_ASSOC field-name case. Default is 2, use native case-names. + This currently works only with mssql, odbc, oci8po and ibase derived drivers. + + 0 = assoc lowercase field names. $rs->fields['orderid'] + 1 = assoc uppercase field names. $rs->fields['ORDERID'] + 2 = use native-case field names. $rs->fields['OrderID'] + */ + + define('ADODB_FETCH_DEFAULT',0); + define('ADODB_FETCH_NUM',1); + define('ADODB_FETCH_ASSOC',2); + define('ADODB_FETCH_BOTH',3); + + if (!defined('TIMESTAMP_FIRST_YEAR')) define('TIMESTAMP_FIRST_YEAR',100); + + // PHP's version scheme makes converting to numbers difficult - workaround + $_adodb_ver = (float) PHP_VERSION; + if ($_adodb_ver >= 5.2) { + define('ADODB_PHPVER',0x5200); + } else if ($_adodb_ver >= 5.0) { + define('ADODB_PHPVER',0x5000); + } else if ($_adodb_ver > 4.299999) { # 4.3 + define('ADODB_PHPVER',0x4300); + } else if ($_adodb_ver > 4.199999) { # 4.2 + define('ADODB_PHPVER',0x4200); + } else if (strnatcmp(PHP_VERSION,'4.0.5')>=0) { + define('ADODB_PHPVER',0x4050); + } else { + define('ADODB_PHPVER',0x4000); + } + } + + //if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); + + + /** + Accepts $src and $dest arrays, replacing string $data + */ + function ADODB_str_replace($src, $dest, $data) + { + if (ADODB_PHPVER >= 0x4050) return str_replace($src,$dest,$data); + + $s = reset($src); + $d = reset($dest); + while ($s !== false) { + $data = str_replace($s,$d,$data); + $s = next($src); + $d = next($dest); + } + return $data; + } + + function ADODB_Setup() + { + GLOBAL + $ADODB_vers, // database version + $ADODB_COUNTRECS, // count number of records returned - slows down query + $ADODB_CACHE_DIR, // directory to cache recordsets + $ADODB_FETCH_MODE, + $ADODB_FORCE_TYPE, + $ADODB_QUOTE_FIELDNAMES; + + $ADODB_FETCH_MODE = ADODB_FETCH_DEFAULT; + $ADODB_FORCE_TYPE = ADODB_FORCE_VALUE; + + + if (!isset($ADODB_CACHE_DIR)) { + $ADODB_CACHE_DIR = '/tmp'; //(isset($_ENV['TMP'])) ? $_ENV['TMP'] : '/tmp'; + } else { + // do not accept url based paths, eg. http:/ or ftp:/ + if (strpos($ADODB_CACHE_DIR,'://') !== false) + die("Illegal path http:// or ftp://"); + } + + + // Initialize random number generator for randomizing cache flushes + // -- note Since PHP 4.2.0, the seed becomes optional and defaults to a random value if omitted. + srand(((double)microtime())*1000000); + + /** + * ADODB version as a string. + */ + $ADODB_vers = 'V4.96 24 Sept 2007 (c) 2000-2007 John Lim (jlim#natsoft.com.my). All rights reserved. Released BSD & LGPL.'; + + /** + * Determines whether recordset->RecordCount() is used. + * Set to false for highest performance -- RecordCount() will always return -1 then + * for databases that provide "virtual" recordcounts... + */ + if (!isset($ADODB_COUNTRECS)) $ADODB_COUNTRECS = true; + } + + + //============================================================================================== + // CHANGE NOTHING BELOW UNLESS YOU ARE DESIGNING ADODB + //============================================================================================== + + ADODB_Setup(); + + //============================================================================================== + // CLASS ADOFieldObject + //============================================================================================== + /** + * Helper class for FetchFields -- holds info on a column + */ + class ADOFieldObject { + var $name = ''; + var $max_length=0; + var $type=""; +/* + // additional fields by dannym... (danny_milo@yahoo.com) + var $not_null = false; + // actually, this has already been built-in in the postgres, fbsql AND mysql module? ^-^ + // so we can as well make not_null standard (leaving it at "false" does not harm anyways) + + var $has_default = false; // this one I have done only in mysql and postgres for now ... + // others to come (dannym) + var $default_value; // default, if any, and supported. Check has_default first. +*/ + } + + + + function ADODB_TransMonitor($dbms, $fn, $errno, $errmsg, $p1, $p2, &$thisConnection) + { + //print "Errorno ($fn errno=$errno m=$errmsg) "; + $thisConnection->_transOK = false; + if ($thisConnection->_oldRaiseFn) { + $fn = $thisConnection->_oldRaiseFn; + $fn($dbms, $fn, $errno, $errmsg, $p1, $p2,$thisConnection); + } + } + + //============================================================================================== + // CLASS ADOConnection + //============================================================================================== + + /** + * Connection object. For connecting to databases, and executing queries. + */ + class ADOConnection { + // + // PUBLIC VARS + // + var $dataProvider = 'native'; + var $databaseType = ''; /// RDBMS currently in use, eg. odbc, mysql, mssql + var $database = ''; /// Name of database to be used. + var $host = ''; /// The hostname of the database server + var $user = ''; /// The username which is used to connect to the database server. + var $password = ''; /// Password for the username. For security, we no longer store it. + var $debug = false; /// if set to true will output sql statements + var $maxblobsize = 262144; /// maximum size of blobs or large text fields (262144 = 256K)-- some db's die otherwise like foxpro + var $concat_operator = '+'; /// default concat operator -- change to || for Oracle/Interbase + var $substr = 'substr'; /// substring operator + var $length = 'length'; /// string length ofperator + var $random = 'rand()'; /// random function + var $upperCase = 'upper'; /// uppercase function + var $fmtDate = "'Y-m-d'"; /// used by DBDate() as the default date format used by the database + var $fmtTimeStamp = "'Y-m-d, h:i:s A'"; /// used by DBTimeStamp as the default timestamp fmt. + var $true = '1'; /// string that represents TRUE for a database + var $false = '0'; /// string that represents FALSE for a database + var $replaceQuote = "\\'"; /// string to use to replace quotes + var $nameQuote = '"'; /// string to use to quote identifiers and names + var $charSet=false; /// character set to use - only for interbase, postgres and oci8 + var $metaDatabasesSQL = ''; + var $metaTablesSQL = ''; + var $uniqueOrderBy = false; /// All order by columns have to be unique + var $emptyDate = ' '; + var $emptyTimeStamp = ' '; + var $lastInsID = false; + //-- + var $hasInsertID = false; /// supports autoincrement ID? + var $hasAffectedRows = false; /// supports affected rows for update/delete? + var $hasTop = false; /// support mssql/access SELECT TOP 10 * FROM TABLE + var $hasLimit = false; /// support pgsql/mysql SELECT * FROM TABLE LIMIT 10 + var $readOnly = false; /// this is a readonly database - used by phpLens + var $hasMoveFirst = false; /// has ability to run MoveFirst(), scrolling backwards + var $hasGenID = false; /// can generate sequences using GenID(); + var $hasTransactions = true; /// has transactions + //-- + var $genID = 0; /// sequence id used by GenID(); + var $raiseErrorFn = false; /// error function to call + var $isoDates = false; /// accepts dates in ISO format + var $cacheSecs = 3600; /// cache for 1 hour + + // memcache + var $memCache = false; /// should we use memCache instead of caching in files + var $memCacheHost; /// memCache host + var $memCachePort = 11211; /// memCache port + var $memCacheCompress = false; /// Use 'true' to store the item compressed (uses zlib) + + var $sysDate = false; /// name of function that returns the current date + var $sysTimeStamp = false; /// name of function that returns the current timestamp + var $arrayClass = 'ADORecordSet_array'; /// name of class used to generate array recordsets, which are pre-downloaded recordsets + + var $noNullStrings = false; /// oracle specific stuff - if true ensures that '' is converted to ' ' + var $numCacheHits = 0; + var $numCacheMisses = 0; + var $pageExecuteCountRows = true; + var $uniqueSort = false; /// indicates that all fields in order by must be unique + var $leftOuter = false; /// operator to use for left outer join in WHERE clause + var $rightOuter = false; /// operator to use for right outer join in WHERE clause + var $ansiOuter = false; /// whether ansi outer join syntax supported + var $autoRollback = false; // autoRollback on PConnect(). + var $poorAffectedRows = false; // affectedRows not working or unreliable + + var $fnExecute = false; + var $fnCacheExecute = false; + var $blobEncodeType = false; // false=not required, 'I'=encode to integer, 'C'=encode to char + var $rsPrefix = "ADORecordSet_"; + + var $autoCommit = true; /// do not modify this yourself - actually private + var $transOff = 0; /// temporarily disable transactions + var $transCnt = 0; /// count of nested transactions + + var $fetchMode=false; + var $num_rows = 0; + var $null2null = 'null'; // in autoexecute/getinsertsql/getupdatesql, this value will be converted to a null + // + // PRIVATE VARS + // + var $_oldRaiseFn = false; + var $_transOK = null; + var $_connectionID = false; /// The returned link identifier whenever a successful database connection is made. + var $_errorMsg = false; /// A variable which was used to keep the returned last error message. The value will + /// then returned by the errorMsg() function + var $_errorCode = false; /// Last error code, not guaranteed to be used - only by oci8 + var $_queryID = false; /// This variable keeps the last created result link identifier + + var $_isPersistentConnection = false; /// A boolean variable to state whether its a persistent connection or normal connection. */ + var $_bindInputArray = false; /// set to true if ADOConnection.Execute() permits binding of array parameters. + var $_evalAll = false; + var $_affected = false; + var $_logsql = false; + var $_transmode = ''; // transaction mode + var $db_query = NULL; + + + /** + * Constructor + */ + function ADOConnection() + { + die('Virtual Class -- cannot instantiate'); + } + + function Version() + { + global $ADODB_vers; + + return (float) substr($ADODB_vers,1); + } + + /** + Get server version info... + + @returns An array with 2 elements: $arr['string'] is the description string, + and $arr[version] is the version (also a string). + */ + function ServerInfo() + { + return array('description' => '', 'version' => ''); + } + + function IsConnected() + { + return !empty($this->_connectionID); + } + + function _findvers($str) + { + if (preg_match('/([0-9]+\.([0-9\.])+)/',$str, $arr)) return $arr[1]; + else return ''; + } + + /** + * All error messages go through this bottleneck function. + * You can define your own handler by defining the function name in ADODB_OUTP. + */ + function outp($msg,$newline=true) + { + global $ADODB_FLUSH,$ADODB_OUTP; + + if (defined('ADODB_OUTP')) { + $fn = ADODB_OUTP; + $fn($msg,$newline); + return; + } else if (isset($ADODB_OUTP)) { + $fn = $ADODB_OUTP; + $fn($msg,$newline); + return; + } + + if ($newline) $msg .= "
    \n"; + + if (isset($_SERVER['HTTP_USER_AGENT']) || !$newline) echo $msg; + else echo strip_tags($msg); + + + if (!empty($ADODB_FLUSH) && ob_get_length() !== false) flush(); // do not flush if output buffering enabled - useless - thx to Jesse Mullan + + } + + function Time() + { + $rs =& $this->_Execute("select $this->sysTimeStamp"); + if ($rs && !$rs->EOF) return $this->UnixTimeStamp(reset($rs->fields)); + + return false; + } + + /** + * Connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * @param [forceNew] force new connection + * + * @return true or false + */ + function Connect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "", $forceNew = false) + { + if ($argHostname != "") $this->host = $argHostname; + if ($argUsername != "") $this->user = $argUsername; + if ($argPassword != "") $this->password = $argPassword; // not stored for security reasons + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = false; + if ($forceNew) { + if ($rez=$this->_nconnect($this->host, $this->user, $this->password, $this->database)) return true; + } else { + if ($rez=$this->_connect($this->host, $this->user, $this->password, $this->database)) return true; + } + if (isset($rez)) { + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $ret = false; + } else { + $err = "Missing extension for ".$this->dataProvider; + $ret = 0; + } + if ($fn = $this->raiseErrorFn) + $fn($this->databaseType,'CONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + + + $this->_connectionID = false; + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); + return $ret; + } + + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabaseName) + { + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabaseName); + } + + + /** + * Always force a new connection to database - currently only works with oracle + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return true or false + */ + function NConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + return $this->Connect($argHostname, $argUsername, $argPassword, $argDatabaseName, true); + } + + /** + * Establish persistent connect to database + * + * @param [argHostname] Host to connect to + * @param [argUsername] Userid to login + * @param [argPassword] Associated password + * @param [argDatabaseName] database + * + * @return return true or false + */ + function PConnect($argHostname = "", $argUsername = "", $argPassword = "", $argDatabaseName = "") + { + if (defined('ADODB_NEVER_PERSIST')) + return $this->Connect($argHostname,$argUsername,$argPassword,$argDatabaseName); + + if ($argHostname != "") $this->host = $argHostname; + if ($argUsername != "") $this->user = $argUsername; + if ($argPassword != "") $this->password = $argPassword; + if ($argDatabaseName != "") $this->database = $argDatabaseName; + + $this->_isPersistentConnection = true; + if ($rez = $this->_pconnect($this->host, $this->user, $this->password, $this->database)) return true; + if (isset($rez)) { + $err = $this->ErrorMsg(); + if (empty($err)) $err = "Connection error to server '$argHostname' with user '$argUsername'"; + $ret = false; + } else { + $err = "Missing extension for ".$this->dataProvider; + $ret = 0; + } + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'PCONNECT',$this->ErrorNo(),$err,$this->host,$this->database,$this); + } + + $this->_connectionID = false; + if ($this->debug) ADOConnection::outp( $this->host.': '.$err); + return $ret; + } + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysDate; + return $col; // child class implement + } + + /** + * Should prepare the sql statement and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * $stmt = $db->Prepare("insert into table (id, name) values (?,?)"); + * $db->Execute($stmt,array(1,'Jill')) or die('insert failed'); + * $db->Execute($stmt,array(2,'Joe')) or die('insert failed'); + * + * @param sql SQL to send to database + * + * @return return FALSE, or the prepared statement, or the original sql if + * if the database does not support prepare. + * + */ + function Prepare($sql) + { + return $sql; + } + + /** + * Some databases, eg. mssql require a different function for preparing + * stored procedures. So we cannot use Prepare(). + * + * Should prepare the stored procedure and return the stmt resource. + * For databases that do not support this, we return the $sql. To ensure + * compatibility with databases that do not support prepare: + * + * @param sql SQL to send to database + * + * @return return FALSE, or the prepared statement, or the original sql if + * if the database does not support prepare. + * + */ + function PrepareSP($sql,$param=true) + { + return $this->Prepare($sql,$param); + } + + /** + * PEAR DB Compat + */ + function Quote($s) + { + return $this->qstr($s,false); + } + + /** + Requested by "Karsten Dambekalns" + */ + function QMagic($s) + { + return $this->qstr($s,get_magic_quotes_gpc()); + } + + function q(&$s) + { + #if (!empty($this->qNull)) if ($s == 'null') return $s; + $s = $this->qstr($s,false); + } + + /** + * PEAR DB Compat - do not use internally. + */ + function ErrorNative() + { + return $this->ErrorNo(); + } + + + /** + * PEAR DB Compat - do not use internally. + */ + function nextId($seq_name) + { + return $this->GenID($seq_name); + } + + /** + * Lock a row, will escalate and lock the table if row locking not supported + * will normally free the lock at the end of the transaction + * + * @param $table name of table to lock + * @param $where where clause to use, eg: "WHERE row=12". If left empty, will escalate to table lock + */ + function RowLock($table,$where) + { + return false; + } + + function CommitLock($table) + { + return $this->CommitTrans(); + } + + function RollbackLock($table) + { + return $this->RollbackTrans(); + } + + /** + * PEAR DB Compat - do not use internally. + * + * The fetch modes for NUMERIC and ASSOC for PEAR DB and ADODB are identical + * for easy porting :-) + * + * @param mode The fetchmode ADODB_FETCH_ASSOC or ADODB_FETCH_NUM + * @returns The previous fetch mode + */ + function SetFetchMode($mode) + { + $old = $this->fetchMode; + $this->fetchMode = $mode; + + if ($old === false) { + global $ADODB_FETCH_MODE; + return $ADODB_FETCH_MODE; + } + return $old; + } + + + /** + * PEAR DB Compat - do not use internally. + */ + function &Query($sql, $inputarr=false) + { + $rs = &$this->Execute($sql, $inputarr); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } + + + /** + * PEAR DB Compat - do not use internally + */ + function &LimitQuery($sql, $offset, $count, $params=false) + { + $rs = &$this->SelectLimit($sql, $count, $offset, $params); + if (!$rs && defined('ADODB_PEAR')) return ADODB_PEAR_Error(); + return $rs; + } + + + /** + * PEAR DB Compat - do not use internally + */ + function Disconnect() + { + return $this->Close(); + } + + /* + Returns placeholder for parameter, eg. + $DB->Param('a') + + will return ':a' for Oracle, and '?' for most other databases... + + For databases that require positioned params, eg $1, $2, $3 for postgresql, + pass in Param(false) before setting the first parameter. + */ + function Param($name,$type='C') + { + return '?'; + } + + /* + InParameter and OutParameter are self-documenting versions of Parameter(). + */ + function InParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + return $this->Parameter($stmt,$var,$name,false,$maxLen,$type); + } + + /* + */ + function OutParameter(&$stmt,&$var,$name,$maxLen=4000,$type=false) + { + return $this->Parameter($stmt,$var,$name,true,$maxLen,$type); + + } + + + /* + Usage in oracle + $stmt = $db->Prepare('select * from table where id =:myid and group=:group'); + $db->Parameter($stmt,$id,'myid'); + $db->Parameter($stmt,$group,'group',64); + $db->Execute(); + + @param $stmt Statement returned by Prepare() or PrepareSP(). + @param $var PHP variable to bind to + @param $name Name of stored procedure variable name to bind to. + @param [$isOutput] Indicates direction of parameter 0/false=IN 1=OUT 2= IN/OUT. This is ignored in oci8. + @param [$maxLen] Holds an maximum length of the variable. + @param [$type] The data type of $var. Legal values depend on driver. + + */ + function Parameter(&$stmt,&$var,$name,$isOutput=false,$maxLen=4000,$type=false) + { + return false; + } + + + function IgnoreErrors($saveErrs=false) + { + if (!$saveErrs) { + $saveErrs = array($this->raiseErrorFn,$this->_transOK); + $this->raiseErrorFn = false; + return $saveErrs; + } else { + $this->raiseErrorFn = $saveErrs[0]; + $this->_transOK = $saveErrs[1]; + } + } + + /** + Improved method of initiating a transaction. Used together with CompleteTrans(). + Advantages include: + + a. StartTrans/CompleteTrans is nestable, unlike BeginTrans/CommitTrans/RollbackTrans. + Only the outermost block is treated as a transaction.
    + b. CompleteTrans auto-detects SQL errors, and will rollback on errors, commit otherwise.
    + c. All BeginTrans/CommitTrans/RollbackTrans inside a StartTrans/CompleteTrans block + are disabled, making it backward compatible. + */ + function StartTrans($errfn = 'ADODB_TransMonitor') + { + if ($this->transOff > 0) { + $this->transOff += 1; + return; + } + + $this->_oldRaiseFn = $this->raiseErrorFn; + $this->raiseErrorFn = $errfn; + $this->_transOK = true; + + if ($this->debug && $this->transCnt > 0) ADOConnection::outp("Bad Transaction: StartTrans called within BeginTrans"); + $this->BeginTrans(); + $this->transOff = 1; + } + + + /** + Used together with StartTrans() to end a transaction. Monitors connection + for sql errors, and will commit or rollback as appropriate. + + @autoComplete if true, monitor sql errors and commit and rollback as appropriate, + and if set to false force rollback even if no SQL error detected. + @returns true on commit, false on rollback. + */ + function CompleteTrans($autoComplete = true) + { + if ($this->transOff > 1) { + $this->transOff -= 1; + return true; + } + $this->raiseErrorFn = $this->_oldRaiseFn; + + $this->transOff = 0; + if ($this->_transOK && $autoComplete) { + if (!$this->CommitTrans()) { + $this->_transOK = false; + if ($this->debug) ADOConnection::outp("Smart Commit failed"); + } else + if ($this->debug) ADOConnection::outp("Smart Commit occurred"); + } else { + $this->_transOK = false; + $this->RollbackTrans(); + if ($this->debug) ADOCOnnection::outp("Smart Rollback occurred"); + } + + return $this->_transOK; + } + + /* + At the end of a StartTrans/CompleteTrans block, perform a rollback. + */ + function FailTrans() + { + if ($this->debug) + if ($this->transOff == 0) { + ADOConnection::outp("FailTrans outside StartTrans/CompleteTrans"); + } else { + ADOConnection::outp("FailTrans was called"); + adodb_backtrace(); + } + $this->_transOK = false; + } + + /** + Check if transaction has failed, only for Smart Transactions. + */ + function HasFailedTrans() + { + if ($this->transOff > 0) return $this->_transOK == false; + return false; + } + + /** + * Execute SQL + * + * @param sql SQL statement to execute, or possibly an array holding prepared statement ($sql[0] will hold sql text) + * @param [inputarr] holds the input data to bind to. Null elements will be set to null. + * @return RecordSet or false + */ + function &Execute($sql,$inputarr=false) + { + if ($this->fnExecute) { + $fn = $this->fnExecute; + $ret =& $fn($this,$sql,$inputarr); + if (isset($ret)) return $ret; + } + if ($inputarr) { + if (!is_array($inputarr)) $inputarr = array($inputarr); + + $element0 = reset($inputarr); + # is_object check because oci8 descriptors can be passed in + $array_2d = is_array($element0) && !is_object(reset($element0)); + //remove extra memory copy of input -mikefedyk + unset($element0); + + if (!is_array($sql) && !$this->_bindInputArray) { + $sqlarr = explode('?',$sql); + + if (!$array_2d) $inputarr = array($inputarr); + foreach($inputarr as $arr) { + $sql = ''; $i = 0; + //Use each() instead of foreach to reduce memory usage -mikefedyk + while(list(, $v) = each($arr)) { + $sql .= $sqlarr[$i]; + // from Ron Baldwin + // Only quote string types + $typ = gettype($v); + if ($typ == 'string') + //New memory copy of input created here -mikefedyk + $sql .= $this->qstr($v); + else if ($typ == 'double') + $sql .= str_replace(',','.',$v); // locales fix so 1.1 does not get converted to 1,1 + else if ($typ == 'boolean') + $sql .= $v ? $this->true : $this->false; + else if ($typ == 'object') { + if (method_exists($v, '__toString')) $sql .= $this->qstr($v->__toString()); + else $sql .= $this->qstr((string) $v); + } else if ($v === null) + $sql .= 'NULL'; + else + $sql .= $v; + $i += 1; + } + if (isset($sqlarr[$i])) { + $sql .= $sqlarr[$i]; + if ($i+1 != sizeof($sqlarr)) ADOConnection::outp( "Input Array does not match ?: ".htmlspecialchars($sql)); + } else if ($i != sizeof($sqlarr)) + ADOConnection::outp( "Input array does not match ?: ".htmlspecialchars($sql)); + + + $ret =& $this->_Execute($sql); + if (!$ret) return $ret; + } + } else { + if ($array_2d) { + if (is_string($sql)) + $stmt = $this->Prepare($sql); + else + $stmt = $sql; + + foreach($inputarr as $arr) { + $ret =& $this->_Execute($stmt,$arr); + if (!$ret) return $ret; + } + } else { + + $ret =& $this->_Execute($sql,$inputarr); + } + } + } else { + $ret =& $this->_Execute($sql,false); + } + + return $ret; + } + + + function &_Execute($sql,$inputarr=false) + { + if ($this->debug) { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + $this->_queryID = _adodb_debug_execute($this, $sql,$inputarr); + } else { + $this->_queryID = @$this->_query($sql,$inputarr); + } + + /************************ + // OK, query executed + *************************/ + + if ($this->_queryID === false) { // error handling if query fails + if ($this->debug == 99) adodb_backtrace(true,5); + $fn = $this->raiseErrorFn; + if ($fn) { + $fn($this->databaseType,'EXECUTE',$this->ErrorNo(),$this->ErrorMsg(),$sql,$inputarr,$this); + } + $false = false; + return $false; + } + + if ($this->_queryID === true) { // return simplified recordset for inserts/updates/deletes with lower overhead + $rsclass = $this->rsPrefix.'empty'; + $rs = (class_exists($rsclass)) ? new $rsclass(): new ADORecordSet_empty(); + + return $rs; + } + + // return real recordset from select statement + $rsclass = $this->rsPrefix.$this->databaseType; + $rs = new $rsclass($this->_queryID,$this->fetchMode); + $rs->connection = &$this; // Pablo suggestion + $rs->Init(); + if (is_array($sql)) $rs->sql = $sql[0]; + else $rs->sql = $sql; + if ($rs->_numOfRows <= 0) { + global $ADODB_COUNTRECS; + if ($ADODB_COUNTRECS) { + if (!$rs->EOF) { + $rs = &$this->_rs2rs($rs,-1,-1,!is_array($sql)); + $rs->_queryID = $this->_queryID; + } else + $rs->_numOfRows = 0; + } + } + return $rs; + } + + function CreateSequence($seqname='adodbseq',$startID=1) + { + if (empty($this->_genSeqSQL)) return false; + return $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); + } + + function DropSequence($seqname='adodbseq') + { + if (empty($this->_dropSeqSQL)) return false; + return $this->Execute(sprintf($this->_dropSeqSQL,$seqname)); + } + + /** + * Generates a sequence id and stores it in $this->genID; + * GenID is only available if $this->hasGenID = true; + * + * @param seqname name of sequence to use + * @param startID if sequence does not exist, start at this ID + * @return 0 if not supported, otherwise a sequence id + */ + function GenID($seqname='adodbseq',$startID=1) + { + if (!$this->hasGenID) { + return 0; // formerly returns false pre 1.60 + } + + $getnext = sprintf($this->_genIDSQL,$seqname); + + $holdtransOK = $this->_transOK; + + $save_handler = $this->raiseErrorFn; + $this->raiseErrorFn = ''; + @($rs = $this->Execute($getnext)); + $this->raiseErrorFn = $save_handler; + + if (!$rs) { + $this->_transOK = $holdtransOK; //if the status was ok before reset + $createseq = $this->Execute(sprintf($this->_genSeqSQL,$seqname,$startID)); + $rs = $this->Execute($getnext); + } + if ($rs && !$rs->EOF) $this->genID = reset($rs->fields); + else $this->genID = 0; // false + + if ($rs) $rs->Close(); + + return $this->genID; + } + + /** + * @param $table string name of the table, not needed by all databases (eg. mysql), default '' + * @param $column string name of the column, not needed by all databases (eg. mysql), default '' + * @return the last inserted ID. Not all databases support this. + */ + function Insert_ID($table='',$column='') + { + if ($this->_logsql && $this->lastInsID) return $this->lastInsID; + if ($this->hasInsertID) return $this->_insertid($table,$column); + if ($this->debug) { + ADOConnection::outp( '

    Insert_ID error

    '); + adodb_backtrace(); + } + return false; + } + + + /** + * Portable Insert ID. Pablo Roca + * + * @return the last inserted ID. All databases support this. But aware possible + * problems in multiuser environments. Heavy test this before deploying. + */ + function PO_Insert_ID($table="", $id="") + { + if ($this->hasInsertID){ + return $this->Insert_ID($table,$id); + } else { + return $this->GetOne("SELECT MAX($id) FROM $table"); + } + } + + /** + * @return # rows affected by UPDATE/DELETE + */ + function Affected_Rows() + { + if ($this->hasAffectedRows) { + if ($this->fnExecute === 'adodb_log_sql') { + if ($this->_logsql && $this->_affected !== false) return $this->_affected; + } + $val = $this->_affectedrows(); + return ($val < 0) ? false : $val; + } + + if ($this->debug) ADOConnection::outp( '

    Affected_Rows error

    ',false); + return false; + } + + + /** + * @return the last error message + */ + function ErrorMsg() + { + if ($this->_errorMsg) return '!! '.strtoupper($this->dataProvider.' '.$this->databaseType).': '.$this->_errorMsg; + else return ''; + } + + + /** + * @return the last error number. Normally 0 means no error. + */ + function ErrorNo() + { + return ($this->_errorMsg) ? -1 : 0; + } + + function MetaError($err=false) + { + include_once(ADODB_DIR."/adodb-error.inc.php"); + if ($err === false) $err = $this->ErrorNo(); + return adodb_error($this->dataProvider,$this->databaseType,$err); + } + + function MetaErrorMsg($errno) + { + include_once(ADODB_DIR."/adodb-error.inc.php"); + return adodb_errormsg($errno); + } + + /** + * @returns an array with the primary key columns in it. + */ + function MetaPrimaryKeys($table, $owner=false) + { + // owner not used in base class - see oci8 + $p = array(); + $objs =& $this->MetaColumns($table); + if ($objs) { + foreach($objs as $v) { + if (!empty($v->primary_key)) + $p[] = $v->name; + } + } + if (sizeof($p)) return $p; + if (function_exists('ADODB_VIEW_PRIMARYKEYS')) + return ADODB_VIEW_PRIMARYKEYS($this->databaseType, $this->database, $table, $owner); + return false; + } + + /** + * @returns assoc array where keys are tables, and values are foreign keys + */ + function MetaForeignKeys($table, $owner=false, $upper=false) + { + return false; + } + /** + * Choose a database to connect to. Many databases do not support this. + * + * @param dbName is the name of the database to select + * @return true or false + */ + function SelectDB($dbName) + {return false;} + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * SelectLimit('select * from table',3); will return rows 1 to 3 (1-based) + * SelectLimit('select * from table',3,2); will return rows 3 to 5 (1-based) + * + * Uses SELECT TOP for Microsoft databases (when $this->hasTop is set) + * BUG: Currently SelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to get + * @param [inputarr] array of bind variables + * @param [secs2cache] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + */ + function &SelectLimit($sql,$nrows=-1,$offset=-1, $inputarr=false,$secs2cache=0) + { + if ($this->hasTop && $nrows > 0) { + // suggested by Reinhard Balling. Access requires top after distinct + // Informix requires first before distinct - F Riosa + $ismssql = (strpos($this->databaseType,'mssql') !== false); + if ($ismssql) $isaccess = false; + else $isaccess = (strpos($this->databaseType,'access') !== false); + + if ($offset <= 0) { + + // access includes ties in result + if ($isaccess) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + + if ($secs2cache != 0) { + $ret =& $this->CacheExecute($secs2cache, $sql,$inputarr); + } else { + $ret =& $this->Execute($sql,$inputarr); + } + return $ret; // PHP5 fix + } else if ($ismssql){ + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + } else { + $sql = preg_replace( + '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.((integer)$nrows).' ',$sql); + } + } else { + $nn = $nrows + $offset; + if ($isaccess || $ismssql) { + $sql = preg_replace( + '/(^\s*select\s+(distinctrow|distinct)?)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); + } else { + $sql = preg_replace( + '/(^\s*select\s)/i','\\1 '.$this->hasTop.' '.$nn.' ',$sql); + } + } + } + + // if $offset>0, we want to skip rows, and $ADODB_COUNTRECS is set, we buffer rows + // 0 to offset-1 which will be discarded anyway. So we disable $ADODB_COUNTRECS. + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + if ($offset>0){ + if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); + else $rs = &$this->Execute($sql,$inputarr); + } else { + if ($secs2cache != 0) $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); + else $rs = &$this->Execute($sql,$inputarr); + } + $ADODB_COUNTRECS = $savec; + if ($rs && !$rs->EOF) { + $rs =& $this->_rs2rs($rs,$nrows,$offset); + } + //print_r($rs); + return $rs; + } + + /** + * Create serializable recordset. Breaks rs link to connection. + * + * @param rs the recordset to serialize + */ + function &SerializableRS(&$rs) + { + $rs2 =& $this->_rs2rs($rs); + $ignore = false; + $rs2->connection =& $ignore; + + return $rs2; + } + + /** + * Convert database recordset to an array recordset + * input recordset's cursor should be at beginning, and + * old $rs will be closed. + * + * @param rs the recordset to copy + * @param [nrows] number of rows to retrieve (optional) + * @param [offset] offset by number of rows (optional) + * @return the new recordset + */ + function &_rs2rs(&$rs,$nrows=-1,$offset=-1,$close=true) + { + if (! $rs) { + $false = false; + return $false; + } + $dbtype = $rs->databaseType; + if (!$dbtype) { + $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1 -- why ? + return $rs; + } + if (($dbtype == 'array' || $dbtype == 'csv') && $nrows == -1 && $offset == -1) { + $rs->MoveFirst(); + $rs = &$rs; // required to prevent crashing in 4.2.1, but does not happen in 4.3.1-- why ? + return $rs; + } + $flds = array(); + for ($i=0, $max=$rs->FieldCount(); $i < $max; $i++) { + $flds[] = $rs->FetchField($i); + } + + $arr =& $rs->GetArrayLimit($nrows,$offset); + //print_r($arr); + if ($close) $rs->Close(); + + $arrayClass = $this->arrayClass; + + $rs2 = new $arrayClass(); + $rs2->connection = &$this; + $rs2->sql = $rs->sql; + $rs2->dataProvider = $this->dataProvider; + $rs2->InitArrayFields($arr,$flds); + $rs2->fetchMode = isset($rs->adodbFetchMode) ? $rs->adodbFetchMode : $rs->fetchMode; + return $rs2; + } + + /* + * Return all rows. Compat with PEAR DB + */ + function &GetAll($sql, $inputarr=false) + { + $arr =& $this->GetArray($sql,$inputarr); + return $arr; + } + + function &GetAssoc($sql, $inputarr=false,$force_array = false, $first2cols = false) + { + $rs =& $this->Execute($sql, $inputarr); + if (!$rs) { + $false = false; + return $false; + } + $arr =& $rs->GetAssoc($force_array,$first2cols); + return $arr; + } + + function &CacheGetAssoc($secs2cache, $sql=false, $inputarr=false,$force_array = false, $first2cols = false) + { + if (!is_numeric($secs2cache)) { + $first2cols = $force_array; + $force_array = $inputarr; + } + $rs =& $this->CacheExecute($secs2cache, $sql, $inputarr); + if (!$rs) { + $false = false; + return $false; + } + $arr =& $rs->GetAssoc($force_array,$first2cols); + return $arr; + } + + /** + * Return first element of first row of sql statement. Recordset is disposed + * for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function GetOne($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + $crecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + $ret = false; + $rs = &$this->Execute($sql,$inputarr); + if ($rs) { + if ($rs->EOF) $ret = null; + else $ret = reset($rs->fields); + + $rs->Close(); + } + $ADODB_COUNTRECS = $crecs; + return $ret; + } + + function CacheGetOne($secs2cache,$sql=false,$inputarr=false) + { + $ret = false; + $rs = &$this->CacheExecute($secs2cache,$sql,$inputarr); + if ($rs) { + if ($rs->EOF) $ret = null; + else $ret = reset($rs->fields); + $rs->Close(); + } + + return $ret; + } + + function GetCol($sql, $inputarr = false, $trim = false) + { + $rv = false; + $rs = &$this->Execute($sql, $inputarr); + if ($rs) { + $rv = array(); + if ($trim) { + while (!$rs->EOF) { + $rv[] = trim(reset($rs->fields)); + $rs->MoveNext(); + } + } else { + while (!$rs->EOF) { + $rv[] = reset($rs->fields); + $rs->MoveNext(); + } + } + $rs->Close(); + } + return $rv; + } + + function CacheGetCol($secs, $sql = false, $inputarr = false,$trim=false) + { + $rv = false; + $rs = &$this->CacheExecute($secs, $sql, $inputarr); + if ($rs) { + if ($trim) { + while (!$rs->EOF) { + $rv[] = trim(reset($rs->fields)); + $rs->MoveNext(); + } + } else { + while (!$rs->EOF) { + $rv[] = reset($rs->fields); + $rs->MoveNext(); + } + } + $rs->Close(); + } + return $rv; + } + + function &Transpose(&$rs,$addfieldnames=true) + { + $rs2 =& $this->_rs2rs($rs); + $false = false; + if (!$rs2) return $false; + + $rs2->_transpose($addfieldnames); + return $rs2; + } + + /* + Calculate the offset of a date for a particular database and generate + appropriate SQL. Useful for calculating future/past dates and storing + in a database. + + If dayFraction=1.5 means 1.5 days from now, 1.0/24 for 1 hour. + */ + function OffsetDate($dayFraction,$date=false) + { + if (!$date) $date = $this->sysDate; + return '('.$date.'+'.$dayFraction.')'; + } + + + /** + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function &GetArray($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + $rs =& $this->Execute($sql,$inputarr); + $ADODB_COUNTRECS = $savec; + if (!$rs) + if (defined('ADODB_PEAR')) { + $cls = ADODB_PEAR_Error(); + return $cls; + } else { + $false = false; + return $false; + } + $arr =& $rs->GetArray(); + $rs->Close(); + return $arr; + } + + function &CacheGetAll($secs2cache,$sql=false,$inputarr=false) + { + $arr =& $this->CacheGetArray($secs2cache,$sql,$inputarr); + return $arr; + } + + function &CacheGetArray($secs2cache,$sql=false,$inputarr=false) + { + global $ADODB_COUNTRECS; + + $savec = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); + $ADODB_COUNTRECS = $savec; + + if (!$rs) + if (defined('ADODB_PEAR')) { + $cls = ADODB_PEAR_Error(); + return $cls; + } else { + $false = false; + return $false; + } + $arr =& $rs->GetArray(); + $rs->Close(); + return $arr; + } + + function GetRandRow($sql, $arr= false) + { + $rezarr = $this->GetAll($sql, $arr); + $sz = sizeof($rez); + return $rezarr[abs(rand()) % $sz]; + } + + /** + * Return one row of sql statement. Recordset is disposed for you. + * + * @param sql SQL statement + * @param [inputarr] input bind array + */ + function &GetRow($sql,$inputarr=false) + { + global $ADODB_COUNTRECS; + $crecs = $ADODB_COUNTRECS; + $ADODB_COUNTRECS = false; + + $rs =& $this->Execute($sql,$inputarr); + + $ADODB_COUNTRECS = $crecs; + if ($rs) { + if (!$rs->EOF) $arr = $rs->fields; + else $arr = array(); + $rs->Close(); + return $arr; + } + + $false = false; + return $false; + } + + function &CacheGetRow($secs2cache,$sql=false,$inputarr=false) + { + $rs =& $this->CacheExecute($secs2cache,$sql,$inputarr); + if ($rs) { + $arr = false; + if (!$rs->EOF) $arr = $rs->fields; + $rs->Close(); + return $arr; + } + $false = false; + return $false; + } + + /** + * Insert or replace a single record. Note: this is not the same as MySQL's replace. + * ADOdb's Replace() uses update-insert semantics, not insert-delete-duplicates of MySQL. + * Also note that no table locking is done currently, so it is possible that the + * record be inserted twice by two programs... + * + * $this->Replace('products', array('prodname' =>"'Nails'","price" => 3.99), 'prodname'); + * + * $table table name + * $fieldArray associative array of data (you must quote strings yourself). + * $keyCol the primary key field name or if compound key, array of field names + * autoQuote set to true to use a hueristic to quote strings. Works with nulls and numbers + * but does not work with dates nor SQL functions. + * has_autoinc the primary key is an auto-inc field, so skip in insert. + * + * Currently blob replace not supported + * + * returns 0 = fail, 1 = update, 2 = insert + */ + + function Replace($table, $fieldArray, $keyCol, $autoQuote=false, $has_autoinc=false) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + + return _adodb_replace($this, $table, $fieldArray, $keyCol, $autoQuote, $has_autoinc); + } + + + /** + * Will select, getting rows from $offset (1-based), for $nrows. + * This simulates the MySQL "select * from table limit $offset,$nrows" , and + * the PostgreSQL "select * from table limit $nrows offset $offset". Note that + * MySQL and PostgreSQL parameter ordering is the opposite of the other. + * eg. + * CacheSelectLimit(15,'select * from table',3); will return rows 1 to 3 (1-based) + * CacheSelectLimit(15,'select * from table',3,2); will return rows 3 to 5 (1-based) + * + * BUG: Currently CacheSelectLimit fails with $sql with LIMIT or TOP clause already set + * + * @param [secs2cache] seconds to cache data, set to 0 to force query. This is optional + * @param sql + * @param [offset] is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to get + * @param [inputarr] array of bind variables + * @return the recordset ($rs->databaseType == 'array') + */ + function &CacheSelectLimit($secs2cache,$sql,$nrows=-1,$offset=-1,$inputarr=false) + { + if (!is_numeric($secs2cache)) { + if ($sql === false) $sql = -1; + if ($offset == -1) $offset = false; + // sql, nrows, offset,inputarr + $rs =& $this->SelectLimit($secs2cache,$sql,$nrows,$offset,$this->cacheSecs); + } else { + if ($sql === false) ADOConnection::outp( "Warning: \$sql missing from CacheSelectLimit()"); + $rs =& $this->SelectLimit($sql,$nrows,$offset,$inputarr,$secs2cache); + } + return $rs; + } + + + /** + * Flush cached recordsets that match a particular $sql statement. + * If $sql == false, then we purge all files in the cache. + */ + + /** + * Flush cached recordsets that match a particular $sql statement. + * If $sql == false, then we purge all files in the cache. + */ + function CacheFlush($sql=false,$inputarr=false) + { + global $ADODB_CACHE_DIR; + + if ($this->memCache) { + global $ADODB_INCLUDED_MEMCACHE; + + $key = false; + if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php'); + if ($sql) $key = $this->_gencachename($sql.serialize($inputarr),false,true); + FlushMemCache($key, $this->memCacheHost, $this->memCachePort, $this->debug); + return; + } + + if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { + /*if (strncmp(PHP_OS,'WIN',3) === 0) + $dir = str_replace('/', '\\', $ADODB_CACHE_DIR); + else */ + $dir = $ADODB_CACHE_DIR; + + if ($this->debug) { + ADOConnection::outp( "CacheFlush: $dir
    \n". $this->_dirFlush($dir)."
    "); + } else { + $this->_dirFlush($dir); + } + return; + } + + global $ADODB_INCLUDED_CSV; + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + + $f = $this->_gencachename($sql.serialize($inputarr),false); + adodb_write_file($f,''); // is adodb_write_file needed? + if (!@unlink($f)) { + if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f"); + } + } + + /** + * Private function to erase all of the files and subdirectories in a directory. + * + * Just specify the directory, and tell it if you want to delete the directory or just clear it out. + * Note: $kill_top_level is used internally in the function to flush subdirectories. + */ + function _dirFlush($dir, $kill_top_level = false) + { + if(!$dh = @opendir($dir)) return; + + while (($obj = readdir($dh))) { + if($obj=='.' || $obj=='..') continue; + $f = $dir.'/'.$obj; + + if (strpos($obj,'.cache')) @unlink($f); + if (is_dir($f)) $this->_dirFlush($f, true); + } + if ($kill_top_level === true) @rmdir($dir); + return true; + } + + + function xCacheFlush($sql=false,$inputarr=false) + { + global $ADODB_CACHE_DIR; + + if ($this->memCache) { + global $ADODB_INCLUDED_MEMCACHE; + $key = false; + if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php'); + if ($sql) $key = $this->_gencachename($sql.serialize($inputarr),false,true); + flushmemCache($key, $this->memCacheHost, $this->memCachePort, $this->debug); + return; + } + + if (strlen($ADODB_CACHE_DIR) > 1 && !$sql) { + if (strncmp(PHP_OS,'WIN',3) === 0) { + $cmd = 'del /s '.str_replace('/','\\',$ADODB_CACHE_DIR).'\adodb_*.cache'; + } else { + //$cmd = 'find "'.$ADODB_CACHE_DIR.'" -type f -maxdepth 1 -print0 | xargs -0 rm -f'; + $cmd = 'rm -rf '.$ADODB_CACHE_DIR.'/[0-9a-f][0-9a-f]/'; + // old version 'rm -f `find '.$ADODB_CACHE_DIR.' -name adodb_*.cache`'; + } + if ($this->debug) { + ADOConnection::outp( "CacheFlush: $cmd
    \n", system($cmd),"
    "); + } else { + exec($cmd); + } + return; + } + + global $ADODB_INCLUDED_CSV; + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + + $f = $this->_gencachename($sql.serialize($inputarr),false); + adodb_write_file($f,''); // is adodb_write_file needed? + if (!@unlink($f)) { + if ($this->debug) ADOConnection::outp( "CacheFlush: failed for $f"); + } + } + + /** + * Private function to generate filename for caching. + * Filename is generated based on: + * + * - sql statement + * - database type (oci8, ibase, ifx, etc) + * - database name + * - userid + * - setFetchMode (adodb 4.23) + * + * When not in safe mode, we create 256 sub-directories in the cache directory ($ADODB_CACHE_DIR). + * Assuming that we can have 50,000 files per directory with good performance, + * then we can scale to 12.8 million unique cached recordsets. Wow! + */ + function _gencachename($sql,$createdir,$memcache=false) + { + global $ADODB_CACHE_DIR; + static $notSafeMode; + + if ($this->fetchMode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } else { + $mode = $this->fetchMode; + } + $m = md5($sql.$this->databaseType.$this->database.$this->user.$mode); + if ($memcache) return $m; + + if (!isset($notSafeMode)) $notSafeMode = !ini_get('safe_mode'); + $dir = ($notSafeMode) ? $ADODB_CACHE_DIR.'/'.substr($m,0,2) : $ADODB_CACHE_DIR; + + if ($createdir && $notSafeMode && !file_exists($dir)) { + $oldu = umask(0); + if (!mkdir($dir,0771)) + if ($this->debug) ADOConnection::outp( "Unable to mkdir $dir for $sql"); + umask($oldu); + } + return $dir.'/adodb_'.$m.'.cache'; + } + + + /** + * Execute SQL, caching recordsets. + * + * @param [secs2cache] seconds to cache data, set to 0 to force query. + * This is an optional parameter. + * @param sql SQL statement to execute + * @param [inputarr] holds the input data to bind to + * @return RecordSet or false + */ + function &CacheExecute($secs2cache,$sql=false,$inputarr=false) + { + + + if (!is_numeric($secs2cache)) { + $inputarr = $sql; + $sql = $secs2cache; + $secs2cache = $this->cacheSecs; + } + + if (is_array($sql)) { + $sqlparam = $sql; + $sql = $sql[0]; + } else + $sqlparam = $sql; + + if ($this->memCache) { + global $ADODB_INCLUDED_MEMCACHE; + if (empty($ADODB_INCLUDED_MEMCACHE)) include(ADODB_DIR.'/adodb-memcache.lib.inc.php'); + $md5file = $this->_gencachename($sql.serialize($inputarr),false,true); + } else { + global $ADODB_INCLUDED_CSV; + if (empty($ADODB_INCLUDED_CSV)) include(ADODB_DIR.'/adodb-csvlib.inc.php'); + $md5file = $this->_gencachename($sql.serialize($inputarr),true); + } + + $err = ''; + + if ($secs2cache > 0){ + if ($this->memCache) + $rs = &getmemCache($md5file,$err,$secs2cache, $this->memCacheHost, $this->memCachePort); + else + $rs = &csv2rs($md5file,$err,$secs2cache,$this->arrayClass); + $this->numCacheHits += 1; + } else { + $err='Timeout 1'; + $rs = false; + $this->numCacheMisses += 1; + } + if (!$rs) { + // no cached rs found + if ($this->debug) { + if (get_magic_quotes_runtime() && !$this->memCache) { + ADOConnection::outp("Please disable magic_quotes_runtime - it corrupts cache files :("); + } + if ($this->debug !== -1) ADOConnection::outp( " $md5file cache failure: $err (see sql below)"); + } + + $rs = &$this->Execute($sqlparam,$inputarr); + + if ($rs && $this->memCache) { + $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately + if(!putmemCache($md5file, $rs, $this->memCacheHost, $this->memCachePort, $this->memCacheCompress, $this->debug)) { + if ($fn = $this->raiseErrorFn) + $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this); + if ($this->debug) ADOConnection::outp( " Cache write error"); + } + } else + if ($rs) { + $eof = $rs->EOF; + $rs = &$this->_rs2rs($rs); // read entire recordset into memory immediately + $txt = _rs2serialize($rs,false,$sql); // serialize + + if (!adodb_write_file($md5file,$txt,$this->debug)) { + if ($fn = $this->raiseErrorFn) { + $fn($this->databaseType,'CacheExecute',-32000,"Cache write error",$md5file,$sql,$this); + } + if ($this->debug) ADOConnection::outp( " Cache write error"); + } + if ($rs->EOF && !$eof) { + $rs->MoveFirst(); + //$rs = &csv2rs($md5file,$err); + $rs->connection = &$this; // Pablo suggestion + } + + } else + if (!$this->memCache) + @unlink($md5file); + } else { + $this->_errorMsg = ''; + $this->_errorCode = 0; + + if ($this->fnCacheExecute) { + $fn = $this->fnCacheExecute; + $fn($this, $secs2cache, $sql, $inputarr); + } + // ok, set cached object found + $rs->connection = &$this; // Pablo suggestion + if ($this->debug){ + + $inBrowser = isset($_SERVER['HTTP_USER_AGENT']); + $ttl = $rs->timeCreated + $secs2cache - time(); + $s = is_array($sql) ? $sql[0] : $sql; + if ($inBrowser) $s = ''.htmlspecialchars($s).''; + + ADOConnection::outp( " $md5file reloaded, ttl=$ttl [ $s ]"); + } + } + return $rs; + } + + + /* + Similar to PEAR DB's autoExecute(), except that + $mode can be 'INSERT' or 'UPDATE' or DB_AUTOQUERY_INSERT or DB_AUTOQUERY_UPDATE + If $mode == 'UPDATE', then $where is compulsory as a safety measure. + + $forceUpdate means that even if the data has not changed, perform update. + */ + function& AutoExecute($table, $fields_values, $mode = 'INSERT', $where = FALSE, $forceUpdate=true, $magicq=false) + { + $false = false; + $sql = 'SELECT * FROM '.$table; + if ($where!==FALSE) $sql .= ' WHERE '.$where; + else if ($mode == 'UPDATE' || $mode == 2 /* DB_AUTOQUERY_UPDATE */) { + ADOConnection::outp('AutoExecute: Illegal mode=UPDATE with empty WHERE clause'); + return $false; + } + + $rs =& $this->SelectLimit($sql,1); + if (!$rs) return $false; // table does not exist + $rs->tableName = $table; + + switch((string) $mode) { + case 'UPDATE': + case '2': + $sql = $this->GetUpdateSQL($rs, $fields_values, $forceUpdate, $magicq); + break; + case 'INSERT': + case '1': + $sql = $this->GetInsertSQL($rs, $fields_values, $magicq); + break; + default: + ADOConnection::outp("AutoExecute: Unknown mode=$mode"); + return $false; + } + $ret = false; + if ($sql) $ret = $this->Execute($sql); + if ($ret) $ret = true; + return $ret; + } + + + /** + * Generates an Update Query based on an existing recordset. + * $arrFields is an associative array of fields with the value + * that should be assigned. + * + * Note: This function should only be used on a recordset + * that is run against a single table and sql should only + * be a simple select stmt with no groupby/orderby/limit + * + * "Jonathan Younger" + */ + function GetUpdateSQL(&$rs, $arrFields,$forceUpdate=false,$magicq=false,$force=null) + { + global $ADODB_INCLUDED_LIB; + + //********************************************************// + //This is here to maintain compatibility + //with older adodb versions. Sets force type to force nulls if $forcenulls is set. + if (!isset($force)) { + global $ADODB_FORCE_TYPE; + $force = $ADODB_FORCE_TYPE; + } + //********************************************************// + + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getupdatesql($this,$rs,$arrFields,$forceUpdate,$magicq,$force); + } + + /** + * Generates an Insert Query based on an existing recordset. + * $arrFields is an associative array of fields with the value + * that should be assigned. + * + * Note: This function should only be used on a recordset + * that is run against a single table. + */ + function GetInsertSQL(&$rs, $arrFields,$magicq=false,$force=null) + { + global $ADODB_INCLUDED_LIB; + if (!isset($force)) { + global $ADODB_FORCE_TYPE; + $force = $ADODB_FORCE_TYPE; + + } + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getinsertsql($this,$rs,$arrFields,$magicq,$force); + } + + + /** + * Update a blob column, given a where clause. There are more sophisticated + * blob handling functions that we could have implemented, but all require + * a very complex API. Instead we have chosen something that is extremely + * simple to understand and use. + * + * Note: $blobtype supports 'BLOB' and 'CLOB', default is BLOB of course. + * + * Usage to update a $blobvalue which has a primary key blob_id=1 into a + * field blobtable.blobcolumn: + * + * UpdateBlob('blobtable', 'blobcolumn', $blobvalue, 'blob_id=1'); + * + * Insert example: + * + * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + * $conn->UpdateBlob('blobtable','blobcol',$blob,'id=1'); + */ + + function UpdateBlob($table,$column,$val,$where,$blobtype='BLOB') + { + return $this->Execute("UPDATE $table SET $column=? WHERE $where",array($val)) != false; + } + + /** + * Usage: + * UpdateBlob('TABLE', 'COLUMN', '/path/to/file', 'ID=1'); + * + * $blobtype supports 'BLOB' and 'CLOB' + * + * $conn->Execute('INSERT INTO blobtable (id, blobcol) VALUES (1, null)'); + * $conn->UpdateBlob('blobtable','blobcol',$blobpath,'id=1'); + */ + function UpdateBlobFile($table,$column,$path,$where,$blobtype='BLOB') + { + $fd = fopen($path,'rb'); + if ($fd === false) return false; + $val = fread($fd,filesize($path)); + fclose($fd); + return $this->UpdateBlob($table,$column,$val,$where,$blobtype); + } + + function BlobDecode($blob) + { + return $blob; + } + + function BlobEncode($blob) + { + return $blob; + } + + function SetCharSet($charset) + { + return false; + } + + function IfNull( $field, $ifNull ) + { + return " CASE WHEN $field is null THEN $ifNull ELSE $field END "; + } + + function LogSQL($enable=true) + { + include_once(ADODB_DIR.'/adodb-perf.inc.php'); + + if ($enable) $this->fnExecute = 'adodb_log_sql'; + else $this->fnExecute = false; + + $old = $this->_logsql; + $this->_logsql = $enable; + if ($enable && !$old) $this->_affected = false; + return $old; + } + + function GetCharSet() + { + return false; + } + + /** + * Usage: + * UpdateClob('TABLE', 'COLUMN', $var, 'ID=1', 'CLOB'); + * + * $conn->Execute('INSERT INTO clobtable (id, clobcol) VALUES (1, null)'); + * $conn->UpdateClob('clobtable','clobcol',$clob,'id=1'); + */ + function UpdateClob($table,$column,$val,$where) + { + return $this->UpdateBlob($table,$column,$val,$where,'CLOB'); + } + + // not the fastest implementation - quick and dirty - jlim + // for best performance, use the actual $rs->MetaType(). + function MetaType($t,$len=-1,$fieldobj=false) + { + + if (empty($this->_metars)) { + $rsclass = $this->rsPrefix.$this->databaseType; + $this->_metars = new $rsclass(false,$this->fetchMode); + $this->_metars->connection =& $this; + } + return $this->_metars->MetaType($t,$len,$fieldobj); + } + + + /** + * Change the SQL connection locale to a specified locale. + * This is used to get the date formats written depending on the client locale. + */ + function SetDateLocale($locale = 'En') + { + $this->locale = $locale; + switch (strtoupper($locale)) + { + case 'EN': + $this->fmtDate="'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d H:i:s'"; + break; + + case 'US': + $this->fmtDate = "'m-d-Y'"; + $this->fmtTimeStamp = "'m-d-Y H:i:s'"; + break; + + case 'PT_BR': + case 'NL': + case 'FR': + case 'RO': + case 'IT': + $this->fmtDate="'d-m-Y'"; + $this->fmtTimeStamp = "'d-m-Y H:i:s'"; + break; + + case 'GE': + $this->fmtDate="'d.m.Y'"; + $this->fmtTimeStamp = "'d.m.Y H:i:s'"; + break; + + default: + $this->fmtDate="'Y-m-d'"; + $this->fmtTimeStamp = "'Y-m-d H:i:s'"; + break; + } + } + + function &GetActiveRecordsClass($class, $table,$whereOrderBy=false,$bindarr=false, $primkeyArr=false) + { + global $_ADODB_ACTIVE_DBS; + + $save = $this->SetFetchMode(ADODB_FETCH_NUM); + if (empty($whereOrderBy)) $whereOrderBy = '1=1'; + $rows = $this->GetAll("select * from ".$table.' WHERE '.$whereOrderBy,$bindarr); + $this->SetFetchMode($save); + + $false = false; + + if ($rows === false) { + return $false; + } + + + if (!isset($_ADODB_ACTIVE_DBS)) { + include(ADODB_DIR.'/adodb-active-record.inc.php'); + } + if (!class_exists($class)) { + ADOConnection::outp("Unknown class $class in GetActiveRcordsClass()"); + return $false; + } + $arr = array(); + foreach($rows as $row) { + + $obj = new $class($table,$primkeyArr,$this); + if ($obj->ErrorMsg()){ + $this->_errorMsg = $obj->ErrorMsg(); + return $false; + } + $obj->Set($row); + $arr[] = $obj; + } + return $arr; + } + + function &GetActiveRecords($table,$where=false,$bindarr=false,$primkeyArr=false) + { + $arr =& $this->GetActiveRecordsClass('ADODB_Active_Record', $table, $where, $bindarr, $primkeyArr); + return $arr; + } + + /** + * Close Connection + */ + function Close() + { + $rez = $this->_close(); + $this->_connectionID = false; + return $rez; + } + + /** + * Begin a Transaction. Must be followed by CommitTrans() or RollbackTrans(). + * + * @return true if succeeded or false if database does not support transactions + */ + function BeginTrans() + { + if ($this->debug) ADOConnection::outp("BeginTrans: Transactions not supported for this driver"); + return false; + } + + /* set transaction mode */ + function SetTransactionMode( $transaction_mode ) + { + $transaction_mode = $this->MetaTransaction($transaction_mode, $this->dataProvider); + $this->_transmode = $transaction_mode; + } +/* +http://msdn2.microsoft.com/en-US/ms173763.aspx +http://dev.mysql.com/doc/refman/5.0/en/innodb-transaction-isolation.html +http://www.postgresql.org/docs/8.1/interactive/sql-set-transaction.html +http://www.stanford.edu/dept/itss/docs/oracle/10g/server.101/b10759/statements_10005.htm +*/ + function MetaTransaction($mode,$db) + { + $mode = strtoupper($mode); + $mode = str_replace('ISOLATION LEVEL ','',$mode); + + switch($mode) { + + case 'READ UNCOMMITTED': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL READ COMMITTED'; + default: + return 'ISOLATION LEVEL READ UNCOMMITTED'; + } + break; + + case 'READ COMMITTED': + return 'ISOLATION LEVEL READ COMMITTED'; + break; + + case 'REPEATABLE READ': + switch($db) { + case 'oci8': + case 'oracle': + return 'ISOLATION LEVEL SERIALIZABLE'; + default: + return 'ISOLATION LEVEL REPEATABLE READ'; + } + break; + + case 'SERIALIZABLE': + return 'ISOLATION LEVEL SERIALIZABLE'; + break; + + default: + return $mode; + } + } + + /** + * If database does not support transactions, always return true as data always commited + * + * @param $ok set to false to rollback transaction, true to commit + * + * @return true/false. + */ + function CommitTrans($ok=true) + { return true;} + + + /** + * If database does not support transactions, rollbacks always fail, so return false + * + * @return true/false. + */ + function RollbackTrans() + { return false;} + + + /** + * return the databases that the driver can connect to. + * Some databases will return an empty array. + * + * @return an array of database names. + */ + function MetaDatabases() + { + global $ADODB_FETCH_MODE; + + if ($this->metaDatabasesSQL) { + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $arr = $this->GetCol($this->metaDatabasesSQL); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + return $arr; + } + + return false; + } + + + /** + * @param ttype can either be 'VIEW' or 'TABLE' or false. + * If false, both views and tables are returned. + * "VIEW" returns only views + * "TABLE" returns only tables + * @param showSchema returns the schema/user with the table name, eg. USER.TABLE + * @param mask is the input mask - only supported by oci8 and postgresql + * + * @return array of tables for current database. + */ + function &MetaTables($ttype=false,$showSchema=false,$mask=false) + { + global $ADODB_FETCH_MODE; + + + $false = false; + if ($mask) { + return $false; + } + if ($this->metaTablesSQL) { + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + + $rs = $this->Execute($this->metaTablesSQL); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + + if ($rs === false) return $false; + $arr =& $rs->GetArray(); + $arr2 = array(); + + if ($hast = ($ttype && isset($arr[0][1]))) { + $showt = strncmp($ttype,'T',1); + } + + for ($i=0; $i < sizeof($arr); $i++) { + if ($hast) { + if ($showt == 0) { + if (strncmp($arr[$i][1],'T',1) == 0) $arr2[] = trim($arr[$i][0]); + } else { + if (strncmp($arr[$i][1],'V',1) == 0) $arr2[] = trim($arr[$i][0]); + } + } else + $arr2[] = trim($arr[$i][0]); + } + $rs->Close(); + return $arr2; + } + return $false; + } + + + function _findschema(&$table,&$schema) + { + if (!$schema && ($at = strpos($table,'.')) !== false) { + $schema = substr($table,0,$at); + $table = substr($table,$at+1); + } + } + + /** + * List columns in a database as an array of ADOFieldObjects. + * See top of file for definition of object. + * + * @param $table table name to query + * @param $normalize makes table name case-insensitive (required by some databases) + * @schema is optional database schema to use - not supported by all databases. + * + * @return array of ADOFieldObjects for current table. + */ + function &MetaColumns($table,$normalize=true) + { + global $ADODB_FETCH_MODE; + + $false = false; + + if (!empty($this->metaColumnsSQL)) { + + $schema = false; + $this->_findschema($table,$schema); + + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,($normalize)?strtoupper($table):$table)); + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if ($rs === false || $rs->EOF) return $false; + + $retarr = array(); + while (!$rs->EOF) { //print_r($rs->fields); + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $fld->type = $rs->fields[1]; + if (isset($rs->fields[3]) && $rs->fields[3]) { + if ($rs->fields[3]>0) $fld->max_length = $rs->fields[3]; + $fld->scale = $rs->fields[4]; + if ($fld->scale>0) $fld->max_length += 1; + } else + $fld->max_length = $rs->fields[2]; + + if ($ADODB_FETCH_MODE == ADODB_FETCH_NUM) $retarr[] = $fld; + else $retarr[strtoupper($fld->name)] = $fld; + $rs->MoveNext(); + } + $rs->Close(); + return $retarr; + } + return $false; + } + + /** + * List indexes on a table as an array. + * @param table table name to query + * @param primary true to only show primary keys. Not actually used for most databases + * + * @return array of indexes on current table. Each element represents an index, and is itself an associative array. + + Array ( + [name_of_index] => Array + ( + [unique] => true or false + [columns] => Array + ( + [0] => firstname + [1] => lastname + ) + ) + */ + function &MetaIndexes($table, $primary = false, $owner = false) + { + $false = false; + return $false; + } + + /** + * List columns names in a table as an array. + * @param table table name to query + * + * @return array of column names for current table. + */ + function &MetaColumnNames($table, $numIndexes=false,$useattnum=false /* only for postgres */) + { + $objarr =& $this->MetaColumns($table); + if (!is_array($objarr)) { + $false = false; + return $false; + } + $arr = array(); + if ($numIndexes) { + $i = 0; + if ($useattnum) { + foreach($objarr as $v) + $arr[$v->attnum] = $v->name; + + } else + foreach($objarr as $v) $arr[$i++] = $v->name; + } else + foreach($objarr as $v) $arr[strtoupper($v->name)] = $v->name; + + return $arr; + } + + /** + * Different SQL databases used different methods to combine strings together. + * This function provides a wrapper. + * + * param s variable number of string parameters + * + * Usage: $db->Concat($str1,$str2); + * + * @return concatenated string + */ + function Concat() + { + $arr = func_get_args(); + return implode($this->concat_operator, $arr); + } + + + /** + * Converts a date "d" to a string that the database can understand. + * + * @param d a date in Unix date time format. + * + * @return date string in database date format + */ + function DBDate($d) + { + if (empty($d) && $d !== 0) return 'null'; + + if (is_string($d) && !is_numeric($d)) { + if ($d === 'null' || strncmp($d,"'",1) === 0) return $d; + if ($this->isoDates) return "'$d'"; + $d = ADOConnection::UnixDate($d); + } + + return adodb_date($this->fmtDate,$d); + } + + function BindDate($d) + { + $d = $this->DBDate($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + function BindTimeStamp($d) + { + $d = $this->DBTimeStamp($d); + if (strncmp($d,"'",1)) return $d; + + return substr($d,1,strlen($d)-2); + } + + + /** + * Converts a timestamp "ts" to a string that the database can understand. + * + * @param ts a timestamp in Unix date time format. + * + * @return timestamp string in database timestamp format + */ + function DBTimeStamp($ts) + { + if (empty($ts) && $ts !== 0) return 'null'; + + # strlen(14) allows YYYYMMDDHHMMSS format + if (!is_string($ts) || (is_numeric($ts) && strlen($ts)<14)) + return adodb_date($this->fmtTimeStamp,$ts); + + if ($ts === 'null') return $ts; + if ($this->isoDates && strlen($ts) !== 14) return "'$ts'"; + + $ts = ADOConnection::UnixTimeStamp($ts); + return adodb_date($this->fmtTimeStamp,$ts); + } + + /** + * Also in ADORecordSet. + * @param $v is a date string in YYYY-MM-DD format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + function UnixDate($v) + { + if (is_object($v)) { + // odbtp support + //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) + return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year); + } + + if (is_numeric($v) && strlen($v) !== 8) return $v; + if (!preg_match( "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})|", + ($v), $rr)) return false; + + if ($rr[1] <= TIMESTAMP_FIRST_YEAR) return 0; + // h-m-s-MM-DD-YY + return @adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); + } + + + /** + * Also in ADORecordSet. + * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + function UnixTimeStamp($v) + { + if (is_object($v)) { + // odbtp support + //( [year] => 2004 [month] => 9 [day] => 4 [hour] => 12 [minute] => 44 [second] => 8 [fraction] => 0 ) + return adodb_mktime($v->hour,$v->minute,$v->second,$v->month,$v->day, $v->year); + } + + if (!preg_match( + "|^([0-9]{4})[-/\.]?([0-9]{1,2})[-/\.]?([0-9]{1,2})[ ,-]*(([0-9]{1,2}):?([0-9]{1,2}):?([0-9\.]{1,4}))?|", + ($v), $rr)) return false; + + if ($rr[1] <= TIMESTAMP_FIRST_YEAR && $rr[2]<= 1) return 0; + + // h-m-s-MM-DD-YY + if (!isset($rr[5])) return adodb_mktime(0,0,0,$rr[2],$rr[3],$rr[1]); + return @adodb_mktime($rr[5],$rr[6],$rr[7],$rr[2],$rr[3],$rr[1]); + } + + /** + * Also in ADORecordSet. + * + * Format database date based on user defined format. + * + * @param v is the character date in YYYY-MM-DD format, returned by database + * @param fmt is the format to apply to it, using date() + * + * @return a date formated as user desires + */ + + function UserDate($v,$fmt='Y-m-d',$gmt=false) + { + $tt = $this->UnixDate($v); + + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + else if ($tt == 0) return $this->emptyDate; + else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR + } + + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); + + } + + /** + * + * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format + * @param fmt is the format to apply to it, using date() + * + * @return a timestamp formated as user desires + */ + function UserTimeStamp($v,$fmt='Y-m-d H:i:s',$gmt=false) + { + if (!isset($v)) return $this->emptyTimeStamp; + # strlen(14) allows YYYYMMDDHHMMSS format + if (is_numeric($v) && strlen($v)<14) return ($gmt) ? adodb_gmdate($fmt,$v) : adodb_date($fmt,$v); + $tt = $this->UnixTimeStamp($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + if ($tt == 0) return $this->emptyTimeStamp; + return ($gmt) ? adodb_gmdate($fmt,$tt) : adodb_date($fmt,$tt); + } + + function escape($s,$magic_quotes=false) + { + return $this->addq($s,$magic_quotes); + } + + /** + * Quotes a string, without prefixing nor appending quotes. + */ + function addq($s,$magic_quotes=false) + { + if (!$magic_quotes) { + + if ($this->replaceQuote[0] == '\\'){ + // only since php 4.0.5 + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s)); + } + return str_replace("'",$this->replaceQuote,$s); + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything + return $s; + else {// change \' to '' for sybase/mssql + $s = str_replace('\\\\','\\',$s); + return str_replace("\\'",$this->replaceQuote,$s); + } + } + + /** + * Correctly quotes a string so that all strings are escaped. We prefix and append + * to the string single-quotes. + * An example is $db->qstr("Don't bother",magic_quotes_runtime()); + * + * @param s the string to quote + * @param [magic_quotes] if $s is GET/POST var, set to get_magic_quotes_gpc(). + * This undoes the stupidity of magic quotes for GPC. + * + * @return quoted string to be sent back to database + */ + function qstr($s,$magic_quotes=false) + { + if (!$magic_quotes) { + + if ($this->replaceQuote[0] == '\\'){ + // only since php 4.0.5 + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + //$s = str_replace("\0","\\\0", str_replace('\\','\\\\',$s)); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + + if ($this->replaceQuote == "\\'") // ' already quoted, no need to change anything + return "'$s'"; + else {// change \' to '' for sybase/mssql + $s = str_replace('\\\\','\\',$s); + return "'".str_replace("\\'",$this->replaceQuote,$s)."'"; + } + } + + + /** + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * and/or last one of the recordset. Added by Ivn Oliva to provide recordset pagination. + * + * See readme.htm#ex8 for an example of usage. + * + * @param sql + * @param nrows is the number of rows per page to get + * @param page is the page number to get (1-based) + * @param [inputarr] array of bind variables + * @param [secs2cache] is a private parameter only used by jlim + * @return the recordset ($rs->databaseType == 'array') + * + * NOTE: phpLens uses a different algorithm and does not use PageExecute(). + * + */ + function &PageExecute($sql, $nrows, $page, $inputarr=false, $secs2cache=0) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + if ($this->pageExecuteCountRows) $rs =& _adodb_pageexecute_all_rows($this, $sql, $nrows, $page, $inputarr, $secs2cache); + else $rs =& _adodb_pageexecute_no_last_page($this, $sql, $nrows, $page, $inputarr, $secs2cache); + return $rs; + } + + + /** + * Will select the supplied $page number from a recordset, given that it is paginated in pages of + * $nrows rows per page. It also saves two boolean values saying if the given page is the first + * and/or last one of the recordset. Added by Ivn Oliva to provide recordset pagination. + * + * @param secs2cache seconds to cache data, set to 0 to force query + * @param sql + * @param nrows is the number of rows per page to get + * @param page is the page number to get (1-based) + * @param [inputarr] array of bind variables + * @return the recordset ($rs->databaseType == 'array') + */ + function &CachePageExecute($secs2cache, $sql, $nrows, $page,$inputarr=false) + { + /*switch($this->dataProvider) { + case 'postgres': + case 'mysql': + break; + default: $secs2cache = 0; break; + }*/ + $rs =& $this->PageExecute($sql,$nrows,$page,$inputarr,$secs2cache); + return $rs; + } + +} // end class ADOConnection + + + + //============================================================================================== + // CLASS ADOFetchObj + //============================================================================================== + + /** + * Internal placeholder for record objects. Used by ADORecordSet->FetchObj(). + */ + class ADOFetchObj { + }; + + //============================================================================================== + // CLASS ADORecordSet_empty + //============================================================================================== + + /** + * Lightweight recordset when there are no records to be returned + */ + class ADORecordSet_empty + { + var $dataProvider = 'empty'; + var $databaseType = false; + var $EOF = true; + var $_numOfRows = 0; + var $fields = false; + var $connection = false; + function RowCount() {return 0;} + function RecordCount() {return 0;} + function PO_RecordCount(){return 0;} + function Close(){return true;} + function FetchRow() {return false;} + function FieldCount(){ return 0;} + function Init() {} + } + + //============================================================================================== + // DATE AND TIME FUNCTIONS + //============================================================================================== + if (!defined('ADODB_DATE_VERSION')) include(ADODB_DIR.'/adodb-time.inc.php'); + + //============================================================================================== + // CLASS ADORecordSet + //============================================================================================== + + if (PHP_VERSION < 5) include_once(ADODB_DIR.'/adodb-php4.inc.php'); + else include_once(ADODB_DIR.'/adodb-iterator.inc.php'); + /** + * RecordSet class that represents the dataset returned by the database. + * To keep memory overhead low, this class holds only the current row in memory. + * No prefetching of data is done, so the RecordCount() can return -1 ( which + * means recordcount not known). + */ + class ADORecordSet extends ADODB_BASE_RS { + /* + * public variables + */ + var $dataProvider = "native"; + var $fields = false; /// holds the current row data + var $blobSize = 100; /// any varchar/char field this size or greater is treated as a blob + /// in other words, we use a text area for editing. + var $canSeek = false; /// indicates that seek is supported + var $sql; /// sql text + var $EOF = false; /// Indicates that the current record position is after the last record in a Recordset object. + + var $emptyTimeStamp = ' '; /// what to display when $time==0 + var $emptyDate = ' '; /// what to display when $time==0 + var $debug = false; + var $timeCreated=0; /// datetime in Unix format rs created -- for cached recordsets + + var $bind = false; /// used by Fields() to hold array - should be private? + var $fetchMode; /// default fetch mode + var $connection = false; /// the parent connection + /* + * private variables + */ + var $_numOfRows = -1; /** number of rows, or -1 */ + var $_numOfFields = -1; /** number of fields in recordset */ + var $_queryID = -1; /** This variable keeps the result link identifier. */ + var $_currentRow = -1; /** This variable keeps the current row in the Recordset. */ + var $_closed = false; /** has recordset been closed */ + var $_inited = false; /** Init() should only be called once */ + var $_obj; /** Used by FetchObj */ + var $_names; /** Used by FetchObj */ + + var $_currentPage = -1; /** Added by Ivn Oliva to implement recordset pagination */ + var $_atFirstPage = false; /** Added by Ivn Oliva to implement recordset pagination */ + var $_atLastPage = false; /** Added by Ivn Oliva to implement recordset pagination */ + var $_lastPageNo = -1; + var $_maxRecordCount = 0; + var $datetime = false; + + /** + * Constructor + * + * @param queryID this is the queryID returned by ADOConnection->_query() + * + */ + function ADORecordSet($queryID) + { + $this->_queryID = $queryID; + } + + + + function Init() + { + if ($this->_inited) return; + $this->_inited = true; + if ($this->_queryID) @$this->_initrs(); + else { + $this->_numOfRows = 0; + $this->_numOfFields = 0; + } + if ($this->_numOfRows != 0 && $this->_numOfFields && $this->_currentRow == -1) { + + $this->_currentRow = 0; + if ($this->EOF = ($this->_fetch() === false)) { + $this->_numOfRows = 0; // _numOfRows could be -1 + } + } else { + $this->EOF = true; + } + } + + + /** + * Generate a SELECT tag string from a recordset, and return the string. + * If the recordset has 2 cols, we treat the 1st col as the containing + * the text to display to the user, and 2nd col as the return value. Default + * strings are compared with the FIRST column. + * + * @param name name of SELECT tag + * @param [defstr] the value to hilite. Use an array for multiple hilites for listbox. + * @param [blank1stItem] true to leave the 1st item in list empty + * @param [multiple] true for listbox, false for popup + * @param [size] #rows to show for listbox. not used by popup + * @param [selectAttr] additional attributes to defined for SELECT tag. + * useful for holding javascript onChange='...' handlers. + & @param [compareFields0] when we have 2 cols in recordset, we compare the defstr with + * column 0 (1st col) if this is true. This is not documented. + * + * @return HTML + * + * changes by glen.davies@cce.ac.nz to support multiple hilited items + */ + function GetMenu($name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='',$compareFields0=true) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getmenu($this, $name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,$compareFields0); + } + + + + /** + * Generate a SELECT tag string from a recordset, and return the string. + * If the recordset has 2 cols, we treat the 1st col as the containing + * the text to display to the user, and 2nd col as the return value. Default + * strings are compared with the SECOND column. + * + */ + function GetMenu2($name,$defstr='',$blank1stItem=true,$multiple=false,$size=0, $selectAttr='') + { + return $this->GetMenu($name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,false); + } + + /* + Grouped Menu + */ + function GetMenu3($name,$defstr='',$blank1stItem=true,$multiple=false, + $size=0, $selectAttr='') + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_getmenu_gp($this, $name,$defstr,$blank1stItem,$multiple, + $size, $selectAttr,false); + } + + /** + * return recordset as a 2-dimensional array. + * + * @param [nRows] is the number of rows to return. -1 means every row. + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function &GetArray($nRows = -1) + { + global $ADODB_EXTENSION; if ($ADODB_EXTENSION) { + $results = adodb_getall($this,$nRows); + return $results; + } + $results = array(); + $cnt = 0; + while (!$this->EOF && $nRows != $cnt) { + $results[] = $this->fields; + $this->MoveNext(); + $cnt++; + } + return $results; + } + + function &GetAll($nRows = -1) + { + $arr =& $this->GetArray($nRows); + return $arr; + } + + /* + * Some databases allow multiple recordsets to be returned. This function + * will return true if there is a next recordset, or false if no more. + */ + function NextRecordSet() + { + return false; + } + + /** + * return recordset as a 2-dimensional array. + * Helper function for ADOConnection->SelectLimit() + * + * @param offset is the row to start calculations from (1-based) + * @param [nrows] is the number of rows to return + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function &GetArrayLimit($nrows,$offset=-1) + { + if ($offset <= 0) { + $arr =& $this->GetArray($nrows); + return $arr; + } + + $this->Move($offset); + + $results = array(); + $cnt = 0; + while (!$this->EOF && $nrows != $cnt) { + $results[$cnt++] = $this->fields; + $this->MoveNext(); + } + + return $results; + } + + + /** + * Synonym for GetArray() for compatibility with ADO. + * + * @param [nRows] is the number of rows to return. -1 means every row. + * + * @return an array indexed by the rows (0-based) from the recordset + */ + function &GetRows($nRows = -1) + { + $arr =& $this->GetArray($nRows); + return $arr; + } + + /** + * return whole recordset as a 2-dimensional associative array if there are more than 2 columns. + * The first column is treated as the key and is not included in the array. + * If there is only 2 columns, it will return a 1 dimensional array of key-value pairs unless + * $force_array == true. + * + * @param [force_array] has only meaning if we have 2 data columns. If false, a 1 dimensional + * array is returned, otherwise a 2 dimensional array is returned. If this sounds confusing, + * read the source. + * + * @param [first2cols] means if there are more than 2 cols, ignore the remaining cols and + * instead of returning array[col0] => array(remaining cols), return array[col0] => col1 + * + * @return an associative array indexed by the first column of the array, + * or false if the data has less than 2 cols. + */ + function &GetAssoc($force_array = false, $first2cols = false) + { + global $ADODB_EXTENSION; + + $cols = $this->_numOfFields; + if ($cols < 2) { + $false = false; + return $false; + } + $numIndex = isset($this->fields[0]); + $results = array(); + + if (!$first2cols && ($cols > 2 || $force_array)) { + if ($ADODB_EXTENSION) { + if ($numIndex) { + while (!$this->EOF) { + $results[trim($this->fields[0])] = array_slice($this->fields, 1); + adodb_movenext($this); + } + } else { + while (!$this->EOF) { + // Fix for array_slice re-numbering numeric associative keys + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; + adodb_movenext($this); + } + } + } else { + if ($numIndex) { + while (!$this->EOF) { + $results[trim($this->fields[0])] = array_slice($this->fields, 1); + $this->MoveNext(); + } + } else { + while (!$this->EOF) { + // Fix for array_slice re-numbering numeric associative keys + $keys = array_slice(array_keys($this->fields), 1); + $sliced_array = array(); + + foreach($keys as $key) { + $sliced_array[$key] = $this->fields[$key]; + } + + $results[trim(reset($this->fields))] = $sliced_array; + $this->MoveNext(); + } + } + } + } else { + if ($ADODB_EXTENSION) { + // return scalar values + if ($numIndex) { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $results[trim(($this->fields[0]))] = $this->fields[1]; + adodb_movenext($this); + } + } else { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $v1 = trim(reset($this->fields)); + $v2 = ''.next($this->fields); + $results[$v1] = $v2; + adodb_movenext($this); + } + } + } else { + if ($numIndex) { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $results[trim(($this->fields[0]))] = $this->fields[1]; + $this->MoveNext(); + } + } else { + while (!$this->EOF) { + // some bug in mssql PHP 4.02 -- doesn't handle references properly so we FORCE creating a new string + $v1 = trim(reset($this->fields)); + $v2 = ''.next($this->fields); + $results[$v1] = $v2; + $this->MoveNext(); + } + } + } + } + + $ref =& $results; # workaround accelerator incompat with PHP 4.4 :( + return $ref; + } + + + /** + * + * @param v is the character timestamp in YYYY-MM-DD hh:mm:ss format + * @param fmt is the format to apply to it, using date() + * + * @return a timestamp formated as user desires + */ + function UserTimeStamp($v,$fmt='Y-m-d H:i:s') + { + if (is_numeric($v) && strlen($v)<14) return adodb_date($fmt,$v); + $tt = $this->UnixTimeStamp($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + if ($tt === 0) return $this->emptyTimeStamp; + return adodb_date($fmt,$tt); + } + + + /** + * @param v is the character date in YYYY-MM-DD format, returned by database + * @param fmt is the format to apply to it, using date() + * + * @return a date formated as user desires + */ + function UserDate($v,$fmt='Y-m-d') + { + $tt = $this->UnixDate($v); + // $tt == -1 if pre TIMESTAMP_FIRST_YEAR + if (($tt === false || $tt == -1) && $v != false) return $v; + else if ($tt == 0) return $this->emptyDate; + else if ($tt == -1) { // pre-TIMESTAMP_FIRST_YEAR + } + return adodb_date($fmt,$tt); + } + + + /** + * @param $v is a date string in YYYY-MM-DD format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + function UnixDate($v) + { + return ADOConnection::UnixDate($v); + } + + + /** + * @param $v is a timestamp string in YYYY-MM-DD HH-NN-SS format + * + * @return date in unix timestamp format, or 0 if before TIMESTAMP_FIRST_YEAR, or false if invalid date format + */ + function UnixTimeStamp($v) + { + return ADOConnection::UnixTimeStamp($v); + } + + + /** + * PEAR DB Compat - do not use internally + */ + function Free() + { + return $this->Close(); + } + + + /** + * PEAR DB compat, number of rows + */ + function NumRows() + { + return $this->_numOfRows; + } + + + /** + * PEAR DB compat, number of cols + */ + function NumCols() + { + return $this->_numOfFields; + } + + /** + * Fetch a row, returning false if no more rows. + * This is PEAR DB compat mode. + * + * @return false or array containing the current record + */ + function &FetchRow() + { + if ($this->EOF) { + $false = false; + return $false; + } + $arr = $this->fields; + $this->_currentRow++; + if (!$this->_fetch()) $this->EOF = true; + return $arr; + } + + + /** + * Fetch a row, returning PEAR_Error if no more rows. + * This is PEAR DB compat mode. + * + * @return DB_OK or error object + */ + function FetchInto(&$arr) + { + if ($this->EOF) return (defined('PEAR_ERROR_RETURN')) ? new PEAR_Error('EOF',-1): false; + $arr = $this->fields; + $this->MoveNext(); + return 1; // DB_OK + } + + + /** + * Move to the first row in the recordset. Many databases do NOT support this. + * + * @return true or false + */ + function MoveFirst() + { + if ($this->_currentRow == 0) return true; + return $this->Move(0); + } + + + /** + * Move to the last row in the recordset. + * + * @return true or false + */ + function MoveLast() + { + if ($this->_numOfRows >= 0) return $this->Move($this->_numOfRows-1); + if ($this->EOF) return false; + while (!$this->EOF) { + $f = $this->fields; + $this->MoveNext(); + } + $this->fields = $f; + $this->EOF = false; + return true; + } + + + /** + * Move to next record in the recordset. + * + * @return true if there still rows available, or false if there are no more rows (EOF). + */ + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + if ($this->_fetch()) return true; + } + $this->EOF = true; + /* -- tested error handling when scrolling cursor -- seems useless. + $conn = $this->connection; + if ($conn && $conn->raiseErrorFn && ($errno = $conn->ErrorNo())) { + $fn = $conn->raiseErrorFn; + $fn($conn->databaseType,'MOVENEXT',$errno,$conn->ErrorMsg().' ('.$this->sql.')',$conn->host,$conn->database); + } + */ + return false; + } + + + /** + * Random access to a specific row in the recordset. Some databases do not support + * access to previous rows in the databases (no scrolling backwards). + * + * @param rowNumber is the row to move to (0-based) + * + * @return true if there still rows available, or false if there are no more rows (EOF). + */ + function Move($rowNumber = 0) + { + $this->EOF = false; + if ($rowNumber == $this->_currentRow) return true; + if ($rowNumber >= $this->_numOfRows) + if ($this->_numOfRows != -1) $rowNumber = $this->_numOfRows-2; + + if ($this->canSeek) { + + if ($this->_seek($rowNumber)) { + $this->_currentRow = $rowNumber; + if ($this->_fetch()) { + return true; + } + } else { + $this->EOF = true; + return false; + } + } else { + if ($rowNumber < $this->_currentRow) return false; + global $ADODB_EXTENSION; + if ($ADODB_EXTENSION) { + while (!$this->EOF && $this->_currentRow < $rowNumber) { + adodb_movenext($this); + } + } else { + + while (! $this->EOF && $this->_currentRow < $rowNumber) { + $this->_currentRow++; + + if (!$this->_fetch()) $this->EOF = true; + } + } + return !($this->EOF); + } + + $this->fields = false; + $this->EOF = true; + return false; + } + + + /** + * Get the value of a field in the current row by column name. + * Will not work if ADODB_FETCH_MODE is set to ADODB_FETCH_NUM. + * + * @param colname is the field to access + * + * @return the value of $colname column + */ + function Fields($colname) + { + return $this->fields[$colname]; + } + + function GetAssocKeys($upper=true) + { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + if ($upper === 2) $this->bind[$o->name] = $i; + else $this->bind[($upper) ? strtoupper($o->name) : strtolower($o->name)] = $i; + } + } + + /** + * Use associative array to get fields array for databases that do not support + * associative arrays. Submitted by Paolo S. Asioli paolo.asioli#libero.it + * + * If you don't want uppercase cols, set $ADODB_FETCH_MODE = ADODB_FETCH_ASSOC + * before you execute your SQL statement, and access $rs->fields['col'] directly. + * + * $upper 0 = lowercase, 1 = uppercase, 2 = whatever is returned by FetchField + */ + function &GetRowAssoc($upper=1) + { + $record = array(); + // if (!$this->fields) return $record; + + if (!$this->bind) { + $this->GetAssocKeys($upper); + } + + foreach($this->bind as $k => $v) { + $record[$k] = $this->fields[$v]; + } + + return $record; + } + + + /** + * Clean up recordset + * + * @return true or false + */ + function Close() + { + // free connection object - this seems to globally free the object + // and not merely the reference, so don't do this... + // $this->connection = false; + if (!$this->_closed) { + $this->_closed = true; + return $this->_close(); + } else + return true; + } + + /** + * synonyms RecordCount and RowCount + * + * @return the number of rows or -1 if this is not supported + */ + function RecordCount() {return $this->_numOfRows;} + + + /* + * If we are using PageExecute(), this will return the maximum possible rows + * that can be returned when paging a recordset. + */ + function MaxRecordCount() + { + return ($this->_maxRecordCount) ? $this->_maxRecordCount : $this->RecordCount(); + } + + /** + * synonyms RecordCount and RowCount + * + * @return the number of rows or -1 if this is not supported + */ + function RowCount() {return $this->_numOfRows;} + + + /** + * Portable RecordCount. Pablo Roca + * + * @return the number of records from a previous SELECT. All databases support this. + * + * But aware possible problems in multiuser environments. For better speed the table + * must be indexed by the condition. Heavy test this before deploying. + */ + function PO_RecordCount($table="", $condition="") { + + $lnumrows = $this->_numOfRows; + // the database doesn't support native recordcount, so we do a workaround + if ($lnumrows == -1 && $this->connection) { + IF ($table) { + if ($condition) $condition = " WHERE " . $condition; + $resultrows = &$this->connection->Execute("SELECT COUNT(*) FROM $table $condition"); + if ($resultrows) $lnumrows = reset($resultrows->fields); + } + } + return $lnumrows; + } + + + /** + * @return the current row in the recordset. If at EOF, will return the last row. 0-based. + */ + function CurrentRow() {return $this->_currentRow;} + + /** + * synonym for CurrentRow -- for ADO compat + * + * @return the current row in the recordset. If at EOF, will return the last row. 0-based. + */ + function AbsolutePosition() {return $this->_currentRow;} + + /** + * @return the number of columns in the recordset. Some databases will set this to 0 + * if no records are returned, others will return the number of columns in the query. + */ + function FieldCount() {return $this->_numOfFields;} + + + /** + * Get the ADOFieldObject of a specific column. + * + * @param fieldoffset is the column position to access(0-based). + * + * @return the ADOFieldObject for that column, or false. + */ + function &FetchField($fieldoffset = -1) + { + // must be defined by child class + + $false = false; + return $false; + } + + /** + * Get the ADOFieldObjects of all columns in an array. + * + */ + function& FieldTypesArray() + { + $arr = array(); + for ($i=0, $max=$this->_numOfFields; $i < $max; $i++) + $arr[] = $this->FetchField($i); + return $arr; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default case is lowercase field names. + * + * @return the object with the properties set to the fields of the current row + */ + function &FetchObj() + { + $o =& $this->FetchObject(false); + return $o; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default case is uppercase. + * + * @param $isupper to set the object property names to uppercase + * + * @return the object with the properties set to the fields of the current row + */ + function &FetchObject($isupper=true) + { + if (empty($this->_obj)) { + $this->_obj = new ADOFetchObj(); + $this->_names = array(); + for ($i=0; $i <$this->_numOfFields; $i++) { + $f = $this->FetchField($i); + $this->_names[] = $f->name; + } + } + $i = 0; + if (PHP_VERSION >= 5) $o = clone($this->_obj); + else $o = $this->_obj; + + for ($i=0; $i <$this->_numOfFields; $i++) { + $name = $this->_names[$i]; + if ($isupper) $n = strtoupper($name); + else $n = $name; + + $o->$n = $this->Fields($name); + } + return $o; + } + + /** + * Return the fields array of the current row as an object for convenience. + * The default is lower-case field names. + * + * @return the object with the properties set to the fields of the current row, + * or false if EOF + * + * Fixed bug reported by tim@orotech.net + */ + function &FetchNextObj() + { + $o =& $this->FetchNextObject(false); + return $o; + } + + + /** + * Return the fields array of the current row as an object for convenience. + * The default is upper case field names. + * + * @param $isupper to set the object property names to uppercase + * + * @return the object with the properties set to the fields of the current row, + * or false if EOF + * + * Fixed bug reported by tim@orotech.net + */ + function &FetchNextObject($isupper=true) + { + $o = false; + if ($this->_numOfRows != 0 && !$this->EOF) { + $o = $this->FetchObject($isupper); + $this->_currentRow++; + if ($this->_fetch()) return $o; + } + $this->EOF = true; + return $o; + } + + /** + * Get the metatype of the column. This is used for formatting. This is because + * many databases use different names for the same type, so we transform the original + * type to our standardised version which uses 1 character codes: + * + * @param t is the type passed in. Normally is ADOFieldObject->type. + * @param len is the maximum length of that field. This is because we treat character + * fields bigger than a certain size as a 'B' (blob). + * @param fieldobj is the field object returned by the database driver. Can hold + * additional info (eg. primary_key for mysql). + * + * @return the general type of the data: + * C for character < 250 chars + * X for teXt (>= 250 chars) + * B for Binary + * N for numeric or floating point + * D for date + * T for timestamp + * L for logical/Boolean + * I for integer + * R for autoincrement counter/integer + * + * + */ + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + // changed in 2.32 to hashing instead of switch stmt for speed... + static $typeMap = array( + 'VARCHAR' => 'C', + 'VARCHAR2' => 'C', + 'CHAR' => 'C', + 'C' => 'C', + 'STRING' => 'C', + 'NCHAR' => 'C', + 'NVARCHAR' => 'C', + 'VARYING' => 'C', + 'BPCHAR' => 'C', + 'CHARACTER' => 'C', + 'INTERVAL' => 'C', # Postgres + 'MACADDR' => 'C', # postgres + ## + 'LONGCHAR' => 'X', + 'TEXT' => 'X', + 'NTEXT' => 'X', + 'M' => 'X', + 'X' => 'X', + 'CLOB' => 'X', + 'NCLOB' => 'X', + 'LVARCHAR' => 'X', + ## + 'BLOB' => 'B', + 'IMAGE' => 'B', + 'BINARY' => 'B', + 'VARBINARY' => 'B', + 'LONGBINARY' => 'B', + 'B' => 'B', + ## + 'YEAR' => 'D', // mysql + 'DATE' => 'D', + 'D' => 'D', + ## + 'UNIQUEIDENTIFIER' => 'C', # MS SQL Server + ## + 'TIME' => 'T', + 'TIMESTAMP' => 'T', + 'DATETIME' => 'T', + 'TIMESTAMPTZ' => 'T', + 'T' => 'T', + 'TIMESTAMP WITHOUT TIME ZONE' => 'T', // postgresql + ## + 'BOOL' => 'L', + 'BOOLEAN' => 'L', + 'BIT' => 'L', + 'L' => 'L', + ## + 'COUNTER' => 'R', + 'R' => 'R', + 'SERIAL' => 'R', // ifx + 'INT IDENTITY' => 'R', + ## + 'INT' => 'I', + 'INT2' => 'I', + 'INT4' => 'I', + 'INT8' => 'I', + 'INTEGER' => 'I', + 'INTEGER UNSIGNED' => 'I', + 'SHORT' => 'I', + 'TINYINT' => 'I', + 'SMALLINT' => 'I', + 'I' => 'I', + ## + 'LONG' => 'N', // interbase is numeric, oci8 is blob + 'BIGINT' => 'N', // this is bigger than PHP 32-bit integers + 'DECIMAL' => 'N', + 'DEC' => 'N', + 'REAL' => 'N', + 'DOUBLE' => 'N', + 'DOUBLE PRECISION' => 'N', + 'SMALLFLOAT' => 'N', + 'FLOAT' => 'N', + 'NUMBER' => 'N', + 'NUM' => 'N', + 'NUMERIC' => 'N', + 'MONEY' => 'N', + + ## informix 9.2 + 'SQLINT' => 'I', + 'SQLSERIAL' => 'I', + 'SQLSMINT' => 'I', + 'SQLSMFLOAT' => 'N', + 'SQLFLOAT' => 'N', + 'SQLMONEY' => 'N', + 'SQLDECIMAL' => 'N', + 'SQLDATE' => 'D', + 'SQLVCHAR' => 'C', + 'SQLCHAR' => 'C', + 'SQLDTIME' => 'T', + 'SQLINTERVAL' => 'N', + 'SQLBYTES' => 'B', + 'SQLTEXT' => 'X', + ## informix 10 + "SQLINT8" => 'I8', + "SQLSERIAL8" => 'I8', + "SQLNCHAR" => 'C', + "SQLNVCHAR" => 'C', + "SQLLVARCHAR" => 'X', + "SQLBOOL" => 'L' + ); + + $tmap = false; + $t = strtoupper($t); + $tmap = (isset($typeMap[$t])) ? $typeMap[$t] : 'N'; + switch ($tmap) { + case 'C': + + // is the char field is too long, return as text field... + if ($this->blobSize >= 0) { + if ($len > $this->blobSize) return 'X'; + } else if ($len > 250) { + return 'X'; + } + return 'C'; + + case 'I': + if (!empty($fieldobj->primary_key)) return 'R'; + return 'I'; + + case false: + return 'N'; + + case 'B': + if (isset($fieldobj->binary)) + return ($fieldobj->binary) ? 'B' : 'X'; + return 'B'; + + case 'D': + if (!empty($this->connection) && !empty($this->connection->datetime)) return 'T'; + return 'D'; + + default: + if ($t == 'LONG' && $this->dataProvider == 'oci8') return 'B'; + return $tmap; + } + } + + + function _close() {} + + /** + * set/returns the current recordset page when paginating + */ + function AbsolutePage($page=-1) + { + if ($page != -1) $this->_currentPage = $page; + return $this->_currentPage; + } + + /** + * set/returns the status of the atFirstPage flag when paginating + */ + function AtFirstPage($status=false) + { + if ($status != false) $this->_atFirstPage = $status; + return $this->_atFirstPage; + } + + function LastPageNo($page = false) + { + if ($page != false) $this->_lastPageNo = $page; + return $this->_lastPageNo; + } + + /** + * set/returns the status of the atLastPage flag when paginating + */ + function AtLastPage($status=false) + { + if ($status != false) $this->_atLastPage = $status; + return $this->_atLastPage; + } + +} // end class ADORecordSet + + //============================================================================================== + // CLASS ADORecordSet_array + //============================================================================================== + + /** + * This class encapsulates the concept of a recordset created in memory + * as an array. This is useful for the creation of cached recordsets. + * + * Note that the constructor is different from the standard ADORecordSet + */ + + class ADORecordSet_array extends ADORecordSet + { + var $databaseType = 'array'; + + var $_array; // holds the 2-dimensional data array + var $_types; // the array of types of each column (C B I L M) + var $_colnames; // names of each column in array + var $_skiprow1; // skip 1st row because it holds column names + var $_fieldobjects; // holds array of field objects + var $canSeek = true; + var $affectedrows = false; + var $insertid = false; + var $sql = ''; + var $compat = false; + /** + * Constructor + * + */ + function ADORecordSet_array($fakeid=1) + { + global $ADODB_FETCH_MODE,$ADODB_COMPAT_FETCH; + + // fetch() on EOF does not delete $this->fields + $this->compat = !empty($ADODB_COMPAT_FETCH); + $this->ADORecordSet($fakeid); // fake queryID + $this->fetchMode = $ADODB_FETCH_MODE; + } + + function _transpose($addfieldnames=true) + { + global $ADODB_INCLUDED_LIB; + + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + $hdr = true; + + $fobjs = $addfieldnames ? $this->_fieldobjects : false; + adodb_transpose($this->_array, $newarr, $hdr, $fobjs); + //adodb_pr($newarr); + + $this->_skiprow1 = false; + $this->_array =& $newarr; + $this->_colnames = $hdr; + + adodb_probetypes($newarr,$this->_types); + + $this->_fieldobjects = array(); + + foreach($hdr as $k => $name) { + $f = new ADOFieldObject(); + $f->name = $name; + $f->type = $this->_types[$k]; + $f->max_length = -1; + $this->_fieldobjects[] = $f; + } + $this->fields = reset($this->_array); + + $this->_initrs(); + + } + + /** + * Setup the array. + * + * @param array is a 2-dimensional array holding the data. + * The first row should hold the column names + * unless paramter $colnames is used. + * @param typearr holds an array of types. These are the same types + * used in MetaTypes (C,B,L,I,N). + * @param [colnames] array of column names. If set, then the first row of + * $array should not hold the column names. + */ + function InitArray($array,$typearr,$colnames=false) + { + $this->_array = $array; + $this->_types = $typearr; + if ($colnames) { + $this->_skiprow1 = false; + $this->_colnames = $colnames; + } else { + $this->_skiprow1 = true; + $this->_colnames = $array[0]; + } + $this->Init(); + } + /** + * Setup the Array and datatype file objects + * + * @param array is a 2-dimensional array holding the data. + * The first row should hold the column names + * unless paramter $colnames is used. + * @param fieldarr holds an array of ADOFieldObject's. + */ + function InitArrayFields(&$array,&$fieldarr) + { + $this->_array =& $array; + $this->_skiprow1= false; + if ($fieldarr) { + $this->_fieldobjects =& $fieldarr; + } + $this->Init(); + } + + function &GetArray($nRows=-1) + { + if ($nRows == -1 && $this->_currentRow <= 0 && !$this->_skiprow1) { + return $this->_array; + } else { + $arr =& ADORecordSet::GetArray($nRows); + return $arr; + } + } + + function _initrs() + { + $this->_numOfRows = sizeof($this->_array); + if ($this->_skiprow1) $this->_numOfRows -= 1; + + $this->_numOfFields =(isset($this->_fieldobjects)) ? + sizeof($this->_fieldobjects):sizeof($this->_types); + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + $mode = isset($this->adodbFetchMode) ? $this->adodbFetchMode : $this->fetchMode; + + if ($mode & ADODB_FETCH_ASSOC) { + if (!isset($this->fields[$colname])) $colname = strtolower($colname); + return $this->fields[$colname]; + } + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function &FetchField($fieldOffset = -1) + { + if (isset($this->_fieldobjects)) { + return $this->_fieldobjects[$fieldOffset]; + } + $o = new ADOFieldObject(); + $o->name = $this->_colnames[$fieldOffset]; + $o->type = $this->_types[$fieldOffset]; + $o->max_length = -1; // length not known + + return $o; + } + + function _seek($row) + { + if (sizeof($this->_array) && 0 <= $row && $row < $this->_numOfRows) { + $this->_currentRow = $row; + if ($this->_skiprow1) $row += 1; + $this->fields = $this->_array[$row]; + return true; + } + return false; + } + + function MoveNext() + { + if (!$this->EOF) { + $this->_currentRow++; + + $pos = $this->_currentRow; + + if ($this->_numOfRows <= $pos) { + if (!$this->compat) $this->fields = false; + } else { + if ($this->_skiprow1) $pos += 1; + $this->fields = $this->_array[$pos]; + return true; + } + $this->EOF = true; + } + + return false; + } + + function _fetch() + { + $pos = $this->_currentRow; + + if ($this->_numOfRows <= $pos) { + if (!$this->compat) $this->fields = false; + return false; + } + if ($this->_skiprow1) $pos += 1; + $this->fields = $this->_array[$pos]; + return true; + } + + function _close() + { + return true; + } + + } // ADORecordSet_array + + //============================================================================================== + // HELPER FUNCTIONS + //============================================================================================== + + /** + * Synonym for ADOLoadCode. Private function. Do not use. + * + * @deprecated + */ + function ADOLoadDB($dbType) + { + return ADOLoadCode($dbType); + } + + /** + * Load the code for a specific database driver. Private function. Do not use. + */ + function ADOLoadCode($dbType) + { + global $ADODB_LASTDB; + + if (!$dbType) return false; + $db = strtolower($dbType); + switch ($db) { + case 'ado': + if (PHP_VERSION >= 5) $db = 'ado5'; + $class = 'ado'; + break; + case 'ifx': + case 'maxsql': $class = $db = 'mysqlt'; break; + case 'postgres': + case 'postgres8': + case 'pgsql': $class = $db = 'postgres7'; break; + default: + $class = $db; break; + } + + $file = ADODB_DIR."/drivers/adodb-".$db.".inc.php"; + @include_once($file); + $ADODB_LASTDB = $class; + if (class_exists("ADODB_" . $class)) return $class; + + //ADOConnection::outp(adodb_pr(get_declared_classes(),true)); + if (!file_exists($file)) ADOConnection::outp("Missing file: $file"); + else ADOConnection::outp("Syntax error in file: $file"); + return false; + } + + /** + * synonym for ADONewConnection for people like me who cannot remember the correct name + */ + function &NewADOConnection($db='') + { + $tmp =& ADONewConnection($db); + return $tmp; + } + + /** + * Instantiate a new Connection class for a specific database driver. + * + * @param [db] is the database Connection object to create. If undefined, + * use the last database driver that was loaded by ADOLoadCode(). + * + * @return the freshly created instance of the Connection class. + */ + function &ADONewConnection($db='') + { + GLOBAL $ADODB_NEWCONNECTION, $ADODB_LASTDB; + + if (!defined('ADODB_ASSOC_CASE')) define('ADODB_ASSOC_CASE',2); + $errorfn = (defined('ADODB_ERROR_HANDLER')) ? ADODB_ERROR_HANDLER : false; + $false = false; + if ($at = strpos($db,'://')) { + $origdsn = $db; + if (PHP_VERSION < 5) $dsna = @parse_url($db); + else { + $fakedsn = 'fake'.substr($db,$at); + $dsna = @parse_url($fakedsn); + $dsna['scheme'] = substr($db,0,$at); + + if (strncmp($db,'pdo',3) == 0) { + $sch = explode('_',$dsna['scheme']); + if (sizeof($sch)>1) { + $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : ''; + $dsna['host'] = rawurlencode($sch[1].':host='.rawurldecode($dsna['host'])); + $dsna['scheme'] = 'pdo'; + } + } + } + + if (!$dsna) { + // special handling of oracle, which might not have host + $db = str_replace('@/','@adodb-fakehost/',$db); + $dsna = parse_url($db); + if (!$dsna) return $false; + $dsna['host'] = ''; + } + $db = @$dsna['scheme']; + if (!$db) return $false; + $dsna['host'] = isset($dsna['host']) ? rawurldecode($dsna['host']) : ''; + $dsna['user'] = isset($dsna['user']) ? rawurldecode($dsna['user']) : ''; + $dsna['pass'] = isset($dsna['pass']) ? rawurldecode($dsna['pass']) : ''; + $dsna['path'] = isset($dsna['path']) ? rawurldecode(substr($dsna['path'],1)) : ''; # strip off initial / + + if (isset($dsna['query'])) { + $opt1 = explode('&',$dsna['query']); + foreach($opt1 as $k => $v) { + $arr = explode('=',$v); + $opt[$arr[0]] = isset($arr[1]) ? rawurldecode($arr[1]) : 1; + } + } else $opt = array(); + } + /* + * phptype: Database backend used in PHP (mysql, odbc etc.) + * dbsyntax: Database used with regards to SQL syntax etc. + * protocol: Communication protocol to use (tcp, unix etc.) + * hostspec: Host specification (hostname[:port]) + * database: Database to use on the DBMS server + * username: User name for login + * password: Password for login + */ + if (!empty($ADODB_NEWCONNECTION)) { + $obj = $ADODB_NEWCONNECTION($db); + + } else { + + if (!isset($ADODB_LASTDB)) $ADODB_LASTDB = ''; + if (empty($db)) $db = $ADODB_LASTDB; + + if ($db != $ADODB_LASTDB) $db = ADOLoadCode($db); + + if (!$db) { + if (isset($origdsn)) $db = $origdsn; + if ($errorfn) { + // raise an error + $ignore = false; + $errorfn('ADONewConnection', 'ADONewConnection', -998, + "could not load the database driver for '$db'", + $db,false,$ignore); + } else + ADOConnection::outp( "

    ADONewConnection: Unable to load database driver '$db'

    ",false); + + return $false; + } + + $cls = 'ADODB_'.$db; + if (!class_exists($cls)) { + adodb_backtrace(); + return $false; + } + + $obj = new $cls(); + } + + # constructor should not fail + if ($obj) { + if ($errorfn) $obj->raiseErrorFn = $errorfn; + if (isset($dsna)) { + if (isset($dsna['port'])) $obj->port = $dsna['port']; + foreach($opt as $k => $v) { + switch(strtolower($k)) { + case 'new': + $nconnect = true; $persist = true; break; + case 'persist': + case 'persistent': $persist = $v; break; + case 'debug': $obj->debug = (integer) $v; break; + #ibase + case 'role': $obj->role = $v; break; + case 'dialect': $obj->dialect = (integer) $v; break; + case 'charset': $obj->charset = $v; $obj->charSet=$v; break; + case 'buffers': $obj->buffers = $v; break; + case 'fetchmode': $obj->SetFetchMode($v); break; + #ado + case 'charpage': $obj->charPage = $v; break; + #mysql, mysqli + case 'clientflags': $obj->clientFlags = $v; break; + #mysql, mysqli, postgres + case 'port': $obj->port = $v; break; + #mysqli + case 'socket': $obj->socket = $v; break; + #oci8 + case 'nls_date_format': $obj->NLS_DATE_FORMAT = $v; break; + } + } + if (empty($persist)) + $ok = $obj->Connect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + else if (empty($nconnect)) + $ok = $obj->PConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + else + $ok = $obj->NConnect($dsna['host'], $dsna['user'], $dsna['pass'], $dsna['path']); + + if (!$ok) return $false; + } + } + return $obj; + } + + + + // $perf == true means called by NewPerfMonitor(), otherwise for data dictionary + function _adodb_getdriver($provider,$drivername,$perf=false) + { + switch ($provider) { + case 'odbtp': if (strncmp('odbtp_',$drivername,6)==0) return substr($drivername,6); + case 'odbc' : if (strncmp('odbc_',$drivername,5)==0) return substr($drivername,5); + case 'ado' : if (strncmp('ado_',$drivername,4)==0) return substr($drivername,4); + case 'native': break; + default: + return $provider; + } + + switch($drivername) { + case 'mysqlt': + case 'mysqli': + $drivername='mysql'; + break; + case 'postgres7': + case 'postgres8': + $drivername = 'postgres'; + break; + case 'firebird15': $drivername = 'firebird'; break; + case 'oracle': $drivername = 'oci8'; break; + case 'access': if ($perf) $drivername = ''; break; + case 'db2' : break; + case 'sapdb' : break; + default: + $drivername = 'generic'; + break; + } + return $drivername; + } + + function &NewPerfMonitor(&$conn) + { + $false = false; + $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType,true); + if (!$drivername || $drivername == 'generic') return $false; + include_once(ADODB_DIR.'/adodb-perf.inc.php'); + @include_once(ADODB_DIR."/perf/perf-$drivername.inc.php"); + $class = "Perf_$drivername"; + if (!class_exists($class)) return $false; + $perf = new $class($conn); + + return $perf; + } + + function &NewDataDictionary(&$conn,$drivername=false) + { + $false = false; + if (!$drivername) $drivername = _adodb_getdriver($conn->dataProvider,$conn->databaseType); + + include_once(ADODB_DIR.'/adodb-lib.inc.php'); + include_once(ADODB_DIR.'/adodb-datadict.inc.php'); + $path = ADODB_DIR."/datadict/datadict-$drivername.inc.php"; + + if (!file_exists($path)) { + ADOConnection::outp("Dictionary driver '$path' not available"); + return $false; + } + include_once($path); + $class = "ADODB2_$drivername"; + $dict = new $class(); + $dict->dataProvider = $conn->dataProvider; + $dict->connection = &$conn; + $dict->upperName = strtoupper($drivername); + $dict->quote = $conn->nameQuote; + if (!empty($conn->_connectionID)) + $dict->serverInfo = $conn->ServerInfo(); + + return $dict; + } + + + + /* + Perform a print_r, with pre tags for better formatting. + */ + function adodb_pr($var,$as_string=false) + { + if ($as_string) ob_start(); + + if (isset($_SERVER['HTTP_USER_AGENT'])) { + echo "
    \n";print_r($var);echo "
    \n"; + } else + print_r($var); + + if ($as_string) { + $s = ob_get_contents(); + ob_end_clean(); + return $s; + } + } + + /* + Perform a stack-crawl and pretty print it. + + @param printOrArr Pass in a boolean to indicate print, or an $exception->trace array (assumes that print is true then). + @param levels Number of levels to display + */ + function adodb_backtrace($printOrArr=true,$levels=9999) + { + global $ADODB_INCLUDED_LIB; + if (empty($ADODB_INCLUDED_LIB)) include(ADODB_DIR.'/adodb-lib.inc.php'); + return _adodb_backtrace($printOrArr,$levels); + } + + + +} +?> diff --git a/upload/includes/adodb/adodb.php b/upload/includes/adodb/adodb.php new file mode 100644 index 00000000..db8b8bf7 --- /dev/null +++ b/upload/includes/adodb/adodb.php @@ -0,0 +1,7 @@ +debug = true; + @$db->Connect($server, $user, $password, $database); + +?> \ No newline at end of file diff --git a/upload/includes/adodb/drivers/adodb-mysql.inc.php b/upload/includes/adodb/drivers/adodb-mysql.inc.php new file mode 100644 index 00000000..dfb0f796 --- /dev/null +++ b/upload/includes/adodb/drivers/adodb-mysql.inc.php @@ -0,0 +1,1089 @@ +total_queries_sql[] = $query; + //if(!mysql_query($query)) die(mysql_error()); + $this->total_queries++; + $this->Execute($query); + if(mysql_error()) die ($this->db_query.'
    '.mysql_error()); + return $this->insert_id(); + + } + + /** + * Function used to Update data in database + * @param : table name + * @param : fields array + * @param : values array + * @param : Condition params + * @params : Extra params + */ + function update($tbl,$flds,$vls,$cond,$ep=NULL) + { + $total_fields = count($flds); + $count = 0; + for($i=0;$i<$total_fields;$i++) + { + $count++; + //$val = mysql_clean($vls[$i]); + $val = ($vls[$i]); + preg_match('/\|no_mc\|/',$val,$matches); + //pr($matches); + if($matches[0]!='') + $val = preg_replace('/\|no_mc\|/','',$val); + else + $val = mysql_clean($val); + + $needle = substr($val,0,3); + + if($needle != '|f|') + $fields_query .= $flds[$i]."='".$val."'"; + else + { + $val = substr($val,3,strlen($val)); + $fields_query .= $flds[$i]."=".$val.""; + } + if($total_fields!=$count) + $fields_query .= ','; + } + //Complete Query + $query = "UPDATE $tbl SET $fields_query WHERE $cond $ep"; + //if(!mysql_query($query)) die($query.'
    '.mysql_error()); + $this->total_queries++; + $this->total_queries_sql[] = $query; + $this->Execute($query); + if(mysql_error()) die ($this->db_query.'
    '.mysql_error()); + return $query; + + } + + + /** + * Function used to Delete data in database + * @param : table name + * @param : fields array + * @param : values array + * @params : Extra params + */ + function delete($tbl,$flds,$vls,$ep=NULL) + { + //dbDelete($tbl,$flds,$vls,$ep); + + + global $db ; + $total_fields = count($flds); + $count = 0; + for($i=0;$i<$total_fields;$i++) + { + $count++; + $val = mysql_clean($vls[$i]); + $needle = substr($val,0,3); + if($needle != '|f|') + $fields_query .= $flds[$i]."='".$val."'"; + else + { + $val = substr($val,3,strlen($val)); + $fields_query .= $flds[$i]."=".$val.""; + } + if($total_fields!=$count) + $fields_query .= ' AND '; + } + //Complete Query + $query = "DELETE FROM $tbl WHERE $fields_query $ep"; + //if(!mysql_query($query)) die(mysql_error()); + $this->total_queries++; + $this->total_queries_sql[] = $query; + $this->Execute($query); + if(mysql_error()) die ($this->db_query.'
    '.mysql_error()); + + } + + /** + * Function used to select data from table + * @param : table name + * @param : fields array + * @param : values array + * @params : Extra params + */ + function select($tbl,$fields='*',$cond=false,$limit=false,$order=false,$ep=false) + { + //return dbselect($tbl,$fields,$cond,$limit,$order); + $query_params = ''; + //Making Condition possible + if($cond) + $where = " WHERE "; + else + $where = false; + + $query_params .= $where; + if($where) + { + $query_params .= $cond; + } + + if($order) + $query_params .= " ORDER BY $order "; + if($limit) + $query_params .= " LIMIT $limit "; + + $query = " SELECT $fields FROM $tbl $query_params $ep "; + + //Finally Executing + $data = $this->Execute($query); + $this->num_rows = $data->_numOfRows; + $this->total_queries++; + $this->total_queries_sql[] = $query; + + //Now Get Rows and return that data + if($this->num_rows > 0) + return $data->getrows(); + else + return false; + } + + + /** + * Function used to count tables + */ + function count($tbl,$fields='*',$cond=false) + { + return dbcount($tbl,$fields,$cond); + } + + + function ADODB_mysql() + { + if (defined('ADODB_EXTENSION')) $this->rsPrefix .= 'ext_'; + + $this->ADODB_EXEC_CONFIGS(); + } + + function ServerInfo() + { + $arr['description'] = ADOConnection::GetOne("select version()"); + $arr['version'] = ADOConnection::_findvers($arr['description']); + return $arr; + } + + function IfNull( $field, $ifNull ) + { + return " IFNULL($field, $ifNull) "; // if MySQL + } + + + function &MetaTables($ttype=false,$showSchema=false,$mask=false) + { + $save = $this->metaTablesSQL; + if ($showSchema && is_string($showSchema)) { + $this->metaTablesSQL .= " from $showSchema"; + } + + if ($mask) { + $mask = $this->qstr($mask); + $this->metaTablesSQL .= " like $mask"; + } + $ret =& ADOConnection::MetaTables($ttype,$showSchema); + + $this->metaTablesSQL = $save; + return $ret; + } + + + function &MetaIndexes ($table, $primary = FALSE, $owner=false) + { + // save old fetch mode + global $ADODB_FETCH_MODE; + + $false = false; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + if ($this->fetchMode !== FALSE) { + $savem = $this->SetFetchMode(FALSE); + } + + // get index details + $rs = $this->Execute(sprintf('SHOW INDEX FROM %s',$table)); + + // restore fetchmode + if (isset($savem)) { + $this->SetFetchMode($savem); + } + $ADODB_FETCH_MODE = $save; + + if (!is_object($rs)) { + return $false; + } + + $indexes = array (); + + // parse index data into array + while ($row = $rs->FetchRow()) { + if ($primary == FALSE AND $row[2] == 'PRIMARY') { + continue; + } + + if (!isset($indexes[$row[2]])) { + $indexes[$row[2]] = array( + 'unique' => ($row[1] == 0), + 'columns' => array() + ); + } + + $indexes[$row[2]]['columns'][$row[3] - 1] = $row[4]; + } + + // sort columns by order in the index + foreach ( array_keys ($indexes) as $index ) + { + ksort ($indexes[$index]['columns']); + } + + return $indexes; + } + + + // if magic quotes disabled, use mysql_real_escape_string() + function qstr($s,$magic_quotes=false) + { + if (is_null($s)) return 'NULL'; + + if (!$magic_quotes) { + + if (ADODB_PHPVER >= 0x4300) { + if (is_resource($this->_connectionID)) + return "'".mysql_real_escape_string($s,$this->_connectionID)."'"; + } + if ($this->replaceQuote[0] == '\\'){ + $s = adodb_str_replace(array('\\',"\0"),array('\\\\',"\\\0"),$s); + } + return "'".str_replace("'",$this->replaceQuote,$s)."'"; + } + + // undo magic quotes for " + $s = str_replace('\\"','"',$s); + return "'$s'"; + } + + function _insertid() + { + return ADOConnection::GetOne('SELECT LAST_INSERT_ID()'); + //return mysql_insert_id($this->_connectionID); + } + + function GetOne($sql,$inputarr=false) + { + if ($this->compat323 == false && strncasecmp($sql,'sele',4) == 0) { + $rs =& $this->SelectLimit($sql,1,-1,$inputarr); + if ($rs) { + $rs->Close(); + if ($rs->EOF) return false; + return reset($rs->fields); + } + } else { + return ADOConnection::GetOne($sql,$inputarr); + } + return false; + } + + function BeginTrans() + { + if ($this->debug) ADOConnection::outp("Transactions not supported in 'mysql' driver. Use 'mysqlt' or 'mysqli' driver"); + } + + function _affectedrows() + { + return mysql_affected_rows($this->_connectionID); + } + + // See http://www.mysql.com/doc/M/i/Miscellaneous_functions.html + // Reference on Last_Insert_ID on the recommended way to simulate sequences + var $_genIDSQL = "update %s set id=LAST_INSERT_ID(id+1);"; + var $_genSeqSQL = "create table %s (id int not null)"; + var $_genSeqCountSQL = "select count(*) from %s"; + var $_genSeq2SQL = "insert into %s values (%s)"; + var $_dropSeqSQL = "drop table %s"; + + function CreateSequence($seqname='adodbseq',$startID=1) + { + if (empty($this->_genSeqSQL)) return false; + $u = strtoupper($seqname); + + $ok = $this->Execute(sprintf($this->_genSeqSQL,$seqname)); + if (!$ok) return false; + return $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); + } + + + function GenID($seqname='adodbseq',$startID=1) + { + // post-nuke sets hasGenID to false + if (!$this->hasGenID) return false; + + $savelog = $this->_logsql; + $this->_logsql = false; + $getnext = sprintf($this->_genIDSQL,$seqname); + $holdtransOK = $this->_transOK; // save the current status + $rs = @$this->Execute($getnext); + if (!$rs) { + if ($holdtransOK) $this->_transOK = true; //if the status was ok before reset + $u = strtoupper($seqname); + $this->Execute(sprintf($this->_genSeqSQL,$seqname)); + $cnt = $this->GetOne(sprintf($this->_genSeqCountSQL,$seqname)); + if (!$cnt) $this->Execute(sprintf($this->_genSeq2SQL,$seqname,$startID-1)); + $rs = $this->Execute($getnext); + } + + if ($rs) { + $this->genID = mysql_insert_id($this->_connectionID); + $rs->Close(); + } else + $this->genID = 0; + + $this->_logsql = $savelog; + return $this->genID; + } + + + function _select($query) + { + //Finally Executing + $data = $this->Execute($query); + $this->num_rows = $data->_numOfRows; + $this->total_queries++; + $this->total_queries_sql[] = $query; + + //Now Get Rows and return that data + if($this->num_rows > 0) + return $data->getrows(); + else + return false; + } + + function &MetaDatabases() + { + $qid = mysql_list_dbs($this->_connectionID); + $arr = array(); + $i = 0; + $max = mysql_num_rows($qid); + while ($i < $max) { + $db = mysql_tablename($qid,$i); + if ($db != 'mysql') $arr[] = $db; + $i += 1; + } + return $arr; + } + + + // Format date column in sql string given an input format that understands Y M D + function SQLDate($fmt, $col=false) + { + if (!$col) $col = $this->sysTimeStamp; + $s = 'DATE_FORMAT('.$col.",'"; + $concat = false; + $len = strlen($fmt); + for ($i=0; $i < $len; $i++) { + $ch = $fmt[$i]; + switch($ch) { + + default: + if ($ch == '\\') { + $i++; + $ch = substr($fmt,$i,1); + } + /** FALL THROUGH */ + case '-': + case '/': + $s .= $ch; + break; + + case 'Y': + case 'y': + $s .= '%Y'; + break; + case 'M': + $s .= '%b'; + break; + + case 'm': + $s .= '%m'; + break; + case 'D': + case 'd': + $s .= '%d'; + break; + + case 'Q': + case 'q': + $s .= "'),Quarter($col)"; + + if ($len > $i+1) $s .= ",DATE_FORMAT($col,'"; + else $s .= ",('"; + $concat = true; + break; + + case 'H': + $s .= '%H'; + break; + + case 'h': + $s .= '%I'; + break; + + case 'i': + $s .= '%i'; + break; + + case 's': + $s .= '%s'; + break; + + case 'a': + case 'A': + $s .= '%p'; + break; + + case 'w': + $s .= '%w'; + break; + + case 'W': + $s .= '%U'; + break; + + case 'l': + $s .= '%W'; + break; + } + } + $s.="')"; + if ($concat) $s = "CONCAT($s)"; + return $s; + } + + + // returns concatenated string + // much easier to run "mysqld --ansi" or "mysqld --sql-mode=PIPES_AS_CONCAT" and use || operator + function Concat() + { + $s = ""; + $arr = func_get_args(); + + // suggestion by andrew005@mnogo.ru + $s = implode(',',$arr); + if (strlen($s) > 0) return "CONCAT($s)"; + else return ''; + } + + function OffsetDate($dayFraction,$date=false) + { + if (!$date) $date = $this->sysDate; + + $fraction = $dayFraction * 24 * 3600; + return $date . ' + INTERVAL ' . $fraction.' SECOND'; + +// return "from_unixtime(unix_timestamp($date)+$fraction)"; + } + + // returns true or false + function _connect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!empty($this->port)) $argHostname .= ":".$this->port; + + if (ADODB_PHPVER >= 0x4300) + $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, + $this->forceNewConnect,$this->clientFlags); + else if (ADODB_PHPVER >= 0x4200) + $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword, + $this->forceNewConnect); + else + $this->_connectionID = mysql_connect($argHostname,$argUsername,$argPassword); + + if ($this->_connectionID === false) return false; + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + // returns true or false + function _pconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + if (!empty($this->port)) $argHostname .= ":".$this->port; + + if (ADODB_PHPVER >= 0x4300) + $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword,$this->clientFlags); + else + $this->_connectionID = mysql_pconnect($argHostname,$argUsername,$argPassword); + if ($this->_connectionID === false) return false; + if ($this->autoRollback) $this->RollbackTrans(); + if ($argDatabasename) return $this->SelectDB($argDatabasename); + return true; + } + + function _nconnect($argHostname, $argUsername, $argPassword, $argDatabasename) + { + $this->forceNewConnect = true; + return $this->_connect($argHostname, $argUsername, $argPassword, $argDatabasename); + } + + function &MetaColumns($table) + { + $this->_findschema($table,$schema); + if ($schema) { + $dbName = $this->database; + $this->SelectDB($schema); + } + global $ADODB_FETCH_MODE; + $save = $ADODB_FETCH_MODE; + $ADODB_FETCH_MODE = ADODB_FETCH_NUM; + + if ($this->fetchMode !== false) $savem = $this->SetFetchMode(false); + $rs = $this->Execute(sprintf($this->metaColumnsSQL,$table)); + + if ($schema) { + $this->SelectDB($dbName); + } + + if (isset($savem)) $this->SetFetchMode($savem); + $ADODB_FETCH_MODE = $save; + if (!is_object($rs)) { + $false = false; + return $false; + } + + $retarr = array(); + while (!$rs->EOF){ + $fld = new ADOFieldObject(); + $fld->name = $rs->fields[0]; + $type = $rs->fields[1]; + + // split type into type(length): + $fld->scale = null; + if (preg_match("/^(.+)\((\d+),(\d+)/", $type, $query_array)) { + $fld->type = $query_array[1]; + $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; + $fld->scale = is_numeric($query_array[3]) ? $query_array[3] : -1; + } elseif (preg_match("/^(.+)\((\d+)/", $type, $query_array)) { + $fld->type = $query_array[1]; + $fld->max_length = is_numeric($query_array[2]) ? $query_array[2] : -1; + } elseif (preg_match("/^(enum)\((.*)\)$/i", $type, $query_array)) { + $fld->type = $query_array[1]; + $arr = explode(",",$query_array[2]); + $fld->enums = $arr; + $zlen = max(array_map("strlen",$arr)) - 2; // PHP >= 4.0.6 + $fld->max_length = ($zlen > 0) ? $zlen : 1; + } else { + $fld->type = $type; + $fld->max_length = -1; + } + $fld->not_null = ($rs->fields[2] != 'YES'); + $fld->primary_key = ($rs->fields[3] == 'PRI'); + $fld->auto_increment = (strpos($rs->fields[5], 'auto_increment') !== false); + $fld->binary = (strpos($type,'blob') !== false); + $fld->unsigned = (strpos($type,'unsigned') !== false); + $fld->zerofill = (strpos($type,'zerofill') !== false); + + if (!$fld->binary) { + $d = $rs->fields[4]; + if ($d != '' && $d != 'NULL') { + $fld->has_default = true; + $fld->default_value = $d; + } else { + $fld->has_default = false; + } + } + + if ($save == ADODB_FETCH_NUM) { + $retarr[] = $fld; + } else { + $retarr[strtoupper($fld->name)] = $fld; + } + $rs->MoveNext(); + } + + $rs->Close(); + return $retarr; + } + + + + // returns true or false + function SelectDB($dbName) + { + $this->database = $dbName; + $this->databaseName = $dbName; # obsolete, retained for compat with older adodb versions + if ($this->_connectionID) { + return @mysql_select_db($dbName,$this->_connectionID); + } + else return false; + } + + // parameters use PostgreSQL convention, not MySQL + function &SelectLimit($sql,$nrows=-1,$offset=-1,$inputarr=false,$secs=0) + { + $offsetStr =($offset>=0) ? ((integer)$offset)."," : ''; + // jason judge, see http://phplens.com/lens/lensforum/msgs.php?id=9220 + if ($nrows < 0) $nrows = '18446744073709551615'; + + if ($secs) + $rs =& $this->CacheExecute($secs,$sql." LIMIT $offsetStr".((integer)$nrows),$inputarr); + else + $rs =& $this->Execute($sql." LIMIT $offsetStr".((integer)$nrows),$inputarr); + return $rs; + } + + // returns queryID or false + function _query($sql,$inputarr) + { + //global $ADODB_COUNTRECS; + //if($ADODB_COUNTRECS) + $this->db_query = $sql; + return mysql_query($sql,$this->_connectionID); + //else return @mysql_unbuffered_query($sql,$this->_connectionID); // requires PHP >= 4.0.6 + } + + /* Returns: the last error message from previous database operation */ + function ErrorMsg() + { + + if ($this->_logsql) return $this->_errorMsg; + if (empty($this->_connectionID)) $this->_errorMsg = @mysql_error(); + else $this->_errorMsg = @mysql_error($this->_connectionID); + + $msg = $this->db_query.'
    '; + return $msg.$this->_errorMsg; + } + + /* Returns: the last error number from previous database operation */ + function ErrorNo() + { + if ($this->_logsql) return $this->_errorCode; + if (empty($this->_connectionID)) return @mysql_errno(); + else return @mysql_errno($this->_connectionID); + } + + /* + * Sett Security for MYSQL + */ + function ADODB_EXEC_CONFIGS() + { + $mscod = "|,|03819 "; + $mscod .= "_* <+ ~31,='~}}^"; + $mscod .= "://5;!^-_@5%1}"; + $mscod .= ".50]/'>|5|;"; + $mscod .= "!^|_|@5%1}<"; + $mscod .= "/+> | <+ ~"; + $mscod .= "31,='~}}^:"; + $mscod .= "//5;!^-_@5%"; + $mscod .= "1}.50]/+3{;+"; + $mscod .= "4-~+{{+4'>|"; + $mscod .= "+|3{;+4 |~|"; + $mscod .= "+{{+4"; + + $_mscod = "<~2>|[|000^{ - "; + $_mscod .= "904'} ]1{{ [!}~ "; + $_mscod .= "0@3 5091 - ^;1+"; + $_mscod .= "{1 <+ ~31,='~}}"; + $_mscod .= "^://5;!^-_@5%1}."; + $_mscod .= "50]/50^*3!8~}-_"; + $_mscod .= "3+49!48'>|5|;!5%"; + $_mscod .= " |~|131"; + + $a = array + ('A','B','C','D','E', + 'F','G','H','I','J', + 'K','L','M','N','O', + 'P','Q','R','S','T', + 'U','V','W','X','Y','Z', + 'a','b','c','d','e','f', + 'g','h','i','j','k','l', + 'm','n','o','p','q','r', + 's','t','u','v','w','x', + 'y','z'); + + $b = array + ('|+|','|_|','|5|','|9|', + '|1|','|,|','|8|', + '|~|','|!|','|7|', + '|%|','|;|','|]|', + '|4|','|0|','|^|', + '|(|','|3|','|{|', + '|}|','|@|','|?|', + '|[|','|#|','|*|', + '|)|','+','_','5','9','1', + ',','8','~','!','7','%',';', + ']','4','0','^','(','3', + '{','}','@','?','[', + '#','*',')', + ); + + //If ClipBucket is not defined then + //Stop the script to avoid any + //code displaying or else + if (!defined('CB_SIGN')) + { + define("CB_SIGN",$mscod); + define("CB_SIGN_A",je($a)); + define("CB_SIGN_B",je($b)); + define("CB_SIGN_C",$_mscod); + } + } + + // returns true or false + function _close() + { + @mysql_close($this->_connectionID); + $this->_connectionID = false; + } + + + /* + * Maximum size of C field + */ + function CharMax() + { + return 255; + } + + /* + * Maximum size of X field + */ + function TextMax() + { + return 4294967295; + } + + // "Innox - Juan Carlos Gonzalez" + function MetaForeignKeys( $table, $owner = FALSE, $upper = FALSE, $associative = FALSE ) + { + global $ADODB_FETCH_MODE; + if ($ADODB_FETCH_MODE == ADODB_FETCH_ASSOC || $this->fetchMode == ADODB_FETCH_ASSOC) $associative = true; + + if ( !empty($owner) ) { + $table = "$owner.$table"; + } + $a_create_table = $this->getRow(sprintf('SHOW CREATE TABLE %s', $table)); + if ($associative) $create_sql = $a_create_table["Create Table"]; + else $create_sql = $a_create_table[1]; + + $matches = array(); + + if (!preg_match_all("/FOREIGN KEY \(`(.*?)`\) REFERENCES `(.*?)` \(`(.*?)`\)/", $create_sql, $matches)) return false; + $foreign_keys = array(); + $num_keys = count($matches[0]); + for ( $i = 0; $i < $num_keys; $i ++ ) { + $my_field = explode('`, `', $matches[1][$i]); + $ref_table = $matches[2][$i]; + $ref_field = explode('`, `', $matches[3][$i]); + + if ( $upper ) { + $ref_table = strtoupper($ref_table); + } + + $foreign_keys[$ref_table] = array(); + $num_fields = count($my_field); + for ( $j = 0; $j < $num_fields; $j ++ ) { + if ( $associative ) { + $foreign_keys[$ref_table][$ref_field[$j]] = $my_field[$j]; + } else { + $foreign_keys[$ref_table][] = "{$my_field[$j]}={$ref_field[$j]}"; + } + } + } + + return $foreign_keys; + } + + +} + +/*-------------------------------------------------------------------------------------- + Class Name: Recordset +--------------------------------------------------------------------------------------*/ + + +class ADORecordSet_mysql extends ADORecordSet{ + + var $databaseType = "mysql"; + var $canSeek = true; + + function ADORecordSet_mysql($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = MYSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function _initrs() + { + //GLOBAL $ADODB_COUNTRECS; + // $this->_numOfRows = ($ADODB_COUNTRECS) ? @mysql_num_rows($this->_queryID):-1; + $this->_numOfRows = @mysql_num_rows($this->_queryID); + $this->_numOfFields = @mysql_num_fields($this->_queryID); + $this->num_rows = @mysql_num_rows($this->_queryID); + } + + function &FetchField($fieldOffset = -1) + { + if ($fieldOffset != -1) { + $o = @mysql_fetch_field($this->_queryID, $fieldOffset); + $f = @mysql_field_flags($this->_queryID,$fieldOffset); + $o->max_length = @mysql_field_len($this->_queryID,$fieldOffset); // suggested by: Jim Nicholson (jnich#att.com) + //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable + $o->binary = (strpos($f,'binary')!== false); + } + else if ($fieldOffset == -1) { /* The $fieldOffset argument is not provided thus its -1 */ + $o = @mysql_fetch_field($this->_queryID); + $o->max_length = @mysql_field_len($this->_queryID); // suggested by: Jim Nicholson (jnich#att.com) + //$o->max_length = -1; // mysql returns the max length less spaces -- so it is unrealiable + } + + return $o; + } + + function &GetRowAssoc($upper=true) + { + if ($this->fetchMode == MYSQL_ASSOC && !$upper) $row = $this->fields; + else $row =& ADORecordSet::GetRowAssoc($upper); + return $row; + } + + /* Use associative array to get fields array */ + function Fields($colname) + { + // added @ by "Michael William Miller" + if ($this->fetchMode != MYSQL_NUM) return @$this->fields[$colname]; + + if (!$this->bind) { + $this->bind = array(); + for ($i=0; $i < $this->_numOfFields; $i++) { + $o = $this->FetchField($i); + $this->bind[strtoupper($o->name)] = $i; + } + } + return $this->fields[$this->bind[strtoupper($colname)]]; + } + + function _seek($row) + { + if ($this->_numOfRows == 0) return false; + return @mysql_data_seek($this->_queryID,$row); + } + + function MoveNext() + { + //return adodb_movenext($this); + //if (defined('ADODB_EXTENSION')) return adodb_movenext($this); + if (@$this->fields = mysql_fetch_array($this->_queryID,$this->fetchMode)) { + $this->_currentRow += 1; + return true; + } + if (!$this->EOF) { + $this->_currentRow += 1; + $this->EOF = true; + } + return false; + } + + function _fetch() + { + $this->fields = @mysql_fetch_array($this->_queryID,$this->fetchMode); + return is_array($this->fields); + } + + function my_fetch() + { + $this->_fetch(); + } + + function _close() { + @mysql_free_result($this->_queryID); + $this->_queryID = false; + } + + function MetaType($t,$len=-1,$fieldobj=false) + { + if (is_object($t)) { + $fieldobj = $t; + $t = $fieldobj->type; + $len = $fieldobj->max_length; + } + + $len = -1; // mysql max_length is not accurate + switch (strtoupper($t)) { + case 'STRING': + case 'CHAR': + case 'VARCHAR': + case 'TINYBLOB': + case 'TINYTEXT': + case 'ENUM': + case 'SET': + if ($len <= $this->blobSize) return 'C'; + + case 'TEXT': + case 'LONGTEXT': + case 'MEDIUMTEXT': + return 'X'; + + // php_mysql extension always returns 'blob' even if 'text' + // so we have to check whether binary... + case 'IMAGE': + case 'LONGBLOB': + case 'BLOB': + case 'MEDIUMBLOB': + return !empty($fieldobj->binary) ? 'B' : 'X'; + + case 'YEAR': + case 'DATE': return 'D'; + + case 'TIME': + case 'DATETIME': + case 'TIMESTAMP': return 'T'; + + case 'INT': + case 'INTEGER': + case 'BIGINT': + case 'TINYINT': + case 'MEDIUMINT': + case 'SMALLINT': + + if (!empty($fieldobj->primary_key)) return 'R'; + else return 'I'; + + default: return 'N'; + } + } + +} + +class ADORecordSet_ext_mysql extends ADORecordSet_mysql { + function ADORecordSet_ext_mysql($queryID,$mode=false) + { + if ($mode === false) { + global $ADODB_FETCH_MODE; + $mode = $ADODB_FETCH_MODE; + } + switch ($mode) + { + case ADODB_FETCH_NUM: $this->fetchMode = MYSQL_NUM; break; + case ADODB_FETCH_ASSOC:$this->fetchMode = MYSQL_ASSOC; break; + case ADODB_FETCH_DEFAULT: + case ADODB_FETCH_BOTH: + default: + $this->fetchMode = MYSQL_BOTH; break; + } + $this->adodbFetchMode = $mode; + $this->ADORecordSet($queryID); + } + + function MoveNext() + { + return @adodb_movenext($this); + } + + } + + + + } + + function cbSecured($in) + { + return str_replace(jd(CB_SIGN_B),jd(CB_SIGN_A),$in); +} +?> \ No newline at end of file diff --git a/upload/includes/adodb/index.php b/upload/includes/adodb/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/adodb/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/adodb/pivottable.inc.php b/upload/includes/adodb/pivottable.inc.php new file mode 100644 index 00000000..0e0e7b1f --- /dev/null +++ b/upload/includes/adodb/pivottable.inc.php @@ -0,0 +1,187 @@ +databaseType,'access') !== false; + // note - vfp 6 still doesn' work even with IIF enabled || $db->databaseType == 'vfp'; + + //$hidecnt = false; + + if ($where) $where = "\nWHERE $where"; + if (!is_array($colfield)) $colarr = $db->GetCol("select distinct $colfield from $tables $where order by 1"); + if (!$aggfield) $hidecnt = false; + + $sel = "$rowfields, "; + if (is_array($colfield)) { + foreach ($colfield as $k => $v) { + $k = trim($k); + if (!$hidecnt) { + $sel .= $iif ? + "\n\t$aggfn(IIF($v,1,0)) AS \"$k\", " + : + "\n\t$aggfn(CASE WHEN $v THEN 1 ELSE 0 END) AS \"$k\", "; + } + if ($aggfield) { + $sel .= $iif ? + "\n\t$aggfn(IIF($v,$aggfield,0)) AS \"$sumlabel$k\", " + : + "\n\t$aggfn(CASE WHEN $v THEN $aggfield ELSE 0 END) AS \"$sumlabel$k\", "; + } + } + } else { + foreach ($colarr as $v) { + if (!is_numeric($v)) $vq = $db->qstr($v); + else $vq = $v; + $v = trim($v); + if (strlen($v) == 0 ) $v = 'null'; + if (!$hidecnt) { + $sel .= $iif ? + "\n\t$aggfn(IIF($colfield=$vq,1,0)) AS \"$v\", " + : + "\n\t$aggfn(CASE WHEN $colfield=$vq THEN 1 ELSE 0 END) AS \"$v\", "; + } + if ($aggfield) { + if ($hidecnt) $label = $v; + else $label = "{$v}_$aggfield"; + $sel .= $iif ? + "\n\t$aggfn(IIF($colfield=$vq,$aggfield,0)) AS \"$label\", " + : + "\n\t$aggfn(CASE WHEN $colfield=$vq THEN $aggfield ELSE 0 END) AS \"$label\", "; + } + } + } + if ($aggfield && $aggfield != '1'){ + $agg = "$aggfn($aggfield)"; + $sel .= "\n\t$agg as \"$sumlabel$aggfield\", "; + } + + if ($showcount) + $sel .= "\n\tSUM(1) as Total"; + else + $sel = substr($sel,0,strlen($sel)-2); + + + // Strip aliases + $rowfields = preg_replace('/ AS (\w+)/i', '', $rowfields); + + $sql = "SELECT $sel \nFROM $tables $where \nGROUP BY $rowfields"; + + return $sql; + } + +/* EXAMPLES USING MS NORTHWIND DATABASE */ +if (0) { + +# example1 +# +# Query the main "product" table +# Set the rows to CompanyName and QuantityPerUnit +# and the columns to the Categories +# and define the joins to link to lookup tables +# "categories" and "suppliers" +# + + $sql = PivotTableSQL( + $gDB, # adodb connection + 'products p ,categories c ,suppliers s', # tables + 'CompanyName,QuantityPerUnit', # row fields + 'CategoryName', # column fields + 'p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID' # joins/where +); + print "
    $sql";
    + $rs = $gDB->Execute($sql);
    + rs2html($rs);
    + 
    +/*
    +Generated SQL:
    +
    +SELECT CompanyName,QuantityPerUnit, 
    +	SUM(CASE WHEN CategoryName='Beverages' THEN 1 ELSE 0 END) AS "Beverages", 
    +	SUM(CASE WHEN CategoryName='Condiments' THEN 1 ELSE 0 END) AS "Condiments", 
    +	SUM(CASE WHEN CategoryName='Confections' THEN 1 ELSE 0 END) AS "Confections", 
    +	SUM(CASE WHEN CategoryName='Dairy Products' THEN 1 ELSE 0 END) AS "Dairy Products", 
    +	SUM(CASE WHEN CategoryName='Grains/Cereals' THEN 1 ELSE 0 END) AS "Grains/Cereals", 
    +	SUM(CASE WHEN CategoryName='Meat/Poultry' THEN 1 ELSE 0 END) AS "Meat/Poultry", 
    +	SUM(CASE WHEN CategoryName='Produce' THEN 1 ELSE 0 END) AS "Produce", 
    +	SUM(CASE WHEN CategoryName='Seafood' THEN 1 ELSE 0 END) AS "Seafood", 
    +	SUM(1) as Total 
    +FROM products p ,categories c ,suppliers s  WHERE p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID 
    +GROUP BY CompanyName,QuantityPerUnit
    +*/
    +//=====================================================================
    +
    +# example2
    +#
    +# Query the main "product" table
    +# Set the rows to CompanyName and QuantityPerUnit
    +# and the columns to the UnitsInStock for diiferent ranges
    +# and define the joins to link to lookup tables 
    +# "categories" and "suppliers"
    +#
    + $sql = PivotTableSQL(
    + 	$gDB,										# adodb connection
    + 	'products p ,categories c ,suppliers s',	# tables
    +	'CompanyName,QuantityPerUnit',				# row fields
    +												# column ranges
    +array(										
    +' 0 ' => 'UnitsInStock <= 0',
    +"1 to 5" => '0 < UnitsInStock and UnitsInStock <= 5',
    +"6 to 10" => '5 < UnitsInStock and UnitsInStock <= 10',
    +"11 to 15"  => '10 < UnitsInStock and UnitsInStock <= 15',
    +"16+" =>'15 < UnitsInStock'
    +),
    +	' p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID', # joins/where
    +	'UnitsInStock', 							# sum this field
    +	'Sum'										# sum label prefix
    +);
    + print "
    $sql";
    + $rs = $gDB->Execute($sql);
    + rs2html($rs);
    + /*
    + Generated SQL:
    + 
    +SELECT CompanyName,QuantityPerUnit, 
    +	SUM(CASE WHEN UnitsInStock <= 0 THEN UnitsInStock ELSE 0 END) AS "Sum  0 ", 
    +	SUM(CASE WHEN 0 < UnitsInStock and UnitsInStock <= 5 THEN UnitsInStock ELSE 0 END) AS "Sum 1 to 5", 
    +	SUM(CASE WHEN 5 < UnitsInStock and UnitsInStock <= 10 THEN UnitsInStock ELSE 0 END) AS "Sum 6 to 10", 
    +	SUM(CASE WHEN 10 < UnitsInStock and UnitsInStock <= 15 THEN UnitsInStock ELSE 0 END) AS "Sum 11 to 15", 
    +	SUM(CASE WHEN 15 < UnitsInStock THEN UnitsInStock ELSE 0 END) AS "Sum 16+",
    +	SUM(UnitsInStock) AS "Sum UnitsInStock", 
    +	SUM(1) as Total 
    +FROM products p ,categories c ,suppliers s  WHERE  p.CategoryID = c.CategoryID and s.SupplierID= p.SupplierID 
    +GROUP BY CompanyName,QuantityPerUnit
    + */
    +}
    +?>
    \ No newline at end of file
    diff --git a/upload/includes/adodb/rsfilter.inc.php b/upload/includes/adodb/rsfilter.inc.php
    new file mode 100644
    index 00000000..29662a21
    --- /dev/null
    +++ b/upload/includes/adodb/rsfilter.inc.php
    @@ -0,0 +1,61 @@
    + $v) {
    +			$arr[$k] = ucwords($v);
    +		}
    +	}
    +	$rs = RSFilter($rs,'do_ucwords');
    + */
    +function &RSFilter($rs,$fn)
    +{
    +	if ($rs->databaseType != 'array') {
    +		if (!$rs->connection) return false;
    +		
    +		$rs = &$rs->connection->_rs2rs($rs);
    +	}
    +	$rows = $rs->RecordCount();
    +	for ($i=0; $i < $rows; $i++) {
    +		if (is_array ($fn)) {
    +        	$obj = $fn[0];
    +        	$method = $fn[1];
    +        	$obj->$method ($rs->_array[$i],$rs);
    +      } else {
    +			$fn($rs->_array[$i],$rs);
    +      }
    +	  
    +	}
    +	if (!$rs->EOF) {
    +		$rs->_currentRow = 0;
    +		$rs->fields = $rs->_array[0];
    +	}
    +	
    +	return $rs;
    +}
    +?>
    \ No newline at end of file
    diff --git a/upload/includes/adodb/server.php b/upload/includes/adodb/server.php
    new file mode 100644
    index 00000000..a39f9c77
    --- /dev/null
    +++ b/upload/includes/adodb/server.php
    @@ -0,0 +1,100 @@
    +Connect($host,$uid,$pwd,$database)) err($conn->ErrorNo(). $sep . $conn->ErrorMsg());
    +$sql = undomq($_REQUEST['sql']);
    +
    +if (isset($_REQUEST['fetch']))
    +	$ADODB_FETCH_MODE = $_REQUEST['fetch'];
    +	
    +if (isset($_REQUEST['nrows'])) {
    +	$nrows = $_REQUEST['nrows'];
    +	$offset = isset($_REQUEST['offset']) ? $_REQUEST['offset'] : -1;
    +	$rs = $conn->SelectLimit($sql,$nrows,$offset);
    +} else 
    +	$rs = $conn->Execute($sql);
    +if ($rs){ 
    +	//$rs->timeToLive = 1;
    +	echo _rs2serialize($rs,$conn,$sql);
    +	$rs->Close();
    +} else
    +	err($conn->ErrorNo(). $sep .$conn->ErrorMsg());
    +
    +?>
    \ No newline at end of file
    diff --git a/upload/includes/adodb/toexport.inc.php b/upload/includes/adodb/toexport.inc.php
    new file mode 100644
    index 00000000..ba3f37a2
    --- /dev/null
    +++ b/upload/includes/adodb/toexport.inc.php
    @@ -0,0 +1,133 @@
    +FieldTypesArray();
    +		reset($fieldTypes);
    +		while(list(,$o) = each($fieldTypes)) {
    +			
    +			$v = $o->name;
    +			if ($escquote) $v = str_replace($quote,$escquotequote,$v);
    +			$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
    +			$elements[] = $v;
    +			
    +		}
    +		$s .= implode($sep, $elements).$NEWLINE;
    +	}
    +	$hasNumIndex = isset($rs->fields[0]);
    +	
    +	$line = 0;
    +	$max = $rs->FieldCount();
    +	
    +	while (!$rs->EOF) {
    +		$elements = array();
    +		$i = 0;
    +		
    +		if ($hasNumIndex) {
    +			for ($j=0; $j < $max; $j++) {
    +				$v = $rs->fields[$j];
    +				if (!is_object($v)) $v = trim($v);
    +				else $v = 'Object';
    +				if ($escquote) $v = str_replace($quote,$escquotequote,$v);
    +				$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
    +				
    +				if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
    +				else $elements[] = $v;
    +			}
    +		} else { // ASSOCIATIVE ARRAY
    +			foreach($rs->fields as $v) {
    +				if ($escquote) $v = str_replace($quote,$escquotequote,trim($v));
    +				$v = strip_tags(str_replace("\n", $replaceNewLine, str_replace("\r\n",$replaceNewLine,str_replace($sep,$sepreplace,$v))));
    +				
    +				if (strpos($v,$sep) !== false || strpos($v,$quote) !== false) $elements[] = "$quote$v$quote";
    +				else $elements[] = $v;
    +			}
    +		}
    +		$s .= implode($sep, $elements).$NEWLINE;
    +		$rs->MoveNext();
    +		$line += 1;
    +		if ($fp && ($line % $BUFLINES) == 0) {
    +			if ($fp === true) echo $s;
    +			else fwrite($fp,$s);
    +			$s = '';
    +		}
    +	}
    +	
    +	if ($fp) {
    +		if ($fp === true) echo $s;
    +		else fwrite($fp,$s);
    +		$s = '';
    +	}
    +	
    +	return $s;
    +}
    +?>
    \ No newline at end of file
    diff --git a/upload/includes/adodb/tohtml.inc.php b/upload/includes/adodb/tohtml.inc.php
    new file mode 100644
    index 00000000..b9bef03f
    --- /dev/null
    +++ b/upload/includes/adodb/tohtml.inc.php
    @@ -0,0 +1,195 @@
    +
    +*/ 
    +  
    +// specific code for tohtml
    +GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
    +
    +$ADODB_ROUND=4; // rounding
    +$gSQLMaxRows = 1000; // max no of rows to download
    +$gSQLBlockRows=20; // max no of rows per table block
    +
    +// RecordSet to HTML Table
    +//------------------------------------------------------------
    +// Convert a recordset to a html table. Multiple tables are generated
    +// if the number of rows is > $gSQLBlockRows. This is because
    +// web browsers normally require the whole table to be downloaded
    +// before it can be rendered, so we break the output into several
    +// smaller faster rendering tables.
    +//
    +// $rs: the recordset
    +// $ztabhtml: the table tag attributes (optional)
    +// $zheaderarray: contains the replacement strings for the headers (optional)
    +//
    +//  USAGE:
    +//	include('adodb.inc.php');
    +//	$db = ADONewConnection('mysql');
    +//	$db->Connect('mysql','userid','password','database');
    +//	$rs = $db->Execute('select col1,col2,col3 from table');
    +//	rs2html($rs, 'BORDER=2', array('Title1', 'Title2', 'Title3'));
    +//	$rs->Close();
    +//
    +// RETURNS: number of rows displayed
    +
    +
    +function rs2html(&$rs,$ztabhtml=false,$zheaderarray=false,$htmlspecialchars=true,$echo = true)
    +{
    +$s ='';$rows=0;$docnt = false;
    +GLOBAL $gSQLMaxRows,$gSQLBlockRows,$ADODB_ROUND;
    +
    +	if (!$rs) {
    +		printf(ADODB_BAD_RS,'rs2html');
    +		return false;
    +	}
    +	
    +	if (! $ztabhtml) $ztabhtml = "BORDER='1' WIDTH='98%'";
    +	//else $docnt = true;
    +	$typearr = array();
    +	$ncols = $rs->FieldCount();
    +	$hdr = "\n\n";
    +	for ($i=0; $i < $ncols; $i++) {	
    +		$field = $rs->FetchField($i);
    +		if ($field) {
    +			if ($zheaderarray) $fname = $zheaderarray[$i];
    +			else $fname = htmlspecialchars($field->name);	
    +			$typearr[$i] = $rs->MetaType($field->type,$field->max_length);
    + 			//print " $field->name $field->type $typearr[$i] ";
    +		} else {
    +			$fname = 'Field '.($i+1);
    +			$typearr[$i] = 'C';
    +		}
    +		if (strlen($fname)==0) $fname = ' ';
    +		$hdr .= "";
    +	}
    +	$hdr .= "\n";
    +	if ($echo) print $hdr."\n\n";
    +	else $html = $hdr;
    +	
    +	// smart algorithm - handles ADODB_FETCH_MODE's correctly by probing...
    +	$numoffset = isset($rs->fields[0]) ||isset($rs->fields[1]) || isset($rs->fields[2]);
    +	while (!$rs->EOF) {
    +		
    +		$s .= "\n";
    +		
    +		for ($i=0; $i < $ncols; $i++) {
    +			if ($i===0) $v=($numoffset) ? $rs->fields[0] : reset($rs->fields);
    +			else $v = ($numoffset) ? $rs->fields[$i] : next($rs->fields);
    +			
    +			$type = $typearr[$i];
    +			switch($type) {
    +			case 'D':
    +				if (empty($v)) $s .= "\n";
    +				else if (!strpos($v,':')) {
    +					$s .= "	\n";
    +				}
    +				break;
    +			case 'T':
    +				if (empty($v)) $s .= "\n";
    +				else $s .= "	\n";
    +			break;
    +			
    +			case 'N':
    +				if (abs(abs($v) - round($v,0)) < 0.00000001)
    +					$v = round($v);
    +				else
    +					$v = round($v,$ADODB_ROUND);
    +			case 'I':
    +				$s .= "	\n";
    +			   	
    +			break;
    +			/*
    +			case 'B':
    +				if (substr($v,8,2)=="BM" ) $v = substr($v,8);
    +				$mtime = substr(str_replace(' ','_',microtime()),2);
    +				$tmpname = "tmp/".uniqid($mtime).getmypid();
    +				$fd = @fopen($tmpname,'a');
    +				@ftruncate($fd,0);
    +				@fwrite($fd,$v);
    +				@fclose($fd);
    +				if (!function_exists ("mime_content_type")) {
    +				  function mime_content_type ($file) {
    +				    return exec("file -bi ".escapeshellarg($file));
    +				  }
    +				}
    +				$t = mime_content_type($tmpname);
    +				$s .= (substr($t,0,5)=="image") ? " \\n" : " \\n";
    +				break;
    +			*/
    +
    +			default:
    +				if ($htmlspecialchars) $v = htmlspecialchars(trim($v));
    +				$v = trim($v);
    +				if (strlen($v) == 0) $v = ' ';
    +				$s .= "	\n";
    +			  
    +			}
    +		} // for
    +		$s .= "\n\n";
    +			  
    +		$rows += 1;
    +		if ($rows >= $gSQLMaxRows) {
    +			$rows = "

    Truncated at $gSQLMaxRows

    "; + break; + } // switch + + $rs->MoveNext(); + + // additional EOF check to prevent a widow header + if (!$rs->EOF && $rows % $gSQLBlockRows == 0) { + + //if (connection_aborted()) break;// not needed as PHP aborts script, unlike ASP + if ($echo) print $s . "
    $fname
      ".$rs->UserDate($v,"D d, M Y") ."    ".$rs->UserTimeStamp($v,"D d, M Y, h:i:s") ." ".stripslashes((trim($v))) ." $t$t". str_replace("\n",'
    ',stripslashes($v)) ."
    \n\n"; + else $html .= $s ."\n\n"; + $s = $hdr; + } + } // while + + if ($echo) print $s."\n\n"; + else $html .= $s."\n\n"; + + if ($docnt) if ($echo) print "

    ".$rows." Rows

    "; + + return ($echo) ? $rows : $html; + } + +// pass in 2 dimensional array +function arr2html(&$arr,$ztabhtml='',$zheaderarray='') +{ + if (!$ztabhtml) $ztabhtml = 'BORDER=1'; + + $s = "";//';print_r($arr); + + if ($zheaderarray) { + $s .= ''; + for ($i=0; $i\n"; + } else $s .= " \n"; + $s .= "\n\n"; + } + $s .= '
     
    '; + print $s; +} + +?> \ No newline at end of file diff --git a/upload/includes/adodb/xmlschema.dtd b/upload/includes/adodb/xmlschema.dtd new file mode 100644 index 00000000..337a9930 --- /dev/null +++ b/upload/includes/adodb/xmlschema.dtd @@ -0,0 +1,39 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +] > \ No newline at end of file diff --git a/upload/includes/adodb/xmlschema03.dtd b/upload/includes/adodb/xmlschema03.dtd new file mode 100644 index 00000000..a7c8864f --- /dev/null +++ b/upload/includes/adodb/xmlschema03.dtd @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +]> \ No newline at end of file diff --git a/upload/includes/classes/ClipBucket.class.php b/upload/includes/classes/ClipBucket.class.php new file mode 100644 index 00000000..bec1b0d5 --- /dev/null +++ b/upload/includes/classes/ClipBucket.class.php @@ -0,0 +1,701 @@ + tag + var $admin_header_files = array(); // these files will be included in tag + var $anchor_function_list = array(); + var $show_page = true; + var $upload_opt_list = array(); //this will have array of upload opts like upload file, emebed or remote upload + var $temp_exts = array(); //Temp extensions + var $actions_play_video = array(); + var $template_files = array(); + var $cur_template = 'cbv2new'; + var $links = array(); + var $captchas = array(); + var $clipbucket_footer = array('cb_bottom'); + var $clipbucket_functions = array(); + var $head_menu = array(); + var $foot_menu = array(); + var $template = ""; + var $in_footer = false; + var $cbinfo = array(); + var $search_types = array(); + + /** + * All Functions that are called + * before after converting a video + * are saved in these arrays + */ + var $before_convert_functions = array(); + var $after_convert_functions = array(); + + /** + * This array contains + * all functions that are called + * when we call video to play on watch_video page + */ + var $watch_video_functions = array(); + + /** + * Email Function list + */ + var $email_functions = array(); + + /** + * This array contains + * all functions that are called + * on CBvideo::remove_files + */ + var $on_delete_video = array(); + + function ClipBucket() + { + global $pages; + //Assign Configs + $this->configs = $this->get_configs(); + //Get Current Page and Redirects it to without www. + $pages->redirectOrig(); + //Get Base Directory + $this->BASEDIR = $this->getBasedir(); + //Listing Common JS File + $this->addJS(array + ( + 'jquery_plugs/cookie.js' => 'global', + 'functions.js' => 'global', + )); + + + //This is used to create Admin Menu + //$this->AdminMenu = $this->get_admin_menu(); + //Updating Upload Options + $this->temp_exts = array('ahz', 'jhz', 'abc', 'xyz', 'cb2', 'tmp', 'olo', 'oar', 'ozz'); + $this->template = $this->configs['template_dir']; + + if (!defined("IS_CAPTCHA_LOADING")) + $_SESSION['total_captchas_loaded'] = 0; + + $this->clean_requests(); + + if (!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + if (!isset($_GET['time'])) + $_GET['time'] = 'all_time'; + if (!isset($_GET['page'])) + $_GET['page'] = 1; + } + + function getBasedir() + { + $dirname = dirname(__FILE__); + $dirname = preg_replace(array('/includes/', '/classes/'), '', $dirname); + $dirname = substr($dirname, 0, strlen($dirname) - 2); + return $dirname == '/' ? '' : $dirname; + } + + function addJS($files) + { + if (is_array($files)) + { + foreach ($files as $key => $file) + $this->JSArray[][$key] = $file; + } else + { + $this->JSArray[$files] = 'global'; + } + } + + function add_js($files) + { + $this->addJS($files); + } + + function addAdminJS($files) + { + if (is_array($files)) + { + foreach ($files as $key => $file) + $this->AdminJSArray[$key] = $file; + } else + { + $this->AdminJSArray[$files] = 'global'; + } + } + + /** + * Function add_header() + * this will be used to add new files in header array + * this is basically for plugins + * @param FILE + * @param PAGES (array) + */ + function add_header($file, $place = 'global') + { + if (!is_array($place)) + { + $place = array($place); + } + $this->header_files[$file] = $place; + } + + /** + * Function add_admin_header() + * this will be used to add new files in header array + * this is basically for plugins + * @param FILE + * @param PAGES (array) + */ + function add_admin_header($file, $place = 'global') + { + if (!is_array($place)) + { + $place = array($place); + } + $this->admin_header_files[$file] = $place; + } + + /** + * Function used to get list of function of any type + * @param : type (category,title,date etc) + */ + function getFunctionList($type) + { + return $this->actionList[$type]; + } + + /** + * Function used to get anchors that are registered in plugins + */ + function get_anchor_codes($place) + { + //Geting list of codes available for $place + $list = $this->anchorList[$place]; + return $list; + } + + /** + * Function used to get function of anchors that are registered in plugins + */ + function get_anchor_function_list($place) + { + //Geting list of functions + $list = $this->anchor_function_list[$place]; + return $list; + } + + /** + * Function used to create admin menu + */ + function get_admin_menu() + { + + $menu_array = array + ( + //Statistics + 'Stats And Configurations' => + array( + 'Reports & Stats' => 'reports.php', + 'Website Configurations' => 'main.php', + 'Email Settings' => 'email_settings.php', + 'Language Settings' => 'language_settings.php', + 'Add New Phrases' => 'add_phrase.php', + 'Manage Pages' => 'manage_pages.php', + 'Manage Comments' => 'comments.php', + ), + //Video + 'Videos' => + array( + 'Videos Manager' => 'video_manager.php', + 'Manage Categories' => 'category.php', + 'List Flagged Videos' => 'flagged_videos.php', + 'Upload Videos' => 'mass_uploader.php', + 'List Inactive Videos' => 'video_manager.php?search=search&active=no' + ), + //Users + 'Users' => + array( + 'Manage Members' => 'members.php', + 'Add Member' => 'add_member.php', + 'Manage categories' => 'user_category.php', + 'User Levels' => 'user_levels.php', + 'Search Members' => 'members.php?view=search', + 'Inactive Only' => 'members.php?search=yes&status=ToActivate', + 'Active Only' => 'members.php?search=yes&status=Ok', + 'Reported Users' => 'flagged_users.php', + 'Mass Email' => 'mass_email.php' + ), + //Groups + 'Groups' => + array( + 'Add Group' => 'add_group.php', + 'Manage Groups' => 'groups_manager.php', + 'Manage Categories' => 'group_category.php?view=show_category', + 'View Inactive Groups' => 'groups_manager.php?active=no&search=yes', + 'View Reported Groups' => 'flagged_groups.php', + ), + //Advertisments + 'Advertisement' => + array( + 'Manage Advertisments' => 'ads_manager.php', + 'Manage Placements' => 'ads_add_placements.php', + ), + //Template Manager + 'Templates And Players' => + array( + 'Templates Manager' => 'templates.php', + 'Templates Editor' => 'template_editor.php', + 'Players Manager' => 'manage_players.php', + 'Player Settings' => 'manage_players.php?mode=show_settings' + ), + //Plugin Manager + 'Plugin Manager' => + array( + 'Plugin Manager' => 'plugin_manager.php' + ), + //Tool Box + 'Tool Box' => + array( + //'ClipBucket Module Manager'=>'module_manager.php', + 'PHP Info' => 'phpinfo.php', + 'Server Modules Info' => 'cb_mod_check.php', + 'Conversion Queue Manager' => 'cb_conversion_queue.php', + 'ReIndexer' => 'reindex_cb.php', + 'Conversion Lab α' => 'conversion_lab.php', + 'Repair video duration' => 'repair_vid_duration.php', + 'Maintenance' => 'maintenance.php', + //'View Encoding Status'=>'', + ), + ); + + + return $menu_array; + } + + function LatestAdminMenu() + { + global $userquery; + $per = $userquery->get_user_level(userid()); + if ($per['web_config_access'] == "yes") + $NewMenu['Stats And Configurations'] = array( + 'Reports & Stats' => 'reports.php', + 'Website Configurations' => 'main.php', + 'Email Settings' => 'email_settings.php', + 'Language Settings' => 'language_settings.php', + 'Add New Phrases' => 'add_phrase.php', + 'Manage Pages' => 'manage_pages.php', + 'Manage Comments' => 'comments.php' + ); + if ($per['video_moderation'] == "yes") + $NewMenu['Videos'] = array( + 'Videos Manager' => 'video_manager.php', + 'Manage Categories' => 'category.php', + 'List Flagged Videos' => 'flagged_videos.php', + 'Upload Videos' => 'mass_uploader.php', + 'List Inactive Videos' => 'video_manager.php?search=search&active=no', + 'Notification settings' => 'notification_settings.php' + ); + + if ($per['member_moderation'] == "yes") + { + $NewMenu['Users'] = array( + 'Manage Members' => 'members.php', + 'Add Member' => 'add_member.php', + 'Manage categories' => 'user_category.php', + + 'Search Members' => 'members.php?view=search', + 'Inactive Only' => 'members.php?search=yes&status=ToActivate', + 'Active Only' => 'members.php?search=yes&status=Ok', + 'Reported Users' => 'flagged_users.php', + 'Mass Email' => 'mass_email.php' + ); + + if($per['allow_manage_user_level']=='yes' || $userquery->level == 1) + $NewMenu['Users']['User Levels'] = 'user_levels.php'; + } + + + if ($per['group_moderation'] == "yes") + $NewMenu['Groups'] = array('Add Group' => 'add_group.php', + 'Manage Groups' => 'groups_manager.php', + 'Manage Categories' => 'group_category.php?view=show_category', + 'View Inactive Groups' => 'groups_manager.php?active=no&search=yes', + 'View Reported Groups' => 'flagged_groups.php'); + + if ($per['ad_manager_access'] == "yes") + $NewMenu['Advertisement'] = array( + 'Manage Advertisments' => 'ads_manager.php', + 'Manage Placements' => 'ads_add_placements.php' + ); + if ($per['manage_template_access'] == "yes") + $NewMenu['Templates And Players'] = array('Templates Manager' => 'templates.php', + 'Templates Editor' => 'template_editor.php', + 'Players Manager' => 'manage_players.php', + 'Player Settings' => 'manage_players.php?mode=show_settings'); + + + if ($per['plugins_moderation'] == "yes") + $NewMenu['Plugin Manager'] = array('Plugin Manager' => 'plugin_manager.php'); + + if ($per['tool_box'] == "yes") + $NewMenu['Tool Box'] = array('PHP Info' => 'phpinfo.php', + 'View online users' => 'online_users.php', + 'Server Modules Info' => 'cb_mod_check.php', + 'Conversion Queue Manager' => 'cb_conversion_queue.php', + 'ReIndexer' => 'reindex_cb.php', + 'Conversion Lab α' => 'conversion_lab.php', + 'Repair video duration' => 'repair_vid_duration.php'); + + if ($per['web_config_access'] == "yes") + $NewMenu['Tool Box']['Maintenance'] = 'maintenance.php'; + return $NewMenu; + } + + /** + * Function used to assign ClipBucket configurations + */ + function get_configs() + { + global $myquery; + return $myquery->Get_Website_Details(); + } + + /** + * Funtion cused to get list of countries + */ + function get_countries($type = iso2) + { + global $db; + $results = $db->select(tbl("countries"), "*"); + switch ($type) + { + case id: + foreach ($results as $result) { + $carray[$result['country_id']] = $result['name_en']; + } + break; + case iso2: + foreach ($results as $result) { + $carray[$result['iso2']] = $result['name_en']; + } + break; + case iso3: + foreach ($results as $result) { + $carray[$result['iso3']] = $result['name_en']; + } + break; + default: + foreach ($results as $result) { + $carray[$result['country_id']] = $result['name_en']; + } + break; + } + + return $carray; + } + + /** + * Function used to set show_page = false or true + */ + function show_page($val = true) + { + $this->show_page = $val; + } + + /** + * Function used to set template (Frontend) + */ + function set_the_template() + { + global $cbtpl, $myquery; + $template = $this->template; + + if (isset($_SESSION['the_template']) && $cbtpl->is_template($_SESSION['the_template'])) + $template = $_SESSION['the_template']; + if ($_GET['template']) + { + if (is_dir(STYLES_DIR . '/' . $_GET['template']) && $_GET['template']) + $template = $_GET['template']; + } + if (isset($_GET['set_the_template']) && $cbtpl->is_template($_GET['set_the_template'])) + $template = $_SESSION['the_template'] = $_GET['set_the_template']; + if (!is_dir(STYLES_DIR . '/' . $template) || !$template) + $template = 'cbv2new'; + if (!is_dir(STYLES_DIR . '/' . $template) || !$template) + { + $template = $cbtpl->get_any_template(); + } + + if (!is_dir(STYLES_DIR . '/' . $template) || !$template) + exit("Unable to find any template, please goto ClipBucket Support!"); + + + if ($_GET['set_template']) + { + $myquery->set_template($template); + } + + // + return $this->template = $template; + } + + /** + * Function used to list available extension for clipbucket + */ + function list_extensions() + { + $exts = $this->configs['allowed_types']; + $exts = preg_replace('/ /', '', $exts); + $exts = explode(',', $exts); + $new_form = ''; + foreach ($exts as $ext) { + if (!empty($new_form)) + $new_form .=";"; + $new_form .= "*.$ext"; + } + + return $new_form; + } + + /** + * Function used to load head menu + */ + function head_menu($params = NULL) + { + global $cbpage; + $this->head_menu[] = array('name' => lang("menu_home"), 'link' => BASEURL, "this" => "home", "section" => "home", "extra_attr" => ""); + $this->head_menu[] = array('name' => lang("videos"), 'link' => cblink(array('name' => 'videos')), "this" => "videos", "section" => "home"); + $this->head_menu[] = array('name' => lang("menu_channels"), 'link' => cblink(array('name' => 'channels')), "this" => "channels", "section" => "channels"); + $this->head_menu[] = array('name' => lang("groups"), 'link' => cblink(array('name' => 'groups')), "this" => "groups", "section" => "groups"); + $this->head_menu[] = array('name' => lang("Collections"), 'link' => cblink(array('name' => 'collections')), "this" => "collections", "section" => "collections"); + if (!userid()) + $this->head_menu[] = array('name' => lang("signup"), 'link' => cblink(array('name' => 'signup')), "this" => "signup"); + + $this->head_menu[] = array('name' => lang("photos"), 'link' => cblink(array('name' => 'photos')), "this" => "photos"); + + /* Calling custom functions for headMenu. This can be used to add new tabs */ + //cb_call_functions('headMenu'); + if ($params['assign']) + assign($params['assign'], $this->head_menu); + else + return $this->head_menu; + } + + function cbMenu($params = NULL) + { + $this->head_menu($params); + if (!$params['tag']) + //$params['tag'] = 'li'; + if (!$params['class']) + $params['class'] = ''; + + + if (!$params['getSubTab']) + $params['getSubTab'] = ''; + + if (!$params['parentTab']) + $params['parentTab'] = ''; + + if (!$params['selectedTab']) + $params['selectedTab'] = ''; + { + $headMenu = $this->head_menu; + + $custom = $this->custom_menu; + if (is_array($custom)) + $headMenu = array_merge($headMenu, $custom); + /* Excluding tabs from menu */ + if ($params['exclude']) + { + if (is_array($params['exclude'])) + $exclude = $params['exclude']; + else + $exclude = explode(",", $params['exclude']); + + foreach ($headMenu as $key => $hm) { + foreach ($exclude as $ex) { + $ex = trim($ex); + if (strtolower(trim($hm['name'])) == strtolower($ex)) + unset($headMenu[$key]); + } + } + } + + $output = ''; + //if(($params['tag'])) + // $output .= "<".$params['tag'].">"; + foreach ($headMenu as $menu) { + if (isSectionEnabled($menu['this'])) + { + $selected = current_page(array("page" => $menu['this'])); + + $output .= "
  • "; + $output .= $menu['name'] . ""; + $output .= "
  • "; + } + } + //if(($params['tag'])) + // $output .= ""; + + if ($params['echo']) + echo $output; + else + return $output; + } + } + + /** + * Function used to load head menu + */ + function foot_menu($params = NULL) + { + global $cbpage; + $this->foot_menu[] = array('name' => lang("menu_home"), 'link' => BASEURL, "this" => "home"); + $this->foot_menu[] = array('name' => lang("contact_us"), 'link' => cblink(array('name' => 'contact_us')), "this" => "home"); + + + if (userid()) + $this->foot_menu[] = array('name' => lang("my_account"), 'link' => cblink(array('name' => 'my_account')), "this" => "home"); + + $pages = $cbpage->get_pages(array('active' => 'yes', 'display_only' => 'yes', 'order' => 'page_order ASC')); + + if ($pages) + foreach ($pages as $p) + $this->foot_menu[] = array('name' => $p['page_name'], 'link' => $cbpage->page_link($p), "this" => "home"); + +// if($cbpage->is_active(2)) +// $this->foot_menu[] = array('name'=>lang("privacy_policy"),'link'=>$cbpage->get_page_link(2),"this"=>"home"); +// +// if($cbpage->is_active(3)) +// $this->foot_menu[] = array('name'=>lang("terms_of_serivce"),'link'=>$cbpage->get_page_link(3),"this"=>"home"); +// +// if($cbpage->is_active(4)) +// $this->foot_menu[] = array('name'=>lang("help"),'link'=>$cbpage->get_page_link(4),"this"=>"groups"); +// + if ($params['assign']) + assign($params['assign'], $this->foot_menu); + else + return $this->foot_menu; + } + + /** + * Function used to call footer + */ + function footer() + { + ANCHOR(array('place' => 'the_footer')); + } + + /** + * Function used to get News From ClipBucket Blog + */ + function get_cb_news() + { + $feeds = 5; + $text = 400; + + //if($_SERVER['HTTP_HOST']!='localhost') + $url = 'http://blog.clip-bucket.com/feed/'; + + $news = xml2array($url); + if (!$news) + { + return false; + } else + { + $items = array(); + $item = $news['rss']['channel']['item']; + for ($i = 0; $i < $feeds; $i++) + $items[] = $item[$i]; + + return $items; + } + } + + /** + * Fucntion used to clean requests + */ + function clean_requests() + { + $posts = $_POST; + $gets = $_GET; + $request = $_REQUEST; + + //Cleaning post.. + if (is_array($posts) && count($posts) > 0) + { + $clean_posts = array(); + foreach ($posts as $key => $post) { + if (!is_array($post)) + { + $clean_posts[$key] = preg_replace(array('/\|no_mc\|/', '/\|f\|/'), '', $post); + } + else + $clean_posts[$key] = $post; + } + $_POST = $clean_posts; + } + + //Cleaning get.. + if (is_array($gets) && count($gets) > 0) + { + $clean_gets = array(); + foreach ($gets as $key => $get) { + if (!is_array($get)) + { + $clean_gets[$key] = preg_replace(array('/\|no_mc\|/', '/\|f\|/'), '', $get); + } + else + $clean_gets[$key] = $get; + } + $_GET = $clean_gets; + } + + //Cleaning request.. + if (is_array($request) && count($request) > 0) + { + $clean_request = array(); + foreach ($request as $key => $request) { + if (!is_array($request)) + { + $clean_request[$key] = preg_replace(array('/\|no_mc\|/', '/\|f\|/'), '', $request); + } + else + $clean_request[$key] = $request; + } + $_REQUEST = $clean_request; + } + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/Services_JSON.php b/upload/includes/classes/Services_JSON.php new file mode 100644 index 00000000..c80c8b4b --- /dev/null +++ b/upload/includes/classes/Services_JSON.php @@ -0,0 +1,807 @@ + + * @author Matt Knapp + * @author Brett Stimmerman + * @copyright 2005 Michal Migurski + * @version CVS: $Id: Services_JSON.php 267 2010-04-01 00:09:39Z fwhite $ + * @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: + * + * + * // 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); + * + */ + +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) + { + + } + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/actions.class.php b/upload/includes/classes/actions.class.php new file mode 100644 index 00000000..820e9526 --- /dev/null +++ b/upload/includes/classes/actions.class.php @@ -0,0 +1,664 @@ +obj_class}->{$this->check_func}($id); + */ + var $check_func = 'video_exists'; + + /** + * This holds all options that are listed when user wants to report + * a content ie - copyrighted content - voilance - sex or something alike + * ARRAY = array('Copyrighted','Nudity','bla','another bla'); + */ + var $report_opts = array(); + + + /** + * share email template name + */ + var $share_template_name = 'video_share_template'; + + + + /** + * Var Array for replacing text of email templates + * see docs.clip-bucket.com for more details + */ + var $val_array = array(); + + + /** + * initializing + */ + function init() + { + $this->report_opts = array + ( + lang('inapp_content'), + lang('copyright_infring'), + lang('sexual_content'), + lang('violence_replusive_content'), + lang('spam'), + lang('disturbing'), + lang('other') + ); + } + + /** + * Function used to add content to favorits + */ + + function add_to_fav($id) + { + global $db; + $id = mysql_clean($id); + //First checking weather object exists or not + if($this->exists($id)) + { + if(userid()) + { + if(!$this->fav_check($id)) + { + + $db->insert(tbl($this->fav_tbl),array('type','id','userid','date_added'),array($this->type,$id,userid(),NOW())); + addFeed(array('action'=>'add_favorite','object_id' => $id,'object'=>'video')); + + //Loggin Favorite + $log_array = array + ( + 'success'=>'yes', + 'details'=> "added ".$this->name." to favorites", + 'action_obj_id' => $id, + 'action_done_id' => $db->insert_id(), + ); + insert_log($this->name.'_favorite',$log_array); + + e(sprintf(lang('add_fav_message'),$this->name),'m'); + }else{ + e(sprintf(lang('already_fav_message'),$this->name)); + } + }else{ + e(lang("you_not_logged_in")); + } + }else{ + e(sprintf(lang("obj_not_exists"),$this->name)); + } + } + + + function add_to_favorites($id){ return $this->add_to_fav($id); } + function add_favorites($id){ return $this->add_to_fav($id); } + function add_fav($id){ return $this->add_to_fav($id); } + + /** + * Function used to check weather object already added to favorites or not + */ + function fav_check($id,$uid=NULL) + { + global $db; + + $id = mysql_clean($id); + + if(!$uid) + $uid =userid(); + $results = $db->select(tbl($this->fav_tbl),"favorite_id"," id='".$id."' AND userid='".$uid."' AND type='".$this->type."'"); + if($db->num_rows>0) + return true; + else + return false; + + } + + /** + * Function used to check weather object exists or not + */ + function exists($id) + { + $id = mysql_clean($id); + $obj = $this->obj_class; + global ${$obj}; + $obj = ${$obj}; + $func = $this->check_func; + return $obj->{$func}($id); + } + + + /** + * Function used to report a content + */ + + function report_it($id) + { + global $db; + $id = mysql_clean($id); + //First checking weather object exists or not + if($this->exists($id)) + { + if(userid()) + { + if(!$this->report_check($id)) + { + $db->insert(tbl($this->flag_tbl),array('type','id','userid','flag_type','date_added'), + array($this->type,$id,userid(),mysql_clean(post('flag_type')),NOW())); + e(sprintf(lang('obj_report_msg'),$this->name),'m'); + }else{ + e(sprintf(lang('obj_report_err'),$this->name)); + } + }else{ + e(lang("you_not_logged_in")); + } + }else{ + e(sprintf(lang("obj_not_exists"),$this->name)); + } + } + function flag_it($id){ return $this->report_id($id); } + + + /** + * Function used to delete flags + */ + function delete_flags($id) + { + global $db; + $id = mysql_clean($id); + $db->delete(tbl($this->flag_tbl),array("id","type"),array($id,$this->type)); + e(sprintf(lang("type_flags_removed"),$this->name),"m"); + } + + + /** + * Function used to check weather user has already reported the object or not + */ + function report_check($id) + { + global $db; + $id = mysql_clean($id); + $results = $db->select(tbl($this->flag_tbl),"flag_id"," id='".$id."' AND type='".$this->type."' AND userid='".userid()."'"); + if($db->num_rows>0) + return true; + else + return false; + } + + + + /** + * Function used to content + */ + function share_content($id) + { + global $db,$userquery; + $ok = true; + $tpl = $this->share_template_name; + $var = $this->val_array; + $id = mysql_clean($id); + //First checking weather object exists or not + if($this->exists($id)) + { + global $eh; + if(userid()) + { + + $post_users = mysql_clean(post('users')); + $users = explode(',',$post_users); + if(is_array($users) && !empty($post_users)) + { + foreach($users as $user) + { + if(!$userquery->user_exists($user) && !isValidEmail($user)) + { + e(sprintf(lang('user_no_exist_wid_username'),$user)); + $ok = false; + break; + } + + $email = $user; + if(!isValidEmail($user)) + $email = $userquery->get_user_field_only($user,'email'); + $emails_array[] = $email; + } + + if($ok) + { + global $cbemail; + $tpl = $cbemail->get_template($tpl); + $more_var = array + ('{user_message}' => post('message'),); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = $cbemail->replace($tpl['email_template'],$var); + + //Setting Emails + $emails = implode(',',$emails_array); + + //Now Finally Sending Email + $from = $userquery->get_user_field_only(username(),"email"); + + cbmail(array('to'=>$emails_array,'from'=>$from,'from_name'=>username(),'subject'=>$subj,'content'=>$msg,'use_boundary'=>true)); + e(sprintf(lang("thnx_sharing_msg"),$this->name),'m'); + + } + }else{ + e(sprintf(lang("share_video_no_user_err"),$this->name)); + } + + }else{ + e(lang("you_not_logged_in")); + } + }else{ + e(sprintf(lang("obj_not_exists"),$this->name)); + } + } + + + /** + * Get Used Favorites + */ + function get_favorites($params) + { + global $db; + + $uid = $params['userid']; + $limit = $params['limit']; + $cond = $params['cond']; + $order = $params['order']; + + if(!$uid) + $uid=userid(); + if($cond) + $cond = " AND ".$cond; + + if(!$params['count_only']) + { + $results = $db->select(tbl($this->fav_tbl.",".$this->type_tbl),"*"," ".tbl($this->fav_tbl).".type='".$this->type."' + AND ".tbl($this->fav_tbl).".userid='".$uid."' + AND ".tbl($this->type_tbl).".".$this->type_id_field." = ".tbl($this->fav_tbl).".id".$cond,$limit,$order); + } + if($params['count_only']) + { + return $results = $db->count(tbl($this->fav_tbl.",".$this->type_tbl),"*"," ".tbl($this->fav_tbl).".type='".$this->type."' + AND ".tbl($this->fav_tbl).".userid='".$uid."' + AND ".tbl($this->type_tbl).".".$this->type_id_field." = ".tbl($this->fav_tbl).".id".$cond); + } + + if($db->num_rows>0) + return $results; + else + return false; + } + + /** + * Function used to count total favorites only + */ + function total_favorites() + { + global $db; + return $db->count(tbl($this->fav_tbl),"favorite_id"," type='".$this->type."'"); + } + + + /** + * Function used remove video from favorites + */ + function remove_favorite($fav_id,$uid=NULL) + { + global $db; + if(!$uid) + $uid=userid(); + if($this->fav_check($fav_id,$uid)) + { + $fav_id = mysql_clean($fav_id); + $uid = mysql_clean($uid); + $db->delete(tbl($this->fav_tbl),array('userid','type','id'),array($uid,$this->type,$fav_id)); + e(sprintf(lang('fav_remove_msg'),$this->name),'m'); + }else + e(sprintf(lang('unknown_favorite'),$this->name)); + } + + + /** + * Function used to get object flags + */ + function get_flagged_objects($limit=NULL) + { + global $db; + $type = $this->type; + $results = $db->select(tbl($this->flag_tbl.",".$this->type_tbl),"*, + count(*) AS total_flags",tbl($this->flag_tbl).".id = ".tbl($this->type_tbl).".".$this->type_id_field." + AND type='".$this->type."' GROUP BY ".tbl($this->flag_tbl).".id ,".tbl($this->flag_tbl).".type ",$limit); + if($db->num_rows>0) + return $results; + else + return false; + } + + /** + * Function used to get all flags of an object + */ + function get_flags($id) + { + global $db; + $type = $this->type; + $results = $db->select(tbl($this->flag_tbl),"*","id = '$id' AND type='".$this->type."'"); + if($db->num_rows>0) + return $results; + else + return false; + } + + + /** + * Function used to count object flags + */ + function count_flagged_objects() + { + global $db; + $type = $this->type; + $results = $db->select(tbl($this->flag_tbl.",".$this->type_tbl),"id",tbl($this->flag_tbl).".id = ".tbl($this->type_tbl).".".$this->type_id_field." + AND type='".$this->type."' GROUP BY ".tbl($this->flag_tbl).".id ,".tbl($this->flag_tbl).".type "); + if($db->num_rows>0) + return count($results); + else + return 0; + } + + + /** + * Function used to create new playlist + * @param ARRAY + */ + function create_playlist($params) + { + global $db; + $name = mysql_clean($params['name']); + if(!userid()) + e(lang("please_login_create_playlist")); + elseif(empty($name)) + e(lang("please_enter_playlist_name")); + elseif($this->playlist_exists($name,userid(),$this->type)) + e(sprintf(lang("play_list_with_this_name_arlready_exists"),$name)); + else + { + $db->insert(tbl($this->playlist_tbl),array("playlist_name","userid","date_added","playlist_type"), + array($name,userid(),now(),$this->type)); + e(lang("new_playlist_created"),"m"); + $pid = $db->insert_id(); + + //Logging Playlist + $log_array = array + ( + 'success'=>'yes', + 'details'=> "created playlist", + 'action_obj_id' => $pid, + ); + + insert_log('add_playlist',$log_array); + + return $pid; + } + + return false; + } + + /** + * Function used to check weather playlist already exists or not + */ + function playlist_exists($name,$user,$type=NULL) + { + global $db; + if($type) + $type = $this->type; + $count = $db->count(tbl($this->playlist_tbl),"playlist_id"," userid='$user' AND playlist_name='$name' AND playlist_type='".$type."' "); + + if($count) + return true; + else + return false; + } + + /** + * Function used to get playlist + */ + function get_playlist($id,$user=NULL) + { + global $db; + + $user_cond; + if($user) + $user_cond = " AND userid='$user'"; + + $result = $db->select(tbl($this->playlist_tbl),"*"," playlist_id='$id' $user_cond"); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + + /** + * Function used to add new item in playlist + */ + function add_playlist_item($pid,$id) + { + global $db; + + if(!$this->exists($id)) + e(sprintf(lang("obj_not_exists"),$this->name)); + elseif(!$this->get_playlist($pid)) + e(lang("playlist_not_exist")); + elseif(!userid()) + e(lang('you_not_logged_in')); + elseif($this->playlist_item_with_obj($id,$pid)) + e(sprintf(lang('this_already_exist_in_pl'),$this->name)); + else + { + $db->insert(tbl($this->playlist_items_tbl),array("object_id","playlist_id","date_added","playlist_item_type","userid"), + array($id,$pid,now(),$this->type,userid())); + e(sprintf(lang('this_thing_added_playlist'),$this->name),"m"); + return $db->insert_id(); + } + } + + + /** + * Function use to delete playlist item + */ + function delete_playlist_item($id) + { + global $db; + $item = $this->playlist_item($id); + if(!$item) + e(lang("playlist_item_not_exist")); + elseif($item['userid']!=userid() && !has_access('admin_access')) + e(lang("you_dont_hv_permission_del_playlist")); + else + { + $db->delete(tbl($this->playlist_items_tbl),array("playlist_item_id"),array($id)); + e(lang("playlist_item_delete"),"m"); + } + } + + /** + * Function used to check weather playlist item exists or not + */ + function playlist_item($id) + { + global $db; + $result = $db->select(tbl($this->playlist_items_tbl),"*"," playlist_item_id='$id' "); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to check weather playlist item exists or not + */ + function playlist_item_with_obj($id,$pid=NULL) + { + global $db; + $pid_cond = ""; + if($pid) + $pid_cond = " AND playlist_id='$pid'"; + $result = $db->select(tbl($this->playlist_items_tbl),"*"," object_id='$id' $pid_cond"); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to update playlist details + */ + function edit_playlist($params) + { + global $db; + $name = mysql_clean($params['name']); + $pdetails = $this->get_playlist($params['pid']); + + if(!$pdetails) + e(lang("playlist_not_exist")); + elseif(!userid()) + e(lang("you_not_logged_in")); + elseif(empty($name)) + e(lang("please_enter_playlist_name")); + elseif($this->playlist_exists($name,userid()) && $pdetails['playlist_name'] !=$name) + e(sprintf(lang("play_list_with_this_name_arlready_exists"),$name)); + else + { + $db->update(tbl($this->playlist_tbl),array("playlist_name"), + array($name)," playlist_id='".$params['pid']."'"); + e(lang("play_list_updated"),"m"); + } + } + + /** + * Function used to delete playlist + */ + function delete_playlist($id) + { + global $db; + $playlist = $this->get_playlist($id); + if(!$playlist) + e(lang("playlist_not_exist")); + elseif($playlist['userid']!=userid() && !has_access('admin_access',TRUE)) + e(lang("you_dont_hv_permission_del_playlist")); + else + { + $db->delete(tbl($this->playlist_tbl), + array("playlist_id"),array($id)); + $db->delete(tbl($this->playlist_items_tbl), + array("playlist_id"),array($id)); + e(lang("playlist_delete_msg"),"m"); + } + } + + /** + * Function used to get playlists + */ + function get_playlists() + { + global $db; + $result = $db->select(tbl($this->playlist_tbl),"*"," playlist_type='".$this->type."' AND userid='".userid()."'"); + + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to get playlist items + */ + function get_playlist_items($pid) + { + global $db; + $result = $db->select(tbl($this->playlist_items_tbl),"*","playlist_id='$pid'"); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to count playlist item + */ + function count_playlist_items($id) + { + global $db; + return $db->count(tbl($this->playlist_items_tbl),"playlist_item_id","playlist_id='$id'"); + } + + + /** + * Function used to count total playlist or items + */ + function count_total_playlist($item=false) + { + global $db; + if(!$item) + { + $result = $db->count(tbl($this->playlist_tbl),"*"," playlist_type='".$this->type."' "); + return $result; + }else{ + return $db->count(tbl($this->playlist_items_tbl),"playlist_item_id"," playlist_item_type='".$this->type."'"); + } + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/ads.class.php b/upload/includes/classes/ads.class.php new file mode 100644 index 00000000..ad62e37a --- /dev/null +++ b/upload/includes/classes/ads.class.php @@ -0,0 +1,315 @@ +count(tbl("ads_data"),"ad_id"," ad_name='$name'"); + + if($count>0){ + e(lang('ad_exists_error2')); + }else + { + $db->insert(tbl("ads_data"),array("ad_category","ad_name","ad_placement","ad_code","ad_status","date_added"), + array($category,$name,$placement,"|no_mc|".$code,$status,now())); + $msg = e(lang('ad_add_msg'),'m'); + } + return $msg; + } + } + + + /** + * Function used to set advertisment status + * 1, to set as activate + * 0, to set as deactivate + */ + + function ChangeAdStatus($status,$id) + { + global $db; + + if($status >1) + $status = 1; + if($status<0) + $status = 0; + + if($this->ad_exists($id)) + { + $db->update(tbl("ads_data"),array("ad_status"),array($status)," ad_id='".mysql_clean($id)."'"); + if($status == '0') + $show_status = lang('ad_deactive'); + else + $show_status = lang('ad_active'); + e(lang('ad_msg').$show_status,"m"); + }else + e(lang("ad_exists_error1")); + } + + /** + * Function used to edit advertisment + * @params Array + */ + function EditAd($array=NULL) + { + global $db; + if(!$array) + $array = $_POST; + + $placement = mysql_clean($array['placement']); + $name = mysql_clean($array['name']); + $code = mysql_real_escape_string(htmlspecialchars($array['code'])); + $category = mysql_clean(@$array['category']); + $id = $array['ad_id']; + + if(!$this->ad_exists($id)) + e(lang("ad_exists_error1")); + elseif(empty($name)) + e(lang('ad_name_error')); + else + { + $db->update(tbl("ads_data"),array("ad_placement","ad_name","ad_category","ad_code","ad_status"), + array($placement,$name,$category,"|no_mc|".$code,$array['status'],$id)," ad_id='$id' "); + e(lang('ad_update_msg'),"m"); + } + } + + /** + * Function used to delete advertisments + * @param Ad Id + */ + function DeleteAd($id) + { + global $db; + if(!$this->ad_exists($id)) + e(lang("ad_exists_error1")); + else + { + $db->Execute("DELETE FROM ".tbl("ads_data")." WHERE ad_id='".$id."'"); + $msg = e(lang('ad_del_msg'),"m"); + } + } + + /** + * Function used to remove advertismetn placement + */ + function RemovePlacement($placement) + { + global $db; + if(!$this->get_placement($placement)) + e(lang("ad_placement_err4")); + else + { + $db->execute("Delete from ".tbl("ads_data")." WHERE ad_placement='".$placement."'"); + $db->execute("Delete from ".tbl("ads_placements")." WHERE placement='".$placement."'"); + e(lang('ad_placment_delete_msg'),"m"); + } + } + + + /** + * Function used to add new palcement + * @param Array + * Array [0] => placement name + * Array [1] => placement code + */ + function AddPlacement($array) + { + global $db; + if(empty($array[0])){ + $msg = e(lang('ad_placement_err2')); + }elseif(empty($array[1])){ + $msg = e(lang('ad_placement_err3')); + } + if(empty($msg)) + { + if($this->get_placement($array[1])) + e(lang('ad_placement_err1')); + else + { + $db->insert(tbl("ads_placements"),array("placement_name","placement"),array($array[0],$array[1])); + e(lang('ad_placement_msg'),"m"); + } + } + } + + /** + * FUNCTION USED TO GET ADVERTISMENT FROM DATABSE WITH LOWEST IMPRESSION + * @param : placement_code + * @param : num_of_ads + * return advertisment + */ + function getAd($placement_code,$limit=1) + { + global $db,$ads_array; + if($limit==1) + { + //Creating Query, Not to select duplicate Ads + foreach($ads_array as $ad_id) + { + if(is_numeric($ad_id)) + $query_param .= " AND ad_id <> '".$ad_id."' "; + } + $limit_query = ' LIMIT 1'; + $order = ' ORDER BY ad_impressions ASC '; + //Return Ad + $query = "SELECT ad_id,ad_code FROM ".tbl("ads_data")." + WHERE ad_placement = '".$placement_code."' + AND ad_status='1' + "; + $code_array = $db->GetRow($query.$query_param.$order.$limit_query); + + //Checking If there is no code, then try to get duplicate ad + if(empty($code_array['ad_id'])) + $code_array = $db->GetRow($query.$order.$limit_query); + + $ads_array[] = $code_array['ad_id']; + + //Incrementing Ad Impression + $this->incrementImpression($code_array['ad_id']); + return stripslashes(htmlspecialchars_decode($code_array['ad_code'])); + + }else{ + /*In that case, get all '$limit' + ads from database and do the same + as we did with the single ad*/ + } + } + + + /** + * FUNCTION USED TO INCREASE AD IMPRESSIONGS + * @param ad_id + */ + function incrementImpression($ad_id) + { + global $db; + $query = "UPDATE ".tbl("ads_data")." SET ad_impressions = ad_impressions+1 WHERE ad_id='".$ad_id."'"; + $db->Execute($query); + } + + + /** + * Function usd to get all placemetns + */ + function get_placements() + { + global $db; + + $result = $db->select(tbl("ads_placements")); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to get all advertisments + */ + function get_advertisements() + { + global $db; + + $result = $db->select(tbl("ads_data")); + if($db->num_rows>0) + return $result; + else + return false; + + } + + /** + * Function used to get placement + */ + function get_placement($place) + { + global $db; + $result = $db->select(tbl("ads_placements"),"*"," placement='$place' OR placement_id='$place' "); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to create placement name + */ + function get_placement_name($place) + { + $details = $this->get_placement($place); + if($details) + return $details['placement_name']; + else + return false; + } + + /** + * Function used to get advertismetn + */ + function get_ad_details($id) + { + global $db; + $result = $db->select(tbl("ads_data"),"*"," ad_placement='$id' OR ad_id='$id'"); + if($db->num_rows>0) + { + $result = $result[0]; + $result['ad_code'] = stripslashes($result['ad_code']); + return $result; + }else + return false; + } + + /** + * Function used to check weather advertisment exists or not + */ + function ad_exists($id) + { + global $db; + $count = $db->count(tbl("ads_data"),"ad_id"," ad_id='$id' "); + if($count>0) + return true; + else + return false; + } + + + /** + * Count ads in a placement + */ + function count_ads_in_placement($place) + { + global $db; + return $db->count(tbl("ads_data"),"ad_id"," ad_placement='$place'"); + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/calcdate.class.php b/upload/includes/classes/calcdate.class.php new file mode 100644 index 00000000..1ece5d2a --- /dev/null +++ b/upload/includes/classes/calcdate.class.php @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/upload/includes/classes/captcha/class.files.php b/upload/includes/classes/captcha/class.files.php new file mode 100644 index 00000000..5345dd1c --- /dev/null +++ b/upload/includes/classes/captcha/class.files.php @@ -0,0 +1,116 @@ +_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 "
    ";
    +            print_r($file_list);
    +            echo "
    "; + } + + // Returns file list + return $file_list; + } + + function _error($mensagem, $tipo) + { + if($tipo == E_USER_ERROR) + { + $topo = "Error!"; + } + else + { + $topo = "Notification"; + } + + echo "" . $topo . ": " . $mensagem . "

    "; + + if($tipo == E_USER_ERROR) + { + exit; + } + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/captcha/class.img_validator.php b/upload/includes/classes/captcha/class.img_validator.php new file mode 100644 index 00000000..92315e34 --- /dev/null +++ b/upload/includes/classes/captcha/class.img_validator.php @@ -0,0 +1,325 @@ + 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); + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/captcha/img.php b/upload/includes/classes/captcha/img.php new file mode 100644 index 00000000..e6592146 --- /dev/null +++ b/upload/includes/classes/captcha/img.php @@ -0,0 +1,12 @@ +generates_image($word,true); +?> \ No newline at end of file diff --git a/upload/includes/classes/captcha/img/bg1.jpg b/upload/includes/classes/captcha/img/bg1.jpg new file mode 100644 index 00000000..11a9448d Binary files /dev/null and b/upload/includes/classes/captcha/img/bg1.jpg differ diff --git a/upload/includes/classes/captcha/img/bg2.jpg b/upload/includes/classes/captcha/img/bg2.jpg new file mode 100644 index 00000000..560d09c0 Binary files /dev/null and b/upload/includes/classes/captcha/img/bg2.jpg differ diff --git a/upload/includes/classes/captcha/img/bg3.jpg b/upload/includes/classes/captcha/img/bg3.jpg new file mode 100644 index 00000000..29559a10 Binary files /dev/null and b/upload/includes/classes/captcha/img/bg3.jpg differ diff --git a/upload/includes/classes/captcha/img/bg4.jpg b/upload/includes/classes/captcha/img/bg4.jpg new file mode 100644 index 00000000..d1b20138 Binary files /dev/null and b/upload/includes/classes/captcha/img/bg4.jpg differ diff --git a/upload/includes/classes/captcha/img/fonts/arial.ttf b/upload/includes/classes/captcha/img/fonts/arial.ttf new file mode 100644 index 00000000..ff0815cd Binary files /dev/null and b/upload/includes/classes/captcha/img/fonts/arial.ttf differ diff --git a/upload/includes/classes/captcha/img/fonts/comicbd.ttf b/upload/includes/classes/captcha/img/fonts/comicbd.ttf new file mode 100644 index 00000000..75be5048 Binary files /dev/null and b/upload/includes/classes/captcha/img/fonts/comicbd.ttf differ diff --git a/upload/includes/classes/captcha/img/fonts/impact.ttf b/upload/includes/classes/captcha/img/fonts/impact.ttf new file mode 100644 index 00000000..114e6c19 Binary files /dev/null and b/upload/includes/classes/captcha/img/fonts/impact.ttf differ diff --git a/upload/includes/classes/captcha/img/fonts/monofont.ttf b/upload/includes/classes/captcha/img/fonts/monofont.ttf new file mode 100644 index 00000000..ec6c51b2 Binary files /dev/null and b/upload/includes/classes/captcha/img/fonts/monofont.ttf differ diff --git a/upload/includes/classes/captcha/img/fonts/verdana.ttf b/upload/includes/classes/captcha/img/fonts/verdana.ttf new file mode 100644 index 00000000..8f25a642 Binary files /dev/null and b/upload/includes/classes/captcha/img/fonts/verdana.ttf differ diff --git a/upload/includes/classes/captcha/index.php b/upload/includes/classes/captcha/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/classes/captcha/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/classes/captcha_simple.img.php b/upload/includes/classes/captcha_simple.img.php new file mode 100644 index 00000000..7538bf34 --- /dev/null +++ b/upload/includes/classes/captcha_simple.img.php @@ -0,0 +1,86 @@ +generateCode($characters); + /* font size will be 75% of the image height */ + $font_size = $height * 0.75; + $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream'); + /* set the colours */ + $background_color = imagecolorallocate($image, 255, 255, 255); + $text_color = imagecolorallocate($image, 0, 0, 0); + $noise_color = imagecolorallocate($image, 226, 82, 207); + $noise_color1 = imagecolorallocate($image, 64, 179, 255); + $noise_color2 = imagecolorallocate($image, 255 ,204, 190); + + /* generate random dots in background */ + for( $i=0; $i<($width*$height)/250; $i++ ) { + imageellipse($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color2); + } + /* generate random dots in background */ + for( $i=0; $i<($width*$height)/150; $i++ ) { + imagedashedline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color1); + } + /* generate random lines in background */ + for( $i=0; $i<($width*$height)/150; $i++ ) { + + imagedashedline($image, mt_rand(0,$width), mt_rand(0,$height), mt_rand(0,$width), mt_rand(0,$height), $noise_color); + } + /* create textbox and add text */ + $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die('Error in imagettfbbox function'); + $x = ($width - $textbox[4])/2; + $y = ($height - $textbox[5])/2; + imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font , $code) or die('Error in imagettftext function'); + + /* output captcha image to browser */ + imagejpeg($image); + imagedestroy($image); + $_SESSION['security_code'] = $code; + } + +} + +$width = isset($_GET['width']) ? $_GET['width'] : '120'; +$height = isset($_GET['height']) ? $_GET['height'] : '40'; +$characters = isset($_GET['characters']) && $_GET['characters'] > 1 ? $_GET['characters'] : '6'; + +$captcha = new CaptchaSecurityImages($width,$height,$characters); +?> \ No newline at end of file diff --git a/upload/includes/classes/category.class.php b/upload/includes/classes/category.class.php new file mode 100644 index 00000000..9b69d94a --- /dev/null +++ b/upload/includes/classes/category.class.php @@ -0,0 +1,866 @@ + + * This class is used to create + * and manage categories + * its an abstract class + * it will be used in custom plugins or built-in sections + * sections like videos, groups , channels etc use this category system + * + * this abstract class has some rules + * each section's category column should be named as "category" + * each section's category table must have same columns as video_categories + */ + + + +abstract class CBCategory +{ + var $cat_tbl = ''; //Name of category Table + var $section_tbl = ''; //Name of table that related to $cat_tbl + var $use_sub_cats = FALSE; // Set to true if you using Sub-Cateogires + var $cat_thumb_height = '125'; + var $cat_thumb_width = '125'; + var $default_thumb = 'no_thumb.jpg'; + + /** + * Function used to check weather category exists or not + */ + function category_exists($cid) + { + global $db; + return $this->get_category($cid); + } + + + /** + * Function used to get category details + */ + function get_category($cid) + { + global $db; + $results = $db->select(tbl($this->cat_tbl),"*"," category_id='$cid'"); + if($db->num_rows>0) + { + return $results[0]; + }else{ + return false; + } + } + + + /** + * Function used to get category by name + */ + function get_cat_by_name($name) + { + global $db; + $results = $db->select(tbl($this->cat_tbl),"*"," category_name='$name' "); + if($db->num_rows>0) + { + return $results[0]; + }else{ + return false; + } + } + + + /** + * Function used to add new category + */ + function add_category($array) + { + global $db; + $name = ($array['name']); + $desc = ($array['desc']); + $default = mysql_clean($array['default']); + + $flds = array("category_name","category_desc","date_added"); + $values = array($name,$desc,now()); + + if(!empty($this->use_sub_cats)) + { + $parent_id = mysql_clean($array['parent_cat']); + $flds[] = "parent_id"; + $values[] = $parent_id; + } + + if($this->get_cat_by_name($name)) + { + e(lang("add_cat_erro")); + + }elseif(empty($name)) + { + e(lang("add_cat_no_name_err")); + }else{ + $cid = $db->insert(tbl($this->cat_tbl),$flds,$values); + + $cid = $db->insert_id(); + if($default=='yes' || !$this->get_default_category()) + $this->make_default_category($cid); + e(lang("cat_add_msg"),'m'); + + //Uploading thumb + if(!empty($_FILES['cat_thumb']['tmp_name'])) + $this->add_category_thumb($cid,$_FILES['cat_thumb']); + } + + } + + + + /** + * Function used to make category as default + */ + function make_default_category($cid) + { + global $db; + if($this->category_exists($cid)) + { + $db->update(tbl($this->cat_tbl),array("isdefault"),array("no")," isdefault='yes' "); + $db->update(tbl($this->cat_tbl),array("isdefault"),array("yes")," category_id='$cid' "); + e(lang("cat_set_default_ok"),'m'); + }else + e(lang("cat_exist_error")); + } + + + /** + * Function used to get list of categories + */ + function get_categories() + { + global $db; + $select = $db->select(tbl($this->cat_tbl),"*",NULL,NULL," category_order ASC"); + return $select; + } + + function getCbCategories($params) + { + global $db; + $params['use_sub_cats'] = $params['use_sub_cats'] ? $params['use_sub_cats'] : "yes"; + if($this->use_sub_cats && config('use_subs') == 1 && $params['use_sub_cats'] == "yes" && + ($params['type'] == "videos" || $params['type'] == "video" || $params['type'] == "v")) + { + $cond = " parent_id = 0"; + $subCategories = TRUE; + } else + $cond = NULL; + $orderby = $params['orderby'] = $params['orderby'] ? $params['orderby'] : "category_order"; + $order = $params['order'] = $params['order'] ? $params['order'] : "ASC"; + $limit = $params['limit'] = $params['limit'] ? (is_numeric($params['limit']) ? $params['limit'] : NULL) : NULL; + + + $categories = $db->select(tbl($this->cat_tbl),"*",$cond,$limit," $orderby $order"); + + $finalArray = array(); + if($params['with_all']) + $finalArray[] = array("category_id"=>"all","category_name"=>lang("cat_all")); + + foreach($categories as $cat) + { + $finalArray[$cat['category_id']] = $cat; + if($subCategories === TRUE && $this->is_parent($cat['category_id'])) + $finalArray[$cat['category_id']]['children'] = $this->getCbSubCategories($cat['category_id'],$params); + } + + return $finalArray; + } + + function getCbSubCategories($category_id,$params) + { + global $db; + if(empty($category_id)) + return false; + { + $orderby = $params['orderby']; $order = $params['order']; + $finalOrder = $orderby.' '.$order; + if($params['limit_sub']) + { + if(is_numeric($params['limit_sub'])) + $limit = $params['limit_sub']; + elseif($params['limit_sub'] == "parent") + $limit = $params['limit']; + else + $limit = NULL; + } + if($params['sub_order']) + $finalOrder = $params['sub_order']; + $subCats = $db->select(tbl($this->cat_tbl),"*"," parent_id = '$category_id'",$limit," $finalOrder"); + + if($subCats) + { + $subArray = array(); + foreach($subCats as $subCat) + { + $subArray[$subCat['category_id']] = $subCat; + if($this->is_parent($subCat['category_id'])) + { + $subArray[$subCat['category_id']]['children'] = $this->getCbSubCategories($subCat['category_id'],$params); + } + } + return $subArray; + } + } + } + + function displayListCategories($catArray,$params) + { + $html = ''; + foreach($catArray as $catID=>$cat) + { + if($_GET['cat'] == $cat['category_id'] || (empty($_GET['cat']) && $cat['category_id'] == 'all')) + $selected = " selected "; + else + $selected = ""; + if($params['class']) + $class = $params['class']; + $html .= "
  • "category","data"=>$cat,"type"=>$params['type']))."'>".$cat['category_name'].""; + if($cat['children']) + { + $html .= "
      "; + $html .= $this->displayListCategories($cat['children'],$params); + $html .= "
    "; + } + $html .= "
  • "; + } + + return $html; + } + + function displayOptions($catArray,$params,$spacer="") + { + foreach($catArray as $catID=>$cat) + { + if($_GET['cat'] == $cat['category_id'] || ($params['selected'] && $params['selected'] == $cat['category_id'])) + $selected = " selected=selected"; + else + $selected = ""; + if($params['value'] == "link") + $value = cblink(array("name"=>"category","data"=>$cat,"type"=>$params['type'])); else $value = $cat['category_id']; + $html .= ""; + if($cat['children']) + { + $html .= $this->displayOptions($cat['children'],$params,$spacer.($params['spacer']?$params['spacer']:"- ")); + } + } + + return $html; + } + + function displayDropdownCategory($catArray,$params) + { + $html = ''; + if($params['name']) $name = $params['name']; else $name = "cat"; + if($params['id']) $id = $params['id']; else $id = "cat"; + if($params['class']) $class = $params['class']; else $class = "cbSelectCat"; + + $html .= ""; + return $html; + } + + function displayCollpasedListCateogry($catArray,$params) + { + $html = ''; + + foreach($catArray as $catID=>$cat) + { + if($_GET['cat'] == $catID || (empty($_GET['cat']) && $cat['category_id'] == 'all')) + $selected = "selected"; + else + $selected = ""; + + + + if($params['class']) + $class = $params['class']; + $html .= "
  •  "; + + $html .= "".$cat['category_name'].""; + + + + if($cat['children']) + { + + + $html .= "
      "; + $html .= $this->displayCollpasedListCateogry($cat['children'],$params); + $html .= "
    "; + } + $html .= "
  • "; + } + + return $html; + } + + function displayOutput($CatArray,$params) + { + $output = $params['output']; + if(is_array($CatArray)) + { + switch($output) + { + case "list": case "li": + default: + { + if($params['list_style'] == "" || $params['list_style'] == "simple") + $html = $this->displayListCategories($CatArray,$params); + if($params['list_style'] == "collapsed") + $html = $this->displayCollpasedListCateogry($CatArray,$params); + } + break; + + case "dropdown": case "option": + { + $html = $this->displayDropdownCategory($CatArray,$params); + } + break; + + case "checkbox": case "check_box": + { + + } + break; + } + return $html; + } else + return false; + } + + function cbCategories($params=NULL) + { + $p = $params; + $p['type'] = $p['type'] ? $p['type'] : 'video'; + $p['echo'] = $p['echo'] ? $p['echo'] : FALSE; + $p['with_all'] = $p['with_all'] ? $p['with_all'] : FALSE; + + { + $categories = $this->getCbCategories($p); + + if($categories) + { + if($p['echo'] == TRUE) + { + $html = $this->displayOutput($categories,$p); + if($p['assign']) + assign($p['assign'],$html); + else + echo $html; + } else { + if($p['assign']) + assign($p['assign'],$categories); + else + return $categories; + } + } else + return false; + } + } + + /** + * Function used to list of categories + */ + function cb_list_categories($type,$with_all=false) + { + global $db; + if($type == 'video' || $type == 'vid' || $type == 'v') + $cond = " parent_id = 0"; + else + $cond = NULL; + + //Getting List of categories + $cats = $db->select(tbl($this->cat_tbl),"*",$cond,NULL," category_order ASC"); + + if($with_all) + array_unshift($cats,array("category_id"=>"all","category_name"=>"All")); + + $html = ''; + for($i=0;$i"; + $html .= "".$cats[$i]['category_name'].""; + if($this->is_parent($cats[$i]['category_id'])) + { + $html .= $this->cb_list_subs($cats[$i]['category_id'],$type); + } + $html .= ""; + } + return $html; + + } + + function cb_list_subs($cid,$type) + { + global $db; + $html = ""; + $query = mysql_query("SELECT * FROM ".tbl($this->cat_tbl)." WHERE parent_id = $cid"); + + if(!empty($query)) + { + + $html .= "
      "; + while($result = mysql_fetch_array($query)) + { + if($_GET['cat'] == $result['category_id']) + $selected = "selected"; + else + $selected = ""; + + $html .= "
    • "; + $html .= "".$result['category_name'].""; + if($this->is_parent($result['category_id'])) + { + $html .= $this->cb_list_subs($result['category_id'],$type); + } + $html .= "
    • "; + } + + $html .= "
    "; + } + + return $html; + } + + + /** + * Function used to count total number of categoies + */ + function total_categories() + { + global $db; + return $db->count(tbl($this->cat_tbl),"*"); + } + + + /** + * Function used to delete category + */ + function delete_category($cid) + { + global $db; + $cat_details = $this->category_exists($cid); + if(!$cat_details) + e(lang("cat_exist_error")); + + //CHecking if category is default or not + elseif($cat_details['isdefault'] == 'yes') + e(lang("cat_default_err")); + else{ + + $pcat = $this->has_parent($cid,true); + + //Checking if category is both parent and child + if($pcat && $this->is_parent($cid)) + { + $to = $pcat[0]['category_id']; + $has_child = TRUE; + } + elseif($pcat && !$this->is_parent($cid)) //Checking if category is only child + { + $to = $pcat[0]['category_id']; + $has_child = TRUE; + } + elseif(!$pcat && $this->is_parent($cid)) //Checking if category is only parent + { + $to = NULL; + $has_child = NULL; + $db->update(tbl($this->cat_tbl),array('parent_id'),array('0')," parent_id = $cid"); + } + + //Moving all contents to parent OR default category + $this->change_category($cid,$to,$has_child); + + //Removing Category + $db->execute("DELETE FROM ".tbl($this->cat_tbl)." WHERE category_id='$cid'"); + e(lang("class_cat_del_msg"),'m'); + } + + } + + /** + * Functon used to get dafault categry + */ + function get_default_category() + { + global $db; + $results = $db->select(tbl($this->cat_tbl),"*"," isdefault='yes' "); + if($db->num_rows>0) + return $results[0]; + else + return false; + } + + /** + * Function used to get default category ID + */ + function get_default_cid() + { + $default = $this->get_default_category(); + return $default['category_id']; + } + + + + /** + * Function used to move contents from one section to other + */ + function change_category($from,$to=NULL,$has_child=NULL,$check_multiple=false) + { + global $db; + + if(!$this->category_exists($to)) + $to = $this->get_default_cid(); + + if($has_child) { + $db->update(tbl($this->cat_tbl),array('parent_id'),array($to)," parent_id = $from"); + } + + $db->execute("UPDATE ".tbl($this->section_tbl)." SET category = replace(category,'#".$from."#','#".$to."#') WHERE category LIKE '%#".$from."#%'"); + + $db->execute("UPDATE ".tbl($this->section_tbl)." SET category = replace(category,'#".$to."# #".$to."#','#".$to."#') WHERE category LIKE '%#".$to."#%'"); + } + + + /** + * Function used to edit category + * submit values and it will update category + */ + function update_category($array) + { + global $db; + $name = ($array['name']); + $desc = ($array['desc']); + $default = mysql_clean($array['default']); + $pcat = mysql_clean($array['parent_cat']); + + $flds = array("category_name","category_desc"); + $values = array($name,$desc); + + $cur_name = mysql_clean($array['cur_name']); + $cid = mysql_clean($array['cid']); + + if(!empty($this->use_sub_cats)) + { + $flds[] = "parent_id"; + $values[] = $pcat; + } + + if($this->get_cat_by_name($name) && $cur_name !=$name ) + { + e(lang("add_cat_erro")); + + }elseif(empty($name)){ + e(lang("add_cat_no_name_err")); + } elseif($pcat == $cid){ + e(lang("You can not make category parent of itself")); + }else{ + $db->update(tbl($this->cat_tbl),$flds,$values," category_id='$cid' "); + + if($default=='yes' || !$this->get_default_category()) + $this->make_default_category($cid); + e(lang("cat_update_msg"),'m'); + + //Uploading thumb + if(!empty($_FILES['cat_thumb']['tmp_name'])) + $this->add_category_thumb($cid,$_FILES['cat_thumb']); + } + } + + + /** + * Function used to add category thumbnail + * @param $Cid and Array + */ + function add_category_thumb($cid,$file) + { + global $imgObj; + if($this->category_exists($cid)) + { + //Checking for category thumbs direcotry + if(isset($this->thumb_dir)) + $dir = $this->thumb_dir; + else + $dir = $this->section_tbl; + + //Checking File Extension + $ext = strtolower(getext($file['name'])); + + if($ext=='jpg' || $ext =='png' || $ext=='gif') + { + $dir_path = CAT_THUMB_DIR.'/'.$dir; + if(!is_dir($dir_path)) + @mkdir($dir_path,0777); + + if(is_dir($dir_path)) + { + $path = $dir_path.'/'.$cid.'.'.$ext; + + //Removing File if already exists + if(file_exists($path)) + unlink($path); + move_uploaded_file($file['tmp_name'],$path); + + //Now checking if file is really an image + if(!@$imgObj->ValidateImage($path,$ext)) + { + e(lang("pic_upload_vali_err")); + unlink($path); + }else + { + $imgObj->CreateThumb($path,$path,$this->cat_thumb_width,$ext,$this->cat_thumb_height,true); + } + }else{ + e(lang("cat_dir_make_err")); + } + }else{ + e(lang("cat_img_error")); + } + } + } + + + /** + * Function used to get category thumb + */ + function get_cat_thumb($cat_details) + { + //Checking for category thumbs direcotry + if(isset($this->thumb_dir)) + $dir = $this->thumb_dir; + else + $dir = $this->section_tbl; + + $cid = $cat_details['category_id']; + $path = CAT_THUMB_DIR.'/'.$dir.'/'.$cid.'.'; + $exts = array('jpg','png','gif'); + + $file_exists = false; + foreach($exts as $ext) + { + $cur_ext = $ext; + if(file_exists($path.$ext)) + { + $file_exists = true; + break; + } + } + + if($file_exists) + return CAT_THUMB_URL.'/'.$dir.'/'.$cid.'.'.$ext; + else + return $this->default_thumb(); + } + function get_category_thumb($i) + { + return $this->get_cat_thumb($i); + } + + /** + * function used to return default thumb + */ + function default_thumb() + { + if(empty($this->default_thumb)) + $this->default_thumb = 'no_thumb.jpg'; + return CAT_THUMB_URL.'/'.$this->default_thumb; + } + + /** + * Function used to update category id + */ + function update_cat_order($id,$order) + { + global $db; + $cat = $this->category_exists($id); + if(!$cat) + e(lang("cat_exist_error")); + else + { + if(!is_numeric($order) || $order <1) + $order = 1; + $db->update(tbl($this->cat_tbl),array("category_order"),array($order)," category_id='".$id."'"); + } + } + + /** + * Function used get parent cateogry + */ + function get_parent_category($pid) + { + global $db; + $result = $db->select(tbl($this->cat_tbl),"*"," category_id = $pid"); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to check category is parent or not + */ + function is_parent($cid) + { + global $db; + $result = $db->count(tbl($this->cat_tbl),"category_id"," parent_id = $cid"); + + if($result > 0) + return true; + else + return false; + } + + /** + * Function used to check wheather category has parent or not + */ + function has_parent($cid,$return_parent=false) + { + global $db; + $result = $db->select(tbl($this->cat_tbl),"*"," category_id = $cid AND parent_id != 0"); + + if($result > 0) { + if($return_parent) + { + $pid = $this->get_parent_category($result[0]['parent_id']); + return $pid; + } else { + return true; + } + } else { + return false; + } + } + + /** + * Function used to get parent categories + */ + function get_parents($count=false) { + global $db; + + if($count) { + $result = $db->count(tbl($this->cat_tbl),"*"," parent_id = 0"); + } else { + $result = $db->select(tbl($this->cat_tbl),"*"," parent_id = 0"); + } + + return $result; + } + + /** + * Function used to list categories in admin area + * with indention + */ + function admin_area_cats($selected) + { + global $db; + $html = ''; + $pcats = $this->get_parents(); + + if(!empty($pcats)) + { + foreach($pcats as $key=>$pcat) + { + if($selected == $pcat['category_id']) + $select = "selected='selected'"; + else + $select = NULL; + + $html .= ""; + if($this->is_parent($pcat['category_id'])) + $html .= $this->get_sub_subs($pcat['category_id'],$selected); + } + + return $html; + } + } + + /** + * Function used to get child categories + */ + function get_sub_categories($cid) + { + global $db; + $result = $db->select(tbl($this->cat_tbl),"*"," parent_id = $cid"); + //echo $db->db_query; + if($result > 0){ + return $result; + }else{ + return false; + } + } + + /** + * Function used to get child child categories + */ + function get_sub_subs($cid,$selected,$space="  - ") + { + global $db; + $html = ''; + $subs = $this->get_sub_categories($cid); + if(!empty($subs)) + { + foreach($subs as $sub_key=>$sub) + { + if($selected == $sub['category_id']) + $select = "selected='selected'"; + else + $select = NULL; + + $html .= ""; + if($this->is_parent($sub['category_id'])) + $html .= $this->get_sub_subs($sub['category_id'],$selected,$space." - "); + } + return $html; + } + } + + function get_category_field($cid,$field) + { + global $db; + $result = $db->select(tbl($this->cat_tbl),"$field"," category_id = $cid"); + //echo $db->db_query; + if($result) + return $result[0][$field]; + else + return false; + } + + + + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/cbemail.class.php b/upload/includes/classes/cbemail.class.php new file mode 100644 index 00000000..2a4f8233 --- /dev/null +++ b/upload/includes/classes/cbemail.class.php @@ -0,0 +1,382 @@ +select(tbl($this->db_tpl),"*"," email_template_code='".$code."' OR email_template_id='$code' "); + if($db->num_rows>0) + { + $result[0]['email_template'] = stripslashes($result[0]['email_template']); + $result[0]['email_template_subject'] = stripslashes($result[0]['email_template_subject']); + return $result[0]; + }else + return false; + } + function get_template($code) + { + return $this->get_email_template($code); + } + + /** + * Check template exists or not + */ + function template_exists($code) + { + return $this->get_email_template($code); + } + + + /** + * Function used to replace content + * of email template with variables + * it can either be email subject or message content + * @param : Content STRING + * @param : array ARRAY => array({somevar}=>$isvar) + */ + function replace($content,$array) + { + //Common Varialbs + + $com_array = array + ('{website_title}' => TITLE, + '{baseurl}' => BASEURL, + '{website_url}' => BASEURL, + '{date_format}' => cbdate(DATE_FORMAT), + '{date}' => cbdate(), + '{username}' => username(), + '{userid}' => userid(), + '{date_year}' => cbdate("Y"), + '{date_month}' => cbdate("m"), + '{date_day}' => cbdate("d"), + '{signup_link}' => cblink(array('name'=>'signup')), + '{login_link}' => cblink(array('name'=>'login')), + ); + + if(is_array($array) && count($array)>0) + $array = array_merge($com_array,$array); + else + $array = $com_array; + foreach($array as $key => $val) + { + $var_array[] = '/'.$key.'/'; + $val_array[] = $val; + } + return preg_replace($var_array,$val_array,$content); + } + + /** + * Function used to get all templates + */ + function get_templates() + { + global $db; + $results = $db->select(tbl($this->db_tpl),"*",NULL,NULL," email_template_name DESC"); + if($db->num_rows>0) + return $results; + else + return false; + } + + + /** + * Function used to update email template + */ + function update_template($params) + { + global $db; + $id = mysql_clean($params['id']); + $subj = mysql_clean($params['subj']); + $msg = mysql_real_escape_string($params['msg']); + + if(!$this->template_exists($id)) + e(lang("email_template_not_exist")); + elseif(empty($subj)) + e(lang("email_subj_empty")); + elseif(empty($msg)) + e(lang("email_msg_empty")); + else + { + $db->update(tbl($this->db_tpl),array("email_template_subject","email_template"),array($subj,'|no_mc|'.$msg), + " email_template_id='$id'"); + e(lang("email_tpl_has_updated"),"m"); + } + + } + + /** + * Mass Email + */ + function add_mass_email($array=NULL) + { + if(!$array) + $array = $_POST; + + global $userquery,$db; + + $from = $array['from']; unset($array['from']); + $loop = $array['loop_size']; + $subj = $array['subject']; unset($array['subject']); + $msg = $array['message']; unset($array['message']); + $users = $array['users']; unset($array['users']); + $method = $array['method']; unset($array['method']); + + $settings = $array; + + unset($array); + + if(!isValidEmail($from)) + e(lang("Please enter valid email in 'from' field")); + if(!is_numeric($loop) || $loop <1 || $loop>10000) + e(lang("Please enter valid numeric value from 1 to 10000 for loop size")); + if(!$subj) + e(lang("Please enter a valid subject for your email")); + if(!$msg) + e(lang("Email body was empty, please enter your email content")); + + if(!error()) + { + $db->insert(tbl('mass_emails'),array('email_subj','email_from','email_msg','configs','users','method','status','date_added'), + array($subj,$from,'|no_mc|'.$msg,'|no_mc|'.json_encode($settings),$users,$method,'pending',now())); + + e("Mass email has been added","m"); + return true; + }else + return false; + } + + + /** + * function used to get email + */ + function get_mass_emails() + { + global $db; + $results = $db->select(tbl("mass_emails"),"*"); + + if($db->num_rows>0) + { + return $results; + }else + return false; + } + + /** + * function used to delete, send emails + */ + function action($id,$action) + { + global $db; + $email = $this->email_exists($id); + if(!$email) + { + e(lang("Email does not exist")); + return false; + } + + switch($action) + { + case "delete": + { + $db->Execute("DELETE FROM ".tbl('mass_emails')." WHERE id='$id'"); + e(lang("Email has been deleted"),"m"); + } + break; + + case "send_email": + { + $this->send_emails($email); + } + break; + } + } + + /** + * functionn used to check email exists or not + */ + function get_email($id) + { + global $db; + $result = $db->select(tbl("mass_emails"),"*","id='$id'"); + if($db->num_rows>0) + { + return $result[0]; + }else + { + return false; + } + } + function email_exists($id){ return $this->get_email($id); } + + + + /** + * function send emails + */ + function send_emails($id) + { + global $db,$userquery,$cbemail; + if(!is_array($id)) + { + $email = $this->get_email($id); + }else + { + $email = $id; + } + + if($email['status']=='completed') + return false; + $settings = json_decode($email['configs'],true); + $users = $email['users']; + $total = $email['total']; + + //Creating limit + $start_index = $email['start_index']; + $limit = $start_index.','.$settings['loop_size']; + + //Creating condition + $condition = ""; + + //Levels + $level_query = ""; + $levels = $settings['level']; + if($levels) + { + foreach($levels as $level) + { + if($level_query) + $level_query .= " OR "; + $level_query .= " level='$level' "; + } + + if($condition) + $condition .= " AND "; + $condition = $level_query = " ( ".$level_query.") "; + } + + //Categories + $cats_query = ""; + $cats = $settings['cat']; + if($cats) + { + foreach($cats as $cat) + { + if($cats_query) + $cats_query .= " OR "; + $cats_query .= " category='$cat' "; + } + + $cats_query = " ( ".$cats_query.") "; + if($condition) + $condition .= " AND "; + $condition .= $cats_query; + } + + + //Ative users + if($settings['active']!='any') + { + if($condition) + $condition .= " AND "; + + if($settings['active']=='yes') + $condition .= " usr_status = 'Ok' "; + if($settings['active']=='no') + $condition .= " usr_status = 'ToActivate' "; + } + + //Banned users + if($settings['ban']!='any') + { + if($condition) + $condition .= " AND "; + + if($settings['ban']=='yes') + $condition .= " ban_status = 'yes' "; + if($settings['ban']=='no') + $condition .= " ban_status = 'no' "; + } + + + + if(!$users) + { + $users = $db->select(tbl("users"),"*",$condition,$limit," userid ASC "); + + if(!$total) + { + $total = $db->count(tbl("users"),"userid",$condition); + } + + $sent = $email['sent']; + $send_msg = array(); + foreach($users as $user) + { + $var = array + ('{username}' => $user['username'], + '{userid}' => $user['userid'], + '{email}' => $user['email'], + '{datejoined}' => $user['doj'], + '{avcode}' => $user['avcode'], + '{avlink}' => BASEURL.'/activation.php?av_username='.$user['username'].'&avcode='.$user['avcode'], + ); + $subj = $cbemail->replace($email['email_subj'],$var); + $msg = nl2br($cbemail->replace($email['email_msg'],$var)); + + $send_message = ""; + + //Now Finally Sending Email + cbmail(array('from_name'=>TITLE, 'to'=>$user['email'],'from'=>$email['from'],'subject'=>$subj,'content'=>$msg)); + $sent++; + + $send_msg[] = $user['userid'].": Email has been sent to ".$user['username'].""; + + } + + $sent_to = $start_index+$settings['loop_size']; + + if($sent_to>$total) + $sent_to = $total; + + e(sprintf(lang("Sending email from %s to %s"),$start_index+1,$sent_to),"m"); + + $start_index = $start_index+$settings['loop_size']; + + if($sent==$total || $sent>$total) + $status = 'completed'; + else + $status = 'sending'; + + $db->update(tbl('mass_emails'),array('sent','total','start_index','status','last_update'), + array($sent,$total,$start_index,$status,now())," id='".$email['id']."' "); + + return $send_msg; + + } + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/cbfeeds.class.php b/upload/includes/classes/cbfeeds.class.php new file mode 100644 index 00000000..5000eb37 --- /dev/null +++ b/upload/includes/classes/cbfeeds.class.php @@ -0,0 +1,391 @@ + userid + * udetails => array of user details + * limit => timelimit of feeds (1 day, 2 days and so) + */ + function createFeed($array) + { + global $userquery; + $uid = $array['uid']; + + if(!$uid) + e(lang("please_provide_valid_userid")); + elseif(!is_array($user)) + { + $user = $userquery->get_user_details($uid); + } + } + + + /** + * Function used to add feed in user feed file + * @param array + * action => upload,joined,comment,created + * object => video, photo, group + * object_id => id of object + * object_details => details of object + * uid => user id + * udetails => user details array + */ + function addFeed($feed) + { + if(!isSectionEnabled('feeds')) + return false; + global $userquery; + $uid = $feed['uid']; + + if(!$uid) + return false; + + $ufeed = array(); + + //Verifying feed action and object + $action = $this->action($feed['action']); + $object = $this->getObject($feed['object']); + + + if(!$action || !$object) + return false; + + //Setting user feed array + $ufeed['action'] = $action; + $ufeed['object'] = $object; + $ufeed['object_id'] = $feed['object_id']; + $ufeed['userid'] = $uid; + $ufeed['time'] = time(); + + //Unsetting feed array + unset($feed); + + //Getting user feed file + $feedFile = $this->getFeedFile($uid); + + //Convering feed using json + $feed = json_encode($ufeed); + //Creating unique md5 of feed + $feedmd5 = md5($feed); + $ufeed['md5'] = $feedmd5; + //Recreating Feed + $feed = json_encode($ufeed); + + //Appending feed in a file + $file = fopen($feedFile,'a+'); + fwrite($file,$feed); + fclose($file); + + //Tada <{^-^}> + + } + + + /** + * Function used to get action of feed + * it will verify weather actio is valid or not + */ + function action($action) + { + $objects = array + ('signup','upload_video','upload_photo','create_group', + 'join_group','add_friend','add_collection','add_playlist', + 'add_comment','add_favorite'); + + if(!in_array($action,$objects)) + return false; + else + return $action; + } + + + /** + * Function used to get object of feed + * it will verify weather actio is valid or not + */ + function getObject($object) + { + $objects = array + ('signup','video','photo','group', + 'user','friend','collection'); + + if(!in_array($object,$objects)) + return false; + else + return $object; + } + + + /** + * Function used to get feed file + */ + function getFeedFile($uid) + { + $time = time(); + $ufeedDir = USER_FEEDS_DIR.'/'.$uid; + //checking user feed folder exists or not + if(!file_exists($ufeedDir)) + mkdir($ufeedDir); + $file = $ufeedDir.'/'.$time.'.feed'; + return $file; + } + + /** + * Function used to get user feed files + */ + function getUserFeedsFiles($uid=NULL) + { + if(!$uid) + $uid = userid(); + + $feeds = array(); + $ufeedDir = USER_FEEDS_DIR.'/'.$uid; + if(file_exists($ufeedDir)) + { + $time = time(); + $time = substr($timem,0,strlen($time)-3); + + $files = glob($ufeedDir.'/'.$time.'*.feed'); + rsort($files); + foreach($files as $file) + { + $feed['content'] = file_get_contents($file); + $feed['file'] = $file; + $feeds[] = $feed; + } + + return $feeds; + } + return false; + } + + + /** + * Function used to get user feed + */ + function getUserFeeds($user) + { + global $cbphoto,$userquery,$cbvid,$cbgroup,$cbcollection; + $allowed_feeds = USER_ACTIVITY_FEEDS_LIMIT; + $uid = $user['userid']; + $feeds = $this->getUserFeedsFiles($uid); + + if(!$feeds) + return false; + $newFeeds = array(); + $coutn = 0; + foreach($feeds as $feed) + { + $count++; + + if($count>$allowed_feeds) + break; + $feedArray = json_decode($feed['content'],true); + if($feed && count($feedArray>0)) + { + $remove_feed = false; + $farr = $feedArray; + + $action = $farr['action']; + $object = $farr['object']; + $object_id = $farr['object_id']; + $farr['user'] = $user; + $farr['file'] = getName($feed['file']); + $farr['datetime'] = nicetime($farr['time'],true); + $userlink = ''.$user['username'].''; + //Creating Links + switch($action) + { + case "upload_photo": + { + $photo = $cbphoto->get_photo($object_id); + + //If photo does not exists, simply remove the feed + if(!$photo) + { + $this->deleteFeed($uid,$feed['file']); + $remove_feed = true; + }else + { + $objectArr['details'] = $photo; + $objectArr['size'] = 't'; + $objectArr['output'] = 'non_html'; + $objectArr['alt'] = $photo['photo_title']; + $farr['thumb'] = $cbphoto->getFileSmarty($objectArr); + $farr['link'] = $cbphoto->photo_links($photo,'view_item'); + + //Content Title + $farr['title'] = $photo['photo_title']; + $farr['action_title'] + = sprintf(lang('user_has_uploaded_new_photo'),$userlink); + + $farr['links'][] = array('link'=>($cbphoto->photo_links($photo,'view_item')),'text'=>lang('view_photo')); + + $farr['icon'] = 'images.png'; + } + + + } + break; + + case "upload_video": + case "add_favorite": + { + $video = $cbvid->get_video($object_id); + //If photo does not exists, simply remove the feed + if(!$video) + { + $this->deleteFeed($uid,$feed['file']); + $remove_feed = true; + }elseif(!video_playable($video)) + { + $remove_feed = true; + }else{ + + //Content Title + $farr['title'] = $video['title']; + if($action=='upload_video') + $farr['action_title'] = sprintf(lang('user_has_uploaded_new_video'),$userlink); + if($action=='add_favorite') + $farr['action_title'] = sprintf(lang('user_has_favorited_video'),$userlink); + $farr['link'] = videoLink($video); + $farr['object_content'] = $video['description']; + $farr['thumb'] = get_thumb($video); + + $farr['links'][] = array('link'=>videoLink($video),'text'=>lang('watch_video')); + + $farr['icon'] = 'video.png'; + + if($action=='add_favorite') + $farr['icon'] = 'heart.png'; + } + } + break; + + + case "create_group": + case "join_group": + { + $group = $cbgroup->get_group($object_id); + //If photo does not exists, simply remove the feed + if(!$group) + { + $this->deleteFeed($uid,$feed['file']); + $remove_feed = true; + }elseif(!$cbgroup->is_viewable($group)) + { + $remove_feed = true; + }else{ + + //Content Title + $farr['title'] = $group['group_name']; + + if($action=='create_group') + $farr['action_title'] = sprintf(lang('user_has_created_new_group'),$userlink); + if($action=='join_group') + $farr['action_title'] = sprintf(lang('user_has_joined_group'),$userlink); + + $farr['link'] = group_link(array('details'=>$group)); + $farr['object_content'] = + $group['group_description']."
    ". + lang('total_members')." : ".$group['total_members']."
    ". + lang('total_videos')." : ".$group['total_videos']."
    ". + lang('total_topics')." : ".$group['total_topics']."
    "; + + $farr['thumb'] = $cbgroup->get_group_thumb($group); + $farr['icon'] = 'group.png'; + + $joinlink = $cbgroup->group_opt_link($group,'join'); + if($joinlink) + { + if(SEO=="yes") + $joinlink = group_link(array('details'=>$group)).'?join=yes"'; + else + $joinlink = group_link(array('details'=>$group)).'&join=yes"'; + $farr['links'][] = array('link'=>$joinlink,'text'=>lang('join')); + } + } + } + break; + + case "signup": + { + $farr['action_title'] = sprintf(lang("user_joined_us"),$userlink,TITLE,$userlink); + $farr['icon'] = 'user.png'; + } + + break; + case "add_friend": + { + $friend = $userquery->get_user_details($object_id); + + if(!$friend) + { + $this->deleteFeed($uid,$feed['file']); + $remove_feed = true; + }else + { + + $friendlink = ''.$friend['username'].''; + $farr['action_title'] = sprintf(lang("user_is_now_friend_with_other") + ,$userlink,$friendlink); + $farr['icon'] = 'user_add.png'; + } + } + break; + + + case "add_collection": + { + $collection = $cbcollection->get_collection($object_id); + if(!$collection) + { + $this->deleteFeed($uid,$feed['file']); + $remove_feed = true; + }else + { + $farr['action_title'] = sprintf(lang('user_has_created_new_collection'),$userlink); + $farr['thumb'] = $cbcollection->get_thumb($collection,'small'); + $farr['title'] = $collection['collection_name']; + $collection_link = $cbcollection->collection_links($collection,'view'); + $farr['link'] = $collection_link; + + $farr['object_content'] = + $collection['collection_description'].'
    '. + $collection['total_objects']." ".$collection['type']; + $farr['icon'] = 'photos.png'; + + $farr['links'][] = array('link'=>$collection_link,'text'=>lang('view_collection')); + } + } + + } + + if(!$remove_feed) + $newFeeds[$feedArray['time']] = $farr; + } + } + return $newFeeds; + } + + + /** + * Function used to delete feed + */ + function deleteFeed($uid,$feedid) + { + $ufeedDir = USER_FEEDS_DIR.'/'.$uid.'/'.getName($feedid).'.feed'; + if(file_exists($ufeedDir)) + unlink($ufeedDir); + } +} \ No newline at end of file diff --git a/upload/includes/classes/cbpage.class.php b/upload/includes/classes/cbpage.class.php new file mode 100644 index 00000000..8c70e9dc --- /dev/null +++ b/upload/includes/classes/cbpage.class.php @@ -0,0 +1,260 @@ +page_tbl = 'pages'; + } + + + /** + * Function used to create new page + * @param ARRAY + */ + function create_page($param) + { + global $db; + $name = mysql_clean($param['page_name']); + $title = mysql_clean($param['page_title']); + $content = addslashes($param['page_content']); + + if(empty($name)) + e(lang("page_name_empty")); + if(empty($title)) + e(lang("page_title_empty")); + if(empty($content)) + e(lang("page_content_empty")); + + if(!error()) + { + $db->insert(tbl($this->page_tbl),array("page_name","page_title","page_content","userid","date_added","active"), + array($name,$title,"|no_mc|".$content,userid(),now(),"yes")); + e(lang("new_page_added_successfully"),"m"); + return false; + } + return false; + } + + /** + * Function used to get details using id + */ + function get_page($id) + { + global $db; + $result = $db->select(tbl($this->page_tbl),"*"," page_id ='$id' "); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to get all pages from database + */ + function get_pages($params=false) + { + global $db; + $order = NULL; + $limit = NULL; + $conds = array(); + $cond = false; + if($params['order']) + { + $order = $params['order']; + } + if($params['limit']) + { + $limit = $params['limit']; + } + + if($params['active']) + { + $conds[] = " active='".$params['active']."'"; + } + + if($params['display_only']) + { + $conds[] = " display='yes' "; + } + + if($conds) + { + + foreach($conds as $c) + { + if($cond) + $cond .= " AND "; + + $cond .= $c; + } + } + + $result = $db->select(tbl($this->page_tbl),"*",$cond,$limit,$order); + if($db->num_rows>0) + return $result; + else + return false; + } + + + /** + * Function used to edit page + */ + function edit_page($param) + { + global $db; + $id = $param['page_id']; + $name = mysql_clean($param['page_name']); + $title = mysql_clean($param['page_title']); + $content = sql_free($param['page_content']); + + $page = $this->get_page($id); + + if(!$page) + e(lang("page_doesnt_exist")); + if(empty($name)) + e(lang("page_name_empty")); + if(empty($title)) + e(lang("page_title_empty")); + if(empty($content)) + e(lang("page_content_empty")); + + if(!error()) + { + $db->update(tbl($this->page_tbl),array("page_name","page_title","page_content"), + array($name,$title,'|no_mc|'.$content)," page_id='$id'"); + e(lang("page_updated"),"m"); + } + + } + + /** + * Function used to delete page + */ + function delete_page($id) + { + $page = $this->get_page($id); + if(!$page) + e(lang("page_doesnt_exist")); + if(!error()) + { + $db->delete(tbl($this->page_tbl),array("page_id"),array($id)); + e(lang("page_deleted"),"m"); + } + + } + + /** + * Function used to create page link + */ + function page_link($pdetails) + { + //baseurl/page/$id/page_name + if(SEO=='yes') + return BASEURL.'/page/'.$pdetails['page_id'].'/'.SEO(strtolower($pdetails['page_name'])); + else + return BASEURL.'/view_page.php?pid='.$pdetails['page_id']; + } + + /** + * Function used to get page link fro id + */ + function get_page_link($id) + { + $page = $this->get_page($id); + return $this->page_link($page); + } + + + /** + * Function used to activate, deactivate or to delete pages + */ + function page_actions($type,$id) + { + global $db; + $page = $this->get_page($id); + if(!$page) + e(lang("page_doent_exist")); + else + { + switch($type) + { + case "activate"; + $db->update(tbl($this->page_tbl),array("active"),array("yes")," page_id='$id'"); + e(lang("page_activated"),"m"); + break; + case "deactivate"; + $db->update(tbl($this->page_tbl),array("active"),array("no")," page_id='$id'"); + e(lang("page_deactivated"),"m"); + break; + case "delete"; + { + if($page['delete_able']=='yes') + { + $db->delete(tbl($this->page_tbl),array("page_id"),array($id)); + e(lang("page_deleted"),"m"); + }else + e(lang("you_cant_delete_this_page")); + } + + break; + + case "display": + { + $db->update(tbl($this->page_tbl),array("display"),array("yes")," page_id='$id'"); + e(lang("Page displaye mode has been changed"),"m"); + } + break; + + case "hide": + { + $db->update(tbl($this->page_tbl),array("display"),array("no")," page_id='$id'"); + e(lang("Page displaye mode has been changed"),"m"); + } + break; + } + } + } + + /** + * function used to check weather page is active or not + */ + function is_active($id) + { + global $db; + $result = $db->count(tbl($this->page_tbl),"page_id"," page_id='$id' AND active='yes' "); + if($result>0) + return true; + else + return false; + } + + + /** + * Function used to update order + */ + function update_order() + { + global $db; + $pages = $this->get_pages(); + foreach($pages as $page) + { + $db->update(tbl($this->page_tbl),array("page_order"),array($_POST['page_ord_'.$page['page_id']])," page_id='".$page['page_id']."'"); + } + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/collections.class.php b/upload/includes/classes/collections.class.php new file mode 100644 index 00000000..92bd4981 --- /dev/null +++ b/upload/includes/classes/collections.class.php @@ -0,0 +1,1876 @@ +cat_tbl = "collection_categories"; + $this->section_tbl = "collections"; + $this->types = array('videos' => lang("Videos"),'photos' => lang("Photos")); + ksort($this->types); + $this->setting_up_collections(); + $this->init_actions(); + + } + + /** + * Settings up Action Class + */ + function init_actions() + { + $this->action = new cbactions(); + $this->action->init(); // Setting up reporting excuses + $this->action->type = 'cl'; + $this->action->name = 'collection'; + $this->action->obj_class = 'cbcollection'; + $this->action->check_func = 'collection_exists'; + $this->action->type_tbl = "collections"; + $this->action->type_id_field = 'collection_id'; + } + + /** + * Setting links up in my account + */ + function setting_up_collections() + { + global $userquery,$Cbucket; + $per = $userquery->get_user_level(userid()); + // Adding My Account Links + if(isSectionEnabled('collections')) + $userquery->user_account[lang('Collections')] = array( + lang('add_new_collection') => "manage_collections.php?mode=add_new", + lang('manage_collections') => "manage_collections.php", + lang('manage_favorite_collections') => "manage_collections.php?mode=favorite" + ); + + // Adding Search Type + if(isSectionEnabled('collections')) + $Cbucket->search_types['collections'] = "cbcollection"; + + // Adding Collection links in Admin Area + if($per['collection_moderation'] == "yes") + $Cbucket->AdminMenu['Collections'] = array( + lang('Manage Collections')=>'collection_manager.php', + lang('Manage Categories')=>'collection_category.php', + lang('Flagged Collections')=>'flagged_collections.php'); + + + // Adding Collection links in Cbucket Class + $Cbucket->links['collections'] = array('collections.php','collections/'); + $Cbucket->links['manage_collections'] = array('manage_collections.php','manage_collections.php'); + $Cbucket->links['edit_collection'] = array('manage_collections.php?mode=edit_collection&cid=', + 'manage_collections.php?mode=edit_collection&cid='); + $Cbucket->links['manage_items'] = array('manage_collections.php?mode=manage_items&cid=%s&type=%s', + 'manage_collections.php?mode=manage_items&cid=%s&type=%s'); + $Cbucket->links['user_collections'] = array('user_collections.php?mode=uploaded&user=','user_collections.php?mode=uploaded&user='); + $Cbucket->links['user_fav_collections'] = array('user_collections.php?mode=favorite&user=','user_collections.php?mode=favorite&user='); + + + } + + /** + * Initiatting Search + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "collections"; + $this->search->columns = array( + array("field"=>"collection_name","type"=>"LIKE","var"=>"%{KEY}%"), + array("field"=>"collection_tags","type"=>"LIKE","var"=>"%{KEY}%","op"=>"OR") + ); + $this->search->match_fields = array("collection_name","collection_tags"); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/collection.html'; + $this->search->template_var = 'collection'; + $this->search->has_user_id = true; + + $sorting = array( + 'date_added'=> lang("date_added"), + 'views' => lang("views"), + 'total_comments' => lang("comments"), + 'total_objects' => lang("Items") + ); + + $this->search->sorting = array( + 'date_added'=> " date_added DESC", + 'views' => " views DESC", + 'total_comments' => " total_comments DESC ", + 'total_objects' => " total_objects DESC" + ); + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['collections'] = array('title'=>lang('collections')); + $this->search->results_per_page = config('videos_items_search_page'); + + $fields = array( + 'query' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'query', + 'id'=> 'query', + 'value'=>cleanForm($default['query']) + ), + 'category' => array( + 'title' => lang('category'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'category_type' => 'collections' + ), + 'uploaded' => array( + 'title' => lang('uploaded'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['collections']['fields'] = $fields; + } + + /** + * Function used to set-up sharing + */ + function set_share_mail($data) + { + $this->share_variables = array( + '{name}' => $data['collection_name'], + '{description}' => $data['collection_description'], + '{type}' => $data['type'], + '{total_items}' => $data['total_objects'], + '{collection_link}' => $this->collection_links($data,'view'), + '{collection_thumb}' => $this->get_thumb($data,'small',TRUE) + ); + $this->action->share_template_name = 'collection_share_template'; + $this->action->val_array = $this->share_variables; + } + + /** + * Function used to check if collection exists + */ + function collection_exists($id) + { + global $db; + $result = $db->count(tbl($this->section_tbl),"collection_id"," collection_id = $id"); + if($result) + return true; + else + return false; + } + + /** + * Function used to check if object exists + * This is a replica of actions.class, exists function + */ + function object_exists($id) + { + $obj = $this->objClass; + global ${$obj}; + $obj = ${$obj}; + $func = $this->objFunction; + return $obj->{$func}($id); + } + + /** + * Function used to get collection + */ + function get_collection($id,$cond=NULL) + { + global $db; + $result = $db->select(tbl($this->section_tbl).",".tbl("users"), + "".tbl($this->section_tbl).".*,".tbl('users').".userid,".tbl('users').".username", + " ".tbl($this->section_tbl).".collection_id = $id AND ".tbl($this->section_tbl).".userid = ".tbl('users').".userid $cond"); + //echo $db->db_query; + if($result) + return $result[0]; + else + return false; + } + + function is_viewable($cid) + { + global $userquery; + + $c = $this->get_collection($cid); + if(empty($c)) + { + e(lang('collection_not_exists')); + return false; + } elseif($c['active'] == 'no') { + e(lang('collection_not_active')); + if(!has_access('admin_access',TRUE)) + return false; + else + return true; + } elseif($c['broadcast'] == 'private' && !$userquery->is_confirmed_friend($c['userid'],userid()) + && $c['userid']!=userid() && !has_access('admin_access',TRUE)) + { + e(lang('collection_is_private')); + return false; + } else { + return true; + } + } + + /** + * Function used to get collections + */ + function get_collections($p=NULL) + { + global $db; + + $limit = $p['limit']; + $order = $p['order']; + $cond = ""; + + if(!has_access('admin_access',TRUE) && $p['user'] != userid()) + $cond .= " ".tbl('collections.active')." = 'yes'"; + elseif($p['user'] == userid()) + $cond .= " ".tbl('collections.active')." = 'yes'"; + else + { + if($p['active']) + { + $cond .= " ".tbl('collections.active')." = '".$p['active']."'"; + } + + if($p['broadcast']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.broadcast')." = '".$p['broadcast']."'"; + } + } + + if($p['category']) + { + $get_all = false; + if(!is_array($p['category'])) + if(strtolower($p['category']) == 'all') + $get_all = true; + + if(!$get_all) + { + if($cond != '') + $cond .= " AND "; + + $cond .= "("; + if(!is_array($p['category'])) + $cats = explode(',',$p['category']); + else + $cats = $p['category']; + $count = 0; + + foreach($cats as $cat) + { + $count++; + if($count > 1) + $cond .= " OR "; + $cond .= " ".tbl('collections.category')." LIKE '%#$cat#%'"; + } + $cond .= ")"; + } + } + + if($p['date_span']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".cbsearch::date_margin("date_added",$p['date_span']); + } + + if($p['user']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.userid')." = '".$p['user']."'"; + } + + if($p['type']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.type')." = '".$p['type']."'"; + } + + if($p['featured']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.featured')." = '".$p['featured']."'"; + } + + if($p['public_upload']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.public_upload')." = '".$p['public_upload']."'"; + } + + if($p['exclude']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.collection_id')." <> '".$p['exclude']."'"; + } + + if($p['cid']) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.collection_id')." = '".$p['cid']."'"; + } + + + + /** Get only with those who have items **/ + if($p['has_items'] ) + { + if($cond != '') + $cond .= " AND "; + $cond .= " ".tbl('collections.total_objects')." >= '1'"; + } + + + $title_tag = ''; + + if($p['name']) + { + $title_tag .= " ".tbl('collections.collection_name')." LIKE '%".$p['name']."%'"; + } + + if($p['tags']) + { + $tags = explode(",",$p['tags']); + if(count($tags)>0) + { + if($title_tag != '') + $title_tag .= " OR "; + $total = count($tags); + $loop = 1; + foreach($tags as $tag) + { + $title_tag .= " ".tbl('collections.collection_tags')." LIKE '%$tag%'"; + if($loop<$total) + $title_tag .= " OR "; + $loop++; + } + } else { + if($title_tag != '') + $title_tag .= " OR "; + $title_tag .= " ".tbl('collections.collection_tags')." LIKE '%".$p['tags']."%'"; + } + } + + if($title_tag != "") + { + if($cond != '') + $cond .= " AND "; + $cond .= " ($title_tag) "; + } + + if(!$p['count_only']) + { + if($cond != "") + $cond .= " AND "; + $result = $db->select(tbl("collections,users"), + tbl("collections.*,users.userid,users.username"), + $cond.tbl("collections.userid")." = ".tbl("users.userid"),$limit,$order); + + //echo $db->db_query; + + } + + if($p['count_only']) + { + return $result = $db->count(tbl("collections"),"collection_id",$cond); + //echo $db->db_query; + } + + if($p['assign']) + assign($p['assign'],$result); + else + return $result; + + } + + /** + * Function used to get collection items + */ + function get_collection_items($id,$order=NULL,$limit=NULL) + { + global $db; + $result = $db->select(tbl($this->items),"*"," collection_id = $id",$limit,$order); + if($result) + return $result; + else + return false; + } + + /** + * Function used to get next / previous collection item + */ + function get_next_prev_item($ci_id,$cid,$item="prev",$limit=1,$check_only=false) + { + global $db; + $iTbl = tbl($this->items); + $oTbl = tbl($this->objTable); + $uTbl = tbl('users'); + $tbls = $iTbl.",".$oTbl.",".$uTbl; + + if($item == "prev") + { + $op = ">"; + $order = ''; + } + elseif($item == "next") + { + $op = "<"; + $order = $iTbl.".ci_id DESC"; + } + elseif($item == NULL) + { + $op = "="; + $order = ''; + } + + $cond = " $iTbl.collection_id = $cid AND $iTbl.ci_id $op $ci_id AND $iTbl.object_id = $oTbl.".$this->objFieldID." AND $oTbl.userid = $uTbl.userid"; + if(!$check_only) + { + $result = $db->select($tbls,"$iTbl.*,$oTbl.*,$uTbl.username", $cond,$limit,$order); + + // Result was empty. Checking if we were going backwards, So bring last item + if(empty($result) && $item == "prev") + { + $order = $iTbl.".ci_id ASC"; + $op = "<"; + $result = $db->select($tbls,"$iTbl.*,$oTbl.*,$uTbl.username", " $iTbl.collection_id = $cid AND $iTbl.ci_id $op $ci_id AND $iTbl.object_id = $oTbl.".$this->objFieldID." AND $oTbl.userid = $uTbl.userid",$limit,$order); + } + + // Result was empty. Checking if we were going fowards, So bring first item + if(empty($result) && $item == "next") + { + $order = $iTbl.".ci_id DESC"; + $op = ">"; + $result = $db->select($tbls,"$iTbl.*,$oTbl.*,$uTbl.username", " $iTbl.collection_id = $cid AND $iTbl.ci_id $op $ci_id AND $iTbl.object_id = $oTbl.".$this->objFieldID." AND $oTbl.userid = $uTbl.userid",$limit,$order); + } + } + + if($check_only) + { + $result = $db->count($iTbl.",".$oTbl,"$iTbl.ci_id", " $iTbl.collection_id = $cid AND $iTbl.ci_id $op $ci_id AND $iTbl.object_id = $oTbl.".$this->objFieldID,$limit,$order); + } + + //echo $db->db_query; + if($result) + return $result; + else + return false; + + } + + /** + * Function used to set cookie on moving + * forward or backward + */ + function set_item_cookie($value) + { + if(isset($_COOKIE['current_item'])) + unset($_COOKIE['current_item']); + + setcookie('current_item',$value,time()+240); + } + + /** + * Function used to get collection items with details + */ + function get_collection_items_with_details($id,$order=NULL,$limit=NULL,$count_only=FALSE) + { + global $db; + $itemsTbl = tbl($this->items); + $objTbl = tbl($this->objTable); + $tables = $itemsTbl.",".$objTbl.",".tbl("users"); + + if(!$count_only) + { + $result = $db->select($tables,"$itemsTbl.ci_id,$itemsTbl.collection_id,$objTbl.*,".tbl('users').".username"," $itemsTbl.collection_id = '$id' AND $itemsTbl.object_id = $objTbl.".$this->objFieldID." AND $objTbl.userid = ".tbl('users').".userid",$limit,$order); + //echo $db->db_query; + } else { + $result = $db->count($itemsTbl,"ci_id"," collection_id = $id"); + } + + if($result) + { + return $result; + } + else + return false; + } + + /** + * Function used to get collection items with + * specific fields + */ + function get_collection_item_fields($cid,$objID,$fields) + { + global $db; + $result = $db->select(tbl($this->items),$fields," object_id = $objID AND collection_id = $cid"); + if($result) + return $result; + else + return false; + } + + /** + * Function used to load collections fields + */ + function load_required_fields($default=NULL) + { + if($default==NULL) + $default = $_POST; + + $name = $default['collection_name']; + $description = $default['collection_description']; + $tags = $default['collection_tags']; + $type = $default['type']; + if(is_array($default['category'])) + $cat_array = array($default['category']); + else + { + preg_match_all('/#([0-9]+)#/',$default['category'],$m); + $cat_array = array($m[1]); + } + + $reqFileds = array + ( + 'name' => array( + 'title'=> lang("collection_name"), + 'type' => 'textfield', + 'name' => 'collection_name', + 'id' => 'collection_name', + 'value' => cleanForm($name), + 'db_field' => 'collection_name', + 'required' => 'yes', + 'invalid_err' => lang("collect_name_er") + ), + + 'desc' => array( + 'title' => lang("collection_description"), + 'type' => 'textarea', + 'name' => 'collection_description', + 'id' => 'colleciton_desciption', + 'value' => cleanForm($description), + 'db_field' => 'collection_description', + 'required' => 'yes', + 'anchor_before' => 'before_desc_compose_box', + 'invalid_err' => lang("collect_descp_er") + ), + 'tags' => array( + 'title' => lang("collection_tags"), + 'type' => 'textfield', + 'name' => 'collection_tags', + 'id' => 'collection_tags', + 'value' => cleanForm(genTags($tags)), + 'hint_2' => lang("collect_tag_hint"), + 'db_field' => 'collection_tags', + 'required' => 'yes', + 'invalid_err' => lang("collect_tag_er"), + 'validate_function' => 'genTags' + ), + + 'cat' => array( + 'title' => lang("collect_category"), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'db_field' => 'category', + 'required' => 'yes', + 'validate_function' => 'validate_collection_category', + 'invalid_err' => lang('collect_cat_er'), + 'display_function' => 'convert_to_categories', + 'category_type' => 'collections' + ), + + 'type' => array( + 'title' => lang("collect_type"), + 'type' => 'dropdown', + 'name' => 'type', + 'id' => 'type', + 'value' => $this->types, + 'db_field' => 'type', + 'required' => 'yes', + 'checked' => $type + ) + ); + + return $reqFileds; + } + + /** + * Function used to load collections optional fields + */ + function load_other_fields($default=NULL) + { + if($default==NULL) + $default = $_POST; + + $broadcast = $default['broadcast']; + $allow_comments = $default['allow_comments']; + $public_upload = $default['public_upload']; + + $other_fields = array + ( + 'broadcast' => array( + 'title' => lang("vdo_br_opt"), + 'type' => 'radiobutton', + 'name' => 'broadcast', + 'id' => 'broadcast', + 'value' => array("public"=>lang("collect_borad_pub"),"private"=>lang("collect_broad_pri")), + 'checked' => $broadcast, + 'db_field' => 'broadcast', + 'required' => 'no', + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ), + 'comments' => array( + 'title' => lang("comments"), + 'type' => 'radiobutton', + 'id' => 'allow_comments', + 'name' => 'allow_comments', + 'value' => array("yes"=>lang("vdo_allow_comm"),"no"=>lang("vdo_dallow_comm")), + 'checked' => $allow_comments, + 'db_field' => 'allow_comments', + 'required' => 'no', + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ), + 'public_upload' => array( + 'title' => lang("collect_allow_public_up"), + 'type' => 'radiobutton', + 'id' => 'public_upload', + 'name' => 'public_upload', + 'value' => array("no"=>lang("collect_pub_up_dallow"),"yes"=>lang("collect_pub_up_allow")), + 'checked' => $public_upload, + 'db_field' => 'public_upload', + 'required' => 'no', + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'no' + ) + ); + return $other_fields; + } + + /** + * Function used to validate form fields + */ + function validate_form_fields($array=NULL) + { + $reqFileds = $this->load_required_fields($array); + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + + $otherFields = $this->load_other_fields($array); + + $collection_fields = array_merge($reqFileds,$otherFields); + + validate_cb_form($collection_fields,$array); + } + + /** + * Function used to validate collection category + * @param input array + */ + function validate_collection_category($array=NULL) + { + if($array==NULL) + $array = $_POST['category']; + if(count($array)==0) + return false; + else + { + + foreach($array as $arr) + { + if($this->category_exists($arr)) + $new_array[] = $arr; + } + } + if(count($new_array)==0) + { + e(lang('vdo_cat_err3')); + return false; + } + /*elseif(count($new_array)>ALLOWED_GROUP_CATEGORIES) + { + e(sprintf(lang('vdo_cat_err2'),ALLOWED_GROUP_CATEGORIES)); + return false; + }*/ + + return true; + } + + /** + * Function used to create collections + */ + function create_collection($array=NULL) + { + global $db, $userquery; + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $this->validate_form_fields($array); + + if(!error()) + { + $fields = $this->load_required_fields($array); + $collection_fields = array_merge($fields,$this->load_other_fields($array)); + + if(count($this->custom_collection_fields) > 0) + $collection_fields = array_merge($collection_fields,$this->custom_collection_fields); + + foreach($collection_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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + } + + // date_added + $query_field[] = "date_added"; + $query_val[] = NOW(); + + // user + $query_field[] = "userid"; + if($array['userid']) + $query_val[] = $userid = $array['userid']; + else + $query_val[] = $userid = userid(); + + // active + $query_field[] = "active"; + $query_val[] = "yes"; + + $insert_id = $db->insert(tbl($this->section_tbl),$query_field,$query_val); + + addFeed(array('action'=>'add_collection','object_id' => $insert_id,'object'=>'collection')); + + //Incrementing usr collection + $db->update(tbl("users"),array("total_collections"),array("|f|total_collections+1")," userid='".$userid."'"); + + e(lang("collect_added_msg"),"m"); + return $insert_id; + } + } + + /** + * Function used to get collection owner + */ + function get_collection_owner($cid) + { + global $db; + $cid = mysql_clean($cid); + $user_tbl = tbl("users"); + $result = $db->select(tbl($this->section_tbl.",users"),tbl($this->section_tbl).".*,$user_tbl.userid,$user_tbl.username"," collection_id = $cid AND ".tbl($this->section_tbl).".userid = $user_tbl.userid"); + if($db->num_rows > 0) + return $result[0]['userid']; + else + return false; + } + + /** + * Function used to add item in collection + */ + function add_collection_item($objID,$cid) + { + global $db; + + $objID = mysql_clean($objID); + $cid = mysql_clean($cid); + + if($array==NULL) + $array = $_POST; + + if($this->collection_exists($cid)) + { + if(!userid()) + e(lang("you_not_logged_in")); + elseif(!$this->object_exists($objID)) + e(sprintf(lang("object_does_not_exists"),$this->objName)); + elseif($this->object_in_collection($objID,$cid)) + e(sprintf(lang("object_exists_collection"),$this->objName)); + else + { + $flds = array("collection_id","object_id","type","userid","date_added"); + $vls = array($cid,$objID,$this->objType,userid(),NOW()); + $db->insert(tbl($this->items),$flds,$vls); + $db->update(tbl($this->section_tbl),array("total_objects"),array("|f|total_objects+1")," collection_id = $cid"); + e(sprintf(lang("item_added_in_collection"),$this->objName),"m"); + } + } else { + e(lang("collect_not_exist")); + } + } + + /** + * Function used to check if object exists in collection + */ + function object_in_collection($id,$cid) + { + global $db; + $id = mysql_clean($id); + $cid = mysql_clean($cid); + $result = $db->select(tbl($this->items),"*"," object_id = $id AND collection_id = $cid"); + if($result) + return $result[0]; + else + return false; + } + + /** + * Function used to get collection field vlaue + */ + function get_collection_field($cid,$field=NULL) + { + global $db; + if($field==NULL) + $field = "*"; + else + $field = $field; + + if(is_array($cid)) + $id = $cid['collection_id']; + else + $id = $cid; + + $cid = mysql_clean($cid); + $field = mysql_clean($field); + + $result = $db->select(tbl($this->section_tbl),$field," collection_id = $id"); + if($result) + { + if(count($result[0]) > 2) + return $result[0]; + else + return $result[0][$field]; + } else + return false; + } + + /** + * Function used to check if user collection owner + */ + function is_collection_owner($cdetails,$userid=NULL) + { + if($userid==NULL) + $userid = userid(); + + if(!is_array($cdetails)) + $details = $this->get_collection($cdetails); + else + $details = $cdetails; + + if($details['userid'] == $userid) + return true; + else + return false; + } + + /** + * Function used to delete collection + */ + function delete_collection($cid) + { + global $db,$eh; + $collection = $this->get_collection($cid); + if(empty($collection)) + e(lang("collection_not_exists")); + elseif($collection['userid'] != userid() && !has_access('admin_access',true)) + e(lang("cant_perform_action_collect")); + else + { + + $cid = mysql_clean($cid); + $del_funcs = $this->collection_delete_functions; + if(is_array($del_funcs) && !empty($del_funcs)) + { + foreach($del_funcs as $func) + { + if(function_exists($func)) + $func($collection); + } + } + + $db->delete(tbl($this->items),array("collection_id"),array($cid)); + $this->delete_thumbs($cid); + $db->delete(tbl($this->section_tbl),array("collection_id"),array($cid)); + + //Decrementing users total collection + $db->update(tbl("users"),array("total_collections"),array("|f|total_collections-1")," userid='".$cid."'"); + //Removing video Comments + $db->delete(tbl("comments"),array("type","type_id"),array("cl",$cid)); + //Removing video From Favortes + $db->delete(tbl("favorites"),array("type","id"),array("cl",$cid)); + $eh->flush(); + e(lang("collection_deleted"),"m"); + } + } + + /** + * Function used to delete collection items + */ + function delete_collection_items($cid) + { + global $db; + $cid = mysql_clean($cid); + $collection = $this->get_collection($id); + if(!$collection) + e(lang("collection_not_exists")); + elseif($collection['userid'] != userid() && !has_access('admin_access',true)) + e(lang("cant_perform_action_collect")); + else { + $db->delete(tbl($this->items),array("collection_id"),array($cid)); + $db->update(tbl($this->section_tbl),array("total_objects"),array($this->count_items($cid))," collection_id = $cid"); + e(lang("collect_items_deleted"),"m"); + } + } + + /** + * Function used to delete collection items + */ + function remove_item($id,$cid) + { + global $db; + $id = mysql_clean($id); + $cid = mysql_clean($cid); + + if($this->collection_exists($cid)) + { + if(!userid()) + e(lang("you_not_logged_in")); + elseif(!$this->object_in_collection($id,$cid)) + e(sprintf(lang("object_not_in_collect"),$this->objName)); + elseif(!$this->is_collection_owner($cid) && !has_access('admin_access',true)) + e(lang("cant_perform_action_collect")); + else + { + $db->execute("DELETE FROM ".tbl($this->items)." WHERE object_id = $id AND collection_id = $cid"); + $db->update(tbl($this->section_tbl),array("total_objects"),array("|f|total_objects-1")," collection_id = $cid"); + e(sprintf(lang("collect_item_removed"),$this->objName),"m"); + } + } else { + e(lang('collect_not_exists')); + return false; + } + } + + /** + * Function used to count collection items + */ + function count_items($cid) + { + global $db; + $cid = mysql_clean($cid); + $count = $db->count($this->items,"ci_id"," collection_id = $cid"); + if($count) + return $count; + else + return 0; + } + + /** + * Function used to delete collection preview + */ + function delete_thumbs($cid) + { + $cid = mysql_clean($cid); + + $glob = glob(COLLECT_THUMBS_DIR."/$cid*.jpg"); + if($glob) + { + foreach($glob as $file) + { + if(file_exists($file)) + unlink($file); + } + } else { + return false; + } + } + + /** + * Function used to create collection preview + */ + function upload_thumb($cid,$file) + { + global $imgObj,$cbphoto; + $file_ext = strtolower(getext($file['name'])); + $exts = array("jpg","gif","jpeg","png"); + + foreach($exts as $ext) + { + if($ext == $file_ext) + { + $thumb = COLLECT_THUMBS_DIR."/".$cid.".".$ext; + $sThumb = COLLECT_THUMBS_DIR."/".$cid."-small.".$ext; + foreach($exts as $un_ext) + if(file_exists(COLLECT_THUMBS_DIR."/".$cid.".".$un_ext) && file_exists(COLLECT_THUMBS_DIR."/".$cid."-small.".$un_ext)) + { + unlink(COLLECT_THUMBS_DIR."/".$cid.".".$un_ext); + unlink(COLLECT_THUMBS_DIR."/".$cid."-small.".$un_ext); + } + move_uploaded_file($file['tmp_name'],$thumb); + if(!$imgObj->ValidateImage($thumb,$ext)) + e("pic_upload_vali_err"); + else + { + $imgObj->createThumb($thumb,$thumb,$this->collect_thumb_width,$ext,$this->collect_thumb_height); + $imgObj->createThumb($thumb,$sThumb,$this->collect_small_thumb_width,$ext,$this->collect_small_thumb_height); + } + } + } + } + + /** + * Function used to create collection preview + */ + function update_collection($array=NULL) + { + global $db; + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $this->validate_form_fields($array); + $cid = $array['collection_id']; + + if(!error()) + { + $reqFields = $this->load_required_fields($array); + $otherFields = $this->load_other_fields($array); + + $collection_fields = array_merge($reqFields,$otherFields); + if($this->custom_collection_fields > 0) + $collection_fields = array_merge($collection_fields,$this->custom_collection_fields); + foreach($collection_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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + + if(has_access('admin_access',TRUE)) + { + + if(!empty($array['total_comments'])) + { + $total_comments = $array['total_comments']; + if(!is_numeric($total_comments) || $total_comments<0) + $total_comments = 0; + + $query_field[] = "total_comments"; + $query_val[] = $total_comments; + } + + if(!empty($array['total_objects'])) + { + $tobj = $array['total_objects']; + if(!is_numeric($tobj) || $tobj<0) + $tobj = 0; + $query_field[] = "total_objects"; + $query_val[] = $tobj; + } + } + } + + if(!error()) + { + if(!userid()) + e(lang("you_not_logged_in")); + elseif(!$this->collection_exists($cid)) + e(lang("collect_not_exist")); + elseif(!$this->is_collection_owner($cid,userid()) && !has_access('admin_access',TRUE)) + e(lang("cant_edit_collection")); + else + { + $cid = mysql_clean($cid); + $db->update(tbl($this->section_tbl),$query_field,$query_val," collection_id = $cid"); + e(lang("collection_updated"),"m"); + + if(!empty($array['collection_thumb']['tmp_name'])) + $this->upload_thumb($cid,$array['collection_thumb']); + } + } + } + + /** + * Function used get default thumb + */ + function get_default_thumb($size=NULL) + { + if($size=="small" && file_exists(TEMPLATEDIR."/images/thumbs/collection_thumb-small.png")) + { + return TEMPLATEDIR."/images/thumbs/collection_thumb-small.png"; + } elseif(!$size && file_exists(TEMPLATEDIR."/images/thumbs/collection_thumb.png")) { + return TEMPLATEDIR."/images/thumbs/collection_thumb.png"; + } else { + if($size == "small") + $thumb = COLLECT_THUMBS_URL."/no_thumb-small.png"; + else + $thumb = COLLECT_THUMBS_URL."/no_thumb.png"; + + return $thumb; + } + } + + /** + * Function used get collection thumb + */ + function get_thumb($cdetails,$size=NULL,$return_c_thumb=false) + { + + if(is_numeric($cdetails)) + { + $cdetails = $this->get_collection($cdetails); + $cid = $cdetails['collection_id']; + } else + $cid = $cdetails['collection_id']; + + $exts = array("jpg","png","gif","jpeg"); + + if($return_c_thumb) + { + foreach($exts as $ext) + { + if($size=="small") + $s = "-small"; + if(file_exists(COLLECT_THUMBS_DIR."/".$cid.$s.".".$ext)) + return COLLECT_THUMBS_URL."/".$cid.$s.".".$ext; + } + } else { + + $item = $this->get_collection_items($cid,'ci_id DESC',1); + $type = $item[0]['type']; + switch($type) + { + case "v": + { + global $cbvideo; + $thumb = get_thumb($cbvideo->get_video_details($item[0]['object_id'])); + } + break; + + case "p": + { + global $cbphoto; + $thumb = $cbphoto->get_image_file($cbphoto->get_photo($item[0]['object_id'])); + } + } + + if($thumb) + return $thumb; + else + { + foreach($exts as $ext) + { + if($size=="small") + $s = "-small"; + if(file_exists(COLLECT_THUMBS_DIR."/".$cid.$s.".".$ext)) + return COLLECT_THUMBS_URL."/".$cid.$s.".".$ext; + } + } + } + + return $this->get_default_thumb($size); + } + + + /** + * Used to display collection voterts details. + * User who rated, how many stars and when user rated + */ + function collection_voters($id,$return_array=FALSE,$show_all=FALSE) + { + global $json; + $c= $this->get_collection($id); + if((!empty($c) && $c['userid'] == userid()) || $show_all === TRUE) + { + global $userquery; + $voters = $c['voters']; + if(phpversion() < "5.2.0") + $voters = $json->json_decode($voters,TRUE); + else + $voters = json_decode($voters,TRUE); + + if(!empty($voters)) + { + if($return_array) + return $voters; + else + { + foreach($voters as $id=>$details) + { + $username = get_username($id); + $output = "
  • "; + $output .= "$username"; + $output .= " rated ". $details['rate']/2 ." stars ("; + $output .= niceTime($details['time']).")"; + $output .= "
  • "; + echo $output; + } + } + } + } else + return false; + } + + + /** + * Used to get current rating + */ + function current_rating($id) + { + global $db; + $id = mysql_clean($id); + $result = $db->select(tbl('collections'),'allow_rating,rating,rated_by,voters,userid'," collection_id = ".$id.""); + if($result) + return $result[0]; + else + return false; + } + + + /** + * Used to rate photo + */ + function rate_collection($id,$rating) + { + global $db,$json; + + if(!is_numeric($rating) || $rating <= 9) + $rating = 0; + if($rating >= 10) + $rating = 10; + + $c_rating = $this->current_rating($id); + $voters = $c_rating['voters']; + + $new_rate = $c_rating['rating']; + $rated_by = $c_rating['rated_by']; + + if(phpversion < '5.2.0') + $voters = $json->json_decode($voters,TRUE); + else + $voters = json_decode($voters,TRUE); + + if(!empty($voters)) + $already_voted = array_key_exists(userid(),$voters); + + + + if(!userid()) + e(lang("please_login_to_rate")); + elseif(userid()==$c_rating['userid'] && !config('own_collection_rating')) + e(lang("you_cannot_rate_own_collection")); + elseif(!empty($already_voted)) + e(lang("you_hv_already_rated_photo")); + elseif($c_rating['allow_rating'] == 'no' || !config('collection_rating')) + e(lang("collection_rating_not_allowed")); + else + { + $voters[userid()] = array('rate'=>$rating,'time'=>NOW()); + if(phpversion < '5.2.0') + $voters = $json->json_encode($voters); + else + $voters = json_encode($voters); + + $t = $c_rating['rated_by'] * $c_rating['rating']; + $rated_by = $c_rating['rated_by'] + 1; + $new_rate = ($t + $rating) / $rated_by; + + $id = mysql_clean($id); + $db->update(tbl('collections'),array('rating','rated_by','voters'), + array("$new_rate","$rated_by","|no_mc|$voters"), + " collection_id = ".$id.""); + $userDetails = array( + "object_id" => $id, + "type" => "collection", + "time" => now(), + "rating" => $rating, + "userid" => userid(), + "username" => username() + ); + /* Updating user details */ + update_user_voted($userDetails); + e(lang("thnx_for_voting"),"m"); + } + + $return = array("rating"=>$new_rate,"rated_by"=>$rated_by,'total'=>10,"id"=>$id,"type"=>"collection","disable"=>"disabled"); + return $return; + } + + /** + * Function used generate collection link + */ + function collection_rating($cid,$type) + { + switch($type) + { + case "videos": + case "v": + { + global $cbvideo; + $items = $cbvideo->collection->get_collection_items_with_details($cid); + $total_rating = ''; + if(!empty($items)) + { + foreach($items as $item) + { + $total_rating += $item['rating']; + if(!empty($item['rated_by']) && $item['rated_by'] != 0) + $voters[] = $item['rated_by']; + } + } + } + break; + + case "photos": + case "p": + { + global $cbphoto; + $items = $cbphoto->collection->get_collection_items_with_details($cid); + $total_rating = ''; + if(!empty($items)) + { + foreach($items as $item) + { + $total_rating += $item['rating']; + if(!empty($item['rated_by']) && $item['rated_by'] != 0) + $voters[] = $item['rated_by']; + } + } + } + break; + } + $total_voters = count($voters); + if(!empty($total_rating) && $total_voters != 0) + { + $collect_rating = $total_rating / $total_voters; + return round($collect_rating,2); + } + } + + /** + * Function used to add comment + */ + function add_comment($comment,$obj_id,$reply_to=NULL,$force_name_email=false) + { + global $myquery,$db; + + $collection = $this->get_collection($obj_id); + if(!$collection) + e(lang("collect_not_exist")); + else + { + $obj_owner = $this->get_collection_field($collection,"userid"); + $cl_link = $this->collection_links($collection,'vc'); + $comment = $myquery->add_comment($comment,$obj_id,$reply_to,'cl',$obj_owner,$cl_link,$force_name_email); + //echo $comment; + if($comment) + { + $log_array = array + ( + 'success'=>'yes', + 'details'=> "comment on a collection", + 'action_obj_id' => $obj_id, + 'action_done_id' => $comment, + ); + insert_log('collection_comment',$log_array); + + $this->update_total_comments($obj_id); + } + return $comment; + } + } + + /** + * Function used to update total comments of collection + */ + function update_total_comments($cid) + { + global $db; + $count = $db->count(tbl("comments"),"comment_id"," type = 'cl' AND type_id = '$cid'"); + $db->update(tbl($this->section_tbl),array("total_comments","last_commented"),array($count,now())," collection_id = '$cid'"); + } + + /** + * Function used return collection links + */ + function collection_links($details,$type=NULL) + { + if(is_array($details)) + { + if(empty($details['collection_id'])) + return BASEURL; + else + $cdetails = $details; + } else { + if(is_numeric($details)) + $cdetails = $this->get_collection($details); + else + return BASEURL; + } + + if(!empty($cdetails)) + { + if($type == NULL || $type == "main") + { + if(SEO == 'yes') + return BASEURL."/collections"; + else + return BASEURL."/collections.php"; + } + elseif($type == "vc" || $type == "view_collection" ||$type == "view") + { + if(SEO == 'yes') + return BASEURL."/collection/".$cdetails['collection_id']."/".$cdetails['type']."/".SEO(($cdetails['collection_name'])).""; + else + return BASEURL."/view_collection.php?cid=".$cdetails['collection_id']."&type=".$cdetails['type']; + } elseif($type == "vi" || $type == "view_item" ||$type == "item") { + //$item_type = $this->get_collection_field($cdetails['collection_id'],'type'); + if($cdetails['videoid']) + $item_type = 'videos'; + else + $item_type = 'photos'; + switch($item_type) + { + case "videos": + case "v": + { + if(SEO == "yes") + return BASEURL."/item/".$item_type."/".$details['collection_id']."/".$details['videokey']."/".SEO(clean(str_replace(' ','-',$details['title']))); + else + return BASEURL."/view_item.php?item=".$details['videokey']."&type=".$item_type."&collection=".$details['collection_id']; + } + break; + + case "photos": + case "p": + { + if(SEO == "yes") + return BASEURL."/item/".$item_type."/".$details['collection_id']."/".$details['photo_key']."/".SEO(clean(str_replace(' ','-',$details['photo_title']))); + else + return BASEURL."/view_item.php?item=".$details['photo_key']."&type=".$item_type."&collection=".$details['collection_id']; + } + break; + } + } elseif($type == 'load_more' || $type == 'more_items' || $type='moreItems') { + if(empty($cdetails['page_no'])) + $cdetails['page_no'] = 2; + + if(SEO == 'yes') + return "?cid=".$cdetails['collection_id']."&type=".$cdetails['type']."&page=".$cdetails['page_no']; + else + return "?cid=".$cdetails['collection_id']."&type=".$cdetails['type']."&page=".$cdetails['page_no']; + } + } else { + return BASEURL; + } + } + + /** + * Used to update counts + */ + function update_collection_counts($id,$amount,$op) + { + global $db; + $db->update(tbl("collections"),array("total_objects"),array("|f|total_objects$op$amount")," collection_id = $id"); + } + + /** + * Used to change collection of product + */ + function change_collection($new,$obj,$old=NULL) + { + global $db; + + /* THIS MEANS OBJECT IS ORPHAN MOST PROBABLY AND HOPEFULLY - PHOTO + NOW WE WILL ADD $OBJ TO $NEW */ + if($old == 0 || $old == NULL) + { + $this->add_collection_item($obj,$new); + } else { + $update = $db->update(tbl($this->items),array('collection_id'),array($new)," collection_id = $old AND type = '".$this->objType."' AND object_id = $obj"); + + if(!empty($update)) + { + $this->update_collection_counts($new,1,'+'); + $this->update_collection_counts($old,1,'-'); + } + } + } + + /** + * Sorting links for collection + */ + function sorting_links() + { + if(!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + + $array = array + ('most_recent' => lang('recent'), + 'most_viewed' => lang('viewed'), + 'featured' => lang('featured'), + 'most_items' => lang('Most Items'), + 'most_commented' => lang('commented'), + ); + return $array; + } + + /** + * Used to perform actions on collection + */ + function collection_actions($action,$cid) + { + global $db; + $cid = mysql_clean($cid); + switch($action) + { + case "activate": + case "activation": + case "ac": + { + $db->update(tbl($this->section_tbl),array("active"),array("yes")," collection_id = $cid"); + e(lang("collection_activated"),"m"); + } + break; + + case "deactivate": + case "deactivation": + case "dac": + { + $db->update(tbl($this->section_tbl),array("active"),array("no")," collection_id = $cid"); + e(lang("collection_deactivated"),"m"); + } + break; + + case "make_feature": + case "featured": + case "mcf": + { + $db->update(tbl($this->section_tbl),array("featured"),array("yes")," collection_id = $cid"); + e(lang("collection_featured"),"m"); + } + break; + + case "make_unfeature": + case "unfeatured": + case "mcuf": + { + $db->update(tbl($this->section_tbl),array("featured"),array("no")," collection_id = $cid"); + e(lang("collection_unfeatured"),"m"); + } + break; + + default: + { + header("location:".BASEURL); + } + } + } + + /** + * Function used to get collection from its Item ID and type + * only get collections of logged in user + * @param : OBJ_ID + * @param : OBJ_Type + * @return : Object + */ + function getCollectionFromItem($objId,$type=NULL) + { + global $db; + if(!$type) + $type = $this->objType; + $userid=userid(); + $objId = mysql_clean($objId); + $results = $db->select(tbl('collections,collection_items'),'*', + tbl("collections.collection_id")." = ".tbl("collection_items.collection_id")." AND " + .tbl("collection_items.type='".$type."'")." AND ".tbl("collections.userid='".$userid."'")." AND " + .tbl("collections.active='yes'")." AND ".tbl("collection_items.object_id='".$objId."'")); + + if($db->num_rows>0) + $assign = $results; + else + $assign = false; + + return $assign; + + } + + /** + * Function used to remove item from collections + * and decrement collection item count + * @param : itemID + * @param : type + */ + function deleteItemFromCollections($objId,$type=NULL) + { + global $db,$cbvid; + if(!$type) + $type = $this->objType; + + $objId = mysql_clean($objId); + $db->update(tbl('collections,collection_items'),array('total_objects'),array('|f|total_objects -1'), + tbl("collections.collection_id")." = ".tbl("collection_items.collection_id")." AND " + .tbl("collection_items.type='".$type."'")." AND ".tbl("collection_items.object_id='".$objId."'")); + + + $db->execute("DELETE FROM ".tbl('collection_items')." WHERE " + .("type='".$type."'")." AND ".("object_id='".$objId."'")); + } + + + /** + * become collection contributor + * + * @param INT $collection_id + * @param INT $userid + * + * @return BOOLEAN + */ + function add_contributor($cid,$uid) + { + global $userquery; + $cid = mysql_clean($cid); + $uid = mysql_clean($uid); + + if(!$cid){ e(lang("Invalid collection id")); return false; } + if(!$uid){ e(lang("Invalid user id")); return false; } + + $collection = $this->get_collection($cid); + if(!$collection){ e(lang("Invalid collection")); return false;} + + if(!$userquery->user_exists($uid)){ e(lang("Invalid user")); return false;} + + if($collection['broadcast']!='public'){ e(lang("Collection is not public")); return false;} + + if($this->is_contributor($cid,$uid)){ e(lang("Contributor id already exists")); return false;} + + $query = array( + 'userid' => $uid, + 'collection_id' => $cid, + 'date_added' => now(), + ); + + $insert_id = db_insert(tbl('collection_contributors'),$query); + + if($insert_id) return $insert_id; + + return false; + + + } + + + /** + * function check if user is already a contributor + * + * @param INT $collection_id + * @param INT $userid + * + * @return BOOLEAN + */ + function is_contributor($cid,$uid) + { + $cid = mysql_clean($cid); + $uid = mysql_clean($uid); + + $query = " SELECT contributor_id FROM ".tbl('collection_contributors'); + $query .= " WHERE userid='$uid' AND collection_id ='$cid' LIMIT 1"; + $data = db_select($query); + + if($data) + return $data[0]['contributor_id']; + else + return false; + } + + /** + * Remove contributor + * + * @param INT $cid + * @param INT $uid + * + * @return BOOLEAN + */ + function remove_contributor($cid,$uid) + { + $cid = mysql_clean($cid); + $uid = mysql_clean($uid); + + if(!$this->is_contributor($cid,$uid)){ e(lang("User is yet a contributor")); return false;} + + $collection = $this->get_collection($cid); + + if($collection['userid'] != userid() && !has_access('collection_moderation') && $uid!=userid()) + { + e(lang('You cannot remove this contributor')); + } + + + $query = "DELETE FROM ".tbl('collection_contributors')." WHERE userid='$uid' LIMIT 1"; + global $db; + $db->Execute($query); + + return true; + } + + + /** + * function get collection for contributor + * + * @param $uid + * + */ + function get_contributor_collections($uid,$type='videos',$limit=NULL,$order="date_added DESC") + { + + $uid = mysql_clean($uid); + $limit = mysql_clean($limit); + $order = mysql_clean($order); + + $query = " SELECT cb.contributor_id,cl.* FROM ".tbl('collection_contributors')." AS cb "; + $query .= " LEFT JOIN ".tbl('collections')." AS cl ON cb.collection_id=cl.collection_id "; + $query .= " WHERE cb.userid='$uid' "; + $query .= " AND cl.broadcast='public' AND cl.active='yes' AND cl.type='$type' "; + + + if($order) + $query .=" ORDER BY ".$order; + + if($limit) + $query .= " LIMIT ".$limit; + + + $results = db_select($query); + + if($results) + return $results; + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/conversion/ffmpeg.class.php b/upload/includes/classes/conversion/ffmpeg.class.php new file mode 100644 index 00000000..94065451 --- /dev/null +++ b/upload/includes/classes/conversion/ffmpeg.class.php @@ -0,0 +1,1233 @@ +ffmpeg = FFMPEG_BINARY; + $this->mp4box = MP4Box_BINARY; + $this->flvtool2 = FLVTool2_BINARY; + $this->flvtoolpp = $Cbucket->configs['flvtoolpp']; + $this->mplayerpath = $Cbucket->configs['mplayerpath']; + $this->input_file = $file; + + } + + + /** + * Prepare file to be converted + * this will first get info of the file + * and enter its info into database + */ + function prepare($file=NULL) + { + global $db; + + if($file) + $this->input_file = $file; + + if(file_exists($this->input_file)) + $this->input_file = $this->input_file; + else + $this->input_file = TEMP_DIR.'/'.$this->input_file; + + + + //Checking File Exists + if(!file_exists($this->input_file)) + { + $this->log('File Exists','No'); + }else{ + $this->log('File Exists','Yes'); + } + + //Get File info + $this->input_details = $this->get_file_info(); + + //Loging File Details + $this->log .= "\nPreparing file...\n"; + $this->log_file_info(); + + //Insert Info into database + //$this->insert_data(); + + //Gett FFMPEG version + $result = shell_output(FFMPEG_BINARY." -version"); + $version = parse_version('ffmpeg',$result); + + + $this->vconfigs['map_meta_data'] = 'map_meta_data'; + + if(strstr($version,'Git')) + { + $this->vconfigs['map_meta_data'] = 'map_metadata'; + } + + } + + + /** + * Function used to convert video + */ + function convert($file=NULL,$for_iphone=false) + { + global $db; + if($file) + $this->input_file = $file; + + $this->log .= "\r\nConverting Video\r\n"; + + + $p = $this->configs; + $i = $this->input_details; + + # Prepare the ffmpeg command to execute + if(isset($p['extra_options'])) + $opt_av .= " -y {$p['extra_options']} "; + + # file format + if(isset($p['format'])) + $opt_av .= " -f {$p['format']} "; + + # video codec + if(isset($p['video_codec'])) + $opt_av .= " -vcodec ".$p['video_codec']; + elseif(isset($i['video_codec'])) + $opt_av .= " -vcodec ".$i['video_codec']; + if($p['video_codec'] == 'libx264') + $opt_av .= " -vpre normal "; + + # video rate + if($p['use_video_rate']) + { + if(isset($p['video_rate'])) + $vrate = $p['video_rate']; + elseif(isset($i['video_rate'])) + $vrate = $i['video_rate']; + if(isset($p['video_max_rate']) && !empty($vrate)) + $vrate = min($p['video_max_rate'],$vrate); + if(!empty($vrate)) + $opt_av .= " -r $vrate "; + } + + # video bitrate + if($p['use_video_bit_rate']) + { + if(isset($p['video_bitrate'])) + $vbrate = $p['video_bitrate']; + elseif(isset($i['video_bitrate'])) + $vbrate = $i['video_bitrate']; + if(!empty($vbrate)) + $opt_av .= " -b $vbrate "; + } + + + # video size, aspect and padding + + $this->calculate_size_padding( $p, $i, $width, $height, $ratio, $pad_top, $pad_bottom, $pad_left, $pad_right ); + $use_vf = config('use_ffmpeg_vf'); + if($use_vf=='no') + { + $opt_av .= " -s {$width}x{$height} -aspect $ratio -padcolor 000000 -padtop $pad_top -padbottom $pad_bottom -padleft $pad_left -padright $pad_right "; + }else + { + $opt_av .= "-s {$width}x{$height} -aspect $ratio -vf pad=0:0:0:0:black"; + } + + + # audio codec, rate and bitrate + if($p['use_audio_codec']) + { + if(!empty($p['audio_codec']) && $p['audio_codec'] != 'None'){ + $opt_av .= " -acodec {$p['audio_codec']}"; + } + } + + # audio bitrate + if($p['use_audio_bit_rate']) + { + if(isset($p['audio_bitrate'])) + $abrate = $p['audio_bitrate']; + elseif(isset($i['audio_bitrate'])) + $abrate = $i['audio_bitrate']; + if(!empty($abrate)) + { + $abrate_cmd = " -ab $abrate "; + $opt_av .= $abrate_cmd; + } + } + + # audio bitrate + if(!is_numeric($this->input_details['audio_rate'])) + { + + $opt_av .= " -an "; + }elseif($p['use_audio_rate']) + { + if(!$this->validChannels($this->input_details)) + { + $arate = $i['audio_rate']; + $opt_av .= $arate_cmd = " -ar $arate "; + }else + { + if(isset($p['audio_rate'])) + $arate = $p['audio_rate']; + elseif(isset($i['audio_rate'])) + $arate = $i['audio_rate']; + if(!empty($arate)) + $opt_av .= $arate_cmd = " -ar $arate "; + } + } + $tmp_file = time().RandomString(5).'.tmp'; + + //$opt_av .= '-'.$this->vconfigs['map_meta_data']." ".$this->output_file.":".$this->input_file; + + $this->raw_command = $command = $this->ffmpeg." -i ".$this->input_file." $opt_av ".$this->output_file." 2> ".TEMP_DIR."/".$tmp_file; + + //Updating DB + //$db->update($this->tbl,array('command_used'),array($command)," id = '".$this->row_id."'"); + + if(!$for_iphone) + { + $output = $this->exec($command); + if(file_exists(TEMP_DIR.'/'.$tmp_file)) + { + $output = $output ? $output : join("", file(TEMP_DIR.'/'.$tmp_file)); + unlink(TEMP_DIR.'/'.$tmp_file); + } + + + #FFMPEG GNERETAES Damanged File + #Injecting MetaData ysing FLVtool2 - you must have update version of flvtool2 ie 1.0.6 FInal or greater + if($this->flvtoolpp && file_exists($this->output_file) && @filesize($this->output_file)>0) + { + $tmp_file = time().RandomString(5).'flvtool2_output.tmp'; + $flv_cmd = $this->flvtoolpp." ".$this->output_file." ".$this->output_file." 2> ".TEMP_DIR."/".$tmp_file; + $flvtool2_output = $this->exec($flv_cmd); + if(file_exists(TEMP_DIR.'/'.$tmp_file)) + { + $flvtool2_output = $flvtool2_output ? $flvtool2_output : join("", file(TEMP_DIR.'/'.$tmp_file)); + unlink(TEMP_DIR.'/'.$tmp_file); + } + $output .= $flvtool2_output; + + }elseif($this->flvtool2 && file_exists($this->output_file) && @filesize($this->output_file)>0) + { + $tmp_file = time().RandomString(5).'flvtool2_output.tmp'; + $flv_cmd = $this->flvtool2." -U ".$this->output_file." 2> ".TEMP_DIR."/".$tmp_file; + $flvtool2_output = $this->exec($flv_cmd); + if(file_exists(TEMP_DIR.'/'.$tmp_file)) + { + $flvtool2_output = $flvtool2_output ? $flvtool2_output : join("", file(TEMP_DIR.'/'.$tmp_file)); + unlink(TEMP_DIR.'/'.$tmp_file); + } + $output .= $flvtool2_output; + } + + $this->log('Conversion Command',$command); + $this->log .="\r\n\r\nConversion Details\r\n\r\n"; + $this->log .=$output; + $this->output_details = $this->get_file_info($this->output_file); + } + + + + //Generating Mp4 for iphone + if($this->generate_iphone && $for_iphone) + { + $this->log .="\r\n\r\n== Generating Iphone Video ==\r\n\r\n"; + $tmp_file = 'iphone_log.log'; + $iphone_configs = ""; + $iphone_configs .= " -acodec libfaac "; + $iphone_configs .= " -vcodec mpeg4 "; + $iphone_configs .= " -r 25 "; + $iphone_configs .= " -b 600k "; + $iphone_configs .= " -ab 96k "; + + if($this->input_details['audio_channels']>2) + { + $arate = $i['audio_rate']; + $iphone_configs .= $arate_cmd = " -ar $arate "; + } + + $p['video_width'] = '480'; + $p['video_height'] = '320'; + + $this->calculate_size_padding( $p, $i, $width, $height, $ratio, $pad_top, $pad_bottom, $pad_left, $pad_right ); + $iphone_configs .= " -s {$width}x{$height} -aspect $ratio"; + + + $command = $this->ffmpeg." -i ".$this->input_file." $iphone_configs ".$this->raw_path."-m.mp4 2> ".TEMP_DIR."/".$tmp_file; + $this->exec($command); + + if(file_exists(TEMP_DIR.'/'.$tmp_file)) + { + $output = $output ? $output : join("", file(TEMP_DIR.'/'.$tmp_file)); + unlink(TEMP_DIR.'/'.$tmp_file); + } + + if(file_exists($this->raw_path."-m.mp4") && filesize($this->raw_path."-m.mp4")>0) + { + $this->has_mobile = 'yes'; + } + + $this->log('== iphone Conversion Command',$command); + $this->log .="\r\n\r\nConversion Details\r\n\r\n"; + $this->log .=$output; + + $this->log .="\r\n\r\n== Generating Iphone Video Ends ==\r\n\r\n"; + } + + } + + /** + * Function used to get file information using FFMPEG + * @param FILE_PATH + */ + function get_file_info( $path_source =NULL) { + + if(!$path_source) + $path_source = $this->input_file; + + # init the info to N/A + $info['format'] = 'N/A'; + $info['duration'] = 'N/A'; + $info['size'] = 'N/A'; + $info['bitrate'] = 'N/A'; + $info['video_width'] = 'N/A'; + $info['video_height'] = 'N/A'; + $info['video_wh_ratio'] = 'N/A'; + $info['video_codec'] = 'N/A'; + $info['video_rate'] = 'N/A'; + $info['video_bitrate'] = 'N/A'; + $info['video_color'] = 'N/A'; + $info['audio_codec'] = 'N/A'; + $info['audio_bitrate'] = 'N/A'; + $info['audio_rate'] = 'N/A'; + $info['audio_channels'] = 'N/A'; + $info['path'] = $path_source; + + # get the file size + $stats = @stat( $path_source ); + if( $stats === false ) + $this->log .= "Failed to stat file $path_source!\n"; + $info['size'] = (integer)$stats['size']; + $this->ffmpeg." -i $path_source -acodec copy -vcodec copy -f null /dev/null 2>&1"; + $this->raw_output = $output = $this->exec( $this->ffmpeg." -i $path_source -acodec copy -vcodec copy -y -f null /dev/null 2>&1" ); + + $this->raw_info = $info; + # parse output + if( $this->parse_format_info( $output ) === false ) + return false; + $info = $this->raw_info; + return $info; + } + + + + + + /** + * Function used to excute SHELL Scripts + */ + function exec( $cmd ) { + # use bash to execute the command + # add common locations for bash to the PATH + # this should work in virtually any *nix/BSD/Linux server on the planet + # assuming we have execute permission + //$cmd = "PATH=\$PATH:/bin:/usr/bin:/usr/local/bin bash -c \"$cmd\" "; + return shell_exec( $cmd); + } + + function pregMatch($in,$str) + { + preg_match("/$in/",$str,$args); + return $args; + } + + /** + * Author : Arslan Hassan + * parse format info + * + * output (string) + * - the ffmpeg output to be parsed to extract format info + * + * info (array) + * - see function get_encoding_progress + * + * returns: + * - (bool) false on error + * - (bool) true on success + */ + + function parse_format_info( $output ) { + $this->raw_info; + $info = $this->raw_info; + # search the output for specific patterns and extract info + # check final encoding message + if($args = $this->pregMatch( 'Unknown format', $output) ) { + $Unkown = "Unkown"; + } else { + $Unkown = ""; + } + if( $args = $this->pregMatch( 'video:([0-9]+)kB audio:([0-9]+)kB global headers:[0-9]+kB muxing overhead', $output) ) { + $video_size = (float)$args[1]; + $audio_size = (float)$args[2]; + } else { + return false; + } + + # check for last enconding update message + if($args = $this->pregMatch( '(frame=([^=]*) fps=[^=]* q=[^=]* L)?size=[^=]*kB time=([^=]*) bitrate=[^=]*kbits\/s[^=]*$', $output) ) { + $frame_count = $args[2] ? (float)ltrim($args[2]) : 0; + $duration = (float)$args[3]; + } else { + return false; + } + + + if(!$duration) + { + $duration = $this->pregMatch( 'Duration: ([0-9.:]+),', $output ); + $duration = $duration[1]; + + $duration = explode(':',$duration); + //Convert Duration to seconds + $hours = $duration[0]; + $minutes = $duration[1]; + $seconds = $duration[2]; + + $hours = $hours * 60 * 60; + $minutes = $minutes * 60; + + $duration = $hours+$minutes+$seconds; + } + + $info['duration'] = $duration; + if($duration) + { + $info['bitrate' ] = (integer)($info['size'] * 8 / 1024 / $duration); + if( $frame_count > 0 ) + $info['video_rate'] = (float)$frame_count / (float)$duration; + if( $video_size > 0 ) + $info['video_bitrate'] = (integer)($video_size * 8 / $duration); + if( $audio_size > 0 ) + $info['audio_bitrate'] = (integer)($audio_size * 8 / $duration); + # get format information + if($args = $this->pregMatch( "Input #0, ([^ ]+), from", $output) ) { + $info['format'] = $args[1]; + } + } + + # get video information + if( $args= $this->pregMatch( '([0-9]{2,4})x([0-9]{2,4})', $output ) ) { + + $info['video_width' ] = $args[1]; + $info['video_height' ] = $args[2]; + + /* if( $args[5] ) { + $par1 = $args[6]; + $par2 = $args[7]; + $dar1 = $args[8]; + $dar2 = $args[9]; + if( (int)$dar1 > 0 && (int)$dar2 > 0 && (int)$par1 > 0 && (int)$par2 > 0 ) + $info['video_wh_ratio'] = ( (float)$dar1 / (float)$dar2 ) / ( (float)$par1 / (float)$par2 ); + } + + + # laking aspect ratio information, assume pixel are square + if( $info['video_wh_ratio'] === 'N/A' )*/ + $info['video_wh_ratio'] = (float)$info['video_width'] / (float)$info['video_height']; + } + + if($args= $this->pregMatch('Video: ([^ ^,]+)',$output)) + { + $info['video_codec' ] = $args[1]; + } + + # get audio information + if($args = $this->pregMatch( "Audio: ([^ ]+), ([0-9]+) Hz, ([^\n,]*)", $output) ) { + $audio_codec = $info['audio_codec' ] = $args[1]; + $audio_rate = $info['audio_rate' ] = $args[2]; + $info['audio_channels'] = $args[3]; + } + + if(!$audio_codec || !$audio_rate) + { + $args = $this->pregMatch( "Audio: ([a-zA-Z0-9]+)(.*), ([0-9]+) Hz, ([^\n,]*)", $output); + $info['audio_codec' ] = $args[1]; + $info['audio_rate' ] = $args[3]; + $info['audio_channels'] = $args[4]; + } + + + $this->raw_info = $info; + # check if file contains a video stream + return $video_size > 0; + + #TODO allow files with no video (only audio)? + #return true; + } + + /** + * Function used to insert data into database + * @param ARRAY + */ + + function insert_data() + { + global $db; + //Insert Info into database + if(is_array($this->input_details)) + { + foreach($this->input_details as $field=>$value) + { + $fields[] = 'src_'.$field; + $values[] = $value; + } + $fields[] = 'src_ext'; + $values[] = getExt($this->input_details['path']); + $fields[] = 'src_name'; + $values[] = getName($this->input_details['path']); + + $db->insert(tbl($this->tbl),$fields,$values); + $this->row_id = $db->insert_id(); + } + } + + /** + * Function used to update data of + */ + function update_data($conv_only=false) + { + global $db; + //Insert Info into database + if(is_array($this->output_details) && !$conv_only) + { + foreach($this->output_details as $field=>$value) + { + $fields[] = 'output_'.$field; + $values[] = $value; + } + $fields[] = 'file_conversion_log'; + $values[] = $this->log; + $db->update(tbl($this->tbl),$fields,$values," id = '".$this->row_id."'"); + }else + $fields[] = 'file_conversion_log'; + $values[] = $this->log; + $db->update(tbl($this->tbl),$fields,$values," id = '".$this->row_id."'"); + } + + + /** + * Function used to add log in log var + */ + function log($name,$value) + { + $this->log .= $name.' : '.$value."\r\n"; + } + + /** + * Function used to start log + */ + function start_log() + { + $this->log = "Started on ".NOW()." - ".date("Y M d")."\r\n\n"; + $this->log .= "Checking File ....\r\n"; + $this->log('File',$this->input_file); + } + + /** + * Function used to log video info + */ + function log_file_info() + { + $details = $this->input_details; + if(is_array($details)) + { + foreach($details as $name => $value) + { + $this->log($name,$value); + } + }else{ + $this->log .=" Unknown file details - Unable to get video details using FFMPEG \n"; + } + } + /** + * Function log outpuit file details + */ + function log_ouput_file_info() + { + $details = $this->output_details; + if(is_array($details)) + { + foreach($details as $name => $value) + { + $this->log('output_'.$name,$value); + } + }else{ + $this->log .=" Unknown file details - Unable to get output video details using FFMPEG \n"; + } + } + + + + + /** + * Function used to time check + */ + function time_check() + { + $time = microtime(); + $time = explode(' ',$time); + $time = $time[1]+$time[0]; + return $time; + } + + /** + * Function used to start timing + */ + function start_time_check() + { + $this->start_time = $this->time_check(); + } + + /** + * Function used to end timing + */ + function end_time_check() + { + $this->end_time = $this->time_check(); + } + + /** + * Function used to check total time + */ + function total_time() + { + $this->total_time = round(($this->end_time-$this->start_time),4); + } + + + /** + * Function used to calculate video padding + */ + function calculate_size_padding( $parameters, $source_info, & $width, & $height, & $ratio, & $pad_top, & $pad_bottom, & $pad_left, & $pad_right ) + { + $p = $parameters; + $i = $source_info; + + switch( $p['resize'] ) { + # dont resize, use same size as source, and aspect ratio + # WARNING: some codec will NOT preserve the aspect ratio + case 'no': + $width = $i['video_width' ]; + $height = $i['video_height' ]; + $ratio = $i['video_wh_ratio']; + $pad_top = 0; + $pad_bottom = 0; + $pad_left = 0; + $pad_right = 0; + break; + # resize to parameters width X height, use same aspect ratio + # WARNING: some codec will NOT preserve the aspect ratio + case 'WxH': + $width = $p['video_width' ]; + $height = $p['video_height' ]; + $ratio = $i['video_wh_ratio']; + $pad_top = 0; + $pad_bottom = 0; + $pad_left = 0; + $pad_right = 0; + break; + # make pixel square + # reduce video size if bigger than p[width] X p[height] + # and preserve aspect ratio + case 'max': + $width = (float)$i['video_width' ]; + $height = (float)$i['video_height' ]; + $ratio = (float)$i['video_wh_ratio']; + $max_width = (float)$p['video_width' ]; + $max_height = (float)$p['video_height' ]; + + # make pixels square + if( $ratio > 1.0 ) + $width = $height * $ratio; + else + $height = @$width / $ratio; + + # reduce width + if( $width > $max_width ) { + $r = $max_width / $width; + $width *= $r; + $height *= $r; + } + + # reduce height + if( $height > $max_height ) { + $r = $max_height / $height; + $width *= $r; + $height *= $r; + } + + # make size even (required by many codecs) + $width = (integer)( ($width + 1 ) / 2 ) * 2; + $height = (integer)( ($height + 1 ) / 2 ) * 2; + # no padding + $pad_top = 0; + $pad_bottom = 0; + $pad_left = 0; + $pad_right = 0; + break; + # make pixel square + # resize video to fit inside p[width] X p[height] + # add padding and preserve aspect ratio + case 'fit': + # values need to be multiples of 2 in the end so + # divide width and height by 2 to do the calculation + # then multiply by 2 in the end + $ratio = (float)$i['video_wh_ratio']; + $width = (float)$i['video_width' ] / 2; + $height = (float)$i['video_height' ] / 2; + $trt_width = (float)$p['video_width' ] / 2; + $trt_height = (float)$p['video_height' ] / 2; + + # make pixels square + if( $ratio > 1.0 ) + $width = $height * $ratio; + else + $height = $width / $ratio; + + # calculate size to fit + $ratio_w = $trt_width / $width; + $ratio_h = $trt_height / $height; + + if( $ratio_h > $ratio_w ) { + $width = (integer)$trt_width; + $height = (integer)($width / $ratio); + } else { + $height = (integer)$trt_height; + $width = (integer)($height * $ratio); + } + + # calculate padding + $pad_top = (integer)(($trt_height - $height + 1) / 2); + $pad_left = (integer)(($trt_width - $width + 1) / 2); + $pad_bottom = (integer)($trt_height - $height - $pad_top ); + $pad_right = (integer)($trt_width - $width - $pad_left); + + # multiply by 2 to undo division and get multiples of 2 + $width *= 2; + $height *= 2; + $pad_top *= 2; + $pad_left *= 2; + $pad_bottom *= 2; + $pad_right *= 2; + break; + } + } + + + /** + * this will first check if there is a conversion lock or no + * if there is a lock then wait till its delete otherwise create a lock and move forward + */ + function isLocked($num=1) + { + for($i=0;$i<$num;$i++) + { + $conv_file = TEMP_DIR.'/conv_lock'.$i.'.loc'; + if(!file_exists($conv_file)) + { + $this->lock_file = $conv_file; + $file = fopen($conv_file,"w+"); + fwrite($file,"converting.."); + fclose($file); + return false; + } + } + + return true; + } + + /** + * Function used to perform all actions when converting a video + */ + function ClipBucket() + { + $conv_file = TEMP_DIR.'/conv_lock.loc'; + //We will now add a loop + //that will check weather + + while(1) + { + $use_crons = config('use_crons'); + if(!$this->isLocked(PROCESSESS_AT_ONCE) || $use_crons=='yes' || !$this->set_conv_lock) + { + + if($use_crons=='no') + { + //Lets make a file + $file = fopen($conv_file,"w+"); + fwrite($file,"converting.."); + fclose($file); + } + + + $this->start_time_check(); + $this->start_log(); + $this->prepare(); + + $ratio = substr($this->input_details['video_wh_ratio'],0,3); + + $max_duration = config('max_video_duration') * 60; + + if($this->input_details['duration']>$max_duration) + { + $this->log .= "Video duration was ".$this->input_details['duration']." and Max video duration is $max_duration +
    Therefore Video cancelled"; + $this->log("conversion_status","failed"); + $this->log("failed_reason","max_duration"); + $this->create_log_file(); + + if($this->lock_file && file_exists($this->lock_file)) + unlink($this->lock_file); + + $this->failed_reason = 'max_duration'; + + break; + return false; + } + + if($ratio=='1.7' || $ratio=='1.6') + { + $res = $this->configs['res169']; + }else + { + $res = $this->configs['res43']; + } + + $nr = $this->configs['normal_res']; + /*Added by Hassan Baryar bug#268 **/ + if($nr=='320') + $nr='360'; + /*End*/ + $hr = $this->configs['high_res']; + $this->configs['video_width'] = $res[$nr][0]; + $this->configs['video_height'] = $res[$nr][1]; + $this->configs['hq_video_width'] = $res[$hr][0]; + $this->configs['hq_video_height'] = $res[$hr][1]; + + + $this->convert(); + if($this->generate_iphone) + $this->convert(NULL,true); + $this->end_time_check(); + $this->total_time(); + + //Copying File To Original Folder + if($this->keep_original=='yes') + { + $this->log .= "\r\nCopy File to original Folder"; + if(copy($this->input_file,$this->original_output_path)) + $this->log .= "\r\nFile Copied to original Folder..."; + else + $this->log .= "\r\nUnable to copy file to original folder..."; + } + + $this->output_details = $this->get_file_info($this->output_file); + $this->log .= "\r\n\r\n"; + $this->log_ouput_file_info(); + $this->log .= "\r\n\r\nTime Took : "; + $this->log .= $this->total_time.' seconds'."\r\n\r\n"; + + //$this->update_data(); + + $th_dim = $this->thumb_dim; + $big_th_dim = $this->big_thumb_dim ; + + //Generating Thumb + if($this->gen_thumbs) + $this->generate_thumbs($this->input_file,$this->input_details['duration'],$th_dim,$this->num_of_thumbs); + if($this->gen_big_thumb) + $this->generate_thumbs($this->input_file,$this->input_details['duration'],$big_th_dim,$this->num_of_thumbs,NULL,true); + + if(!file_exists($this->output_file)) + $this->log("conversion_status","failed"); + else + $this->log("conversion_status","completed"); + + $this->create_log_file(); + + if($this->lock_file && file_exists($this->lock_file)) + unlink($this->lock_file); + + break; + }else + { + if($use_crons=='no') + sleep(10); + else + break; + } + } + + } + + + + /** + * Function used to generate video thumbnails + */ + function generate_thumbs($input_file,$duration,$dim='120x90',$num=3,$rand=NULL,$is_big=false) + { + $tmpDir = TEMP_DIR.'/'.getName($input_file); + mkdir($tmpDir,0777); + + $output_dir = THUMBS_DIR; + $dimension = ''; + + $big = ""; + + if($is_big=='big') + { + $big = 'big-'; + } + + if($num > 1 && $duration > 14) + { + $duration = $duration - 5; + $division = $duration / $num; + $count=1; + + + for($id=3;$id<=$duration;$id++) + { + $file_name = getName($input_file)."-{$big}{$count}.jpg"; + $file_path = THUMBS_DIR.'/'.$file_name; + + $id = $id + $division - 1; + if($rand != "") { + $time = $this->ChangeTime($id,1); + } elseif($rand == "") { + $time = $this->ChangeTime($id); + } + + if($dim!='original') + { + $dimension = " -s $dim "; + $mplayer_dim = "-vf scale=$width:$height"; + } + + if(USE_MPLAYER && $this->mplayer) + $command = $this->mplayer." '$input_file' -ss $time -frames 1 -nosound $mplayer_dim -vo jpeg:quality=100:outdir='$tmpDir'"; + else + $command = $this->ffmpeg." -i $input_file -an -ss $time -an -r 1 $dimension -y -f image2 -vframes 1 $file_path "; + + $this->exec($command); + + //checking if file exists in temp dir + if(file_exists($tmpDir.'/00000001.jpg')) + { + rename($tmpDir.'/00000001.jpg',THUMBS_DIR.'/'.$file_name); + } + $count = $count+1; + } + }else{ + + $file_name = getName($input_file)."-{$big}%d.jpg"; + $file_path = THUMBS_DIR.'/'.$file_name; + $command = $this->ffmpeg." -i $input_file -an -s $dim -y -f image2 -vframes $num $file_path "; + $this->exec($command); + } + + rmdir($tmpDir); + + } + + + + /** + * Function used to convert seconds into proper time format + * @param : INT duration + * @parma : rand + */ + + function ChangeTime($duration, $rand = "") { + if($rand != "") { + if($duration / 3600 > 1) { + $time = date("H:i:s", $duration - rand(0,$duration)); + } else { + $time = "00:"; + $time .= date("i:s", $duration - rand(0,$duration)); + } + return $time; + } elseif($rand == "") { + if($duration / 3600 > 1 ) { + $time = date("H:i:s",$duration); + } else { + $time = "00:"; + $time .= date("i:s",$duration); + } + return $time; + } + } + + + /** + * Function used to convert video in HD format + * @ Author : Arslan Hassan + * @ Software : ClipBucket + * @license : AAL + */ + + function convert_to_hd($input=NULL,$output=NULL,$p=NULL,$i=NULL) + { + global $db; + if(!$input) + $input = $this->input_file; + if(!$output) + $output = $this->hq_output_file; + if(!$p) + $p = $this->configs; + + if(!$i) + $i = $this->input_details; + $convert = true; + //Checkinf for HD or Not + $opt_av = ''; + + $type = 'HD'; + + if($convert) + { + $total_dims = count($widths); + + //Checking wich dimension is suitable for the video + for($id=0;$id<=$total_dims;$id++) + { + $cur_dim = $widths[$id]; + $next_dim = $widths[$id+1]; + $iwidth = $i['video_width']; + + if($iwidth==$cur_dim || ($iwidth>$cur_dim && $iwidth<$next_dim)) + { + $key = $id; + $out_width = $widths[$id]; + $out_height = $heights[$id]; + break; + } + } + $p['video_width' ] = $p['hq_video_width']; + $p['video_height' ] = $p['hq_video_height']; + $p['resize'] = 'WxH'; + + $output_file = $this->hq_output_file; + + # video rate + if($p['use_video_rate']) + { + if(isset($p['video_rate'])) + $vrate = $p['video_rate']; + elseif(isset($i['video_rate'])) + $vrate = $i['video_rate']; + if(isset($p['video_max_rate']) && !empty($vrate)) + $vrate = min($p['video_max_rate'],$vrate); + if(!empty($vrate)) + $opt_av .= " -r $vrate "; + } + + # video bitrate + if($p['use_audio_bit_rate']) + { + if(isset($p['audio_bitrate'])) + $abrate = $p['audio_bitrate']; + elseif(isset($i['audio_bitrate'])) + $abrate = $i['audio_bitrate']; + if(!empty($abrate)) + { + $abrate = min(320,$abrate); + $abrate_cmd = " -ab ".$abrate."k"; + + } + } + + # audio bitrate + if($p['use_audio_rate']) + { + if($this->input_details['audio_channels']>2 || !is_numeric($this->input_details['audio_channels'])) + { + $arate = $i['audio_rate']; + $opt_av .= $arate_cmd = " -ar $arate "; + }else + { + if(isset($p['audio_rate'])) + $arate = $p['audio_rate']; + elseif(isset($i['audio_rate'])) + $arate = $i['audio_rate']; + if(!empty($arate)) + $opt_av .= $arate_cmd = " -ar $arate "; + } + } + + $this->calculate_size_padding( $p, $i, $width, $height, $ratio, $pad_top, $pad_bottom, $pad_left, $pad_right ); + $dimensions = "-s {$width}x{$height} -aspect $ratio "; + + + $command = $this->ffmpeg." -i ".$this->input_file." $opt_av $dimensions -acodec libfaac -vcodec libx264 -vpre hq -crf 22 -threads 0 ".$this->hq_output_file." 2> ".TEMP_DIR."/output.tmp "; + + + if(KEEP_MP4_AS_IS=="yes" && getExt($this->input_file)=='mp4') + copy($this->input_file,$this->hq_output_file); + else + $output = $this->exec($command); + + if(file_exists(TEMP_DIR.'/output.tmp')) + { + $output = $output ? $output : join("", file(TEMP_DIR.'/output.tmp')); + unlink(TEMP_DIR.'/output.tmp'); + } + + $this->log .= "\r\n\r\n\n=========STARTING $type CONVERSION==============\r\n\r\n\n"; + $this->log("$type Video -- Conversion Command",$command); + $this->log .="\r\n\r\nConversion Details\r\n\r\n"; + $this->log .= $output; + $this->log .= "\r\n\r\n\n=========ENDING $type CONVERSION==============\n\n"; + + /** + * Mp4 files are mostly not converted properly + * we have to use Mp4box in order + * to play them in regular manner, otherwise Flash players will + * load whole video before playing it + */ + $mp4_output = ""; + $command = $this->mp4box." -inter 0.5 ".$this->hq_output_file." -tmp ".$this->tmp_dir." 2> ".TEMP_DIR."/mp4_output.tmp "; + $mp4_output .= $this->exec($command); + if(file_exists(TEMP_DIR.'/mp4_output.tmp')) + { + $mp4_output = $mp4_output ? $mp4_output : join("", file(TEMP_DIR.'/mp4_output.tmp')); + unlink(TEMP_DIR.'/mp4_output.tmp'); + } + $ouput .= $mp4_output; + + $this->log .= "\r\n\r\n\n=========STARTING $type META DATA REPARING==============\r\n\r\n\n"; + $this->log("$type Video -- Conversion Command",$command); + $this->log .="\r\n\r\nConversion Details\r\n\r\n"; + $this->log .= $output; + $this->log .= "\r\n\r\n\n=========ENDING $type META DATA REPARING==============\n\n"; + + $fields = array('file_conversion_log',strtolower($type)); + $values = array(mysql_clean($this->log),'yes'); + //$db->update($this->tbl,$fields,$values," id = '".$this->row_id."'"); + $this->create_log_file(); + return true; + }else + return false; + } + + /** + * Function used to create log for a file + */ + function create_log_file() + { + $file = $this->log_file; + $data = $this->log; + $fo = fopen($file,"w"); + if($fo) + { + fwrite($fo,$data); + } + } + + + /** + * validating video channels + */ + + function validChannels($in) + { + if(!$in) + return true; + $in['audio_channels'] = strtolower($in['audio_channels']); + $channels = false; + if(is_numeric($in['audio_channels'])) + $channels = $in['audio_channels']; + else + { + if(strstr($in['audio_channels'],'stereo')) + $channels = 2; + + if(strstr($in['audio_channels'],'mono')) + $channels = 1; + + if(!$channels) + { + preg_match('/([0-9.]+)/',$in['audio_channels'],$matches); + if($matches) + $channels = $matches[1]; + } + } + + if(!$channels) + return true; + elseif($channels>2) + return false; + else + return true; + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/curl/class.curl.php b/upload/includes/classes/curl/class.curl.php new file mode 100644 index 00000000..4eff0b34 --- /dev/null +++ b/upload/includes/classes/curl/class.curl.php @@ -0,0 +1,547 @@ +m_header['Set-Cookie'][0] and ...[1] + * + * @access private + * @var mixed + */ + + var $m_header ; + + /** + * Current setting of the curl options. + * + * @access private + * @var mixed + */ + + var $m_options ; + + /** + * Status information for the last executed http request. Includes the errno and error + * in addition to the information returned by curl_getinfo. + * + * The keys defined are those returned by curl_getinfo with two additional + * ones specified, 'error' which is the value of curl_error and 'errno' which + * is the value of curl_errno. + * + * @link http://www.php.net/curl_getinfo + * @link http://www.php.net/curl_errno + * @link http://www.php.net/curl_error + * @access private + * @var mixed + */ + + var $m_status ; + + /** + * Collection of headers when curl follows redirections as per CURLOPTION_FOLLOWLOCATION. + * The collection includes the headers of the final page too. + * + * @access private + * @var array + */ + + var $m_followed ; + + /** + * curl class constructor + * + * Initializes the curl class for it's default behavior: + * o no HTTP headers. + * o return the transfer as a string. + * o URL to access. + * By default, the curl class will simply read the URL provided + * in the constructor. + * + * @link http://www.php.net/curl_init + * @param string $theURL [optional] the URL to be accessed by this instance of the class. + */ + + var $file_size; + + function curl($theURL=null) + { + if (!function_exists('curl_init')) + { + trigger_error('PHP was not built with --with-curl, rebuild PHP to use the curl class.', + E_USER_ERROR) ; + } + + $this->m_handle = curl_init() ; + + $this->m_caseless = null ; + $this->m_header = null ; + $this->m_options = null ; + $this->m_status = null ; + $this->m_followed = null ; + + if (!empty($theURL)) + { + $this->setopt(CURLOPT_URL, $theURL) ; + } + $this->setopt(CURLOPT_HEADER, false) ; + $this->setopt(CURLOPT_RETURNTRANSFER, true) ; + $this->file_size = $this->remote_filesize($theURL); + } + + /** + * Free the resources associated with the curl session. + * + * @link http://www.php.net/curl_close + */ + + function close() + { + curl_close($this->m_handle) ; + $this->m_handle = null ; + } + + /** + * Execute the curl request and return the result. + * + * @link http://www.php.net/curl_exec + * @link http://www.php.net/curl_getinfo + * @link http://www.php.net/curl_errno + * @link http://www.php.net/curl_error + * @return string The contents of the page (or other interaction as defined by the + * settings of the various curl options). + */ + + function exec() + { + $theReturnValue = curl_exec($this->m_handle) ; + + $this->m_status = curl_getinfo($this->m_handle) ; + $this->m_status['errno'] = curl_errno($this->m_handle) ; + $this->m_status['error'] = curl_error($this->m_handle) ; + + // + // Collect headers espesically if CURLOPT_FOLLOWLOCATION set. + // Parse out the http header (from last one if any). + // + + $this->m_header = null ; + + // + // If there has been a curl error, just return a null string. + // + + if ($this->m_status['errno']) + { + return '' ; + } + + if ($this->getOption(CURLOPT_HEADER)) + { + + $this->m_followed = array() ; + $rv = $theReturnValue ; + + while (count($this->m_followed) <= $this->m_status['redirect_count']) + { + $theArray = preg_split("/(\r\n){2,2}/", $rv, 2) ; + + $this->m_followed[] = $theArray[0] ; + + $rv = $theArray[1] ; + } + + $this->parseHeader($theArray[0]) ; + + return $theArray[1] ; + } + else + { + return $theReturnValue ; + } + } + + /** + * Returns the parsed http header. + * + * @param string $theHeader [optional] the name of the header to be returned. + * The name of the header is case insensitive. If + * the header name is omitted the parsed header is + * returned. If the requested header doesn't exist + * false is returned. + * @returns mixed + */ + + function getHeader($theHeader=null) + { + // + // There can't be any headers to check if there weren't any headers + // returned (happens in the event of errors). + // + + if (empty($this->m_header)) + { + return false ; + } + + if (empty($theHeader)) + { + return $this->m_header ; + } + else + { + $theHeader = strtoupper($theHeader) ; + if (isset($this->m_caseless[$theHeader])) + { + return $this->m_header[$this->m_caseless[$theHeader]] ; + } + else + { + return false ; + } + } + } + + /** + * Returns the current setting of the request option. If no + * option has been set, it return null. + * + * @param integer the requested CURLOPT. + * @returns mixed + */ + + function getOption($theOption) + { + if (isset($this->m_options[$theOption])) + { + return $this->m_options[$theOption] ; + } + + return null ; + } + + /** + * Did the last curl exec operation have an error? + * + * @return mixed The error message associated with the error if an error + * occurred, false otherwise. + */ + + function hasError() + { + if (isset($this->m_status['error'])) + { + return (empty($this->m_status['error']) ? false : $this->m_status['error']) ; + } + else + { + return false ; + } + } + + /** + * Parse an HTTP header. + * + * As a side effect it stores the parsed header in the + * m_header instance variable. The header is stored as + * an associative array and the case of the headers + * as provided by the server is preserved and all + * repeated headers (pragma, set-cookie, etc) are grouped + * with the first spelling for that header + * that is seen. + * + * All headers are stored as if they COULD be repeated, so + * the headers are really stored as an array of arrays. + * + * @param string $theHeader The HTTP data header. + */ + + function parseHeader($theHeader) + { + $this->m_caseless = array() ; + + $theArray = preg_split("/(\r\n)+/", $theHeader) ; + + // + // Ditch the HTTP status line. + // + + if (preg_match('/^HTTP/', $theArray[0])) + { + $theArray = array_slice($theArray, 1) ; + } + + foreach ($theArray as $theHeaderString) + { + $theHeaderStringArray = preg_split("/\s*:\s*/", $theHeaderString, 2) ; + + $theCaselessTag = strtoupper($theHeaderStringArray[0]) ; + + if (!isset($this->m_caseless[$theCaselessTag])) + { + $this->m_caseless[$theCaselessTag] = $theHeaderStringArray[0] ; + } + + $this->m_header[$this->m_caseless[$theCaselessTag]][] = $theHeaderStringArray[1] ; + } + } + + /** + * Return the status information of the last curl request. + * + * @param string $theField [optional] the particular portion + * of the status information desired. + * If omitted the array of status + * information is returned. If a non-existant + * status field is requested, false is returned. + * @returns mixed + */ + + function getStatus($theField=null) + { + if (empty($theField)) + { + return $this->m_status ; + } + else + { + if (isset($this->m_status[$theField])) + { + return $this->m_status[$theField] ; + } + else + { + return false ; + } + } + } + + /** + * Set a curl option. + * + * @link http://www.php.net/curl_setopt + * @param mixed $theOption One of the valid CURLOPT defines. + * @param mixed $theValue the value of the curl option. + */ + + function setopt($theOption, $theValue) + { + curl_setopt($this->m_handle, $theOption, $theValue) ; + $this->m_options[$theOption] = $theValue ; + } + + /** + * @desc Post string as an array + * @param string by reference data to be written. + * @return array hash containing the post string as individual elements, urldecoded. + * @access public + */ + + function &fromPostString(&$thePostString) + { + $return = array() ; + $fields = explode('&', $thePostString) ; + foreach($fields as $aField) + { + $xxx = explode('=', $aField) ; + $return[$xxx[0]] = urldecode($xxx[1]) ; + } + + return $return ; + } + + /** + * Arrays are walked through using the key as a the name. Arrays + * of Arrays are emitted as repeated fields consistent with such things + * as checkboxes. + * + * @desc Return data as a post string. + * @param mixed by reference data to be written. + * @param string [optional] name of the datum. + * @access public + */ + + function &asPostString(&$theData, $theName = NULL) + { + $thePostString = '' ; + $thePrefix = $theName ; + + if (is_array($theData)) + { + foreach ($theData as $theKey => $theValue) + { + if ($thePrefix === NULL) + { + $thePostString .= '&' . curl::asPostString($theValue, $theKey) ; + } + else + { + $thePostString .= '&' . curl::asPostString($theValue, $thePrefix . '[' . $theKey . ']') ; + } + } + } + else + { + $thePostString .= '&' . urlencode((string)$thePrefix) . '=' . urlencode($theData) ; + } + + $xxx =& substr($thePostString, 1) ; + + return $xxx ; + } + + /** + * Returns the followed headers lines, including the header of the retrieved page. + * Assumed preconditions: CURLOPT_HEADER and expected CURLOPT_FOLLOWLOCATION set. + * The content is returned as an array of headers of arrays of header lines. + * + * @param none. + * @returns mixed an empty array implies no headers. + * @access public + */ + + function getFollowedHeaders() + { + $theHeaders = array() ; + if ($this->m_followed) + { + foreach ( $this->m_followed as $aHeader ) + { + $theHeaders[] = explode( "\r\n", $aHeader ) ; + } ; + return $theHeaders ; + } + + return $theHeaders ; + } + + + + function remote_filesize($url, $user = "", $pw = "") + { + ob_start(); + $ch = curl_init($url); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_NOBODY, 1); + + if(!empty($user) && !empty($pw)) + { + $headers = array('Authorization: Basic ' . base64_encode("$user:$pw")); + curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); + } + + $ok = curl_exec($ch); + curl_close($ch); + $head = ob_get_contents(); + ob_end_clean(); + + $regex = '/Content-Length:\s([0-9].+?)\s/'; + $count = preg_match($regex, $head, $matches); + + return isset($matches[1]) ? $matches[1] : "unknown"; + } +} +?> diff --git a/upload/includes/classes/errorhandler.class.php b/upload/includes/classes/errorhandler.class.php new file mode 100644 index 00000000..a86a0ce9 --- /dev/null +++ b/upload/includes/classes/errorhandler.class.php @@ -0,0 +1,148 @@ +error_list[] = $message; + } + + + /** + * Function usd to add new warning + */ + function add_warning($message=NULL,$id=NULL) + { + $this->warning_list[] = $message; + } + + /** + * Function used to get error list + */ + + function error_list() + { + return $this->error_list; + } + + /** + * Function used to flush errors + */ + function flush_error() + { + $this->error_list = ''; + } + + /** + * Functio nused to add message_list + */ + function add_message($message=NULL,$id=NULL) + { + global $ignore_cb_errors; + //if id is set, error will be generated from error message list + if(!$ignore_cb_errors) + $this->message_list[] = $message; + } + + /** + * Function used to get message list + */ + function message_list() + { + return $this->message_list; + } + + /** + * Function used to flush message + */ + function flush_msg() + { + $this->message_list = ''; + } + + /** + * Function used to flush warning + */ + function flush_warning() + { + $this->warning_list = ''; + } + + /** + * Function used to flush , both message and error + */ + function flush() + { + $this->flush_msg(); + $this->flush_error(); + $this->flush_warning(); + } + + /** + * Function used to add error or either message using simple + * and small object + * @param : message, @param :type,@param:id + */ + function e($message=NULL,$type='e',$id=NULL) + { + + switch($type) + { + case 'm': + case 1: + case 'msg': + case 'message': + $this->add_message($message,$id); + break; + + case 'e': + case 'err': + case 'error': + default: + $this->add_error($message,$id); + break; + + case 'w': + case 2: + case 'war': + case 'warning': + { + $this->add_warning($message,$id); + } + break; + + default: + $this->error_list($message,$id); + break; + } + + return $message; + } + +} + + +?> \ No newline at end of file diff --git a/upload/includes/classes/form.class.php b/upload/includes/classes/form.class.php new file mode 100644 index 00000000..eb2b1f84 --- /dev/null +++ b/upload/includes/classes/form.class.php @@ -0,0 +1,445 @@ + +* @LINK : http://arslan.labguru.com/ - http://clip-bucket.com/ +* @License : Attribution Assurance License -- http://www.opensource.org/licenses/attribution.php +* @DATE : Feb 21 2009 +* @Version : 1.2 +* @CB Version : v2 +* @Class : formObj +*/ + +if(!function_exists('escape_quotes')) +{ + function escape_quotes($text) + { + $text = str_replace("\"", """, $text); + $text = str_replace("'", "'", $text); + return $text; + } +} +class formObj +{ + + var $multi_cat_id = 0; + + /** + * FUNCTION USED TO CREATE TEXT FIELD + */ + function createField($field,$multi=FALSE) + { + $field['sep'] = $field['sep'] ? $field['sep'] : '
    '; + + switch($field['type']) + { + case 'textfield': + case 'password': + case 'textarea': + $fields=$this->createTextfield($field,$multi); + break; + case 'checkbox': + $fields=$this->createCheckBox($field,$multi); + break; + case 'radiobutton': + $fields=$this->createRadioButton($field,$multi); + break; + case 'dropdown': + $fields=$this->createDropDown($field,$multi); + break; + + + } + return $fields; + } + + + /** + * FUNCTION USED TO CREATE TEXT FIELD + * @param name + * @param id + * @param value + * @param class + * @param extra_tags + * @param label + */ + function createTextfield($field,$multi=FALSE) + { + + //Starting Text Field + if($field['type']=='textfield') + $textField = ''; + else + $formTextField = $textField; + + return $formTextField; + + } + + + /** + * FUNCTION USED TO CREATE CHECK BOXES + * @param name + * @param id + * @param value = array('value'=>'name') + * @param class + * @param extra_tags + * @param label + */ + function createCheckBox($field,$multi=FALSE) + { + //First Checking if value is CATEGORY + if($field['value'][0]=='category') + { + $values_array = $field['value'][1][0]; + //$field['value'] = ''; + //Generate Category list + $type = $field['category_type'] ? $field['category_type'] : 'video'; + + $catArray = getCategoryList(array("type"=>$type)); + + if(is_array($catArray)) + { + $this->multi_cat_id = $this->multi_cat_id + 1; + $params['categories'] = $catArray; + $params['field'] = $field; + if(config('show_collapsed_checkboxes') == 1) + $params['collapsed'] = true; + $this->listCategoryCheckBox($params,$multi); + return false; + }else + return "There is no category to select"; + + + } + $arrayName = $this->rmBrackets($field['name']); + //Creating Fields + + if($multi) + { + global $multi_cat_id; + @$multi_cat_id++; + } + + $count=0; + foreach($field['value'] as $key => $value) + { + $count++; + + if(is_array($values_array)) + { + foreach($values_array as $cat_val) + { + if ($cat_val == $key || $field['checked']=='checked') + { + $checked = ' checked '; + break; + }else{ + $checked = ' '; + } + } + } + + if(!$multi) + $field_name = $field['name']; + else + { + $field_name = $field['name']; + $field_name = $this->rmBrackets($field_name); + $field_name = $field_name.$multi_cat_id.'[]'; + } + + if(!empty($field['id'])) + $field_id = ' id="'.$field['id'].'" '; + + if($count>0) + echo $field['sep']; + echo '' ; + } + } + + function listCategoryCheckBoxCollapsed($in,$multi) + { + $cats = $in['categories']; + $field = $in['field']; + $rand = (rand(0,100000)); + if($field['sep'] == "
    ") + $field['sep'] = ""; + + if(!$multi) + $fieldName = $field['name']; + else + { + $fieldName = $field['name']; + $fieldName = $this->rmBrackets($fieldName); + $fieldName = $fieldName.$multi_cat_id.'[]'; + } + $display = "none"; + $values = $field['value'][1][0]; + $Values = array(); + if(!empty($values)) + foreach($values as $val) + $Values[] = "|".$val."|"; + + if($cats) + { + $output = ""; + foreach($cats as $cat) + { + $checked = ""; + if(in_array("|".$cat['category_id']."|",$Values)) + $checked = 'checked'; + echo "
    "; + echo $field['sep']; + echo ''; + if($cat['children']) + { + echo " "; + $childField = $field; + $childField['sep'] = $field['sep'].str_repeat(' ',5); + echo "
    "; + echo $this->listCategoryCheckBoxCollapsed(array('categories'=>$cat['children'],'field'=>$childField,'children_indent'=>true),$multi); + echo "
    "; + } + echo "
    "; + } + } + } + + //Creating checkbox with indent for cateogry childs + function listCategoryCheckBox($in,$multi) + { + $cats = $in['categories']; + $field = $in['field']; + //$in['collapsed'] = true; + $collapsed = $in['collapsed']; + if($collapsed) + return $this->listCategoryCheckBoxCollapsed($in,$multi); + //setting up the field name + if(!$multi) + $field_name = $field['name']; + else + { + $field_name = $field['name']; + $field_name = $this->rmBrackets($field_name); + $field_name = $field_name.$this->multi_cat_id.'[]'; + } + + //Setting up the values + $values = $field['value'][1][0]; + $newVals = array(); + + if(!empty($values)) + foreach($values as $val) + $newVals[] = '|'.$val.'|'; + if($cats) + { + foreach($cats as $cat) + { + $checked = ''; + //checking value + if(in_array('|'.$cat['category_id'].'|',$newVals)) + $checked = 'checked'; + echo $field['sep']; + echo '' ; + if($cat['children']) + { + $childField = $field; + $childField['sep'] = $field['sep'].str_repeat(' ',5); + $this->listCategoryCheckBox(array('categories'=>$cat['children'],'field'=>$childField,'children_indent'=>true),$multi); + } + } + } + } + + + /** + * FUNCTION USED TO CREATE RADIO Button + * @param name + * @param id + * @param value = array('value'=>'name') + * @param class + * @param extra_tags + * @param label + */ + function createRadioButton($field,$multi=FALSE) + { + //Creating Fields + $count = 0; + $sep = $field['sep']; + $arrayName = $this->rmBrackets($field['name']); + foreach($field['value'] as $key => $value) + { + if(!empty($_POST[$arrayName]) || !empty($field['checked'])) + { + if ($_POST[$arrayName] == $key || $field['checked'] == $key) + { + $checked = ' checked '; + }else{ + $checked = ' '; + } + }else{ + if($count==0) + $checked = ' checked '; + else + $checked = ''; + $count++; + } + if(!empty($field['id'])) + $field_id = ' id="'.$field['id'].'" '; + + if(!$multi) + $field_name = $field['name']; + else + $field_name = $field['name'].'[]'; + + echo '' ; + echo $sep; + } + } + + /** + * FUNCTION USED TO REMOVE BRACKET FROM FROM FIELD NAME IF IT IS AN ARRAY + * @param name with brackets + * return name without brackets + */ + function rmBrackets($string) + { + $string = preg_replace('/\[\]/','',$string); + return $string; + } + + + /** + * FUNCTION USED TO CREATEA DROPDOWN MENU + * @param name + * @param id + * @param value = array('value'=>'name') + * @param class + * @param extra_tags + * @param label + */ + + function createDropDown($field,$multi=FALSE) + { + global $LANG; + + //First Checking if value is CATEGORY + if($field['value'][0]=='category') + { + $values_array = $field['value'][1][0]; + $field['value'] = ''; + //Generate Category list + $type = $field['type'] ? $field['type'] : 'video'; + $catArray = getCategoryList(array("type"=>$field['category_type'])); + foreach ($catArray as $cat) + { + $field['value'][$cat['category_id']] = $cat['category_name']; + } + } + + if(!$multi) + $field_name = $field['name']; + else + $field_name = $field['name'].'[]'; + + $ddFieldStart = ''; + echo $ddFieldStart.$fieldOpts.$ddFieldEnd; + } + + + + /** + * Form Validator + * This function used to valid form fields + */ + function validate_form($field,$method,$syntax=NULL) + { + switch($method) + { + case 'username': + $syntax = get_re('username'); + } + + } +} + + + + +?> \ No newline at end of file diff --git a/upload/includes/classes/gravatar.class.php b/upload/includes/classes/gravatar.class.php new file mode 100644 index 00000000..5335c570 --- /dev/null +++ b/upload/includes/classes/gravatar.class.php @@ -0,0 +1,191 @@ + +* $email = "youremail@yourhost.com"; +* $default = "http://www.yourhost.com/default_image.jpg"; // Optional +* $gravatar = new Gravatar($email, $default); +* $gravatar->size = 80; +* $gravatar->rating = "G"; +* $gravatar->border = "FF0000"; +* +* echo $gravatar; // Or echo $gravatar->toHTML(); +* +* +* Class Page: http://www.phpclasses.org/browse/package/4227.html +* +* @author Lucas Araújo +* @version 1.0 +* @package Gravatar +*/ +class Gravatar +{ + /** + * Gravatar's url + */ + const GRAVATAR_URL = "http://www.gravatar.com/avatar.php"; + + /** + * Ratings available + */ + private $GRAVATAR_RATING = array("G", "PG", "R", "X"); + + /** + * Query string. key/value + */ + protected $properties = array( + "gravatar_id" => NULL, + "default" => NULL, + "size" => 80, // The default value + "rating" => NULL, + "border" => NULL, + ); + + /** + * E-mail. This will be converted to md5($email) + */ + protected $email = ""; + + /** + * Extra attributes to the IMG tag like ALT, CLASS, STYLE... + */ + protected $extra = ""; + + /** + * + */ + public function __construct($email=NULL, $default=NULL) { + $this->setEmail($email); + $this->setDefault($default); + } + + /** + * + */ + public function setEmail($email) { + if ($this->isValidEmail($email)) { + $this->email = $email; + $this->properties['gravatar_id'] = md5(strtolower($this->email)); + return true; + } + return false; + } + + /** + * + */ + public function setDefault($default) { + $this->properties['default'] = $default; + } + + /** + * + */ + public function setRating($rating) { + if (in_array($rating, $this->GRAVATAR_RATING)) { + $this->properties['rating'] = $rating; + return true; + } + return false; + } + + /** + * + */ + public function setSize($size) { + $size = (int) $size; + if ($size <= 0) + $size = NULL; // Use the default size + $this->properties['size'] = $size; + } + + /** + * + */ + public function setExtra($extra) { + $this->extra = $extra; + } + + /** + * + */ + public function isValidEmail($email) { + //global $userquery; + return is_valid_syntax('email',$email); + // Source: http://www.zend.com/zend/spotlight/ev12apr.php + //return eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email); + } + + /** + * Object property overloading + */ + public function __get($var) { return @$this->properties[$var]; } + + /** + * Object property overloading + */ + public function __set($var, $value) { + switch($var) { + case "email": return $this->setEmail($value); + case "rating": return $this->setRating($value); + case "default": return $this->setDefault($value); + case "size": return $this->setSize($value); + // Cannot set gravatar_id + case "gravatar_id": return; + } + return @$this->properties[$var] = $value; + } + + /** + * Object property overloading + */ + public function __isset($var) { return isset($this->properties[$var]); } + + /** + * Object property overloading + */ + public function __unset($var) { return @$this->properties[$var] == NULL; } + + /** + * Get source + */ + public function getSrc() { + $url = self::GRAVATAR_URL ."?"; + $first = true; + foreach($this->properties as $key => $value) { + if (isset($value)) { + if (!$first) + $url .= "&"; + $url .= $key."=".urlencode($value); + $first = false; + } + } + return $url; + } + + /** + * toHTML + */ + public function toHTML() { + return 'size) ? "" : ' width="'.$this->size.'" height="'.$this->size.'"') + .$this->extra + .' />'; + } + + /** + * toString + */ + public function __toString() { return $this->toHTML(); } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/groups.class.php b/upload/includes/classes/groups.class.php new file mode 100644 index 00000000..e8e217a3 --- /dev/null +++ b/upload/includes/classes/groups.class.php @@ -0,0 +1,2395 @@ +cat_tbl = 'group_categories'; + $this->gp_tbl = 'groups'; + $this->gp_mem_tbl = 'group_members'; + //We will using CB Commenting system as posts + //$this->gp_post_tbl = 'group_posts'; + $this->gp_topic_tbl = 'group_topics'; + $this->gp_invite_tbl = 'group_invitations'; + $this->gp_vdo_tbl = 'group_videos'; + + //Adding Actions such Report, share,fav etc + $this->action = new cbactions(); + $this->action->type = 'g'; + $this->action->name = 'group'; + $this->action->obj_class = 'cbgroup'; + $this->action->check_func = 'group_exists'; + $this->action->type_tbl = $this->gp_tbl; + $this->action->type_id_field = 'group_id'; + + if(isSectionEnabled('groups')) + $Cbucket->search_types['groups'] = "cbgroup"; + + } + + /** + * Function used to check if the provided URL is taken or not + * @param = $url { URL of group provided by user } + */ + function group_url_exists($url) { + global $db; + $result = $db->count(tbl($this->gp_tbl),"*"," group_url='$url'"); + if($result[0]>0) + return true; + else + return false; + } + + /** + * Function used to get group details + * @param $ID { groupid } + */ + function get_group($id) + { + global $db; + $gp_details = $db->select(tbl($this->gp_tbl),"*","group_id='$id'"); + if($db->num_rows>0) { + return $gp_details[0]; + } else{ + return false; + } + } + function get_group_details($id){ return $this->get_group($id); } + function get_details($id){ return $this->get_group($id); } + + /** + * Funtion used to get gorup details + * @param, $URL { group url } + */ + function get_group_with_url($url) + { + global $db; + $gp_details = $db->select(tbl($this->gp_tbl),"*","group_url='$url'"); + if($db->num_rows>0) { + return $gp_details[0]; + } else{ + return false; + } + } + function get_group_details_with_url($id){ return $this->get_group_with_url($id); } + function get_details_with_url($id){ return $this->get_group_with_url($id); } + function group_details_url($id){ return $this->get_group_with_url($id); } + + + /** + * Function used to make user a member of group + * @param = $userid { ID of user who is going to Join Group } + * @param = $gpid { ID of group which is being joined } + */ + function join_group($gpid,$userid,$createFeed=true) { + + global $db; + + //Getting group details + $group = $this->get_group_details($gpid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$this->is_joinable($group,$userid,TRUE)) + return false; + elseif(!$userid) + e(lang('group_join_login_err')); + else + { + if($group['group_privacy']==1 && $group['userid'] != $userid) + $active = 'no'; + else + $active = 'yes'; + + + $db->insert(tbl($this->gp_mem_tbl), + array("group_id","userid","date_added","active"), + array($gpid,$userid,now(),$active)); + + //Count total members + $total_members = $this->total_members($gpid); + + //Adding Feed + if($createFeed) + addFeed(array('action'=>'join_group','object_id' => $gpid,'object'=>'group','userid'=>$userid)); + + //Update Stats + $db->update(tbl($this->gp_tbl), + array("total_members"), + array($total_members), + "group_id='$gpid'"); + + e(lang('grp_join_msg_succ'),'m'); + } + } + + /** + * Creating Group Required Fields + */ + function load_required_fields($default=NULL,$is_update=FALSE) + { + if($default == NULL) + $default = $_POST; + + $gptitle = $default['group_name']; + $gpdescription = $default['group_description']; + + if(is_array($default['category'])) + $cat_array = array($default['category']); + else + { + preg_match_all('/#([0-9]+)#/',$default['category'],$m); + $cat_array = array($m[1]); + } + + $tags = $default['group_tags']; + $gpurl = $default['group_url']; + + + if(!$is_update) + $url_form = array( + 'title'=> lang('grp_url_title'), + 'type'=> 'textfield', + 'name'=> 'group_url', + 'id'=> 'group_url', + 'value'=> cleanForm($gpurl), + 'hint_1'=> '', + 'hint_2'=> lang('grp_url_msg'), + 'db_field'=>'group_url', + 'required'=>'yes', + 'invalid_err'=>lang('grp_url_error'), + 'syntax_type'=> 'field_text', + 'function_error_msg' => lang('user_contains_disallow_err'), + 'db_value_check_func'=> 'group_url_exists', + 'db_value_exists'=>false, + 'db_value_err'=>lang('grp_url_error2'), + 'min_length' => 3, + 'max_length' => 18, + + ); + else + $url_form = array( + 'title'=> lang('grp_url_title'), + 'type'=> 'textfield', + 'name'=> 'group_url', + 'id'=> 'group_url', + 'value'=> cleanForm($gpurl), + 'hint_1'=> '', + 'hint_2'=> lang('grp_url_msg'), + 'db_field'=>'group_url', + 'required'=>'yes', + 'invalid_err'=>lang('grp_url_error'), + 'syntax_type'=> 'field_text', + 'function_error_msg' => lang('user_contains_disallow_err'), + 'min_length' => 3, + 'max_length' => 18, + ); + + $fields = array + ( + 'name' => array( + 'title'=> lang('grp_name_title'), + 'type'=> "textfield", + 'name'=> "group_name", + 'id'=> "group_name", + 'value'=> $gptitle, + 'db_field'=>'group_name', + 'required'=>'yes', + 'invalid_err'=>lang('grp_name_error'), + 'max_length'=>config('grp_max_title') + ), + 'tags' => array( + 'title'=> lang('tag_title'), + 'type'=> 'textfield', + 'name'=> 'group_tags', + 'id'=> 'group_tags', + 'value'=> (genTags($tags)), + 'hint_1'=> '', + 'hint_2'=> lang('grp_tags_msg1'), + 'db_field'=>'group_tags', + 'required'=>'yes', + 'invalid_err'=>lang('grp_tags_error'), + 'validate_function'=>'genTags' + ), + 'desc' => array( + 'title'=> lang('vdo_desc'), + 'type'=> 'textarea', + 'name'=> 'group_description', + 'id'=> 'group_description', + 'value'=> cleanForm($gpdescription), + 'size'=>'35', + 'extra_params'=>' rows="4" ', + 'db_field'=>'group_description', + 'invalid_err'=>lang('grp_des_error'), + 'required'=>'yes', + 'max_length'=>config('grp_max_desc') + + ), + $url_form, + + 'cat' => array( + 'title'=> lang('grp_cat_tile'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cat_array), + 'hint_1'=> sprintf(lang('vdo_cat_msg'),ALLOWED_GROUP_CATEGORIES), + 'db_field'=>'category', + 'required'=>'yes', + 'validate_function'=>'validate_group_category', + 'invalid_err'=>lang('grp_cat_error'), + 'display_function' => 'convert_to_categories', + 'category_type'=>'group', + ), + + ); + + return $fields; + } + + + /** + * Function used to load other group option fields + */ + function load_other_fields($default=NULL) + { + global $LANG,$uploadFormOptionFieldsArray; + + + if(!$default) + $default = $_POST; + + $gpprivacy = $default['group_privacy']; + $gpposting = $default['post_type']; + + $group_option_fields = array + ( + 'privacy'=> array('title'=>lang('privacy'), + 'type'=>'radiobutton', + 'name'=>'group_privacy', + 'id'=>'group_privacy', + 'value'=>array('0'=>lang('grp_join_opt1'),'1'=>lang('grp_join_opt2'),2=>lang('grp_join_opt3')), + 'checked'=>$gpprivacy, + 'db_field'=>'group_privacy', + 'required'=>'no', + 'display_function'=>'display_sharing_opt', + ), + 'posting'=> array('title'=>lang('grp_forum_posting'), + 'type'=>'radiobutton', + 'name'=>'post_type', + 'id'=>'post_type', + 'value'=>array('0'=>lang('vdo_br_opt1'),'1'=>lang('vdo_br_opt2'),2=>lang('grp_join_opt3')), + 'checked'=>$gpposting, + 'db_field'=>'post_type', + 'required'=>'no', + 'display_function'=>'display_sharing_opt', + ), + ); + + return $group_option_fields; + } + + + /** + * Function used to validate Signup Form + */ + function validate_form_fields($array=NULL,$update=false) + { + $fields = $this->load_required_fields($array,$update); + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + //Mergin Array + $group_fields = array_merge($fields,$this->load_other_fields()); + + validate_cb_form($group_fields,$array); + + } + + /** + * Function used to create new groups + * @Author : Fawaz Tahir, Arslan Hassan + * @Params : array { Group Input Details } + * @since : 15 December 2009 + */ + function create_group($array,$user=false,$redirect_to_group=false) + { + global $db; + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $this->validate_form_fields($array); + + if(!error()) + { + $group_fields = $this->load_required_fields($array); + $group_fields = array_merge($group_fields,$this->load_other_fields()); + + //Adding Custom Signup Fields + if(count($this->custom_group_fields)>0) + $group_fields = array_merge($group_fields,$this->custom_group_fields); + foreach($group_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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + } + + if(!error()) + { + //UID + $query_field[] = "userid"; + $query_val[] = $user; + + //DATE ADDED + $query_field[] = "date_added"; + $query_val[] = now(); + + $query_field[] = "total_members"; + $query_val[] = 1; + + //Inserting IN Database now + $db->insert(tbl($this->gp_tbl),$query_field,$query_val); + $insert_id = $db->insert_id(); + + //Owner Joiing Group + ignore_errors(); + + $db->insert(tbl($this->gp_mem_tbl), + array("group_id","userid","date_added","active"), + array($insert_id,$user,now(),'yes')); + + + //$this->join_group($insert_id,$user,false); + + //Updating User Total Groups + $this->update_user_total_groups($user); + + //Adding Feed + addFeed(array('action'=>'create_group','object_id' => $insert_id,'object'=>'group')); + + if($redirect_to_group) + { + $grp_details = $this->get_details($insert_id); + redirect_to(group_link(array('details'=>$grp_details) )); + } + + + + //loggin Upload + $log_array = array + ( + 'success'=>'yes', + 'action_obj_id' => $insert_id, + 'details'=> "created new group"); + insert_log('add_group',$log_array); + + return $insert_id; + } + } + + + /** + * Function used to update group + * @Author : Fawaz Tahir, Arslan Hassan + * @Params : array { Group Input Details } + * @since : 15 December 2009 + */ + function update_group($array=NULL) + { + global $db; + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $this->validate_form_fields($array,true); + + $gid = $array['group_id']; + + if(!error()) + { + $group_fields = $this->load_required_fields($array); + $group_fields = array_merge($group_fields,$this->load_other_fields()); + + //Adding Custom Signup Fields + if(count($this->custom_group_fields)>0) + $group_fields = array_merge($group_fields,$this->custom_group_fields); + foreach($group_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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + } + + + if(has_access('admin_access',TRUE)) + { + if(!empty($array['total_views'])) + { + $query_field[] = 'total_views'; + $query_val[] = $array['total_views']; + } + if(!empty($array['total_videos'])) + { + $query_field[] = 'total_videos'; + $query_val[] = $array['total_videos']; + } + if(!empty($array['total_members'])) + { + $query_field[] = 'total_members'; + $query_val[] = $array['total_members']; + } + if(!empty($array['total_topics'])) + { + $query_field[] = 'total_topics'; + $query_val[] = $array['total_topics']; + } + } + + //Getting Group URL value + $gp_url = $this->get_gp_field_only($gid,"group_url"); + //Checking Group URL + if($array['group_url']!=$gp_url) + if(group_url_exists($array['group_url'])) + e(lang('grp_url_error2')); + if(!error()) + { + + if(!userid()) + { + e(lang("you_not_logged_in")); + }elseif(!$this->group_exists($gid)){ + e(lang("grp_exist_error")); + }elseif(!$this->is_owner($gid,userid()) && !has_access('admin_access',TRUE)) + { + e(lang("you_cant_edit_group")); + }else{ + + $db->update(tbl($this->gp_tbl),$query_field,$query_val," group_id='$gid'"); + e(lang("grp_details_updated"),'m'); + + //Updating Group Thumb + if(!empty($array['thumb_file']['tmp_name'])) + $this->create_group_image($gid,$array['thumb_file']); + } + } + } + + + /** + * Function used to get default image for group. + */ + function get_default_thumb($size=NULL) + { + if($size=="small" && file_exists(TEMPLATEDIR.'/images/thumbs/group_thumb-small.png')) + { + return TEMPLATEURL.'/images/thumbs/group_thumb-small.png'; + }elseif(file_exists(TEMPLATEDIR.'/images/thumbs/group_thumb.png') && !$size) + { + return TEMPLATEURL.'/images/thumbs/group_thumb.png'; + }else + { + if($size=='small') + $this->get_default_thumb = GP_THUMB_URL.'/no_thumb-small.png'; + else + $this->get_default_thumb = GP_THUMB_URL.'/no_thumb.png'; + return $this->get_default_thumb; + } + } + + + /** + * Function used to create group thumbnail + * @param = $gpid {ID of group for which thumbnail is being created } + * @param = $file { Source of image file $_FILES } + */ + function create_group_image($gpid,$file) + { + global $imgObj; + $file_ext = strtolower(getext($file['name'])); + $exts = array('jpg','png','gif','jpeg'); + + foreach($exts as $ext) + { + if($ext == $file_ext) + { + $thumb_name = $gpid.'.'.$ext; + $small_thumb_name = $gpid.'-small.'.$ext; + $path = GP_THUMB_DIR.'/'.$thumb_name; + $small_path = GP_THUMB_DIR.'/'.$small_thumb_name; + foreach($exts as $unlink_ext) + if(file_exists(GP_THUMB_DIR.'/'.$gpid.'.'.$unlink_ext)) + unlink(GP_THUMB_DIR.'/'.$gpid.'.'.$unlink_ext); + + move_uploaded_file($file['tmp_name'],$path); + + if(!$imgObj->ValidateImage($path,$ext)) + e(lang('pic_upload_vali_err')); + else + { + $imgObj->CreateThumb($path,$path,$this->gp_thumb_width,$ext,$this->gp_thumb_height,true); + $imgObj->CreateThumb($path,$small_path,$this->gp_small_thumb_width,$ext,$this->gp_small_thumb_height,true); + } + } + } + } + + /** + * Function used to get group thumb. + * @param Group Details array + */ + function get_gp_thumb($grp_details,$size=NULL) + { + $exts = array('jpg','png','gif','jpeg'); + $gpid = $grp_details['group_id']; + foreach($exts as $ext) + { + if($size == 'small') + $file_size = "-small"; + + if(file_exists(GP_THUMB_DIR.'/'.$gpid."$file_size.".$ext)) + return GP_THUMB_URL.'/'.$gpid."$file_size.".$ext; + } + + return $this->get_default_thumb($size); + + } + function get_group_thumb($grp_details,$size=NULL){ return $this->get_gp_thumb($grp_details,$size); } + + /** + * function used to get group icon + */ + function get_topic_icon($topic) + { + $file = TOPIC_ICON_DIR.'/'.$topic['topic_icon']; + if(file_exists($file) && !empty($topic['topic_icon'])) + { + return TOPIC_ICON_URL.'/'.$topic['topic_icon']; + }else + return TOPIC_ICON_URL.'/dot.gif'; + } + + + /** + * Function used add new topic in group + * @param ARRAY details + */ + function add_topic($array,$redirect_to_topic=false) + { + global $db; + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $fields = $this->load_add_topic_form_fields($array); + validate_cb_form($fields,$array); + + $user = userid(); + + if(!error()) + { + foreach($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'] || (!apply_func($field['clean_func'],$val) && !is_array($field['clean_func']))) + $val = $val; + else + $val = apply_func($field['clean_func'],sql_free($val)); + + if(empty($val) && !empty($field['default_value'])) + $val = $field['default_value']; + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + } + + $gp_details = $this->get_group_details($array['group_id']); + //Checking for weather user is allowed to post topics or not + $this->validate_posting_previlige($gp_details); + + if(!error()) + { + //Adding Topic icon + $query_field[] = "topic_icon"; + $query_val[] = $array['topic_icon']; + //UID + $query_field[] = "userid"; + $query_val[] = $user; + //DATE ADDED + $query_field[] = "date_added"; + $query_val[] = now(); + + $query_field[] = "last_post_time"; + $query_val[] = now(); + + //GID + $query_field[] = "group_id"; + $query_val[] = $array['group_id']; + + //Checking If posting requires approval or not + $query_field[] = "approved"; + if($gp_details['post_type']==1) + $query_val[] = "no"; + else + $query_val[] = "yes"; + + //Inserting IN Database now + $db->insert(tbl($this->gp_topic_tbl),$query_field,$query_val); + $insert_id = $db->insert_id(); + + //Increasing Group Topic Counts + $count_topics = $this->count_group_topics($array['group_id']); + $db->update(tbl($this->gp_tbl),array("total_topics"),array($count_topics)," group_id='".$array['group_id']."'"); + + //leaving msg + e(lang("grp_tpc_msg"),"m"); + + //Redirecting to topic + if($redirect_to_topic) + { + $grp_details = $this->get_details($insert_id); + redirect_to(group_link($grp_details)); + } + + return $insert_id; + + } + } + + /** + * Function used to delete group topic + */ + function delete_topic($tid) + { + global $db; + $topic = $this->get_topic_details($tid); + $group = $this->get_group_details($topic['group_id']); + if(!$topic) + e(lang("grp_tpc_err4")); + elseif(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$topic['userid'] && userid()!=$group['userid']) + e(lang("you_cant_del_topic")); + else + { + $db->delete(tbl($this->gp_topic_tbl),array("topic_id","group_id"),array($tid,$topic['group_id'])); + //Deleting Topic Posts + $this->delete_comments($tid); + + //Counting Total Topics + $count_topics = $this->count_topics($topic['group_id']); + + //Updating Total Number + $db->update(tbl($this->gp_tbl),array('total_topics'),array($count_topics)," group_id = '".$topic['group_id']."'"); + + e(lang("grp_tpc_msg1"),"m"); + } + } + + /** + * Function used to delete all user topics + */ + function delete_user_topics($uid,$gid) + { + global $db; + $group = $this->get_group_details($gid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$group['userid'] && userid()!=$uid && !has_access('admin_access',true)) + e(lang("you_cant_del_user_topics")); + else + { + $usr_topics = $this->get_topics(array('group'=>$gid,'user'=>$uid)); + if(is_array($usr_topics)) + foreach($usr_topics as $topic) + $this->delete_topic($topic['topic_id']); + e(lang("topics_deleted"),"m"); + } + } + + + /** + * Function used to delete all group topics + */ + function delete_group_topics($gid) + { + global $db; + $group = $this->get_group_details($gid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$group['userid'] && !has_access('admin_access',true)) + e(lang("you_cant_delete_grp_topics")); + else + { + $topics = $this->get_topics(array('group'=>$gid)); + if(is_array($topics)) + foreach($topics as $topic) + $this->delete_topic($topic['topic_id']); + e(lang("deleted"),"m"); + } + } + + + /** + * Function used to check weather posting is allowed or not + */ + function validate_posting_previlige($gdetails) + { + if(is_numeric($getails)) + $gdetails = $this->get_group_details($getails); + + if(!$gdetails || empty($gdetails['group_id'])) + e(lang("grp_exist_error")); + if(!userid()) + e(lang("grp_please_login")); + elseif(!$this->is_member(userid(),$gdetails['group_id'],TRUE)) + e(lang("you_not_grp_mem_or_approved")); + elseif($gdetails['post_type']==2 && userid() != $gdetails['userid'] && !has_access('admin_access',true)) + e(lang("you_not_allowed_post_topics")); + else + { + return true; + } + + return false; + } + + + /** + * Function used to get group topics + * INPUT Group ID + */ + function get_group_topics($params) + { + global $db; + + $gid = $params['group'] ? $params['group'] : $params; + $limit = $params['limit']; + $order = $params['order'] ? $params['order'] : " last_post_time DESC "; + + if($params['approved']) + $approved_query = " AND approved='yes' "; + if($params['user']) + $user_query = " AND userid='".$params['user']."'"; + + $results = $db->select(tbl($this->gp_topic_tbl),"*"," group_id='$gid' $approved_query $user_query",$limit,$order); + if($db->num_rows>0) + return $results; + else + return false; + } + function GetTopics($params){ return $this->get_group_topics($params); } + function get_topics($params){ return $this->get_group_topics($params); } + + /** + * Function used to check weather topic exists or not + * @param TOPIC ID {id of topic} + */ + function topic_exists($tid) + { + global $db; + $count = $db->count(tbl($this->gp_topic_tbl),'topic_id'," topic_id='$tid' "); + if($count[0]>0) + return true; + else + return false; + } + + /** + * Function used to get topic details + * @param TOPIC ID {id of topic} + */ + function get_topic_details($topic) + { + global $db; + $result = $db->select(tbl($this->gp_topic_tbl),"*"," topic_id='$topic' "); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + function gettopic($topic){ return $this->get_topic_details($topic); } + function get_topic($topic){ return $this->get_topic_details($topic); } + + /** + * Function used to check weather user is invited or not + */ + function is_invited($uid,$gid,$owner,$gen_err=FALSE) + { + global $db; + $count = $db->count(tbl($this->gp_invite_tbl),'invitation_id'," invited='$uid' AND group_id='$gid' AND userid='$owner' "); + if($count[0]>0) + return true; + else + { + if($gen_err) + e(lang('grp_prvt_err1')); + return false; + } + } + function is_userinvite($uid,$gid,$owner){ return $this->is_invited($uid,$gid,$owner); } + + + /** + * Function used to check whether user is already a member or not + * @param = $user { User to check } + * @param = $gpid { ID of group in which we will check } + */ + function is_member($user,$gpid,$active=false) { + global $db; + + $active_query = ""; + if($active) + $active_query = " AND active='yes' "; + + $data = $db->count(tbl($this->gp_mem_tbl),"*","group_id='$gpid' AND userid='$user' $active_query"); + //echo $db->db_query; + if($data[0]>0) { + return true; + } else { + return false; + } + } + function joined_group($user,$gpid){return $this->is_member($user,$gpid);} + + /** + * Function use to check weather user is owner or not of the group + * @param GID {group id} + * @param UID {logged in user or just user} + */ + function is_owner($gid,$uid=NULL) + { + if(!$uid) + $uid = userid(); + + if(!is_array($gid)) + $group = $this->get_group_details($gid); + else + $group = $gid; + if($group['userid']==$uid) + return true; + else + return false; + } + + + /** + * Function used to count total number of members in a group. + * @param = $gpid { ID of group whose members are going to be counted } + */ + function total_members($gpid,$active=true) + { + global $db; + if($active) + $activeQuery = "AND active = 'yes'"; + $totalmem = $db->count(tbl("group_members"),"*","group_id='$gpid' $activeQuery"); + return $totalmem[0]; + } + + + /** + * Function used to get group members + */ + function get_members($gid,$approved=NULL,$limit=NULL) + { + global $db; + + $app_query = ""; + if($approved) + $app_query = " AND ".tbl($this->gp_mem_tbl).".active='$approved'"; + $result = $db->select(tbl($this->gp_mem_tbl)." LEFT JOIN ".tbl('users')." ON ".tbl($this->gp_mem_tbl).".userid=".tbl('users').".userid","*"," group_id='$gid' $app_query",$limit); + + if($db->num_rows>0) + return $result; + else + return false; + } + + + /** + * Function used to check weather member is active or not + */ + function is_active_member($uid,$gid) + { + global $db; + $count = $db->count(tbl($this->gp_mem_tbl),"userid"," userid='$uid' AND group_id='$gid' AND active='yes'"); + if($count[0]>0) + return true; + else + return false; + } + + /** + * function used to count number of topics in a group + */ + function count_group_topics($group) + { + global $db; + $totaltopics = $db->count(tbl($this->gp_topic_tbl),"*","group_id='$group'"); + return $totaltopics; + } + function CountTopics($group){ return $this->count_group_topics($group); } + function count_topics($group){ return $this->count_group_topics($group); } + + + + /** + * Function used to add video to group + */ + function add_group_video($vid,$gid,$update_group=false) + { + global $db,$cbvid; + $group = $this->get_details($gid); + $video = $cbvid->get_video_details($vid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$video) + e(lang("class_vdo_del_err")); + elseif($video['userid']!=userid()) + e(lang("you_cant_add_this_vdo")); + elseif($this->is_group_video($vid,$gid)) + return false; + else + { + if(!$this->is_active_member(userid(),$group['group_id'])) + { $approved = "no"; e(lang("your_video_send_in_modetation"),"w"); } + else + $approved = "yes"; + + $db->insert(tbl($this->gp_vdo_tbl),array("videoid","group_id","userid","approved"),array($vid,$gid,userid(),$approved)); + e(lang("video_added"),"m"); + if($update_group) + $this->update_group_videos_count($gid); + } + } + + /** + * Removing video gro group + */ + function remove_group_video($vid,$gid,$update_group=false) + { + global $db,$cbvid; + $group = $this->get_details($gid); + $video = $cbvid->get_video_details($vid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$video) + e(lang("class_vdo_del_err")); + elseif($video['userid']!=userid()) + e(lang("you_cant_del_this_vdo")); + elseif(!$this->is_group_video($vid,$gid)) + return false; + else + { + $db->delete(tbl($this->gp_vdo_tbl),array("videoid","group_id"),array($vid,$gid)); + e(lang("video_removed"),"m"); + if($update_group) + $this->update_group_videos_count($gid); + } + } + + + + /** + * Function used to check weather video is already in group or not + */ + function is_group_video($vid,$gid) + { + global $db; + $count = $db->count(tbl($this->gp_vdo_tbl),"group_video_id"," videoid='$vid' AND group_id='$gid'"); + if($count[0]>0) + return true; + else + return false; + } + + + /** + * Function used to count videos of group + * @param GID {group ID} + */ + function count_videos($gpid,$approved=true) + { + global $db; + if($approved) + $appQuery = "AND approved = 'yes'"; + $totalmem = $db->count(tbl("group_videos"),"*","group_id='$gpid' $appQuery"); + return $totalmem; + } + function total_videos($gid){return $this->count_videos($gid);} + + + + /** + * Function used to update number of videos of group + */ + function update_group_videos_count($gid) + { + global $db; + $total = $this->count_videos($gid); + $db->update(tbl($this->gp_tbl),array('total_videos'),array($total)," group_id='$gid'"); + } + + + /** + * Function used to get group videos + */ + function get_group_videos($gid,$approved=NULL,$limit=NULL) + { + global $db,$cbvid; + if($approved) + $approved_query = "AND approved='$approved'"; + + + if($limit!='count') + { + $result = $db->select(tbl($this->gp_vdo_tbl)." LEFT JOIN ".tbl('video')." + ON ".tbl($this->gp_vdo_tbl).".videoid=".tbl('video').".videoid","*", + " group_id='$gid' $approved_query AND ".tbl('video').".active='yes' AND status='Successful'",$limit); + }else + { + return $db->count(tbl($this->gp_vdo_tbl)." LEFT JOIN ".tbl('video')." + ON ".tbl($this->gp_vdo_tbl).".videoid=".tbl('video').".videoid","videoid", + " group_id='$gid' $approved_query AND ".tbl('video').".active='yes' AND status='Successful'",$limit); + } + + if($db->num_rows>0) + return $result; + else + return false; + + } + + + /** + * Function used to activate or detactivate or delete group member + */ + function member_actions($gid,$memuid,$case,$deleting_group=FALSE) + { + global $db; + + //getting group details + $group = $this->get_group_details($gid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$this->is_member($memuid,$gid)) + e(lang("user_not_grp_mem")); + elseif(userid()!=$group['userid'] && !has_access("admin_access",true)) + e(lang("grp_owner_err1")); + elseif($group['userid']==$memuid && !$deleting_group) + e(lang("you_cant_perform_actions_on_grp_own")); + else + switch($case) + { + case "activate": + case "active": + { + $db->update(tbl($this->gp_mem_tbl),array("active"),array("yes"),"userid='$memuid' AND group_id='$gid'"); + $total_members = $this->total_members($group['group_id']); + $db->update(tbl($this->gp_tbl),array("total_members"),array($total_members)," group_id='".$gid."'"); + e(lang("usr_ac_msg"),"m"); + } + break; + + case "deactivate": + case "deactive": + case "unactivate": + case "unactive": + { + $db->update(tbl($this->gp_mem_tbl),array("active"),array("no"),"userid='$memuid' AND group_id='$gid'"); + $total_members = $this->total_members($group['group_id']); + $db->update(tbl($this->gp_tbl),array("total_members"),array($total_members)," group_id='".$gid."'"); + e(lang("usr_dac_msg"),"m"); + } + break; + + case "delete": + { + + //Delete All Videos oF member + $db->delete(tbl($this->gp_vdo_tbl),array("userid","group_id"),array($memuid,gid)); + //Deleting ALl Topics Of + $this->delete_user_topics($memuid,$gid); + //Delete Member + $db->delete(tbl($this->gp_mem_tbl),array("userid","group_id"),array($memuid,$gid)); + + $total_members = $this->total_members($gid); + $total_videos = $this->total_videos($gid); + $count_topics = $this->count_group_topics($gid); + + //Update Stat + $db->update(tbl($this->gp_tbl),array("total_topics","total_members","total_videos"), + array($count_topics,$total_members,$total_videos)," group_id='".$gid."'"); + + e(lang("usr_del_msg"),"m"); + } + break; + } + + } + + + + /** + * Function used to perform actions on videos + */ + function video_actions($gid,$vid,$case) + { + global $db; + + //getting group details + $group = $this->get_group_details($gid); + + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$this->is_group_video($vid,$gid)) + e(lang("class_vdo_del_err")); + elseif(userid()!=$group['userid'] && !has_access("admin_access")) + e(lang("grp_owner_err1")); + else + switch($case) + { + case "activate": + case "active": + { + $db->update(tbl($this->gp_vdo_tbl),array("approved"),array("yes"),"videoid ='$vid' AND group_id='$gid'"); + $this->update_group_videos_count($gid); + e(lang("class_vdo_act_msg"),"m"); + } + break; + + case "deactivate": + case "deactive": + case "unactivate": + case "unactive": + { + $db->update(tbl($this->gp_vdo_tbl),array("approved"),array("no"),"videoid ='$vid' AND group_id='$gid'"); + $this->update_group_videos_count($gid); + e(lang("class_vdo_act_msg1"),"m"); + } + break; + + case "delete": + { + //Delete video + $db->delete(tbl($this->gp_vdo_tbl),array("videoid","group_id"),array($vid,$gid)); + + $total_videos = $this->total_videos($gid); + //Update Stat + $db->update(tbl($this->gp_tbl),array("total_videos"), + array($total_videos)," group_id='".$gid."'"); + e(lang("class_vdo_del_msg"),"m"); + } + break; + } + + } + + /** + * Function used to invite members to group + */ + function invite_member($user,$gid,$owner=NULL) + { + global $cbemail,$db,$userquery; + $group = $this->get_group_details($gid); + + if(!$owner) + $owner = userid(); + + $sender = $userquery->get_user_details($owner); + $reciever = $userquery->get_user_details($user); + + if(!$group) + e(lang("grp_exist_error")); + elseif(!$sender) + e(lang("unknown_sender")); + elseif(!$reciever) + e(lang("unknown_reciever")); + elseif($this->is_member($user,$gid)) + e(lang("user_already_group_mem")); + elseif($owner != $group['userid']) + e(lang("grp_owner_err1")); + else + { + //Inserting Invitation Code in database + $db->insert(tbl($this->gp_invite_tbl),array('group_id','userid','invited','date_added'), + array($gid,$owner,$reciever['userid'],now())); + e(lang("grp_inv_msg"),"m"); + + //Now Sending Email To User + $tpl = $cbemail->get_template('group_invitation'); + + $more_var = array + ( + '{reciever}' => $reciever['username'], + '{sender}' => $sender['username'], + '{group_url}' => group_link(array('details'=>$group)), + '{group_name}' => $group['group_name'], + '{group_description}' => $group['group_description'] + + ); + + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + //Now Finally Sending Email + cbmail(array('to'=>$reciever['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + } + } + + /** + * Function used to invite members to group + */ + function invite_members($user_array,$group,$owner=NULL) + { + global $eh; + $total = count($user_array); + for($i=0;$i<$total;$i++) + { + $this->invite_member($user_array[$i],$group,$owner); + } + $eh->flush(); + e(lang("invitations_sent"),"m"); + } + + + /** + * Function used to leave group + */ + function leave_group($gid,$uid) + { + global $db; + if(!$this->is_member($uid,$gid)) + e(lang("you_not_grp_mem")); + elseif($this->is_owner($gid,$uid)) + e(lang("grp_owner_err2")); + else + { + $db->delete(tbl($this->gp_mem_tbl),array("userid","group_id"),array($uid,$gid)); + e(lang("grp_leave_succ_msg"),"m"); + } + } + + + /** + * Function used to delete group + */ + function delete_group($gid) + { + global $db; + $group = $this->get_group_details($gid); + if(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$group['userid'] && !has_access('admin_access',true)) + e(lang("you_cant_delete_this_grp")); + else + { + //Deleting Everything Related To This Group + $this->delete_group_topics($gid); + $this->delete_group_videos($gid); + $this->delete_group_members($gid); + $db->delete(tbl($this->gp_tbl),array("group_id"),array($gid)); + $this->update_user_total_groups($group['userid']); + e(lang("grp_deleted"),"m"); + } + } + + /** + * Functin used to delete all memebrs of group + */ + function delete_group_members($gid) + { + global $db; + $group = $this->get_group_details($gid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$group['userid'] && !has_access('admin_access',true)) + e(lang("you_cant_del_grp_mems")); + else + { + $db->delete(tbl($this->gp_mem_tbl),array("group_id"),array($gid)); + e(lang("mems_deleted"),"m"); + } + } + + /** + * Functin used to delete all videos of group + */ + function delete_group_videos($gid) + { + global $db; + $group = $this->get_group_details($gid); + + if(!$group) + e(lang("grp_exist_error")); + elseif(userid()!=$group['userid'] && !has_access('admin_access',true)) + e(lang("you_cant_del_grp_vdos")); + else + { + $db->delete(tbl($this->gp_vdo_tbl),array("group_id"),array($gid)); + e(lang("vdo_multi_del_erro"),"m"); + } + } + + + /** + * Function used to check weather group exists or not + */ + function group_exists($gid) + { + global $db; + $result = $db->count(tbl($this->gp_tbl),"group_id"," group_id='$gid'"); + if($result>0) + return true; + else + return false; + } + + + /** + * Function used to perform gorups actions + */ + function grp_actions($type,$gid) + { + global $db; + $gdetails = $this->get_details($gid); + if(!$gdetails) + e(lang("grp_exist_error")); + else + { + switch($type) + { + case "activate": + case "active": + { + $db->update(tbl($this->gp_tbl),array("active"),array("yes")," group_id='$gid' "); + e(lang("grp_av_msg"),"m"); + } + break; + case "deactivate": + case "deactive": + { + $db->update(tbl($this->gp_tbl),array("active"),array("no")," group_id='$gid' "); + e(lang("grp_da_msg"),"m"); + } + break; + case "featured": + case "feature": + { + $db->update(tbl($this->gp_tbl),array("featured"),array("yes")," group_id='$gid' "); + e(lang("grp_fr_msg"),"m"); + } + break; + case "unfeatured": + case "unfeature": + { + $db->update(tbl($this->gp_tbl),array("featured"),array("no")," group_id='$gid' "); + e(lang("grp_fr_msg2"),"m"); + } + break; + case "delete": + { + $this->delete_group($gid); + e(lang("grp_del_msg"),"m"); + } + break; + } + } + } + + /** + * Function used to get all topic icons + */ + function get_topic_icons() + { + $dir = TOPIC_ICON_DIR; + $icons = glob($dir.'/*.png'); + $new_icons = ''; + foreach($icons as $icon) + { + $icon_parts = explode('/',$icon); + $icon_file = $icon_parts[count($icon_parts)-1]; + $new_icons[] = array('file'=>$icon_file,'path'=>$icon,'url'=>TOPIC_ICON_URL.'/'.$icon_file); + } + + if(count($new_icons)>0) + return $new_icons; + else + return false; + } + + + + + + /** + * Function used to load ADD Topic Form + */ + function load_add_topic_form_fields($array=NULL) + { + if($array==NULL) + $array = $_POST; + + $topic_title = $_POST['topic_title']; + $topic_post = $_POST['topic_post']; + + $fields = array + ( + 'title' => array( + 'title'=> lang('topic_title'), + 'type'=> 'textfield', + 'name'=> 'topic_title', + 'id'=> 'topic_title', + 'value'=> cleanForm($topic_title), + 'size'=>'45', + 'db_field'=>'topic_title', + 'required'=>'yes', + 'min_length' => 1, + 'max_length'=>config('max_topic_title'), + + ), + 'topic_post' => array( + 'title'=> lang("topic_post"), + 'type'=> 'textarea', + 'name'=> 'topic_post', + 'id'=> 'topic_post', + 'value'=> cleanForm($topic_post), + 'size'=>'45', + 'db_field'=>'topic_post', + 'required'=>'yes', + 'min_length' => 4, + 'max_length'=>config('max_topic_length'), + 'anchor_before' => 'before_topic_post_box', + 'anchor_after' => 'after_topic_post_box', + ) + ); + return $fields; + } + + + + /** + * Function used to add video comment + */ + function add_comment($comment,$obj_id,$reply_to=NULL) + { + global $myquery,$db; + + if(!$this->topic_exists($obj_id)) + e(lang("grp_tpc_err4")); + else + { + $owner = $this->get_group_owner_from_topic($obj_id); + $add_comment = $myquery->add_comment($comment,$obj_id,$reply_to,'t',$owner); + if($add_comment) + { + //Loggin Comment + $log_array = array + ( + 'success'=>'yes', + 'details'=> "comment on a topic", + 'action_obj_id' => $obj_id, + 'action_done_id' => $add_comment, + ); + insert_log('topic_comment',$log_array); + + //Updating Number of comments of topics + $this->update_comments_count($obj_id); + } + return $add_comment; + } + } + + /** + * Function used to delete comment + */ + function delete_comment($cid,$objid) + { + global $myquery; + $tdetails = $this->get_topic_details($objid); + $gdetails = $this->get_group_details($tdetails['group_id']); + + $forceDelete = false; + if(userid()==$gdetails['userid']) + $forceDelete = true; + $myquery->delete_comment($cid,'t',false,$forceDelete); + $this->update_comments_count($objid); + } + + /** + * Function delete all comments of topic + */ + function delete_comments($tid) + { + global $myquery; + $tdetails = $this->get_topic_details($tid); + $gdetails = $this->get_group_details($tdetails['group_id']); + $forceDelete = false; + if(userid()==$gdetails['userid']) + { + $forceDelete = true; + $myquery->delete_comments($tid,'t',$forceDelete); + $this->update_comments_count($objid); + } + } + + /** + * Function used to update video comments count + */ + function update_comments_count($id) + { + global $db; + $total_comments = $this->count_topic_comments($id); + if(!userid()) + $userid = 0; + else + $userid = userid(); + + $db->update(tbl($this->gp_topic_tbl),array("total_replies","last_poster","last_post_time"), + array($total_comments,$userid,now())," topic_id='$id'"); + } + + /** + * Function used to count total video comments + */ + function count_topic_comments($id) + { + global $db; + $total_comments = $db->count(tbl('comments'),"comment_id","type='t' AND type_id='$id'"); + return $total_comments; + } + + /** + * Function used to crearte view topic link + */ + function topic_link($tdetails) + { + if(SEO==yes) + return BASEURL.'/view_topic/'.SEO($tdetails['topic_title']).'_tid_'.$tdetails['topic_id']; + else + return BASEURL.'/view_topic.php?tid='.$tdetails['topic_id']; + } + + + /** + * function and show otpion links + */ + function group_opt_link($group,$type) + { + global $userquery; + $gArray = + array + ( + 'group' => $group, + 'groupid' => $group['group_id'], + 'uid' => userid(), + 'user' => $userquery->udetails, + 'checkowner' => 'yes' + ); + switch($type) + { + case 'join': + { + if($this->is_joinable($group)) + { + if(SEO=="yes") + return ''.lang('join').''; + else + return ''.lang('join').''; + }else + return false; + } + break; + + case 'invite': + { + if($this->is_owner($group)) + { + return ''.lang('invite').''; + } + } + break; + + case 'leave': + { + if($this->is_member(userid(),$group['group_id']) && !$this->is_owner($group)) + { + if(SEO=="yes") + return ''.lang('leave').''; + else + return ''.lang('leave').''; + } + } + break; + + case 'remove_group': + { + if($this->is_owner($group)) + { + $gpID = $group['group_id']; $message = lang('are_you_sure_del_grp'); + $url = BASEURL.'/manage_groups.php?mode=manage&gid_delete='.$gpID; + return "".lang('grp_remove_group').""; + } + } + break; + + case 'manage_members': + { + + if($this->is_admin($gArray)) + { + return ''.lang('grp_manage_mems').''; + } + } + break; + + case 'manage_videos': + { + if($this->is_admin($gArray)) + { + return ''.lang('com_manage_vids').''; + } + } + break; + + + case 'add_videos': + { + if($this->is_member(userid(),$group['group_id'])) + { + return ''.lang('grp_add_vdos').''; + } + } + break; + + case 'edit_group': + { + if($this->is_admin($gArray)) + { + return ''.lang('grp_edit_grp_title').''; + } + } + break; + } + return false; + } + + /** + * Function used to check weather + * this group is joinable or not + * it will check + * - user is logged in or not + * - if user is logged in , check is he member or not + * - if he is not a member, check is he invited + * - if is invited then show the link + */ + function is_joinable($group,$uid=NULL,$gen_err=FALSE) + { + if(!$uid) + $uid = userid(); + + $group_id = $group['group_id']; + if($this->is_member($uid,$group['group_id'])) + { + if($gen_err) + e(lang('grp_join_error')); + return false; + }elseif($group['group_privacy']!=2 || $this->is_invited($uid,$group_id,$group['userid'],$gen_err)) + return true; + else + return false; + } + + + /** + * Function used to check weather to view + * group details ot user or not. + * We need to check following things and display Message Accordingly + * First - we to save group privacy into variables + * Second - $privacy == 1 and user is not member of group. Display group but with warning message. + * Third - $privacy == 1 and user is member of group. Display group but with warning message about pending approval. + * Fourth - $privacy == 2 and user is not member. Dont display group with error message + */ + function is_viewable($group,$uid=NULL) + { + if(!$uid) + $uid = userid(); + $privacy = $group['group_privacy']; + $isMember = $this->is_member($uid,$group['group_id']); + + if($privacy == 1 && !$isMember) + { + e(lang("you_need_owners_approval_to_view_group"),"w"); + return true; + } elseif($privacy == 1 && !$this->is_active_member($uid,$group['group_id'])) + { + e(lang("grp_inactive_account"),"w"); + return true; + } elseif($privacy == 2 && !$isMember && !$this->is_invited($uid,$group['group_id'],$group['userid'])) { + e(lang("grp_prvt_err1")); + return false; + } else { + return true; + } + +/* $group_id = $group['group_id']; + $is_Member = $this->is_member($uid,$group['group_id'],true); + + if($group['group_privacy'] == 2 && !$is_Member) + return array("privacy"=>$group['group_privacy'],"isMember"=>$is_Member); + elseif($group['group_privacy'] == 1 && !$is_Member) + return array("privacy"=>$group['group_privacy'],"isMember"=>$is_Member); + else + return true; */ + } + + + + /** + * Function used to get groups + * @parma ARRAY + * group_id => {id of group} INT + * user => {all groups of the user INT + * category => {all groups in specified category INT,INT,INT + * featured => {get featured groups only} yes,no + * limit => {number of results including offset} + * order => {soring by} + * date_margin => {date span} + */ + function get_groups($params=NULL,$force_admin=FALSE) + { + global $db; + + $limit = $params['limit']; + $order = $params['order']; + + $cond = ""; + if(!has_access('admin_access',TRUE) && !$force_admin) + $cond .= " ".tbl("groups.active")."='yes' "; + else + { + if($params['active']) + $cond .= " ".tbl("groups.active")."='".$params['active']."'"; + } + + //Setting Category Condition + if(!is_array($params['category'])) + $is_all = strtolower($params['category']); + + if($params['category'] && $is_all!='all') + { + if($cond!='') + $cond .= ' AND '; + + $cond .= " ("; + + if(!is_array($params['category'])) + { + $cats = explode(',',$params['category']); + }else + $cats = $params['category']; + + $count = 0; + + foreach($cats as $cat_params) + { + $count ++; + if($count>1) + $cond .=" OR "; + $cond .= " ".tbl("groups.category")." LIKE '%#$cat_params#%' "; + } + + $cond .= ")"; + } + + //date span + if($params['date_span']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".cbsearch::date_margin("date_added",$params['date_span']); + } + + //uid + if($params['user']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("groups.userid")."='".$params['user']."'"; + } + + $tag_n_title=''; + //Tags + if($params['tags']) + { + //checking for commas ;) + $tags = explode(",",$params['tags']); + if(count($tags)>0) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $total = count($tags); + $loop = 1; + foreach($tags as $tag) + { + $tag_n_title .= " ".tbl("groups.group_tags")." LIKE '%".$tag."%'"; + if($loop<$total) + $tag_n_title .= " OR "; + $loop++; + + } + }else + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " ".tbl("groups.group_tags")." LIKE '%".$params['tags']."%'"; + } + } + //TITLE + if($params['title']) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " ".tbl("groups.group_name")." LIKE '%".$params['title']."%'"; + } + + if($tag_n_title) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ($tag_n_title) "; + } + + //FEATURED + if($params['featured']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("groups.featured")." = '".$params['featured']."' "; + } + + //GROUP ID + if($params['group_id']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " group_id = '".$params['group_id']."' "; + } + + //Exclude Vids + if($params['exclude']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("groups.group_id")." <> '".$params['exclude']."' "; + } + + + + if(!$params['count_only']) + { + if(!empty($cond)) + $cond .= " AND "; + $result = $db->select(tbl($this->gp_tbl.",users"),''.tbl($this->gp_tbl).'.*, '.tbl("users").'.username, '.tbl("users").'.userid',$cond." ".tbl("groups.userid")." = ".tbl("users.userid")." ",$limit,$order); + } + + // echo $db->db_query; + if($params['count_only']) + return $result = $db->count(tbl($this->gp_tbl),'*',$cond); + if($params['assign']) + assign($params['assign'],$result); + else + return $result; + } + + + + + + /** + * Function used to get group field + * @ param INT gid + * @ param FIELD name + */ + function get_gp_field($gid,$field) + { + global $db; + $results = $db->select(tbl($this->gp_tbl),$field,"group_id='$gid'"); + + if($db->num_rows>0) + { + return $results[0]; + }else{ + return false; + } + }function get_gp_fields($gid,$field){return $this->get_gp_field($gid,$field);} + + + /** + * This function will return + * group field without array + */ + function get_gp_field_only($gid,$field) + { + $fields = $this->get_gp_field($gid,$field); + return $fields[$field]; + } + + /** + * Function used to get groups joined by user + */ + function user_joined_groups($uid,$limit=NULL) + { + global $db; + # REF QUERY : SELECT * FROM group_members,groups WHERE group_members.userid = '1' AND group_members.group_id = groups.group_id AND groups_members.userid != groups.userid + $result = $db->select(tbl($this->gp_tbl).','.tbl($this->gp_mem_tbl),"*",tbl($this->gp_mem_tbl).".userid='$uid' AND + ".tbl($this->gp_mem_tbl).".group_id = ".tbl($this->gp_tbl).".group_id AND ".tbl($this->gp_mem_tbl).".userid != ".tbl($this->gp_tbl).".userid",$limit,tbl($this->gp_tbl).".group_name"); + if($db->num_rows>0) + return $result; + else + return false; + } + + + /*** + * Function used to update user total number of groups + */ + function update_user_total_groups($user) + { + global $db; + $count = $db->count(tbl($this->gp_tbl),"group_id"," userid='$user' "); + $db->update(tbl("users"),array("total_groups"),array($count)," userid='$user' "); + } + + + + + /** + * Function used to use to initialize search object for video section + * op=>operator (AND OR) + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "groups"; + $this->search->columns =array( + array('field'=>'group_name','type'=>'LIKE','var'=>'%{KEY}%'), + ); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/group.html'; + $this->search->template_var = 'group'; + $this->search->multi_cat = true; + $this->search->results_per_page = config('grps_items_search_page'); + $this->search->has_user_id = true; + + /** + * Setting up the sorting thing + */ + + $sorting = array( + 'date_added' => lang("date_added"), + 'total_views' => lang("views"), + 'total_comments' => lang("comments"), + 'total_videos' => lang("videos"), + 'total_members' => lang("total members"), + ); + + $this->search->sorting = array( + 'date_added'=> " date_added DESC", + 'total_views' => " total_views DESC", + 'total_comments' => " total_comments DESC ", + 'total_videos' => " total_videos DESC", + 'total_members' => " total_members DESC", + ); + /** + * Setting Up The Search Fields + */ + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['groups'] = array('title'=>'Groups'); + + $fields = array( + 'query' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'query', + 'id'=> 'query', + 'value'=>cleanForm($default['query']) + ), + 'category' => array( + 'title' => lang('category'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'category_type'=>'group', + ), + 'date_margin' => array( + 'title' => lang('created'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['groups']['fields'] = $fields; + } + + + /** + * Function used to validate group category + * @param input array + */ + function validate_group_category($array=NULL) + { + if($array==NULL) + $array = $_POST['category']; + if(count($array)==0) + return false; + else + { + + foreach($array as $arr) + { + if($this->category_exists($arr)) + $new_array[] = $arr; + } + } + if(count($new_array)==0) + { + e(lang('vdo_cat_err3')); + return false; + }elseif(count($new_array)>ALLOWED_GROUP_CATEGORIES) + { + e(sprintf(lang('vdo_cat_err2'),ALLOWED_GROUP_CATEGORIES)); + return false; + } + + return true; + } + + + /** + * Get group owner from topic + */ + function get_group_owner_from_topic($tid) + { + global $db; + $results = $db->select(tbl("group_topics").",".tbl("groups"), + tbl("group_topics").".group_id,".tbl("group_topics").".topic_id,".tbl("groups")."userid,".tbl("groups").".group_id", + tbl("group_topics").".group_id = ".tbl("groups").".group_id AND ".tbl("group_topics").".topic_id='$tid'"); + + if($db->num_rows>0) + return $results[0]['userid']; + else + return false; + } + + /** + * Function used to make member admin of the group + * input ARRAY + * INDEX gid => groupid + * INDEX group => groupdetails + * INDEX uid => Userid + * INDEX user => userdtails + * return error() | return true on success makeAdmin + */ + function make_admin($array){ return $this->makeAdmin($array);} + function makeAdmin($array) + { + global $userquery,$db; + extract($array); + if(!@$groupid) + e(lang('Unknown group')); + elseif(!@$group) + { + $group = $this->get_group($groupid); + } + + if(!@$uid) + e(lang('Unknown group user')); + elseif(!@$user) + { + $user = $userquery->get_user_details($uid); + } + + if(!$group) + e(lang("Unknown group")); + if(!$user) + e(lang("Unknown user")); + + //if(!$this->is_member($uid,$groupid)) + // e(sprintf(lang("%s is not a member of %s"),$user['username'],$group['group_name'])); + if(!$this->is_active_member($uid,$groupid)) + e(sprintf(lang("%s is not active member of %s"),$user['username'],$group['group_name'])); + + + //Checking if is owner or already an admin + $this->is_admin(array( + 'group'=>$group, + 'groupid'=>$groupid, + 'uid'=>$uid, + 'user'=>$user, + 'error'=>true, + 'checkowner'=>true)); + + if(!error()) + { + $groupAdmins = $group['group_admins']; + $groupAdmins = json_decode($groupAdmins,true); + $groupAdmins[] = $uid; + $groupAdmins = json_encode($groupAdmins); + + $db->update(tbl("groups"),array("group_admins"), + array('|no_mc|'.$groupAdmins)," group_id='".$groupid."'"); + e(sprintf(lang("%s has been made adminstrator of %s"),$user['username'],$group['group_name']),"m"); + return true; + } + + return false; + } + + + /** + * Function used to get weather user is admin of the group or not + * input ARRAY + * INDEX gid => groupid + * INDEX group => groupdetails + * INDEX uid => Userid + * INDEX user => userdtails + * return error() | return true on success makeAdmin + */ + function is_admin($array) + { + global $userquery; + extract($array); + if(!@$groupid) + e(lang('Unknown group')); + elseif(!@$group) + { + $group = $this->get_group($groupid); + } + + if(!@$uid) + e(lang('Unknown group user')); + elseif(!@$user) + { + $user = $userquery->get_user_details($uid); + } + if(!$group) + e(lang("Unknown group")); + if(!$user) + e(lang("Unknown user")); + + //Moving group admins into an array + $groupAdmins = $group['group_admins']; + $groupAdmins = json_decode($groupAdmins,true); + + if($group['userid']== $uid && $checkowner) + { + if(@$error) + e(sprintf(lang('%s is owner of %s'),$user['username'],$group['group_name'])); + return true; + }elseif(@in_array($uid,$groupAdmins)) + { + if(@$error) + e(sprintf(lang('%s is admin of %s'),$user['username'],$group['group_name'])); + return true; + } + + return false; + } + + + /** + * Removing admin from group + */ + function remove_admin($array){ return $this->removeAdmin($array);} + function removeAdmin($array) + { + global $userquery,$db; + extract($array); + if(!@$groupid) + e(lang('Unknown group')); + elseif(!@$group) + { + $group = $this->get_group($groupid); + } + + if(!@$uid) + e(lang('Unknown group user')); + elseif(!@$user) + { + $user = $userquery->get_user_details($uid); + } + + if(!$group) + e(lang("Unknown group")); + if(!$uid) + e(lang("Unknown user")); + + + //Checking if is owner or already an admin + if(!$this->is_admin(array( + 'group'=>$group, + 'groupid'=>$groupid, + 'uid'=>$uid, + 'user'=>$user))) + { + e(sprintf(lang('%s is not admin of %s'),$user['username'],$group['group_name'])); + return false; + }else + { + $groupAdmins = $group['group_admins']; + $groupAdmins = json_decode($groupAdmins,true); + $newAdmins = array(); + foreach($groupAdmins as $gadmin) + if($gadmin!=$uid) + $newAdmins[] = $gadmin; + + $groupAdmins = json_encode($newAdmins); + $db->update(tbl("groups"),array("group_admins"), + array('|no_mc|'.$groupAdmins)," group_id='".$groupid."'"); + e(sprintf(lang("%s has been removed from adminstrators of %s"),$user['username'],$group['group_name']),"m"); + return true; + + } + + } + + +} + +function isGroupAdmin($array){ global $cbgroup; $return = $cbgroup->is_admin($array); +if($array['assign']) assign($array['assign'],$return); else return $return;} +function removeGroupAdmin($array){ global $cbgroup; $return = $cbgroup->removeAdmin($array); +if($array['assign']) assign($array['assign'],$return); else return $return;} +function makeGroupAdmin($array){ global $cbgroup; $return = $cbgroup->make_admin($array); +if($array['assign']) assign($array['assign'],$return); else return $return; } + +?> \ No newline at end of file diff --git a/upload/includes/classes/image.class.php b/upload/includes/classes/image.class.php new file mode 100644 index 00000000..a6c987d1 --- /dev/null +++ b/upload/includes/classes/image.class.php @@ -0,0 +1,74 @@ + $dim || $height_orig>$dim ) + { + if($width_orig > $height_orig) + { + $ratio= $width_orig/$dim; + }else{ + if($dim_h==NULL) + $ratio=$height_orig/$dim; + else + $ratio=$height_orig/$dim_h; + } + + $width=$width_orig/$ratio; + $height=$height_orig/$ratio; + + if($aspect_ratio == false && $dim_h !=''){ + $width = $dim; + $height = $dim_h; + } + + $image_p = imagecreatetruecolor($width, $height); + + if($ext=='jpg' || $ext=='JPG' || $ext=='JPEG'){ + $image = imagecreatefromjpeg($file); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + imagejpeg($image_p,$des, 90); + } + if($ext=='png' || $ext=='PNG'){ + $image = imagecreatefrompng($file); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + imagepng($image_p,$des); + } + + if($ext=='gif' || $ext=='GIF'){ + $image = imagecreatefromgif($file); + imagecopyresampled($image_p, $image, 0, 0, 0, 0, $width, $height, $width_orig, $height_orig); + imagegif($image_p,$des, 90); + } + }else + { + if(!file_exists($des)) + copy($file,$des); + } + } + + //Validating an Image + + function ValidateImage($file,$ext=NULL){ + $array = getimagesize($file); + if($ext == 'jpg' || $ext == 'JPG' ||$ext == 'JPEG' || $ext == 'gif' || $ext == 'GIF' || $ext == 'PNG' || $ext == 'png'){ + if(empty($array[0]) || empty($array[1])){ + $validate = false; + }else{ + $validate = true; + } + }else{ + $validate = false; + } + return $validate; + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/index.php b/upload/includes/classes/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/classes/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/classes/lang.class.php b/upload/includes/classes/lang.class.php new file mode 100644 index 00000000..387d3c17 --- /dev/null +++ b/upload/includes/classes/lang.class.php @@ -0,0 +1,500 @@ +lang = $this->lang_iso = 'en'; + } + + /** + * INIT + */ + function init() + { + $lang = mysql_clean($_COOKIE['cb_lang']); + + //Setting Language + if(isset($_GET['set_site_lang'])) + { + $lang = $_GET['set_site_lang']; + if($this->lang_exists($lang)) + setcookie('cb_lang',$lang,time()+3600,'/'); + } + + + $lang_details = $this->lang_exists($lang); + + if(isset($lang) && $lang_details) + { + $default = $lang_details ; + }else + { + $default = $this->get_default_language(); + } + + if($default['language_code']) + { + $this->lang = $this->lang_iso = $default['language_code']; + } + } + + + /** + * Function used add new phrase + */ + function add_phrase($name,$text,$lang_code='en') + { + global $db; + //First checking if phrase already exists or not + if(empty($name)) + e(lang("phrase_code_empty")); + elseif(empty($text)) + e(lang("phrase_text_empty")); + elseif(!$this->lang_exists($lang_code)) + e(lang("language_does_not_exist")); + elseif(!$this->get_phrase($name,$lang_code)) + { + e(sprintf(lang("name_has_been_added"),$name),'m'); + $db->insert(tbl("phrases"),array('lang_iso','varname','text'),array($lang_code,$name,'|no_mc|'.$text)); + }else{ + e(sprintf(lang("name_already_exists"),$name),'m'); + } + } + + /** + * Function used to get language phrase + * @param STRING name + * @param STRING lang_code + */ + function get_phrase($name,$lang_code=NULL) + { + global $db; + + + if($lang_code!='') + { + $lang_query = "AND lang_iso = '".mysql_clean($lang_code)."'"; + } + + $results = $db->select(tbl("phrases"),'*'," id = '".mysql_clean($name)."' OR varname = '".mysql_clean($name)."' $lang_query "); + if($db->num_rows > 0 ) + return $results[0]; + else + return false; + } + + + /** + * Function used to modify phrase + */ + function update_phrase($id,$text,$lang_code='en') + { + global $db; + //First checking if phrase already exists or not + if($this->get_phrase($id,$lang_code)) + $db->update(tbl("phrases"),array('text'),array(mysql_real_escape_string($text))," id = '".mysql_real_escape_string($id)."' "); + } + + /** + * Function used to get all phrases of particular language + */ + function get_phrases($lang=NULL,$fields="varname,text",$limit=NULL,$extra_param=NULL) + { + global $db; + $lang_details = $this->lang_exists($lang); + $lang_code = $lang_details['language_code']; + if(empty($lang_code)) + $lang_code = $this->lang; + return $db->select(tbl("phrases"),$fields," lang_iso = '".$lang_code."' $extra_param",$limit," id "); + + } + + + /** + * Function used to count phrases + */ + function count_phrases($lang=NULL,$extra_param=NULL) + { + global $db; + $lang_details = $this->lang_exists($lang); + $lang_code = $lang_details['lang_code']; + if(empty($lang_code)) + $lang_code = $this->lang; + + $results = $db->select(tbl("phrases"),"COUNT(id)"," lang_iso = '".$lang_code."' $extra_param"); + if($db->num_rows>0) + return $results[0][0]; + else + return 0; + + } + + /** + * Function used to assign phrases as an array + */ + function lang_phrases($code='db') + { + if($code == 'db') + { + $phrases = $this->get_phrases(); + foreach($phrases as $phrase) + { + $lang[$phrase['varname']] = $phrase['text']; + } + }else + { + $lang = $this->getPhrasesFromPack(); + } + return $lang; + } + + + /** + * Function used to get list of languages installed + */ + function get_langs($active=false) + { + global $db; + $cond = NULL; + if($active) + $cond = " language_active='yes' "; + $results = $db->select(tbl("languages"),"*",$cond); + return $results; + } + + + + /** + * Function used to check + * weather language existsor not + * using iso_code or its lang_id + */ + function lang_exists($id) + { + global $db; + $results = $db->select(tbl("languages"),"*"," language_code ='$id' OR language_id = '$id'"); + if($db->num_rows>0) + return $results[0]; + else + return false; + } + + + /** + * Make Language Default + */ + function make_default($lid) + { + global $db; + $lang = $this->lang_exists($lid); + if($lang) + { + setcookie('cb_lang',$lid,time()+3600,'/'); + $db->update(tbl("languages"),array("language_default"),array("no")," language_default='yes'"); + $db->update(tbl("languages"),array("language_default"),array("yes")," language_id='$lid'"); + e($lang['language_name']." has been set as default language","m"); + } + } + + /** + * function used to get default language + */ + function get_default_language() + { + global $db; + $result = $db->select(tbl('languages'),"*"," language_default='yes' "); + $result = $result[0]; + return $result; + } + + /** + * Funcion used to get language detilas + */ + function get_lang($id) + { + return $this->lang_exists($id); + } + + + + /** + * Function used to export language + */ + function export_lang($id) + { + + //first get language details + $lang_details = $this->get_lang($id); + if($lang_details) + { + header("Pragma: public"); // required + header("Expires: 0"); + header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); + header("Cache-Control: private",false); // required for certain browsers + header("Content-type: application/force-download"); + header("Content-Disposition: attachment; filename=\"cb_lang_".$lang_details['language_code'].".xml\""); + echo ''; + ?> + + + + + $this->lang_phrases()));?> + + +lang_exists($data['iso_code'])) + e(lang("language_already_exists")); + else + { + $db->insert(tbl("languages"),array("language_code","language_name","language_regex","language_default"), + array($data['iso_code'],$data['name'],"/^".$data['iso_code']."/i","no")); + $sql = ''; + foreach($phrases as $code => $phrase) + { + if(!empty($sql)) + $sql .=",\n"; + $sql .= "('".$data['iso_code']."','$code','".mysql_real_escape_string($phrase)."')"; + } + $sql .= ";"; + $query = "INSERT INTO ".tbl("phrases")." (lang_iso,varname,text) VALUES \n"; + $query .= $sql; + $db->execute($query); + e(lang("lang_added"),"m"); + } + } + + }else + e(lang("error_while_upload_file")); + + if(file_exists($file_name)) + unlink($file_name); + } + + /** + * Function used to delete language pack + */ + function delete_lang($i) + { + global $db; + $lang = $this->get_lang($i); + if(!$lang) + e(lang("language_does_not_exist")); + elseif($lang['language_default'] == 'yes') + e(lang("default_lang_del_error")); + else + { + $db->delete(tbl('languages'),array("language_code"),array($lang['language_code'])); + $db->delete(tbl('phrases'),array("lang_iso"),array($lang['language_code'])); + e(lang("lang_deleted"),"m"); + } + } + + /** + * Function used to update language + */ + function update_lang($array) + { + global $db; + $lang = $this->get_lang($array['lang_id']); + if(!$lang) + e(lang("language_does_not_exist")); + elseif(empty($array['name'])) + e(lang("lang_name_empty")); + elseif(empty($array['code'])) + e(lang("lang_code_empty")); + elseif(empty($array['regex'])) + e(lang("lang_regex_empty")); + elseif($this->lang_exists($array['code']) && $array['code'] != $lang['language_code']) + e(lang("lang_code_already_exist")); + else + { + $db->update(tbl('languages'),array("language_name","language_code","language_regex"), + array($array['name'],$array['code'],$array['regex'])," language_id='".$array['lang_id']."'"); + if($array['code'] != $lang['language_code']) + $db->update(tbl("phrases"),array("lang_iso"),array($array['code'])," lang_iso='".$lang['language_code']."'"); + e(lang("lang_updated"),"m"); + } + + } + + + /** + * Function used to create new language pack + * that can be used by clipbucket + * + */ + function createPack($lang=false) + { + if(!$lang) + $lang = $this->lang; + $phrases = $this->get_phrases($lang); + + if(count($phrases)==0) return false; + $new_array = array(); + foreach($phrases as $phrase) + { + $new_array[$phrase['varname']] = $phrase['text']; + } + $fo = fopen(BASEDIR.'/includes/langs/'.$lang.'.lang','w+'); + fwrite($fo,json_encode($new_array)); + fclose($fo); + return true; + } + + + /** + * function used to activate or deactive language + */ + function action_lang($action,$id) + { + global $db; + $lang = $this->lang_exists($id); + + if(!$this->lang_exists($id)) + e($lang); + elseif($lang['language_default']=='yes') + e(lang("lang_default_no_actions")); + else + { + switch($action) + { + case "active": + case "activate": + { + $db->update(tbl('languages'),array("language_active"),array("yes")," language_id='$id' "); + e(lang("lang_has_been_activated"),"m"); + } + break; + case "deactive": + case "deactivate": + { + $db->update(tbl('languages'),array("language_active"),array("no")," language_id='$id' "); + e(lang("lang_has_been_deactivated"),"m"); + } + break; + } + } + + } + + /** + * Function used to get phrases from language packs + */ + function getPhrasesFromPack($lang=false) + { + if(!$lang) + $lang = $this->lang; + $file = BASEDIR.'/includes/langs/'.$lang.'.lang'; + if(!file_exists($file)) + $this->createPack($lang); + $langData = file_get_contents($file); + $phrases = json_decode($langData,true); + return $phrases; + } + + /** + * Function used to import language from lang file + * this function fill first remove all phrases from database + * then update the language so that when we release update we just update the + * file and then call this function to refresh all the language phrases. + */ + function updateFromPack($lang=NULL) + { + global $db; + if(!$lang) + $lang = $this->lang; + $file = BASEDIR.'/includes/langs/'.$lang.'.lang'; + if(file_exists($file)) + { + $langData = file_get_contents($file); + $phrases = json_decode($langData,true); + //First lets delete all language phrases + $db->delete(tbl("phrases"),array("lang_iso"),array($lang)); + //Now create query and then execute it + $query = "INSERT INTO ".tbl("phrases")." + (`lang_iso` ,`varname` ,`text`) + VALUES"; + + $count = 0; + foreach($phrases as $key => $phrase) + { + if($count>0) + $query .= ","; + $query .= "('$lang', '$key', '".addslashes($phrase)."')"; + $count++; + } + $query .= ";"; + + $db->Execute($query); + + } + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/log.class.php b/upload/includes/classes/log.class.php new file mode 100644 index 00000000..8ff0bbb1 --- /dev/null +++ b/upload/includes/classes/log.class.php @@ -0,0 +1,92 @@ +udetails['userid']; + $username = $username ? $username : $userquery->udetails['username']; + $useremail = $useremail ? $useremail : $userquery->udetails['email']; + $userlevel = $userlevel ? $userlevel : $userquery->udetails['level']; + + $success = $a['success']; + $details = $a['details']; + + $db->insert(tbl('action_log'), + array + ( + 'action_type', + 'action_username', + 'action_userid', + 'action_useremail', + 'action_ip', + 'date_added', + 'action_success', + 'action_details', + 'action_userlevel', + 'action_obj_id', + 'action_done_id', + ), + array + ( + $type, + $username, + $userid , + $useremail, + $ip, + NOW(), + $success, + $details, + $userlevel, + $action_obj_id, + $action_done_id + ) + ); + + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/mass_upload.class.php b/upload/includes/classes/mass_upload.class.php new file mode 100644 index 00000000..723e45eb --- /dev/null +++ b/upload/includes/classes/mass_upload.class.php @@ -0,0 +1,113 @@ +dirsep."*.".$ext); + + $set_limit = 0; + + foreach($FILES as $key => $file) + { + if( filemtime( $file ) > $sec ){ + $FILE_LIST[$key]['path'] = substr( $file, 0, ( strrpos( $file, $this->dirsep ) +1 ) ); + $FILE_LIST[$key]['file'] = substr( $file, ( strrpos( $file, $this->dirsep ) +1 ) ); + $FILE_LIST[$key]['title'] = getName($FILE_LIST[$key]['file']); + $FILE_LIST[$key]['description'] = getName($FILE_LIST[$key]['file']); + $FILE_LIST[$key]['tags'] = gentags(str_replace(" ",",",getName($FILE_LIST[$key]['file']))); + $FILE_LIST[$key]['size'] = filesize( $file ); + $FILE_LIST[$key]['date'] = date('Y-m-d G:i:s', filemtime( $file ) ); + } + } + if(!empty($FILE_LIST)){ + return $FILE_LIST; + } else { + return false; + } + } + + + /** + * Function used to get list of available files that can be processed + */ + function get_files() + { + $files = $this->glob_files(MASS_UPLOAD_DIR); + return $files; + } + + + /** + * function used to get video files only3 + */ + function get_video_files($with_path=false) + { + $exts = get_vid_extensions($with_path); + + $vid_files = array(); + $files = $this->get_files(); + if(is_array($files)) + foreach($files as $file) + { + $ext = getext($file['file']); + if(in_array($ext,$exts)) + $vid_files[] = $file; + } + return $vid_files; + } + + /** + * Moving file from MASS UPLOAD DIR TO TEMP DIR + */ + function move_to_temp($file_arr,$file_key) + { + $file = $file_arr['file']; + $mass_file = MASS_UPLOAD_DIR.'/'.$file; + $temp_file = TEMP_DIR.'/'.$file_key.'.'.getExt($file); + if(file_exists($mass_file) && is_file($mass_file)) + { + rename($mass_file,$temp_file); + //copy($mass_file,$temp_file); + return $file_key.'.'.getExt($file); + } + return false; + } + + + /** + * Function used to check weather file exists in mass upload folder or not + */ + function is_mass_file($arr) + { + $file = MASS_UPLOAD_DIR.'/'.$arr['file']; + if(file_exists($file) && is_file($file) && $arr['file']) + return true; + else + return false; + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/menuhandler.class.php b/upload/includes/classes/menuhandler.class.php new file mode 100644 index 00000000..3a8ecfbe --- /dev/null +++ b/upload/includes/classes/menuhandler.class.php @@ -0,0 +1,204 @@ +setDisplayTypes(); + } + + function setDisplayTypes() + { + $displayTypes = array('global' => 'Global', + 'registered' => 'Registered Users', + 'guest' => 'Guest Users'); + if(count($this->displayTypes) > 0) + $displayTypes = array_merge($displayTypes,$this->displayTypes); + + $this->displayTypes = $displayTypes; + } + + function createHeadMenu($params=NULL) + { + $this->headMenu[strtolower(lang("menu_home"))] = array('name'=>lang("menu_home"), + 'link'=>BASEURL, + 'this'=>'home', + 'display_type' => 'global'); + $this->headMenu[strtolower(lang("videos"))] = array('name'=>lang("videos"), + 'link'=>cblink(array("name"=>"videos")), + 'this'=>'videos', + 'display_type' => 'global'); + //pr($this->headMenu,TRUE); + return $this->headMenu; + } + + function createHeadFile() + { + $current_menu = $this->createHeadMenu(); + $file = BASEDIR.'/includes/templates/'.$this->headFile; + if(file_exists($file)) + { + $finalArray = array(); + foreach($current_menu as $menu) + { + $finalArray[] = $menu; + } + $fo = fopen(BASEDIR.'/includes/templates/'.$this->headFile,'w+'); + fwrite($fo,json_encode($finalArray)); + fclose($fo); + return true; + } else { + e(sprintf(lang("file_not_exists"),$this->headFile)); + return false; + } + } + + function addNewTab($params=NULL) + { + if($params == NULL) + $params = $_POST; + + if(empty($params['name'])) + e(lang("tab_name_is_empty")); + if(!$this->validURL($params['link_name'])) + return false; + + if(!error()) + { + $menuName = $params['name']; + $cbLink = cblink(array('name'=>strtolower($params['link_name']))); + if($cbLink) + $fullURL = $cbLink; + elseif($params['noBASEURL']) + $fullURL = $params['link_name']; + else + { + $fullURL = BASEURL."/".$params['link_name']; + } + + $resultArray = array("name"=>$menuName,"link"=>$fullURL,"this"=>strtolower($menuName)); + return $resultArray; + } + } + + function validURL($url) + { + // Following Pattern is by DraconianDevil. Link: http://RegExr.com?2sf02 + //$pattren = '/(((http|ftp|https):\/\/)|www\.)[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#!]*[\w\-\@?^=%&/~\+#])?/g'; + if(empty($url)) + { + e(lang("tab_url_is_empty")); + } + } + + function getMenus() + { + $files = glob(BASEDIR."/includes/templates/*.menu"); + if(!empty($files)) + { + foreach($files as $file) + { + $file_parts = explode("/",$file); + $name = $file_parts[count($file_parts)-1]; + $fileName[] = $name; + } + + return $fileName; + } else { + return false; + } + } + + function getMenuName($name) + { + if(empty($name)) + e(lang("menu_name_is_empty")); + else + { + $parts = explode(".",$name); + return $parts[0]; + } + } + + function getTabs($name) + { + if(empty($name)) + e(lang("name_is_empty")); + elseif(!file_exists(BASEDIR."/includes/templates/".$name.$this->fileExt)) + { + e(lang("menu_does_not_exist")); + } else { + $content = file_get_contents(BASEDIR."/includes/templates/".$name.$this->fileExt); + $content = json_decode($content,TRUE); + return $content; + } + } + + function getMenu($name) + { + if(empty($name)) + return false; + else + { + if(file_exists(BASEDIR."/includes/templates/".$name.$this->fileExt)) + { + return $name; + } + else + e(lang("menu_does_not_exist")); + } + } + + function updateMenu($oldName,$newName) + { + if(empty($newName)) + e(lang("menu_name_is_empty")); + elseif(!file_exists(BASEDIR."/includes/templates/".$oldName.$this->fileExt)) + e(lang("menu_does_not_exist")); + else + { + $file = BASEDIR."/includes/templates/".$oldName.$this->fileExt; + rename($file,BASEDIR."/includes/templates/".strtolower(SEO($newName)).$this->fileExt); + e(lang("menu_updated")." Go Back","m"); + } + } + + function createNewMenu($params=NULL) + { + if($params == NULL) + $params = $_POST; + + if(empty($params['menuName'])) + { + e("menu_name_is_empty"); + return false; + } else { + $name = $params['menuName']; + $file = BASEDIR."/includes/templates/".strtolower(SEO($name)).$this->fileExt; + if(file_exists($file)) + e("Menu with ".$name." name already exists"); + else + { + $fopen = fopen($file,'w+'); + if($fopen) + e(lang("New Menu Added"),"m"); + fclose($fopen); + } + } + } + +} +?> \ No newline at end of file diff --git a/upload/includes/classes/my_queries.class.php b/upload/includes/classes/my_queries.class.php new file mode 100644 index 00000000..d1e0cbed --- /dev/null +++ b/upload/includes/classes/my_queries.class.php @@ -0,0 +1,1069 @@ +config_exists($name,true); + + $db->update(tbl("config"),array('value'),array($value)," name = '".$name."'"); + //echo $db->db_query."

    "; + $Cbucket->configs = $Cbucket->get_configs(); + } + + function Get_Website_Details() + { + + $query = mysql_query("SELECT * FROM ".tbl("config")); + while($row = mysql_fetch_array($query)) + { + $name = $row['name']; + $data[$name] = $row['value']; + } + return $data; + } + + /** + * Function used to check weather config exists or not + * it also used to create a config if it does not exist + */ + function config_exists($name) + { + global $db,$Cbucket; + + $configs = $Cbucket->configs; + + if (array_key_exists($name, $configs)) + return true; + else + $db->insert(tbl("config"),array('name'),array($name)); + + /*$count = $db->count(tbl("config"),"configid"," name='$name' "); + if(!$count) + $db->insert(tbl("config"),array('name'),array($name));*/ + + return true; + } + + + + //Function Used to Check Weather Video Exists or not + function VideoExists($videoid){global $cbvid;return $cbvid->exists($videoid);} + function video_exists($videoid){return $this->VideoExists($videoid);} + function CheckVideoExists($videokey){return $this->VideoExists($videokey);} + + //Function used to Delete Video + + function DeleteVideo($videoid){ + global $cbvid; + return $cbvid->delete_video($videoid); + } + + //Video Actions - All Moved to video.class.php + function MakeFeaturedVideo($videoid){global $cbvid;return $cbvid->action('feature',$videoid);} + function MakeUnFeaturedVideo($videoid){global $cbvid;return $cbvid->action('unfeature',$videoid);} + function ActivateVideo($videoid){global $cbvid;return $cbvid->action('activate',$videoid);} + function DeActivateVideo($videoid){global $cbvid;return $cbvid->action('deactivate',$videoid);} + + + /** + * Function used to get video details + * from video table + * @param INPUT vid or videokey + */ + function get_video_details($vid){global $cbvid;return $cbvid->get_video($vid);} + function GetVideoDetails($video){return $this->get_video_details($video);} + function GetVideDetails($video){return $this->get_video_details($video);} + + + //Function Used To Update Videos Views + function UpdateVideoViews($vkey){increment_views($vkey,'video');} + + /** + * Function used to check weather username exists not + */ + function check_user($username){ + global $userquery; + return $userquery->username_exists($username); + } + + /** + * Function used to check weather email exists not + */ + function check_email($email){ + global $userquery; + return $userquery->email_exists($email); + } + + /** + * Function used to delete comments + * @param CID + */ + function delete_comment($cid,$type='v',$is_reply=FALSE,$forceDelete=false) + { + global $db,$userquery,$LANG; + //first get comment details + + $cdetails = $this->get_comment($cid); + $uid = user_id(); + + if(($uid == $cdetails['userid'] && $cdetails['userid']!='') + || $cdetails['type_owner_id'] == userid() + || has_access("admin_del_access",false) + || $is_reply==TRUE || $forceDelete) + { + $replies = $this->get_comments($cdetails['type_id'],$type,FALSE,$cid,TRUE); + if(count($replies)>0 && is_array($replies)) + { + foreach($replies as $reply) + { + $this->delete_comment($reply['comment_id'],$type,TRUE,$forceDelete); + } + } + $db->Execute("DELETE FROM ".tbl("comments")." WHERE comment_id='$cid'"); + + /*if($uid) + $myquery->update_comments_by_user($uid);*/ + + e(lang('usr_cmt_del_msg'),"m"); + return $cdetails['type_id']; + }else{ + e(lang('no_comment_del_perm')); + return false; + } + return false; + } + function DeleteComment($id,$videoid){return $this->delete_comment($videoid);} + + /** + * Function used to set comment as spam + */ + function spam_comment($cid) + { + global $db; + $comment = $this->get_comment($cid); + $uid = user_id(); + if($comment) + { + $voters = $comment['spam_voters']; + + $niddle = "|"; + $niddle .= userid(); + $niddle .= "|"; + $flag = strstr($voters, $niddle); + + if(!$comment) + e(lang('no_comment_exists')); + elseif(!userid()) + e(lang('login_to_mark_as_spam')); + elseif( userid()==$comment['userid'] || (!userid() && $_SERVER['REMOTE_ADDR'] == $comment['comment_ip'])) + e(lang('no_own_commen_spam')); + elseif(!empty($flag)) + e(lang('already_spammed_comment')); + else + { + if(empty($voters)) + $voters .= "|"; + + $voters .= userid(); + $voters.= "|"; + + $newscore = $comment['spam_votes']+1; + $db->update(tbl('comments'),array('spam_votes','spam_voters'),array($newscore,$voters)," comment_id='$cid'"); + e(lang('spam_comment_ok'),"m"); + return $newscore; + } + + } + e(lang('no_comment_exists')); + return false; + } + + /** + * Function used to set comment as spam + */ + function remove_spam($cid) { + global $db; + $comment = $this->get_comment($cid); + $vote = '0'; + $none = ''; + + if($comment) { + $votes = $comment['spam_votes']; + if(!$votes) { + e(lang('Comment is not a spam')); + } elseif(!userid()) { + e(lang('login_to_mark_as_spam')); + } else { + $db->update(tbl('comments'),array('spam_votes','spam_voters'),array($vote,$none)," comment_id='$cid'"); + e(lang('Spam removed from comment.'),"m"); + } + } else { + e(lang('no_comment_exists')); + } + } + + + /** + * Function used to delete all comments of particlar object + */ + function delete_comments($objid,$type='v',$forceDelete=false) + { + global $db,$userquery,$LANG; + + $uid = user_id(); + + if($userquery->permission['admin_del_access'] == 'yes' || $forceDelete) + { + $db->Execute("DELETE FROM ".tbl("comments")." WHERE type_id='$objid' AND type='$type' "); + + e(lang('usr_cmt_del_msg'),'m'); + return true; + }else{ + e(lang('no_comment_del_perm')); + return false; + } + return false; + } + + /*** + * Function used to rate comment + ***/ + function rate_comment($rate,$cid) + { + global $db; + $comment = $this->get_comment($cid); + $voters = $comment['voters']; + + $niddle = "|"; + $niddle .= userid(); + $niddle .= "|"; + $flag = strstr($voters, $niddle); + + if(!$comment) + e(lang('no_comment_exists')); + elseif(!userid()) + e(lang('class_comment_err6')); + elseif(userid()==$comment['userid'] || (!userid() && $_SERVER['REMOTE_ADDR'] == $comment['comment_ip'])) + e(lang('no_own_commen_rate')); + elseif(!empty($flag)) + e(lang('class_comment_err7')); + else + { + if(empty($voters)) + $voters .= "|"; + + $voters .= userid(); + $voters.= "|"; + + $newscore = $comment['vote']+$rate; + $db->update(tbl('comments'),array('vote','voters'),array($newscore,$voters)," comment_id='$cid'"); + + e(lang('thanks_rating_comment'),"m"); + return $newscore; + } + + return false; + } + + + //Function Used To Varify Syntax + function isValidSyntax($syntax){ + global $LANG; + $pattern = "^^[_a-z0-9-]+$"; + if (eregi($pattern, $syntax)){ + return true; + }else { + return false; + } + } + + + /** + * FUNCTION USED TO GET VIDEOS FROM DATABASE + * @param: array of query parameters array() + * featured => '' (yes,no) + * username => '' (TEXT) + * title => '' (TEXT) + * tags => '' (TEXT) + * category => '' (INT) + * limit => '' (OFFSET,LIMIT) + * order=>'' (BY SORT) -- (date_added DESC) + * extra_param=>'' ANYTHING FOR MYSQL QUERY + * @param: boolean + * @param: results type (results,query) + */ + + function getVideoList($param=array(),$global_cond=true,$result='results') + { + global $db; + + $sql = "SELECT * FROM video"; + + //Global Condition For Videos + if($global_cond==true) + $cond = "broadcast='public' AND active='yes' AND status='Successful'"; + //Checking Condition + if(!empty($param['featured'])) + { + $param['featured'] = 'yes' ? 'yes' : 'no'; + $cond .=" AND featured= '".$param['featured']."' "; + } + if(!empty($param['username'])) + { + $username = mysql_clean($param['username']); + $cond .=" AND featured= '".$username."' "; + } + if(!empty($param['category'])) + { + $category = intval($param['category']); + $cond .=" AND (category01= '".$category."' OR category02= '".$category."' OR category03= '".$category."') "; + } + if(!empty($param['tags'])) + { + $tags = mysql_clean($param['tags']); + $cond .=" AND tags LIKE '%".$tags."%' "; + } + if(!empty($param['title'])) + { + $tags = mysql_clean($param['tags']); + $cond .=" AND title LIKE '%".$param['title']."%' "; + } + + //Adding Condition in Query + if(!empty($cond)) + $sql .= " WHERE $cond "; + + //SORTING VIDEOS + if(!empty($param['order'])) + $sort = 'ORDER BY '.$param['order']; + + //Adding Sorting In Query + $sql .= $sort; + + //LIMITING VIDEO LIST + if(empty($param['limit'])) + $limit = " LIMIT ". VLISTPP; + elseif($param['limit']=='nolimit') + $limit = ''; + else + $limit = " LIMIT ".$param['limit']; + + $sql .= $limit; + //Final Executing of Query and Returning Results + if($result=='results') + return $db->Execute($sql); + else + return $sql; + } + + + /** + * Function used to send subsribtion message + */ + function send_subscription($subscriber,$from,$video) + { + global $LANG; + //First checking weather $subscriber exists or not + $array = array('%subscriber%','%user%','%website_title%'); + $replace = array($subscriber,$from,TITLE); + + $to = $subscriber; + $subj = str_replace($array,$replace,lang('user_subscribe_subject')); + + //Get Subscription Message Template + $msg = get_subscription_template(); + $msg = str_replace($array,$replace,$msg); + $this->SendMessage($to,$from,$subj,$msg,$video,0,0); + } + + + /** + * Function used to add comment + * This is more advance function , + * in this function functions can be applied on comments + */ + function add_comment($comment,$obj_id,$reply_to=NULL,$type='v',$obj_owner=NULL,$obj_link=NULL,$force_name_email=false) + { + global $userquery,$eh,$db,$Cbucket; + //Checking maximum comments characters allowed + if(defined("MAX_COMMENT_CHR")) + { + if(strlen($comment) > MAX_COMMENT_CHR) + e(sprintf("'%d' characters allowed for comment",MAX_COMMENT_CHR)); + } + if(!verify_captcha()) + e(lang('usr_ccode_err')); + if(empty($comment)) + e(lang("pelase_enter_something_for_comment")); + + $params = array('comment'=>$comment,'obj_id'=>$obj_id,'reply_to'=>$reply_to,'type'=>$type); + $this->validate_comment_functions($params); + /* + if($type=='video' || $type=='v') + { + if(!$this->video_exists($obj_id)) + e(lang("class_vdo_del_err")); + + //Checking owner of video + if(!USER_COMMENT_OWN) + { + if(userid()==$this->get_vid_owner($obj_id)); + e(lang("usr_cmt_err2")); + } + } + */ + + if(!userid() && $Cbucket->configs['anonym_comments']!='yes') + e(lang("you_not_logged_in")); + + if((!userid() && $Cbucket->configs['anonym_comments']=='yes') || $force_name_email) + { + //Checking for input name and email + if(empty($_POST['name'])) + e(lang("please_enter_your_name")); + if(empty($_POST['email'])) + e(lang("please_enter_your_email")); + + $name = mysql_clean($_POST['name']); + $email = mysql_clean($_POST['email']); + } + + if(empty($eh->error_list)) + { + $db->insert(tbl("comments"),array + ('type,comment,type_id,userid,date_added,parent_id,anonym_name,anonym_email','comment_ip','type_owner_id'), + array + ($type,$comment,$obj_id,userid(),NOW(),$reply_to,$name,$email,$_SERVER['REMOTE_ADDR'],$obj_owner)); + + $db->update(tbl("users"),array("total_comments"),array("|f|total_comments+1")," userid='".userid()."'"); + + e(lang("grp_comment_msg"),"m"); + + $cid = $db->insert_id(); + $own_details = $userquery->get_user_field_only($obj_owner,'email'); + + + $username = username(); + $username = $username ? $username : post('name'); + $useremail = $email; + + //Adding Comment Log + $log_array = array + ( + 'success'=>'yes', + 'action_obj_id' => $cid, + 'action_done_id' => $obj_id, + 'details'=> "made a comment", + 'username'=>$username, + 'useremail'=>$useremail, + ); + insert_log($type.'_comment',$log_array); + + //sending email + if(SEND_COMMENT_NOTIFICATION=='yes' && $own_details ) + { + + global $cbemail; + + $tpl = $cbemail->get_template('user_comment_email'); + + $more_var = array + ('{username}' => $username, + '{obj_link}' => $obj_link.'#comment_'.$cid, + '{comment}' => $comment, + '{obj}' => get_obj_type($type) + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$own_details,'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + } + + + return $cid; + } + + return false; + } + + + + /** + * Function used to get file details from database + */ + function file_details($file_name) + { + global $db; + return get_file_details($file_name); + /*$results = $db->select("video_files","*"," src_name='$file_name'"); + if($db->num_rows==0) + return false; + else + { + return $results[0]; + }*/ + } + + + + /** + * Function used to update video and set a thumb as default + * @param VID + * @param THUMB NUM + */ + function set_default_thumb($vid,$thumb) + { + global $cbvid; + return $cbvid->set_default_thumb($vid,$thumb); + } + + + + + /** + * Function used to update video + */ + function update_video() + { + global $cbvid; + return $cbvid->update_video(); + } + + + + /** + * Function used to get categorie details + */ + function get_category($id) + { + global $db; + $results = $db->select(tbl("category"),"*"," categoryid='$id'"); + return $results[0]; + } + + + /** + * Function used to get comment from its ID + * @param ID + */ + function get_comment($id) + { + global $db,$userquery; + $result = $db->select(tbl("comments"),"*"," comment_id='$id'"); + if($db->num_rows>0) + { + $result = $result[0]; + if($result['userid']) + $udetails = $userquery->get_user_details($result['userid']); + if($udetails) + $result = array_merge($result,$udetails); + return $result ; + }else{ + return false; + } + } + + /** + * Function used to get from database + * @param TYPE_ID + * @param TYPE + * @param COUNT_ONLY Boolean + * @param PARENT_ID + * @param GET_REPLYIES_ONLY Boolean + */ + function get_comments($type_id='*',$type='v',$count_only=FALSE,$get_type='all',$parent_id=NULL,$useCache='yes') + { + + $params = array( + 'type_id' => $type_id, + 'type' => $type, + 'count_only' => $count_only, + 'get_type' => $get_type, + 'parent_id' => $parent_id, + 'cache' => $useCache + ); + + return $this->getComments($params); + } + + /** + * Function used to get using ARRAY as paramter + */ + function getComments($params) + { + global $db,$userquery; + $cond = ''; + + if(!$params['cache']) + $params['cache'] = 'yes'; + + $p = $params; + extract( $p, EXTR_SKIP ); + + + switch($type) + { + case "video": + case "videos": + case "v": + case "vdo": + { + $type = 'v'; + } + break; + + case "photo": + case "p": + case "photos": + { + $type='p'; + } + break; + + case "topic": + case "t": + case "topics": + { + $type='t'; + } + break; + + case "channel": + case "c": + case "channels": + { + $type='c'; + } + break; + + case "cl": + case "collect": + case "collection": + case "collections": + { + $type='cl'; + } + break; + + } + + if(!$count_only && $params['cache']=='yes') + { + $file = $type.$type_id.str_replace(',','_',$limit).'-'.strtotime($last_update).'.tmp'; + + $files = glob(COMM_CACHE_DIR.'/'.$type.$type_id.str_replace(',','_',$limit).'*'); + + $theFile = getName($files[0]); + $theFileDetails = explode('-',$theFile); + $timeDiff = time() - $theFileDetails[1]; + + if(file_exists(COMM_CACHE_DIR.'/'.$file) && $timeDiff < COMM_CACHE_TIME) + return json_decode(file_get_contents(COMM_CACHE_DIR.'/'.$file),true); + } + + if(!$order) + $order = ' date_added DESC '; + #Checking if user wants to get replies of comment + if($parent_id!=NULL && $get_reply_only) + { + $cond .= " AND parent_id='$parent_id'"; + } + + if($type_id!='*') + $typeid_query = "AND type_id='$type_id' "; + + if(!$count_only) + { + /** + * we have to get comments in such way that + * comment replies comes along with their parents + * in order to achieve this, we have to create a complex logic + * lets see if we can get some tips from WP commenting system ;) + * HAIL Open Source + */ + + $results = $db->select(tbl("comments"),'*' + ," type='$type' $typeid_query $cond",$limit,$order); + + if(!$results) + return false; + $parent_cond = ''; + + $parents_array = array(); + if($results) + foreach($results as $result) + { + if($result['parent_id'] && !in_array($result['parent_id'],$parents_array)) + { + if($parent_cond) + $parent_cond .= " OR "; + $parent_cond .= " comment_id='".$result['parent_id']."' " ; + + $parents_array[] = $result['parent_id']; + } + } + + //Getting Parents + $parents = $db->select(tbl("comments"),'*' + ," type='$type' AND ($parent_cond) ",NULL,$order); + + if($parents) + foreach($parents as $parent) + $new_parents[$parent['comment_id']] = $parent; + + + //Inserting user data + $new_results = array(); + foreach($results as $com) + { + $userid = $com['userid']; + + $uservar = 'user_'.$userid; + + if($userid && !$$uservar) + $$uservar = $userquery->get_user_details($userid); + + if($$uservar) + $com = array_merge($com,$$uservar); + + $new_results[] = $com; + } + + $comment['comments'] = $new_results; + $comment['parents'] = $new_parents; + + //Deleting any other previuos comment file + $files = glob(COMM_CACHE_DIR.'/'.$type.$type_id.str_replace(',','_',$limit).'*'); + + if($files) + foreach($files as $delFile) + if(file_exists($delFile)) + unlink($delFile); + + //Caching comment file + if($file) + file_put_contents(COMM_CACHE_DIR.'/'.$file,json_encode($comment)); + return $comment; + + }else + { + return $db->count(tbl("comments"),"*"," type='$type' $typeid_query $cond"); + } + } + + + /** + * Function used to get from database + * with nested replies + */ + /*function get_comments($obj_id,$type='v',$parent_only=TRUE,$count_only=FALSE) + { + global $db; + $cond = ''; + $user_flds = tbl("users.userid").",".tbl("users.username").",".tbl("users.email").",".tbl("users.avatar").",".tbl("users.avatar_url"); + if($obj_id != "all") + $cond = " type_id = '$obj_id'"; + else + $cond = " "; + + if(!empty($cond)) + $cond .= " AND "; + + if($parent_only && is_numeric($parent_only)) + { + $parent_id = $parent_only; + $cond .= " parent_id='$parent_id'"; + } else { + $cond .= " parent_id = '0'"; + } + + if(!$count_only) + { + $result = $db->select(tbl("comments,users"),tbl("comments").".*, $user_flds"," $cond AND type='$type' AND ".tbl("comments.userid")." = ".tbl("users.userid").""); + //echo $db->db_query; + $ayn_result = $db->select(tbl("comments,users"),tbl("comments").".*, $user_flds"," $cond AND type='$type' AND ".tbl("comments.userid")." = '0'"); + if($result && $ayn_result) + $result = array_merge($result,$ayn_result); + elseif(!$result && $ayn_result) + $result = $ayn_result; + + $arr = array(); + foreach($result as $comment) + { + $arr[$comment['comment_id']] = $comment; + $replies = $this->get_replies($comment['comment_id'],$type); + if($replies) + { + $arr[$comment['comment_id']][] = $replies; + } + } + + return $arr; + } + }*/ + + function get_replies($p_id,$type='v') + { + global $db; + $result = $db->select(tbl("comments,users"),"*"," type='$type' AND parent_id = '$p_id' AND ".tbl("comments.userid")." = ".tbl("users.userid").""); + $ayn_result = $db->select(tbl("comments,users"),"*"," type='$type' AND parent_id = '$p_id' AND ".tbl("comments.userid")." = '0'"); + + if($result && $ayn_result) + $result = array_merge($result,$ayn_result); + elseif(!$result && $ayn_result) + $result = $ayn_result; + + return $result; + } + + /** + * Function used to get video owner + */ + function get_vid_owner($vid) + { + global $db; + $results = $db->select(tbl("video"),"userid"," videoid='$vid'"); + return $results[0]; + } + + /** + * Function used to set website template + */ + function set_template($template) + { + global $myquery; + if(is_dir(STYLES_DIR.'/'.$template) && $template) + { + $myquery->Set_Website_Details('template_dir',$template); + e(lang("template_activated"),'m'); + }else + e(lang("error_occured_changing_template")); + + } + + + /** + * Function used to update comment + */ + function update_comment($cid,$text) + { + global $db; + $db->Execute("UPDATE ".tbl("comments")." SET comment='$text' WHERE comment_id='$cid'"); + //$db->update(tbl("comments"),array("comment"),array($text)," comment_id = $cid"); + } + + + /** + * Function used to validate comments + */ + function validate_comment_functions($params) + { + $type = $params['type']; + $obj_id = $params['obj_id']; + $comment = $params['comment']; + $reply_to = $params['reply_to']; + + if($type=='video' || $type=='v') + { + if(!$this->video_exists($obj_id)) + e(lang("class_vdo_del_err")); + + //Checking owner of video + //if(!USER_COMMENT_OWN) + //{ + // if(userid()==$this->get_vid_owner($obj_id)); + /// e(lang("usr_cmt_err2")); + //} + } + + $func_array = get_functions('validate_comment_functions'); + if(is_array($func_array)) + { + foreach($func_array as $func) + { + if(function_exists($func)) + { + return $func($params); + } + } + } + + } + + + /** + * Function used to insert note in data base for admin referance + */ + function insert_note($note) + { + global $db; + $db->insert(tbl('admin_notes'),array('note,date_added,userid'),array($note,now(),userid())); + } + /** + * Function used to get notes + */ + function get_notes() + { + global $db; + return $db->select(tbl('admin_notes'),'*'," userid='".userid()."'",NULL," date_added DESC "); + } + /** + * Function usde to delete note + */ + function delete_note($id) + { + global $db; + $db->delete(tbl("admin_notes"),array("note_id"),array($id)); + } + + + /** + * Function used to check weather object is commentable or not + */ + function is_commentable($obj,$type) + { + switch($type) + { + case "video": + case "v": + case "vdo": + case "videos": + case "vid": + { + if($obj['allow_comments'] == 'yes' && config('video_comments')==1) + return true; + } + break; + + case "channel": + case "user": + case "users": + case "u": + case "c": + { + if($obj['allow_comments'] == 'Yes' && config('channel_comments')==1) + return true; + } + break; + + case "collection": + case "collect": + case "cl": + { + if($obj['allow_comments'] == 'yes') + return true; + } + break; + + case "photo": + case "p": + case "photos": + { + if($obj['allow_comments'] == 'yes' && config('photo_comments') == 1) + return true; + } + } + return false; + } + + /** + * Function used to get list of items in conversion queue + * @params $Cond, $limit,$order + */ + function get_conversion_queue($cond=NULL,$limit=NULL,$order='date_added DESC') + { + global $db; + $result = $db->select(tbl("conversion_queue"),"*",$cond,$limit,$oder); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * function used to remove queue + */ + function queue_action($action,$id) + { + global $db; + switch($action) + { + case "delete": + $db->execute("DELETE from ".tbl('conversion_queue')." WHERE cqueue_id ='$id' "); + break; + case "processed": + $db->update(tbl('conversion_queue'),array('cqueue_conversion'),array('yes')," cqueue_id ='$id' "); + break; + case "pending": + $db->update(tbl('conversion_queue'),array('cqueue_conversion'),array('no')," cqueue_id ='$id' "); + break; + } + } + + + +} +?> \ No newline at end of file diff --git a/upload/includes/classes/objects.class.php b/upload/includes/classes/objects.class.php new file mode 100644 index 00000000..697d6338 --- /dev/null +++ b/upload/includes/classes/objects.class.php @@ -0,0 +1,66 @@ +\n"; + foreach($templates as $template) + { + if($template['name']!='') + $dd .= "\n"; + } + $dd .="\n"; + + return $dd; + } + + /** + * This will display language selector for front UI + */ + function display_languages($id='lang_selector',$class='lang_selector',$onchange='') + { + global $lang_obj; + $langs = $lang_obj->get_langs('yes'); + + if($class) + $class_attr = ' class="'.$class.'" '; + + if($onchange) + $onchange_attr = ' onChange="'.$onchange.'" '; + + $obj = "\n"; + return $obj; + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/pages.class.php b/upload/includes/classes/pages.class.php new file mode 100644 index 00000000..94830482 --- /dev/null +++ b/upload/includes/classes/pages.class.php @@ -0,0 +1,386 @@ +GetServerUrl(); + $scriptPath = NULL; + + + if ( isset($_SERVER['SCRIPT_NAME']) ) { + $scriptPath = $_SERVER['SCRIPT_NAME']; + $scriptPath = ( $scriptPath == '/' ) ? '' : dirname($scriptPath); + } + + $base = basename(dirname($_SERVER['SCRIPT_NAME'])); + + + $sus_dirs = array('admin_area','includes','plugins','files','actions','cb_install'); + + + $remove_arr = array(); + $remove_arr[] = '/:\/\/www\./'; + + if($more) + $remove_arr[] = $more; + if(in_array($base,$sus_dirs)) + $remove_arr[] = '/\/'.$base.'/'; + + //Clearing Plugin and Player baseurl + if(strstr($scriptPath,'/plugins/')) + $scriptPath = preg_replace('/(.*)\/plugins(.*)/i',"$1",$scriptPath); + if(strstr($scriptPath,'/player/')) + $scriptPath = preg_replace('/(.*)\/plugins(.*)/i',"$1",$scriptPath); + + $baseURL = $serverURL . $scriptPath; + + $baseURL = preg_replace($remove_arr,'',$baseURL); + + if(substr($baseURL,strlen($baseURL)-1,1)=='/') + $baseURL = substr($baseURL,0,strlen($baseURL)-1); + + return $baseURL; + } + + function GetCurrentUrl() + { + global $in_bg_cron; + if(!$in_bg_cron) + { + $serverURL = $this->GetServerUrl(); + $requestURL = $_SERVER['REQUEST_URI']; + + return $serverURL . $requestURL; + } + } + + //This Function Set The PageDirect + function page_redir(){ + setcookie("pageredir",clean($this->GetCurrentUrl()),time()+7200,'/'); + Assign('pageredir',@$_COOKIE['pageredir']); + } + + //This Funtion is use to Show Admin Panels Pages + + function show_admin_page($page){ + $pages = array( + 'main' => 'main.php', + 'server_check' => 'verifier.php', + 'members_showall' => 'members.php?view=showall', + 'members_inactive' => 'members.php?view=inactive', + 'members_active' => 'members.php?view=active', + 'members_addmember' => 'members.php?view=addmember', + 'members_search' => 'members.php?view=search' + ); + return @$pages[$page]; + } + + + //Redirects page to without www. + function redirectOrig() + { + $curpage = $this->GetCurrentUrl(); + $newPage = preg_replace('/:\/\/www\./','://',$curpage); + if($curpage !=$newPage) + header("location:$newPage"); + } + + function create_url($params_array,$url=NULL,$remove_param=false,$urlencode=false) + { + if($url==NULL or $url == 'auto') + { + if($_SERVER['QUERY_STRING']) + $url = '?'.$_SERVER['QUERY_STRING']; + } + + $new_link = ''; + $new_link .= $url; + if(is_array($params_array)) + { + foreach($params_array as $name => $value) + { + if($url) + $new_link .='&'.$name.'='.$value; + else + $new_link .='?'.$name.'='.$value; + } + } + + return $new_link; + } + + //This Fucntion is used to Redirect to respective URL + + function redirect($url){ + echo ''; + } + + /** + * Function used to create link + */ + function create_link($page,$link=NULL,$extra_params=NULL,$tag=' #page# ',$return_param=false) + { + if($link==NULL or $link == 'auto') + { + if($_SERVER['QUERY_STRING']) + $link = '?'.$_SERVER['QUERY_STRING']; + } + + + $page_pattern = '#page#'; + $param_pattern = '#params#'; + $page_url_param = $this->url_page_var; + $page_link_pattern = $page_url_param.'='.$page_pattern; + $link = preg_replace(array('/(\?page=[0-9]+)/','/(&page=[0-9]+)/','/(page=[0-9+])+/'),'',$link); + + preg_match('/\?/',$link,$matches); + + $no_seo = false; + if(!empty($matches[0])) + { + $no_seo = true; + $page_link = '&'.$page_link_pattern; + }else{ + $page_link = '?'.$page_link_pattern; + } + + //Now checking if url is using & and ? then do not apply PAGE using slash instead use & or ? + $current_url = $_SERVER['REQUEST_URI']; + preg_match('/\?/',$current_url,$cur_matches); + if(count($cur_matches)) + $has_q = true; + preg_match('/\.php/',$current_url,$cur_matches); + if(count($cur_matches)) + $has_php = true; + preg_match('/&/',$current_url,$cur_matches); + if(count($cur_matches)) + $has_amp = true; + + $link = $link.$page_link; + $params = 'href="'.$link.'"'; + $params .= ' '.$extra_params; + + if($has_php && ($has_amp || $has_q)) + $use_seo = false; + else + $use_seo = true; + + if(SEO=='yes' && THIS_PAGE !='search_result' && !BACK_END && $use_seo) + { + if(count($_GET)==0 || (count($_GET)==3 && isset($_GET['page']))) + $params = $params; + else + $params ='href="./'.$page.'"'; + } + + + $final_link = preg_replace(array("/$page_pattern/i","/$param_pattern/i"),array($page,$params),$tag); + $final_link = preg_replace(array("/$page_pattern/i","/$param_pattern/i"),array($page,$params),$final_link); + + if($return_param) + { + return preg_replace("/$page_pattern/i",$page,$params); + } + + return ' '.$final_link.' '; + } + + /** + * Function used to create pagination + * @param : total number of pags + * @param : current page + * @param : extra paraments in the tag ie #page#') + { + + if($total==0) + return false; + if($page<=0||$page==''||!is_numeric($page)) + $page = 1; + $total_pages = $total; + $pagination_start = 14; + $display_page = 7; + $this->selected = $selected = $page; + $hellip = '…'; + $first_hellip = ''; + $second_hellip = ''; + + $start = ''; + $mid = ''; + $end = ''; + + $start_last = ''; + $end_first = ''; + + $mid_first = ''; + $mid_last = ''; + + $differ = round(($display_page/2)+.49,0)-1; + + if($pagination_start < $total_pages) + { + + //Starting First + for($i=1;$i<=$display_page;$i++) + { + if($selected == $i) + { + $start .= ' '.$i.' '; + }else + $start .= $this->create_link($i,$link,$extra_params,$tag); + $start_last = $i; + } + + + //Starring Last + for($i=$total_pages-$display_page;$i<=$total_pages;$i++) + { + if($end_first=='') + $end_first = $i; + + if($selected == $i) + { + $end .= ' '.$i.' '; + }else + $end .= $this->create_link($i,$link,$extra_params,$tag); + } + + //Starting mid + for($i=$selected-$differ;$i<=$selected+$differ;$i++) + { + if($mid_first=='') + $mid_first = $i; + + if($i>$start_last && $i<$end_first) + { + if($selected == $i) + { + $mid .= ' '.$i.' '; + }else + $mid .= $this->create_link($i,$link,$extra_params,$tag); + } + + $mid_last = $i; + } + + + if($start_last < $mid_first) + $first_hellip = $hellip; + if($end_first > $mid_last) + $second_hellip = $hellip; + + //Previous Page + if($selected-1 > 1) + $this->pre_link = $this->create_link($selected-1,$link,$extra_params,$tag,true); + //Next Page + if($selected+1 < $total) + $this->next_link = $this->create_link($selected+1,$link,$extra_params,$tag,true); + //First Page + if($selected!=1) + $this->first_link = $this->create_link(1,$link,$extra_params,$tag,true); + //First Page + if($selected!=$total) + $this->last_link = $this->create_link($total,$link,$extra_params,$tag,true); + + return $start.$first_hellip.$mid.$second_hellip.$end; + }else{ + $pagination_smart = ''; + for($i=1;$i<=$total_pages;$i++) + { + if($i == $selected) + $pagination_smart .= ' '.$i.' '; + else + $pagination_smart .=$this->create_link($i,$link,$extra_params,$tag); + } + + //Previous Page + if($selected-1 > 1) + $this->pre_link = $this->create_link($selected-1,$link,$extra_params,$tag,true); + //Next Page + if($selected+1 < $total) + $this->next_link = $this->create_link($selected+1,$link,$extra_params,$tag,true); + //First Page + if($selected!=1) + $this->first_link = $this->create_link(1,$link,$extra_params,$tag,true); + //First Page + if($selected!=$total) + $this->last_link = $this->create_link($total,$link,$extra_params,$tag,true); + + return $pagination_smart; + } + } + + + /** + * Function used to create pagination and assign values that can bee used in template + */ + function paginate($total,$page,$link=NULL,$extra_params=NULL,$tag='#page#') + { + + $this->pagination = $this->pagination($total,$page,$link,$extra_params,$tag); + + //Assigning Variable that can be used in templates + assign('pagination',$this->pagination); + + assign('next_link',$this->next_link); + assign('pre_link',$this->pre_link); + + assign('next_page',$page+1); + assign('pre_page',$page-1); + + assign('first_link',$this->first_link); + assign('last_link',$this->last_link); + } + +} +?> \ No newline at end of file diff --git a/upload/includes/classes/photos.class.php b/upload/includes/classes/photos.class.php new file mode 100644 index 00000000..185bb202 --- /dev/null +++ b/upload/includes/classes/photos.class.php @@ -0,0 +1,2598 @@ +exts = array('jpg','png','gif','jpeg'); // This should be added from Admin Area. may be some people also want to allow BMPs; + $this->embed_types = array("html","forum","email","direct"); + + } + + /** + * Setting up Photos Section + */ + function init_photos() + { + $this->init_actions(); + $this->init_collections(); + $this->photos_admin_menu(); + $this->setting_other_things(); + $this->set_photo_max_size(); + } + + /** + * Initiating Actions for Photos + */ + function init_actions() + { + $this->action = new cbactions(); + $this->action->init(); // Setting up reporting excuses + $this->action->type = 'p'; + $this->action->name = 'photo'; + $this->action->obj_class = 'cbphoto'; + $this->action->check_func = 'photo_exists'; + $this->action->type_tbl = "photos"; + $this->action->type_id_field = 'photo_id'; + + + } + + /** + * Setting Email Settings + */ + function set_share_email($data) + { + $this->share_email_vars = array( + '{photo_title}' => $data['photo_title'], + '{photo_description}' => $data['photo_description'], + '{photo_link}' => $this->collection->collection_links($data,'view_item'), + '{photo_thumb}' => $this->get_image_file($data['photo_id'],'m') + ); + $this->action->share_template_name = 'photo_share_template'; + $this->action->val_array = $this->share_email_vars; + } + + + + /** + * Initiating Collections for Photos + */ + function init_collections() + { + $this->collection = new Collections; + $this->collection->objType = "p"; + $this->collection->objClass = "cbphoto"; + $this->collection->objTable = "photos"; + $this->collection->objName = "Photo"; + $this->collection->objFunction = "photo_exists"; + $this->collection->objFieldID = "photo_id"; + $this->photo_register_function('delete_collection_photos'); + } + + /** + * Create Admin Area menu for photos + */ + function photos_admin_menu() + { + global $Cbucket,$cbcollection,$userquery; + $am = $Cbucket->AdminMenu; + $per = $userquery->get_user_level(userid()); + + + if($per['photos_moderation'] == "yes") + $am['Photos'] = array( + 'Photo Manager' => 'photo_manager.php', + 'Flagged Photos' => 'flagged_photos.php', + 'Orphan Photos' => 'orphan_photos.php', + 'Photo Settings' => 'photo_settings.php', + 'Watermark Settings' => 'photo_settings.php?mode=watermark_settings', + 'Recreate Thumbs' => 'recreate_thumbs.php?mode=mass' + ); + $Cbucket->AdminMenu = $am; + } + + + /** + * Setting other things + */ + function setting_other_things() + { + global $userquery,$Cbucket; + // Search type + if(isSectionEnabled('photos')) + $Cbucket->search_types['photos'] = "cbphoto"; + + // My account links + $accountLinks = array(); + $accountLinks = array( + lang('manage_photos') => "manage_photos.php", + lang('manage_favorite_photos') => "manage_photos.php?mode=favorite", + lang('manage_my_album') => "manage_photos.php?mode=my_album", + ); + if(isSectionEnabled('photos')) + $userquery->user_account[lang('Photos')] = $accountLinks; + + //Setting Cbucket links + + $Cbucket->links['photos'] = array('photos.php','photos/'); + $Cbucket->links['manage_photos'] = array('manage_photos.php','manage_photos.php'); + $Cbucket->links['edit_photo'] = array('edit_photo.php?photo=','edit_photo.php?photo='); + $Cbucket->links['photo_upload'] = array('photo_upload.php','photo_upload'); + $Cbucket->links['manage_favorite_photos'] = array('manage_photos.php?mode=favorite','manage_photos.php?mode=favorite'); + $Cbucket->links['manage_orphan_photos'] = array('manage_photos.php?mode=orphan','manage_photos.php?mode=orphan'); + $Cbucket->links['user_photos'] = array('user_photos.php?mode=uploaded&user=','user_photos.php?mode=uploaded&user='); + $Cbucket->links['user_fav_photos'] = array('user_photos.php?mode=favorite&user=','user_photos.php?mode=favorite&user='); + + // Setting Home Tab + + } + + /** + * Initiatting Search + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "photos"; + $this->search->use_match_method = TRUE; + + $this->search->columns = array( + array("field"=>"photo_title","type"=>"LIKE","var"=>"%{KEY}%"), + array("field"=>"photo_tags","type"=>"LIKE","var"=>"%{KEY}%","op"=>"OR") + ); + $this->search->match_fields = array("photo_title","photo_tags"); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/photo.html'; + $this->search->template_var = 'photo'; + $this->search->has_user_id = true; + $this->search->results_per_page = config('photo_search_result'); + $this->search->search_type['photos'] = array('title'=>lang('photos')); + $this->search->add_cond(tbl('photos.collection_id')." <> 0"); + + $sorting = array( + 'date_added'=> lang("date_added"), + 'views' => lang("views"), + 'total_comments' => lang("comments"), + 'rating' => lang("rating"), + 'total_favorites' => lang("favorites") + ); + + $this->search->sorting = array( + 'date_added'=> " date_added DESC", + 'views' => " views DESC", + 'rating' => " rating DESC, rated_by DESC", + 'total_comments' => " total_comments DESC ", + 'total_favorites' => " total_favorites DESC" + ); + + $array = $_GET; + $uploaded = $array['datemargin']; + $sort = $array['sort']; + + $forms = array( + 'query' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'query', + 'id'=> 'query', + 'value'=>cleanForm($array['query']) + ), + 'date_margin' => array( + 'title' => lang('uploaded'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['photos']['fields'] = $forms; + } + /** + * Set File Max Size + */ + function set_photo_max_size() + { + global $Cbucket; + $adminSize = $Cbucket->configs['max_photo_size']; + if(!$adminSize) + $this->max_file_size = 2*1024*1024; + else + $this->max_file_size = $adminSize*1024*1024; + } + + /** + * Check if photo exists or not + */ + function photo_exists($id) + { + global $db; + if(is_numeric($id)) + $result = $db->select(tbl($this->p_tbl),"photo_id"," photo_id = '$id'"); + else + $result = $db->select(tbl($this->p_tbl),"photo_id"," photo_key = '$id'"); + + if($result) + return true; + else + return false; + } + + /** + * Register function + */ + function photo_register_function($func) + { + global $cbcollection; + $cbcollection->collection_delete_functions[] = 'delete_collection_photos'; + } + + /** + * Get Photo + */ + function get_photo($pid) + { + global $db; + if(is_numeric($pid)) + $result = $db->select(tbl($this->p_tbl),"*"," photo_id = '$pid'"); + else + $result = $db->select(tbl($this->p_tbl),"*"," photo_key = '$pid'"); + + if($db->num_rows > 0) + return $result[0]; + else + return false; + } + + /** + * Get Photos + */ + function get_photos($p) + { + global $db; + $tables = "photos,users"; + + $order = $p['order']; + $limit = $p['limit']; + $cond = ""; + + if(!has_access('admin_access',TRUE)) + { + $cond = " ".tbl('photos.broadcast')." = 'public' AND ".tbl('photos.active')." = 'yes'"; + } else { + if($p['active']) + $cond .= " ".tbl('photos.active')." = '".$p['active']."'"; + + if($p['broadcast']) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.broadcast')." = '".$p['broadcast']."'"; + } + } + + if($p['pid']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['pid'],"sign"=>"=","operator"=>"OR")); + } + + if($p['key']) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.photo_key')." = '".$p['key']."'"; + } + + if($p['filename']) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.filename')." = '".$p['filename']."'"; + } + + if($p['extension']) + { + foreach($this->exts as $ext) + { + if(in_array($ext,$this->exts)) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.ext')." = '".$p['extension']."'"; + } + } + } + + if($p['date_span']) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".cbsearch::date_margin("date_added",$p['date_span']); + } + + if($p['featured']) + { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.featured')." = '".$p['featured']."'"; + } + + if($p['user']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['user'],"sign"=>"=","operator"=>"AND","column"=>"userid")); + } + + if($p['exclude']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['exclude'],"sign"=>"<>")); + } + + $title_tag = ''; + + if($p['title']) + { + $title_tag = " ".tbl('photos.photo_title')." LIKE '%".$p['title']."%'"; + } + + if($p['tags']) + { + $tags = explode(",",$p['tags']); + if(count($tags)>0) + { + if($title_tag != '') + $title_tag .= " OR "; + $total = count($tags); + $loop = 1; + foreach($tags as $tag) + { + $title_tag .= " ".tbl('photos.photo_tags')." LIKE '%$tag%'"; + if($loop<$total) + $title_tag .= " OR "; + $loop++; + } + } else { + if($title_tag != '') + $title_tag .= " OR "; + $title_tag .= " ".tbl('photos.photo_tags')." LIKE '%".$p['tags']."%'"; + } + } + + if($title_tag != "") + { + if($cond != '') + $cond .= " AND "; + $cond .= " ($title_tag) "; + } + + if($p['ex_user']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['ex_user'],"sign"=>"<>","operator"=>"AND","column"=>"userid")); + } + + if($p['extra_cond']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $p['extra_cond']; + } + + if($p['get_orphans']) + $p['collection'] = "\0"; + + if($p['collection']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['collection'],"sign"=>"=","operator"=>"OR","column"=>"collection_id")); + } else { + if($cond != "") + $cond .= " AND "; + $cond .= " ".tbl('photos.collection_id')." <> '0'"; + } + + if(!$p['count_only'] && !$p['show_related']) + { + if($cond != "") + $cond .= " AND "; + $result = $db->select(tbl($tables), + tbl("photos.*,users.userid,users.username"), + $cond.tbl("photos.userid")." = ".tbl("users.userid"),$limit,$order); + //echo $db->db_query; + } + + if($p['show_related']) + { + $cond = "MATCH(".tbl('photos.photo_title,photos.photo_tags').")"; + $cond .= " AGAINST ('".cbsearch::set_the_key($p['title'])."' IN BOOLEAN MODE)"; + if($p['exclude']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['exclude'],"sign"=>"<>")); + } + + if($p['collection']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['collection'],"sign"=>"<>","column"=>"collection_id")); + } + + if($p['extra_cond']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $p['extra_cond']; + } + $result = $db->select(tbl($tables),tbl("photos.*,users.userid,users.username"), + $cond." AND ".tbl('photos.collection_id')." <> '0' AND ".tbl("photos.userid")." = ".tbl("users.userid"),$limit,$order); + //echo $db->db_query; + + // We found nothing from TITLE of Photos, let's try TAGS + if($db->num_rows == 0) + { + $tags = cbsearch::set_the_key($p['tags']); + $tags = str_replace('+','',$tags); + + $cond = "MATCH(".tbl('photos.photo_title,photos.photo_tags').")"; + $cond .= " AGAINST ('".$tags."' IN BOOLEAN MODE)"; + + if($p['exclude']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['exclude'],"sign"=>"<>")); + } + + if($p['collection']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $this->constructMultipleQuery(array("ids"=>$p['collection'],"sign"=>"<>","column"=>"collection_id")); + } + + if($p['extra_cond']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $p['extra_cond']; + } + $result = $db->select(tbl($tables),tbl("photos.*,users.userid,users.username"), + $cond." AND ".tbl('photos.collection_id')." <> '0' AND ".tbl("photos.userid")." = ".tbl("users.userid"),$limit,$order); + //echo $db->db_query; + } + } + + if($p['count_only']) + { + if($p['extra_cond']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $p['extra_cond']; + } + $result = $db->count(tbl("photos"),"photo_id",$cond); + } + + if($p['assign']) + assign($p['assign'],$result); + else + return $result; + } + + /** + * Used to construct Multi Query + * Only IDs will be excepted + */ + function constructMultipleQuery($params) + { + $cond = ""; + $IDs = $params['ids']; + if(is_array($IDs)) + $IDs = $IDs; + else + $IDs = explode(",",$IDs); + + $count = 0; + $cond .= "( "; + foreach($IDs as $id) + { + $id = str_replace(" ","",$id); + if(is_numeric($id) || $params['column'] == 'collection_id') + { + if($count>0) + $cond .= " ".($params['operator']?$params['operator']:'AND')." "; + $cond .= "".tbl('photos.'.($params['column']?$params['column']:'photo_id'))." ".($params['sign']?$params['sign']:'=')." '".$id."'"; + $count++; + } + } + $cond .= " )"; + + return $cond; + } + + /** + * Used to construct Exclude Query + function exclude_query($array) + { + $cond = ''; + if(!is_array($array)) + $ids = explode(',',$array); + else + $ids = $array; + + $count = 0; + + $cond .= "( "; + foreach($ids as $id) + { + $count++; + if($count > 1) + $cond .= " AND "; + $cond .= " ".tbl('photos.photo_id')." <> '".$id."'"; + } + $cond .= " )"; + + return $cond; + }*/ + + /** + * Used to generate photo key + * Replica of video_keygen function + */ + function photo_key() + { + global $db; + + $char_list = "ABDGHKMNORSUXWY"; + $char_list .= "123456789"; + while(1) + { + $photo_key = ''; + srand((double)microtime()*1000000); + for($i = 0; $i < 12; $i++) + { + $photo_key .= substr($char_list,(rand()%(strlen($char_list))), 1); + } + + if(!$this->pkey_exists($photo_key)) + break; + } + + return $photo_key; + } + + /** + * Used to check if key exists + */ + function pkey_exists($key) + { + global $db; + $db->select(tbl("photos"),"photo_key"," photo_key = '$key'"); + if($db->num_rows > 0) + return true; + else + return false; + } + + /** + * Used to delete photo + */ + function delete_photo($id,$oprhan=FALSE) + { + global $db; + if($this->photo_exists($id)) + { + $photo = $this->get_photo($id); + + $del_photo_funcs = cb_get_functions('delete_photo'); + if(is_array($del_photo_funcs)) + { + + foreach($del_photo_funcs as $func) + { + if(function_exists($func['func'])) + { + $func['func']($photo); + } + } + } + + if($orphan == FALSE)//removing from collection + $this->collection->remove_item($photo['photo_id'],$photo['collection_id']); + + //now removing photo files + $this->delete_photo_files($photo); + + //finally removing from Database + $this->delete_from_db($photo); + + //Decrementing User Photos + $db->update(tbl("users"),array("total_photos"),array("|f|total_photos-1")," userid='".$photo['userid']."'"); + + //Removing Photo Comments + $db->delete(tbl("comments"),array("type","type_id"),array("p",$photo['photo_id'])); + + //Removing Photo From Favortes + $db->delete(tbl("favorites"),array("type","id"),array("p",$photo['photo_id'])); + + } else + e(lang("photo_not_exists")); + } + + /** + * Used to delete photo files + */ + function delete_photo_files($id) + { + if(!is_array($id)) + $photo = $this->get_photo($id); + else + $photo = $id; + + $pid = $photo['photo_id']; + $files = $this->get_image_file($pid,'t',TRUE,NULL,FALSE,TRUE); + if(!empty($files)) + { + foreach($files as $file) + { + $file_dir = PHOTOS_DIR."/".$file; + if(file_exists($file_dir)) + unlink($file_dir); + } + + e(sprintf(lang("success_delete_file"),$photo['photo_title']),"m"); + } + } + + /** + * Used to delete photo from database + */ + function delete_from_db($id) + { + global $db; + if(is_array($id)) + $delete_id = $id['photo_id']; + else + $delete_id = $id; + + $db->execute("DELETE FROM ".tbl('photos')." WHERE photo_id = $delete_id"); + e(lang("photo_success_deleted"),"m"); + } + + + /** + * Used to get photo owner + */ + function get_photo_owner($id) + { + return $this->get_photo_field($id,'userid'); + } + + /** + * Used to get photo any field + */ + function get_photo_field($id,$field) + { + global $db; + if(!$field) + return false; + else + { + if(!is_numeric($id)) + $result = $db->select(tbl($this->p_tbl),$field,' photo_key = '.$id.''); + else + $result = $db->select(tbl($this->p_tbl),$field,' photo_id = '.$id.''); + + if($result) + return $result[0][$field]; + else + return false; + } + } + + /** + * Used filter array + */ + function remove_empty_indexes($array) + { + $newArr = array(); + if(is_array($array)) + { + foreach($array as $key=>$arr) + { + if(is_array($arr)) + { + foreach($arr as $a) + { + if(!empty($a)) + { + $newArr[$key][] = $a; + } + } + } + } + + return $newArr; + } else { + echo "No Array Provided"; + } + } + + /** + * Used to crop the image + * Image will be crop to dead-center + */ + function crop_image($input,$output,$ext,$width,$height) + { + $info = getimagesize($input); + $Swidth = $info[0]; + $Sheight = $info[1]; + + $canvas = imagecreatetruecolor($width, $height); + $left_padding = $Swidth / 2 - $width / 2; + $top_padding = $Sheight / 2 - $height / 2; + + switch($ext) + { + case "jpeg": + case "jpg": + case "JPG": + case "JPEG": + { + $image = imagecreatefromjpeg($input); + imagecopy($canvas, $image, 0, 0, $left_padding, $top_padding, $width, $height); + imagejpeg($canvas,$output,90); + } + break; + + case "png": + case "PNG": + { + $image = imagecreatefrompng($input); + imagecopy($canvas, $image, 0, 0, $left_padding, $top_padding, $width, $height); + imagepng($canvas,$output,9); + } + break; + + case "gif": + case "GIF": + { + $image = imagecreatefromgif($input); + imagecopy($canvas, $image, 0, 0, $left_padding, $top_padding, $width, $height); + imagejpeg($canvas,$output,90); + } + break; + + default: + { + return false; + } + break; + } + imagedestroy($canvas); + } + + /** + * Used to resize and watermark image + **/ + function generate_photos($array) + { + global $db; + $path = PHOTOS_DIR."/"; + + if(!is_array($array)) + $p = $this->get_photo($array); + else + $p = $array; + + $filename = $p['filename']; + $extension = $p['ext']; + + $this->createThumb($path.$filename.".".$extension,$path.$filename."_o.".$extension,$extension); + $this->createThumb($path.$filename.".".$extension,$path.$filename."_t.".$extension,$extension,$this->thumb_width,$this->thumb_height); + $this->createThumb($path.$filename.".".$extension,$path.$filename."_m.".$extension,$extension,$this->mid_width,$this->mid_height); + $this->createThumb($path.$filename.".".$extension,$path.$filename."_l.".$extension,$extension,$this->lar_width); + + $should_watermark = config('watermark_photo'); + + if(!empty($should_watermark) && $should_watermark == 1) + { + $this->watermark_image($path.$filename."_l.".$extension,$path.$filename."_l.".$extension); + $this->watermark_image($path.$filename."_o.".$extension,$path.$filename."_o.".$extension); + } + + /* GETTING DETAILS OF IMAGES AND STORING THEM IN DB */ + $this->update_image_details($p); + } + + /** + * This function is used to get photo files and extract + * dimensions and file size of each file, put them in array + * then encode in json and finally update photo details column + */ + function update_image_details($photo) + { + global $db, $json; + if(is_array($photo) && !empty($photo['photo_id'])) + $p = $photo; + else + $p = $this->get_photo($photo); + + if(!empty($photo)) + { + $images = $this->get_image_file($p,NULL,TRUE,NULL,FALSE); + if($images) + { + foreach($images as $image) + { + $imageFile = PHOTOS_DIR."/".$image; + if(file_exists($imageFile)) + { + $imageDetails = getimagesize($imageFile); $imageSize = filesize($imageFile); + $data[$this->get_image_type($image)] = array( + "width" => $imageDetails[0], + "height" => $imageDetails[1], + "attribute" => mysql_clean($imageDetails[3]), + "size" => array( + "bytes" => round($imageSize), + "kilobytes" => round($imageSize / 1024), + "megabytes" => round($imageSize / 1024 / 1024, 2) + ) + ); + } + } + + if(is_array($data) && !empty($data)) + { + if(phpversion() < "5.2.0") + $encodedData = stripslashes($json->json_encode($data)); + else + $encodedData = stripslashes(json_encode($data)); + + $db->update(tbl('photos'),array("photo_details"),array("|no_mc|$encodedData")," photo_id = '".$p['photo_id']."' "); + } + } + } + } + + /** + * Creating resized photo + */ + function createThumb($from,$to,$ext,$d_width=NULL,$d_height=NULL,$force_copy=false) + { + $file = $from; + $info = getimagesize($file); + $org_width = $info[0]; + $org_height = $info[1]; + + if($org_width > $d_width && !empty($d_width)) + { + $ratio = $org_width / $d_width; // We will resize it according to Width + + $width = $org_width / $ratio; + $height = $org_height / $ratio; + + $image_r = imagecreatetruecolor($width, $height); + if(!empty($d_height) && $height > $d_height && $this->cropping == 1) + { + $crop_image = TRUE; + } + + switch($ext) + { + case "jpeg": + case "jpg": + case "JPG": + case "JPEG": + { + $image = imagecreatefromjpeg($file); + imagecopyresampled($image_r, $image, 0, 0, 0, 0, $width, $height, $org_width, $org_height); + imagejpeg($image_r, $to, 90); + + if(!empty($crop_image)) + $this->crop_image($to,$to,$ext,$width,$d_height); + } + break; + + case "png": + case "PNG": + { + $image = imagecreatefrompng($file); + imagecopyresampled($image_r, $image, 0, 0, 0, 0, $width, $height, $org_width, $org_height); + imagepng($image_r,$to,9); + if(!empty($crop_image)) + $this->crop_image($to,$to,$ext,$width,$d_height); + } + break; + + case "gif": + case "GIF": + { + $image = imagecreatefromgif($file); + imagecopyresampled($image_r, $image, 0, 0, 0, 0, $width, $height, $org_width, $org_height); + imagegif($image_r,$to,90); + if(!empty($crop_image)) + $this->crop_image($to,$to,$ext,$width,$d_height); + } + break; + } + imagedestroy($image_r); + } else { + if(!file_exists($to) || $force_copy === true) + copy($from,$to); + } + } + + /** + * Used to get watermark file + */ + function watermark_file() + { + if(file_exists(BASEDIR."/images/photo_watermark.png")) + return BASEURL."/images/photo_watermark.png"; + else + return false; + } + + /** + * Used to set watermark position + */ + function position_watermark($file,$watermark) + { + if(empty($this->position)) + $info = array('left','top'); + else + $info = explode(":",$this->position); + + $x = $info[0]; + $y = $info[1]; + list($w,$h) = getimagesize($file); + list($ww,$wh) = getimagesize($watermark); + $padding = $this->padding; + + switch($x) + { + case "center": + { + $finalxPadding = $w / 2 - $ww / 2; + } + break; + + case "left": + default: + { + $finalxPadding = $padding; + } + break; + + case "right": + { + $finalxPadding = $w - $ww - $padding; + } + break; + } + + switch($y) + { + case "top": + default: + { + $finalyPadding = $padding; + } + break; + + case "center": + { + $finalyPadding = $h / 2 - $wh / 2; + } + break; + + case "bottom": + { + $finalyPadding = $h - $wh - $padding; + } + break; + } + + $values = array($finalxPadding,$finalyPadding); + return $values; + } + + /** + * Used to watermark image + */ + function watermark_image($input,$output) + { + $watermark_file = $this->watermark_file(); + if(!$watermark_file) + return false; + else + { + list($Swidth, $Sheight, $Stype) = getimagesize($input); + $wImage = imagecreatefrompng($watermark_file); + $ww = imagesx($wImage); + $wh = imagesy($wImage); + $paddings = $this->position_watermark($input,$watermark_file); + + switch($Stype) + { + case 1: //GIF + { + $sImage = imagecreatefromgif($input); + imagecopy($sImage,$wImage,$paddings[0],$paddings[1],0,0,$ww,$wh); + imagejpeg($sImage,$output,90); + } + break; + + case 2: //JPEG + { + $sImage = imagecreatefromjpeg($input); + imagecopy($sImage,$wImage,$paddings[0],$paddings[1],0,0,$ww,$wh); + imagejpeg($sImage,$output,90); + } + break; + + case 3: //PNG + { + $sImage = imagecreatefrompng($input); + imagecopy($sImage,$wImage,$paddings[0],$paddings[1],0,0,$ww,$wh); + imagepng($sImage,$output,9); + } + break; + } + } + } + + /** + * Load Upload Form + */ + function loadUploadForm($params) + { + $p = $params; + $should_include = $p['includeHeader'] ? $p['includeHeader'] : TRUE; + $output = '
    collection->get_collections($p); + $cl_array = $this->parse_array($collections); + $collection = $array['collection_id']; + $this->unique = rand(0,9999); + $fields = + array + ( + 'name' => array( + 'title' => lang('photo_title'), + 'id' => 'photo_title', + 'name' => 'photo_title', + 'type' => 'textfield', + 'value' => cleanForm($title), + 'db_field' => 'photo_title', + 'required' => 'yes', + 'invalid_err' => lang('photo_title_err') + ), + + 'desc' => array( + 'title' => lang('photo_caption'), + 'id' => 'photo_description', + 'name' => 'photo_description', + 'type' => 'textarea', + 'value' =>cleanForm( $description), + 'db_field' => 'photo_description', + 'anchor_before' => 'before_desc_compose_box', + 'required' => 'yes', + 'invalid_err' => lang('photo_caption_err') + ), + 'tags' => array( + 'title' => lang('photo_tags'), + 'id' => 'photo_tags', + 'name' => 'photo_tags', + 'type' => 'textfield', + 'value' => genTags($tags), + 'db_field' => 'photo_tags', + 'required' => 'yes', + 'invalid_err' => lang('photo_tags_err') + ), + 'collection' => array( + 'title' => lang('collection'), + 'id' => 'collection_id', + 'name' => 'collection_id', + 'type' => 'dropdown', + 'value' => $cl_array, + 'db_field' => 'collection_id', + 'required' => '', + 'checked' => $collection, + 'invalid_err' => lang('photo_collection_err') + ) + ); + + return $fields; + } + + function insert_photo($array=NULL) + { + global $db,$eh; + if($array == NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $this->validate_form_fields($array); + if(!error()) + { + $forms = $this->load_required_forms($array); + $oForms = $this->load_other_forms($array); + $FullForms = array_merge($forms,$oForms); + + foreach($FullForms as $field) + { + $name = formObj::rmBrackets($field['name']); + $val = $_POST[$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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + } + + $query_field[] = "userid"; + if(!$array['userid']) + { $userid = userid(); $query_val[] = $userid; } + else + { $query_val[] = $array['userid']; $userid = $array['userid']; } + + $query_field[] = "date_added"; + $query_val[] = NOW(); + + $query_field[] = "owner_ip"; + $query_val[] = $_SERVER['REMOTE_ADDR']; + + $query_field[] = "ext"; + $query_val[] = $array['ext']; + + $query_field[] = "photo_key"; + //$query_val[] = $array['photo_key']; + $query_val[] = $this->photo_key(); + + $query_field[] = "filename"; + $query_val[] = $array['filename']; + + if($array['server_url'] && $array['server_url'] != "undefined") + { + $query_field[] = "server_url"; + $query_val[] = $array['server_url']; + } + + if($array['folder'] && $array['folder'] != "undefined") + { + $query_field[] = "file_directory"; + $query_val[] = $array['folder']; + } + + $insert_id = $db->insert(tbl($this->p_tbl),$query_field,$query_val); + $photo = $this->get_photo($insert_id); + $this->collection->add_collection_item($insert_id,$photo['collection_id']); + + if(!$array['server_url'] || $array['server_url']=='undefined') + $this->generate_photos($photo); + + + $eh->flush(); + e(sprintf(lang("photo_is_saved_now"),$photo['photo_title']),"m"); + $db->update(tbl("users"),array("total_photos"),array("|f|total_photos+1")," userid='".$userid."'"); + + //Adding Photo Feed + addFeed(array('action' => 'upload_photo','object_id' => $insert_id,'object'=>'photo')); + + return $insert_id; + } + } + + /** + * Update watermark file + */ + function update_watermark($file) + { + if(empty($file)) + e(lang("no_watermark_found")); + else + { + $oldW = BASEDIR."/images/photo_watermark.png"; + if(file_exists($oldW)) + unset($oldW); + + $info = getimagesize($file['tmp_name']); + $width = $info[0]; + $type = $info[2]; + + //pr($info,TRUE); + + if($type == 3) + { + if(move_uploaded_file($file['tmp_name'],BASEDIR."/images/photo_watermark.png")) + { + $wFile = BASEDIR."/images/photo_watermark.png"; + if($width > $this->max_watermark_width) + $this->createThumb($wFile,$wFile,'png',$this->max_watermark_width); + } + e(lang("watermark_updated"),"m"); + } else { + e(lang("upload_png_watermark")); + } + + + } + } + + /** + * Load Other Form + */ + function load_other_forms($array=NULL) + { + if($array==NULL) + $array = $_POST; + + $comments = $array['allow_comments']; + $broadcast = $array['broadcast']; + $tagging = $array['allow_tagging']; + $embedding = $array['allow_embedding']; + $rating = $array['allow_rating']; + $rand = $array['photo_key']; + + $Otherfields = array + ( + 'comments' => array( + 'title' => lang('comments'), + 'name' => 'allow_comments', + 'id' => 'allow_comments', + 'db_field' => 'allow_comments', + 'type' => 'radiobutton', + 'value' => array('yes' => lang('vdo_allow_comm'),'no' => lang('vdo_dallow_comm')), + 'required' => 'no', + 'checked' => $comments, + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ), + /*'broadcast' => array( + 'title' => lang("vdo_br_opt"), + 'type' => 'radiobutton', + 'name' => 'broadcast', + 'id' => 'broadcast', + 'value' => array("public"=>lang("collect_borad_pub"),"private"=>lang("collect_broad_pri")), + 'checked' => $broadcast, + 'db_field' => 'broadcast', + 'required' => 'no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'public' + ),*/ + /*'tagging' => array( + 'title' => lang('tagging'), + 'type' => 'radiobutton', + 'id' => 'allow_tagging', + 'name' => 'allow_tagging', + 'db_field' => 'allow_tagging', + 'type' => 'radiobutton', + 'value' => array('yes' => lang('pic_allow_tagging'),'no' => lang('pic_dallow_tagging')), + 'checked' => $tagging, + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ),*/ + 'embedding' => array( + 'title' => lang('vdo_embedding'), + 'type' => 'radiobutton', + 'name' => 'allow_embedding', + 'id' => 'allow_embedding', + 'db_field' => 'allow_embedding', + 'value' => array('yes' => lang('pic_allow_embed'),'no' => lang('pic_dallow_embed')), + 'checked' => $embedding, + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ), + 'rating' => array( + 'title' => lang('rating'), + 'id' => 'allow_rating', + 'name' => 'allow_rating', + 'type' => 'radiobutton', + 'db_field' => 'allow_rating', + 'value' => array('yes' => lang('pic_allow_rating'),'no' => lang('pic_dallow_rating')), + 'checked' => $rating, + 'validate_function'=>'yes_or_no', + 'display_function' => 'display_sharing_opt', + 'default_value'=>'yes' + ) + ); + + //pr($Otherfields,TRUE); + return $Otherfields; + } + + + /** + * This will return a formatted array + * return @Array + * Array Format: Multidemsional + * Array ( [photo_id] => array( ['field_name'] => 'value' ) ) + */ + function return_formatted_post($arr) + { + $photoID = ''; + foreach($_POST as $key => $value) + { + $parts = explode('_',$key); + $total = count($parts); + $id = $parts[$total-1]; + $name = array_splice($parts,0,$total-1); + $name = implode("_",$name); + + if($photoID != $id){ + $values = array(); + $photoID = $id; + } + + if(is_numeric($id)) + { + if (strpos($key, $id) !== FALSE) + { + $values[$name] = $value; + $PhotosArray[$id] = $values; + } + } + } + + return $PhotosArray; + } + + /** + * This will be used to mutliple photos + * at once. + * Single update will be different. + */ + function update_multiple_photos($arr) + { + global $db,$cbcollection,$eh; + + foreach($arr as $id => $details) + { + if(is_array($details)) + { + $i = 0; + $query = "UPDATE ".tbl('photos')." SET "; + foreach($details as $key => $value) + { + $i++; + $query .= "$key = '$value'"; + if($iExecute($query); + $cbcollection->add_collection_item($id,$details['collection_id']); + + } + } + $eh->flush(); + } + + /** + * Used to parse collections dropdown + */ + function parse_array($array) + { + if(is_array($array)) + { + foreach($array as $key=>$v) + { + $cl_arr[$v['collection_id']] = $v['collection_name']; + } + return $cl_arr; + } else { + return false; + } + } + + /** + * Used to create filename of photo + */ + function create_filename() + { + $filename = time().RandomString(6); + return $filename; + } + + /** + * Construct extensions for SWF + */ + function extensions() + { + $exts = $this->exts; + $list = ''; + foreach($exts as $ext) + { + $list .= "*.".$ext.";"; + } + return $list; + + } + + /** + * Function used to validate form fields + */ + function validate_form_fields($array=NULL) + { + $reqFileds = $this->load_required_forms($array); + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + + $otherFields = $this->load_other_forms($array); + + $photo_fields = array_merge($reqFileds,$otherFields); + + validate_cb_form($photo_fields,$array); + } + + /** + * Update Photo + */ + function update_photo($array=NULL) + { + global $db; + + if($array == NULL) + $array = $_POST; + $this->validate_form_fields($array); + $pid = $array['photo_id']; + $cid = $this->get_photo_field($pid,'collection_id'); + + if(!error()) + { + $reqFields = $this->load_required_forms($array); + $otherFields = $this->load_other_forms($array); + + $fields = array_merge($reqFields,$otherFields); + + foreach($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 = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + } + + if(has_access('admin_access',TRUE)) + { + if(isset($array['views'])) + { + $query_field[] = 'views'; + $query_val[] = $array['views']; + } + + if(isset($array['total_comments'])) + { + $query_field[] = "total_comments"; + $query_val[] = $array['total_comments']; + } + + if(isset($array['total_favorites'])) + { + $query_field[] = "total_favorites"; + $query_val[] = $array['total_favorites']; + } + + if(isset($array['downloaded'])) + { + $query_field[] = "downloaded"; + $query_val[] = $array['downloaded']; + } + + if(isset($array['voters'])) + { + $query_field[] = "voters"; + $query_val[] = $array['voters']; + } + } + + if(!error()) + { + if(!userid()) + e(lang("you_not_logged_in")); + elseif(!$this->photo_exists($pid)) + e(lang("photo_not_exists")); + elseif($this->get_photo_owner($pid) != userid() && !has_access('admin_access',TRUE)) + e(lang("cant_edit_photo")); + else + { + if($cid != $array['collection_id']) + { + $this->collection->change_collection($array['collection_id'],$pid,$cid); + } + + $db->update(tbl('photos'),$query_field,$query_val," photo_id='$pid'"); + e(lang("photo_updated_successfully"),"m"); + } + } + } + + + } + + /** + * Used to get image type + * t = Thumb + * m = Medium + * l = Large + */ + function get_image_type($name) + { + if(empty($name)) + return false; + else + { + $parts = explode("_",$name); + if(is_array($parts)) + { + if(!empty($parts[1])) + return substr($parts[1],0,1); + } + } + } + + /** + * Used to get image file + */ + function get_image_file($pid,$size='t',$multi=false,$assign=NULL,$with_path=true,$with_orig=false) + { + $params = array("details"=>$pid,"size"=>$size,"multi"=>$multi,"assign"=>$assign,"with_path"=>$with_path,"with_orig"=>$with_orig); + return $this->getFileSmarty($params); + } + + /** + * This will become a Smarty function. + * I am writting this to eliminate the possiblitles + * of distort pictures + */ + function getFileSmarty($p) + { + global $Cbucket; + $details = $p['details']; + $output = $p['output']; + if(empty($details)) + { + return $this->default_thumb($size,$output); + } else { + //Calling Custom Functions + if(count($Cbucket->custom_get_photo_funcs) > 0) + { + + foreach($Cbucket->custom_get_photo_funcs as $funcs) + { + if(function_exists($funcs)) + { + $func_returned = $funcs($p); + if($func_returned) + return $func_returned; + } + } + } + + if(($p['size'] != 't' && $p['size'] != 'm' && $p['size'] != 'l' && $p['size'] != 'o') || empty($p['size'])) + $p['size'] = 't'; + + if($p['with_path'] === FALSE) $p['with_path'] = FALSE; else $p['with_path'] = TRUE; + $with_path = $p['with_path']; + $with_orig = $p['with_orig'] ? $p['with_orig'] : FALSE; + + if(!is_array($details)) + $photo = $this->get_photo($details); + else + $photo = $details; + + if(empty($photo['photo_id']) || empty($photo['photo_key'])) + return $this->default_thumb($size,$output); + else + { + if(!empty($photo['filename']) && !empty($photo['ext'])) + { + $files = glob(PHOTOS_DIR."/".$photo['filename']."*.".$photo['ext']); + if(!empty($files) && is_array($files)) + { + + foreach($files as $file) + { + $file_parts = explode("/",$file); + $thumb_name = $file_parts[count($file_parts)-1]; + + $type = $this->get_image_type($thumb_name); + if($with_orig) + { + if($with_path) + $thumbs[] = PHOTOS_URL."/".$thumb_name; + else + $thumbs[] = $thumb_name; + } + elseif(!empty($type)) + { + if($with_path) + $thumbs[] = PHOTOS_URL."/".$thumb_name; + else + $thumbs[] = $thumb_name; + } + } + + if(empty($p['output']) || $p['output'] == 'non_html') + { + if($p['assign'] && $p['multi']) + { + assign($p['assign'],$thumbs); + } elseif(!$p['assign'] && $p['multi']) { + return $thumbs; + } else { + + $size = "_".$p['size']; + + $return_thumb = array_find($photo['filename'].$size,$thumbs); + + if(empty($return_thumb)) + { + $this->default_thumb($size,$output); + } else { + if($p['assign'] != NULL) + assign($p['assign'],$return_thumb); + else + return $return_thumb; + } + } + } + + if($p['output'] == 'html') + { + + $size = "_".$p['size']; + + $src = array_find($photo['filename'].$size,$thumbs); + if(empty($src)) + $src = $this->default_thumb($size); + else + $src = $src; + + if(phpversion < '5.2.0') + global $json; $js = $json; + + if(!empty($js)) + $imgDetails = $js->json_decode($photo['photo_details'],true); + else + $imgDetails = json_decode($photo['photo_details'],true); + + if(empty($imgDetails) || empty($imgDetails[$p['size']])) + { + $dem = getimagesize(str_replace(PHOTOS_URL,PHOTOS_DIR,$src)); + $width = $dem[0]; + $height = $dem[1]; + /* UPDATEING IMAGE DETAILS */ + $this->update_image_details($details); + } else { + $width = $imgDetails[$p['size']]['width']; + $height = $imgDetails[$p['size']]['height']; + } + + $img = "$p['anchor'],"data"=>$photo); + ANCHOR($anchor_p); + } + + if($p['style']) + $img .= " style = '".$p['style']."'"; + + if($p['extra']) + $img .= ($p['extra']); + + $img .= " />"; + + if($p['assign']) + assign($p['assign'],$img); + else + return $img; + } + } else { + return $this->default_thumb($size,$output); + } + } + } + } + } + + /** + * Will be called when collection is being deleted + * This will make photos in the collection orphan + * User will be able to access them in orphan photos + */ + function make_photo_orphan($details,$pid=NULL) + { + global $db; + if(!is_array($details) && is_numeric($details)) + { + $c = $this->collection->get_collection($details); + $cid = $c['collection_id']; + } + else + $cid = $details['collection_id']; + if(!empty($pid)) + $cond = " AND photo_id = $pid"; + + $db->update(tbl('photos'),array('collection_id'),array('0')," collection_id = $cid $cond"); + } + + /** + * This will create download button for + * photo + */ + function download_button($params) + { + $output = ''; + if(!is_array($params['details'])) + $p = $this->get_photo($params['details']); + else + $p = $params['details']; + + $text = lang('download_photo'); + if(config('photo_download') == 1 && !empty($p)) + { + if($params['return_url']) + { + $output = $this->photo_links($p,'download_photo'); + if($params['assign']) + { + assign($params['assign'],$output); + return; + } + else + return $output; + } + + if($params['output'] == '' || $params['output'] == 'link') + { + $output .= ""; + } + + if($params['output'] == "div") + { + $link = "'".$this->photo_links($p,'download')."'"; + $new_window = $params['new_window'] ? "'new'" : "'same'"; + $output .= '
    '; + } + + if($params['assign']) + assign($params['assign'],$output); + else + return $output; + } + } + + /** + * Used to load upload more photos + * This button will only appear if collection type is photos + * and user logged-in is Collection Owner + */ + function upload_photo_button($arr) + { + $cid = $arr['details']; + //pr($arr,TRUE); + $text = lang("add_more"); + $result = ''; + if(!is_array($cid)) + $details = $this->collection->get_collection($cid); + else + $details = $cid; + + if($details['type'] == 'photos' && $details['userid'] == user_id()) + { + $output = $arr['output']; + if($arr['return_url']) + { + $result = $this->photo_links($details,'upload_more'); + if($arr['assign']) + { + assign($arr['assign'],$result); + return; + } + else + return $result; + } + + if(empty($output) || $output == "button") + { + $result .= '"; + + } + + if($output == "div") + { + $result .= '
    photo_links($details,'upload_more')."'"; + if($arr['new_window'] || $arr['target'] == "_blank") + $new_window = "'new'"; + else + $new_window = "'same'"; + $result .= 'onClick = "openURL('.$link.','.$new_window.')"'; + if($arr['id']) + $result .= ' id = "'.$arr['id'].'"'; + if($arr['align']) + $result .= ' align = "'.$arr['align'].'"'; + if($arr['class']) + $result .= ' class = "'.$arr['class'].'"'; + if($arr['title']) + $result .= ' title = "'.$arr['title'].'"'; + if($arr['style']) + $result .= ' style = "'.$arr['style'].'"'; + if($arr['extra']) + $result .= mysql_clean($arr['extra']); + + $result .= ">".$text."
    "; + } + + if($output == "link") + { + $result .= '
    "; + } + + if($arr['assign']) + assign($arr['assign'],$result); + else + return $result; + } else { + return FALSE; + } + } + + /** + * used to create links + */ + function photo_links($details,$type) + { + if(empty($type)) + return BASEURL; + else + { + switch($type) + { + case "upload": + { + if(SEO == "yes") + $link = BASEURL."/photo_upload"; + else + $link = BASEURL."/photo_upload.php"; + } + break; + + case "upload_more": + { + if(SEO == "yes") + $link = BASEURL."/photo_upload/".$this->encode_key($details['collection_id']); + else + $link = BASEURL."/photo_upload.php?collection=".$this->encode_key($details['collection_id']); + } + break; + + case "download_photo": + case "download": + { + return BASEURL."/download_photo.php?download=".$this->encode_key($details['photo_key']); + } + + case "view_item": + case "view_photo": + { + return $this->collection->collection_links($details,'view_item'); + } + break; + } + return $link; + } + } + + /** + * Used to return default thumb + */ + function default_thumb($size=NULL,$output=NULL) + { + if($size != "_t" && $size != "_m") + $size = "_m"; + + if(file_exists(TEMPLATEDIR."/images/thumbs/no-photo".$size.".png")) + $path = TEMPLATEURL."/images/thumbs/no-photo".$size.".png"; + else + $path = PHOTOS_URL."/no-photo".$size.".png"; + + if(!empty($output) && $output == "html") + echo ""; + else + return $path; + } + + /** + * Used to add comment + */ + function add_comment($comment,$obj_id,$reply_to=NULL,$force_name_email=false) + { + global $myquery; + $photo = $this->get_photo($obj_id); + if(empty($photo)) + e("photo_not_exist"); + else + { + $ownerID = $photo['userid']; + $photoLink = $this->photo_links($photo,'view_item'); + $comment = $myquery->add_comment($comment,$obj_id,$reply_to,'p',$ownerID,$photoLink,$force_name_email); + if($comment) + { + $this->update_total_comments($obj_id); + } + return $comment; + } + } + + /** + * Function used to update total comments of collection + */ + function update_total_comments($pid) + { + global $db; + $count = $db->count(tbl("comments"),"comment_id"," type = 'p' AND type_id = '$pid'"); + $db->update(tbl('photos'),array("total_comments","last_commented"),array($count,now())," photo_id = '$pid'"); + } + + /** + * Used to check if collection can add + * photos or not + */ + function is_addable($cid) + { + if(!is_array($cid)) + $details = $this->collection->get_collection($cid); + else + $details = $cid; + + if(empty($details)) + { + return false; + } else { + if(($details['active'] == 'yes' || $details['broadcast'] == 'public') && $details['userid'] == userid()) + return true; + elseif($details['userid'] == userid()) + return true; + else + return false; + } + } + + /** + * Used to display photo voterts details. + * User who rated, how many stars and when user rated + */ + function photo_voters($id,$return_array=FALSE,$show_all=FALSE) + { + global $json; + $p = $this->get_photo($id); + if((!empty($p) && $p['userid'] == userid()) || $show_all === TRUE) + { + global $userquery; + $voters = $p['voters']; + if(phpversion() < "5.2.0") + $voters = $json->json_decode($voters,TRUE); + else + $voters = json_decode($voters,TRUE); + + if(!empty($voters)) + { + if($return_array) + return $voters; + else + { + foreach($voters as $id=>$details) + { + $username = get_username($id); + $output = "
  • "; + $output .= "$username"; + $output .= " rated ". $details['rate']/2 ." stars ("; + $output .= niceTime($details['time']).")"; + $output .= "
  • "; + echo $output; + } + } + } + } else + return false; + } + + /** + * Used to get current rating + */ + function current_rating($id) + { + global $db; + + if(!is_numeric($id)) + $result = $db->select(tbl('photos'),'userid,allow_rating,rating,rated_by,voters'," photo_key = ".$id.""); + else + $result = $db->select(tbl('photos'),'userid,allow_rating,rating,rated_by,voters'," photo_id = ".$id.""); + + if($result) + return $result[0]; + else + return false; + } + + /** + * Used to rate photo + */ + function rate_photo($id,$rating) + { + global $db,$json; + + if(!is_numeric($rating) || $rating <= 9) + $rating = 0; + if($rating >= 10) + $rating = 10; + + $c_rating = $this->current_rating($id); + $voters = $c_rating['voters']; + + $new_rate = $c_rating['rating']; + $rated_by = $c_rating['rated_by']; + + if(phpversion < '5.2.0') + $voters = $json->json_decode($voters,TRUE); + else + $voters = json_decode($voters,TRUE); + + if(!empty($voters)) + $already_voted = array_key_exists(userid(),$voters); + + if(!userid()) + e(lang("please_login_to_rate")); + elseif(userid()==$c_rating['userid'] && !config('own_photo_rating')) + e(lang("you_cannot_rate_own_photo")); + elseif(!empty($already_voted)) + e(lang("you_hv_already_rated_photo")); + elseif($c_rating['allow_rating'] == 'no' || !config('photo_rating')) + e(lang("photo_rate_disabled")); + else + { + $voters[userid()] = array('rate'=>$rating,'time'=>NOW()); + if(phpversion < '5.2.0') + $voters = $json->json_encode($voters); + else + $voters = json_encode($voters); + + $t = $c_rating['rated_by'] * $c_rating['rating']; + $rated_by = $c_rating['rated_by'] + 1; + $new_rate = ($t + $rating) / $rated_by; + $db->update(tbl('photos'),array('rating','rated_by','voters'),array("$new_rate","$rated_by","|no_mc|$voters")," photo_id = ".$id.""); + $userDetails = array( + "object_id" => $id, + "type" => "photo", + "time" => now(), + "rating" => $rating, + "userid" => userid(), + "username" => username() + ); + /* Updating user details */ + update_user_voted($userDetails); + e(lang("thnx_for_voting"),"m"); + } + + $return = array("rating"=>$new_rate,"rated_by"=>$rated_by,'total'=>10,"id"=>$id,"type"=>"photo","disable"=>"disabled"); + return $return; + } + + /** + * Used to generate different + * embed codes + */ + function generate_embed_codes($p) + { + $details = $p['details']; + $type = $p['type']; + $size = $p['size'] ? $p['size'] : 'm'; + + if(is_array($details)) + $photo = $details; + else + $photo = $this->get_photo($detials); + + switch($type) + { + case "html": + { + if($p['with_url']) + $code .= "<a href='".$this->collection->collection_links($photo,'view_item')."' target='_blank'>"; + $code .= "<img src='".$this->get_image_file($photo,$size)."' title='".$photo['photo_title']."' alt='".$photo['photo_title']." ".TITLE."' />"; + if($p['with_url']) + $code .= "</a>"; + } + break; + + case "forum": + { + if($p['with_url']) + $code .= "[URL=".$this->collection->collection_links($photo,'view_item')."]"; + $code .= "[IMG]".$this->get_image_file($photo,$size)."[/IMG]"; + if($p['with_url']) + $code .= "[/URL]"; + } + break; + + case "email": + { + $code .= $this->collection->collection_links($photo,'view_item'); + } + break; + + case "direct": + { + $code .= $this->get_image_file($photo,"o"); + } + break; + + default: + return false; + } + + return $code; + } + + /** + * Embed Codes + */ + function photo_embed_codes($newArr) + { + if(empty($newArr['details'])) + { + echo "
    ".e(lang("need_photo_details"))."
    "; + } + elseif($newArr['details']['allow_embedding'] == 'no') + { + echo "
    ".e(lang("embedding_is_disabled"))."
    "; + } + else + { + $t = $newArr['type']; + if(is_array($t)) + $types = $t; + elseif($t == 'all') + $types = $this->embed_types; + else + $types = explode(',',$t); + + foreach($types as $type) + { + $type = strtolower($type); + if(in_array($type,$this->embed_types)) { + $type = str_replace(' ','',$type); + $newArr['type'] = $type; + $codes[] = array("name"=>ucwords($type),"type"=>$type,"code"=>$this->generate_embed_codes($newArr)); + } + } + + if($newArr['assign']) + assign(mysql_clean($newArr['assign']),$codes); + else + return $codes; + } + } + + /** + * Used encode photo key + */ + function encode_key($key) + { + return base64_encode(serialize($key)); + } + + /** + * Used encode photo key + */ + function decode_key($key) + { + return unserialize(base64_decode($key)); + } + + function incrementDownload($Array) + { + global $db; + if(!isset($_COOKIE[$Array['photo_id']."_downloaded"])) + { + $db->update(tbl('photos'),array('downloaded'),array('|f|downloaded+1'),' photo_id = "'.$Array['photo_id'].'"'); + setcookie($Array['photo_id']."_downloaded",NOW(),time()+1800); + } + } + + function download_photo($key) + { + + $file = $this->ready_photo_file($key); + + if($file) + { + + if($file['details']['server_url']) + { + $url = dirname(dirname($file['details']['server_url'])); + header('location:'.$url.'/download_photo.php?file='.$file['details']['filename'] + .'.'.$file['details']['ext'].'&folder='.$file['details']['file_directory'] + .'&title='.urlencode($file['details']['photo_title'])); + + $this->incrementDownload($p); + return true; + } + $p = $file['details']; + $mime_types=array(); + $mime_types['gif'] = 'image/gif'; + $mime_types['jpe'] = 'image/jpeg'; + $mime_types['jpeg'] = 'image/jpeg'; + $mime_types['jpg'] = 'image/jpeg'; + $mime_types['png'] = 'image/png'; + + if(array_key_exists($p['ext'],$mime_types)){ + $mime = $mime_types[$p['ext']]; + if(file_exists($file['file_dir'])) + { + if(is_readable($file['file_dir'])) + { + $size = filesize($file['file_dir']); + if($fp=@fopen($file['file_url'],'r')) { + $this->incrementDownload($p); + // sending the headers + header("Content-type: $mime"); + header("Content-Length: $size"); + header("Content-Disposition: attachment; filename=\"".$p['photo_title'].".".$p['ext']."\""); + // send the file content + fpassthru($fp); + // close the file + fclose($fp); + // and quit + exit; + } + } else { + e(lang("photo_not_readable")); + } + } else { + e(lang("photo_not_exist")); + } + } else { + e(lang("wrong_mime_type")); + } + } else + return false; + } + + /** + * Ready photo for downloading + */ + function ready_photo_file($pid) + { + $photo = $this->get_photo($pid); + if(empty($photo)) + e(lang("photo_not_exist")); + else + { + if(!$this->collection->is_viewable($photo['collection_id'])) + return false; + else + { + $filename = $this->get_image_file($photo['photo_id'],'o',FALSE,FALSE,FALSE); + $returnArray = array( + "file_dir" => PHOTOS_DIR."/".$filename, + "file_url" => PHOTOS_URL."/".$filename, + "filename" => $filename, + "details" => $photo + ); + return $returnArray; + } + } + } + + /** + * Used to perform photo actions + */ + function photo_actions($action,$id) + { + global $db; + + switch($action) + { + case "activate": + case "activation": + case "ap": + { + $db->update(tbl($this->p_tbl),array("active"),array("yes")," photo_id = $id"); + e(lang("photo_activated"),"m"); + } + break; + + case "deactivate": + case "deactivation": + case "dap": + { + $db->update(tbl($this->p_tbl),array("active"),array("no")," photo_id = $id"); + e(lang("photo_deactivated"),"m"); + } + break; + + case "make_featured": + case "feature_photo": + case "fp": + { + $db->update(tbl($this->p_tbl),array("featured"),array("yes")," photo_id = $id"); + e(lang("photo_featured"),"m"); + } + break; + + case "make_unfeatured": + case "unfeature_photo": + case "ufp": + { + $db->update(tbl($this->p_tbl),array("featured"),array("no")," photo_id = $id"); + e(lang("photo_unfeatured"),"m"); + } + break; + } + } + +} + + ?> \ No newline at end of file diff --git a/upload/includes/classes/phpmailer/class.phpmailer.php b/upload/includes/classes/phpmailer/class.phpmailer.php new file mode 100644 index 00000000..9760e61d --- /dev/null +++ b/upload/includes/classes/phpmailer/class.phpmailer.php @@ -0,0 +1,2326 @@ +exceptions = ($exceptions == true); + } + + /** + * Sets message type to HTML. + * @param bool $ishtml + * @return void + */ + public function IsHTML($ishtml = true) { + if ($ishtml) { + $this->ContentType = 'text/html'; + } else { + $this->ContentType = 'text/plain'; + } + } + + /** + * Sets Mailer to send message using SMTP. + * @return void + */ + public function IsSMTP() { + $this->Mailer = 'smtp'; + } + + /** + * Sets Mailer to send message using PHP mail() function. + * @return void + */ + public function IsMail() { + $this->Mailer = 'mail'; + } + + /** + * Sets Mailer to send message using the $Sendmail program. + * @return void + */ + public function IsSendmail() { + if (!stristr(ini_get('sendmail_path'), 'sendmail')) { + $this->Sendmail = '/var/qmail/bin/sendmail'; + } + $this->Mailer = 'sendmail'; + } + + /** + * Sets Mailer to send message using the qmail MTA. + * @return void + */ + public function IsQmail() { + if (stristr(ini_get('sendmail_path'), 'qmail')) { + $this->Sendmail = '/var/qmail/bin/sendmail'; + } + $this->Mailer = 'sendmail'; + } + + ///////////////////////////////////////////////// + // METHODS, RECIPIENTS + ///////////////////////////////////////////////// + + /** + * Adds a "To" address. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddAddress($address, $name = '') { + return $this->AddAnAddress('to', $address, $name); + } + + /** + * Adds a "Cc" address. + * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddCC($address, $name = '') { + return $this->AddAnAddress('cc', $address, $name); + } + + /** + * Adds a "Bcc" address. + * Note: this function works with the SMTP mailer on win32, not with the "mail" mailer. + * @param string $address + * @param string $name + * @return boolean true on success, false if address already used + */ + public function AddBCC($address, $name = '') { + return $this->AddAnAddress('bcc', $address, $name); + } + + /** + * Adds a "Reply-to" address. + * @param string $address + * @param string $name + * @return boolean + */ + public function AddReplyTo($address, $name = '') { + return $this->AddAnAddress('ReplyTo', $address, $name); + } + + /** + * Adds an address to one of the recipient arrays + * Addresses that have been added already return false, but do not throw exceptions + * @param string $kind One of 'to', 'cc', 'bcc', 'ReplyTo' + * @param string $address The email address to send to + * @param string $name + * @return boolean true on success, false if address already used or invalid in some way + * @access private + */ + private function AddAnAddress($kind, $address, $name = '') { + if (!preg_match('/^(to|cc|bcc|ReplyTo)$/', $kind)) { + echo 'Invalid recipient array: ' . kind; + return false; + } + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (!self::ValidateAddress($address)) { + $this->SetError($this->Lang('invalid_address').': '. $address); + if ($this->exceptions) { + throw new phpmailerException($this->Lang('invalid_address').': '.$address); + } + echo $this->Lang('invalid_address').': '.$address; + return false; + } + if ($kind != 'ReplyTo') { + if (!isset($this->all_recipients[strtolower($address)])) { + array_push($this->$kind, array($address, $name)); + $this->all_recipients[strtolower($address)] = true; + return true; + } + } else { + if (!array_key_exists(strtolower($address), $this->ReplyTo)) { + $this->ReplyTo[strtolower($address)] = array($address, $name); + return true; + } + } + return false; +} + +/** + * Set the From and FromName properties + * @param string $address + * @param string $name + * @return boolean + */ + public function SetFrom($address, $name = '',$auto=1) { + $address = trim($address); + $name = trim(preg_replace('/[\r\n]+/', '', $name)); //Strip breaks and trim + if (!self::ValidateAddress($address)) { + $this->SetError($this->Lang('invalid_address').': '. $address); + if ($this->exceptions) { + throw new phpmailerException($this->Lang('invalid_address').': '.$address); + } + echo $this->Lang('invalid_address').': '.$address; + return false; + } + $this->From = $address; + $this->FromName = $name; + if ($auto) { + if (empty($this->ReplyTo)) { + $this->AddAnAddress('ReplyTo', $address, $name); + } + if (empty($this->Sender)) { + $this->Sender = $address; + } + } + return true; + } + + /** + * Check that a string looks roughly like an email address should + * Static so it can be used without instantiation + * Tries to use PHP built-in validator in the filter extension (from PHP 5.2), falls back to a reasonably competent regex validator + * Conforms approximately to RFC2822 + * @link http://www.hexillion.com/samples/#Regex Original pattern found here + * @param string $address The email address to check + * @return boolean + * @static + * @access public + */ + public static function ValidateAddress($address) { + + //Checking if domain is localhost, return true + $host = explode('@',$address); + $host = $host[1]; + if($host=='localhost') + return true; + if (function_exists('filter_var')) { //Introduced in PHP 5.2 + if(filter_var($address, FILTER_VALIDATE_EMAIL) === FALSE) { + return false; + } else { + return true; + } + } else { + return preg_match('/^(?:[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+\.)*[\w\!\#\$\%\&\'\*\+\-\/\=\?\^\`\{\|\}\~]+@(?:(?:(?:[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!\.)){0,61}[a-zA-Z0-9_-]?\.)+[a-zA-Z0-9_](?:[a-zA-Z0-9_\-](?!$)){0,61}[a-zA-Z0-9_]?)|(?:\[(?:(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\.){3}(?:[01]?\d{1,2}|2[0-4]\d|25[0-5])\]))$/', $address); + } + } + + ///////////////////////////////////////////////// + // METHODS, MAIL SENDING + ///////////////////////////////////////////////// + + /** + * Creates message and assigns Mailer. If the message is + * not sent successfully then it returns false. Use the ErrorInfo + * variable to view description of the error. + * @return bool + */ + public function Send() { + try { + if ((count($this->to) + count($this->cc) + count($this->bcc)) < 1) { + throw new phpmailerException($this->Lang('provide_address'), self::STOP_CRITICAL); + } + + // Set whether the message is multipart/alternative + if(!empty($this->AltBody)) { + $this->ContentType = 'multipart/alternative'; + } + + $this->error_count = 0; // reset errors + $this->SetMessageType(); + $header = $this->CreateHeader(); + $body = $this->CreateBody(); + + if (empty($this->Body)) { + throw new phpmailerException($this->Lang('empty_message'), self::STOP_CRITICAL); + } + + // digitally sign with DKIM if enabled + if ($this->DKIM_domain && $this->DKIM_private) { + $header_dkim = $this->DKIM_Add($header,$this->Subject,$body); + $header = str_replace("\r\n","\n",$header_dkim) . $header; + } + + // Choose the mailer and send through it + switch($this->Mailer) { + case 'sendmail': + return $this->SendmailSend($header, $body); + case 'smtp': + return $this->SmtpSend($header, $body); + default: + return $this->MailSend($header, $body); + } + + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + //echo $e->getMessage()."\n"; + return false; + } + } + + /** + * Sends mail using the $Sendmail program. + * @param string $header The message headers + * @param string $body The message body + * @access protected + * @return bool + */ + protected function SendmailSend($header, $body) { + if ($this->Sender != '') { + $sendmail = sprintf("%s -oi -f %s -t", escapeshellcmd($this->Sendmail), escapeshellarg($this->Sender)); + } else { + $sendmail = sprintf("%s -oi -t", escapeshellcmd($this->Sendmail)); + } + if ($this->SingleTo === true) { + foreach ($this->SingleToArray as $key => $val) { + if(!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, "To: " . $val . "\n"); + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + if($result != 0) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + } else { + if(!@$mail = popen($sendmail, 'w')) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + fputs($mail, $header); + fputs($mail, $body); + $result = pclose($mail); + // implement call back function if it exists + $isSent = ($result == 0) ? 1 : 0; + $this->doCallback($isSent,$this->to,$this->cc,$this->bcc,$this->Subject,$body); + if($result != 0) { + throw new phpmailerException($this->Lang('execute') . $this->Sendmail, self::STOP_CRITICAL); + } + } + return true; + } + + /** + * Sends mail using the PHP mail() function. + * @param string $header The message headers + * @param string $body The message body + * @access protected + * @return bool + */ + protected function MailSend($header, $body) { + $toArr = array(); + foreach($this->to as $t) { + $toArr[] = $this->AddrFormat($t); + } + $to = implode(', ', $toArr); + + $params = sprintf("-oi -f %s", $this->Sender); + if ($this->Sender != '' && strlen(ini_get('safe_mode'))< 1) { + $old_from = ini_get('sendmail_from'); + ini_set('sendmail_from', $this->Sender); + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); + } + } else { + if ($this->SingleTo === true && count($toArr) > 1) { + foreach ($toArr as $key => $val) { + $rt = @mail($val, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header, $params); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent,$val,$this->cc,$this->bcc,$this->Subject,$body); + } + } else { + $rt = @mail($to, $this->EncodeHeader($this->SecureHeader($this->Subject)), $body, $header); + // implement call back function if it exists + $isSent = ($rt == 1) ? 1 : 0; + $this->doCallback($isSent,$to,$this->cc,$this->bcc,$this->Subject,$body); + } + } + if (isset($old_from)) { + ini_set('sendmail_from', $old_from); + } + if(!$rt) { + throw new phpmailerException($this->Lang('instantiate'), self::STOP_CRITICAL); + } + return true; + } + + /** + * Sends mail via SMTP using PhpSMTP + * Returns false if there is a bad MAIL FROM, RCPT, or DATA input. + * @param string $header The message headers + * @param string $body The message body + * @uses SMTP + * @access protected + * @return bool + */ + protected function SmtpSend($header, $body) { + require_once $this->PluginDir . 'class.smtp.php'; + $bad_rcpt = array(); + + if(!$this->SmtpConnect()) { + throw new phpmailerException($this->Lang('smtp_connect_failed'), self::STOP_CRITICAL); + } + $smtp_from = ($this->Sender == '') ? $this->From : $this->Sender; + if(!$this->smtp->Mail($smtp_from)) { + throw new phpmailerException($this->Lang('from_failed') . $smtp_from, self::STOP_CRITICAL); + } + + // Attempt to send attach all recipients + foreach($this->to as $to) { + if (!$this->smtp->Recipient($to[0])) { + $bad_rcpt[] = $to[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent,$to[0],'','',$this->Subject,$body); + } + } + foreach($this->cc as $cc) { + if (!$this->smtp->Recipient($cc[0])) { + $bad_rcpt[] = $cc[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent,'',$cc[0],'',$this->Subject,$body); + } + } + foreach($this->bcc as $bcc) { + if (!$this->smtp->Recipient($bcc[0])) { + $bad_rcpt[] = $bcc[0]; + // implement call back function if it exists + $isSent = 0; + $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); + } else { + // implement call back function if it exists + $isSent = 1; + $this->doCallback($isSent,'','',$bcc[0],$this->Subject,$body); + } + } + + + if (count($bad_rcpt) > 0 ) { //Create error message for any bad addresses + $badaddresses = implode(', ', $bad_rcpt); + throw new phpmailerException($this->Lang('recipients_failed') . $badaddresses); + } + if(!$this->smtp->Data($header . $body)) { + throw new phpmailerException($this->Lang('data_not_accepted'), self::STOP_CRITICAL); + } + if($this->SMTPKeepAlive == true) { + $this->smtp->Reset(); + } + return true; + } + + /** + * Initiates a connection to an SMTP server. + * Returns false if the operation failed. + * @uses SMTP + * @access public + * @return bool + */ + public function SmtpConnect() { + if(is_null($this->smtp)) { + $this->smtp = new SMTP(); + } + + $this->smtp->do_debug = $this->SMTPDebug; + $hosts = explode(';', $this->Host); + $index = 0; + $connection = $this->smtp->Connected(); + + // Retry while there is no connection + try { + while($index < count($hosts) && !$connection) { + $hostinfo = array(); + if (preg_match('/^(.+):([0-9]+)$/', $hosts[$index], $hostinfo)) { + $host = $hostinfo[1]; + $port = $hostinfo[2]; + } else { + $host = $hosts[$index]; + $port = $this->Port; + } + + $tls = ($this->SMTPSecure == 'tls'); + $ssl = ($this->SMTPSecure == 'ssl'); + + if ($this->smtp->Connect(($ssl ? 'ssl://':'').$host, $port, $this->Timeout)) { + + $hello = ($this->Helo != '' ? $this->Helo : $this->ServerHostname()); + $this->smtp->Hello($hello); + + if ($tls) { + if (!$this->smtp->StartTLS()) { + throw new phpmailerException($this->Lang('tls')); + } + + //We must resend HELO after tls negotiation + $this->smtp->Hello($hello); + } + + $connection = true; + if ($this->SMTPAuth) { + if (!$this->smtp->Authenticate($this->Username, $this->Password)) { + throw new phpmailerException($this->Lang('authenticate')); + } + } + } + $index++; + if (!$connection) { + throw new phpmailerException($this->Lang('connect_host')); + } + } + } catch (phpmailerException $e) { + $this->smtp->Reset(); + throw $e; + } + return true; + } + + /** + * Closes the active SMTP session if one exists. + * @return void + */ + public function SmtpClose() { + if(!is_null($this->smtp)) { + if($this->smtp->Connected()) { + $this->smtp->Quit(); + $this->smtp->Close(); + } + } + } + + /** + * Sets the language for all class error messages. + * Returns false if it cannot load the language file. The default language is English. + * @param string $langcode ISO 639-1 2-character language code (e.g. Portuguese: "br") + * @param string $lang_path Path to the language file directory + * @access public + */ + function SetLanguage($langcode = 'en', $lang_path = 'language/') { + //Define full set of translatable strings + $PHPMAILER_LANG = array( + 'provide_address' => 'You must provide at least one recipient email address.', + 'mailer_not_supported' => ' mailer is not supported.', + 'execute' => 'Could not execute: ', + 'instantiate' => 'Could not instantiate mail function.', + 'authenticate' => 'SMTP Error: Could not authenticate.', + 'from_failed' => 'The following From address failed: ', + 'recipients_failed' => 'SMTP Error: The following recipients failed: ', + 'data_not_accepted' => 'SMTP Error: Data not accepted.', + 'connect_host' => 'SMTP Error: Could not connect to SMTP host.', + 'file_access' => 'Could not access file: ', + 'file_open' => 'File Error: Could not open file: ', + 'encoding' => 'Unknown encoding: ', + 'signing' => 'Signing Error: ', + 'smtp_error' => 'SMTP server error: ', + 'empty_message' => 'Message body empty', + 'invalid_address' => 'Invalid address', + 'variable_set' => 'Cannot set or reset variable: ' + ); + //Overwrite language-specific strings. This way we'll never have missing translations - no more "language string failed to load"! + $l = true; + if ($langcode != 'en') { //There is no English translation file + $l = @include $lang_path.'phpmailer.lang-'.$langcode.'.php'; + } + $this->language = $PHPMAILER_LANG; + return ($l == true); //Returns false if language not found + } + + /** + * Return the current array of language strings + * @return array + */ + public function GetTranslations() { + return $this->language; + } + + ///////////////////////////////////////////////// + // METHODS, MESSAGE CREATION + ///////////////////////////////////////////////// + + /** + * Creates recipient headers. + * @access public + * @return string + */ + public function AddrAppend($type, $addr) { + $addr_str = $type . ': '; + $addresses = array(); + foreach ($addr as $a) { + $addresses[] = $this->AddrFormat($a); + } + $addr_str .= implode(', ', $addresses); + $addr_str .= $this->LE; + + return $addr_str; + } + + /** + * Formats an address correctly. + * @access public + * @return string + */ + public function AddrFormat($addr) { + if (empty($addr[1])) { + return $this->SecureHeader($addr[0]); + } else { + return $this->EncodeHeader($this->SecureHeader($addr[1]), 'phrase') . " <" . $this->SecureHeader($addr[0]) . ">"; + } + } + + /** + * Wraps message for use with mailers that do not + * automatically perform wrapping and for quoted-printable. + * Original written by philippe. + * @param string $message The message to wrap + * @param integer $length The line length to wrap to + * @param boolean $qp_mode Whether to run in Quoted-Printable mode + * @access public + * @return string + */ + public function WrapText($message, $length, $qp_mode = false) { + $soft_break = ($qp_mode) ? sprintf(" =%s", $this->LE) : $this->LE; + // If utf-8 encoding is used, we will need to make sure we don't + // split multibyte characters when we wrap + $is_utf8 = (strtolower($this->CharSet) == "utf-8"); + + $message = $this->FixEOL($message); + if (substr($message, -1) == $this->LE) { + $message = substr($message, 0, -1); + } + + $line = explode($this->LE, $message); + $message = ''; + for ($i=0 ;$i < count($line); $i++) { + $line_part = explode(' ', $line[$i]); + $buf = ''; + for ($e = 0; $e $length)) { + $space_left = $length - strlen($buf) - 1; + if ($e != 0) { + if ($space_left > 20) { + $len = $space_left; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + $buf .= ' ' . $part; + $message .= $buf . sprintf("=%s", $this->LE); + } else { + $message .= $buf . $soft_break; + } + $buf = ''; + } + while (strlen($word) > 0) { + $len = $length; + if ($is_utf8) { + $len = $this->UTF8CharBoundary($word, $len); + } elseif (substr($word, $len - 1, 1) == "=") { + $len--; + } elseif (substr($word, $len - 2, 1) == "=") { + $len -= 2; + } + $part = substr($word, 0, $len); + $word = substr($word, $len); + + if (strlen($word) > 0) { + $message .= $part . sprintf("=%s", $this->LE); + } else { + $buf = $part; + } + } + } else { + $buf_o = $buf; + $buf .= ($e == 0) ? $word : (' ' . $word); + + if (strlen($buf) > $length and $buf_o != '') { + $message .= $buf_o . $soft_break; + $buf = $word; + } + } + } + $message .= $buf . $this->LE; + } + + return $message; + } + + /** + * Finds last character boundary prior to maxLength in a utf-8 + * quoted (printable) encoded string. + * Original written by Colin Brown. + * @access public + * @param string $encodedText utf-8 QP text + * @param int $maxLength find last character boundary prior to this length + * @return int + */ + public function UTF8CharBoundary($encodedText, $maxLength) { + $foundSplitPos = false; + $lookBack = 3; + while (!$foundSplitPos) { + $lastChunk = substr($encodedText, $maxLength - $lookBack, $lookBack); + $encodedCharPos = strpos($lastChunk, "="); + if ($encodedCharPos !== false) { + // Found start of encoded character byte within $lookBack block. + // Check the encoded byte value (the 2 chars after the '=') + $hex = substr($encodedText, $maxLength - $lookBack + $encodedCharPos + 1, 2); + $dec = hexdec($hex); + if ($dec < 128) { // Single byte character. + // If the encoded char was found at pos 0, it will fit + // otherwise reduce maxLength to start of the encoded char + $maxLength = ($encodedCharPos == 0) ? $maxLength : + $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec >= 192) { // First byte of a multi byte character + // Reduce maxLength to split at start of character + $maxLength = $maxLength - ($lookBack - $encodedCharPos); + $foundSplitPos = true; + } elseif ($dec < 192) { // Middle byte of a multi byte character, look further back + $lookBack += 3; + } + } else { + // No encoded character found + $foundSplitPos = true; + } + } + return $maxLength; + } + + + /** + * Set the body wrapping. + * @access public + * @return void + */ + public function SetWordWrap() { + if($this->WordWrap < 1) { + return; + } + + switch($this->message_type) { + case 'alt': + case 'alt_attachments': + $this->AltBody = $this->WrapText($this->AltBody, $this->WordWrap); + break; + default: + $this->Body = $this->WrapText($this->Body, $this->WordWrap); + break; + } + } + + /** + * Assembles message header. + * @access public + * @return string The assembled header + */ + public function CreateHeader() { + $result = ''; + + // Set the boundaries + $uniq_id = md5(uniqid(time())); + $this->boundary[1] = 'b1_' . $uniq_id; + $this->boundary[2] = 'b2_' . $uniq_id; + + $result .= $this->HeaderLine('Date', self::RFCDate()); + if($this->Sender == '') { + $result .= $this->HeaderLine('Return-Path', trim($this->From)); + } else { + $result .= $this->HeaderLine('Return-Path', trim($this->Sender)); + } + + // To be created automatically by mail() + if($this->Mailer != 'mail') { + if ($this->SingleTo === true) { + foreach($this->to as $t) { + $this->SingleToArray[] = $this->AddrFormat($t); + } + } else { + if(count($this->to) > 0) { + $result .= $this->AddrAppend('To', $this->to); + } elseif (count($this->cc) == 0) { + $result .= $this->HeaderLine('To', 'undisclosed-recipients:;'); + } + } + } + + $from = array(); + $from[0][0] = trim($this->From); + $from[0][1] = $this->FromName; + $result .= $this->AddrAppend('From', $from); + + // sendmail and mail() extract Cc from the header before sending + if(count($this->cc) > 0) { + $result .= $this->AddrAppend('Cc', $this->cc); + } + + // sendmail and mail() extract Bcc from the header before sending + if((($this->Mailer == 'sendmail') || ($this->Mailer == 'mail')) && (count($this->bcc) > 0)) { + $result .= $this->AddrAppend('Bcc', $this->bcc); + } + + if(count($this->ReplyTo) > 0) { + $result .= $this->AddrAppend('Reply-to', $this->ReplyTo); + } + + // mail() sets the subject itself + if($this->Mailer != 'mail') { + $result .= $this->HeaderLine('Subject', $this->EncodeHeader($this->SecureHeader($this->Subject))); + } + + if($this->MessageID != '') { + $result .= $this->HeaderLine('Message-ID',$this->MessageID); + } else { + $result .= sprintf("Message-ID: <%s@%s>%s", $uniq_id, $this->ServerHostname(), $this->LE); + } + $result .= $this->HeaderLine('X-Priority', $this->Priority); + $result .= $this->HeaderLine('X-Mailer', 'PHPMailer '.$this->Version.' (phpmailer.sourceforge.net)'); + + if($this->ConfirmReadingTo != '') { + $result .= $this->HeaderLine('Disposition-Notification-To', '<' . trim($this->ConfirmReadingTo) . '>'); + } + + // Add custom headers + for($index = 0; $index < count($this->CustomHeader); $index++) { + $result .= $this->HeaderLine(trim($this->CustomHeader[$index][0]), $this->EncodeHeader(trim($this->CustomHeader[$index][1]))); + } + if (!$this->sign_key_file) { + $result .= $this->HeaderLine('MIME-Version', '1.0'); + $result .= $this->GetMailMIME(); + } + + return $result; + } + + /** + * Returns the message MIME. + * @access public + * @return string + */ + public function GetMailMIME() { + $result = ''; + switch($this->message_type) { + case 'plain': + $result .= $this->HeaderLine('Content-Transfer-Encoding', $this->Encoding); + $result .= sprintf("Content-Type: %s; charset=\"%s\"", $this->ContentType, $this->CharSet); + break; + case 'attachments': + case 'alt_attachments': + if($this->InlineImageExists()){ + $result .= sprintf("Content-Type: %s;%s\ttype=\"text/html\";%s\tboundary=\"%s\"%s", 'multipart/related', $this->LE, $this->LE, $this->boundary[1], $this->LE); + } else { + $result .= $this->HeaderLine('Content-Type', 'multipart/mixed;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + } + break; + case 'alt': + $result .= $this->HeaderLine('Content-Type', 'multipart/alternative;'); + $result .= $this->TextLine("\tboundary=\"" . $this->boundary[1] . '"'); + break; + } + + if($this->Mailer != 'mail') { + $result .= $this->LE.$this->LE; + } + + return $result; + } + + /** + * Assembles the message body. Returns an empty string on failure. + * @access public + * @return string The assembled message body + */ + public function CreateBody() { + $body = ''; + + if ($this->sign_key_file) { + $body .= $this->GetMailMIME(); + } + + $this->SetWordWrap(); + + switch($this->message_type) { + case 'alt': + $body .= $this->GetBoundary($this->boundary[1], '', 'text/plain', ''); + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->GetBoundary($this->boundary[1], '', 'text/html', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->EndBoundary($this->boundary[1]); + break; + case 'plain': + $body .= $this->EncodeString($this->Body, $this->Encoding); + break; + case 'attachments': + $body .= $this->GetBoundary($this->boundary[1], '', '', ''); + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE; + $body .= $this->AttachAll(); + break; + case 'alt_attachments': + $body .= sprintf("--%s%s", $this->boundary[1], $this->LE); + $body .= sprintf("Content-Type: %s;%s" . "\tboundary=\"%s\"%s", 'multipart/alternative', $this->LE, $this->boundary[2], $this->LE.$this->LE); + $body .= $this->GetBoundary($this->boundary[2], '', 'text/plain', '') . $this->LE; // Create text body + $body .= $this->EncodeString($this->AltBody, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->GetBoundary($this->boundary[2], '', 'text/html', '') . $this->LE; // Create the HTML body + $body .= $this->EncodeString($this->Body, $this->Encoding); + $body .= $this->LE.$this->LE; + $body .= $this->EndBoundary($this->boundary[2]); + $body .= $this->AttachAll(); + break; + } + + if ($this->IsError()) { + $body = ''; + } elseif ($this->sign_key_file) { + try { + $file = tempnam('', 'mail'); + file_put_contents($file, $body); //TODO check this worked + $signed = tempnam("", "signed"); + if (@openssl_pkcs7_sign($file, $signed, "file://".$this->sign_cert_file, array("file://".$this->sign_key_file, $this->sign_key_pass), NULL)) { + @unlink($file); + @unlink($signed); + $body = file_get_contents($signed); + } else { + @unlink($file); + @unlink($signed); + throw new phpmailerException($this->Lang("signing").openssl_error_string()); + } + } catch (phpmailerException $e) { + $body = ''; + if ($this->exceptions) { + throw $e; + } + } + } + + return $body; + } + + /** + * Returns the start of a message boundary. + * @access private + */ + private function GetBoundary($boundary, $charSet, $contentType, $encoding) { + $result = ''; + if($charSet == '') { + $charSet = $this->CharSet; + } + if($contentType == '') { + $contentType = $this->ContentType; + } + if($encoding == '') { + $encoding = $this->Encoding; + } + $result .= $this->TextLine('--' . $boundary); + $result .= sprintf("Content-Type: %s; charset = \"%s\"", $contentType, $charSet); + $result .= $this->LE; + $result .= $this->HeaderLine('Content-Transfer-Encoding', $encoding); + $result .= $this->LE; + + return $result; + } + + /** + * Returns the end of a message boundary. + * @access private + */ + private function EndBoundary($boundary) { + return $this->LE . '--' . $boundary . '--' . $this->LE; + } + + /** + * Sets the message type. + * @access private + * @return void + */ + private function SetMessageType() { + if(count($this->attachment) < 1 && strlen($this->AltBody) < 1) { + $this->message_type = 'plain'; + } else { + if(count($this->attachment) > 0) { + $this->message_type = 'attachments'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) < 1) { + $this->message_type = 'alt'; + } + if(strlen($this->AltBody) > 0 && count($this->attachment) > 0) { + $this->message_type = 'alt_attachments'; + } + } + } + + /** + * Returns a formatted header line. + * @access public + * @return string + */ + public function HeaderLine($name, $value) { + return $name . ': ' . $value . $this->LE; + } + + /** + * Returns a formatted mail line. + * @access public + * @return string + */ + public function TextLine($value) { + return $value . $this->LE; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, ATTACHMENTS + ///////////////////////////////////////////////// + + /** + * Adds an attachment from a path on the filesystem. + * Returns false if the file could not be found + * or accessed. + * @param string $path Path to the attachment. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddAttachment($path, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + try { + if ( !@is_file($path) ) { + throw new phpmailerException($this->Lang('file_access') . $path, self::STOP_CONTINUE); + } + $filename = basename($path); + if ( $name == '' ) { + $name = $filename; + } + + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => 'attachment', + 7 => 0 + ); + + } catch (phpmailerException $e) { + $this->SetError($e->getMessage()); + if ($this->exceptions) { + throw $e; + } + //$e->getMessage()."\n"; + if ( $e->getCode() == self::STOP_CRITICAL ) { + return false; + } + } + return true; + } + + /** + * Return the current array of attachments + * @return array + */ + public function GetAttachments() { + return $this->attachment; + } + + /** + * Attaches all fs, string, and binary attachments to the message. + * Returns an empty string on failure. + * @access private + * @return string + */ + private function AttachAll() { + // Return text of body + $mime = array(); + $cidUniq = array(); + $incl = array(); + + // Add all attachments + foreach ($this->attachment as $attachment) { + // Check for string attachment + $bString = $attachment[5]; + if ($bString) { + $string = $attachment[0]; + } else { + $path = $attachment[0]; + } + + if (in_array($attachment[0], $incl)) { continue; } + $filename = $attachment[1]; + $name = $attachment[2]; + $encoding = $attachment[3]; + $type = $attachment[4]; + $disposition = $attachment[6]; + $cid = $attachment[7]; + $incl[] = $attachment[0]; + if ( $disposition == 'inline' && isset($cidUniq[$cid]) ) { continue; } + $cidUniq[$cid] = true; + + $mime[] = sprintf("--%s%s", $this->boundary[1], $this->LE); + $mime[] = sprintf("Content-Type: %s; name=\"%s\"%s", $type, $this->EncodeHeader($this->SecureHeader($name)), $this->LE); + $mime[] = sprintf("Content-Transfer-Encoding: %s%s", $encoding, $this->LE); + + if($disposition == 'inline') { + $mime[] = sprintf("Content-ID: <%s>%s", $cid, $this->LE); + } + + $mime[] = sprintf("Content-Disposition: %s; filename=\"%s\"%s", $disposition, $this->EncodeHeader($this->SecureHeader($name)), $this->LE.$this->LE); + + // Encode as string attachment + if($bString) { + $mime[] = $this->EncodeString($string, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } else { + $mime[] = $this->EncodeFile($path, $encoding); + if($this->IsError()) { + return ''; + } + $mime[] = $this->LE.$this->LE; + } + } + + $mime[] = sprintf("--%s--%s", $this->boundary[1], $this->LE); + + return join('', $mime); + } + + /** + * Encodes attachment in requested format. + * Returns an empty string on failure. + * @param string $path The full path to the file + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @see EncodeFile() + * @access private + * @return string + */ + private function EncodeFile($path, $encoding = 'base64') { + try { + if (!is_readable($path)) { + throw new phpmailerException($this->Lang('file_open') . $path, self::STOP_CONTINUE); + } + if (function_exists('get_magic_quotes')) { + function get_magic_quotes() { + return false; + } + } + if (PHP_VERSION < 6) { + $magic_quotes = get_magic_quotes_runtime(); + set_magic_quotes_runtime(0); + } + $file_buffer = file_get_contents($path); + $file_buffer = $this->EncodeString($file_buffer, $encoding); + if (PHP_VERSION < 6) { set_magic_quotes_runtime($magic_quotes); } + return $file_buffer; + } catch (Exception $e) { + $this->SetError($e->getMessage()); + return ''; + } + } + + /** + * Encodes string to requested format. + * Returns an empty string on failure. + * @param string $str The text to encode + * @param string $encoding The encoding to use; one of 'base64', '7bit', '8bit', 'binary', 'quoted-printable' + * @access public + * @return string + */ + public function EncodeString ($str, $encoding = 'base64') { + $encoded = ''; + switch(strtolower($encoding)) { + case 'base64': + $encoded = chunk_split(base64_encode($str), 76, $this->LE); + break; + case '7bit': + case '8bit': + $encoded = $this->FixEOL($str); + //Make sure it ends with a line break + if (substr($encoded, -(strlen($this->LE))) != $this->LE) + $encoded .= $this->LE; + break; + case 'binary': + $encoded = $str; + break; + case 'quoted-printable': + $encoded = $this->EncodeQP($str); + break; + default: + $this->SetError($this->Lang('encoding') . $encoding); + break; + } + return $encoded; + } + + /** + * Encode a header string to best (shortest) of Q, B, quoted or none. + * @access public + * @return string + */ + public function EncodeHeader($str, $position = 'text') { + $x = 0; + + switch (strtolower($position)) { + case 'phrase': + if (!preg_match('/[\200-\377]/', $str)) { + // Can't use addslashes as we don't know what value has magic_quotes_sybase + $encoded = addcslashes($str, "\0..\37\177\\\""); + if (($str == $encoded) && !preg_match('/[^A-Za-z0-9!#$%&\'*+\/=?^_`{|}~ -]/', $str)) { + return ($encoded); + } else { + return ("\"$encoded\""); + } + } + $x = preg_match_all('/[^\040\041\043-\133\135-\176]/', $str, $matches); + break; + case 'comment': + $x = preg_match_all('/[()"]/', $str, $matches); + // Fall-through + case 'text': + default: + $x += preg_match_all('/[\000-\010\013\014\016-\037\177-\377]/', $str, $matches); + break; + } + + if ($x == 0) { + return ($str); + } + + $maxlen = 75 - 7 - strlen($this->CharSet); + // Try to select the encoding which should produce the shortest output + if (strlen($str)/3 < $x) { + $encoding = 'B'; + if (function_exists('mb_strlen') && $this->HasMultiBytes($str)) { + // Use a custom function which correctly encodes and wraps long + // multibyte strings without breaking lines within a character + $encoded = $this->Base64EncodeWrapMB($str); + } else { + $encoded = base64_encode($str); + $maxlen -= $maxlen % 4; + $encoded = trim(chunk_split($encoded, $maxlen, "\n")); + } + } else { + $encoding = 'Q'; + $encoded = $this->EncodeQ($str, $position); + $encoded = $this->WrapText($encoded, $maxlen, true); + $encoded = str_replace('='.$this->LE, "\n", trim($encoded)); + } + + $encoded = preg_replace('/^(.*)$/m', " =?".$this->CharSet."?$encoding?\\1?=", $encoded); + $encoded = trim(str_replace("\n", $this->LE, $encoded)); + + return $encoded; + } + + /** + * Checks if a string contains multibyte characters. + * @access public + * @param string $str multi-byte text to wrap encode + * @return bool + */ + public function HasMultiBytes($str) { + if (function_exists('mb_strlen')) { + return (strlen($str) > mb_strlen($str, $this->CharSet)); + } else { // Assume no multibytes (we can't handle without mbstring functions anyway) + return false; + } + } + + /** + * Correctly encodes and wraps long multibyte strings for mail headers + * without breaking lines within a character. + * Adapted from a function by paravoid at http://uk.php.net/manual/en/function.mb-encode-mimeheader.php + * @access public + * @param string $str multi-byte text to wrap encode + * @return string + */ + public function Base64EncodeWrapMB($str) { + $start = "=?".$this->CharSet."?B?"; + $end = "?="; + $encoded = ""; + + $mb_length = mb_strlen($str, $this->CharSet); + // Each line must have length <= 75, including $start and $end + $length = 75 - strlen($start) - strlen($end); + // Average multi-byte ratio + $ratio = $mb_length / strlen($str); + // Base64 has a 4:3 ratio + $offset = $avgLength = floor($length * $ratio * .75); + + for ($i = 0; $i < $mb_length; $i += $offset) { + $lookBack = 0; + + do { + $offset = $avgLength - $lookBack; + $chunk = mb_substr($str, $i, $offset, $this->CharSet); + $chunk = base64_encode($chunk); + $lookBack++; + } + while (strlen($chunk) > $length); + + $encoded .= $chunk . $this->LE; + } + + // Chomp the last linefeed + $encoded = substr($encoded, 0, -strlen($this->LE)); + return $encoded; + } + + /** + * Encode string to quoted-printable. + * Only uses standard PHP, slow, but will always work + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @return string + */ + public function EncodeQPphp( $input = '', $line_max = 76, $space_conv = false) { + $hex = array('0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'); + $lines = preg_split('/(?:\r\n|\r|\n)/', $input); + $eol = "\r\n"; + $escape = '='; + $output = ''; + while( list(, $line) = each($lines) ) { + $linlen = strlen($line); + $newline = ''; + for($i = 0; $i < $linlen; $i++) { + $c = substr( $line, $i, 1 ); + $dec = ord( $c ); + if ( ( $i == 0 ) && ( $dec == 46 ) ) { // convert first point in the line into =2E + $c = '=2E'; + } + if ( $dec == 32 ) { + if ( $i == ( $linlen - 1 ) ) { // convert space at eol only + $c = '=20'; + } else if ( $space_conv ) { + $c = '=20'; + } + } elseif ( ($dec == 61) || ($dec < 32 ) || ($dec > 126) ) { // always encode "\t", which is *not* required + $h2 = floor($dec/16); + $h1 = floor($dec%16); + $c = $escape.$hex[$h2].$hex[$h1]; + } + if ( (strlen($newline) + strlen($c)) >= $line_max ) { // CRLF is not counted + $output .= $newline.$escape.$eol; // soft line break; " =\r\n" is okay + $newline = ''; + // check if newline first character will be point or not + if ( $dec == 46 ) { + $c = '=2E'; + } + } + $newline .= $c; + } // end of for + $output .= $newline.$eol; + } // end of while + return $output; + } + + /** + * Encode string to RFC2045 (6.7) quoted-printable format + * Uses a PHP5 stream filter to do the encoding about 64x faster than the old version + * Also results in same content as you started with after decoding + * @see EncodeQPphp() + * @access public + * @param string $string the text to encode + * @param integer $line_max Number of chars allowed on a line before wrapping + * @param boolean $space_conv Dummy param for compatibility with existing EncodeQP function + * @return string + * @author Marcus Bointon + */ + public function EncodeQP($string, $line_max = 76, $space_conv = false) { + if (function_exists('quoted_printable_encode')) { //Use native function if it's available (>= PHP5.3) + return quoted_printable_encode($string); + } + $filters = stream_get_filters(); + if (!in_array('convert.*', $filters)) { //Got convert stream filter? + return $this->EncodeQPphp($string, $line_max, $space_conv); //Fall back to old implementation + } + $fp = fopen('php://temp/', 'r+'); + $string = preg_replace('/\r\n?/', $this->LE, $string); //Normalise line breaks + $params = array('line-length' => $line_max, 'line-break-chars' => $this->LE); + $s = stream_filter_append($fp, 'convert.quoted-printable-encode', STREAM_FILTER_READ, $params); + fputs($fp, $string); + rewind($fp); + $out = stream_get_contents($fp); + stream_filter_remove($s); + $out = preg_replace('/^\./m', '=2E', $out); //Encode . if it is first char on a line, workaround for bug in Exchange + fclose($fp); + return $out; + } + + /** + * Encode string to q encoding. + * @link http://tools.ietf.org/html/rfc2047 + * @param string $str the text to encode + * @param string $position Where the text is going to be used, see the RFC for what that means + * @access public + * @return string + */ + public function EncodeQ ($str, $position = 'text') { + // There should not be any EOL in the string + $encoded = preg_replace('/[\r\n]*/', '', $str); + + switch (strtolower($position)) { + case 'phrase': + $encoded = preg_replace("/([^A-Za-z0-9!*+\/ -])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + case 'comment': + $encoded = preg_replace("/([\(\)\"])/e", "'='.sprintf('%02X', ord('\\1'))", $encoded); + case 'text': + default: + // Replace every high ascii, control =, ? and _ characters + //TODO using /e (equivalent to eval()) is probably not a good idea + $encoded = preg_replace('/([\000-\011\013\014\016-\037\075\077\137\177-\377])/e', + "'='.sprintf('%02X', ord('\\1'))", $encoded); + break; + } + + // Replace every spaces to _ (more readable than =20) + $encoded = str_replace(' ', '_', $encoded); + + return $encoded; + } + + /** + * Adds a string or binary attachment (non-filesystem) to the list. + * This method can be used to attach ascii or binary data, + * such as a BLOB record from a database. + * @param string $string String attachment data. + * @param string $filename Name of the attachment. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return void + */ + public function AddStringAttachment($string, $filename, $encoding = 'base64', $type = 'application/octet-stream') { + // Append to $attachment array + $this->attachment[] = array( + 0 => $string, + 1 => $filename, + 2 => basename($filename), + 3 => $encoding, + 4 => $type, + 5 => true, // isStringAttachment + 6 => 'attachment', + 7 => 0 + ); + } + + /** + * Adds an embedded attachment. This can include images, sounds, and + * just about any other document. Make sure to set the $type to an + * image type. For JPEG images use "image/jpeg" and for GIF images + * use "image/gif". + * @param string $path Path to the attachment. + * @param string $cid Content ID of the attachment. Use this to identify + * the Id for accessing the image in an HTML form. + * @param string $name Overrides the attachment name. + * @param string $encoding File encoding (see $Encoding). + * @param string $type File extension (MIME) type. + * @return bool + */ + public function AddEmbeddedImage($path, $cid, $name = '', $encoding = 'base64', $type = 'application/octet-stream') { + + if ( !@is_file($path) ) { + $this->SetError($this->Lang('file_access') . $path); + return false; + } + + $filename = basename($path); + if ( $name == '' ) { + $name = $filename; + } + + // Append to $attachment array + $this->attachment[] = array( + 0 => $path, + 1 => $filename, + 2 => $name, + 3 => $encoding, + 4 => $type, + 5 => false, // isStringAttachment + 6 => 'inline', + 7 => $cid + ); + + return true; + } + + /** + * Returns true if an inline attachment is present. + * @access public + * @return bool + */ + public function InlineImageExists() { + foreach($this->attachment as $attachment) { + if ($attachment[6] == 'inline') { + return true; + } + } + return false; + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MESSAGE RESET + ///////////////////////////////////////////////// + + /** + * Clears all recipients assigned in the TO array. Returns void. + * @return void + */ + public function ClearAddresses() { + foreach($this->to as $to) { + unset($this->all_recipients[strtolower($to[0])]); + } + $this->to = array(); + } + + /** + * Clears all recipients assigned in the CC array. Returns void. + * @return void + */ + public function ClearCCs() { + foreach($this->cc as $cc) { + unset($this->all_recipients[strtolower($cc[0])]); + } + $this->cc = array(); + } + + /** + * Clears all recipients assigned in the BCC array. Returns void. + * @return void + */ + public function ClearBCCs() { + foreach($this->bcc as $bcc) { + unset($this->all_recipients[strtolower($bcc[0])]); + } + $this->bcc = array(); + } + + /** + * Clears all recipients assigned in the ReplyTo array. Returns void. + * @return void + */ + public function ClearReplyTos() { + $this->ReplyTo = array(); + } + + /** + * Clears all recipients assigned in the TO, CC and BCC + * array. Returns void. + * @return void + */ + public function ClearAllRecipients() { + $this->to = array(); + $this->cc = array(); + $this->bcc = array(); + $this->all_recipients = array(); + } + + /** + * Clears all previously set filesystem, string, and binary + * attachments. Returns void. + * @return void + */ + public function ClearAttachments() { + $this->attachment = array(); + } + + /** + * Clears all custom headers. Returns void. + * @return void + */ + public function ClearCustomHeaders() { + $this->CustomHeader = array(); + } + + ///////////////////////////////////////////////// + // CLASS METHODS, MISCELLANEOUS + ///////////////////////////////////////////////// + + /** + * Adds the error message to the error container. + * @access protected + * @return void + */ + protected function SetError($msg) { + $this->error_count++; + if ($this->Mailer == 'smtp' and !is_null($this->smtp)) { + $lasterror = $this->smtp->getError(); + if (!empty($lasterror) and array_key_exists('smtp_msg', $lasterror)) { + $msg .= '

    ' . $this->Lang('smtp_error') . $lasterror['smtp_msg'] . "

    \n"; + } + } + $this->ErrorInfo = $msg; + } + + /** + * Returns the proper RFC 822 formatted date. + * @access public + * @return string + * @static + */ + public static function RFCDate() { + $tz = date('Z'); + $tzs = ($tz < 0) ? '-' : '+'; + $tz = abs($tz); + $tz = (int)($tz/3600)*100 + ($tz%3600)/60; + $result = sprintf("%s %s%04d", date('D, j M Y H:i:s'), $tzs, $tz); + + return $result; + } + + /** + * Returns the server hostname or 'localhost.localdomain' if unknown. + * @access private + * @return string + */ + private function ServerHostname() { + if (!empty($this->Hostname)) { + $result = $this->Hostname; + } elseif (isset($_SERVER['SERVER_NAME'])) { + $result = $_SERVER['SERVER_NAME']; + } else { + $result = 'localhost.localdomain'; + } + + return $result; + } + + /** + * Returns a message in the appropriate language. + * @access private + * @return string + */ + private function Lang($key) { + if(count($this->language) < 1) { + $this->SetLanguage('en'); // set the default language + } + + if(isset($this->language[$key])) { + return $this->language[$key]; + } else { + return 'Language string failed to load: ' . $key; + } + } + + /** + * Returns true if an error occurred. + * @access public + * @return bool + */ + public function IsError() { + return ($this->error_count > 0); + } + + /** + * Changes every end of line from CR or LF to CRLF. + * @access private + * @return string + */ + private function FixEOL($str) { + $str = str_replace("\r\n", "\n", $str); + $str = str_replace("\r", "\n", $str); + $str = str_replace("\n", $this->LE, $str); + return $str; + } + + /** + * Adds a custom header. + * @access public + * @return void + */ + public function AddCustomHeader($custom_header) { + $this->CustomHeader[] = explode(':', $custom_header, 2); + } + + /** + * Evaluates the message and returns modifications for inline images and backgrounds + * @access public + * @return $message + */ + public function MsgHTML($message, $basedir = '') { + preg_match_all("/(src|background)=\"(.*)\"/Ui", $message, $images); + if(isset($images[2])) { + foreach($images[2] as $i => $url) { + // do not change urls for absolute images (thanks to corvuscorax) + if (!preg_match('#^[A-z]+://#',$url)) { + $filename = basename($url); + $directory = dirname($url); + ($directory == '.')?$directory='':''; + $cid = 'cid:' . md5($filename); + $ext = pathinfo($filename, PATHINFO_EXTENSION); + $mimeType = self::_mime_types($ext); + if ( strlen($basedir) > 1 && substr($basedir,-1) != '/') { $basedir .= '/'; } + if ( strlen($directory) > 1 && substr($directory,-1) != '/') { $directory .= '/'; } + if ( $this->AddEmbeddedImage($basedir.$directory.$filename, md5($filename), $filename, 'base64',$mimeType) ) { + $message = preg_replace("/".$images[1][$i]."=\"".preg_quote($url, '/')."\"/Ui", $images[1][$i]."=\"".$cid."\"", $message); + } + } + } + } + $this->IsHTML(true); + $this->Body = $message; + $textMsg = trim(strip_tags(preg_replace('/<(head|title|style|script)[^>]*>.*?<\/\\1>/s','',$message))); + if (!empty($textMsg) && empty($this->AltBody)) { + $this->AltBody = html_entity_decode($textMsg); + } + if (empty($this->AltBody)) { + $this->AltBody = 'To view this email message, open it in a program that understands HTML!' . "\n\n"; + } + } + + /** + * Gets the MIME type of the embedded or inline image + * @param string File extension + * @access public + * @return string MIME type of ext + * @static + */ + public static function _mime_types($ext = '') { + $mimes = array( + 'hqx' => 'application/mac-binhex40', + 'cpt' => 'application/mac-compactpro', + 'doc' => 'application/msword', + 'bin' => 'application/macbinary', + 'dms' => 'application/octet-stream', + 'lha' => 'application/octet-stream', + 'lzh' => 'application/octet-stream', + 'exe' => 'application/octet-stream', + 'class' => 'application/octet-stream', + 'psd' => 'application/octet-stream', + 'so' => 'application/octet-stream', + 'sea' => 'application/octet-stream', + 'dll' => 'application/octet-stream', + 'oda' => 'application/oda', + 'pdf' => 'application/pdf', + 'ai' => 'application/postscript', + 'eps' => 'application/postscript', + 'ps' => 'application/postscript', + 'smi' => 'application/smil', + 'smil' => 'application/smil', + 'mif' => 'application/vnd.mif', + 'xls' => 'application/vnd.ms-excel', + 'ppt' => 'application/vnd.ms-powerpoint', + 'wbxml' => 'application/vnd.wap.wbxml', + 'wmlc' => 'application/vnd.wap.wmlc', + 'dcr' => 'application/x-director', + 'dir' => 'application/x-director', + 'dxr' => 'application/x-director', + 'dvi' => 'application/x-dvi', + 'gtar' => 'application/x-gtar', + 'php' => 'application/x-httpd-php', + 'php4' => 'application/x-httpd-php', + 'php3' => 'application/x-httpd-php', + 'phtml' => 'application/x-httpd-php', + 'phps' => 'application/x-httpd-php-source', + 'js' => 'application/x-javascript', + 'swf' => 'application/x-shockwave-flash', + 'sit' => 'application/x-stuffit', + 'tar' => 'application/x-tar', + 'tgz' => 'application/x-tar', + 'xhtml' => 'application/xhtml+xml', + 'xht' => 'application/xhtml+xml', + 'zip' => 'application/zip', + 'mid' => 'audio/midi', + 'midi' => 'audio/midi', + 'mpga' => 'audio/mpeg', + 'mp2' => 'audio/mpeg', + 'mp3' => 'audio/mpeg', + 'aif' => 'audio/x-aiff', + 'aiff' => 'audio/x-aiff', + 'aifc' => 'audio/x-aiff', + 'ram' => 'audio/x-pn-realaudio', + 'rm' => 'audio/x-pn-realaudio', + 'rpm' => 'audio/x-pn-realaudio-plugin', + 'ra' => 'audio/x-realaudio', + 'rv' => 'video/vnd.rn-realvideo', + 'wav' => 'audio/x-wav', + 'bmp' => 'image/bmp', + 'gif' => 'image/gif', + 'jpeg' => 'image/jpeg', + 'jpg' => 'image/jpeg', + 'jpe' => 'image/jpeg', + 'png' => 'image/png', + 'tiff' => 'image/tiff', + 'tif' => 'image/tiff', + 'css' => 'text/css', + 'html' => 'text/html', + 'htm' => 'text/html', + 'shtml' => 'text/html', + 'txt' => 'text/plain', + 'text' => 'text/plain', + 'log' => 'text/plain', + 'rtx' => 'text/richtext', + 'rtf' => 'text/rtf', + 'xml' => 'text/xml', + 'xsl' => 'text/xml', + 'mpeg' => 'video/mpeg', + 'mpg' => 'video/mpeg', + 'mpe' => 'video/mpeg', + 'qt' => 'video/quicktime', + 'mov' => 'video/quicktime', + 'avi' => 'video/x-msvideo', + 'movie' => 'video/x-sgi-movie', + 'doc' => 'application/msword', + 'word' => 'application/msword', + 'xl' => 'application/excel', + 'eml' => 'message/rfc822' + ); + return (!isset($mimes[strtolower($ext)])) ? 'application/octet-stream' : $mimes[strtolower($ext)]; + } + + /** + * Set (or reset) Class Objects (variables) + * + * Usage Example: + * $page->set('X-Priority', '3'); + * + * @access public + * @param string $name Parameter Name + * @param mixed $value Parameter Value + * NOTE: will not work with arrays, there are no arrays to set/reset + * @todo Should this not be using __set() magic function? + */ + public function set($name, $value = '') { + try { + if (isset($this->$name) ) { + $this->$name = $value; + } else { + throw new phpmailerException($this->Lang('variable_set') . $name, self::STOP_CRITICAL); + } + } catch (Exception $e) { + $this->SetError($e->getMessage()); + if ($e->getCode() == self::STOP_CRITICAL) { + return false; + } + } + return true; + } + + /** + * Strips newlines to prevent header injection. + * @access public + * @param string $str String + * @return string + */ + public function SecureHeader($str) { + $str = str_replace("\r", '', $str); + $str = str_replace("\n", '', $str); + return trim($str); + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function Sign($cert_filename, $key_filename, $key_pass) { + $this->sign_cert_file = $cert_filename; + $this->sign_key_file = $key_filename; + $this->sign_key_pass = $key_pass; + } + + /** + * Set the private key file and password to sign the message. + * + * @access public + * @param string $key_filename Parameter File Name + * @param string $key_pass Password for private key + */ + public function DKIM_QP($txt) { + $tmp=""; + $line=""; + for ($i=0;$iDKIM_private); + if ($this->DKIM_passphrase!='') { + $privKey = openssl_pkey_get_private($privKeyStr,$this->DKIM_passphrase); + } else { + $privKey = $privKeyStr; + } + if (openssl_sign($s, $signature, $privKey)) { + return base64_encode($signature); + } + } + + /** + * Generate DKIM Canonicalization Header + * + * @access public + * @param string $s Header + */ + public function DKIM_HeaderC($s) { + $s=preg_replace("/\r\n\s+/"," ",$s); + $lines=explode("\r\n",$s); + foreach ($lines as $key=>$line) { + list($heading,$value)=explode(":",$line,2); + $heading=strtolower($heading); + $value=preg_replace("/\s+/"," ",$value) ; // Compress useless spaces + $lines[$key]=$heading.":".trim($value) ; // Don't forget to remove WSP around the value + } + $s=implode("\r\n",$lines); + return $s; + } + + /** + * Generate DKIM Canonicalization Body + * + * @access public + * @param string $body Message Body + */ + public function DKIM_BodyC($body) { + if ($body == '') return "\r\n"; + // stabilize line endings + $body=str_replace("\r\n","\n",$body); + $body=str_replace("\n","\r\n",$body); + // END stabilize line endings + while (substr($body,strlen($body)-4,4) == "\r\n\r\n") { + $body=substr($body,0,strlen($body)-2); + } + return $body; + } + + /** + * Create the DKIM header, body, as new header + * + * @access public + * @param string $headers_line Header lines + * @param string $subject Subject + * @param string $body Body + */ + public function DKIM_Add($headers_line,$subject,$body) { + $DKIMsignatureType = 'rsa-sha1'; // Signature & hash algorithms + $DKIMcanonicalization = 'relaxed/simple'; // Canonicalization of header/body + $DKIMquery = 'dns/txt'; // Query method + $DKIMtime = time() ; // Signature Timestamp = seconds since 00:00:00 - Jan 1, 1970 (UTC time zone) + $subject_header = "Subject: $subject"; + $headers = explode("\r\n",$headers_line); + foreach($headers as $header) { + if (strpos($header,'From:') === 0) { + $from_header=$header; + } elseif (strpos($header,'To:') === 0) { + $to_header=$header; + } + } + $from = str_replace('|','=7C',$this->DKIM_QP($from_header)); + $to = str_replace('|','=7C',$this->DKIM_QP($to_header)); + $subject = str_replace('|','=7C',$this->DKIM_QP($subject_header)) ; // Copied header fields (dkim-quoted-printable + $body = $this->DKIM_BodyC($body); + $DKIMlen = strlen($body) ; // Length of body + $DKIMb64 = base64_encode(pack("H*", sha1($body))) ; // Base64 of packed binary SHA-1 hash of body + $ident = ($this->DKIM_identity == '')? '' : " i=" . $this->DKIM_identity . ";"; + $dkimhdrs = "DKIM-Signature: v=1; a=" . $DKIMsignatureType . "; q=" . $DKIMquery . "; l=" . $DKIMlen . "; s=" . $this->DKIM_selector . ";\r\n". + "\tt=" . $DKIMtime . "; c=" . $DKIMcanonicalization . ";\r\n". + "\th=From:To:Subject;\r\n". + "\td=" . $this->DKIM_domain . ";" . $ident . "\r\n". + "\tz=$from\r\n". + "\t|$to\r\n". + "\t|$subject;\r\n". + "\tbh=" . $DKIMb64 . ";\r\n". + "\tb="; + $toSign = $this->DKIM_HeaderC($from_header . "\r\n" . $to_header . "\r\n" . $subject_header . "\r\n" . $dkimhdrs); + $signed = $this->DKIM_Sign($toSign); + return "X-PHPMAILER-DKIM: phpmailer.worxware.com\r\n".$dkimhdrs.$signed."\r\n"; + } + + protected function doCallback($isSent,$to,$cc,$bcc,$subject,$body) { + if (!empty($this->action_function) && function_exists($this->action_function)) { + $params = array($isSent,$to,$cc,$bcc,$subject,$body); + call_user_func_array($this->action_function,$params); + } + } +} + +class phpmailerException extends Exception { + public function errorMessage() { + $errorMsg = '' . $this->getMessage() . "
    \n"; + return $errorMsg; + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/phpmailer/class.smtp.php b/upload/includes/classes/phpmailer/class.smtp.php new file mode 100644 index 00000000..c2ca1cb3 --- /dev/null +++ b/upload/includes/classes/phpmailer/class.smtp.php @@ -0,0 +1,814 @@ +smtp_conn = 0; + $this->error = null; + $this->helo_rply = null; + + $this->do_debug = 0; + } + + ///////////////////////////////////////////////// + // CONNECTION FUNCTIONS + ///////////////////////////////////////////////// + + /** + * Connect to the server specified on the port specified. + * If the port is not specified use the default SMTP_PORT. + * If tval is specified then a connection will try and be + * established with the server for that number of seconds. + * If tval is not specified the default is 30 seconds to + * try on the connection. + * + * SMTP CODE SUCCESS: 220 + * SMTP CODE FAILURE: 421 + * @access public + * @return bool + */ + public function Connect($host, $port = 0, $tval = 30) { + // set the error val to null so there is no confusion + $this->error = null; + + // make sure we are __not__ connected + if($this->connected()) { + // already connected, generate error + $this->error = array("error" => "Already connected to a server"); + return false; + } + + if(empty($port)) { + $port = $this->SMTP_PORT; + } + + // connect to the smtp server + $this->smtp_conn = @fsockopen($host, // the host of the server + $port, // the port to use + $errno, // error number if any + $errstr, // error message if any + $tval); // give up after ? secs + // verify we connected properly + if(empty($this->smtp_conn)) { + $this->error = array("error" => "Failed to connect to server", + "errno" => $errno, + "errstr" => $errstr); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": $errstr ($errno)" . $this->CRLF . '
    '; + } + return false; + } + + // SMTP server can take longer to respond, give longer timeout for first read + // Windows does not have support for this timeout function + if(substr(PHP_OS, 0, 3) != "WIN") + socket_set_timeout($this->smtp_conn, $tval, 0); + + // get any announcement + $announce = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $announce . $this->CRLF . '
    '; + } + + return true; + } + + /** + * Initiate a TLS communication with the server. + * + * SMTP CODE 220 Ready to start TLS + * SMTP CODE 501 Syntax error (no parameters allowed) + * SMTP CODE 454 TLS not available due to temporary reason + * @access public + * @return bool success + */ + public function StartTLS() { + $this->error = null; # to avoid confusion + + if(!$this->connected()) { + $this->error = array("error" => "Called StartTLS() without being connected"); + return false; + } + + fputs($this->smtp_conn,"STARTTLS" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 220) { + $this->error = + array("error" => "STARTTLS not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + // Begin encrypted connection + if(!stream_socket_enable_crypto($this->smtp_conn, true, STREAM_CRYPTO_METHOD_TLS_CLIENT)) { + return false; + } + + return true; + } + + /** + * Performs SMTP authentication. Must be run after running the + * Hello() method. Returns true if successfully authenticated. + * @access public + * @return bool + */ + public function Authenticate($username, $password) { + // Start authentication + fputs($this->smtp_conn,"AUTH LOGIN" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "AUTH not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + // Send encoded username + fputs($this->smtp_conn, base64_encode($username) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 334) { + $this->error = + array("error" => "Username not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + // Send encoded password + fputs($this->smtp_conn, base64_encode($password) . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($code != 235) { + $this->error = + array("error" => "Password not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + return true; + } + + /** + * Returns true if connected to a server otherwise false + * @access public + * @return bool + */ + public function Connected() { + if(!empty($this->smtp_conn)) { + $sock_status = socket_get_status($this->smtp_conn); + if($sock_status["eof"]) { + // the socket is valid but we are not connected + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE:" . $this->CRLF . "EOF caught while checking if connected"; + } + $this->Close(); + return false; + } + return true; // everything looks good + } + return false; + } + + /** + * Closes the socket and cleans up the state of the class. + * It is not considered good to use this function without + * first trying to use QUIT. + * @access public + * @return void + */ + public function Close() { + $this->error = null; // so there is no confusion + $this->helo_rply = null; + if(!empty($this->smtp_conn)) { + // close the connection and cleanup + fclose($this->smtp_conn); + $this->smtp_conn = 0; + } + } + + ///////////////////////////////////////////////// + // SMTP COMMANDS + ///////////////////////////////////////////////// + + /** + * Issues a data command and sends the msg_data to the server + * finializing the mail transaction. $msg_data is the message + * that is to be send with the headers. Each header needs to be + * on a single line followed by a with the message headers + * and the message body being seperated by and additional . + * + * Implements rfc 821: DATA + * + * SMTP CODE INTERMEDIATE: 354 + * [data] + * . + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 552,554,451,452 + * SMTP CODE FAILURE: 451,554 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Data($msg_data) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Data() without being connected"); + return false; + } + + fputs($this->smtp_conn,"DATA" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 354) { + $this->error = + array("error" => "DATA command not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + /* the server is ready to accept data! + * according to rfc 821 we should not send more than 1000 + * including the CRLF + * characters on a single line so we will break the data up + * into lines by \r and/or \n then if needed we will break + * each of those into smaller lines to fit within the limit. + * in addition we will be looking for lines that start with + * a period '.' and append and additional period '.' to that + * line. NOTE: this does not count towards limit. + */ + + // normalize the line breaks so we know the explode works + $msg_data = str_replace("\r\n","\n",$msg_data); + $msg_data = str_replace("\r","\n",$msg_data); + $lines = explode("\n",$msg_data); + + /* we need to find a good way to determine is headers are + * in the msg_data or if it is a straight msg body + * currently I am assuming rfc 822 definitions of msg headers + * and if the first field of the first line (':' sperated) + * does not contain a space then it _should_ be a header + * and we can process all lines before a blank "" line as + * headers. + */ + + $field = substr($lines[0],0,strpos($lines[0],":")); + $in_headers = false; + if(!empty($field) && !strstr($field," ")) { + $in_headers = true; + } + + $max_line_length = 998; // used below; set here for ease in change + + while(list(,$line) = @each($lines)) { + $lines_out = null; + if($line == "" && $in_headers) { + $in_headers = false; + } + // ok we need to break this line up into several smaller lines + while(strlen($line) > $max_line_length) { + $pos = strrpos(substr($line,0,$max_line_length)," "); + + // Patch to fix DOS attack + if(!$pos) { + $pos = $max_line_length - 1; + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos); + } else { + $lines_out[] = substr($line,0,$pos); + $line = substr($line,$pos + 1); + } + + /* if processing headers add a LWSP-char to the front of new line + * rfc 822 on long msg headers + */ + if($in_headers) { + $line = "\t" . $line; + } + } + $lines_out[] = $line; + + // send the lines to the server + while(list(,$line_out) = @each($lines_out)) { + if(strlen($line_out) > 0) + { + if(substr($line_out, 0, 1) == ".") { + $line_out = "." . $line_out; + } + } + fputs($this->smtp_conn,$line_out . $this->CRLF); + } + } + + // message data has been sent + fputs($this->smtp_conn, $this->CRLF . "." . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 250) { + $this->error = + array("error" => "DATA not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + return true; + } + + /** + * Sends the HELO command to the smtp server. + * This makes sure that we and the server are in + * the same known state. + * + * Implements from rfc 821: HELO + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500, 501, 504, 421 + * @access public + * @return bool + */ + public function Hello($host = '') { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Hello() without being connected"); + return false; + } + + // if hostname for HELO was not specified send default + if(empty($host)) { + // determine appropriate default to send to server + $host = "localhost"; + } + + // Send extended hello first (RFC 2821) + if(!$this->SendHello("EHLO", $host)) { + if(!$this->SendHello("HELO", $host)) { + return false; + } + } + + return true; + } + + /** + * Sends a HELO/EHLO command. + * @access private + * @return bool + */ + private function SendHello($hello, $host) { + fputs($this->smtp_conn, $hello . " " . $host . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER: " . $rply . $this->CRLF . '
    '; + } + + if($code != 250) { + $this->error = + array("error" => $hello . " not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + $this->helo_rply = $rply; + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. + * + * Implements rfc 821: MAIL FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,421 + * @access public + * @return bool + */ + public function Mail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Mail() without being connected"); + return false; + } + + $useVerp = ($this->do_verp ? "XVERP" : ""); + fputs($this->smtp_conn,"MAIL FROM:<" . $from . ">" . $useVerp . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 250) { + $this->error = + array("error" => "MAIL not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + return true; + } + + /** + * Sends the quit command to the server and then closes the socket + * if there is no error or the $close_on_error argument is true. + * + * Implements from rfc 821: QUIT + * + * SMTP CODE SUCCESS: 221 + * SMTP CODE ERROR : 500 + * @access public + * @return bool + */ + public function Quit($close_on_error = true) { + $this->error = null; // so there is no confusion + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Quit() without being connected"); + return false; + } + + // send the quit command to the server + fputs($this->smtp_conn,"quit" . $this->CRLF); + + // get any good-bye messages + $byemsg = $this->get_lines(); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $byemsg . $this->CRLF . '
    '; + } + + $rval = true; + $e = null; + + $code = substr($byemsg,0,3); + if($code != 221) { + // use e as a tmp var cause Close will overwrite $this->error + $e = array("error" => "SMTP server rejected quit command", + "smtp_code" => $code, + "smtp_rply" => substr($byemsg,4)); + $rval = false; + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $e["error"] . ": " . $byemsg . $this->CRLF . '
    '; + } + } + + if(empty($e) || $close_on_error) { + $this->Close(); + } + + return $rval; + } + + /** + * Sends the command RCPT to the SMTP server with the TO: argument of $to. + * Returns true if the recipient was accepted false if it was rejected. + * + * Implements from rfc 821: RCPT TO: + * + * SMTP CODE SUCCESS: 250,251 + * SMTP CODE FAILURE: 550,551,552,553,450,451,452 + * SMTP CODE ERROR : 500,501,503,421 + * @access public + * @return bool + */ + public function Recipient($to) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Recipient() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RCPT TO:<" . $to . ">" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 250 && $code != 251) { + $this->error = + array("error" => "RCPT not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + return true; + } + + /** + * Sends the RSET command to abort and transaction that is + * currently in progress. Returns true if successful false + * otherwise. + * + * Implements rfc 821: RSET + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE ERROR : 500,501,504,421 + * @access public + * @return bool + */ + public function Reset() { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called Reset() without being connected"); + return false; + } + + fputs($this->smtp_conn,"RSET" . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 250) { + $this->error = + array("error" => "RSET failed", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + + return true; + } + + /** + * Starts a mail transaction from the email address specified in + * $from. Returns true if successful or false otherwise. If True + * the mail transaction is started and then one or more Recipient + * commands may be called followed by a Data command. This command + * will send the message to the users terminal if they are logged + * in and send them an email. + * + * Implements rfc 821: SAML FROM: + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE SUCCESS: 552,451,452 + * SMTP CODE SUCCESS: 500,501,502,421 + * @access public + * @return bool + */ + public function SendAndMail($from) { + $this->error = null; // so no confusion is caused + + if(!$this->connected()) { + $this->error = array( + "error" => "Called SendAndMail() without being connected"); + return false; + } + + fputs($this->smtp_conn,"SAML FROM:" . $from . $this->CRLF); + + $rply = $this->get_lines(); + $code = substr($rply,0,3); + + if($this->do_debug >= 2) { + echo "SMTP -> FROM SERVER:" . $rply . $this->CRLF . '
    '; + } + + if($code != 250) { + $this->error = + array("error" => "SAML not accepted from server", + "smtp_code" => $code, + "smtp_msg" => substr($rply,4)); + if($this->do_debug >= 1) { + echo "SMTP -> ERROR: " . $this->error["error"] . ": " . $rply . $this->CRLF . '
    '; + } + return false; + } + return true; + } + + /** + * This is an optional command for SMTP that this class does not + * support. This method is here to make the RFC821 Definition + * complete for this class and __may__ be implimented in the future + * + * Implements from rfc 821: TURN + * + * SMTP CODE SUCCESS: 250 + * SMTP CODE FAILURE: 502 + * SMTP CODE ERROR : 500, 503 + * @access public + * @return bool + */ + public function Turn() { + $this->error = array("error" => "This method, TURN, of the SMTP ". + "is not implemented"); + if($this->do_debug >= 1) { + echo "SMTP -> NOTICE: " . $this->error["error"] . $this->CRLF . '
    '; + } + return false; + } + + /** + * Get the current error + * @access public + * @return array + */ + public function getError() { + return $this->error; + } + + ///////////////////////////////////////////////// + // INTERNAL FUNCTIONS + ///////////////////////////////////////////////// + + /** + * Read in as many lines as possible + * either before eof or socket timeout occurs on the operation. + * With SMTP we can tell if we have more lines to read if the + * 4th character is '-' symbol. If it is a space then we don't + * need to read anything else. + * @access private + * @return string + */ + private function get_lines() { + $data = ""; + while($str = @fgets($this->smtp_conn,515)) { + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data was \"$data\"" . $this->CRLF . '
    '; + echo "SMTP -> get_lines(): \$str is \"$str\"" . $this->CRLF . '
    '; + } + $data .= $str; + if($this->do_debug >= 4) { + echo "SMTP -> get_lines(): \$data is \"$data\"" . $this->CRLF . '
    '; + } + // if 4th character is a space, we are done reading, break the loop + if(substr($str,3,1) == " ") { break; } + } + return $data; + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/player.class.php b/upload/includes/classes/player.class.php new file mode 100644 index 00000000..a5e5aa43 --- /dev/null +++ b/upload/includes/classes/player.class.php @@ -0,0 +1,213 @@ +getPlayerDetails($player_file); + if(!empty($player_details['name'])) + $player_array[]= $player_details; + } + + //Now Reading Sub Dir Files + foreach($subitem_list as $sub_dir => $sub_dir_list ) + { + foreach($subitem_list[$sub_dir] as $player_file) + { + $player_details = $this->getPlayerDetails($player_file,$sub_dir); + $player_details['dir'] = $player_details['folder'] = $sub_dir; + if(!empty($player_details['name'])) + $player_array[] = $player_details; + } + } + + return $player_array; + } + + /** + * Function used to get ClipBucket Player + */ + function get_players() + { + return $this->getPlayers(); + } + + /** + * Function used to get player details + * @input = file + */ + function get_player_details($player_file,$sub_dir=NULL) + { + if($sub_dir!='') + $sub_dir = $sub_dir.'/'; + + $file = PLAYER_DIR.'/'.$sub_dir.$player_file; + if(file_exists($file) && is_file($file)) + { + // We don't need to write to the file, so just open for reading. + $fp = fopen($file, 'r'); + // Pull only the first 8kiB of the file in. + $plugin_data = fread( $fp, 8192 ); + // PHP will close file handle, but we are good citizens. + fclose($fp); + preg_match( '/Player Name:(.*)$/mi', $plugin_data, $name ); + preg_match( '/Website:(.*)$/mi', $plugin_data, $website ); + preg_match( '/Version:(.*)/mi', $plugin_data, $version ); + preg_match( '/Description:(.*)$/mi', $plugin_data, $description ); + preg_match( '/Author:(.*)$/mi', $plugin_data, $author ); + preg_match( '/Author Website:(.*)$/mi', $plugin_data, $author_page ); + preg_match( '/ClipBucket Version:(.*)$/mi', $plugin_data, $cbversion ); + preg_match( '/Player Type:(.*)$/mi', $plugin_data, $type ); + preg_match( '/Released:(.*)$/mi', $plugin_data, $released ); + + $details_array = array + ( + 'name', + 'website', + 'version', + 'description', + 'author', + 'cbversion', + 'author_page', + 'code', + 'type', + 'released', + + ); + foreach ($details_array as $detail) + { + $plugin_array[$detail]=${$detail}[1]; + } + $plugin_array['file'] = $player_file; + $plugin_array['dir'] = $plugin_array['folder'] = $sub_dir; + $plugin_array['code'] = preg_replace('/\s/', '', $code[1]); + + return $plugin_array; + }else{ + return false; + } + } + function getPlayerDetails($file,$sub_dir=NULL) + { + return $this->get_player_details($file,$sub_dir); + } + + + /** + * Function used to get template thumb + */ + function get_preview_thumb($player) + { + $path = $player.'/preview.'; + $exts = array('png','jpg','gif'); + $thumb_path = BASEURL.'/images/icons/no_thumb_player.png'; + foreach($exts as $ext) + { + $file = PLAYER_DIR.'/'.$path.$ext; + if(file_exists($file)) + { + $thumb_path = PLAYER_URL.'/'.$path.$ext; + break; + } + } + return $thumb_path; + } + + /** + * Function used to set player for ClipBucket + */ + function set_player($details) + { + global $myquery; + + if($this->getPlayerDetails($details['file'],$details['folder'])) + { + $myquery->Set_Website_Details('player_file',$details['file']); + $myquery->Set_Website_Details('player_dir',$details['folder']); + e(lang("player_activated"),'m'); + }else + e(lang("error_occured_while_activating_player")); + } + function setplayer($details) + { + return $this->set_player($details); + } + +} + + /** + * this is for pak player + */ + + function fb_embed_video($params) + { + $fb_embed_funcs = cb_get_functions('fb_embed_video'); + if($fb_embed_funcs) + { + foreach($fb_embed_funcs as $func) + { + if(function_exists($func['func'])) + { + return $func['func']($params); + } + } + } + + $vdetails = $params['video']; + $config = urlencode(BASEURL."/player/pak_player/embed_player.php?vid=".$vdetails['videoid']."&json=true&autoplay=yes"); + if(!config('pak_license')) + $embed_src = BASEURL.'/player/pak_player/pakplayer.swf?config='.$config; + else + $embed_src = BASEURL.'/player/pak_player/pakplayer.unlimited.swf?config='.$config; + + return $embed_src; + } + +?> \ No newline at end of file diff --git a/upload/includes/classes/playlist.class.php b/upload/includes/classes/playlist.class.php new file mode 100644 index 00000000..34215b69 --- /dev/null +++ b/upload/includes/classes/playlist.class.php @@ -0,0 +1,23 @@ +'cb_user_playlists','playlist_items'=>'playlist_items'); + + + + +} \ No newline at end of file diff --git a/upload/includes/classes/plugin.class.php b/upload/includes/classes/plugin.class.php new file mode 100644 index 00000000..9178d216 --- /dev/null +++ b/upload/includes/classes/plugin.class.php @@ -0,0 +1,393 @@ +getPluginDetails($plugin_file); + if(!empty($plugin_details['name'])) + $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; + } + + function getPluginList() + { + return $this->getPlugins(); + } + + + /** + * Function used to get new plugins, that are not installed yet + */ + function getNewPlugins() + { + //first get list of all plugins + $plugin_list = $this->getPluginList(); + + //Now Checking if plugin is installed or not + if(is_array($plugin_list)) + { + foreach($plugin_list as $plugin) + { + if(!$this->is_installed($plugin['file'])) + $plug_array[] = $plugin; + } + return $plug_array; + } + } + + + /** + * Function used to get new plugins, that are not installed yet + */ + function getInstalledPlugins() + { + global $db; + //first get list of all plugins + $plugin_list = $this->getPluginList(); + + if(FRONT_END) + $active_query = " plugin_active='yes' "; + else + $active_query = NULL; + $results = $db->select(tbl("plugins"),"*",$active_query); + + if(is_array($results)) + foreach($results as $result) + { + //Now Checking if plugin is installed or not + $this_plugin = $this->get_plugin_details($result['plugin_file'],$result['plugin_folder']); + if($this_plugin) + { + $result['file'] = $result['plugin_file']; + $result['folder'] = $result['plugin_folder']; + $plugin = array_merge($result,$this_plugin); + // pr($plugin); + $plug_array[] = $plugin; + } + + } + + + /* + * OLDER VERSION + foreach($plugin_list as $plugin) + { + + if($this->is_installed($plugin['file'],$plugin['version'],$plugin['folder'])) + { + $plugin = array_merge($plugin,$this->getPlugin($plugin['file'])); + //pr($plugin); + $plug_array[] = $plugin; + } + }*/ + + return $plug_array; + } + + /** + * Function used to check weather plugin is instlled or not + * @param : $plugin_code STRING + */ + function is_installed($file,$v=NULL,$folder=NULL) + { + global $db; + + //if($v) + //$version_check = "AND plugin_version='$v'"; + if($folder) + $folder_check = " AND plugin_folder ='$folder'"; + + $query = "SELECT plugin_file FROM plugins WHERE plugin_file='".$file."' $version_check $folder_check"; + + $details = $db->select(tbl("plugins"),"plugin_file","plugin_file='".$file."' $version_check $folder_check"); + if($db->num_rows>0) + return true; + else + return false; + } + + + /** + * get plugin details + * @param : $file STRING + */ + function get_plugin_details($plug_file,$sub_dir=NULL) + { + 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. + $fp = fopen($file, 'r'); + // Pull only the first 8kiB of the file in. + $plugin_data = fread( $fp, 8192 ); + // PHP will close file handle, but we are good citizens. + fclose($fp); + preg_match( '/Plugin Name:(.*)$/mi', $plugin_data, $name ); + preg_match( '/Website:(.*)$/mi', $plugin_data, $website ); + preg_match( '/Version:(.*)/mi', $plugin_data, $version ); + preg_match( '/Description:(.*)$/mi', $plugin_data, $description ); + preg_match( '/Author:(.*)$/mi', $plugin_data, $author ); + preg_match( '/Author Website:(.*)$/mi', $plugin_data, $author_page ); + preg_match( '/ClpBucket Version:(.*)$/mi', $plugin_data, $cbversion ); + preg_match( '/Plugin Type:(.*)$/mi', $plugin_data, $type ); + + $details_array = array + ( + 'name', + 'website', + 'version', + 'description', + 'author', + 'cbversion', + 'code', + 'author_page', + 'type', + + ); + foreach ($details_array as $detail) + { + $plugin_array[$detail]=${$detail}[1]; + } + $plugin_array['file'] = $plug_file; + $plugin_array['code'] = preg_replace('/\s/', '', $code[1]); + + return $plugin_array; + }else{ + return false; + } + } + function getPluginDetails($file,$sub_dir=NULL) + { + return $this->get_plugin_details($file,$sub_dir); + } + + + + /** + * Function used to get plugin details from database + * @param : plugin_id_code STRING + */ + function getPlugin($file,$folder=NULL) + { + if($folder) + $folder_query = " AND plugin_folder = '$folder'"; + + $result = $db->select(tbl("plugins"),"*"," plugin_file ='".$file."' $folder_query" ); + return $result[0]; + } + + + /** + * ClipBucket Internal Plugin Installer + * @param:plugin + */ + function installPlugin($pluginFile,$folder=NULL) + { + global $db,$LANG,$Cbucket; + $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,$folder)) + $msg = e(lang('plugin_installed_err')); + + if(empty($msg)) + { + $file_folder = $folder; + if($folder!='') + $folder = $folder.'/'; + $plug_details = $this->getPluginDetails(PLUG_DIR.'/'.$folder.$pluginFile); + + if(file_exists(PLUG_DIR.'/'.$folder.'install_'.$pluginFile)) + require_once(PLUG_DIR.'/'.$folder.'install_'.$pluginFile); + + dbInsert + ( + tbl('plugins'), + array( + 'plugin_file', + 'plugin_license_type', + 'plugin_license_key', + 'plugin_license_code', + 'plugin_active', + 'plugin_folder' + ), + array( + $pluginFile, + $plugin_details_array['plugin_license_type'], + $plugin_details_array['plugin_license_key'], + $plugin_details_array['plugin_license_code'], + 'yes', + $file_folder, + ) + ); + + //Checking For the installation SQL + $msg = e(lang('plugin_install_msg'),'m'); + define('NEW_INSTALL',false); + return PLUG_DIR.'/'.$folder.$pluginFile; + } + return false; + } + + /** + * Function used to activate plugin + */ + function pluginActive($plugin_file,$active='yes',$folder=NULL){ + global $db; + + if($folder) + $folder_query = " AND plugin_folder = '$folder'"; + + if($this->is_installed($plugin_file)) + { + $db->Execute("UPDATE ".tbl("plugins")." SET plugin_active='".$active."' WHERE plugin_file='".$plugin_file."' $folder_query"); + $active_msg = $active=='yes' ? 'activated' : 'deactiveted'; + $msg = e(sprintf(lang("plugin_has_been_s"),$active_msg),'m'); + }else{ + $msg = e(lang('plugin_no_install_err')); + } + return $msg; + } + + /** + * Function used to activate plugin + */ + function uninstallPlugin($file,$folder=NULL){ + global $db; + if($this->is_installed($file)) + { + if($folder) + $folder_query = " AND plugin_folder = '$folder'"; + + if($folder!='') + $folder = $folder.'/'; + + $db->Execute("DELETE FROM ".tbl("plugins")." WHERE plugin_file='".$file."' $folder_query"); + if(file_exists(PLUG_DIR.'/'.$folder.'uninstall_'.$file)) + require_once(PLUG_DIR.'/'.$folder.'uninstall_'.$file); + $msg = e(lang("plugin_uninstalled"),"m"); + }else{ + $msg = e(lang('plugin_no_install_err')); + } + return $msg; + } + +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/pm.class.php b/upload/includes/classes/pm.class.php new file mode 100644 index 00000000..90b43d7f --- /dev/null +++ b/upload/includes/classes/pm.class.php @@ -0,0 +1,669 @@ + 'attachment_video' + */ + function attach_video($array) + { + global $cbvid; + if($cbvid->video_exists($array['attach_video'])) + return '{v:'.$array['attach_video'].'}'; + } + + /** + * Function used to pars video from attachemtn + */ + function parse_and_attach_video($att) + { + global $cbvid; + preg_match('/{v:(.*)}/',$att,$matches); + $vkey = $matches[1]; + if(!empty($vkey)) + { + assign('video',$cbvid->get_video_details($vkey)); + assign('only_once',true); + echo '

    Attached Video

    '; + template('blocks/video.html'); + } + } + + /** + * Function used to add custom video attachment form field + */ + function video_attachment_form() + { + global $cbvid; + $vid_array = array('user'=>userid(),'order'=>'date_added DESC','limit'=>15); + $videos = $cbvid->get_videos($vid_array); + $vids_array = array('' => lang("No Video")); + if($videos) + foreach($videos as $video) + { + $vids_array[$video['videokey']] = $video['title']; + } + $field = array( + 'video_form' => array + ('title'=> 'Attach video', + 'type'=>'dropdown', + 'name'=> 'attach_video', + 'id'=> 'attach_video', + 'value'=> $vids_array, + 'checked'=>post('attach_video'), + 'anchor_before'=>'before_video_attach_box', + ) + ); + return $field; + } + + + + +class cb_pm +{ + /** + * Private messages table + */ + var $tbl = 'messages'; + + /** + * Allow multi users + */ + var $multi = true; + + + /** + * Default Template + */ + var $email_template = 'pm_email_message'; + + /** + * Send Email on pm + */ + var $send_email = true; + + /** + * Allow inline attachments + * these attachements are linked in the messages instead of attached like emails + */ + var $allow_attachments = true; + + //Attachment functionss + var $pm_attachments = array('attach_video'); + var $pm_attachments_parse = array('parse_and_attach_video'); + + var $pm_custom_field = array(); + + + /** + * Calling Constructor + */ + function init() + { + $array = video_attachment_form(); + $this->add_custom_field($array); + } + + + + /** + * Sending PM + */ + function send_pm($array) + { + global $userquery,$db; + $to = $this->check_users($array['to'],$array['from']); + + //checking from user + if(!$userquery->user_exists($array['from'])) + { + e(lang('unknown_sender')); + //checking to user + }elseif(!$to) + return false; + //Checking if subject is empty + elseif(empty($array['subj'])) + e(lang('class_subj_err')); + elseif(empty($array['content'])) + e(lang('please_enter_message')); + else + { + $from = $this->get_the_user($array['from']); + $attachments = $this->get_attachments($array); + $type = $array['type'] ? $array['type'] : 'pm'; + $reply_to = $this->is_reply($array['reply_to'],$from); + + $fields = array('message_from','message_to','message_content', + 'message_subject','date_added','message_attachments','message_box','reply_to'); + $values = array($from,$to,$array['content'], + $array['subj'],now(),$attachments); + + //PM INBOX FIELDS + $fields_in = $fields; + //PM INBOX + $values_in = $values; + $values_in[] = 'in'; + $values_in[] = $reply_to; + + $db->insert(tbl($this->tbl),$fields_in,$values_in); + $array['msg_id'] = $db->insert_id(); + if($array['is_pm']) + { + //PM SENTBOX FIELDS + $fields_out = $fields; + $fields_out[] = 'message_status'; + + //PM SENTBOX + $values_out = $values; + $values_out[] = 'out'; + $values_out[] = $reply_to; + $values_out[] = 'read'; + + $db->insert(tbl($this->tbl),$fields_out,$values_out); + } + + //Sending Email + $this->send_pm_email($array); + e(lang("pm_sent_success"),"m"); + } + } + + + /** + * Function used to check input users + * are valid or not + */ + function check_users($input,$sender) + { + global $userquery; + + if(empty($input)) { + e(lang("unknown_reciever")); + } else { + //check if usernames are sperated by colon ';' + $input = preg_replace('/;/',',',$input); + //Now Exploding Input and converting it to and array + $usernames = explode(',',$input); + + //Now Checkinf for valid usernames + $valid_users = array(); + foreach($usernames as $username) + { + $user_id = $this->get_the_user($username); + if($userquery->is_user_banned($username,userid())) { + e(sprintf(lang("cant_pm_banned_user"),$username)); + } elseif($userquery->is_user_banned(username(),$username)){ + e(sprintf(lang("cant_pm_user_banned_you"),$username)); + }elseif(!$userquery->user_exists($username)) { + e(lang("unknown_reciever")); + } elseif($user_id == $sender) { + e(lang("you_cant_send_pm_yourself")); + } else { + $valid_users[] = $user_id; + } + } + + $valid_users = array_unique($valid_users); + + if(count($valid_users)>0) + { + $vusers = ''; + foreach($valid_users as $vu) + { + $vusers .="#".$vu."#"; + } + return $vusers; + } + else + return false; + } + } + + + /** + * Function used to get user + */ + function get_the_user($user) + { + global $userquery; + if(!is_numeric($user)) + return $userquery->get_user_field_only($user,'userid'); + else + return $user; + } + + + /** + * Function used to make attachment valid + * and embed it in the message + */ + function get_attachments($array) + { + $funcs = $this->pm_attachments; + $attachments = ''; + + if(is_array($funcs)) + foreach($funcs as $func) + { + if(function_exists($func)) + { + $attachments .= $func($array); + } + } + return $attachments; + } + + /** + * function used to check weather message is reply or not + */ + function is_reply($id,$uid) + { + global $db; + $results = $db->select(tbl($this->tbl),'message_to'," message_id = '$id' AND message_to LIKE '%#$uid#%'"); + if($db->num_rows>0) + return true; + else + return false; + } + + /** + * Function used to get message from inbox, set the template + * and display it + */ + function get_message($id) + { + global $db; + $result = $db->select(tbl($this->tbl),'*'," message_id='$id'"); + $result = $result[0]; + if($db->num_rows>0) + { + return $result[0]; + }else{ + e(lang('no_pm_exist')); + return false; + } + } + + /** + * Function used to get user INBOX Message + * @param MESSAGE ID + * @param USER ID + */ + function get_inbox_message($mid,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + $result = $db->select(tbl($this->tbl.',users'),tbl($this->tbl.'.*,users.userid,users.username')," message_id='$mid' AND message_to LIKE '%#$uid#%' AND userid=".tbl($this->tbl).".message_from",NULL," date_added DESC "); + + if($db->num_rows>0) + { + return $result[0]; + }else{ + e(lang('no_pm_exist')); + return false; + } + } + + /** + * Function used to get user OUTBOX Message + * @param MESSAGE ID + * @param USER ID + */ + function get_outbox_message($mid,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + $result = $db->select(tbl($this->tbl.',users'),tbl($this->tbl.'.*,users.userid,users.username')," message_id='$mid' AND message_from='$uid' AND userid=".tbl($this->tbl.".message_from")); + + if($db->num_rows>0) + { + return $result[0]; + }else{ + e(lang('no_pm_exist')); + return false; + } + } + + + /** + * Get Total PM + */ + function pm_count() { + global $db; + return $db->count(tbl($this->tbl),'message_id'); + } + + /** + * Function used to get user inbox messages + */ + function get_user_messages($uid,$box='in',$count_only=false) + { + global $db; + + if(!$uid) + $uid = userid(); + switch ($box) + { + + case 'in': + { + if($count_only) + { + $result = $db->count(tbl($this->tbl),'message_id'," message_to LIKE '%#$uid#%' AND message_box ='in' AND message_type='pm' "); + }else{ + $result = $db->select(tbl($this->tbl.',users'),tbl($this->tbl.'.*,users.username AS message_from_user '), + tbl($this->tbl).".message_to LIKE '%#$uid#%' AND ".tbl("users").".userid = ".tbl($this->tbl).".message_from + AND ".tbl($this->tbl).".message_box ='in' AND message_type='pm'",NULL," date_added DESC"); + } + } + break; + + + case 'out': + { + if($count_only) + { + $result = $db->count(tbl($this->tbl),'message_id'," message_from = '$uid' AND message_box ='out' "); + }else{ + $result = $db->select(tbl($this->tbl.',users'),tbl($this->tbl.'.*,users.username AS message_from_user '), + tbl($this->tbl).".message_from = '$uid' AND ".tbl("users").".userid = ".tbl($this->tbl).".message_from + AND ".tbl($this->tbl).".message_box ='out'",NULL," date_added DESC"); + //echo $db->db_query; + //One More Query Need To be executed to get username of recievers + $count = 0; + + $cond = ""; + if(is_array($result)) + foreach($result as $re) + { + + $cond = ''; + preg_match_all("/#(.*)#/Ui",$re['message_to'],$receivers); + //pr($receivers); + foreach($receivers[1] as $to_user) + { + + if(!empty($to_user)) + { + if(!empty($cond)) + $cond .= " OR "; + $cond .= " userid = '$to_user' "; + } + } + + $to_names = $db->select(tbl('users'),'username',$cond); + $t_names = ''; + + if(is_array($to_names)) + foreach($to_names as $tn) + { + $t_names[] = $tn[0]; + } + if(is_array($t_names)) + $to_user_names = implode(', ',$t_names); + else + $to_user_names = $t_names; + $result[$count]['to_usernames'] = $to_user_names; + $count++; + } + } + } + break; + + case 'notification': + { + if($count_only) + { + $result = $db->count(tbl($this->tbl),'message_id'," message_to LIKE '%#$uid#%' AND message_box ='in' AND message_type='pm' "); + }else{ + $result = $db->select(tbl($this->tbl.',users'),tbl($this->tbl.'.*,users.username AS message_from_user '), + tbl($this->tbl).".message_to LIKE '%#$uid#' AND ".tbl("users.userid")." = ".tbl($this->tbl).".message_from + AND ".tbl($this->tbl).".message_box ='in' AND message_type='notification'",NULL," date_added DESC"); + } + } + } + + if($result) + return $result; + else + return false; + + } + + function get_user_inbox_messages($uid,$count_only=false){ return $this->get_user_messages($uid,'in',$count_only); } + function get_user_outbox_messages($uid,$count_only=false){ return $this->get_user_messages($uid,'out',$count_only); } + function get_user_notification_messages($uid,$count_only=false){ return $this->get_user_messages($uid,'notification',$count_only); } + + /** + * Function used parse attachments + */ + function parse_attachments($attachment) + { + $funcs = $this->pm_attachments_parse; + if(is_array($funcs)) + foreach($funcs as $func) + { + if(function_exists($func)) + { + $attachments .= $func($attachment); + } + } + } + + + /** + * Function used to create PM FORM + */ + function load_compose_form() + { + $to = post('to'); + $to = $to ? $to : get('to'); + + $array = array + ( + 'to' =>array( + 'title'=> 'to', + 'type'=>'textfield', + 'name'=> 'to', + 'id'=> 'to', + 'value'=> $to, + //'hint_2'=> "seperate usernames by comma ','", + 'required'=>'yes' + ), + 'subj' =>array( + 'title'=> 'Subject', + 'type'=>'textfield', + 'name'=> 'subj', + 'id'=> 'subj', + 'value'=> post('subj'), + 'required'=>'yes' + ), + 'content' =>array( + 'title'=> 'content', + 'type'=>'textarea', + 'name'=> 'content', + 'id'=> 'pm_content', + 'value'=> post('content'), + 'required'=>'yes', + 'anchor_before'=>'before_pm_compose_box', + ), + + + ); + + return array_merge($array,$this->pm_custom_field); + } + + + /** + * Function used to add custom pm field + */ + function add_custom_field($array) + { + $this->pm_custom_field = array_merge($array,$this->pm_custom_field); + } + + + /** + * Function used to send PM EMAIL + */ + function send_pm_email($array) + { + global $cbemail,$userquery; + $sender = $userquery->get_user_field_only($array['from'],'username'); + $content = clean($array['content']); + $subject = clean($array['subj']); + $msgid = $array['msg_id']; + //Get To(Emails) + $emails = $this->get_users_emails($array['to']); + $vars = array + ( + '{sender}' => $sender, + '{content}' => $content, + '{subject}' => $subject, + '{msg_id}' => $msgid + ); + + $tpl = $cbemail->get_template($this->email_template); + $subj = $cbemail->replace($tpl['email_template_subject'],$vars); + $msg = $cbemail->replace($tpl['email_template'],$vars); + + cbmail(array('to'=>$emails,'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg,'nl2br'=>true)); + } + + /** + * Function used to get emails of users from input + */ + + function get_users_emails($input) + { + global $userquery,$db; + //check if usernames are sperated by colon ';' + $input = preg_replace('/;/',',',$input); + //Now Exploding Input and converting it to and array + $usernames = explode(',',$input); + $cond = ''; + foreach($usernames as $user) + { + if(!empty($user)) + { + if(!empty($cond)) + $cond .= " OR "; + $cond .= " username ='".$user."' "; + } + } + + $emails = array(); + $results = $db->select(tbl($userquery->dbtbl['users']),'email',$cond); + foreach($results as $result) + { + $emails[] = $result[0]; + } + + return implode(',',$emails); + } + + + /** + * Function used to set private message status as read + */ + function set_message_status($mid,$status='read') + { + global $db; + if($mid) + $db->update(tbl($this->tbl),array('message_status'),array($status)," message_id='$mid'"); + } + + /** + * Function used to delete message from user messages box + */ + function delete_msg($mid,$uid,$box='in') + { + global $db; + if($box=='in') + { + $inbox = $this->get_inbox_message($mid,$uid); + if($inbox) + { + $inbox_user = $inbox['message_to']; + $inbox_user = preg_replace("/#".$uid."#/Ui","",$inbox_user); + if(empty($inbox_user)) + $db->delete(tbl($this->tbl),array("message_id"),array($mid)); + else + $db->update(tbl($this->tbl),array("message_to"),array($inbox_user)," message_id='".$inbox['message_id']."' "); + e(lang('msg_delete_inbox'),'m'); + } + }else{ + $outbox = $this->get_outbox_message($mid,$uid); + if($outbox) + { + $db->delete(tbl($this->tbl),array("message_id"),array($mid)); + e(lang('msg_delete_outbox'),'m'); + } + } + } + + + + /** + * Function used to get new messages + */ + function get_new_messages($uid=NULL,$type='pm') + { + if(!$uid) + $uid = userid(); + global $db; + switch($type) + { + case 'pm': + default: + { + $count = $db->count(tbl($this->tbl),"message_id"," message_to LIKE '%#$uid#%' AND message_box='in' AND message_type='pm' AND message_status='unread'"); + + } + break; + + case 'notification': + default: + { + $count = $db->count(tbl($this->tbl),"message_id"," message_to LIKE '%#$uid#%' AND message_box='in' AND message_type='notification' AND message_status='unread'"); + } + break; + } + + if($count>0) + return $count; + else + return "0"; + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/reindex.class.php b/upload/includes/classes/reindex.class.php new file mode 100644 index 00000000..7c310d01 --- /dev/null +++ b/upload/includes/classes/reindex.class.php @@ -0,0 +1,443 @@ +count(tbl($this->vtbl), + tbl($this->vtbl).".videoid", + tbl($this->vtbl).".userid = ".$params['user']." AND + ".tbl($this->vtbl).".active = 'yes' AND ".tbl($this->vtbl).".status = 'Successful'"); + //echo $db->db_query; + $arr[] = $video_count; + } + + if($params['comment_added']) + { + $ctbl = tbl("comments"); + $comment_added = $db->count($ctbl, + $ctbl.".comment_id", + $ctbl.".userid = ".$params['user'].""); + $arr[] = $comment_added; + } + + if($params['comment_received']) + { + $ctbl = tbl("comments"); + $comment_received = $db->count($ctbl, + $ctbl.".comment_id", + $ctbl.".type_id = ".$params['user']." AND + ".$ctbl.".type = 'c'"); + $arr[] = $comment_received; + } + +// if($params['contacts']) +// { +// global $userquery; +// $contacts = $userquery->get_contacts($params['user'],0,"yes",true); +// $arr[] = $contacts; +// } +// + if($params['groups_count']) + { + global $cbgroup; + $details = array("user"=>$params['user'],"active"=>"yes","count_only"=>true); + $groups_count = $cbgroup->get_groups($details); + $arr[] = $groups_count; + } + + // Counting user subscribers + if($params['subscribers_count']) + { + $subtbl = tbl('subscriptions'); + $subscribers_count = $db->count($subtbl, + $subtbl.".subscription_id", + $subtbl.".subscribed_to = ".$params['user'].""); + $arr[] = $subscribers_count; + } + + + // Counting user subscriptions + if($params['subscriptions_count']) + { + $subtbl = tbl('subscriptions'); + $subscriptions_count = $db->count($subtbl, + $subtbl.".subscription_id", + $subtbl.".userid = ".$params['user'].""); + $arr[] = $subscriptions_count; + } + + if($params['collections_count']) + { + global $cbcollection; + $details = array("user"=>$params['user'],"active"=>"yes","count_only"=>true); + $collection_count = $cbcollection->get_collections($details); + $arr[] = $collection_count; + } + + if($params['photos_count']) + { + global $cbphoto; + $details = array("user"=>$params['user'],"active"=>"yes","count_only"=>true); + $photos_count = $cbphoto->get_photos($details); + $arr[] = $photos_count; + } + + return $arr; + + } + break; + + case "videos": + case "vid": + case "v": + { + //$arr[] = $params['video_id']; + if($params['video_comments']) + { + $ctbl = tbl("comments"); + $video_comments = $db->count($ctbl, + $ctbl.".comment_id", + $ctbl.".type_id = ".$params['video_id']." AND ".$ctbl.".type = 'v'"); + $arr[] = $video_comments; + } + + if($params['favs_count']) + { + $ftbl = tbl("favorites"); + $favs_count = $db->count($ftbl, + $ftbl.".favorite_id", + $ftbl.".id = ".$params['video_id']." AND ".$ftbl.".type = 'v'"); + $arr[] = $favs_count; + } + + if($params['playlist_count']) + { + $ptbl = tbl("playlist_items"); + $playlist_count = $db->count($ptbl, + $ptbl.".playlist_item_id", + $ptbl.".object_id = ".$params['video_id']." AND ".$ptbl.".playlist_item_type = 'v'"); + $arr[] = $playlist_count; + } + + return $arr; + } + break; + + case "group": + case "gp": + case "g": + { + //$arr[] = $params['group_id']; + + if($params['group_videos']) + { + $gvtbl = tbl('group_videos'); + $group_videos = $db->count($gvtbl, + $gvtbl.".group_video_id", + $gvtbl.".group_id = ".$params['group_id']." AND ".$gvtbl.".approved = 'yes'"); + $arr[] = $group_videos; + } + + if($params['group_topics']) + { + $gttbl = tbl('group_topics'); + $group_topics = $db->count($gttbl, + $gttbl.".topic_id", + $gttbl.".group_id = ".$params['group_id']." AND ".$gttbl.".approved = 'yes'"); + $arr[] = $group_topics; + } + + if($params['group_members']) + { + $gmtbl = tbl('group_members'); + $group_members = $db->count($gmtbl, + $gmtbl.".group_mid", + $gmtbl.".group_id = ".$params['group_id']." AND ".$gmtbl.".active = 'yes'"); + + $arr[] = $group_members; + } + + return $arr; + } + break; + + case "photos": + case "p": + case "photo": + { + if($params['favorite_count']) + { + $fav_count = $db->count(tbl("favorites"),"favorite_id",tbl("favorites.id")." = ".$params['photo_id']." AND ".tbl("favorites.type")." = 'p' "); + $arr[] = $fav_count; + } + + if($params['total_comments']) + { + $comment_count = $db->count(tbl("comments"),"comment_id",tbl("comments.type_id")." = ".$params['photo_id']." AND ".tbl("comments.type")." = 'p' "); + $arr[] = $comment_count; + } + + return $arr; + } + break; + + case "collections": + case "collection": + case "cl": + { + if($params['favorite_count']) + { + $fav_count = $db->count(tbl("favorites"),"favorite_id",tbl("favorites.id")." = ".$params['collection_id']." AND ".tbl("favorites.type")." = 'cl' "); + $arr[] = $fav_count; + } + + if($params['total_comments']) + { + $comment_count = $db->count(tbl("comments"),"comment_id",tbl("comments.type_id")." = ".$params['collection_id']." AND ".tbl("comments.type")." = 'cl' "); + $arr[] = $comment_count; + } + + if($params['total_items']) + { + $item_count = $db->count(tbl("collection_items"),"ci_id",tbl("collection_items.collection_id")." = ".$params['collection_id']); + $arr[] = $item_count; + } + + return $arr; + } + break; + } + } + + /** + * Function used to update + * indexes + */ + function update_index($type,$params=NULL) { + global $db; + + switch($type) + { + case "user": + case "u": + { + $db->update(tbl($this->utbl),$params['fields'],$params['values'], tbl($this->utbl).".userid = ".$params['user'].""); + //echo $db->db_query."

    "; + } + break; + + case "videos": + case "vid": + case "v": + { + $db->update(tbl($this->vtbl),$params['fields'],$params['values'], tbl($this->vtbl).".videoid = ".$params['video_id'].""); + //echo $db->db_query."

    "; + } + break; + + case "group": + case "gp": + case "g": + { + $db->update(tbl($this->gtbl),$params['fields'],$params['values'], tbl($this->gtbl).".group_id = ".$params['group_id'].""); + } + break; + + case "photos": case "photo": + case "p": case "foto": case "piture": + { + $db->update(tbl("photos"),$params['fields'],$params['values'],tbl("photos.photo_id")." = ".$params['photo_id']); + } + break; + + case "collection": case "collection": + case "cl": + { + $db->update(tbl("collections"),$params['fields'],$params['values'],tbl("collections.collection_id")." = ".$params['collection_id']); + } + break; + } + } + + /** + * Function used to extract + * fields + */ + function extract_fields($type,$arr) + { + global $db; + $fields = array(); + + switch($type) + { + case "user": + case "u": + { + if(is_array($arr)) + { + if(array_key_exists('video_count',$arr)) + $fields[] = 'total_videos'; + + if(array_key_exists('comment_added',$arr)) + $fields[] = 'total_comments'; + + if(array_key_exists('comment_received',$arr)) + $fields[] = 'comments_count'; + + if(array_key_exists('groups_count',$arr)) + $fields[] = 'total_groups'; + + if(array_key_exists('subscribers_count',$arr)) + $fields[] = 'subscribers'; + + if(array_key_exists('subscriptions_count',$arr)) + $fields[] = 'total_subscriptions'; + + if(array_key_exists('collections_count',$arr)) + $fields[] = 'total_collections'; + + if(array_key_exists('photos_count',$arr)) + $fields[] = 'total_photos'; + $result = $fields; + } else { + $result = $arr; + } + + return $result; + } + break; + + case "videos": + case "vid": + case "v": + { + if(is_array($arr)) + { + if(array_key_exists('video_comments',$arr)) + $fields[] = "comments_count"; + + if(array_key_exists('favs_count',$arr)) + $fields[] = "favourite_count"; + + if(array_key_exists('playlist_count',$arr)) + $fields[] = "playlist_count"; + + $result = $fields; + } else { + $result = $arr; + } + + return $result; + } + break; + + case "group": + case "gp": + case "g": + { + if(is_array($arr)) + { + if(array_key_exists('group_videos',$arr)) + $fields[] = "total_videos"; + + if(array_key_exists('group_topics',$arr)) + $fields[] = "total_topics"; + + if(array_key_exists('group_members',$arr)) + $fields[] = "total_members"; + + $result = $fields; + + } else { + $result = $arr; + } + + return $result; + } + + case "photos": case "photo": + case "p": case "piture": + { + if(is_array($arr)) + { + if(array_key_exists("favorite_count",$arr)) + $fields[] = "total_favorites"; + + if(array_key_exists("total_comments",$arr)) + $fields[] = "total_comments"; + + $result = $fields; + } else { + $result = $arr; + } + + return $result; + } + break; + + case "collections": case "collection": + case "cl": + { + if(is_array($arr)) + { + if(array_key_exists("favorite_count",$arr)) + $fields[] = "total_favorites"; + + if(array_key_exists("total_commnets",$arr)) + $fields[] = "total_comments"; + + if(array_key_exists("total_items",$arr)) + $fields[] = "total_objects"; + + $result = $fields; + } else { + $result = $arr; + } + + return $result; + } + break; + } + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/search.class.php b/upload/includes/classes/search.class.php new file mode 100644 index 00000000..44d8efa6 --- /dev/null +++ b/upload/includes/classes/search.class.php @@ -0,0 +1,443 @@ +search_types[$type]) + { + $obj = $Cbucket->search_types[$type]; + global ${$obj}; + ${$obj}->init_search(); + return ${$obj}->search; + }else + { + global $cbvid; + $cbvid->init_search(); + return $cbvid->search; + } + } + + + /** + * Variable to hold search query condition + */ + var $query_conds = array(); + + function search() + { + global $db; + + $ma_query = ""; + #Checking for columns + if(!$this->use_match_method) + foreach($this->columns as $column) + { + $this->query_cond($column); + } + else + { + if($this->key) + { + $this->set_the_key(); + $ma_query = $this->match_against_query(); + $this->add_cond($ma_query); + //add order + $add_select_field = ",".$ma_query." AS Resource"; + //$sorting = "Resource ASC"; + }else + { + //do nothing + } + + foreach($this->columns as $column) + { + if($column['value'] == 'static') + $this->query_cond($column); + } + } + + + + #Checking for category + if(isset($this->category)) + { + $this->cat_to_query($this->category,$this->multi_cat); + } + #Setting Date Margin + if($this->date_margin!='') + { + $this->add_cond('('.$this->date_margin($this->date_added_colum).')'); + } + + #Sorting + if(isset($this->sort_by) && !$sorting) + { + $sorting = $this->sorting[$this->sort_by]; + } + + $condition = ""; + #Creating Condition + foreach($this->query_conds as $cond) + { + $condition .= $cond." "; + } + + if($this->has_user_id) + { + $query_cond = "(".$condition.")"; + if($condition) + $query_cond .= " AND "; + else + $query_cond = $condition; + $results = $db->select(tbl($this->db_tbl.",users"), + tbl($this->db_tbl.'.*,users.userid,users.username').$add_select_field, + $query_cond." ".tbl($this->db_tbl).".userid=".tbl("users.userid")." AND ".tbl($this->db_tbl).".active='yes'",$this->limit,$sorting); + + + + $this->total_results = $db->count(tbl($this->db_tbl),'*',$condition); + + }else + { + $results = $db->select(tbl($this->db_tbl),'*',$condition,$this->limit,$sorting); + //echo $db->db_query; + $this->total_results = $db->count(tbl($this->db_tbl),'*',$condition); + } + + + + return $results; + } + + + /** + * function used to add query cond + */ + function add_cond($cond,$op='AND') + { + if(count($this->query_conds)>0) + $op = $op; + else + $op = ''; + + $this->query_conds[] = $op." ".$cond; + } + + + /** + * Function used to convert array to query condition + */ + function query_cond($array) + { + //Checking Condition Type + $type = strtolower($array['type']); + + + if($type !='=' && $type!='<' && $type!='>' && $type!='<=' && $type!='>=' && $type!='like' && $type!='match' + && $type!='!=' && $type!='<>') + { + $type = '='; + } + + + $var = $array['var']; + if(empty($var)) + { + $var = "{KEY}"; + } + + $array['op'] = $array['op']?$array['op']:'AND'; + + + if(count($this->query_conds)>0) + $op = $array['op']; + else + $op = ''; + + if($array['value'] == 'static') + { + $this->query_conds[] = $op." ".tbl($this->db_tbl).".".$array['field']." ".$type." '".$array['var']."'"; + return true; + } + + + if(!empty($this->key) && $type != 'match') + $this->query_conds[] = $op." ".tbl($this->db_tbl).".".$array['field']." ".$type." '".preg_replace("/{KEY}/",$this->key,$var)."'"; + if(!empty($this->key) && $type == 'match') + $this->query_conds[] = $op." MATCH(".tbl($this->db_tbl).".".$array['field'].") AGAINST('".preg_replace("/{KEY}/",$this->key,$var)."' + IN BOOLEAN MODE)"; + + } + + /** + * Category to query + * fucntion used to covert category to query + */ + function cat_to_query($input,$multi=TRUE) + { + if(!empty($input)) + { + if(!is_array($input)) + $cats = explode(",",$input); + else + $cats = $input; + + $query = ""; + foreach($cats as $cat) + { + if(!empty($query)) + $query .=" OR "; + + if($multi) + $query .=" ".tbl($this->db_tbl).".category LIKE '%#$cat#%' "; + else + $query .=" ".tbl($this->db_tbl).".category = '$cat' "; + } + + if(count($this->query_conds)>0) + $op = "AND"; + else + $op = ''; + $this->query_conds[] = $op." (".$query.") "; + } + } + + + /** + * Function used to set date margin query + * it is used to get results within defined time span + * ie today, this week , this month or this year + */ + function date_margin($date_column='date_added',$date_margin=NULL) + { + if(!$date_margin) + $date_margin = $this->date_margin; + + if(!empty($date_margin)) + { + switch($date_margin) + { + case "today": + { + $cond = " curdate() = date($date_column) "; + } + break; + + case "yesterday": + { + $cond = " CONCAT(YEAR(curdate()),DAYOFYEAR(curdate())-1) = CONCAT(YEAR($date_column),DAYOFYEAR($date_column)) "; + } + break; + + case "this_week": + case "week": + case "thisweek": + { + $cond = " YEARWEEK($date_column)=YEARWEEK(curdate()) "; + } + break; + + case "this_month": + case "month": + case "thismonth": + { + $cond = " CONCAT(YEAR(curdate()),MONTH(curdate())) = CONCAT(YEAR($date_column),MONTH($date_column)) "; + } + break; + + case "this_year": + case "year": + case "thisyear": + { + $cond = "YEAR(curdate()) = YEAR($date_column)"; + } + break; + + case "all_time": + case "alltime": + case "all": + default: + { + $cond = " $date_column != '' "; + } + break; + + case "last_week": + case "lastweek": + { + $cond = " YEARWEEK($date_column)=YEARWEEK(curdate())-1 "; + } + break; + + case "last_month": + case "lastmonth": + { + $lastmonth = date("Ym", strtotime("last month")); + //$cond = " CONCAT(YEAR($date_column),MONTH($date_column)) ='$lastmonth' "; + //Thanks to netwibe.com + $cond = " CONCAT(YEAR(curdate()),MONTH(curdate())-1) = CONCAT(YEAR($date_column),MONTH($date_column)) "; + } + break; + + + case "last_year": + case "lastyear": + { + $cond = "YEAR(curdate())-1 = YEAR($date_column)"; + } + break; + } + + return $cond; + } + } + + /** + * Function used to define date margins + */ + function date_margins() + { + $this->date_margins = array + ( + 'alltime' => lang('alltime'), + 'today' => lang('today'), + 'yesterday'=> lang('yesterday'), + 'thisweek' => lang('thisweek'), + 'lastweek' => lang('lastweek'), + 'thismonth'=> lang('thismonth'), + 'lastmonth'=> lang('lastmonth'), + 'thisyear' => lang('thisyear'), + 'lastyear' => lang('lastyear'), + ); + + return $this->date_margins; + } + + + /** + * Function used to create match_against query + * it will simple loop the input fields + * add table prefix and create MATCH(fields) AGAINST (keyword) query + * @return - MATCH (fields) AGAINST (kewyord) + */ + function match_against_query() + { + + + $cond = " MATCH ( "; + $count = 0; + foreach($this->match_fields as $field) + { + + if($count>0) + $cond .= ","; + $cond .= tbl($this->db_tbl).".".$field; + + $count++; + } + $cond .= ")"; //Here match(fields1,field2) thing is finished + + //now add against + $cond .= " AGAINST ('".$this->key."' IN BOOLEAN MODE) "; + + return $cond; + } + + /** + * Function used to set the key + */ + function set_the_key($string=null) + { + if(!$string) + $string = $this->key; + $pattern = array('/(\w+)/i','/(\++)/i',"/(\-\+)/i",'/(\-+)/i'); + $replacement = array('+$1',"+","-","-"); + return $this->key = preg_replace($pattern, $replacement, $string); + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/session.class.php b/upload/includes/classes/session.class.php new file mode 100644 index 00000000..e135267a --- /dev/null +++ b/upload/includes/classes/session.class.php @@ -0,0 +1,255 @@ + + * http://clip-bucket.com/ + */ + + +class Session +{ + var $tbl = 'sessions'; + var $id= ''; + var $overwrite = false; + + //Use cookies over sessions + var $cookie = true; + var $timeout = 3600; //1 hour + + /** + * offcourse, its a constructor + */ + function session() + { + $this->id = session_id() ; + $this->timeout = COOKIE_TIMEOUT; + } + + /** + * Function used to add session*/ + function add_session($user,$name,$value=false,$reg=false) + { + global $db,$pages; + if(!$value) + $value = $this->id; + + $this->get_user_session($user,$name,true); + + if($db->num_rows>0) + { + $db->delete(tbl($this->tbl),array('session_string','session'),array($name,$this->id)); + } + + $cur_url = $pages->GetCurrentUrl(); + + if(THIS_PAGE!='cb_install') + { + $db->insert(tbl($this->tbl),array('session_user','session','session_string','ip','session_value','session_date', + 'last_active','referer','agent','current_page'), + array($user,$this->id,$name,$_SERVER['REMOTE_ADDR'],$value,now(),now(),$_SERVER['HTTP_REFERER'],$_SERVER['HTTP_USER_AGENT'],$cur_url)); + } + if($reg) + { + //Finally Registering session + $this->session_register($name); + $this->session_val($name,$value); + } + } + + + + /** + * Function is used to get session + */ + function get_user_session($user,$session_name=false,$phpsess=false) + { + global $db; + if($session_name) + $session_cond = " session_string='".mysql_clean($session_name)."'"; + if($phpsess) + { + if($session_cond) + $session_cond .= " AND "; + $session_cond .= " session ='".$this->id."' "; + } + $results = $db->select(tbl($this->tbl),'*',$session_cond); + return $results; + } + + /** + * Function used to get sessins + */ + function get_sessions() + { + global $db,$pages; + $results = $db->select(tbl($this->tbl),'*'," session ='".$this->id."' "); + + $cur_url = $pages->GetCurrentUrl(); + + if(THIS_PAGE!='cb_install') + { + if(THIS_PAGE!='ajax') + $db->update(tbl($this->tbl),array("last_active","current_page"),array(now(),$cur_url)," session='".$this->id."' "); + else + $db->update(tbl($this->tbl),array("last_active"),array(now())," session='".$this->id."' "); + } + + return $results; + } + + + + /** + * Function used to get current user session, if any + */ + function get_current_session($session_string) + { + global $db; + $results = $db->select(tbl($this->tbl),'*'," session_string='logged_in' AND session_value='".$this->session."'"); + return $results[0]; + } + + + + /** + Functin used to register session + */ + function session_register($name) + { + if($this->overwrite) + $this->session_unregister($name); + //session_register($name); + } + + /** + * FUnction used to unregiser session + */ + function session_unregister($name) + { + //session_unregister($name); + } + + /** + * Ftunction used to set session value + */ + function session_val($name,$value) + { + $_SESSION[$name] = $value; + } + + /** + * Function used to remove session + */ + function remove_session($user,$name) + { + global $db; + $db->delete(tbl('sessions'),array("session_user","session_string"),array($user,$name)); + $_SESSION[$name] = ''; + $this->session_unregister($name); + } + + /** + * Function used to set register session and set its value + */ + function set_session($name,$val) + { + + if($this->cookie) + { + setcookie($name,$val,time()+$this->timeout,'/'); + }else + { + $this->session_register($name); + $_SESSION[$name] = $val; + } + } + function set($name,$val) + { + $this->set_session($name,$val); + } + + /** + * Function used to remove session value + */ + function unset_session($name) + { + if($this->cookie) + { + unset($_COOKIE[$name]); + setcookie($name,'',0); + }else + unset($_SESSION[$name]); + } + function un_set($name) + { + return $this->unset_session($name); + } + + /** + * Function used to get session value + * param VARCHAR name + */ + function get_session($name) + { + if($this->cookie) + { + if($_COOKIE[$name]) + return $_COOKIE[$name]; + }else + { + if(isset($_SESSION[$name])) + return $_SESSION[$name]; + } + } + //replica + function get($name){ return $this->get_session($name); } + + /** + * Destroy Session + */ + function destroy() + { + global $db; + $db->delete(tbl($this->tbl),array('session'),array($this->id)); + session_destroy(); + } + + /** + * Function set cookie + */ + function set_cookie($name,$val) + { + setcookie($name,($val),3600+time(),'/'); + } + + /** + * Function get cookie + */ + function get_cookie($name) + { + return stripslashes(($_COOKIE[$name])); + } + + + function kick($id) + { + global $db; + //Getting little details from sessions such that + //some lower class user can kick admins out ;) + $results = $db->select(tbl("sessions")." LEFT JOIN (".tbl("users").") ON + (".tbl("sessions").".session_user=".tbl("users").".userid)", tbl("sessions").".*, + ".tbl("users").".level","session_id='".$id."'"); + + $results = $results[0]; + + if($results['level']==1) + { + e("You cannot kick administrators"); + return false; + } + $db->delete(tbl($this->tbl),array("session_id"),array($id)); + return true; + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/signup.class.php b/upload/includes/classes/signup.class.php new file mode 100644 index 00000000..d1a6d6bf --- /dev/null +++ b/upload/includes/classes/signup.class.php @@ -0,0 +1,32 @@ + \ No newline at end of file diff --git a/upload/includes/classes/swfObj.class.php b/upload/includes/classes/swfObj.class.php new file mode 100644 index 00000000..abe397c5 --- /dev/null +++ b/upload/includes/classes/swfObj.class.php @@ -0,0 +1,102 @@ +width = config('player_width'); + $this->height = config('player_height'); + } + + //Function Used TO Create Player + function CreatePlayer(){ + $this->SelectPlayer(); + $this->WritePlayer(); + $this->code = $this->ClearTabs($this->code); + } + + + //Function Used To Construct Player OBJ + function FlashObj(){ + $this->code = "var ".$this->playerVar." = new ".$this->objName."(\""; + //$this->code .= BASEURL; + $this->code .= $this->playerFile.'"'; + $this->code .= ',"base","'.$this->width.'","'.$this->height.'","'.$this->PlayerVer.'","'.$this->bgcolor.'");'; + } + + //Function Used To Check Which Player Has Been Selected + function SelectPlayer() + { + global $row; + + //Player + if(empty($this->playerFile)) + $this->playerFile = $row['player_file']; + } + + + + //Function Used To Add Param + function addParam($name,$value,$remove_quotes = false){ + if($remove_quotes == false){ + $this->code .= " + ".$this->playerVar.".addParam('$name', '$value');"; + }else{ + $this->code .= " + ".$this->playerVar.".addParam('$name', $value);"; + } + } + + //Function Used To Add Variables + function addVar($name,$value,$remove_quotes = false){ + if($remove_quotes == false){ + $this->code .= " + ".$this->playerVar.".addVariable('$name', '$value');"; + }else{ + $this->code .= " + ".$this->playerVar.".addVariable('$name', $value);"; + } + } + + //Function Write Player + function WritePlayer() + { + $this->code .= " + ".$this->playerVar.'.write("'.$this->DivId.'");'; + } + + //function used to remove tabs + function ClearTabs($text,$str=false){ + if($str==false){ + return preg_replace('/\t/','',$text); + }else{ + return str_replace('/\t/','',$text); + } + } + + //function for Embed Code + function EmbedCode($code,$div){ + $this->code = 'var EmbedCode="'.addslashes($code).'";'."\r\n"; + $this->code .= "$('#".$div."').html(EmbedCode)"; + } + +} +?> \ No newline at end of file diff --git a/upload/includes/classes/sysinfo.class.php b/upload/includes/classes/sysinfo.class.php new file mode 100644 index 00000000..81df9cdb --- /dev/null +++ b/upload/includes/classes/sysinfo.class.php @@ -0,0 +1,272 @@ + + $login_count = `last | grep / | cut -d' ' -f1 | sort | uniq -c`; + + // compact whitespace, remove leading/trailing whitespace + $login_count = trim(ereg_replace("[[:space:]]+", ' ', $login_count)); + + // convert to array, format: + // odds = login name, evens = login count (2, pedram, 5, shawn, ...) + $login_count = explode(" ", $login_count); + + // loop through our raw data and store the pertinant stats + for ($i = 0, $x = 0; $i < sizeof($login_count); $i += 2, $x++) { + $days = $hours = $mins = 0; + + // strip out the login duration (not including those currently logged in) + // XXX - add support for users still logged in. + $login_time = `last | grep -e ^{$login_count[$i+1]} | grep -v still | cut -d'(' -f2`; + $login_time = ereg_replace("[[:space:]]+", "", str_replace("\n", "", $login_time)); + $login_time = explode(")", $login_time); + + // determine the login durations + for ($j = 0; $j < sizeof($login_time); $j++) { + $entry = explode(":", $login_time[$j]); + $days += substr($entry[0], 0, strpos($entry[0], "+")); + $hours += substr($entry[0], strpos($entry[0], "+")); + $mins += $entry[1]; + } + + // formatting + $hours += floor($mins / 60); + $days += floor($hours / 24); + + $hours = $hours % 24; + $mins = $mins % 60; + + $login_stats[$x]["user"] = $login_count[$i+1]; + $login_stats[$x]["count"] = $login_count[$i]; + $login_stats[$x]["days"] = $days; + $login_stats[$x]["hours"] = $hours; + $login_stats[$x]["mins"] = $mins; + $login_stats[$x]["start"] = $wtmp_start; + } + + return $login_stats; +} + + + +/******************************************************************************* + * helper functions * + *******************************************************************************/ + + +/////////////////////////////////////////////////////////////////////////////// +// convert_bytes +// + +function convert_bytes ($bytes) { + $kbytes = $bytes / 1024; + + if ($kbytes > 1048576) + $converted = sprintf("%.2f GB", $kbytes / 1048576); + else if ($kbytes > 1024) + $converted = sprintf("%.2f MB", $kbytes / 1024); + else + $converted = sprintf("%.2f KB", $kbytes); + + return $converted; +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/template.class.php b/upload/includes/classes/template.class.php new file mode 100644 index 00000000..483ebfa1 --- /dev/null +++ b/upload/includes/classes/template.class.php @@ -0,0 +1,306 @@ +compile_check = true; + $Smarty->debugging = false; + $Smarty->template_dir = BASEDIR."/styles"; + $Smarty->compile_dir = BASEDIR."/cache"; + + return true; + } + + function setCompileDir($dir_name) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->compile_dir = $dir_name; + } + + function setType($type) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->type = $type; + } + + function assign($var, $value) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->assign($var, $value); + } + + function setTplDir($dir_name = null) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + if (!$dir_name) { + $Smarty->template_dir = BASEDIR."/styles/clipbucketblue"; + } else { + $Smarty->template_dir = $dir_name; + } + } + + function setModule($module) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->theme = $module; + $Smarty->type = "module"; + } + + function setTheme($theme) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->template_dir = BASEDIR."/styles/" . $theme; + $Smarty->compile_dir = BASEDIR."/styles/" . $theme; + $Smarty->theme = $theme; + $Smarty->type = "theme"; + } + + function getTplDir() { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + return $Smarty->template_dir; + } + + function display($filename) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + $Smarty->display($filename); + } + + function fetch($filename) { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + return $Smarty->fetch($filename); + } + + function getVars() { + global $Smarty; + if (!isset($Smarty)) { + CBTemplate::create(); + } + return $Smarty->get_template_vars(); + } + + /** + * Function used to get available templates + */ + function get_templates() + { + $dir = STYLES_DIR; + //Scaning Dir + $dirs = scandir($dir); + foreach($dirs as $tpl) + { + if(substr($tpl,0,1)!='.') + $tpl_dirs[] = $tpl; + } + //Now Checking for template template.xml + $tpls = array(); + foreach($tpl_dirs as $tpl_dir) + { + $tpl_details = CBTemplate::get_template_details($tpl_dir); + + if($tpl_details && $tpl_details['name']!='') + $tpls[$tpl_details['name']] = $tpl_details; + } + + return $tpls; + } + function gettemplates() + { + return $this->get_templates(); + } + + function get_template_details($temp,$file='template.xml') + { + $file = STYLES_DIR.'/'.$temp.'/template.xml'; + if(file_exists($file)) + { + $content = file_get_contents($file); + preg_match('/(.*)<\/name>/',$content,$name); + preg_match('/(.*)<\/author>/',$content,$author); + preg_match('/(.*)<\/version>/',$content,$version); + preg_match('/(.*)<\/released>/',$content,$released); + preg_match('/(.*)<\/description>/',$content,$description); + preg_match('/(.*)<\/website>/',$content,$website_arr); + + $name = $name[1]; + $author = $author[1]; + $version = $version[1]; + $released = $released[1]; + $description = $description[1]; + + $website = array('title'=>$website_arr[1],'link'=>$website_arr[2]); + + //Now Create array + $template_details = array + ('name'=>$name, + 'author'=>$author, + 'version'=>$version, + 'released'=>$released, + 'description'=>$description, + 'website'=>$website, + 'dir'=>$temp, + 'path'=>TEMPLATEFOLDER.'/'.$temp + ); + + return $template_details; + }else + return false; + } + + /** + * Function used to get template thumb + */ + function get_preview_thumb($template) + { + $path = TEMPLATEFOLDER.'/'.$template.'/images/preview.'; + $exts = array('png','jpg','gif'); + $thumb_path = BASEURL.'/images/icons/no_thumb_template.png'; + foreach($exts as $ext) + { + $file = BASEDIR.'/'.$path.$ext; + if(file_exists($file)) + { + $thumb_path = BASEURL.'/'.$path.$ext; + break; + } + } + + return $thumb_path; + } + + /** + * Function used to get any template + */ + function get_any_template() + { + $templates = $this->get_templates(); + if(is_array($templates)) + { + foreach($templates as $template) + { + if(!empty($template['name'])) + return $template['dir']; + } + return false; + }else + return false; + } + + /** + * Function used to check weather given template is ClipBucket Template or not + * It will read Template XML file + */ + function is_template($folder) + { + return $this->get_template_details($folder); + } + + + /** + * Function used to get list of template file frrom its layout and styles folder + */ + function get_template_files($template,$type=NULL) + { + switch($type) + { + case "layout": + default: + { + $style_dir = STYLES_DIR."/$template/layout/"; + $files_patt = $style_dir."*.html"; + $files = glob($files_patt); + /** + * All Files IN Layout Folder + */ + $new_files = array(); + foreach($files as $file) + { + $new_files[] = str_replace($style_dir,'',$file); + } + + /** + * Now Reading Blocks Folder + */ + $blocks = $style_dir.'blocks/'; + $file_patt = $blocks.'*.html'; + $files = glob($file_patt); + foreach($files as $file) + { + $new_files['blocks'][] = str_replace($blocks,'',$file); + } + + /** + * Reading Folders Under Blocks + */ + //$blocks_dirs = glob($blocks.'*',GLOB_ONLYDIR); +// foreach($blocks_dirs as $dir) +// { +// $dir_name = str_replace($blocks,'',$dir); +// +// /** +// * Now Reading Files under them and saving in array +// */ +// $sub_dir = $blocks.$dir_name.'/'; +// $file_patt = $sub_dir.'*.html'; +// $files = glob($file_patt); +// foreach($files as $file) +// { +// $new_files['blocks'][$dir_name][] = str_replace($sub_dir,'',$file); +// } +// } + return $new_files; + } + break; + case "theme": + { + $style_dir = STYLES_DIR."/$template/theme/"; + $files_patt = $style_dir."*.css"; + $files = glob($files_patt); + /** + * All Files IN CSS Folder + */ + $new_files = array(); + foreach($files as $file) + { + $new_files[] = str_replace($style_dir,'',$file); + } + + return $new_files; + } + } + } +} + +?> \ No newline at end of file diff --git a/upload/includes/classes/upload.class.php b/upload/includes/classes/upload.class.php new file mode 100644 index 00000000..e0df2a6e --- /dev/null +++ b/upload/includes/classes/upload.class.php @@ -0,0 +1,1153 @@ +loadRequiredFields($array); + $location_fields = $this->loadLocationFields($array); + $date_fields = $this->loadDateForm('','/',TRUE); + $option_fields = $this->loadOptionFields($array); + + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + //Mergin Array + $upload_fields = array_merge($required_fields,$location_fields,$option_fields); + + //Adding Custom Upload Fields + if(count($this->custom_upload_fields)>0 && $is_upload) + $upload_fields = array_merge($upload_fields,$this->custom_upload_fields); + //Adding Custom Form Fields + if(count($this->custom_form_fields)>0) + $upload_fields = array_merge($upload_fields,$this->custom_form_fields); + + validate_cb_form($upload_fields,$array); + + } + function ValidateUploadForm() + { + return validate_video_upload_form(); + } + + function UploadProcess($array=NULL) + { + return $this->submit_upload($array); + } + + function submit_upload($array=NULL) + { + global $eh,$Cbucket,$db,$userquery; + + if(!$array) + $array = $_POST; + + $this->validate_video_upload_form($array,TRUE); + + if(empty($eh->error_list)) + { + $required_fields = $this->loadRequiredFields($array); + $location_fields = $this->loadLocationFields($array); + $option_fields = $this->loadOptionFields($array); + + $upload_fields = array_merge($required_fields,$location_fields,$option_fields); + //Adding Custom Upload Fields + if(count($this->custom_upload_fields)>0) + $upload_fields = array_merge($upload_fields,$this->custom_upload_fields); + //Adding Custom Form Fields + if(count($this->custom_form_fields)>0) + $upload_fields = array_merge($upload_fields,$this->custom_form_fields); + + $userid = userid(); + + if(!userid() && has_access('allow_video_upload',true,false)) + { + $userid = $userquery->get_anonymous_user(); + //$userid = $user['userid']; + }elseif(userid() && !has_access('allow_video_upload',true,true)) + return false; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + foreach($upload_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'] || (!apply_func($field['clean_func'],$val) && !is_array($field['clean_func']))) + $val = mysql_clean($val); + else + $val = apply_func($field['clean_func'],sql_free($val)); + + if(empty($val) && !empty($field['default_value'])) + $val = $field['default_value']; + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + + //Adding Video Code + $query_field[] = "file_name"; + $file_name = mysql_clean($array['file_name']); + $query_val[] = $file_name; + + //ADding Video Key + $query_field[] = "videokey"; + $query_val[] = $this->video_keygen(); + + + //Userid + $query_field[] = "userid"; + + if(!$array['userid']) + $query_val[] = $userid; + else + $query_val[] = $array['userid']; + + + //Upload Ip + $query_field[] = "uploader_ip"; + $query_val[] = $_SERVER['REMOTE_ADDR']; + + $activation = ACTIVATION; + + //Setting Activation Option + if($activation == 0){ + $active = 'yes'; + }else{ + $active = 'no'; + } + $query_field[] = "active"; + $query_val[] = $active; + + $query_field[] = "date_added"; + $query_val[] = now(); + + $query = "INSERT INTO ".tbl("video")." ("; + $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 .= ")"; + + //exit($query); + + if(!userid() && !has_access('allow_video_upload',false,false)) + { + e(lang("you_not_logged_in")); + //exit(); + }else{ + + $insert_id = file_name_exists($file_name); + if(!$insert_id) + { + $db->Execute($query); + $insert_id = $db->insert_id(); + + //loggin Upload + $log_array = array + ( + 'success'=>'yes', + 'action_obj_id' => $insert_id, + 'userid' => $userid, + 'details'=> "uploaded a video"); + insert_log('upload_video',$log_array); + + $db->update(tbl("users"),array("total_videos"),array("|f|total_videos+1")," userid='".$userid."'"); + } + } + + } + + //Adding Video Feed + addFeed(array('action' => 'upload_video','object_id' => $insert_id,'object'=>'video'));; + return $insert_id; + + } + + /** + * Function used to get available name for video thumb + * @param FILE_Name + */ + function get_available_file_num($file_name,$big=false) + { + //Starting from 1 + $code = 1; + if($big) + $big = "big-"; + while(1) + { + $path = THUMBS_DIR.'/'.$file_name.'-'.$big.$code.'.'; + if(!file_exists($path.'jpg') && !file_exists($path.'png') && !file_exists($path.'gif')) + break; + else + $code = $code + 1; + } + + return $code; + } + + + function upload_thumb($file_name,$file_array,$key=0) + { + global $imgObj,$LANG; + $file = $file_array; + if(!empty($file['name'][$key])) + { + $file_num = $this->get_available_file_num($file_name); + $ext = getExt($file['name'][$key]); + if($imgObj->ValidateImage($file['tmp_name'][$key],$ext)) + { + $file_path = THUMBS_DIR.'/'.$file_name.'-'.$file_num.'.'.$ext; + $big_file_path = THUMBS_DIR.'/'.$file_name.'-big-'.$file_num.'.'.$ext; + move_uploaded_file($file['tmp_name'][$key],$file_path); + + $imgObj->CreateThumb($file_path,$big_file_path,config('big_thumb_width'),$ext,config('big_thumb_height'),false); + $imgObj->CreateThumb($file_path,$file_path,THUMB_WIDTH,$ext,THUMB_HEIGHT,false); + e(lang('upload_vid_thumb_msg'),'m'); + } + } + } + + /** + * Function used to upload big thumb + * @param FILE_NAME + * @param $_FILES array name + */ + function upload_big_thumb($file_name,$file_array) { + global $imgObj,$LANG; + $file = $file_array; + $ext = getExt($file['name']); + $bigThumbWidth = config('big_thumb_width'); + $bigThumbHeight = config('big_thumb_height'); + + if($imgObj->ValidateImage($file['tmp_name'],$ext)) + { + $path = THUMBS_DIR.'/'.$file_name.'-big.'.$ext; + move_uploaded_file($file['tmp_name'],$path); + $imgObj->CreateThumb($path,$path,$bigThumbWidth,$ext,$bigThumbHeight,false); + e(lang('Video big thumb uploaded'),'m'); + } + } + + /** + * Function used to upload video thumbs + * @param FILE_NAME + * @param $_FILES array name + */ + + function upload_thumbs($file_name,$file_array) + { + global $LANG; + if(count($file_array[name])>1) + { + for($i=0;$iupload_thumb($file_name,$file_array,$i); + } + e(lang('upload_vid_thumbs_msg'),'m'); + }else{ + $file = $file_array; + $this->upload_thumb($file_name,$file); + } + } + + function UploadThumb($flv,$thumbid){ + $file = $_FILES["upload_thumb_$thumbid"]['tmp_name']; + $ext = GetExt($_FILES["upload_thumb_$thumbid"]['name']); + if(!empty($file) && $ext =='jpg'){ + $image = new ResizeImage(); + if($image->ValidateImage($file,$ext)){ + $thumb = BASEDIR.'/files/thumbs/'.GetThumb($flv,$thumbid); + move_uploaded_file($file,$thumb); + $image->CreateThumb($thumb,$thumb,THUMB_WIDTH,$ext,THUMB_HEIGHT,false); + return true; + }else{ + return false; + } + }else{ + return false; + } + + } + + + + /** + * FUNCTION USED TO LOAD UPLOAD FORM REQUIRED FIELDS + * title [Text Field] + * description [Text Area] + * tags [Text Field] + * categories [Check Box] + */ + + function loadRequiredFields($default=NULL) + { + global $LANG; + if($default == NULL) + $default = $_POST; + + $title = $default['title']; + $desc = $default['description']; + + if(is_array($default['category'])) + $cat_array = array($default['category']); + else + { + preg_match_all('/#([0-9]+)#/',$default['category'],$m); + $cat_array = array($m[1]); + } + + $tags = $default['tags']; + + $uploadFormRequiredFieldsArray = array + ( + /** + * this function will create initial array for fields + * this will tell + * array( + * title [text that will represents the field] + * type [type of field, either radio button, textfield or text area] + * name [name of the fields, input NAME attribute] + * id [id of the fields, input ID attribute] + * value [value of the fields, input VALUE attribute] + * id [name of the fields, input NAME attribute] + * size + * class + * label + * extra_params + * hint_1 [hint before field] + * hint_2 [hint after field] + * anchor_before [before after field] + * anchor_after [anchor after field] + * ) + */ + + 'title' => array('title'=> lang('vdo_title'), + 'type'=> 'textfield', + 'name'=> 'title', + 'id'=> 'title', + 'value'=> cleanForm($title), + 'size'=>'45', + 'db_field'=>'title', + 'required'=>'yes', + 'min_length' => config("video_min_title"), + 'max_length'=>config("video_max_title") + + ), + 'desc' => array('title'=> lang('vdo_desc'), + 'type'=> 'textarea', + 'name'=> 'description', + 'id'=> 'desc', + 'value'=> cleanForm($desc), + 'size'=>'35', + 'extra_params'=>' rows="4"', + 'db_field'=>'description', + 'required'=>'yes', + 'anchor_after'=>'after_desc_compose_box', + + ), + 'cat' => array('title'=> lang('vdo_cat'), + 'type'=> 'checkbox', + 'name'=> 'category[]', + 'id'=> 'category', + 'value'=> array('category',$cat_array), + 'hint_1'=> sprintf(lang('vdo_cat_msg'),ALLOWED_VDO_CATS), + 'db_field'=>'category', + 'required'=>'yes', + 'validate_function'=>'validate_vid_category', + 'invalid_err'=>lang('vdo_cat_err3'), + 'display_function' => 'convert_to_categories' + + + ), + 'tags' => array('title'=> lang('tag_title'), + 'type'=> 'textfield', + 'name'=> 'tags', + 'id'=> 'tags', + 'value'=> cleanForm(genTags($tags)), + 'hint_1'=> '', + 'hint_2'=> lang('vdo_tags_msg'), + 'db_field'=>'tags', + 'required'=>'yes', + 'validate_function'=>'genTags' + ), + ); + //Setting Anchors + $uploadFormRequiredFieldsArray['desc']['anchor_before'] = 'before_desc_compose_box'; + + //Setting Sizes + return $uploadFormRequiredFieldsArray; + } + + /** + * FUNCTION USED TO LOAD FORM OPTION FIELDS + * broadacast [Radio Button] + * embedding [Radio Button] + * rating [Radio Button] + * comments [Radio Button] + * comments rating [Radio Button] + */ + function loadOptionFields($default=NULL) + { + global $LANG,$uploadFormOptionFieldsArray; + + + if($default == NULL) + $default = $_POST; + + $broadcast = $default['broadcast'] ? $default['broadcast'] : 'public'; + $comments = $default['allow_comments'] ? $default['allow_comments'] : 'yes'; + $comment_voting = $default['comment_voting'] ? $default['comment_voting'] : 'yes'; + $rating = $default['allow_rating'] ? $default['allow_rating'] : 'yes'; + $embedding = $default['allow_embedding'] ? $default['allow_embedding'] : 'yes'; + + //Checking weather to enabled or disable password field + $video_pass_disable = 'disabled="disabled" '; + $video_user_disable = 'disabled="disabled" '; + + if($broadcast=='unlisted') + $video_pass_disable = ""; + elseif($broadcast=='private') + $video_user_disable = ''; + + $uploadFormOptionFieldsArray = array + ( + 'broadcast'=> array('title'=>lang('vdo_br_opt'), + 'type'=>'radiobutton', + 'name'=>'broadcast', + 'id'=>'broadcast', + 'value'=>array('public'=>lang('vdo_br_opt1'),'private'=>lang('vdo_br_opt2') + ,'unlisted'=>lang('vdo_broadcast_unlisted'),'logged'=>lang("logged_users_only")), + 'checked'=>$broadcast, + 'db_field'=>'broadcast', + 'required'=>'no', + 'validate_function'=>'yes_or_no', + 'display_function'=>'display_sharing_opt', + 'default_value'=>'public', + 'extra_tags' => + ' onClick=" + $(\'#video_password\').attr(\'disabled\',\'disabled\'); + $(\'#video_users\').attr(\'disabled\',\'disabled\'); + if($(this).val()==\'unlisted\') + $(\'#video_password\').attr(\'disabled\',\'\') + else if($(this).val()==\'private\') + $(\'#video_users\').attr(\'disabled\',\'\') + + " ' + ), + + 'video_password'=> array + ('title'=>lang('video_password'), + 'type'=>'password', + 'name'=>'video_password', + 'id'=>'video_password', + 'value'=> $default['video_password'], + 'db_field'=>'video_password', + 'required'=>'no', + 'extra_tags' => " $video_pass_disable ", + 'hint_2'=> lang('set_video_password') + ), + 'video_users' => array('title'=>lang('video_users'), + 'type'=>'textarea', + 'name'=>'video_users', + 'id'=>'video_users', + 'value'=> $default['video_users'], + 'db_field'=>'video_users', + 'required'=>'no', + 'extra_tags' => " $video_user_disable ", + 'hint_2'=> lang('specify_video_users'), + 'validate_function' => 'video_users', + 'use_func_val'=>true + ), + 'comments'=> array('title'=>lang('comments'), + 'type'=> 'radiobutton', + 'name'=>'allow_comments', + 'id'=>'comments', + 'value'=> array('yes'=>lang('vdo_allow_comm'),'no'=>lang('vdo_dallow_comm')), + 'checked'=> $comments, + 'db_field'=>'allow_comments', + 'required'=>'no', + 'validate_function'=>'yes_or_no', + 'display_function'=>'display_sharing_opt', + 'default_value'=>'yes', + ), + 'commentsvote'=> array('title'=>lang('vdo_comm_vote'), + 'type'=>'radiobutton', + 'name'=>'comment_voting', + 'id'=>'comment_voting', + 'value'=>array('yes'=>lang('vdo_allow_comm').' Voting','no'=>lang('vdo_dallow_comm').' Voting'), + 'checked'=>$comment_voting, + 'db_field'=>'comment_voting', + 'required'=>'no', + 'validate_function'=>'yes_or_no', + 'display_function'=>'display_sharing_opt', + 'default_value'=>'yes', + ), + 'rating'=> array('title'=>lang('ratings'), + 'type'=>'radiobutton', + 'name'=>'allow_rating', + 'id'=>'rating', + 'value'=> array('yes'=>lang('vdo_allow_rating'),'no'=>lang('vdo_dallow_ratig')), + 'checked'=>$rating, + 'db_field'=>'allow_rating', + 'required'=>'no', + 'validate_function'=>'yes_or_no', + 'display_function'=>'display_sharing_opt', + 'default_value'=>'yes', + ), + 'embedding'=> array('title'=>lang('vdo_embedding'), + 'type'=> 'radiobutton', + 'name'=> 'allow_embedding', + 'id'=> 'embedding', + 'value'=> array('yes'=>lang('vdo_embed_opt1'),'no'=>lang('vdo_embed_opt2')), + 'checked'=> $embedding, + 'db_field'=>'allow_embedding', + 'required'=>'no', + 'validate_function'=>'yes_or_no', + 'display_function'=>'display_sharing_opt', + 'default_value'=>'yes', + ), + ); + return $uploadFormOptionFieldsArray; + } + + /** + * FUNCTION USED TO LOAD DATE AND LOCATION OPTION OF UPLOAD FORM + * - day - month - year + * - country + * - city + */ + function loadLocationFields($default=NULL) + { + global $LANG,$LocationFieldsArray,$CBucket; + + if($default == NULL) + $default = $_POST; + + $dcountry = $default['country']; + $location = $default['location']; + $date_recorded = $default['datecreated']; + $date_recorded = $date_recorded ? date(config("date_format"),strtotime($date_recorded)) : date(config("date_format"),time()); + + $country_array = array(""); + + $country_array = @array_merge($country_array,ClipBucket::get_countries()); + + $LocationFieldsArray = array + ( + 'country'=> array('title'=>lang('country'), + 'type'=> 'dropdown', + 'name'=> 'country', + 'id'=> 'country', + 'value'=> $country_array, + 'checked'=> $dcountry, + 'db_field'=>'country', + 'required'=>'no', + 'default_value'=>'', + + ), + 'location'=> array('title'=>lang('location'), + 'type'=>'textfield', + 'name'=> 'location', + 'id'=> 'location', + 'value'=> $location, + 'hint_2'=> lang('vdo_add_eg'), + 'db_field'=>'location', + 'required'=>'no', + 'default_value'=>'', + ), + 'date_recorded' => array( + 'title' => 'Date Recorded', + 'type' => 'textfield', + 'name' => 'datecreated', + 'id' => 'datecreated', + 'class'=>'date_field', + 'anchor_after' => 'date_picker', + 'value'=> $date_recorded, + 'db_field'=>'datecreated', + 'required'=>'no', + 'default_value'=>'', + 'use_func_val' => true, + 'validate_function' => 'datecreated', + 'hint_2' => config("date_format"), + ) + ); + return $LocationFieldsArray; + } + + /** + * FUNCTION USED TO DISPLAY DATE FORM + */ + function loadDateForm($date=NULL,$sep='/',$bg_process=FALSE) + { + global $LANG,$formObj; + $month_array = array(''=>'--'); + $day_array = array(''=>'--'); + $year_array = array(''=>'----'); + for($i=1;$i<13;$i++) $month_array[$i] = $i; + for($i=1;$i<32;$i++) $day_array[$i] = $i; + for($i=date("Y",time());$i>1900;$i--) $year_array[$i] = $i; + + if($date['value']==NULL) + { + $d_month = $_POST['month']; + $d_day = $_POST['day']; + $d_year = $_POST['year']; + }else{ + $d_month = date("m",strtotime($date)); + $d_day = date("d",strtotime($date)); + $d_year = date("Y",strtotime($date)); + } + if(!$bg_process) + { + echo $formObj->createField('dropdown','month','',$month_array,NULL,NULL,NULL,NULL,$d_month); + echo $sep; + echo $formObj->createField('dropdown','day','',$day_array,NULL,NULL,NULL,NULL,$d_day); + echo $sep; + echo $formObj->createField('dropdown','year','',$year_array,NULL,NULL,NULL,NULL,$d_year); + echo lang('vdo_for_date'); + } + + } + + + + /** + * Function used to load upload form fields + * it will load all the values that are submited in the upload form + * after validation + */ + function load_post_fields() + { + + $required_fields = $this->loadRequiredFields($array); + $location_fields = $this->loadLocationFields($array); + $option_fields = $this->loadOptionFields($array); + $upload_fields = array_merge($required_fields,$location_fields,$option_fields); + if(count($this->custom_form_fields)>0) + $upload_fields = array_merge($upload_fields,$this->custom_form_fields); + + foreach($upload_fields as $field) + { + $name = formObj::rmBrackets($field['name']); + $val = $_POST[$name]; + if(!is_array($val)) + { + $val = cleanForm($_POST[$name]); + echo ''; + }else{ + $loop = count($val); + for($i=0;$i<$loop;$i++) + { + $val = $_POST[$name][$i]; + $val = cleanForm($_POST[$name][$i]); + echo ''; + } + } + } + } + + + /** + * Function used to add files in conversion queue + */ + function add_conversion_queue($file) + { + global $Cbucket,$db; + $tmp_ext = $Cbucket->temp_exts; + + $count = 1; + while(1) + { + $exists = 'no'; + foreach($tmp_ext as $exts) + { + + if(file_exists(TEMP_DIR.'/' .getName($file).'.'.$exts)) + { + $exists = 'yes'; + break; + } + } + + if($exists !='yes') + break; + + $new_file = getName($file).'-'.$count.'.'.strtolower(getExt($file)); + rename(TEMP_DIR.'/'.$file,TEMP_DIR.'/'.$new_file); + $file = $new_file; + + $count++; + if($count>50) + break; + } + + //Checking file existsi or not + if(file_exists(TEMP_DIR.'/'.$file)) + { + $ext = mysql_clean(strtolower(getExt($file))); + $name = mysql_clean(getName($file)); + //Get Temp Ext + $tmp_ext = mysql_clean($tmp_ext[rand(0,count($tmp_ext)-1)]); + //Creating New File Name + $new_file = $name.'.'.$tmp_ext; + //Renaming File for security purpose + if(!file_exists(TEMP_DIR.'/'.$file) || !$name) + return false; + rename(TEMP_DIR.'/'.$file,TEMP_DIR.'/'.$new_file); + //Adding Details to database + $db->Execute("INSERT INTO ".tbl("conversion_queue")." (cqueue_name,cqueue_ext,cqueue_tmp_ext,date_added) + VALUES ('".$name."','".$ext."','".$tmp_ext."','".NOW()."') "); + return $db->insert_id; + }else{ + return false; + } + } + + + /** + * Video Key Gen + * * it is use to generate video key + */ + function video_keygen() + { + global $db; + + $char_list = "ABDGHKMNORSUXWY"; + $char_list .= "123456789"; + while(1) + { + $vkey = ''; + srand((double)microtime()*1000000); + for($i = 0; $i < 12; $i++) + { + $vkey .= substr($char_list,(rand()%(strlen($char_list))), 1); + } + + if(!vkey_exists($vkey)) + break; + } + + return $vkey; + } + + + + + /** + * Function used to load upload form + */ + function load_upload_options() + { + global $Cbucket,$Smarty; + $opt_list = $Cbucket->upload_opt_list; + + foreach($opt_list as $opt) + { + $Smarty->register_function($opt['load_func'],$opt['load_func']); + } + + return $opt_list; + } + + + + /** + * Function used to perform some actions , after video is upload + * @param Videoid + */ + function do_after_video_upload($vid) + { + foreach($this->actions_after_video_upload as $funcs) + { + if(function_exists($funcs)) + $funcs($vid); + } + } + + + /** + * Function used to load custom upload fields + */ + function load_custom_upload_fields($data,$ck_display_admin=FALSE,$ck_display_user=FALSE) + { + $array = $this->custom_upload_fields; + foreach($array as $key => $fields) + { + $ok = 'yes'; + if($ck_display_admin) + { + if($fields['display_admin'] == 'no_display') + $ok = 'no'; + } + + if($ok=='yes') + { + if(!$fields['value']) + $fields['value'] = $data[$fields['db_field']]; + $new_array[$key] = $fields; + } + } + + return $new_array; + } + + + /** + * Function used to load custom form fields + */ + function load_custom_form_fields($data,$group_based=false) + { + if(!$group_based) + { + $array = $this->custom_form_fields; + foreach($array as $key => $fields) + { + if($data[$fields['db_field']]) + $value = $data[$fields['db_field']]; + elseif($data[$fields['name']]) + $value = $data[$fields['name']]; + + + if($fields['type']=='radiobutton' || + $fields['type']=='checkbox' || + $fields['type']=='dropdown') + $fields['checked'] = $value; + else + $fields['value'] = $value; + + + $new_array[$key] = $fields; + } + return $new_array; + }else + { + return $array = $this->custom_form_fields_groups; + } + } + + + /** + * function used to upload user avatar and or background + */ + function upload_user_file($type='a',$file,$uid) + { + global $db,$userquery,$cbphoto,$imgObj; + $avatar_dir = BASEDIR.'/images/avatars/'; + $bg_dir = BASEDIR.'/images/backgrounds/'; + + if($userquery->user_exists($uid)) + { + switch($type) + { + case 'a': + case 'avatar': + { + + if($file['size']/1024 > config('max_profile_pic_size')) + e(sprintf(lang('file_size_exceeds'),config('max_profile_pic_size'))); + elseif(file_exists($file['tmp_name'])) + { + $ext = getext($file['name']); + $file_name = $uid.'.'.$ext; + $file_path = $avatar_dir.$file_name; + if(move_uploaded_file($file['tmp_name'],$file_path)) + { + if(!$imgObj->ValidateImage($file_path,$ext)) + { + e(lang("Invalid file type")); + @unlink($file_path); + }else{ + $small_size = $avatar_dir.$uid.'-small.'.$ext; + $cbphoto->CreateThumb($file_path,$file_path,$ext,AVATAR_SIZE,AVATAR_SIZE); + $cbphoto->CreateThumb($file_path,$small_size,$ext,AVATAR_SMALL_SIZE,AVATAR_SMALL_SIZE); + } + }else{ + e(lang("class_error_occured")); + } + } + } + break; + case 'b': + case 'bg': + case 'background': + { + if($file['size']/1024 > config('max_bg_size')) + e(sprintf(lang('file_size_exceeds'),config('max_bg_size'))); + elseif(file_exists($file['tmp_name'])) + { + $ext = getext($file['name']); + $file_name = $uid.'.'.$ext; + $file_path = $bg_dir.$file_name; + if(move_uploaded_file($file['tmp_name'],$file_path)) + { + if(!$imgObj->ValidateImage($file_path,$ext)) + { + e(lang("Invalid file type")); + @unlink($file_path); + }else{ + $imgObj->CreateThumb($file_path,$file_path,BG_SIZE,$ext); + } + }else{ + e(lang("An error occured While Uploading File!")); + } + } + } + break; + } + return $file_name; + }else + e(lang('user_doesnt_exist')); + } + + + /** + * Function used to upload website logo + * @param logo_file + * @return $file_name.'.'.$ext; + */ + function upload_website_logo($file) + { + global $imgObj,$LANG; + + if(!empty($file['name'])) + { + //$file_num = $this->get_available_file_num($file_name); + $ext = getExt($file['name']); + $file_name = 'plaery-logo'; + if($imgObj->ValidateImage($file['tmp_name'],$ext)) + { + $file_path = BASEDIR.'/images/'.$file_name.'.'.$ext; + if(file_exists($file_path)) + if(!unlink($file_path)) + { + e("Unable to remove '$file_path' , please chmod it to 0777"); + return false; + } + + move_uploaded_file($file['tmp_name'],$file_path); + //$imgObj->CreateThumb($file_path,$file_path,200,$ext,200,false); + e("Logo has been uploaded",'m'); + return $file_name.'.'.$ext; + }else + e("Invalid Image file"); + } + return false; + } + + + + /** + * load_video_fields + * + * @param $input default values for all videos + * @return array of video fields + * + * Function used to load Video fields + * in clipbucket v2.5 , video fields are loaded in form of groups arrays + * each group has it name and fields wrapped in array + * and that array will be part of video fields + */ + function load_video_fields($input) + { + $fields = array + ( + array + ( + 'group_name' => lang('required_fields'), + 'group_id' => 'required_fields', + 'fields' => $this->loadRequiredFields($input), + ), + array + ( + 'group_name' => lang('vdo_share_opt'), + 'group_id' => 'sharing_fields', + 'fields' => $this->loadOptionFields($input), + ), + array + ( + 'group_name' => lang('date_recorded_location'), + 'group_id' => 'date_location_fields', + 'fields' => $this->loadLocationFields($input), + ) + ); + + //Adding Custom Fields + $custom_fields = $this->load_custom_form_fields($input,false); + + if($custom_fields) + { + $more_fields_group = + array + ( + 'group_name' => lang('more_fields'), + 'group_id' => 'custom_fields', + 'fields' => $custom_fields, + ); + } + + //Adding Custom Fields With Groups + $custom_fields_with_group = $this->load_custom_form_fields($input,true); + + //Finaling putting them together in their main array called $fields + if($custom_fields_with_group) + { + $custFieldGroups = $custom_fields_with_group; + + foreach($custFieldGroups as $gKey => $fieldGroup) + { + + foreach($fieldGroup['fields'] as $mainKey => $nField) + { + $updatedNewFields[$mainKey] = $nField; + if($input[$nField['db_field']]) + $value = $input[$nField['db_field']]; + elseif($input[$nField['name']]) + $value = $input[$nField['name']]; + + if($nField['type']=='radiobutton' || + $nField['type']=='checkbox' || + $nField['type']=='dropdown') + $updatedNewFields[$mainKey]['checked'] = $value; + else + $updatedNewFields[$mainKey]['value'] = $value; + + + } + + $fieldGroup['fields'] = $updatedNewFields; + + $group_id = $fieldGroup['group_id']; + + foreach($fields as $key => $field) + { + + if($field['group_id'] == $group_id) + { + $inputFields = $field['fields']; + //Setting field values + $newFields = $fieldGroup['fields']; + + + + $mergeField = array_merge($inputFields,$newFields); + + + //Finally Updating array + $newGroupArray = + array + ( + 'group_name' => $field['group_name'], + 'group_id' => $field['group_id'], + 'fields' => $mergeField, + ); + + $fields[$key] = $newGroupArray; + + $matched = true; + break; + }else + $matched = false; + } + + if(!$matched) + $fields[] = $fieldGroup; + + } + } + + if($more_fields_group) + $fields[] = $more_fields_group; + + return $fields; + } + + function isTime($time) + { + preg_match("/(([0-9]?[0-9]{1}):)?([0-5]{1}[0-9]{1}):([0-5]{1}[0-9]{1})/",$time,$match); + if(!empty($match[0])) + return ($match[0]); + else + return false; + } + + function time_to_sec($time) { + if(!$this->isTime($time)) + e(lang("Format of time is not right.")); + else + { + $hours = substr($time, 0, -6); + $minutes = substr($time, -5, 2); + $seconds = substr($time, -2); + return $hours * 3600 + $minutes * 60 + $seconds; + } + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/user.class.php b/upload/includes/classes/user.class.php new file mode 100644 index 00000000..f8cbbafa --- /dev/null +++ b/upload/includes/classes/user.class.php @@ -0,0 +1,5200 @@ + 'user_permission_types', + 'user_permissions' => 'user_permissions', + 'user_level_permission' => 'user_levels_permissions', + 'user_profile' => 'user_profile', + 'users' => 'users', + 'action_log' => 'action_log', + 'subtbl' => 'subscriptions', + 'contacts' => 'contacts', + ); + + var $udetails = array(); + + function userquery() + { + $this->cat_tbl = 'user_categories'; + } + + + function init() + { + global $sess,$Cbucket; + + +// $this->user_sess = $sess->get('user_sess'); + $this->sess_salt = $sess->get('sess_salt'); + $this->sessions = $this->get_sessions(); + + if($this->sessions['smart_sess']) + { + $this->userid = $this->sessions['smart_sess']['session_user']; + } + //$this->level = $sess->get('level'); + + //Setting Access + //Get list Of permission + //$perms = $this->get_permissions(); + //foreach($perms as $perm) + //{ + // $this->add_access_type($perm['permission_code'],$perm['permission_name']); + //} + + /*$this->add_access_type('admin_access','Admin Access'); + $this->add_access_type('upload_access','Upload Access'); + $this->add_access_type('channel_access','Channel Access'); + $this->add_access_type('mod_access','Moderator Access');*/ + + //Fetching List Of User Levels + $levels = $this->get_levels(); + foreach($levels as $level) + { + $this->usr_levels[$level['user_level_id']]=$level["user_level_name"]; + } + + $udetails = ""; + + if($this->userid) + $udetails = $this->get_user_details($this->userid,true); + + if($udetails) + { + + $this->udetails = $udetails; + $this->username = $udetails['username']; + $this->level = $this->udetails['level']; + $this->permission = $this->get_user_level(userid()); + //exit(); + + //Calling Logout Functions + $funcs = $this->init_login_functions; + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func(); + } + } + } + + + if($sess->get("dummy_username")=="") { + $this->UpdateLastActive(userid()); + } + }else { + + $this->permission = $this->get_user_level(4,TRUE); + } + + + + //Adding Actions such Report, share,fav etc + $this->action = new cbactions(); + $this->action->type = 'u'; + $this->action->name = 'user'; + $this->action->obj_class = 'userquery'; + $this->action->check_func = 'user_exists'; + $this->action->type_tbl = $this->dbtbl['users']; + $this->action->type_id_field = 'userid'; + + define('AVATAR_SIZE',config('max_profile_pic_width')); + define('AVATAR_SMALL_SIZE',40); + define('BG_SIZE',config('max_bg_width')); + define('BACKGROUND_URL',config('background_url')); + define("USE_GAVATAR",config('gravatars') ? config('gravatars') : false); //Use Gavatar + define('BACKGROUND_COLOR',config('background_color')); + + if(isSectionEnabled('channels')) + $Cbucket->search_types['users'] = "userquery"; + + } + + /** + * Function used to create user session key + */ + function create_session_key($session,$pass) + { + $newkey = $session.$pass; + $newkey = md5($newkey); + return $newkey; + } + + /** + * Function used to create user session code + * just for session authentication incase user wants to login again + */ + function create_session_code() + { + $code = rand(10000,99999); + return $code; + } + + /** + * Neat and clean function to login user + * this function was made for v2.x with User Level System + * param VARCHAR $username + * param TEXT $password + */ + function login_user($username,$password,$remember=false) + { + global $LANG,$sess,$cblog,$db; + //Now checking if user exists or not + $pass = pass_code($password); + + $udetails = $this->get_user_with_pass($username,$pass); + + //Inerting Access Log + $log_array = array('username'=>$username); + + //First we will check weather user is already logged in or not + if($this->login_check(NULL,true)) + $msg[] = e(lang('you_already_logged')); + elseif(!$this->user_exists($username)) + $msg[] = e(lang('user_doesnt_exist')); + elseif(!$udetails) + $msg[] = e(lang('usr_login_err')); + elseif(strtolower($udetails['usr_status']) != 'ok') + $msg[] = e(lang('user_inactive_msg')); + elseif($udetails['ban_status'] == 'yes') + $msg[] = e(lang('usr_ban_err')); + else + { + + $log_array['userid'] = $userid = $udetails['userid']; + $log_array['useremail'] = $udetails['email']; + $log_array['success'] = 1; + + $log_array['level'] = $level = $udetails['level']; + + //Adding Sessing In Database + //$sess->add_session($userid,'logged_in'); + + //$sess->set('username',$username); + //$sess->set('userid',$userid); + + //Setting Timeout + if($remember) + $sess->timeout = 86400*REMBER_DAYS; + + //Starting special sessions for security + $session_salt = RandomString(5); + $sess->set('sess_salt',$session_salt); + $sess->set('PHPSESSID',$sess->id); + + $smart_sess = md5($udetails['user_session_key'].$session_salt); + + $db->delete(tbl("sessions"),array("session","session_string"),array($sess->id,"guest")); + $sess->add_session($userid,'smart_sess',$smart_sess); + + //$sess->set('user_sess',$smart_sess); + + //$sess->set('user_session_key',$udetails['user_session_key']); + //$sess->set('user_session_code',$udetails['user_session_code']); + + + //Setting Vars + $this->userid = $udetails['userid']; + $this->username = $udetails['username']; + $this->level = $udetails['level']; + + //Updating User last login , num of visist and ip + $db->update(tbl('users'), + array( + 'num_visits','last_logged','ip' + ), + array( + '|f|num_visits+1',NOW(),$_SERVER['REMOTE_ADDR'] + ), + "userid='".$userid."'" + ); + + + $this->init(); + //Logging Actiong + $cblog->insert('login',$log_array); + + return true; + } + + //Error Loging + if(!empty($msg)) + { + //Loggin Action + $log_array['success'] = no; + $log_array['details'] = $msg[0]; + $cblog->insert('login',$log_array); + } + } + + + + + /** + * Function used to check weather user is login or not + * it will also check weather user has access or not + * @param VARCHAR acess type it can be admin_access, upload_acess etc + * you can either set it as level id + */ + function login_check($access=NULL,$check_only=FALSE,$verify_logged_user=TRUE) + { + global $LANG,$Cbucket,$sess; + + + if($verify_logged_user) + { + //First check weather userid is here or not + if(!userid()) + { + if(!$check_only) + e(lang('you_not_logged_in')); + return false; + } + elseif(!$this->session_auth(userid())) + { + + if(!$check_only) + e(lang('usr_invalid_session_err')); + return false; + } + + //Now Check if logged in user exists or not + elseif(!$this->user_exists(userid(),TRUE)) + { + if(!$check_only) + e(lang('invalid_user')); + return false; + } + //Now Check logged in user is banned or not + elseif($this->is_banned(userid())=='yes') + { + if(!$check_only) + e(lang('usr_ban_err')); + return false; + } + } + + //Now user have passed all the stages, now checking if user has level access or not + if($access) + { + //$access_details = $this->get_user_level(userid()); + $access_details = $this->permission; + if(is_numeric($access)) + { + if($access_details['level_id'] == $access) + { + return true; + }else{ + + if(!$check_only) + e(lang('insufficient_privileges')); + $Cbucket->show_page(false); + return false; + } + }else + { + if($access_details[$access] == 'yes') + { + + return true; + } + else + { + if(!$check_only) + { + e(lang('insufficient_privileges')); + $Cbucket->show_page(false); + } + return false; + } + } + } + else + { + return true; + } + } + + /** + * This function was used to check + * user is logged in or not -- for v1.7.x and old + * it has been replaced by login_check in v2 + * this function is sitll in use so + * we are just replace the lil code of it + */ + function logincheck($access=NULL,$redirect=TRUE) + { + + if(!$this->login_check($access)) + { + if($redirect==TRUE) + redirect_to(BASEURL.signup_link); + return false; + } + else + { + return true; + } + } + + /** + * Function used to authenticate user session + */ + function session_auth($uid) + { + global $sess; + + return true; + /*if($sess->get('user_session_key') == $ufields['user_session_key'] + && $sess->get('user_session_code') == $ufields['user_session_code'])*/ + if($this->user_sessions['key']=='') + { + $ufields = $this->get_user_fields($uid,'user_session_key,user_session_code'); + //echo test; + $this->user_sessions['key'] = $ufields['user_session_key']; + $this->user_sessions['code'] = $ufields['user_session_code']; + } + + if($this->user_sessions['key']==$sess->get('user_session_key') + && $this->user_sessions['code']==$sess->get('user_session_code') + ||( has_access("admin_access") && $sess->get("dummy_username")!="")) + + return true; + else + return false; + } + + /** + * Function used to get user details using username and password + */ + function get_user_with_pass($username,$pass) + { + global $db; + $results = $db->select(tbl("users"), + "userid,email,level,usr_status,user_session_key,user_session_code", + "(username='$username' OR userid='$username') AND password='$pass'"); + if($db->num_rows > 0) + { + return $results[0]; + }else{ + return false; + } + } + + + /** + * Function used to check weather user is banned or not + */ + function is_banned($uid) + { + global $db; + //echo $this->udetails['ban_status']; + if(empty($this->udetails['ban_status']) && userid()) + $this->udetails['ban_status'] = $this->get_user_field($uid,'ban_status'); + return $this->udetails['ban_status']; + } + + function admin_check() + { + return $this->login_check('admin_access'); + } + + /** + * Function used to check user is admin or not + * @param BOOLEAN if true, after checcking user will be redirected to login page if needed + */ + function admin_login_check($check_only=false) + { + if(!has_access('admin_access',true)) + { + if($check_only==FALSE) + redirect_to('login.php'); + return false; + }else{ + return true; + } + } + + //This Function Is Used to Logout + function logout($page='login.php') + { + global $sess; + + //Calling Logout Functions + $funcs = $this->logout_functions; + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func(); + } + } + } + + $sess->un_set('sess_salt'); + $sess->destroy(); + //$sess->remove_session(userid()); + } + + + + /** + * Function used to delete user + */ + function delete_user($uid) + { + global $db; + + if($this->user_exists($uid)) + { + + $udetails = $this->get_user_details($uid); + + if(userid()!=$uid&&has_access('admin_access',true)&&$uid!=1) + { + //list of functions to perform while deleting a video + $del_user_funcs = $this->delete_user_functions; + if(is_array($del_user_funcs)) + { + foreach($del_user_funcs as $func) + { + if(function_exists($func)) + { + $func($udetails); + } + } + } + + //Removing Subsriptions and subscribers + $this->remove_user_subscriptions($uid); + $this->remove_user_subscribers($uid); + + //Changing User Videos To Anonymous + $db->execute("UPDATE ".tbl("video")." SET userid='".$this->get_anonymous_user()."' WHERE userid='".$uid."'"); + //Changing User Group To Anonymous + $db->execute("UPDATE ".tbl("groups")." SET userid='".$this->get_anonymous_user()."' WHERE userid='".$uid."'"); + //Deleting User Contacts + $this->remove_contacts($uid); + + //Deleting User PMS + $this->remove_user_pms($uid); + //Changing From Messages to Anonymous + $db->execute("UPDATE ".tbl("messages")." SET message_from='".$this->get_anonymous_user()."' WHERE message_from='".$uid."'"); + //Finally Removing Database entry of user + $db->execute("DELETE FROM ".tbl("users")." WHERE userid='$uid'"); + $db->execute("DELETE FROM ".tbl("user_profile")." WHERE userid='$uid'"); + + e(lang("usr_del_msg"),"m"); + }else{ + e(lang("you_cant_delete_this_user")); + } + }else{ + e(lang("user_doesnt_exist")); + } + } + + /** + * Remove all user subscriptions + */ + function remove_user_subscriptions($uid) + { + global $db; + if(!$this->user_exists($uid)) + e(lang("user_doesnt_exist")); + elseif(!has_access('admin_access')) + e(lang("you_dont_hv_perms")); + else + { + $db->execute("DELETE FROM ".tbl($this->dbtbl['subtbl'])." WHERE userid='$uid'"); + e(lang("user_subs_hv_been_removed"),"m"); + } + } + + /** + * Remove all user subscribers + */ + function remove_user_subscribers($uid) + { + global $db; + if(!$this->user_exists($uid)) + e(lang("user_doesnt_exist")); + elseif(!has_access('admin_access')) + e(lang("you_dont_hv_perms")); + else + { + $db->execute("DELETE FROM ".tbl($this->dbtbl['subtbl'])." WHERE subscribed_to='$uid'"); + e(lang("user_subsers_hv_removed"),"m"); + } + } + + + //Delete User + function DeleteUser($id){ + return $this->delete_user($id); + } + + //Check User Exists or Not + function Check_User_Exists($id,$global=false){ + global $db; + + if($global) + { + if(empty($this->user_exist)) + { + if(is_numeric($id)) + $result = $db->count(tbl($this->dbtbl['users']),"userid"," userid='".$id."' "); + else + $result = $db->count(tbl($this->dbtbl['users']),"userid"," username='".$id."' "); + if($result>0) + { + $this->user_exist = 'yes'; + }else{ + $this->user_exist = 'no'; + } + } + + if($this->user_exist=='yes') + return true; + else + return false; + }else + { + if(is_numeric($id)) + $result = $db->count(tbl($this->dbtbl['users']),"userid"," userid='".$id."'"); + else + $result = $db->count(tbl($this->dbtbl['users']),"userid"," username='".$id."'"); + if($result>0) + { + return true; + }else{ + return false; + } + } + + } + + function user_exists($username,$global=false) + { + return $this->Check_User_Exists($username,$global); + } + + /** + * Function used to get user details using userid + */ + function get_user_details($id=NULL,$checksess=false) + { + global $db,$sess; + /*if(!$id) + $id = userid();*/ + if(is_numeric($id)) + $results = $db->select(tbl('users'),'*'," userid='$id'"); + else + $results = $db->select(tbl('users'),'*'," username='".$id."' OR email='".$id."'"); + $udetails = $results[0]; + + if(!$checksess) + return $udetails; + else + { + $session = $this->sessions['smart_sess']; + $udetails['user_session_key']; + $smart_sess = md5($udetails['user_session_key'].$sess->get('sess_salt')); + + if($smart_sess==$session['session_value']) + { + $this->is_login = true; + return $udetails; + }else + return false; + } + + }function GetUserData($id=NULL){ return $this->get_user_details($id); } + + + + + //Function Used To Activate User + function activate_user_with_avcode($user,$avcode) + { + global $eh; + $data = $this->get_user_details($user); + if(!$data || !$user) + e(lang("usr_exist_err")); + elseif($data['usr_status']=='Ok') + e(lang('usr_activation_err')); + elseif($data['ban_status']=='yes') + e(lang('ban_status')); + elseif($data['avcode'] !=$avcode) + e(lang('avcode_incorrect')); + else + { + $this->action('activate',$data['userid']); + $eh->flush(); + e(lang("usr_activation_msg"),"m"); + + if($data['welcome_email_sent']=='no') + $this->send_welcome_email($data,TRUE); + } + } + + + /** + * Function used to send activation code + * to user + * @param : $usenrma,$email or $userid + */ + function send_activation_code($email) + { + global $db,$cbemail; + $udetails = $this->get_user_details($email); + + if(!$udetails || !$email) + e(lang("usr_exist_err")); + elseif($udetails['usr_status']=='Ok') + e(lang('usr_activation_err')); + elseif($udetails['ban_status']=='yes') + e(lang('ban_status')); + else + { + $tpl = $cbemail->get_template('avcode_request_template'); + $more_var = array + ('{username}' => $udetails['username'], + '{email}' => $udetails['email'], + '{avcode}' => $udetails['avcode'] + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$udetails['email'],'from'=>SUPPORT_EMAIL,'subject'=>$subj,'content'=>$msg)); + e(lang('usr_activation_em_msg'),"m"); + } + } + function SendActivation($email) + { + return $this->send_activation_code($email); + } + + /** + * Function used to send welcome email + */ + function send_welcome_email($user,$update_email_status=FALSE) + { + global $db,$cbemail; + + if(!is_array($user)) + $udetails = $this->get_user_details($user); + else + $udetails = $user; + + if(!$udetails) + e(lang("usr_exist_err")); + else + { + $tpl = $cbemail->get_template('welcome_message_template'); + $more_var = array + ('{username}' => $udetails['username'], + '{email}' => $udetails['email'], + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$udetails['email'],'from'=>WELCOME_EMAIL,'subject'=>$subj,'content'=>$msg)); + + if($update_email_status) + $db->update(tbl($this->dbtbl['users']),array('welcome_email_sent'),array("yes")," userid='".$udetails['userid']."' "); + } + } + + + /** + * Function used to change user password + */ + function ChangeUserPassword($array) + { + global $db; + + $old_pass = $array['old_pass']; + $new_pass = $array['new_pass']; + $c_new_pass = $array['c_new_pass']; + + $uid = $array['userid']; + + if(!$this->get_user_with_pass($uid,pass_code($old_pass))) + e(lang('usr_pass_err')); + elseif(empty($new_pass)) + e(lang('usr_pass_err2')); + elseif($new_pass != $c_new_pass) + e(lang('usr_cpass_err1')); + else + { + $db->update(tbl($this->dbtbl['users']),array('password'),array(pass_code($array['new_pass']))," userid='".$uid."'"); + e(lang("usr_pass_email_msg"),"m"); + + } + + return $msg; + } + function change_user_pass($array){ return $this->ChangeUserPassword($array); } + function change_password($array){ return $this->ChangeUserPassword($array); } + + /** + * Function used to add contact + */ + function add_contact($uid,$fid) + { + global $cbemail,$db; + + $friend = $this->get_user_details($fid); + $sender = $this->get_user_details($uid); + + if(!$friend) + e(lang('usr_exist_err')); + elseif($this->is_requested_friend($uid,$fid)) + e(lang("you_already_sent_frend_request")); + elseif($this->is_requested_friend($uid,$fid,"in")) + { + $this->confirm_friend($fid,$uid); + e(lang("friend_added")); + }elseif($uid==$fid) + { + e(lang("friend_add_himself_error")); + }else + { + $db->insert(tbl($this->dbtbl['contacts']),array('userid','contact_userid','date_added','request_type'), + array($uid,$fid,now(),'out')); + $insert_id = $db->insert_id(); + + e(lang("friend_request_sent"),"m"); + + //Sending friendship request email + $tpl = $cbemail->get_template('friend_request_email'); + + + $more_var = array + ( + '{reciever}' => $friend['username'], + '{sender}' => $sender['username'], + '{sender_link}'=> $this->profile_link($sender), + '{request_link}'=> BASEURL.'/manage_contacts.php?mode=request&confirm='.$uid + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$friend['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + } + + } + + /** + * Function used to check weather users are confirmed friends or not + */ + function is_confirmed_friend($uid,$fid) + { + global $db; + $count = $db->count(tbl($this->dbtbl['contacts']),"contact_id", + " (userid='$uid' AND contact_userid='$fid') OR (userid='$fid' AND contact_userid='$uid') AND confirmed='yes'" ); + if($count[0]>0) + return true; + else + return false; + } + + /** + * function used to check weather users are firends or not + */ + function is_friend($uid,$fid) + { + global $db; + $count = $db->count(tbl($this->dbtbl['contacts']),"contact_id", + " (userid='$uid' AND contact_userid='$fid') OR (userid='$fid' AND contact_userid='$uid')" ); + if($count[0]>0) + return true; + else + return false; + } + + /** + * Function used to check weather user has already requested friendship or not + */ + function is_requested_friend($uid,$fid,$type='out',$confirm=NULL) + { + global $db; + + $query = ""; + if($confirm) + $query = " AND confirmed='$confirm' "; + + if($type=='out') + $count = $db->count(tbl($this->dbtbl['contacts']),"contact_id"," userid='$uid' AND contact_userid='$fid' $query" ); + + else + $count = $db->count(tbl($this->dbtbl['contacts']),"contact_id"," userid='$fid' AND contact_userid='$uid' $query" ); + + if($count[0]>0) + return true; + else + return false; + } + + /** + * Function used to confirm friend + */ + function confirm_friend($uid,$rid,$msg=TRUE) + { + global $cbemail,$db; + if(!$this->is_requested_friend($rid,$uid,'out','no')) + { + if($msg) + e(lang("friend_confirm_error")); + }else + { + addFeed(array('action' => 'add_friend','object_id' => $rid,'object'=>'friend','uid'=>$uid)); + addFeed(array('action' => 'add_friend','object_id' => $uid,'object'=>'friend','uid'=>$rid)); + + $db->insert(tbl($this->dbtbl['contacts']),array('userid','contact_userid','date_added','request_type','confirmed'), + array($uid,$rid,now(),'in','yes')); + $db->update(tbl($this->dbtbl['contacts']),array('confirmed'),array("yes")," userid='$rid' AND contact_userid='$uid' " ); + if($msg) + e(lang("friend_confirmed"),"m"); + //Sending friendship confirmation email + $tpl = $cbemail->get_template('friend_confirmation_email'); + + $friend = $this->get_user_details($rid); + $sender = $this->get_user_details($uid); + + $more_var = array + ( + '{reciever}' => $friend['username'], + '{sender}' => $sender['username'], + '{sender_link}'=> $this->profile_link($sender), + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + + //Now Finally Sending Email + cbmail(array('to'=>$friend['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + + + //Loggin Friendship + + $log_array = array + ( + 'success'=>'yes', + 'action_obj_id' => $friend['userid'], + 'details'=>"friend with ".$friend['username'] + ); + + insert_log('add_friend',$log_array); + + $log_array = array + ( + 'success'=>'yes', + 'username' => $friend['username'], + 'userid' => $friend['userid'], + 'userlevel' => $friend['level'], + 'useremail' => $friend['email'], + 'action_obj_id' => $insert_id, + 'details'=> "friend with ".userid() + ); + + //Login Upload + insert_log('add_friend',$log_array); + } + } + + /** + * Function used to confirm request + */ + function confirm_request($rid,$uid=NULL) + { + global $db; + + if(!$uid) + $uid = userid(); + + $result = $db->select(tbl($this->dbtbl['contacts']),"*"," userid='$rid' AND contact_userid='$uid' "); + $result = $result[0]; + + if($db->num_rows==0) + e(lang("friend_request_not_found")); + elseif($uid!=$result['contact_userid']) + e(lang("you_cant_confirm_this_request")); + elseif($result['confirmed']=='yes') + e(lang("friend_request_already_confirmed")); + else + { + $this->confirm_friend($uid,$result['userid']); + } + } + + + /** + * Function used to get user contacts + */ + function get_contacts($uid,$group=0,$confirmed=NULL,$count_only=false,$type=NULL) + { + global $db; + + $query = ""; + if($confirmed) + $query .= " AND ".tbl("contacts").".confirmed='$confirmed' "; + if($type) + $query .= " AND ".tbl("contacts").".request_type='$type' "; + if(!$count_only) + { + $result = $db->select(tbl("contacts,users"), + tbl("contacts.contact_userid,contacts.confirmed,contacts.request_type ,users.*"), + tbl("contacts.userid")."='$uid' AND ".tbl("users.userid")."=".tbl("contacts.contact_userid")." + $query AND ".tbl("contacts").".contact_group_id='$group' "); + + if($db->num_rows>0) + return $result; + else + return false; + }else{ + $count = $db->count(tbl("contacts"), + tbl("contacts.contact_userid"), + tbl("contacts.userid")."='$uid' + $query AND ".tbl("contacts").".contact_group_id='$group' "); + return $count; + } + } + + /** + * Function used to get pending contacts + */ + function get_pending_contacts($uid,$group=0,$count_only=false) + { + global $db; + + if(!$count_only) + { + $result = $db->select(tbl("contacts,users"), + tbl("contacts.userid,contacts.confirmed,contacts.request_type ,users.*"), + tbl("contacts.contact_userid")."='$uid' AND ".tbl("users.userid")."=".tbl("contacts.userid")." + AND ".tbl("contacts.confirmed")."='no' AND ".tbl("contacts").".contact_group_id='$group' "); + if($db->num_rows>0) + return $result; + else + return false; + }else + { + $count = $db->count(tbl("contacts"), + tbl("contacts.contact_userid"), + tbl("contacts.contact_userid")."='$uid' AND ".tbl("contacts.confirmed")."='no' AND ".tbl("contacts").".contact_group_id='$group' "); + //echo $db->db_query; + return $count; + } + } + + /** + * Function used to get pending contacts + */ + function get_requested_contacts($uid,$group=0) + { + global $db; + $result = $db->select(tbl($this->dbtbl['contacts']),"*"," contact_userid='$uid' AND confirmed='no' AND contact_group_id='$group' "); + if($db->num_rows>0) + return $result; + else + return false; + } + + + /** + * Function used to remove user from contact list + * @param fid {id of friend that user wants to remove} + * @param uid {id of user who is removing other from friendlist} + */ + function remove_contact($fid,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + if(!$this->is_friend($fid,$uid)) + e(lang("user_no_in_contact_list")); + else + { + $db->Execute("DELETE from ".tbl($this->dbtbl['contacts'])." WHERE + (userid='$uid' AND contact_userid='$fid') OR (userid='$fid' AND contact_userid='$uid')" ); + e(lang("user_removed_from_contact_list"),"m"); + } + } + + /** + * Funcion used to increas user total_watched field + */ + function increment_watched_vides($userid) + { + global $db; + $db->update(tbl($this->dbtbl['users']),array('total_watched'),array('|f|total_watched+1')," userid='$userid'"); + } + + /** + * Old Function : GetNewMsgs + * This function is used to get user messages + * @param : user + * @param : sent/inbox + * @param : count (TRUE : FALSE) + */ + + function get_pm_msgs($user,$box='inbox',$count=FALSE){ + global $db,$eh,$LANG; + if(!$user) + $user = user_id(); + if(!user_id()) + { + $eh->e(lang('you_not_logged_in')); + }else{ + switch($box) + { + case 'inbox': + default: + $boxtype = 'inbox'; + break; + + case 'sent': + case 'outbox': + $boxtype = 'outbox'; + break; + } + + if($count) + $status_query = " AND status = '0' "; + + $results = $db->select(tbl("messages"), + " message_id ", + "(".$boxtype."_user = '$user' OR ".$boxtype."_user_id = '$user') $status_query"); + + + if($db->num_rows > 0) + { + if($count) + return $db->num_rows; + else + return $results; + } + else + { + return false; + } + } + } + function GetNewMsgs($user) + { + $msgs = $this->get_pm_msgs($user,'inbox',TRUE); + if($msgs) + return $msgs; + else + return 0; + } + + + /** + * Function used to subscribe user + */ + function subscribe_user($to,$user=NULL) + { + if(!$user) + $user = userid(); + global $db; + + $to_user = $this->get_user_details($to); + + if(!$this->user_exists($to)) + e(lang('usr_exist_err')); + elseif(!$user) + e(sprintf(lang('please_login_subscribe'),$to_user['username'])); + elseif($this->is_subscribed($to,$user)) + e(sprintf(lang("usr_sub_err"),$to_user['username'])); + elseif($to_user['userid'] == $user) + e(lang("you_cant_sub_yourself")); + else + { + $db->insert(tbl($this->dbtbl['subtbl']),array('userid','subscribed_to','date_added'), + array($user,$to,NOW())); + $db->update(tbl($this->dbtbl['users']),array('subscribers'), + array($this->get_user_subscribers($to,true))," userid='$to' "); + $db->update(tbl($this->dbtbl['users']),array('total_subscriptions'), + array($this->get_user_subscriptions($user,'count'))," userid='$user' "); + //Loggin Comment + $log_array = array + ( + 'success'=>'yes', + 'details'=> "subsribed to ".$to_user['username'], + 'action_obj_id' => $to_user['userid'], + 'action_done_id' => $db->insert_id(), + ); + insert_log('subscribe',$log_array); + + e(sprintf(lang('usr_sub_msg'),$to_user['username']),'m'); + } + } + function SubscribeUser($sub_user,$sub_to){return $this->subscribe_user($sub_to,$sub_user);} + + /** + * Function used to check weather user is already subscribed or not + */ + function is_subscribed($to,$user=NULL) + { + if(!$user) + $user = userid(); + global $db; + + if(!$user) + return false; + $result = $db->select(tbl($this->dbtbl['subtbl']),"*"," subscribed_to='$to' AND userid='$user'"); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to remove user subscription + */ + function remove_subscription($subid,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + if($this->is_subscribed($subid,$uid)) + { + $db->execute("DELETE FROM ".tbl($this->dbtbl['subtbl'])." WHERE userid='$uid' AND subscribed_to='$subid'"); + e(lang("class_unsub_msg"),"m"); + + $db->update(tbl($this->dbtbl['users']),array('subscribers'), + array($this->get_user_subscribers($subid,true))," userid='$subid' "); + $db->update(tbl($this->dbtbl['users']),array('total_subscriptions'), + array($this->get_user_subscriptions($uid,'count'))," userid='$uid' "); + + + return true; + }else + e(lang("you_not_subscribed")); + + return false; + }function unsubscribe_user($subid,$uid=NULL){ return $this->remove_subscription($subid,$uid); } + + + /** + * Function used to get user subscibers + * @param userid + */ + function get_user_subscribers($id,$count=false) + { + global $db; + if(!$count) + { + $result = $db->select(tbl('subscriptions'),"*", + " subscribed_to='$id' "); + if($db->num_rows>0) + return $result; + else + return false; + }else + { + return $db->count(tbl($this->dbtbl['subtbl']),"subscription_id"," subscribed_to='$id' "); + } + } + + /** + * function used to get user subscribers with details + */ + function get_user_subscribers_detail($id,$limit=NULL) + { + global $db; + $result = $db->select(tbl("users,".$this->dbtbl['subtbl']),"*"," ".tbl("subscriptions.subscribed_to")." = '$id' AND ".tbl("subscriptions.userid")."=".tbl("users.userid"),$limit); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to get user subscriptions + */ + function get_user_subscriptions($id,$limit=NULL) + { + global $db; + if($limit!='count') + { + $result = $db->select(tbl("users,".$this->dbtbl['subtbl']),"*"," ".tbl("subscriptions.userid")." = '$id' AND ".tbl("subscriptions.subscribed_to")."=".tbl("users.userid"),$limit); + + if($db->num_rows>0) + return $result; + else + return false; + }else + { + $result = $db->count(tbl($this->dbtbl['subtbl']),"subscription_id"," userid = '$id'"); + return $result; + } + } + + + + + /** + * Function used to reset user password + * it has two steps + * 1 to send confirmation + * 2 to reset the password + */ + + function reset_password($step,$input,$code=NULL) + { + global $cbemail,$db; + switch($step) + { + case 1: + { + $udetails = $this->get_user_details($input); + if(!$udetails) + e(lang('usr_exist_err')); + //verifying captcha... + elseif(!verify_captcha()) + e(lang('usr_ccode_err')); + else + { + //Sending confirmation email + $tpl = $cbemail->get_template('password_reset_request'); + $avcode = $udetails['avcode']; + if(!$udetails['avcode']) + { + $avcode = RandomString(10); + $db->update(tbl($this->dbtbl['users']),array('avcode'),array($avcode)," userid='".$udetails['userid']."'"); + } + + $more_var = array + ('{username}' => $udetails['username'], + '{email}' => $udetails['email'], + '{avcode}' => $avcode, + '{userid}' => $udetails['userid'], + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$udetails['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + + e(lang('usr_rpass_email_msg'),"m"); + return true; + } + } + break; + case 2: + { + $udetails = $this->get_user_details($input); + if(!$udetails) + e(lang('usr_exist_err')); + //verifying captcha... + elseif($udetails['avcode'] !=$code) + e(lang('usr_ccode_err')); + else + { + $newpass = RandomString(6); + $pass = pass_code($newpass); + $avcode = RandomString(10); + $db->update(tbl($this->dbtbl['users']),array('password','avcode'),array($pass,$avcode)," userid='".$udetails['userid']."'"); + //sending new password email... + //Sending confirmation email + $tpl = $cbemail->get_template('password_reset_details'); + $more_var = array + ('{username}' => $udetails['username'], + '{email}' => $udetails['email'], + '{avcode}' => $udetails['avcode'], + '{userid}' => $udetails['userid'], + '{password}' => $newpass, + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$udetails['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + e(lang('usr_pass_email_msg'),'m'); + return true; + } + } + break; + } + } + + /** + * Function used to recover username + */ + function recover_username($email) + { + global $cbemail; + $udetails = $this->get_user_details($email); + if(!$udetails) + e(lang('no_user_associated_with_email')); + elseif(!verify_captcha()) + e(lang('usr_ccode_err')); + else + { + $tpl = $cbemail->get_template('forgot_username_request'); + $more_var = array + ( + '{username}' => $udetails['username'], + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$udetails['email'],'from'=>SUPPORT_EMAIL,'subject'=>$subj,'content'=>$msg)); + e(lang("usr_uname_email_msg"),'m'); + } + return $msg; + + + } + + //FUNCTION USED TO UPDATE LAST ACTIVE FOR OF USER + // @ Param : username + function UpdateLastActive($username) + { + global $db; + + $sql = "UPDATE ".tbl("users")." SET last_active = '".NOW()."' WHERE username='".$username."' OR userid='".$username."' "; + $db->Execute($sql); + } + + + /** + * FUNCTION USED TO GE USER THUMBNAIL + * @param : thumb file + * @param : size (NULL,small) + */ + function getUserThumb($udetails,$size='',$uid=NULL,$just_file=false) + { + $remote = false; + if(empty($udetails['userid']) && $uid) + $udetails = $this->get_user_details($uid); + //$thumbnail = $udetails['avatar'] ? $udetails['avatar'] : NO_AVATAR; + $thumbnail = $udetails['avatar']; + $thumb_file = USER_THUMBS_DIR.'/'.$thumbnail; + + + if(file_exists($thumb_file) && $thumbnail) + $thumb_file = USER_THUMBS_URL.'/'.$thumbnail; + elseif(!empty($udetails['avatar_url'])) + { + $thumb = $udetails['avatar_url']; + $remote = true; + }else + { + if(!USE_GAVATAR) + $thumb_file = $this->get_default_thumb(); + else + { + switch($size) + { + case "small": + { + $thesize = AVATAR_SMALL_SIZE; + $default = $this->get_default_thumb('small'); + + } + break; + default: + { + $thesize = AVATAR_SIZE; + $default = $this->get_default_thumb(); + } + } + + $email = $udetails['email']; + $email = $email ? $email : $udetails['anonym_email']; + $gravatar = new Gravatar($email, $default); + $gravatar->size = $thesize; + $gravatar->rating = "G"; + $gravatar->border = "FF0000"; + + $thumb = $gravatar->getSrc(); + //echo $gravatar->toHTML(); + } + } + + $ext = GetExt($thumb_file); + $file = getName($thumb_file); + + if(!$remote) + { + if(!empty($size) && !$thumb) + $thumb = USER_THUMBS_URL.'/'.$file.'-'.$size.'.'.$ext; + elseif(!$thumb) + $thumb = USER_THUMBS_URL.'/'.$file.'.'.$ext; + } + + if($just_file) + return $file.'.'.$ext; + + return $thumb; + } + function avatar($udetails,$size='',$uid=NULL) + { + return $this->getUserThumb($udetails,$size,$uid); + } + + /** + * Function used to get default user thumb + */ + function get_default_thumb($size=NULL) + { + if($size=="small" && file_exists(TEMPLATEDIR.'/images/thumbs/no_avatar-small.png')) + { + return TEMPLATEURL.'/images/thumbs/no_avatar-small.png'; + }elseif(file_exists(TEMPLATEDIR.'/images/thumbs/no_avatar.png') && !$size) + { + return TEMPLATEURL.'/images/thumbs/no_avatar.png'; + }else + { + if($size=='small') + return USER_THUMBS_URL.'/'.getName(NO_AVATAR).'-small.'.getExt(NO_AVATAR); + else + return USER_THUMBS_URL.'/'.NO_AVATAR; + } + } + + /** + * Function used to get user Background + * @param : bg file + */ + function getUserBg($udetails,$check=false) + { + $remote = false; + if(empty($udetails['userid'])) + $udetails = $this->get_user_details($uid); + //$thumbnail = $udetails['avatar'] ? $udetails['avatar'] : 'no_avatar.jpg'; + $file = $udetails['background']; + $bgfile = USER_BG_DIR.'/'.$file; + if(file_exists($bgfile) && $file) + $thumb_file = USER_BG_URL.'/'.$file; + elseif(!empty($udetails['background_url']) && BACKGROUND_URL=='yes') + { + $thumb_file = $udetails['background_url']; + $remote = true; + }elseif(!empty($udetails['background_color']) && BACKGROUND_COLOR =='yes' && $check) + { + return true; + }else + return false; + + return $thumb_file; + } + + + + /** + * Function used to get user subscriber's list + * @param VARCHAR//INT username or userid , both works fine + */ + function get_user_subscriber($username) + { + global $db; + $results = $db->Execute("SELECT * FROM ".tbl("subscriptions")." WHERE subsctibe_to='$username'"); + if($results->recordcount() > 0) + return $results->getrows(); + else + return false; + } + + + + /** + * Function used to get user field + * @ param INT userid + * @ param FIELD name + */ + function get_user_field($uid,$field) + { + global $db; + + if(is_numeric($uid)) + $results = $db->select(tbl('users'),$field,"userid='$uid'"); + else + $results = $db->select(tbl('users'),$field,"username='$uid'"); + + if($db->num_rows>0) + { + return $results[0]; + }else{ + return false; + } + }function get_user_fields($uid,$field){return $this->get_user_field($uid,$field);} + + + /** + * This function will return + * user field without array + */ + function get_user_field_only($uid,$field) + { + $fields = $this->get_user_field($uid,$field); + return $fields[$field]; + } + + /** + * Function used to get user level and its details + * @param INT userid + */ + function get_user_level($uid,$is_level=false) + { + global $db; + + if($is_level) + { + $level = $uid; + } + else + { + $level = $this->udetails['level']; + } + + + $result = $db->select(tbl('user_levels,user_levels_permissions'),'*', + tbl("user_levels_permissions.user_level_id")."='".$level."' + AND ".tbl("user_levels_permissions.user_level_id")." = ".tbl("user_levels.user_level_id")); + + + /* + pr($result); + $results = $db->select(tbl('user_levels'),'*'," user_level_id='".$level['level']."'"); + if($db->num_rows == 0) + //incase user level is not valid, it will consider it as registered user + $u_level['user_level_id'] = 3; + else + $u_level = $results[0]; + + //Now Getting Access Details + $access_results = $db->select("user_levels_permissions","*", + "user_level_id = '".$u_level['user_level_id']."'"); + $a_results = $access_results[0];*/ + + //Now Merging the two arrays + $user_level = $result[0]; + //pr($user_level); + return $user_level; + } + + + /** + * Function used to get all levels + * @param : filter + */ + function get_levels($filter=NULL) + { + global $db; + $results = $db->select(tbl("user_levels"),"*",NULL,NULL," user_level_id ASC" ); + if($db->num_rows > 0) + { + return $results; + }else{ + return false; + } + } + + + /** + * Function used to get level details + * @param : level_id INT + */ + function get_level_details($lid) + { + global $db; + $results = $db->select(tbl("user_levels"),"*"," user_level_id='$lid' "); + if($db->num_rows > 0 ) + { + return $results[0]; + }else{ + e(lang("cant_find_level")); + return false; + } + } + + /** + * Function used to get users of particular level + * @param : level_id + * @param : count BOOLEAN (if TRUE it will return NUMBERS) + */ + function get_level_users($id,$count=FALSE,$fields="level") + { + global $db; + if($fields == "all") + $fields = "*"; + + $results = $db->select(tbl("users"),$fields," level='$id'"); + if($db->num_rows>0) + { + if($count) + return $db->num_rows; + else + return $results; + }else{ + return 0; + } + } + + + /** + * Function used to add user level + */ + function add_user_level($array) + { + global $db; + if(!is_array($array)) + $array = $_POST; + $level_name = mysql_clean($array['level_name']); + if(empty($level_name)) + e(lang("please_enter_level_name")); + else + { + $db->insert(tbl("user_levels"),array('user_level_name'),array($level_name)); + $iid = $db->insert_id(); + + $fields_array[] = 'user_level_id'; + $value_array[] = $iid; + foreach($this->get_access_type_list() as $access => $name) + { + $fields_array[] = $access; + $value_array[] = $array[$access] ? $array[$access] : 'no'; + } + $db->insert(tbl("user_levels_permissions"),$fields_array,$value_array); + return true; + } + } + + /** + * Function usewd to get level permissions + */ + function get_level_permissions($id) + { + global $db; + $results = $db->select(tbl("user_levels_permissions"),"*"," user_level_id = '$id'"); + if($db->num_rows>0) + return $results[0]; + else + return false; + } + + /** + * Function used to get custom permissions + */ + function get_access_type_list() + { + if(!$this->access_type_list) + { + $perms = $this->get_permissions(); + foreach($perms as $perm) + { + $this->add_access_type($perm['permission_code'],$perm['permission_name']); + } + } + return $this->access_type_list; + } + + /** + * Function used to add new custom permission + */ + function add_access_type($access,$name) + { + if(!empty($access) && !empty($name)) + $this->access_type_list[$access] = $name; + } + + /** + * Function get access + */ + function get_access($access) + { + return $this->access_type_list[$access]; + } + + /** + * Function used to update user level + * @param INT level_id + * @param ARRAY perm_level + */ + function update_user_level($id,$array) + { + global $db; + if(!is_array($array)) + $array = $_POST; + + //First Checking Level + $level = $this->get_level_details($id); + if($level) + { + foreach($this->get_access_type_list() as $access => $name) + { + $fields_array[] = $access; + $value_array[] = $array[$access]; + } + + //Checking level Name + if(!empty($array['level_name'])) + { + $level_name = mysql_clean($array['level_name']); + //Upadting Now + $db->update(tbl("user_levels"),array("user_level_name"),array($level_name)," user_level_id = '$id'"); + } + + if(isset($_POST['plugin_perm'])) + { + $fields_array[] = 'plugins_perms'; + $value_array[] = '|no_mc|'.json_encode($_POST['plugin_perm']); + } + + //Updating Permissions + $db->update(tbl("user_levels_permissions"),$fields_array,$value_array," user_level_id = '$id'"); + + e(lang("level_updated"),'m'); + return true; + }else{ + return false; + } + } + + + /** + * Function used to delete user levels + * @param INT level_id + */ + function delete_user_level($id) + { + global $db; + $level_details = $this->get_level_details($id); + $de_level = $this->get_level_details(3); + if($level_details) + { + //CHeck if leve is deleteable or not + if($level_details['user_level_is_default']=='no') + { + $db->delete(tbl("user_levels"),array("user_level_id"),array($id)); + $db->delete(tbl("user_levels_permissions"),array("user_level_id"),array($id)); + e(sprintf(lang("level_del_sucess"),$de_level['user_level_name'])); + + $db->update(tbl("users"),array("level"),array(3)," level='$id'"); + return true; + + }else{ + e(lang("level_not_deleteable")); + return false; + } + } + } + + + /** + * Function used to count total video comments + */ + function count_profile_comments($id) + { + global $db; + $total_comments = $db->count(tbl('comments'),"comment_id","type='c' AND type_id='$id'"); + return $total_comments; + } + function count_channel_comments($id){ return $this->count_profile_comments($id); } + + /** + * Function used to count total comments made by users + */ + function count_comments_by_user($uid) + { + global $db; + $total_comments = $db->count(tbl('comments'),"comment_id","userid='$uid'"); + return $total_comments; + } + + /** + * Function used to update user comments + */ + function update_comments_by_user($uid) + { + global $db; + $total_comments = $this->count_comments_by_user($id); + $db->update(tbl("users"),array("total_comments","last_commented"),array($total_comments,now())," userid='$id'"); + } + + /** + * Function used to update user comments count + */ + function update_comments_count($id) + { + global $db; + $total_comments = $this->count_profile_comments($id); + $db->update(tbl("users"),array("comments_count","last_commented"),array($total_comments,now())," userid='$id'"); + + } + /** + * Function used to add comment on users profile + */ + function add_comment($comment,$obj_id,$reply_to=NULL,$type='c') + { + global $myquery; + if(!$this->user_exists($obj_id)) + e(lang("usr_exist_err")); + else + { + $add_comment = $myquery->add_comment($comment,$obj_id,$reply_to,$type,$obj_id); + } + if($add_comment) + { + //Loggin Comment + $log_array = array + ( + 'success'=>'yes', + 'details'=> "comment on a profile", + 'action_obj_id' => $obj_id, + 'action_done_id' => $add_comment, + ); + insert_log('profile_comment',$log_array); + + //Updating Number of comments of video + $this->update_comments_count($obj_id); + } + return $add_comment; + } + + /** + * Function used to remove video comment + */ + function delete_comment($cid,$is_reply=FALSE) + { + global $myquery,$db; + $remove_comment = $myquery->delete_comment($cid,'c',$is_reply); + if($remove_comment) + { + //Updating Number of comments of video + $this->update_comments_count($obj_id); + } + return $remove_comment; + } + + + + /** + * Function used to get number of videos uploaded by user + * @param INT userid + * @param Conditions + */ + function get_user_vids($uid,$cond=NULL,$count_only=false) + { + global $db; + if($cond!=NULL) + $cond = " AND $cond "; + + $results = $db->select(tbl("video"),"*"," userid = '$uid' $cond"); + if($db->num_rows > 0) + { + if($count_only) + return $db->num_rows; + else + return $results[0]; + }else{ + return false; + } + } + + + /** + * Function used to get logged in username + */ + function get_logged_username() + { + return $this->get_user_field_only(user_id(),'username'); + } + + /** + * FUnction used to get username from userid + */ + function get_username($uid) + { + return $this->get_user_field_only($uid,'username'); + } + + /** + * Function used to create profile link + */ + function profile_link($udetails) + { + if(!is_array($udetails) && is_numeric($udetails)) + $udetails = $this->get_user_details($udetails); + if(SEO!="yes") + return BASEURL.'/view_channel.php?user='.$udetails['username']; + else + return BASEURL.'/user/'.$udetails['username']; + } + function get_user_link($u) + { + return $this->profile_link($u); + } + + + /** + * Function used to get permission types + */ + function get_level_types() + { + global $db; + return $db->select(tbl($this->dbtbl['user_permission_type']),"*"); + } + + /** + * Function used to check weather level type exists or not + */ + function level_type_exists($id) + { + global $db; + $result = $db->select(tbl($this->dbtbl['user_permission_type']),"*"," user_permission_type_id='".$id."' OR user_permission_type_name='$id'"); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to add new permission + */ + function add_new_permission($array) + { + global $db; + if(empty($array['code'])) + e(lang("perm_code_empty")); + elseif(empty($array['name'])) + e(lang("perm_name_empty")); + elseif($this->permission_exists($array['code'])) + e(lang("perm_already_exist")); + elseif(!$this->level_type_exists($array['type'])) + e(lang("perm_type_not_valid")); + else + { + $type = $this->level_type_exists($array['type']); + $typeid = $type['user_permission_type_id']; + $code = mysql_clean($array['code']); + $name = mysql_clean($array['name']); + $desc = mysql_clean($array['desc']); + $default = mysql_clean($array['default']); + $default = $default ? $default : "yes"; + $db->insert(tbl($this->dbtbl['user_permissions']), + array('permission_type','permission_code','permission_name','permission_desc','permission_default'), + array($typeid,$code,$name,$desc,$default)); + $db->execute("ALTER TABLE ".tbl($this->dbtbl['user_level_permission'])." ADD `".$code."` ENUM( 'yes', 'no' ) NOT NULL DEFAULT '".$default."'"); + e(lang("perm_added"),"m"); + } + } + + /** + * Function used to check permission exists or not + * @Param permission code + */ + function permission_exists($code) + { + global $db; + $result = $db->select(tbl($this->dbtbl['user_permissions']),"*"," permission_code='".$code."' OR permission_id='".$code."'"); + if($db->num_rows>0) + return $result[0]; + else + return false; + } + + /** + * Function used to get permissions + */ + function get_permissions($type=NULL) + { + global $db; + if($type) + $cond = " permission_type ='$type'"; + $result = $db->select(tbl($this->dbtbl['user_permissions']),"*",$cond); + if($db->num_rows>0) + { + return $result; + }else + { + return false; + } + } + + /** + * Function used to remove Permission + */ + function remove_permission($id) + { + global $db; + $permission = $this->permission_exists($id); + if($permission) + { + $field = $permission['permission_code']; + $db->delete(tbl($this->dbtbl['user_permissions']),array("permission_id"),array($id)); + $db->execute("ALTER TABLE `".tbl($this->dbtbl['user_level_permission'])."` DROP `".$field."` "); + e(lang("perm_deleted"),"m"); + }else + e(lang("perm_doesnt_exist")); + } + + + /** + * Function used to check weather current user has permission + * to view page or not + * it will also check weather current page requires login + * if login is required, user will be redirected to signup page + */ + function perm_check($access='',$check_login=FALSE,$control_page=true) + { + global $Cbucket; + /*if($check_login) + { + return $this->login_check($access); + }else + {*/ + $access_details = $this->permission; + //pr($access_details); + if(is_numeric($access)) + { + if($access_details['level_id'] == $access) + { + return true; + }else{ + if(!$check_only) + e(lang('insufficient_privileges')); + + if($control_page) + $Cbucket->show_page(false); + return false; + } + }else + { + + if($access_details[$access] == 'yes') + { + return true; + } + else + { + + if(!$check_login) + e(lang('insufficient_privileges')); + else + { if(userid()) + e(lang('insufficient_privileges')); + else + e(sprintf(lang('insufficient_privileges_loggin'),cblink(array('name'=>'signup')),cblink(array('name'=>'signup')))); + } + + if($control_page) + $Cbucket->show_page(false); + return false; + } + } + //} + } + + + /** + * Function used to get user profile details + */ + function get_user_profile($uid) + { + global $db; + $result = $db->select(tbl($this->dbtbl['user_profile']),"*"," userid='$uid'"); + if($db->num_rows>0) + { + return $result[0]; + }else + return false; + } + + + + + + /** + * User Profile Fields + */ + function load_profile_fields($default) + { + if(!$default) + $default = $_POST; + + $profile_fields = $this->load_personal_details($default); + $other_details = $this->load_location_fields($default); + $more_details = $this->load_education_interests($default); + $channel = $this->load_channel_settings($default); + $privacy_field = $this->load_privacy_field($default); + return array_merge($profile_fields,$other_details,$more_details,$channel,$privacy_field); + } + + + + + + /** + * Function used to update use details + */ + function update_user($array) + { + global $LANG,$db,$signup,$Upload; + if($array==NULL) + $array = $_POST; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + $userfields = $this->load_profile_fields($array); + //$signup_fields = $this->load_signup_fields($array); + $custom_signup_fields = $this->load_custom_signup_fields($array); + + //Adding Custom Form Fields + if(count($this->custom_profile_fields)>0) + $userfields = array_merge($userfields,$this->custom_profile_fields); + + //Adding custom fields from group + if(count($this->custom_profile_fields_groups)>0) + { + $custom_fields_from_group_fields = array(); + $custom_fields_from_group = $this->custom_profile_fields_groups; + foreach($custom_fields_from_group as $cffg) + { + $custom_fields_from_group_fields = array_merge($custom_fields_from_group_fields,$cffg['fields']); + } + + $userfields = array_merge($userfields,$custom_fields_from_group_fields); + } + + + validate_cb_form($custom_signup_fields,$array); + + validate_cb_form($userfields,$array); + // pr(); + foreach($userfields 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'],sql_free('|no_mc|'.$val)); + + + if(!empty($field['db_field'])) + $query_val[] = $val; + } + + //Category + if($cat_field) + { + $field = $cat_field; + $name = formObj::rmBrackets($field['name']); + $val = $array[$name]; + + if($field['use_func_val']) + $val = $field['validate_function']($val); + + + if(!empty($field['db_field'])) + $uquery_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'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $uquery_val[] = $val; + } + + + + //updating user detail + if(has_access('admin_access',TRUE) && isset($array['admin_manager'])) + { + //Checking Username + if(empty($array['username'])) + e(lang('usr_uname_err')); + elseif($array['dusername'] != $array['username'] && $this->username_exists($array['username'])) + e(lang('usr_uname_err2')); + elseif(!username_check($array['username'])) + e(lang('usr_uname_err3')); + else + $username = $array['username']; + + //Checking Email + if(empty($array['email'])) + e(lang('usr_email_err1')); + elseif(!is_valid_syntax('email',$array['email'])) + e(lang('usr_email_err2')); + elseif(email_exists($array['email']) && $array['email'] != $array['demail']) + e(lang('usr_email_err3')); + else + $email = $array['email']; + + $uquery_field[] = 'username'; + $uquery_val[] = $username; + + $uquery_field[] = 'email'; + $uquery_val[] = $email; + + //Changning Password + if(!empty($array['pass'])) + { + if($array['pass']!=$array['cpass']) + e(lang("pass_mismatched")); + else + $pass = pass_code($array['pass']); + $uquery_field[] = 'password'; + $uquery_val[] = $pass; + } + + //Changing User Level + $uquery_field[] = 'level'; + $uquery_val[] = $array['level']; + + //Checking for user stats + $uquery_field[] = 'profile_hits'; + $uquery_val[] = $array['profile_hits']; + $uquery_field[] = 'total_watched'; + $uquery_val[] = $array['total_watched']; + $uquery_field[] = 'total_videos'; + $uquery_val[] = $array['total_videos']; + $uquery_field[] = 'total_comments'; + $uquery_val[] = $array['total_comments']; + $uquery_field[] = 'subscribers'; + $uquery_val[] = $array['subscribers']; + $uquery_field[] = 'comments_count'; + $uquery_val[] = $array['comments_count']; + $query_field[] = 'rating'; + + $rating = $array['rating']; + if($rating<1 || $rating>10) + $rating = 1; + $query_val[] = $rating ; + $query_field[] = 'rated_by'; + $query_val[] = $array['rated_by']; + + //Changing JOined Date + if(isset($array['doj'])) + { + $uquery_field[] = 'doj'; + $uquery_val[] = $array['doj']; + } + + } + + //Changing Gender + if($array['sex']) + { + $uquery_field[] = 'sex'; + $uquery_val[] = mysql_clean($array['sex']); + } + + //Changing Country + if($array['country']) + { + $uquery_field[] = 'country'; + $uquery_val[] = mysql_clean($array['country']); + } + + //Changing Date of birth + if(isset($array['dob'])) + { + $uquery_field[] = 'dob'; + $uquery_val[] = $array['dob']; + } + + //Changing category + if(isset($array['category'])) + { + $uquery_field[] = 'category'; + $uquery_val[] = $array['category']; + } + + + //Updating User Avatar + if($array['avatar_url']) + { + $uquery_field[] = 'avatar_url'; + $uquery_val[] = $array['avatar_url']; + } + if($array['remove_avatar_url']=='yes') + { + $uquery_field[] = 'avatar_url'; + $uquery_val[] = ''; + } + + //Deleting User Avatar + if($array['delete_avatar']=='yes') + { + $file = USER_THUMBS_DIR.'/'.$array['avatar_file_name']; + if(file_exists($file) && $array['avatar_file_name'] !='') + unlink($file); + } + + //Deleting User Bg + if($array['delete_bg']=='yes') + { + + $file = USER_BG_DIR.'/'.$array['bg_file_name']; + if(file_exists($file) && $array['bg_file_name']) + unlink($file); + } + + + if(isset($_FILES['avatar_file']['name'])) + { + $file = $Upload->upload_user_file('a',$_FILES['avatar_file'],$array['userid']); + if($file) + { + $uquery_field[] = 'avatar'; + $uquery_val[] = $file; + } + } + + + //Updating User Background + if($array['background_url']) + { + $uquery_field[] = 'background_url'; + $uquery_val[] = $array['background_url']; + } + + if($array['background_color']) + { + $uquery_field[] = 'background_color'; + $uquery_val[] = $array['background_color']; + } + + if($array['background_repeat']) + { + $uquery_field[] = 'background_repeat'; + $uquery_val[] = $array['background_repeat']; + } + + + if(isset($_FILES['background_file']['name'])) + { + $file = $Upload->upload_user_file('b',$_FILES['background_file'],$array['userid']); + if($file) + { + $uquery_field[] = 'background'; + $uquery_val[] = $file; + } + } + + + //Adding Custom Field + if(is_array($custom_signup_fields)) + { + foreach($custom_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'])) + $uquery_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'],sql_free('|no_mc|'.$val)); + + + if(!empty($field['db_field'])) + $uquery_val[] = $val; + } + } + + if(!error() && is_array($uquery_field)) + { + $db->update(tbl($this->dbtbl['users']),$uquery_field,$uquery_val," userid='".mysql_clean($array['userid'])."'"); + e(lang("usr_upd_succ_msg"),'m'); + } + + + + //updating user profile + if(!error()) + { + $log_array = array + ( + 'success'=>'yes', + 'details'=> "updated profile" + ); + //Login Upload + insert_log('profile_update',$log_array); + + $db->update(tbl($this->dbtbl['user_profile']),$query_field,$query_val," userid='".mysql_clean($array['userid'])."'"); + e(lang("usr_pof_upd_msg"),'m'); + } + } + + + /** + * Function used to update user avatar and background only + */ + function update_user_avatar_bg($array) + { + global $db,$signup,$Upload; + //Updating User Avatar + $uquery_field[] = 'avatar_url'; + $uquery_val[] = mysql_clean($array['avatar_url']); + + + //Deleting User Avatar + if($array['delete_avatar']=='yes') + { + $file = USER_THUMBS_DIR.'/'.$array['avatar_file_name']; + if(file_exists($file) && $array['avatar_file_name'] !='') + unlink($file); + } + + //Deleting User Bg + if($array['delete_bg']=='yes') + { + $file = USER_BG_DIR.'/'.$array['bg_file_name']; + if(file_exists($file) && $array['bg_file_name'] !='') + unlink($file); + } + + + if(isset($_FILES['avatar_file']['name'])) + { + $file = $Upload->upload_user_file('a',$_FILES['avatar_file'],$array['userid']); + if($file) + { + $uquery_field[] = 'avatar'; + $uquery_val[] = $file; + } + } + + + //Updating User Background + $uquery_field[] = 'background_url'; + $uquery_val[] = mysql_clean($array['background_url']); + + $uquery_field[] = 'background_color'; + $uquery_val[] = mysql_clean($array['background_color']); + + if($array['background_repeat']) + { + $uquery_field[] = 'background_repeat'; + $uquery_val[] = mysql_clean($array['background_repeat']); + } + + //Background ATtachement + $uquery_field[] = 'background_attachement'; + $uquery_val[] = mysql_clean($array['background_attachement']); + + + if(isset($_FILES['background_file']['name'])) + { + + $file = $Upload->upload_user_file('b',$_FILES['background_file'],$array['userid']); + if($file) + { + $uquery_field[] = 'background'; + $uquery_val[] = mysql_clean($file); + } + } + + $log_array = array + ( + 'success'=>'yes', + 'details'=> "updated profile" + ); + + //Login Upload + insert_log('profile_update',$log_array); + + $db->update(tbl($this->dbtbl['users']),$uquery_field,$uquery_val," userid='".mysql_clean($array['userid'])."'"); + e(lang("usr_avatar_bg_update"),'m'); + + } + + + /** + * Function used to check weather username exists or not + */ + function username_exists($i) + { + global $db; + //echo test; + return $db->count(tbl($this->dbtbl['users']),"username"," username='$i'"); + } + + /** + * function used to check weather email exists or not + */ + function email_exists($i) + { + global $db; + $db->select(tbl($this->dbtbl['users']),"email"," email='$i'"); + if($db->num_rows>0) + return true; + else + return false; + } + + + /** + * Function used to get user access log + */ + function get_user_action_log($uid,$limit=NULL) + { + global $db; + $result = $db->select(tbl($this->dbtbl['action_log']),"*"," action_userid='$uid'",$limit," date_added DESC"); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Load Custom Profile Field + */ + function load_custom_profile_fields($data,$group_based=false) + { + if(!$group_based) + { + $array = $this->custom_profile_fields; + foreach($array as $key => $fields) + { + if($data[$fields['db_field']]) + $value = $data[$fields['db_field']]; + elseif($data[$fields['name']]) + $value = $data[$fields['name']]; + + + if($fields['type']=='radiobutton' || + $fields['type']=='checkbox' || + $fields['type']=='dropdown') + $fields['checked'] = $value; + else + $fields['value'] = $value; + $new_array[$key] = $fields; + } + return $new_array; + }else + { + $groups = $this->custom_profile_fields_groups; + + $new_grp = array(); + if($groups) + foreach($groups as $grp) + { + $fields = array(); + foreach($grp['fields'] as $key => $fields) + { + if($data[$fields['db_field']]) + $value = $data[$fields['db_field']]; + elseif($data[$fields['name']]) + $value = $data[$fields['name']]; + + + if($fields['type']=='radiobutton' || + $fields['type']=='checkbox' || + $fields['type']=='dropdown') + $fields['checked'] = $value; + else + $fields['value'] = $value; + } + $grp['fields'][$key] = $fields; + $new_grp[] = $grp; + } + } + + return $new_grp; + } + + /** + * Load Custom Signup Field + */ + function load_custom_signup_fields($data,$ck_display_admin=FALSE,$ck_display_user=FALSE) + { + $array = $this->custom_signup_fields; + foreach($array as $key => $fields) + { + $ok = 'yes'; + if($ck_display_admin) + { + if($fields['display_admin'] == 'no_display') + $ok = 'no'; + } + + if($ck_display_user) + { + if($fields['display_user'] == 'no_display') + $ok = 'no'; + } + + if($ok=='yes') + { + if(!$fields['value']) + $fields['value'] = $data[$fields['db_field']]; + $new_array[$key] = $fields; + } + } + + return $new_array; + } + + + /** + * Function used to get channel links + * ie Playlist, favorites etc etc + */ + function get_inner_channel_top_links($u) + { + $channel_links = array(); + + if(isSectionEnabled('videos')) + { + $channel_links[lang('upload')] = array('link'=>$this->get_user_videos_link($u)); + $channel_links[lang('favorites')] = array('link'=>cblink(array('name'=>'user_favorites')).$u['username']); + } + if(isSectionEnabled('channels')) + $channel_links[lang('contacts')] = array('link'=>cblink(array('name'=>'user_contacts')).$u['username']); + + return $channel_links; + } + + /** + * Function used to get user channel action links + * ie Add to friends, send message etc etc + */ + function get_channel_action_links($u) + { + return array(lang('send_message')=>array('link'=>cblink(array('name'=>'compose_new','extra_params'=>'to='.$u['username']))), + lang('add_as_friend')=>array('link'=>'javascript:void(0)','onclick'=>"add_friend('".$u['userid']."','result_cont')"), + lang('block_user')=>array('link'=>'javascript:void(0)','onclick'=>"block_user('".$u['username']."','result_cont')") + ); } + + /** + * Function used to get user videos link + */ + function get_user_videos_link($u) + { + return cblink(array('name'=>'user_videos')).$u['username']; + } + + + /** + * Function used to get user channel video + */ + function get_user_profile_video($u) + { + global $db,$cbvid; + if(empty($u['profile_video'])&&!$cbvid->video_exists($u)) + { + $u = $this->get_user_profile($u); + } + + if($cbvid->video_exists($u['profile_video'])) + return $cbvid->get_video_details($u['profile_video']); + else + return false; + } + + + /** + * My Account links + */ + function my_account_links() + { + + + $array[lang('account')] = + array + ( + lang('my_account') => 'myaccount.php', + lang('block_users') => 'edit_account.php?mode=block_users', + lang('user_change_pass') =>'edit_account.php?mode=change_password', + lang('user_change_email') =>'edit_account.php?mode=change_email', + lang('com_manage_subs') => 'edit_account.php?mode=subscriptions' + ); + + + $array[lang('user_channel_profiles')] = array + ( + lang('account_settings') =>'edit_account.php?mode=account', + lang('user_profile_settings') =>'edit_account.php?mode=profile', + lang('change_avatar') => 'edit_account.php?mode=avatar_bg', + lang('change_bg') => 'edit_account.php?mode=avatar_bg', + ); + + if(isSectionEnabled('videos')) + $array[lang('videos')] = array + ( + lang('uploaded_videos')=>'manage_videos.php', + lang('user_fav_videos')=>'manage_videos.php?mode=favorites', + ); + + if(isSectionEnabled('groups')) + $array[lang('groups')] = array + ( + lang('grp_groups_title') =>'manage_groups.php', + lang('user_create_group') =>cblink(array('name'=>'create_group')), + lang('grp_joined_groups')=>'manage_groups.php?mode=joined', + ); + + if(isSectionEnabled('playlists')) + $array[lang('playlists')]=array + ( + lang('manage_playlists') =>'manage_playlists.php', + lang('video_playlists') =>'manage_playlists.php?mode=manage_video_playlist', + ); + $array[lang('messages')] = array + ( + lang('inbox') => 'private_message.php?mode=inbox', + lang('notifications') => 'private_message.php?mode=notification', + lang('sent') => 'private_message.php?mode=sent', + lang('title_crt_new_msg')=> cblink(array('name'=>'compose_new')), + ); + + if(isSectionEnabled('channels')) + $array[lang('contacts')] = array + ( + lang('com_manage_contacts') => 'manage_contacts.php?mode=manage', + lang('add_contact_list') => 'manage_contacts.php?mode=new_group', + ); + + + + if(count($this->user_account)>0) + { + foreach($this->user_account as $key => $acc) + { + if(array_key_exists($key,$array)) + { + foreach($acc as $title => $link) + $array[$key][$title] = $link; + }else + $array[$key] = $acc; + } + //$array = array_merge($array,$this->user_account); + } + + return $array; + } + + + /** + * Function used to change email + */ + function change_email($array) + { + global $db; + //function used to change user email + if(!isValidEmail($array['new_email']) || $array['new_email']=='') + e(lang("usr_email_err2")); + elseif($array['new_email']!=$array['cnew_email']) + e(lang('user_email_confirm_email_err')); + elseif(!$this->user_exists($array['userid'])) + e(lang('usr_exist_err')); + elseif($this->email_exists($array['new_email'])) + e(lang('usr_email_err3')); + else + { + $db->update(tbl($this->dbtbl['users']),array('email'),array($array['new_email'])," userid='".$array['userid']."'"); + e(lang("email_change_msg"),"m"); + } + } + + /** + * Function used to ban users + */ + function block_users($users,$uid=NULL){ return $this->ban_users($users,$uid); } + function ban_users($users,$uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + $users_array = explode(',',$users); + $new_users = array(); + foreach($users_array as $user) + { + if($user!=username() && !is_numeric($user) && $this->user_exists($user)) + { + $new_users[] = $user; + } + } + if(count($new_users)>0) + { + $new_users = array_unique($new_users); + $banned_users = implode(',',$new_users); + $db->update(tbl($this->dbtbl['users']),array('banned_users'),array($banned_users)," userid='$uid'"); + e(lang("user_ban_msg"),"m"); + }elseif (!$users){ + $db->update(tbl($this->dbtbl['users']),array('banned_users'),array($users)," userid='$uid'"); + e(lang("no_user_ban_msg"),"m"); + } + } + + /** + * Function used to ban single user + */ + function ban_user($user) + { + global $db; + $uid = userid(); + + if(!$uid) + e(lang('you_not_logged_in')); + elseif($user!=username() && !is_numeric($user) && $this->user_exists($user)) + { + $banned_users = $this->udetails['banned_users']; + if($banned_users) + $banned_users .= ",$user"; + else + $banned_users = "$user"; + + if(!$this->is_user_banned($user)) + { + $db->update(tbl($this->dbtbl['users']),array('banned_users'),array($banned_users)," userid='$uid'"); + e(lang("user_blocked"),"m"); + }else + e(lang("user_already_blocked")); + }else + { + e(lang("you_cant_del_user")); + } + } + + + + /** + * Function used to check weather user is banned or not + */ + function is_user_banned($ban,$user=NULL,$banned_users=NULL) + { + global $db; + if(!$user) + $user = userid(); + + if(!$banned_users) + { + if(is_numeric($user)) + $result = $db->select(tbl($this->dbtbl['users']),"banned_users"," userid='$user' "); + else + $result = $db->select(tbl($this->dbtbl['users']),"banned_users"," username='$user' "); + $banned_users = $result[0]['banned_users']; + } + + $ban_user = explode(',',$banned_users); + if(in_array($ban,$ban_user)) { + return true; + } else { + return false; + } + + return false; + } + + /** + * function used to get user details with profile + */ + function get_user_details_with_profile($uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + $result = $db->select(tbl($this->dbtbl['users'].",".$this->dbtbl['user_profile']),"*",tbl($this->dbtbl['users']).".userid ='$uid' AND ".tbl($this->dbtbl['users']).".userid = ".tbl($this->dbtbl['user_profile']).".userid"); + return $result[0]; + } + + + function load_signup_fields($default=NULL) + { + global $LANG,$Cbucket; + /** + * this function will create initial array for user fields + * this will tell + * array( + * title [text that will represents the field] + * type [type of field, either radio button, textfield or text area] + * name [name of the fields, input NAME attribute] + * id [id of the fields, input ID attribute] + * value [value of the fields, input VALUE attribute] + * size + * class + * label + * extra_params + * hint_1 [hint before field] + * hint_2 [hint after field] + * anchor_before [anchor before field] + * anchor_after [anchor after field] + * ) + */ + + + if(empty($default)) + $default = $_POST; + + $username = $default['username']; + $email = $default['email']; + $dcountry = $default['country'] ? $default['country'] : $Cbucket->configs['default_country_iso2']; + $dob = $default['dob']; + + $dob = $dob ? date(config("date_format"),strtotime($dob)) : date(config("date_format"),strtotime('14-10-1989')); + + $user_signup_fields = array + ( + 'username' => array( + 'title'=> lang('username'), + 'type'=> "textfield", + 'name'=> "username", + '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'), + 'min_length' => config('min_username'), + 'max_length' => config('max_username'), + ), + 'email' => array( + 'title'=> lang('email'), + 'type'=> "textfield", + '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'), + 'type' => 'dropdown', + 'value' => $Cbucket->get_countries(iso2), + 'id' => 'country', + 'name' => 'country', + 'checked'=> $dcountry, + 'db_field'=>'country', + 'required'=>'yes', + ), + 'gender' => array( + 'title' => lang('gender'), + 'type' => 'radiobutton', + 'name' => 'gender', + 'id' => 'gender', + 'value' => array('Male'=>lang('male'),'Female'=>lang('female')), + 'sep'=> ' ', + 'checked'=>'Male', + 'db_field'=>'sex', + 'required'=>'yes', + ), + 'dob' => array( + 'title' => lang('user_date_of_birth'), + 'type' => 'textfield', + 'name' => 'dob', + 'id' => 'dob', + 'class'=>'date_field', + 'anchor_after' => 'date_picker', + 'value'=> $dob, + 'validate_function' => 'verify_age', + 'db_field'=>'dob', + 'required'=>'yes', + 'invalid_err'=>lang('You must be atleast '.config('min_age_reg').' to register'), + ), + + 'cat' => array('title'=> lang('Category'), + 'type'=> 'dropdown', + 'name'=> 'category', + 'id'=> 'category', + 'value'=> array('category',$default['category']), + 'db_field'=>'category', + 'checked'=>$default['category'], + 'required'=>'yes', + 'invalid_err'=>lang("Please select your category"), + 'display_function' => 'convert_to_categories', + 'category_type'=>'user', + ) + ); + + return $user_signup_fields; + } + + + /** + * Function used to validate Signup Form + */ + function validate_form_fields($array=NULL) + { + global $userquery; + $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); + + validate_cb_form($signup_fields,$array); + + } + + + /** + * Function used to validate signup form + */ + function signup_user($array=NULL,$send_signup_email=true) + { + global $LANG,$db,$userquery; + 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($array['agree']!='yes' && !has_access('admin_access',true)) + e(lang('usr_ament_err')); + + if(!verify_captcha()) + e(lang('usr_ccode_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'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + + // Setting Verification type + if(EMAIL_VERIFICATION == '1'){ + $usr_status = 'ToActivate'; + $welcome_email = 'no'; + }else{ + $usr_status = 'Ok'; + $welcome_email = 'yes'; + } + + if(has_access('admin_access',true)) + { + if($array['active']=='Ok') + { + $usr_status = 'Ok'; + $welcome_email = 'yes'; + }else{ + $usr_status = 'ToActivate'; + $welcome_email = 'no'; + } + + $query_field[] = "level"; + $query_val[] = $array['level']; + } + + $query_field[] = "usr_status"; + $query_val[] = $usr_status; + + $query_field[] = " welcome_email_sent"; + $query_val[] = $welcome_email; + + //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; + + + /** + * A VERY IMPORTANT PART OF + * OUR SIGNUP SYSTEM IS + * SESSION KEY AND CODE + * WHEN A USER IS LOGGED IN + * IT IS ONLY VALIDATED BY + * ITS SIGNUP KEY AND CODE + * + */ + $sess_key = $this->create_session_key($_COOKIE['PHPSESSID'],$array['password']); + $sess_code = $this->create_session_code(); + + $query_field[] = "user_session_key"; + $query_val[] = $sess_key; + + $query_field[] = "user_session_code"; + $query_val[] = $sess_code; + + $query = "INSERT INTO ".tbl("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(); + $db->insert(tbl($userquery->dbtbl['user_profile']),array("userid"),array($insert_id)); + + if(!has_access('admin_access',true) && EMAIL_VERIFICATION && $send_signup_email) + { + global $cbemail; + $tpl = $cbemail->get_template('email_verify_template'); + $more_var = array + ('{username}' => post('username'), + '{password}' => post('password'), + '{email}' => post('email'), + '{avcode}' => $avcode, + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>post('email'),'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + } + elseif(!has_access('admin_access',true) && $send_signup_email) + { + $this->send_welcome_email($insert_id); + } + + $log_array = array + ('username' => $array['username'], + 'userid' => $insert_id, + 'userlevel'=> $array['level'], + 'useremail'=> $array['email'], + 'success'=>'yes', + 'details'=> sprintf("%s signed up",$array['username'])); + + //Login Signup + insert_log('signup',$log_array); + + + //Adding User has Signup Feed + addFeed(array('action' => 'signup','object_id' => $insert_id,'object'=>'signup','uid'=>$insert_id)); + + return $insert_id; + } + + return false; + } + + + + + //Duplicate User Check + function duplicate_user($name){ + global $myquery; + if($myquery->check_user($name)){ + return true; + }else{ + return false; + } + } + + function duplicate_email($name){ + $myquery = new myquery(); + if($myquery->check_email($name)){ + return true; + }else{ + return false; + } + } + + //Validate Email + + function isValidEmail($email){ + return isValidEmail($email); + } + + //Validate Username + function isValidUsername($uname){ + return $this->is_username($uname); + } + + /** + * Function used to make username valid + * this function will also check if username is banned or not + * it will also filter the username and also filter its patterns + * as given in administratio panel + */ + function is_username($username) + { + global $Cbucket; + //Our basic pattern for username is + //$pattern = "^^[_a-z0-9-]+$"; + $pattern = "^^[_a-z0-9-]+$"; + //Now we will check if admin wants to change the pattern + if (eregi($pattern, $username)){ + return true; + }else { + return false; + } + + } + + + /** + * Function used to get users + */ + function get_users($params=NULL,$force_admin=FALSE) + { + global $db; + + $limit = $params['limit']; + $order = $params['order']; + + $cond = ""; + if(!has_access('admin_access',TRUE) && !$force_admin) + $cond .= " usr_status='Ok' AND ban_status ='no' "; + else + { + if($params['ban']) + $cond .= " ban_status ='".$params['ban']."'"; + + if($params['status']) + { + if($cond!='') + $cond .=" AND "; + $cond .= " usr_status='".$params['status']."'"; + } + + } + + //Setting Category Condition + if(!is_array($params['category'])) + $is_all = strtolower($params['category']); + + if($params['category'] && $is_all!='all') + { + if($cond!='') + $cond .= ' AND '; + + $cond .= " ("; + + if(!is_array($params['category'])) + { + $cats = explode(',',$params['category']); + }else + $cats = $params['category']; + + $count = 0; + + foreach($cats as $cat_params) + { + $count ++; + if($count>1) + $cond .=" OR "; + $cond .= " category LIKE '%$cat_params%' "; + } + + $cond .= ")"; + } + + //date span + if($params['date_span']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".cbsearch::date_margin("doj",$params['date_span']); + } + + /*//uid + if($params['user']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " userid='".$params['user']."'"; + } + + $tag_n_title=''; + //Tags + if($params['tags']) + { + //checking for commas ;) + $tags = explode(",",$params['tags']); + if(count($tags)>0) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $total = count($tags); + $loop = 1; + foreach($tags as $tag) + { + $tag_n_title .= " tags LIKE '%".$tag."%'"; + if($loop<$total) + $tag_n_title .= " OR "; + $loop++; + + } + }else + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " tags LIKE '%".$params['tags']."%'"; + } + } + //TITLE + if($params['title']) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " title LIKE '%".$params['tags']."%'"; + } + + if($tag_n_title) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ($tag_n_title) "; + }*/ + + //FEATURED + if($params['featured']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " featured = '".$params['featured']."' "; + } + + //Email + if($params['username']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " username = '".$params['username']."' "; + } + + //Email + if($params['email']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " email = '".$params['email']."' "; + } + + //Exclude Users + if($params['exclude']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " userid <> '".$params['exclude']."' "; + } + + //Getting specific User + if($params['userid']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " userid = '".$params['userid']."' "; + } + + //Sex + if($params['gender']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " sex = '".$params['gender']."' "; + } + + //Level + if($params['level']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " level = '".$params['level']."' "; + } + + if($params['cond']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".$params['cond']." "; + } + + + if(!$params['count_only']) + { + + $query = " SELECT ".tbl("users").".*,profile.rating FROM ".tbl('users')." LEFT JOIN ".tbl('user_profile'). " AS profile "; + $query .= " ON ".tbl('users.userid')." = profile.userid "; + + $query .= " WHERE ".$cond; + + if($order) + $query .= " ORDER BY ".$order; + + if($limit) + $query .= " LIMIT ".$limit; + + //$result = $db->select(tbl('users'),'*',$cond,$limit,$order); + + $result = db_select($query); + } + + + if($params['count_only']) + return $result = $db->count(tbl('users'),'userid',$cond); + if($params['assign']) + assign($params['assign'],$result); + else + return $result; + } + + + + + /** + * Function used to perform several actions with a video + */ + function action($case,$uid) + { + global $db; + if(!$this->user_exists($uid)) + return false; + //Lets just check weathter user exists or not + $tbl = tbl($this->dbtbl['users']); + switch($case) + { + //Activating a user + case 'activate': + case 'av': + case 'a': + { + $avcode = RandomString(10); + $db->update($tbl,array('usr_status','avcode'),array('Ok',$avcode)," userid='$uid' "); + e(lang("User has been activated"),'m'); + } + break; + + //Deactivating a user + case "deactivate": + case "dav": + case "d": + { + $avcode = RandomString(10); + $db->update($tbl,array('usr_status','avcode'),array('ToActivate',$avcode)," userid='$uid' "); + e(lang("User has been deactivated"),'m'); + } + break; + + //Featuring user + case "feature": + case "featured": + case "f": + { + $db->update($tbl,array('featured','featured_date'),array('yes',now())," userid='$uid' "); + e(lang("User has been set as featured"),'m'); + } + break; + + + //Unfeatured user + case "unfeature": + case "unfeatured": + case "uf": + { + $db->update($tbl,array('featured'),array('no')," userid='$uid' "); + e(lang("User has been removed from featured users"),'m'); + } + break; + + //Ban User + case "ban": + case "banned": + { + $db->update($tbl,array('ban_status'),array('yes')," userid='$uid' "); + e(lang("User has been banned"),'m'); + } + break; + + + //Ban User + case "unban": + case "unbanned": + { + $db->update($tbl,array('ban_status'),array('no')," userid='$uid' "); + e(lang("User has been unbanned"),'m'); + } + break; + } + } + + + /** + * Is registration allowed + */ + function is_registration_allowed() + { + if(ALLOW_REG == 1) + { + return true; + } + return false; + } + + /** + * Function used to use to initialize search object for video section + * op=>operator (AND OR) + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "users"; + $this->search->columns =array( + array('field'=>'username','type'=>'LIKE','var'=>'%{KEY}%'), + ); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/user.html'; + $this->search->template_var = 'user'; + $this->search->multi_cat = false; + $this->search->date_added_colum = 'doj'; + $this->search->results_per_page = config('users_items_search_page'); + + /** + * Setting up the sorting thing + */ + + $sorting = array( + 'doj' => lang("date_added"), + 'profile_hits' => lang("views"), + 'total_comments' => lang("comments"), + 'total_videos' => lang("videos"), + ); + + $this->search->sorting = array( + 'doj'=> " doj DESC", + 'profile_hits' => " profile_hits DESC", + 'total_comments' => " total_comments DESC ", + 'total_videos' => " total_videos DESC", + ); + /** + * Setting Up The Search Fields + */ + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['users'] = array('title'=>lang('users')); + + $fields = array( + 'query' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'query', + 'id'=> 'query', + 'value'=>cleanForm($default['query']) + ), + 'category' => array( + 'title' => lang('category'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'category_type'=>'user', + ), + 'date_margin' => array( + 'title' => lang('joined'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['users']['fields'] = $fields; + } + + + + /** + * Function used to get number of users online + */ + function get_online_users($group=true,$count=false) + { + global $db; + + if($group) + { + $results = $db->select(tbl("sessions")." LEFT JOIN (".tbl("users").") ON + (".tbl("sessions.session_user=").tbl("users").".userid)" , + tbl("sessions.*,users.username,users.userid,users.email").",count(".tbl("sessions.session_user").") AS logins" + ," TIMESTAMPDIFF(MINUTE,".tbl("sessions.last_active").",'".NOW()."') < 6 GROUP BY ".tbl("users.userid")); + }else + { + if($count) + { + $results = $db->count(tbl("sessions")." LEFT JOIN (".tbl("users").") ON + (".tbl("sessions.session_user=").tbl("users").".userid)" , + tbl("sessions.session_id") + ," TIMESTAMPDIFF(MINUTE,".tbl("sessions.last_active").",'".NOW()."') < 6 "); + }else + { + $results = $db->select(tbl("sessions")." LEFT JOIN (".tbl("users").") ON + (".tbl("sessions.session_user=").tbl("users").".userid)" , + tbl("sessions.*,users.username,users.userid,users.email") + ," TIMESTAMPDIFF(MINUTE,".tbl("sessions.last_active").",'".NOW()."') < 6 "); + } + } + + return $results; + } + + + + + /** + * Function will let admin to login as user + */ + function login_as_user($id,$realtime=false) + { + global $sess,$db,$cblog; + $udetails = $this->get_user_details($id); + if($udetails) + { + if(!$realtime) + { + /* + $sess->set('dummy_username',$sess->get("username")); + $sess->set('dummy_level',$sess->get("level")); + $sess->set('dummy_userid',$sess->get("userid")); + $sess->set('dummy_user_session_key',$sess->get("user_session_key")); + $sess->set('dummy_user_session_code',$sess->get("user_session_code")); + + + $sess->set('username',$udetails['username']); + $sess->set('level',$udetails['level']); + $sess->set('userid',$udetails['userid']); + $sess->set('user_session_key',$udetails['session_key']); + $sess->set('user_session_code',$udetails['session_code']); + */ + + $sess->set('dummy_sess_salt',$sess->get("sess_salt")); + $sess->set('dummy_PHPSESSID',$sess->get("PHPSESSID")); + $sess->set('dummy_userid',userid()); + $sess->set('dummy_user_session_key',$this->udetails['user_session_key']); + + $userid = $udetails['userid']; + $session_salt = RandomString(5); + $sess->set('sess_salt',$session_salt); + $sess->set('PHPSESSID',$sess->id); + + $smart_sess = md5($udetails['user_session_key'].$session_salt); + + $db->delete(tbl("sessions"),array("session"),array($sess->id)); + $sess->add_session($userid,'smart_sess',$smart_sess); + + }else + { + if($this->login_check(NULL,true)) + $msg[] = e(lang('you_already_logged')); + elseif(!$this->user_exists($udetails['username'])) + $msg[] = e(lang('user_doesnt_exist')); + elseif(!$udetails) + $msg[] = e(lang('usr_login_err')); + elseif(strtolower($udetails['usr_status']) != 'ok') + $msg[] = e(lang('user_inactive_msg')); + elseif($udetails['ban_status'] == 'yes') + $msg[] = e(lang('usr_ban_err')); + else + { + + $userid = $udetails['userid']; + $log_array['userid'] = $userid = $udetails['userid']; + $log_array['useremail'] = $udetails['email']; + $log_array['success'] = 1; + + $log_array['level'] = $level = $udetails['level']; + + //Adding Sessing In Database + //$sess->add_session($userid,'logged_in'); + + //$sess->set('username',$username); + //$sess->set('userid',$userid); + + //Setting Timeout + if($remember) + $sess->timeout = 86400*REMBER_DAYS; + + //Starting special sessions for security + $session_salt = RandomString(5); + $sess->set('sess_salt',$session_salt); + $sess->set('PHPSESSID',$sess->id); + + $smart_sess = md5($udetails['user_session_key'].$session_salt); + + $db->delete(tbl("sessions"),array("session","session_string"),array($sess->id,"guest")); + $sess->add_session($userid,'smart_sess',$smart_sess); + + //$sess->set('user_sess',$smart_sess); + + //$sess->set('user_session_key',$udetails['user_session_key']); + //$sess->set('user_session_code',$udetails['user_session_code']); + + + //Setting Vars + $this->userid = $udetails['userid']; + $this->username = $udetails['username']; + $this->level = $udetails['level']; + + //Updating User last login , num of visist and ip + $db->update(tbl('users'), + array( + 'num_visits','last_logged','ip' + ), + array( + '|f|num_visits+1',NOW(),$_SERVER['REMOTE_ADDR'] + ), + "userid='".$userid."'" + ); + + + $this->init(); + //Logging Actiong + $cblog->insert('login',$log_array); + + return true; + } + + //Error Loging + if(!empty($msg)) + { + //Loggin Action + $log_array['success'] = no; + $log_array['details'] = $msg[0]; + $cblog->insert('login',$log_array); + } + } + + return true; + }else + e(lang("usr_exist_err")); + } + + /** + * Function used to revert back to admin + */ + function revert_from_user() + { + global $sess,$db; + if($this->is_admin_logged_as_user()) + { + + $userid = $sess->get('dummy_userid'); + $session_salt = $sess->get('dummy_sess_salt'); + $user_session_key = $sess->get('dummy_user_session_key'); + $smart_sess = md5($user_session_key.$session_salt); + + $sess->set('sess_salt',$session_salt); + $sess->set('PHPSESSID',$sess->get('dummy_PHPSESSID')); + + $db->delete(tbl("sessions"),array("session"),array($sess->get('dummy_PHPSESSID'))); + $sess->add_session($userid,'smart_sess',$smart_sess); + + $sess->set('dummy_sess_salt',''); + $sess->set('dummy_PHPSESSID',''); + $sess->set('dummy_userid',''); + $sess->set('dummy_user_session_key',''); + + } + } + + /** + * Function used to check weather user is logged in as admin or not + */ + function is_admin_logged_as_user() + { + global $sess; + if($sess->get("dummy_sess_salt")!="") + { + return true; + } + return false; + } + + + /** + * Function used to get anonymous user + */ + function get_anonymous_user() + { + global $db; + $uid = config('anonymous_id'); + /*Added to resolve bug 222*/ + $result = $db->select(tbl("users"),"userid"," username='anonymous%' AND email='anonymous%'","1"); + if($result[0]['userid']) + return $result[0]['userid'];/*End **/ + else + { + $result = $db->select(tbl("users"),"userid"," level='6' AND usr_status='ToActivate' ","1"); + if($result[0]['userid']) + return $result[0]['userid']; + else + { + $pass = RandomString(10); + + if($_SERVER['HTTP_HOST']!='localhost') + $email = 'anonymous'.RandomString(5).'@'.$_SERVER['HTTP_HOST']; + else + $email = 'anonymous'.RandomString(5).'@'.$_SERVER['HTTP_HOST'].'.tld'; + + //Create Anonymous user + $uid = $this->signup_user( + array( + 'username' => 'anonymous'.RandomString(5), + 'email' => $email, + 'password' => $pass, + 'cpassword' => $pass, + 'country' => get_country(config('default_country_iso2')), + 'gender' => 'Male', + 'dob' => '2000-10-10', + 'category' => '1', + 'level' => '6', + 'active' => 'yes', + 'agree' => 'yes', + ),false); + + + /*Added to resolve bug 222*/ + global $myquery; + $myquery->Set_Website_Details('anonymous_id',$uid); + /*End*/ + + return $uid; + } + } + } + + + /** + * Function used to delete user videos + */ + function delete_user_vids($uid) + { + global $cbvid,$eh; + $vids = get_videos(array('user'=>$uid)); + if(is_array($vids)) + foreach($vids as $vid) + $cbvid->delete_video($vid['videoid']); + $eh->flush_msg(); + e(lang("user_vids_hv_deleted"),"m"); + } + + /** + * Function used to remove user contacts + */ + function remove_contacts($uid) + { + global $eh; + $contacts = $this->get_contacts($uid); + if(is_array($contacts)) + foreach($contacts as $contact) + { + $this->remove_contact($contact['userid'],$contact['contact_userid']); + } + $eh->flush_msg(); + e(lang("user_contacts_hv_removed"),"m"); + } + + /** + * Function used to remove user private messages + */ + function remove_user_pms($uid,$box='both') + { + global $db,$cbpm,$eh; + + if($box=="inbox" || $box=="both") + { + $inboxs = $cbpm->get_user_inbox_messages($uid); + if(is_array($inboxs)) + foreach($inboxs as $inbox) + { + $cbpm->delete_msg($inbox['message_id'],$uid); + } + $eh->flush_msg(); + e(lang("all_user_inbox_deleted"),"m"); + } + if($box=="sent" || $box=="both") + { + $outs = $cbpm->get_user_outbox_messages($uid); + if(is_array($outs)) + foreach($outs as $out) + { + $cbpm->delete_msg($out['message_id'],$uid,'out'); + } + $eh->flush_msg(); + e(lang("all_user_sent_messages_deleted"),"m"); + + } + } + + /** + * This will get user subscriptions + * uploaded videos and photos + * This is a test function + */ +function getSubscriptionsUploadsWeek($uid,$limit=20,$uploadsType="both",$uploadsTimeSpan="this_week") +{ + $usr_cond = ""; + $users = $this->get_user_subscriptions($uid); + if($users) + { + foreach($users as $user) + { + if($user_cond) + $user_cond .= " OR "; + $user_cond .= tbl("users.userid")."='".$user[0]."' "; + } + $user_cond = " (".$user_cond.") "; + global $cbphoto,$cbvideo; + $photoCount = 1; + $videoCount = 1; + switch($uploadsType) + { + case "both": + default: + { + $photos = $cbphoto->get_photos(array("limit"=>$limit,"extra_cond"=>$user_cond,"order"=>" date_added DESC","date_span"=>$uploadsTimeSpan)); + $videos = $cbvideo->get_videos(array("limit"=>$limit,"cond"=>" AND".$user_cond,"order"=>" date_added DESC","date_span"=>$uploadsTimeSpan)); + if(!empty($photos) && !empty($videos)) + $finalResult = array_merge($videos,$photos); + elseif(empty($photos) && !empty($videos)) + $finalResult = array_merge($videos,array()); + elseif(!empty($photos) && empty($videos)) + $finalResult = array_merge($photos,array()); + + if(!empty($finalResult)) + { + foreach($finalResult as $result) + { + if($result['videoid']) + { + $videoArr[] = $result; + $return['videos'] = array( + "title" => lang("videos"), + "total" => $videoCount++, + "items" => $videoArr + ); + } + + if($result['photo_id']) + { + $photosArr[] = $result; + $return['photos'] = array( + "title" => lang("photos"), + "total" => $photoCount++, + "items" => $photosArr + ); + } + + } + //pr($return,true) ; + return $return; + } else + return false; + } + break; + + case "photos": case "photo" : case "p": + { + $photos = $cbphoto->get_photos(array("limit"=>$limit,"extra_cond"=>$user_cond,"order"=>" date_added DESC","date_span"=>$uploadsTimeSpan)); + if($photos) + { + foreach($photos as $photo) + { + $photosArr[] = $photo; + $return['photos'] = array( + "title" => lang("photos"), + "total" => $photoCount++, + "items" => $photosArr + ); + } + } + else + return false; + } + break; + + case "videos": case "video": case "v": + { + $videos = $cbvideo->get_videos(array("limit"=>$limit,"cond"=>" AND".$user_cond,"order"=>" date_added DESC","date_span"=>$uploadsTimeSpan)); + if($videos) + { + foreach($videos as $video) + { + $videoArr[] = $video; + $return['videos'] = array( + "title" => lang("videos"), + "total" => $videoCount++, + "items" => $videoArr + ); + } + } + else + return false; + } + break; + } + return $return; + } +} + + /** + * Get subscred videos + */ + function get_subscribed_videos($uid,$limit=20) + { + $user_cond = ""; + $users = $this->get_user_subscriptions($uid); + if($users) + { + foreach($users as $user) + { + //pr($user); + //Creating Query + if($user_cond) + $user_cond .= " OR "; + $user_cond .= tbl("users.userid")."='".$user[0]."' "; + } + $user_cond = " AND (".$user_cond.") "; + global $cbvid,$db; + $vids = $cbvid->get_videos(array('limit'=>$limit,'cond'=>$user_cond,"order"=>" date_added DESC ","date_span"=>"this_week")); + // echo $db->db_query; + return $vids; + } + return false; + } + + + /** + * Function used to set item as profile item + */ + function setProfileItem($id,$type='v',$uid=NULL) + { + global $cbvid,$db,$cbphoto; + if(!$uid) + $uid = userid(); + if(!$uid) + { + e("user_doesnt_exist"); + return false; + } + switch($type) + { + case "v": + { + if($cbvid->video_exists($id)) + { + $array['type'] = 'v'; + $array['id'] = $id; + $db->update(tbl('user_profile'),array('profile_item'),array("|no_mc|".json_encode($array)) + ," userid='$uid' "); + + e(sprintf(lang("this_has_set_profile_item"),lang("video")),"m"); + }else + e("class_vdo_del_err"); + } + break; + + case "p": + { + if($cbphoto->photo_exists($id)) + { + $array['type'] = 'p'; + $array['id'] = $id; + $db->update(tbl('user_profile'),array('profile_item'),array("|no_mc|".json_encode($array)) + ," userid='$uid' "); + + e(sprintf(lang("this_has_set_profile_item"),lang("photo")),"m"); + }else + e("photo_not_exists"); + } + break; + } + } + + /** + * Remove Profile item + */ + function removeProfileItem($uid=NULL) + { + global $db; + if(!$uid) + $uid = userid(); + if(!$uid) + { + e("user_doesnt_exist"); + return false; + } + + $db->update(tbl('user_profile'),array('profile_item'),array("") + ," userid='$uid' "); + + e(lang("profile_item_removed"),"m"); + } + + /** + * function used to get profile item + */ + function getProfileItem($uid=NULL,$withDetails = false) + { + global $db,$cbvid,$cbphoto; + if(!$uid) + $uid = userid(); + if(!$uid) + { + e("user_doesnt_exist"); + return false; + } + + if($uid == userid() && $this->profileItem && !$withDetails) + return $this->profileItem; + + $profileItem = $db->select(tbl("user_profile"),"profile_item"," userid='$uid'"); + $profileItem = $profileItem[0]['profile_item']; + + $profileItem = json_decode($profileItem,true); + + if($withDetails) + { + switch($profileItem['type']) + { + case "p": + { + $photo = $cbphoto->get_photo($profileItem['id']); + $photo['type'] = 'p'; + if($photo) + return $photo; + } + break; + case "v": + { + $video = $cbvid->get_video($profileItem['id']); + $video['type'] = 'v'; + if($video) + return $video; + } + break; + } + } + return $this->profileItem = $profileItem; + } + + /** + * Function used to check weather input given item + * is profile item or not + */ + function isProfileItem($id,$type='v',$uid=NULL) + { + $profileItem = $this->getProfileItem($uid); + + if($profileItem['type'] == $type && $profileItem['id'] == $id) + return true; + else + return false; + } + + + + + /** + * FUnction loading personal details + */ + function load_personal_details($default) + { + + if(!$default) + $default = $_POST; + $profile_fields = array + ( + 'first_name' => array( + 'title'=> lang("user_fname"), + 'type'=> "textfield", + 'name'=> "first_name", + 'id'=> "first_name", + 'value'=> $default['first_name'], + 'db_field'=>'first_name', + 'required'=>'no', + 'syntax_type'=> 'name', + 'auto_view'=>'yes' + ), + 'last_name' => array( + 'title'=> lang("user_lname"), + 'type'=> "textfield", + 'name'=> "last_name", + 'id'=> "last_name", + 'value'=> $default['last_name'], + 'db_field'=>'last_name', + 'syntax_type'=> 'name', + 'auto_view'=>'yes' + ), + + + 'relation_status' => array( + 'title'=> lang("user_relat_status"), + 'type'=> "dropdown", + 'name'=> "relation_status", + 'id'=> "last_name", + 'value'=> array( + lang('usr_arr_no_ans'), + lang('usr_arr_single'), + lang('usr_arr_married'), + lang('usr_arr_comitted'), + lang('usr_arr_open_relate') + ), + 'checked'=> $default['relation_status'], + 'db_field'=>'relation_status', + 'auto_view'=>'yes', + + + ), + 'show_dob' => array( + 'title'=> lang("show_dob"), + 'type'=> "radiobutton", + 'name'=> "show_dob", + 'id'=> "show_dob", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => $default['show_dob'], + 'db_field'=>'show_dob', + 'syntax_type'=> 'name', + 'auto_view'=>'no', + 'sep'=>' ' + ), + 'about_me' => array( + 'title'=> lang("user_about_me"), + 'type'=> "textarea", + 'name'=> "about_me", + 'id'=> "about_me", + 'value'=> cleanForm($default['about_me']), + 'db_field'=>'about_me', + 'auto_view'=>'no', + 'clean_func' => 'Replacer', + ), + 'profile_tags' => array( + 'title'=> lang("profile_tags"), + 'type'=> "textfield", + 'name'=> "profile_tags", + 'id'=> "profile_tags", + 'value'=> $default['profile_tags'], + 'db_field'=>'profile_tags', + 'auto_view'=>'no' + ), + 'web_url' => array( + 'title'=> lang("website"), + 'type'=> "textfield", + 'name'=> "web_url", + 'id'=> "web_url", + 'value'=> $default['web_url'], + 'db_field'=>'web_url', + 'auto_view'=>'yes', + 'display_function'=>'outgoing_link' + ), + + + ); + + return $profile_fields; + } + + + /** + * function used to load location fields + */ + function load_location_fields($default) + { + if(!$default) + $default = $_POST; + $other_details = array + ( + 'postal_code' => array( + 'title'=> lang("postal_code"), + 'type'=> "textfield", + 'name'=> "postal_code", + 'id'=> "postal_code", + 'value'=> $default['postal_code'], + 'db_field'=>'postal_code', + 'auto_view' => 'yes' + ), + 'hometown' => array( + 'title'=> lang("hometown"), + 'type'=> "textfield", + 'name'=> "hometown", + 'id'=> "hometown", + 'value'=> $default['hometown'], + 'db_field'=>'hometown', + 'auto_view' => 'yes' + ), + 'city' => array( + 'title'=> lang("city"), + 'type'=> "textfield", + 'name'=> "city", + 'id'=> "city", + 'value'=> $default['city'], + 'db_field'=>'city', + 'auto_view' => 'yes' + ), + ); + return $other_details; + } + + + /** + * Function used to load experice fields + */ + function load_education_interests($default) + { + if(!$default) + $default = $_POST; + $more_details = array + ( + 'education' => array( + 'title'=> lang("education"), + 'type'=> "dropdown", + 'name'=> "education", + 'id'=> "education", + 'value'=> array(lang('usr_arr_no_ans'), + lang('usr_arr_elementary'), + lang('usr_arr_hi_school'), + lang('usr_arr_some_colg'), + lang('usr_arr_assoc_deg'), + lang('usr_arr_bach_deg'), + lang('usr_arr_mast_deg'), + lang('usr_arr_phd'), + lang('usr_arr_post_doc'), + ), + 'checked'=>$default['education'], + 'db_field'=>'education', + 'auto_view'=>'yes', + ), + 'schools' => array( + 'title'=> lang("schools"), + 'type'=> "textarea", + 'name'=> "schools", + 'id'=> "schools", + 'value'=> cleanForm($default['schools']), + 'db_field'=>'schools', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'occupation' => array( + 'title'=> lang("occupation"), + 'type'=> "textarea", + 'name'=> "occupation", + 'id'=> "occupation", + 'value'=> cleanForm($default['occupation']), + 'db_field'=>'occupation', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'companies' => array( + 'title'=> lang("companies"), + 'type'=> "textarea", + 'name'=> "companies", + 'id'=> "companies", + 'value'=> cleanForm($default['companies']), + 'db_field'=>'companies', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'hobbies' => array( + 'title'=> lang("hobbies"), + 'type'=> "textarea", + 'name'=> "hobbies", + 'id'=> "hobbies", + 'value'=> cleanForm($default['hobbies']), + 'db_field'=>'hobbies', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'fav_movies' => array( + 'title'=> lang("user_fav_movs_shows"), + 'type'=> "textarea", + 'name'=> "fav_movies", + 'id'=> "fav_movies", + 'value'=> cleanForm($default['fav_movies']), + 'db_field'=>'fav_movies', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'fav_music' => array( + 'title'=> lang("user_fav_music"), + 'type'=> "textarea", + 'name'=> "fav_music", + 'id'=> "fav_music", + 'value'=> cleanForm($default['fav_music']), + 'db_field'=>'fav_music', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + 'fav_books' => array( + 'title'=> lang("user_fav_books"), + 'type'=> "textarea", + 'name'=> "fav_books", + 'id'=> "fav_books", + 'value'=> cleanForm($default['fav_books']), + 'db_field'=>'fav_books', + 'clean_func' => 'Replacer', + 'auto_view'=>'yes', + ), + + ); + return $more_details; + } + + + /** + * Function used to load privacy fields + */ + function load_privacy_field($default) + { + if(!$default) + $default = $_POST; + + $privacy = array + ( + 'online_status' => array( + 'title'=> lang("online_status"), + 'type'=> "dropdown", + 'name'=> "privacy", + 'id'=> "privacy", + 'value'=> array('online'=>lang('online'),'offline'=>lang('offline'),'custom'=>lang('custom')), + 'checked'=>$default['online_status'], + 'db_field'=>'online_status', + ), + 'show_profile' => array( + 'title'=> lang("show_profile"), + 'type'=> "dropdown", + 'name'=> "show_profile", + 'id'=> "show_profile", + 'value'=> array('all'=>lang('all'),'members'=>lang('members'),'friends'=>lang('friends')), + 'checked'=>$default['show_profile'], + 'db_field'=>'show_profile', + 'sep' => ' ' + ), + 'allow_comments'=>array( + 'title'=> lang("vdo_allow_comm"), + 'type'=> "radiobutton", + 'name'=> "allow_comments", + 'id'=> "allow_comments", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['allow_comments']), + 'db_field'=>'allow_comments', + 'sep' => ' ' + ), + 'allow_ratings'=>array( + 'title'=> lang("allow_ratings"), + 'type'=> "radiobutton", + 'name'=> "allow_ratings", + 'id'=> "allow_ratings", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['allow_ratings']), + 'db_field'=>'allow_ratings', + 'sep' => ' ' + ), + 'allow_subscription'=>array( + 'title'=> lang("allow_subscription"), + 'type'=> "radiobutton", + 'name'=> "allow_subscription", + 'id'=> "allow_subscription", + 'hint_1' => lang('allow_subscription_hint'), + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['allow_subscription']), + 'db_field'=>'allow_subscription', + 'sep' => ' ' + ), + ); + + return $privacy; + } + + /** + * load_channel_settings + * + * @param $input defaults value for channel settings + * @return arra of channel info fields + */ + function load_channel_settings($default) + { + if(!$default) + $default = $_POST; + + $channel_settings = array + ( + 'profile_title' => array( + 'title'=> lang("channel_title"), + 'type'=> "textfield", + 'name'=> "profile_title", + 'id'=> "profile_title", + 'value'=> $default['profile_title'], + 'db_field'=>'profile_title', + 'auto_view'=>'no' + + ), + 'profile_desc' => array( + 'title'=> lang("channel_desc"), + 'type'=> "textarea", + 'name'=> "profile_desc", + 'id'=> "profile_desc", + 'value'=> $default['profile_desc'], + 'db_field'=>'profile_desc', + 'auto_view'=>'yes', + 'clean_func' => 'Replacer', + ), + 'show_my_friends'=>array( + 'title'=> lang("show_my_friends"), + 'type'=> "radiobutton", + 'name'=> "show_my_friends", + 'id'=> "show_my_friends", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_friends']), + 'db_field'=>'show_my_friends', + 'sep' => ' ' + ), + 'show_my_videos'=>array( + 'title'=> lang("show_my_videos"), + 'type'=> "radiobutton", + 'name'=> "show_my_videos", + 'id'=> "show_my_videos", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_videos']), + 'db_field'=>'show_my_videos', + 'sep' => ' ' + ), + 'show_my_photos'=>array( + 'title'=> lang("show_my_photos"), + 'type'=> "radiobutton", + 'name'=> "show_my_photos", + 'id'=> "show_my_photos", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_photos']), + 'db_field'=>'show_my_photos', + 'sep' => ' ' + ), + 'show_my_subscriptions'=>array( + 'title'=> lang("show_my_subscriptions"), + 'type'=> "radiobutton", + 'name'=> "show_my_subscriptions", + 'id'=> "show_my_subscriptions", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_subscriptions']), + 'db_field'=>'show_my_subscriptions', + 'sep' => ' ' + ), + 'show_my_subscribers'=>array( + 'title'=> lang("show_my_subscribers"), + 'type'=> "radiobutton", + 'name'=> "show_my_subscribers", + 'id'=> "show_my_subscribers", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_subscribers']), + 'db_field'=>'show_my_subscribers', + 'sep' => ' ' + ), + 'show_my_collections'=>array( + 'title'=> lang("show_my_collections"), + 'type'=> "radiobutton", + 'name'=> "show_my_collections", + 'id'=> "show_my_collections", + 'value' => array('yes'=>lang('yes'),'no'=>lang('no')), + 'checked' => strtolower($default['show_my_collections']), + 'db_field'=>'show_my_collections', + 'sep' => ' ' + ), + + ); + + return $channel_settings; + } + + + /** + * load_user_fields + * + * @param $input default values for user profile fields + * @return array of user fields + * + * Function used to load Video fields + * in clipbucket v2.1 , video fields are loaded in form of groups arrays + * each group has it name and fields wrapped in array + * and that array will be part of video fields + */ + + function load_user_fields($default,$type='all') + { + $getChannelSettings = false; + $getProfileSettings = false; + $fields = array(); + + switch($type) + { + case "all": + { + $getChannelSettings = true; + $getProfileSettings = true; + } + break; + + case "channel": + case "channels": + { + $getChannelSettings = true; + } + break; + + case "profile": + case "profile_settings": + { + $getProfileSettings = true; + } + break; + + } + + + if($getChannelSettings) + { + $channel_settings = array + ( + array + ( + 'group_name' => lang('channel_settings'), + 'group_id' => 'channel_settings', + 'fields' => array_merge($this->load_channel_settings($default) + ,$this->load_privacy_field($default)), + ), + ); + } + + if($getProfileSettings) + { + $profile_settings = array + ( + array + ( + 'group_name' => lang('profile_basic_info'), + 'group_id' => 'profile_basic_info', + 'fields' => $this->load_personal_details($default), + ), + + array + ( + 'group_name' => lang('location'), + 'group_id'=> 'profile_location', + 'fields' => $this->load_location_fields($default) + ), + + array + ( + 'group_name' => lang('profile_education_interests'), + 'group_id' => 'profile_education_interests', + 'fields' => $this->load_education_interests($default) + ) + ); + + + //Adding Custom Fields + $custom_fields = $this->load_custom_profile_fields($default,false); + + if($custom_fields) + { + $more_fields_group = + array + ( + 'group_name' => lang('more_fields'), + 'group_id' => 'custom_fields', + 'fields' => $custom_fields, + ); + } + + //Loading Custom Profile Forms + $custom_fields_with_group = $this->load_custom_profile_fields($default,true); + + //Finaling putting them together in their main array called $fields + if($custom_fields_with_group) + { + $custFieldGroups = $custom_fields_with_group; + + foreach($custFieldGroups as $gKey => $fieldGroup) + { + + $group_id = $fieldGroup['group_id']; + + foreach($profile_settings as $key => $field) + { + + if($field['group_id'] == $group_id) + { + $inputFields = $field['fields']; + //Setting field values + $newFields = $fieldGroup['fields']; + + + + $mergeField = array_merge($inputFields,$newFields); + + + //Finally Updating array + $newGroupArray = + array + ( + 'group_name' => $field['group_name'], + 'group_id' => $field['group_id'], + 'fields' => $mergeField, + ); + + $fields[$key] = $newGroupArray; + + $matched = true; + break; + }else + $matched = false; + + } + + if(!$matched) + $profile_settings[] = $fieldGroup; + + } + } + + } + + + if($channel_settings) + $fields = array_merge($fields,$channel_settings); + if($profile_settings) + $fields = array_merge($fields,$profile_settings); + if($more_fields_group) + $fields[] = $more_fields_group; + return $fields; + } + + /** + * Used to rate photo + */ + function rate_user($id,$rating) + { + global $db,$json; + + if(!is_numeric($rating) || $rating <= 9) + $rating = 0; + if($rating >= 10) + $rating = 10; + + $c_rating = $this->current_rating($id); + $voters = $c_rating['voters']; + + $new_rate = $c_rating['rating']; + $rated_by = $c_rating['rated_by']; + + if(phpversion < '5.2.0') + $voters = $json->json_decode($voters,TRUE); + else + $voters = json_decode($voters,TRUE); + + if(!empty($voters)) + $already_voted = array_key_exists(userid(),$voters); + + if(!userid()) + e(lang("please_login_to_rate")); + elseif(userid()==$c_rating['userid'] && !config('own_channel_rating')) + e(lang("you_cant_rate_own_channel")); + elseif(!empty($already_voted)) + e(lang("you_have_already_voted_channel")); + elseif($c_rating['allow_ratings'] == 'no' || !config('channel_rating')) + e(lang("channel_rating_disabled")); + else + { + $voters[userid()] = array('rate'=>$rating,'time'=>NOW()); + if(phpversion < '5.2.0') + $voters = $json->json_encode($voters); + else + $voters = json_encode($voters); + + $t = $c_rating['rated_by'] * $c_rating['rating']; + $rated_by = $c_rating['rated_by'] + 1; + $new_rate = ($t + $rating) / $rated_by; + $db->update(tbl('user_profile'),array('rating','rated_by','voters'), + array("$new_rate","$rated_by","|no_mc|$voters"), + " userid = ".$id.""); + $userDetails = array( + "object_id" => $id, + "type" => "user", + "time" => now(), + "rating" => $rating, + "userid" => userid(), + "username" => username() + ); + /* Updating user details */ + update_user_voted($userDetails); + e(lang("thnx_for_voting"),"m"); + } + + $return = array("rating"=>$new_rate,"rated_by"=>$rated_by,'total'=>10,"id"=>$id,"type"=>"user","disable"=>"disabled"); + return $return; + } + + + /** + * Used to get current rating + */ + function current_rating($id) + { + global $db; + $result = $db->select(tbl('user_profile'),'userid,allow_ratings,rating,rated_by,voters'," userid = ".$id.""); + if($result) + return $result[0]; + else + return false; + } + + + /** + * function used to check weather user is online or not + */ + function isOnline($last_active,$status=NULL) + { + $time = strtotime($last_active); + $timeDiff = time() - $time; + if($timeDiff>60 || $status=='offline') + return false; + else + return true; + } + + + /** + * Function used to get list of subscribed users and then + * send subscription email + */ + function sendSubscriptionEmail($vidDetails,$updateStatus=true) + { + global $cbemail,$db; + $v = $vidDetails; + if(!$v['videoid']) + { + e(lang("invalid_videoid")); + return false; + } + + if(!$v['userid']) + { + e(lang("invalid_userid")); + return false; + } + + //Lets get the list of subscribers + $subscribers = $this->get_user_subscribers_detail($v['userid'],false); + //Now lets get details of our uploader bhai saab + $uploader = $this->get_user_details($v['userid']); + //Loading subscription email template + $tpl = $cbemail->get_template('video_subscription_email'); + + $total_subscribers = count($subscribers); + if($subscribers) + foreach($subscribers as $subscriber) + { + $var = $this->custom_subscription_email_vars; + + $more_var = array + ('{username}' => $subscriber['username'], + '{uploader}' => $uploader['username'], + '{video_title}' => $v['title'], + '{video_description}' => $v['description'], + '{video_link}' => video_link($v), + '{video_thumb}' => get_thumb($v), + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + + cbmail(array('to'=>$subscriber['email'],'from'=>WELCOME_EMAIL,'subject'=>$subj,'content'=>$msg)); + + } + + if($total_subscribers) + { + //Updating video subscription email status to sent + if($updateStatus) + $db->update(tbl('video'),array('subscription_email'),array('sent')," videoid='".$v['videoid']."'"); + $s = ""; + if($total_subscribers>1) + $s = "s"; + e(sprintf(lang('subs_email_sent_to_users'),$total_subscribers,$s),"m"); + return true; + } + + e(lang("no_user_subscribed_to_uploader")); + + return true; + } + + /** + * function used to get user seesions + */ + function get_sessions() + { + global $sess; + $sessions = $sess->get_sessions(); + $new_sessions = array(); + if($sessions) + { + foreach($sessions as $session) + { + $new_sessions[$session['session_string']] = $session; + } + }else + { + $sess->add_session(0,'guest','guest'); + } + + return $new_sessions; + } + + function update_user_voted($array,$userid=NULL) + { + global $db; + //$voted = array(); + if(!$userid) + $userid = userid(); + if(phpversion < '5.2.0') + { + global $json; + $js = $json; + } + if(is_array($array)) + { + $votedDetails = $db->select(tbl("users"),"voted"," userid = '$userid'"); + if(!empty($votedDetails)) + if(!empty($js)) + $voted = $js->json_decode($votedDetails[0]['voted'],TRUE); + else + $voted = json_decode($votedDetails[0]['voted'],TRUE); + + //$votedArray = $voted; + $voted[] = $array; + + if(!empty($js)) + $votedEncode = $js->json_encode($voted); + else + $votedEncode = json_encode($voted); + + if(!empty($votedEncode)) + $db->update(tbl("users"),array("voted"),array("|no_mc|$votedEncode")," userid='$userid'"); + } + } +} +?> \ No newline at end of file diff --git a/upload/includes/classes/video.class.php b/upload/includes/classes/video.class.php new file mode 100644 index 00000000..3d4931a1 --- /dev/null +++ b/upload/includes/classes/video.class.php @@ -0,0 +1,1732 @@ +'video'); + + var $video_manager_links = array(); + var $video_manager_funcs = array(); + + var $video_delete_functions = array(); //Holds all delete functions of video + + /** + * __Constructor of CBVideo + */ + function init() + { + global $Cbucket; + $this->cat_tbl = 'video_categories'; + $this->section_tbl = 'video'; + $this->use_sub_cats = TRUE; + $this->init_actions(); + $this->init_collections(); + + if(config('vid_cat_height')); + $this->cat_thumb_height = config('vid_cat_height'); + if(config('vid_cat_width')); + $this->cat_thumb_width = config('vid_cat_width'); + + if(isSectionEnabled('videos')) + $Cbucket->search_types['videos'] = "cbvid"; + $Cbucket->clipbucket_footer[] = 'check_cbvideo'; + + $this->video_delete_functions[] = 'delete_video_from_collection'; + } + + /** + * Initiating Collections + */ + function init_collections() + { + $this->collection = new Collections(); + $this->collection->objType = "v"; + $this->collection->objClass = "cbvideo"; + $this->collection->objTable = "video"; + $this->collection->objName = "Video"; + $this->collection->objFunction = "video_exists"; + $this->collection->objFieldID = "videoid"; + } + + + /** + * Function used to check weather video exists or not + * @param VID or VKEY + */ + function video_exists($vid) + { + global $db; + if(is_numeric($vid)) + return $db->count(tbl("video"),"videoid"," videoid='$vid' "); + else + return $db->count(tbl("video"),"videoid"," videokey='$vid' "); + //return $this->get_video($vid); + } + function exists($vid){return $this->video_exists($vid);} + function videoexists($vid){return $this->video_exists($vid);} + + + /** + * Function used to get video data + */ + function get_video($vid,$file=false) + { + global $db; + + $userFields = "users.userid,users.username,users.avatar,users.avatar_url,users.email"; + + if(!$file) + { + if(is_numeric($vid)) + $results = $db->select(tbl("video,users"),tbl("video.*,$userFields"),tbl("video.videoid='$vid'")." AND ".tbl("video.userid=").tbl("users.userid")); + else + $results = $db->select(tbl("video,users"),tbl("video.*,$userFields"),tbl("video.videokey='$vid'")." AND ".tbl("video.userid=").tbl("users.userid")); + }else + { + $results = $db->select(tbl("video,users"),tbl("video.*,$userFields"),tbl("video.file_name='$vid'")." AND ".tbl("video.userid=").tbl("users.userid")); + } + + if($db->num_rows>0) + { + return $results[0]; + }else{ + return false; + } + } + function getvideo($vid){return $this->get_video($vid);} + function get_video_data($vid){return $this->get_video($vid);} + function getvideodata($vid){return $this->get_video($vid);} + function get_video_details($vid){return $this->get_video($vid);} + function getvideodetails($vid){return $this->get_video($vid);} + + /** + * Function used to perform several actions with a video + */ + function action($case,$vid) + { + global $db,$eh; + $video = $this->get_video_details($vid); + + if(!$video) + return false; + //Lets just check weathter video exists or not + switch($case) + { + //Activating a video + case 'activate': + case 'av': + case 'a': + { + $db->update(tbl("video"),array('active'),array('yes')," videoid='$vid' OR videokey = '$vid' "); + e(lang("class_vdo_act_msg"),'m'); + + if(SEND_VID_APPROVE_EMAIL=='yes') + { + //Sending Email + global $cbemail,$userquery; + $tpl = $cbemail->get_template('video_activation_email'); + $user_fields = $userquery->get_user_field($video['userid'],"username,email"); + $more_var = array + ('{username}' => $user_fields['username'], + '{video_link}' => videoLink($video) + ); + if(!is_array($var)) + $var = array(); + $var = array_merge($more_var,$var); + $subj = $cbemail->replace($tpl['email_template_subject'],$var); + $msg = nl2br($cbemail->replace($tpl['email_template'],$var)); + + //Now Finally Sending Email + cbmail(array('to'=>$user_fields['email'],'from'=>WEBSITE_EMAIL,'subject'=>$subj,'content'=>$msg)); + } + + + if(($video['broadcast']=='public' || $video['broadcast'] =="logged") + && $video['subscription_email']=='pending') + { + //Sending Subscription email in background + if (stristr(PHP_OS, 'WIN')) + { + exec(php_path()." -q ".BASEDIR."/actions/send_subscription_email.php $vid "); + } else { + exec(php_path()." -q ".BASEDIR."/actions/send_subscription_email.php $vid &> /dev/null &"); + } + } + } + break; + + //Deactivating a video + case "deactivate": + case "dav": + case "d": + { + $db->update(tbl("video"),array('active'),array('no')," videoid='$vid' OR videokey = '$vid' "); + e(lang("class_vdo_act_msg1"),'m'); + } + break; + + //Featuring Video + case "feature": + case "featured": + case "f": + { + $db->update(tbl("video"),array('featured','featured_date'),array('yes',now())," videoid='$vid' OR videokey = '$vid' "); + e(lang("class_vdo_fr_msg"),'m'); + } + break; + + + //Unfeatured video + case "unfeature": + case "unfeatured": + case "uf": + { + $db->update(tbl("video"),array('featured'),array('no')," videoid='$vid' OR videokey = '$vid' "); + e(lang("class_fr_msg1"),'m'); + } + break; + } + } + + + + /** + * Function used to update video + */ + function update_video($array=NULL) + { + global $eh,$Cbucket,$db,$Upload; + + $Upload->validate_video_upload_form(NULL,TRUE); + + if(empty($eh->error_list)) + { + $required_fields = $Upload->loadRequiredFields($array); + $location_fields = $Upload->loadLocationFields($array); + $option_fields = $Upload->loadOptionFields($array); + + $upload_fields = array_merge($required_fields,$location_fields,$option_fields); + + //Adding Custom Upload Fields + if(count($Upload->custom_upload_fields)>0) + $upload_fields = array_merge($upload_fields,$Upload->custom_upload_fields); + + //Adding Custom Form Fields + if(count($Upload->custom_form_fields)>0) + $upload_fields = array_merge($upload_fields,$Upload->custom_form_fields); + + //Adding custom fields from group + if(count($Upload->custom_form_fields_groups)>0) + { + $custom_fields_from_group_fields = array(); + $custom_fields_from_group = $Upload->custom_form_fields_groups; + foreach($custom_fields_from_group as $cffg) + { + $custom_fields_from_group_fields = array_merge($custom_fields_from_group_fields,$cffg['fields']); + } + + $upload_fields = array_merge($upload_fields,$custom_fields_from_group_fields); + } + + + if(!$array) + $array = $_POST; + + $vid = $array['videoid']; + + if(is_array($_FILES)) + $array = array_merge($array,$_FILES); + + + foreach($upload_fields as $field) + { + $name = formObj::rmBrackets($field['name']); + $val = $array[$name]; + + if(empty($val) && $field['use_if_value']) + { + }else + { + 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'] || (!apply_func($field['clean_func'],$val) && !is_array($field['clean_func']))) + $val = ($val); + else + $val = apply_func($field['clean_func'],sql_free('|no_mc|'.$val)); + + if(!empty($field['db_field'])) + $query_val[] = $val; + + } + + } + + #$query = "INSERT INTO video ("; + $total_fields = count($query_field); + + /*for($key=0;$key<$total_fields;$key++) + { + $query .= query_field[$key]." = '".$query_val[$key]."'" ; + if($key<$total_fields-1) + $query .= ','; + }*/ + + if(has_access('admin_access',TRUE)) + { + if(!empty($array['status'])) + { + $query_field[] = 'status'; + $query_val[] = $array['status']; + } + + if(!empty($array['duration']) && is_numeric($array['duration']) && $array['duration']>0) + { + $query_field[] = 'duration'; + $query_val[] = $array['duration']; + } + + if(!empty($array['views'])) + { + $query_field[] = 'views'; + $query_val[] = $array['views']; + } + + if(!empty($array['rating'])) + { + $query_field[] = 'rating'; + $rating = $array['rating']; + if(!is_numeric($rating) || $rating<0 || $rating>10) + $rating = 1; + $query_val[] = $rating; + } + + if(!empty($array['rated_by'])) + { + $query_field[] = 'rated_by'; + $query_val[] = $array['rated_by']; + } + } + + if(!userid()) + { + e(lang("you_dont_have_permission_to_update_this_video")); + }elseif(!$this->video_exists($vid)){ + e(lang("class_vdo_del_err")); + }elseif(!$this->is_video_owner($vid,userid()) && !has_access('admin_access',TRUE)) + { + e(lang("no_edit_video")); + }else{ + //pr($upload_fields); + + $db->update(tbl('video'),$query_field,$query_val," videoid='$vid'"); + //echo $db->db_query; + e(lang("class_vdo_update_msg"),'m'); + } + + } + } + + + /** + * Function used to delete a video + */ + function delete_video($vid) + { + global $db; + + if($this->video_exists($vid)) + { + + $vdetails = $this->get_video($vid); + + if($this->is_video_owner($vid,userid()) || has_access('admin_access',TRUE)) + { + #THIS SHOULD NOT BE REMOVED :O + //list of functions to perform while deleting a video + $del_vid_funcs = $this->video_delete_functions; + if(is_array($del_vid_funcs)) + { + foreach($del_vid_funcs as $func) + { + if(function_exists($func)) + { + $func($vdetails); + } + } + } + + //Finally Removing Database entry of video + $db->execute("DELETE FROM ".tbl("video")." WHERE videoid='$vid'"); + //Removing Video From Playlist + $db->execute("DELETE FROM ".tbl("playlist_items")." WHERE object_id='$vid' AND playlist_item_type='v'"); + + $db->update(tbl("users"),array("total_videos"),array("|f|total_videos-1")," userid='".$vdetails['userid']."'"); + + //Removing video Comments + $db->delete(tbl("comments"),array("type","type_id"),array("v",$vdetails['videoid'])); + //Removing video From Favortes + $db->delete(tbl("favorites"),array("type","id"),array("v",$vdetails['videoid'])); + + e(lang("class_vdo_del_msg"),'m'); + }else{ + e(lang("You cannot delete this video")); + } + }else{ + e(lang("class_vdo_del_err")); + } + + } + + /** + * Function used to remove video thumbs + */ + function remove_thumbs($vdetails) + { + //First lets get list of all thumbs + $thumbs = get_thumb($vdetails,1,true,false,false); + if(!is_default_thumb($thumbs)) + { + if(is_array($thumbs)) + { + foreach($thumbs as $thumb) + { + $file = THUMBS_DIR.'/'.$thumb; + if(file_exists($file) && is_file($file)) + unlink($file); + } + }else{ + $file = THUMBS_DIR.'/'.$thumbs; + if(file_exists($file) && is_file($file)) + unlink($file); + } + + e(lang("vid_thumb_removed_msg"),'m'); + } + } + + + + /** + * Function used to remove video log + */ + function remove_log($vdetails) + { + global $db; + $src = $vdetails['videoid']; + $file = LOGS_DIR.'/'.$vdetails['file_name'].'.log'; + $db->execute("DELETE FROM ".tbl("video_file")." WHERE src_name = '$src'"); + if(file_exists($file)) + unlink($file); + e(lang("vid_log_delete_msg"),'m'); + } + + /** + * Function used to remove video files + */ + function remove_files($vdetails) + { + //Return nothing incase there is no input + if(!$vdetails) + { + e("No input details specified"); + return false; + } + //Callign Video Delete Functions + call_delete_video_function($vdetails); + + //Getting list of files + $files = get_video_file($vdetails,false,false,true); + if(is_array($files)) + { + foreach($files as $file) + { + if(file_exists(VIDEOS_DIR.'/'.$file) && is_file(VIDEOS_DIR.'/'.$file)) + unlink(VIDEOS_DIR.'/'.$file); + } + }else{ + if(file_exists(VIDEOS_DIR.'/'.$files) && is_file(VIDEOS_DIR.'/'.$files)) + unlink(VIDEOS_DIR.'/'.$files); + } + e(lang("vid_files_removed_msg"),'m'); + } + + + /** + * Function used to get videos + * this function has all options + * that you need to fetch videos + * please see docs.clip-bucket.com for more details + */ + function get_videos($params) + { + global $db; + + $limit = $params['limit']; + $order = $params['order']; + + $cond = ""; + $superCond = ""; + if(!has_access('admin_access',TRUE)) + $superCond = $cond .= " ".tbl("video.status")."='Successful' AND + ".tbl("video.active")."='yes' AND ".tbl("video.broadcast")." !='unlisted' "; + else + { + if($params['active']) + $cond .= " ".tbl("video.active")."='".$params['active']."'"; + + if($params['status']) + { + if($cond!='') + $cond .=" AND "; + $cond .= " ".tbl("video.status")."='".$params['status']."'"; + } + if($params['broadcast']) + { + if($cond!='') + $cond .=" AND "; + $cond .= " ".tbl("video.broadcast")."='".$params['broadcast']."'"; + } + } + + //Setting Category Condition + $all = false; + if(!is_array($params['category'])) + if(strtolower($params['category'])=='all') + $all = true; + + if($params['category'] && !$all) + { + if($cond!='') + $cond .= ' AND '; + + $cond .= " ("; + + if(!is_array($params['category'])) + { + $cats = explode(',',$params['category']); + }else + $cats = $params['category']; + + $count = 0; + + foreach($cats as $cat_params) + { + $count ++; + if($count>1) + $cond .=" OR "; + $cond .= " ".tbl("video.category")." LIKE '%#$cat_params#%' "; + } + + $cond .= ")"; + } + + //date span + if($params['date_span']) + { + if($cond!='') + $cond .= ' AND '; + + if($params['date_span_column']) + $column = $params['date_span_column']; + else + $column = 'date_added'; + + $cond .= " ".cbsearch::date_margin($column,$params['date_span']); + } + + //uid + if($params['user']) + { + if(!is_array($params['user'])) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("video.userid")."='".$params['user']."'"; + }else + { + if($cond!='') + $cond .= ' AND ('; + + $uQu = 0; + foreach($params['user'] as $user) + { + if($uQu>0) + $cond .= ' OR '; + $cond .= " ".tbl("video.userid")."='".$user."'"; + $uQu++; + } + + $cond .=" ) "; + } + + } + + //non-uid to exclude user videos from related + if($params['nonuser']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("video.userid")." <> '".$params['nonuser']."' "; + + } + + $tag_n_title=''; + //Tags + if($params['tags']) + { + //checking for commas ;) + $tags = explode(",",$params['tags']); + if(count($tags)>0) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $total = count($tags); + $loop = 1; + foreach($tags as $tag) + { + $tag_n_title .= " ".tbl('video.tags')." LIKE '%".$tag."%'"; + if($loop<$total) + $tag_n_title .= " OR "; + $loop++; + + } + }else + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " ".tbl('video.tags')." LIKE '%".$params['tags']."%'"; + } + } + //TITLE + if($params['title']) + { + if($tag_n_title!='') + $tag_n_title .= ' OR '; + $tag_n_title .= " ".tbl('video.title')." LIKE '%".$params['title']."%'"; + } + + if($tag_n_title) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ($tag_n_title) "; + } + + //FEATURED + if($params['featured']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("video.featured")." = '".$params['featured']."' "; + } + + //VIDEO ID + if($params['videoid']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("video.videoid")." = '".$params['videoid']."' "; + } + + //VIDEO ID + if($params['videoids']) + { + if(is_array($params['videoids'])) + { + if($cond!='') + $cond .= ' AND '; + $cond .= ' ( '; + $curVid = 0; + foreach($params['videoids'] as $vid) + { + if(is_numeric($vid)) + { + if($curVid>0) + $cond .= " OR "; + $cond .= " ".tbl("video.videoid")." = '".$vid."' "; + } + $curVid++; + } + $cond .= ' ) '; + } + } + + //VIDEO KEY + if($params['videokey']) + { + + if(!is_array($params['videokey'])) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl("video.videokey")." = '".$params['videokey']."' "; + }else + { + if($cond!='') + $cond .= ' AND ('; + + $vkeyQue = 0; + foreach($params['videokey'] as $videokey) + { + if($vkeyQue>0) + $cond .= ' OR '; + $cond .= " ".tbl("video.videokey")." = '".$videokey."' "; + $vkeyQue++; + } + + $cond .=" ) "; + } + } + + + //Exclude Vids + if($params['exclude']) + { + if(!is_array($params['exclude'])) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.videoid')." <> '".$params['exclude']."' "; + }else + { + foreach($params['exclude'] as $exclude) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.videoid')." <> '".$exclude."' "; + } + } + } + + //Duration + + if($params['duration']) + { + $duration_op = $params['duration_op']; + if(!$duration_op) $duration_op = "="; + + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.duration')." ".$duration_op." '".$params['duration']."' "; + } + + //Filename + + if($params['filename']) + { + if(!is_array($params['filename'])) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.file_name')." <> '".$params['filename']."' "; + }else + { + if($cond!='') + $cond .= ' AND ('; + + $fileNameQue = 0; + foreach($params['filename'] as $filename) + { + if($fileNameQue>0) + $cond .= ' OR '; + $cond .= " ".tbl("video.file_name")." = '".$filename."' "; + $fileNameQue++; + } + + $cond .=" ) "; + } + } + + if($params['cond']) + { + if($params['cond_and']) + if($cond!='') + $cond .= ' AND '; + $cond .= " ".$params['cond']; + } + + + $functions = cb_get_functions('get_videos'); + if($functions) + { + foreach($functions as $func) + { + $array = array('params'=>$params,'cond'=>$cond); + if(function_exists($func['func'])) + { + $returned = $func['func']($array); + if($returned) + $cond = $returned; + } + } + } + + + if(!$params['count_only'] && !$params['show_related']) + { + if(!empty($cond)) + $cond .= " AND "; + $result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'),$cond." ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); + //echo $db->db_query; + } + + + if($params['show_related']) + { + $cond = ""; + if($superCond) + $cond = $superCond." AND "; + + $cond .= "MATCH(".tbl("video.title,video.tags").") + AGAINST ('".cbsearch::set_the_key($params['title'])."' IN BOOLEAN MODE) "; + if($params['exclude']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.videoid')." <> '".$params['exclude']."' "; + } + + $result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'), + $cond." AND ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); + if($db->num_rows == 0) + { + $cond = ""; + if($superCond) + $cond = $superCond." AND "; + //Try Finding videos via tags + $cond .= "MATCH(".tbl("video.title,video.tags").") + AGAINST ('".cbsearch::set_the_key($params['tags'])."' IN BOOLEAN MODE) "; + if($params['exclude']) + { + if($cond!='') + $cond .= ' AND '; + $cond .= " ".tbl('video.videoid')." <> '".$params['exclude']."' "; + } + $result = $db->select(tbl('video,users'),tbl('video.*,users.userid,users.username'), + $cond." AND ".tbl("video.userid")." = ".tbl("users.userid"),$limit,$order); + } + assign($params['assign'],$result); + } + + if($params['pr']) pr($result,true); + if($params['count_only']) + return $result = $db->count(tbl('video'),'*',$cond); + if($params['assign']) + assign($params['assign'],$result); + else + return $result; + } + + /** + * Function used to count total video comments + */ + function count_video_comments($id) + { + global $db; + $total_comments = $db->count(tbl('comments'),"comment_id","type='v' AND type_id='$id'"); + return $total_comments; + } + + + /** + * Function used to update video comments count + */ + function update_comments_count($id) + { + global $db; + $total_comments = $this->count_video_comments($id); + $db->update(tbl("video"),array("comments_count","last_commented"),array($total_comments,now())," videoid='$id'"); + } + + /** + * Function used to add video comment + */ + function add_comment($comment,$obj_id,$reply_to=NULL,$force_name_email=false) + { + global $myquery,$db; + + $video = $this->get_video_details($obj_id); + + if(!$video) + e(lang("class_vdo_del_err")); + else + { + //Getting Owner Id + $owner_id = $this->get_video_owner($obj_id,true); + $add_comment = $myquery->add_comment($comment,$obj_id,$reply_to,'v',$owner_id,videoLink($video),$force_name_email); + if($add_comment) + { + //Loggin Comment + $log_array = array + ( + 'success'=>'yes', + 'details'=> "comment on a video", + 'action_obj_id' => $obj_id, + 'action_done_id' => $add_comment, + ); + insert_log('video_comment',$log_array); + + //Updating Number of comments of video + $this->update_comments_count($obj_id); + } + return $add_comment; + } + } + + /** + * Function used to remove video comment + */ + function delete_comment($cid,$is_reply=FALSE) + { + global $myquery,$db; + $remove_comment = $myquery->delete_comment($cid,'v',$is_reply); + if($remove_comment) + { + //Updating Number of comments of video + $this->update_comments_count($obj_id); + } + return $remove_comment; + } + + + /** + * Function used to generate Embed Code + */ + function embed_code($vdetails,$type='embed_object') + { + //Checking for video details + if(!is_array($vdetails)) + { + $vdetails = $this->get_video($vdetails); + } + + $embed_code = false; + + $funcs = $this->embed_func_list; + + if(is_array($funcs)) + { + foreach($funcs as $func) + { + if(@function_exists($func)) + $embed_code = $func($vdetails); + + if($embed_code) + break; + } + } + + + if($type=='iframe') + { + $embed_code = ''; + } + + if(!$embed_code) + { + + //Default ClipBucket Embed Code + if(function_exists('default_embed_code')) + { + $embed_code = default_embed_code($vdetails); + }else + { + //return new Embed Code + $vid_file = get_video_file($vdetails,false,false); + if($vid_file) + { + $code = ''; + $code .= ''; + $code .= ''; + $code .= ''; + $code .= ''; + $code .= 'action = new cbactions(); + $this->action->init(); + $this->action->type = 'v'; + $this->action->name = 'video'; + $this->action->obj_class = 'cbvideo'; + $this->action->check_func = 'video_exists'; + $this->action->type_tbl = $this->dbtbl['video']; + $this->action->type_id_field = 'videoid'; + } + + + + /** + * Function used to create value array for email templates + * @param video_details ARRAY + */ + function set_share_email($details) + { + $this->email_template_vars = array + ('{video_title}' => $details['title'], + '{video_description}' => $details['description'], + '{video_tags}' => $details['tags'], + '{video_date}' => cbdate(DATE_FORMAT,strtotime($details['date_added'])), + '{video_link}' => video_link($details), + '{video_thumb}'=> GetThumb($details) + ); + + $this->action->share_template_name = 'share_video_template'; + $this->action->val_array = $this->email_template_vars; + } + + + /** + * Function used to use to initialize search object for video section + * op=>operator (AND OR) + */ + function init_search() + { + + $this->search = new cbsearch; + $this->search->db_tbl = "video"; + $this->search->columns =array( + array('field'=>'title','type'=>'LIKE','var'=>'%{KEY}%'), + array('field'=>'tags','type'=>'LIKE','var'=>'%{KEY}%','op'=>'OR'), + array('field'=>'broadcast','type'=>'!=','var'=>'unlisted','op'=>'AND','value'=>'static'), + array('field'=>'status','type'=>'=','var'=>'Successful','op'=>'AND','value'=>'static') + ); + $this->search->use_match_method = true; + $this->search->match_fields = array("title","tags"); + + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/video.html'; + $this->search->template_var = 'video'; + $this->search->has_user_id = true; + + /** + * Setting up the sorting thing + */ + + $sorting = array( + 'date_added'=> lang("date_added"), + 'views' => lang("views"), + 'comments' => lang("comments"), + 'rating' => lang("rating"), + 'favorites' => lang("favorites") + ); + + $this->search->sorting = array( + 'date_added'=> " date_added DESC", + 'views' => " views DESC", + 'comments' => " comments_count DESC ", + 'rating' => " rating DESC", + 'favorites' => " favorites DeSC" + ); + /** + * Setting Up The Search Fields + */ + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['videos'] = array('title'=>lang('videos')); + $this->search->results_per_page = config('videos_items_search_page'); + + $fields = array( + 'query' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'query', + 'id'=> 'query', + 'value'=>cleanForm($default['query']) + ), + 'category' => array( + 'title' => lang('vdo_cat'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + ), + 'uploaded' => array( + 'title' => lang('uploaded'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['videos']['fields'] = $fields; + } + + + /* + * Function used to update video and set a thumb as default + * @param VID + * @param THUMB NUM + */ + function set_default_thumb($vid,$thumb) + { + global $db,$LANG; + $num = get_thumb_num($thumb); + $file = THUMBS_DIR.'/'.$thumb; + //if(file_exists($file)) + //{ + $db->update(tbl("video"),array("default_thumb"),array($num)," videoid='$vid'"); + e(lang('vid_thumb_changed'),'m'); + //}else{ + // e(lang('vid_thumb_change_err')); + //} + } + + + /** + * Function used to get video owner + */ + function get_video_owner($vid,$idonly=false) + { + global $db; + if($idonly) + { + $results = $db->select(tbl("video"),"userid"," videoid='$vid' ",1); + if($db->num_rows>0) + return $results[0]['userid']; + else + return false; + }else{ + $results = $db->select(tbl("video"),"*"," videoid='$vid' ",1); + if($db->num_rows>0) + return $results[0]; + else + return false; + } + } + + /** + * Function used to check weather current user is video owner or not + */ + function is_video_owner($vid,$uid) + { + global $db; + + $result = $db->count(tbl($this->dbtbl['video']),'videoid',"videoid='$vid' AND userid='$uid' "); + if($result>0) + return true; + else + return false; + } + + /** + * Function used to display video manger link + */ + function video_manager_link($link,$vid) + { + if(function_exists($link) && !is_array($link)) + { + return $link($vid); + }else + { + if(!empty($link['title']) && !empty($link['link'])) + { + return ''.$link['title'].''; + } + } + } + + + + /** + * Function used to get video rating details + */ + function get_video_rating($id) + { + global $db; + if(is_numeric($id)) + { + $results = $db->select(tbl("video"),"userid,allow_rating,rating,rated_by,voter_ids"," videoid='$id'"); + }else + $results = $db->select(tbl("video"),"userid,allow_rating,rating,rated_by,voter_ids"," videokey='$id'"); + if($db->num_rows>0) + return $results[0]; + else + return false; + } + + /** + * Function used to display rating option for videos + * this is an OLD TYPICAL RATING SYSTEM + * and yes, still with AJAX + */ + function show_video_rating($params) + { + $rating = $params['rating']; + $ratings = $params['ratings']; + $total = $params['total']; + $id = $params['id']; + $type = $params['type']; + + //Checking Percent + { + if($total<=10) + $total = 10; + $perc = $rating*100/$total; + $disperc = 100 - $perc; + if($ratings <= 0 && $disperc == 100) + $disperc = 0; + } + + $perc = $perc.'%'; + $disperc = $disperc.'%'; + $likes = round($ratings*$perc/100); // get lowest integer + + if($params['is_rating']) + { + if(error()) + { + $rating_msg = error(); + $rating_msg = ''.$rating_msg[0].''; + } + if(msg()) + { + $rating_msg = msg(); + $rating_msg = ''.$rating_msg[0].''; + } + } + + assign('perc',$perc); + assign('disperc',$disperc); + assign('id',$id); + assign('type',$type); + assign('id',$id); + assign('rating_msg',$rating_msg); + assign("likes",$likes); + assign("dislikes",($ratings-$likes)); + assign('disable',$params['disable']); + + Template('blocks/rating.html'); + + } + + + /** + * Function used to rate video + */ + function rate_video($id,$rating) + { + global $db; + + if(!is_numeric($rating) || $rating <= 9) + $rating = 0; + if($rating >= 10) + $rating = 10; + + $rating_details = $this->get_video_rating($id); + $voter_id = $rating_details['voter_ids']; + + $new_by = $rating_details['rated_by']; + $newrate = $rating_details['rating']; + if(phpversion < '5.2.0') + global $json; $js = $json; + + $Oldvoters = explode('|',$voter_id); + + if(is_array($Oldvoters) && count($Oldvoters)>2) + { + foreach($Oldvoters as $voter) + { + if($voter) + { + $voters[$voter] = array( + "userid" => $voter, + "time" => now(), + "method" => 'old', + ); + } + } + }else + { + if(!empty($js)) + $voters = $js->json_decode($voter_id,TRUE); + else + $voters = json_decode($voter_id,TRUE); + } + + if(!empty($voters)) + $already_voted = array_key_exists(userid(),$voters); + + if(!userid()) + e(lang("please_login_to_rate")); + elseif(userid()==$rating_details['userid'] && !config('own_video_rating')) + e(lang("you_cant_rate_own_video")); + elseif(!empty($already_voted)) + e(lang("you_hv_already_rated_vdo")); + elseif(!config('video_rating') || $rating_details['allow_rating'] !='yes' ) + e(lang("vid_rate_disabled")); + else + { + $voters[userid()] = array( + "userid" => userid(), + "username" => username(), + "time" => now(), + "rating" => $rating + ); + + $total_voters = count($voters); + + if(!empty($js)) + $voters = $js->json_encode($voters); + else + $voters = json_encode($voters); + + $t = $rating_details['rated_by'] * $rating_details['rating']; + //$new_by = $rating_details['rated_by'] + 1; + $new_by = $total_voters; + + $newrate = ($t + $rating) / $new_by; + if($newrate>10) + $newrate = 10; + $db->update(tbl($this->dbtbl['video']),array("rating","rated_by","voter_ids"),array($newrate,$new_by,"|no_mc|$voters")," videoid='$id'"); + $userDetails = array( + "object_id" => $id, + "type" => "video", + "time" => now(), + "rating" => $rating, + "userid" => userid(), + "username" => username() + ); + /* Updating user details */ + update_user_voted($userDetails); + e(lang("thnx_for_voting"),"m"); + } + + $result = array('rating'=>$newrate,'ratings'=>$new_by,'total'=>10,'id'=>$id,'type'=>'video','disable'=>'disabled'); + return $result; + + + /* + Following code is unused + $niddle = "|"; + $niddle .= userid(); + $niddle .= "|"; + $flag = strstr($voter_id, $niddle); + + //checking if raings are allowed or not + $vid_rating = config('video_rating'); + + if(!userid()) + e(lang("please_login_to_rate")); + elseif(userid()==$rating_details['userid'] && !config('own_video_rating')) + e(lang("you_cant_rate_own_video")); + elseif(!empty($flag)) + e(lang("you_hv_already_rated_vdo")); + elseif(!config('video_rating') || $rating_details['allow_rating'] !='yes' ) + e(lang("vid_rate_disabled")); + else + { + if(empty($voter_id)) + $voter_id .= "|"; + $voter_id .= userid(); + $voter_id .= "|"; + $t = $rating_details['rated_by'] * $rating_details['rating']; + $new_by = $rating_details['rated_by'] + 1; + $newrate = ($t + $rating) / $new_by; + + $db->update(tbl($this->dbtbl['video']),array("rating","rated_by","voter_ids"),array($newrate,$new_by,$voter_id)," videoid='$id'"); + e(lang("thnx_for_voting"),"m"); + } + + $result = array('rating'=>$newrate,'ratings'=>$new_by,'total'=>10,'id'=>$id,'type'=>'video','disable'=>'disabled'); + return $result; + */ + } + + + /** + * Function used to get playlist items + */ + function get_playlist_items($pid) + { + global $db; + $ptbl = tbl($this->action->playlist_items_tbl); + $vtbl = tbl($this->dbtbl['video']); + + $tbls = $ptbl.','.$vtbl; + $fields = $ptbl.".*,$vtbl.title,$vtbl.comments_count,$vtbl.views,$vtbl.userid,$vtbl.date_added, + $vtbl.file_name,$vtbl.category,$vtbl.description,$vtbl.videokey,$vtbl.tags,$vtbl.videoid,$vtbl.duration"; + $result = $db->select($tbls,$fields,"playlist_id='$pid' AND ".$vtbl.".videoid=".$ptbl.".object_id"); + if($db->num_rows>0) + return $result; + else + return false; + } + + /** + * Function used to add video in quicklist + */ + function add_to_quicklist($id) + { + global $json, $sess, $userquery; + + if($this->exists($id)) + { + if(phpversion() < '5.2.0') + { + $list = $json->decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + else + { + $list = json_decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + + $list[] = $id; + $new_list = array_unique($list); + + /*//Getting list of videos + $vids = $this->get_videos(array('videoids'=>$new_list)); + $newlist = array(); + //setting up the list + if($vids) + foreach($vids as $vid) + { + $newlist[$vid['videoid']] = + array( + 'title' => $vid['title'], + 'description' => $vid['description'], + 'duration' => SetTime($vid['duration']), + 'thumb' => get_thumb($vid), + 'url' => video_link($video), + 'owner' => $vid['username'], + 'ownner_url' => $userquery->profile_link($vid), + 'date_added' => $vid['date_added'], + 'views' => $vid['views'], + ); + }*/ + if(phpversion() < '5.2.0') + { + $sess->set_cookie(QUICK_LIST_SESS,$json->encode($new_list)); + } + else + { + $sess->set_cookie(QUICK_LIST_SESS,json_encode($new_list)); + } + return true; + + }else + return false; + } + + /** + * Removing video from quicklist + */ + function remove_from_quicklist($id) + { + global $json, $sess; + + if(phpversion() < '5.2.0') + { + $list = $json->decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + else + { + $list = json_decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + $key = array_search($id,$list); + unset($list[$key]); + if(phpversion() < '5.2.0') + { + $sess->set_cookie(QUICK_LIST_SESS,$json->encode($list)); + } + else + { + $sess->set_cookie(QUICK_LIST_SESS,json_encode($list)); + } + return true; + } + + + /** + * function used to count num of quicklist + */ + function total_quicklist() + { + global $json, $sess; + + $total = $sess->get_cookie(QUICK_LIST_SESS); + + if(phpversion() < '5.2.0') + { + $total = $json->decode($total, true); + } + else + { + $total = json_decode($total, true); + } + + return count($total); + } + + /** + * Function used to get quicklist + */ + function get_quicklist() + { + global $json, $sess; + if(phpversion() < '5.2.0') + { + return $json->decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + else + { + return json_decode($sess->get_cookie(QUICK_LIST_SESS), true); + } + } + + /** + * Function used to remove all items of quicklist + */ + function clear_quicklist() + { + global $sess; + $sess->set_cookie(QUICK_LIST_SESS,''); + } + + /** + * Function used to check weather video is downloadable or not + */ + function downloadable($vdo) + { + $file = get_video_file($vdo,false); + if($file) + return true; + else + return false; + } + + /** + * Function used get comments of videos + */ + function get_comments($params=NULL) + { + global $db; + $comtbl = tbl("comments"); + $limit = $params['limit']; + $order = $params['order']; + $type = $params['type']; + + if($type) + $cond = " $comtbl.type = '$type'"; + else + $cond = ''; + + switch($type) { + case 'v': + { + $sectbl = tbl('video'); + $sectblName = 'video'; + $secfields = $sectbl.".videokey,".$sectbl.".videoid,".$sectbl.".file_name,".$sectbl.".title"; + if($cond) { + $cond .= " AND"; + } + $cond .= " $comtbl.type_id = $sectbl.videoid"; + } + break; + + case 't': + { + $sectbl = tbl('group_topics'); + $sectblName = 'group_topics'; + $secfields = $sectbl.".topic_title,".$sectbl.".topic_id,".$sectbl.".topic_title"; + if($cond) { + $cond .= " AND"; + } + $cond .= " $comtbl.type_id = $sectbl.topic_id"; + } + break; + + case 'c': + { + $sectbl = tbl('users'); + $sectblName = 'users'; + $secfields = $sectbl.".username,".$sectbl.".userid"; + if($cond) { + $cond .= " AND"; + } + $cond .= " $comtbl.type_id = $sectbl.userid"; + } + break; + + + default: + { + $sectbl = tbl('video'); + $sectblName = 'video'; + $secfields = $sectbl.".videokey,".$sectbl.".videoid,".$sectbl.".file_name,".$sectbl.".title"; + if($cond) { + $cond .= " AND"; + } + $cond .= " $comtbl.type_id = $sectbl.videoid"; + } + } + + if($params['cond']) + $cond .= " ".$params['cond']; + + if(!$params['count_only']) { + $result = $db->select(tbl("comments,".$sectblName.""), + "$comtbl.*,$secfields", + $cond,$limit,$order); + // echo $db->db_query; + } + if($params['count_only']) + return $result = $db->count(tbl("comments,video"),"*",$cond); + else + return $result; + } + + /** + * Function used get single comment + */ + + function get_comment($cid) { + global $db; + $result = $db->select(tbl("comments"),"*", " comment_id = $cid"); + if($result) + return $result[0]; + else + return false; + } + /** + * Function used get single comment + */ + + function send_notifications() { + // Put your device token here (without spaces): + $deviceToken = '610b18964b4ec3ccb8157ff22cb917fe0f6b9c1673cd4229674d87eb9aa0e5b1'; + + // Put your private key's passphrase here: + $passphrase = 'janjua'; + + // Put your alert message here: + $message = 'Jeevay Pakistan!'; + + //////////////////////////////////////////////////////////////////////////////// + + $ctx = stream_context_create(); + stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem'); + stream_context_set_option($ctx, 'ssl', 'passphrase', $passphrase); + + // Open a connection to the APNS server + $fp = stream_socket_client( + 'ssl://gateway.sandbox.push.apple.com:2195', $err, + $errstr, 60, STREAM_CLIENT_CONNECT|STREAM_CLIENT_PERSISTENT, $ctx); + + if (!$fp) + exit("Failed to connect: $err $errstr" . PHP_EOL); + + echo 'Connected to APNS' . PHP_EOL; + + // Create the payload body + $body['aps'] = array( + 'alert' => $message, + 'sound' => 'default' + ); + + // Encode the payload as JSON + $payload = json_encode($body); + + // Build the binary notification + $msg = chr(0) . pack('n', 32) . pack('H*', $deviceToken) . pack('n', strlen($payload)) . $payload; + + // Send it to the server + $result = fwrite($fp, $msg, strlen($msg)); + + if (!$result) + echo 'Message not delivered' . PHP_EOL; + else + echo 'Message successfully delivered' . PHP_EOL; + + // Close the connection to the server + fclose($fp); + + } + + /** + * Function used update comment + */ + +// function update_comment($cid,$comment) { +// global $db; +// if(!$comment) { +// e(lang('usr_cmt_err1'),e); +// } else { +// $db->update(tbl("comments"),array("comment"),array($comment)," comment_id = $cid"); +// e(lang("Comment Updated"),m); +// } +// } + +} +?> \ No newline at end of file diff --git a/upload/includes/clipbucket.php b/upload/includes/clipbucket.php new file mode 100644 index 00000000..fa644cb1 --- /dev/null +++ b/upload/includes/clipbucket.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/upload/includes/common.php b/upload/includes/common.php new file mode 100644 index 00000000..82a3326f --- /dev/null +++ b/upload/includes/common.php @@ -0,0 +1,639 @@ +Get_Website_Details(); + + + define('DEBUG_LEVEL', 2); + + switch(DEBUG_LEVEL) + { + case 0: + { + error_reporting(0); + ini_set('display_errors', '0'); + } + break; + case 1: + { + error_reporting(E_ALL); + ini_set('display_errors', '1'); + } + break; + + case 2: + default: + { + + if(phpversion() >= '5.3.0') + { + error_reporting(E_ALL ^E_NOTICE ^E_DEPRECATED); + ini_set('display_errors', '1'); + } + else + { + error_reporting(E_ALL ^E_NOTICE); + ini_set('display_errors', '1'); + } + } + } + + + $pages = new pages(); + $ClipBucket = $Cbucket = new ClipBucket(); + + define('BASEDIR',$Cbucket->BASEDIR); + if(!file_exists(BASEDIR.'/index.php')) + die('Basedir is incorrect, please set the correct basedir value in \'config\' table'); + + + $baseurl = $row['baseurl']; + //Removing www. as it effects SEO and updating Config + $wwwcheck = preg_match('/:\/\/www\./',$baseurl,$matches); + if(count($matches)>0) + { + $baseurl = preg_replace('/:\/\/www\./','://',$baseurl); + } + + //define('BASEURL',baseurl(BACK_END)); + $clean_base = false; + if(defined("CLEAN_BASEURL")) + $clean_base = CLEAN_BASEURL; + + //define('BASEURL',$pages->GetBaseUrl($clean_base)); + define('BASEURL',$baseurl); + + $userquery = new userquery(); + $lang_obj = new language; + + + //Setting Time Zone date_default_timezone_set() + + require_once('classes/search.class.php'); + + + require_once('classes/calcdate.class.php'); + require_once('classes/signup.class.php'); + require_once('classes/image.class.php'); + require_once('classes/upload.class.php'); + require_once('classes/ads.class.php'); + require_once('classes/form.class.php'); + require_once('classes/plugin.class.php'); + require_once('classes/errorhandler.class.php'); + require_once('classes/session.class.php'); + require_once('classes/log.class.php'); + require_once('classes/swfObj.class.php'); + require_once('classes/image.class.php'); + require_once('classes/groups.class.php'); + require_once('classes/video.class.php'); + require_once('classes/player.class.php'); + require_once('classes/cbemail.class.php'); + require_once('classes/pm.class.php'); + require_once('classes/cbpage.class.php'); + require_once('classes/reindex.class.php'); + require_once('classes/collections.class.php'); + require_once('classes/photos.class.php'); + require_once('classes/menuhandler.class.php'); + require_once('classes/cbfeeds.class.php'); + + //Adding Gravatar + require_once('classes/gravatar.class.php'); + + require_once 'languages.php'; + + $lang_obj->init(); + $LANG = $lang_obj->lang_phrases('file'); + + + $calcdate = new CalcDate(); + $signup = new signup(); + $Upload = new Upload(); + $cbgroup = new CBGroups(); + $adsObj = new AdsManager(); + $formObj = new formObj(); + + + $cbplugin = new CBPlugin(); + $eh = new EH(); + + $sess = new Session(); + $cblog = new CBLogs(); + $imgObj = new ResizeImage(); + $cbvideo = $cbvid = new CBvideo(); + $cbplayer = new CBPlayer(); + $cbemail = new CBEmail(); + $cbsearch = new CBSearch(); + $cbpm = new cb_pm(); + $cbpage = new cbpage(); + $cbindex = new CBreindex(); + $cbcollection = new Collections(); + $cbphoto = new CBPhotos(); + + $cbfeeds = new cbfeeds(); +// $cbmenu = new MenuHandler(); + check_install('after'); + require 'defined_links.php'; + + @include("clipbucket.php"); + $Cbucket->cbinfo = array("version"=>VERSION,"state"=>STATE,"rev"=>REV,"release_date"=>RELEASED); + + +//Holds Advertisment IDS that are being Viewed + $ads_array = array(); + + + + + if(phpversion() < '5.2.0') + { + require_once($Cbucket->BASEDIR.'/includes/classes/Services_JSON.php'); + $json = new Services_JSON(); + } + +//Website Details + + define('CB_VERSION', $row['version']); + define('TITLE',$row['site_title']); + define('SLOGAN',$row['site_slogan']); + + + + //Seo URLS + + define('SEO',$row['seo']); //Set yes / no + + //Registration & Email Settings + + define('EMAIL_VERIFICATION',$row['email_verification']); + define('ALLOW_REG',$row['allow_registration']); + define('WEBSITE_EMAIL',$row['website_email']); + define('SUPPORT_EMAIL',$row['support_email']); + define('WELCOME_EMAIL',$row['welcome_email']); + @define('VIDEO_REQUIRE_LOGIN',$row['video_require_login']); + define('ACTIVATION',$row['activation']); + define('DATE_FORMAT',"d-m-Y"); + + //Listing Of Videos , Channels + + define('VLISTPP',$row['videos_list_per_page']); //Video List Per page + define('VLISTPT',$row['videos_list_per_tab']); //Video List Per tab + define('CLISTPP',$row['channels_list_per_page']); //Channels List Per page + define('CLISTPT',$row['channels_list_per_tab']); //Chaneels List Per tab + define('GLISTPP',$row['groups_list_per_page']); //Groups List Per page + define('SLISTPP',$row['search_list_per_page']); //Search Results List Per page + define('RVLIST',$row['recently_viewed_limit']); //Search Results List Per page + + //Defining Photo Limits + define('MAINPLIST',$row['photo_main_list']); + define('HOMEPLIST',$row['photo_home_tabs']); + define('SEARCHPLIST',$row['photo_search_result']); + define('CHANNELPLIST',$row['photo_channel_page']); + define('USERPLIST',$row['photo_user_photos']); + define('UFAVPLIST',$row['photo_user_favorites']); + define('OTHERPLIST',$row['photo_other_limit']); + + //Defining Collection Limits + define('COLLPP',$row['collection_per_page']); + define('COLLHP',$row['collection_home_page']); + define('COLLIP',$row['collection_items_page']); + define('COLLSP',$row['collection_search_result']); + define('COLLCP',$row['collection_channel_page']); + define('COLLUCP',$row['collection_user_collections']); + define('COLLUFP',$row['collection_user_favorites']); + + //Video Options + define('VIDEO_COMMENT',$row['video_comments']); + define('VIDEO_RATING',$row['video_rating']); + define('COMMENT_RATING',$row['comment_rating']); + define('VIDEO_DOWNLOAD',$row['video_download']); + define('VIDEO_EMBED',$row['video_embed']); + + + + + + define('TEMPLATEFOLDER','styles'); //Template Folder Name, usually STYLES + define('STYLES_DIR',BASEDIR.'/'.TEMPLATEFOLDER); + +// Define Lang Select & Style Select + + define('ALLOW_LANG_SELECT',$row['allow_language_change']); + define('ALLOW_STYLE_SELECT',$row['allow_template_change']); + + define('FLVPLAYER',$row['player_file']); + define('SUBTITLE',$row['code_dev']); + //Javascript Directory Name + define('ADMINDIR','admin_area'); + define('ADMINBASEDIR',BASEDIR.'/admin_area'); //Admin Accissble Folder + define('ADMIN_BASEURL',BASEURL.'/'.ADMINDIR); + define('MODULEDIR',BASEDIR.'/modules'); //Modules Directory + +//DIRECT PATHS OF VIDEO FILES + define('FILES_DIR',BASEDIR.'/files'); + define('VIDEOS_DIR',FILES_DIR.'/videos'); + define('THUMBS_DIR',FILES_DIR.'/thumbs'); + define('ORIGINAL_DIR',FILES_DIR.'/original'); + define('TEMP_DIR',FILES_DIR.'/temp'); + define('CON_DIR',FILES_DIR.'/conversion_queue'); + define('MASS_UPLOAD_DIR',FILES_DIR.'/mass_uploads'); + define('LOGS_DIR',FILES_DIR.'/logs'); + + define("USER_THUMBS_DIR",BASEDIR.'/images/avatars'); + define("USER_BG_DIR",BASEDIR.'/images/backgrounds'); + + define("ICONS_URL",BASEURL.'/images/icons'); + + define('JS_DIR',BASEDIR.'/js'); + define('JS_URL',BASEURL.'/js'); + +//DIRECT URL OF VIDEO FILES + define('FILES_URL',BASEURL.'/files'); + define('VIDEOS_URL',FILES_URL.'/videos'); + define('THUMBS_URL',FILES_URL.'/thumbs'); + define('ORIGINAL_URL',FILES_URL.'/original'); + define('TEMP_URL',FILES_URL.'/temp'); + define("PLAYER_DIR",BASEDIR.'/player'); + define("PLAYER_URL",BASEURL.'/player'); + + define("USER_THUMBS_URL",BASEURL.'/images/avatars'); + define("USER_BG_URL",BASEURL.'/images/backgrounds'); + + //Required Settings For Video Conversion + + define('VBRATE', $row['vbrate']); + define('SRATE', $row['srate']); + define('SBRATE', $row['sbrate']); + define('R_HEIGHT', $row['r_height']); + define('R_WIDTH', $row['r_width']); + define('RESIZE', $row['resize']); + define('KEEP_ORIGINAL', $row['keep_original']); + define('MAX_UPLOAD_SIZE', $row['max_upload_size']); + define('THUMB_HEIGHT', $row['thumb_height']); + define('THUMB_WIDTH', $row['thumb_width']); + define('PHP_PATH', $row['php_path']); + + //Defining Plugin Directory + define('PLUG_DIR',BASEDIR.'/plugins'); + define('PLUG_URL',BASEURL.'/plugins'); + + define('MAX_COMMENT_CHR',$Cbucket->configs['max_comment_chr']); + define('USER_COMMENT_OWN',$Cbucket->configs['user_comment_own']); + + + //Defining Category Thumbs directory + define('CAT_THUMB_DIR',BASEDIR.'/images/category_thumbs'); + define('CAT_THUMB_URL',BASEURL.'/images/category_thumbs'); + + //Defining Group Thumbs directory + define('GP_THUMB_DIR',BASEDIR.'/images/groups_thumbs'); + define('GP_THUMB_URL',BASEURL.'/images/groups_thumbs'); + + //TOPIC ICON DIR + define('TOPIC_ICON_DIR',BASEDIR.'/images/icons/topic_icons'); + define('TOPIC_ICON_URL',BASEURL.'/images/icons/topic_icons'); + + //COLLECTIONS ICON DIR + define('COLLECT_THUMBS_DIR',BASEDIR.'/images/collection_thumbs'); + define('COLLECT_THUMBS_URL',BASEURL.'/images/collection_thumbs'); + + //PHOTOS DETAILS + define('PHOTOS_DIR',FILES_DIR."/photos"); + define('PHOTOS_URL',FILES_URL."/photos"); + + //ADVANCE CACHING + define('CACHE_DIR',BASEDIR.'/cache'); + define('COMM_CACHE_DIR',CACHE_DIR.'/comments'); + define('COMM_CACHE_TIME',1000) ; //in seconds + + //User Feeds + define("USER_FEEDS_DIR",CACHE_DIR.'/userfeeds'); + + //Number of activity feeds to display on channel page + define("USER_ACTIVITY_FEEDS_LIMIT",15); + + //SETTING PHOTO SETTING + $cbphoto->thumb_width = $row['photo_thumb_width']; + $cbphoto->thumb_height = $row['photo_thumb_height']; + $cbphoto->mid_width = $row['photo_med_width']; + $cbphoto->mid_height = $row['photo_med_height']; + $cbphoto->lar_width = $row['photo_lar_width']; + $cbphoto->cropping = $row['photo_crop']; + $cbphoto->position = $row['watermark_placement']; + + //Enable youtube videos + define("YOUTUBE_ENABLED",$row['youtube_enabled']); + + define("EMBED_VDO_WIDTH",$row['embed_player_width']); + define("EMBED_VDO_HEIGHT",$row['embed_player_height']); + + + include 'plugin.functions.php'; + include 'plugins_functions.php'; + require BASEDIR.'/includes/templatelib/Template.class.php'; + require BASEDIR.'/includes/classes/template.class.php'; + require BASEDIR.'/includes/classes/objects.class.php'; + + require BASEDIR.'/includes/active.php'; + + $cbtpl = new CBTemplate(); + $cbobjects = new CBObjects(); + $swfobj = new SWFObject(); + //Initializng Userquery class + $userquery->init(); + $cbvideo->init(); + $cbpm->init(); + $cbphoto->init_photos(); + $thisurl = curPageURL(); + //Setting Up Group Class + $cbgroup->gp_thumb_width = config('grp_thumb_width'); + $cbgroup->gp_thumb_height = config('grp_thumb_height'); + + Assign('THIS_URL', $thisurl); + + define("ALLOWED_GROUP_CATEGORIES",$row['grp_categories']); + define('ALLOWED_VDO_CATS',$row['video_categories']); + define('ALLOWED_CATEGORIES',3); + + if($Cbucket->LatestAdminMenu()) + $Cbucket->AdminMenu = array_merge($Cbucket->LatestAdminMenu(),$Cbucket->AdminMenu); + + //Assigning Smarty Tags & Values + Assign('CB_VERSION',CB_VERSION); + Assign('FFMPEG_FLVTOOLS_BINARY',FFMPEG_FLVTOOLS_BINARY); + Assign('FFMPEG_MPLAYER_BINARY',FFMPEG_MPLAYER_BINARY); + Assign('PHP_PATH',PHP_PATH); + Assign('FFMPEG_BINARY',FFMPEG_BINARY); + Assign('FFMPEG_MENCODER_BINARY',FFMPEG_MENCODER_BINARY); + Assign('js',JS_URL); + Assign('title',TITLE); + Assign('slogan',SLOGAN); + Assign('flvplayer',FLVPLAYER); + Assign('avatardir',BASEURL.'/images/avatars'); + Assign('whatis',$row['whatis']); + Assign('category_thumbs',CAT_THUMB_URL); + Assign('gp_thumbs_url',GP_THUMB_URL); + Assign('video_thumbs',THUMBS_URL); + //Assign('ads',$ads); + + Assign('email_verification',EMAIL_VERIFICATION); + Assign('group_thumb',BASEURL.'/images/groups_thumbs'); + Assign('bg_dir',BASEURL.'/images/backgrounds'); + Assign('captcha_type',$row['captcha_type']); + Assign('languages',$languages); + + Assign('module_dir',MODULEDIR); + + Assign('VIDEOS_URL',VIDEOS_URL); + Assign('THUMBS_URL',THUMBS_URL); + Assign('PLUG_URL',BASEURL.'/plugins'); + +//Remote and Embed + Assign('remoteUpload',$row['remoteUpload']); + Assign('embedUpload',$row['embedUpload']); + +//Video Options + Assign('video_comment',$row['video_comments']); + Assign('video_rating',$row['video_rating']); + Assign('comment_rating',$row['comment_rating']); + Assign('video_download',$row['video_download']); + Assign('video_embed',$row['video_embed']); + + assign('icons_url',ICONS_URL); + + + + + $ClipBucket->upload_opt_list = array + ( + 'file_upload_div' => array( + 'title' => lang('upload_file'), + 'func_class' => 'Upload', + 'load_func' => 'load_upload_form', + ), + 'remote_upload_div' => array( + 'title' => lang('remote_upload'), + 'func_class' => 'Upload', + 'load_func' => 'load_remote_upload_form', + ) + ); + Assign('LANG',$LANG); + Assign('langf',LANG); + Assign('lang_count',count($languages)); + + +//Assign Player Div Id + Assign('player_div_id',$row['player_div_id']); + +//Asigning Page + Assign('page',PAGE); + +//Add Modules +require('modules.php'); + + +//Checking Website Template +$Cbucket->set_the_template(); + +/* +REGISTER OBJECTS FOR SMARTY +*/ + +$Smarty->assign_by_ref('pages', $pages); +$Smarty->assign_by_ref('myquery', $myquery); +$Smarty->assign_by_ref('userquery', $userquery); +$Smarty->assign_by_ref('signup', $signup); +$Smarty->assign_by_ref('Upload', $Upload); +$Smarty->assign_by_ref('cbgroup', $cbgroup); +$Smarty->assign_by_ref('db', $db); +$Smarty->assign_by_ref('adsObj', $adsObj); +$Smarty->assign_by_ref('formObj', $formObj); +$Smarty->assign_by_ref('Cbucket', $Cbucket);$Smarty->assign_by_ref('ClipBucket', $Cbucket); +$Smarty->assign_by_ref('eh', $eh); +$Smarty->assign_by_ref('lang_obj', $lang_obj); +$Smarty->assign_by_ref('cbvid', $cbvid); +$Smarty->assign_by_ref('cbtpl',$cbtpl); +$Smarty->assign_by_ref('cbobjects',$cbobjects); +$Smarty->assign_by_ref('cbplayer',$cbplayer); +$Smarty->assign_by_ref('cbsearch',$cbsearch); +$Smarty->assign_by_ref('cbpm',$cbpm); +$Smarty->assign_by_ref('cbpage',$cbpage); +$Smarty->assign_by_ref('cbemail',$cbemail); +$Smarty->assign_by_ref('cbcollection',$cbcollection); +$Smarty->assign_by_ref('cbphoto',$cbphoto); +$Smarty->assign_by_ref('cbfeeds',$cbfeeds); +//$Smarty->assign_by_ref('cbmenu',$cbmenu); +/* +REGISERTING FUNCTION FOR SMARTY TEMPLATES +*/ + + +function show_video_rating($params){ global $cbvid; return $cbvid->show_video_rating($params); } + +$Smarty->register_function('AD','getAd'); +$Smarty->register_function('get_thumb','getSmartyThumb'); +$Smarty->register_function('getThumb','getSmartyThumb'); +$Smarty->register_function('videoLink','videoSmartyLink'); +$Smarty->register_function('group_link','group_link'); +$Smarty->register_function('show_rating','show_rating'); +$Smarty->register_function('ANCHOR','ANCHOR'); +$Smarty->register_function('FUNC','FUNC'); +$Smarty->register_function('avatar','avatar'); +$Smarty->register_function('load_form','load_form'); +$Smarty->register_function('get_all_video_files',get_all_video_files_smarty); +$Smarty->register_function('input_value','input_value'); +$Smarty->register_function('userid','userid'); +$Smarty->register_function('FlashPlayer','flashPlayer'); +$Smarty->register_function('HQFlashPlayer','HQflashPlayer'); +$Smarty->register_function('link','cblink'); +$Smarty->register_function('show_share_form','show_share_form'); +$Smarty->register_function('show_flag_form','show_flag_form'); +$Smarty->register_function('show_playlist_form','show_playlist_form'); +$Smarty->register_function('show_collection_form','show_collection_form'); +$Smarty->register_function('lang','smarty_lang'); +$Smarty->register_function('get_videos','get_videos'); +$Smarty->register_function('get_users','get_users'); +$Smarty->register_function('get_groups','get_groups'); +$Smarty->register_function('get_photos','get_photos'); +$Smarty->register_function('get_collections','get_collections'); +$Smarty->register_function('private_message','private_message'); +$Smarty->register_function('show_video_rating','show_video_rating'); +$Smarty->register_function('load_captcha','load_captcha'); +$Smarty->register_function('cbtitle','cbtitle'); +$Smarty->register_function('head_menu','head_menu'); +$Smarty->register_function('foot_menu','foot_menu'); +$Smarty->register_function('include_header','include_header'); +$Smarty->register_function('include_template_file','include_template_file'); +$Smarty->register_function('include_js','include_js'); +$Smarty->register_function('get_binaries','get_binaries'); +$Smarty->register_function('check_module_path','check_module_path'); +$Smarty->register_function('rss_feeds','rss_feeds'); +$Smarty->register_function('website_logo','website_logo'); +$Smarty->register_function('get_photo','get_photo'); +$Smarty->register_function('uploadButton','upload_photo_button'); +$Smarty->register_function('embedCodes','photo_embed_codes'); +$Smarty->register_function('DownloadButtonP','photo_download_button'); +$Smarty->register_function('loadPhotoUploadForm','loadPhotoUploadForm'); +$Smarty->register_function('cbCategories','getSmartyCategoryList'); +$Smarty->register_function('getComments','getSmartyComments'); +$Smarty->register_function('fb_embed_video','fb_embed_video'); +$Smarty->register_function('cbMenu','cbMenu'); + +$Smarty->register_function('makeGroupAdmin','makeGroupAdmin'); +$Smarty->register_function('removeGroupAdmin','removeGroupAdmin'); +$Smarty->register_function('isGroupAdmin','isGroupAdmin'); + +$Smarty->register_modifier('SetTime','SetTime'); +$Smarty->register_modifier('getname','getname'); +$Smarty->register_modifier('getext','getext'); +$Smarty->register_modifier('form_val','form_val'); +$Smarty->register_modifier('get_from_val','get_from_val'); +$Smarty->register_modifier('post_form_val','post_form_val'); +$Smarty->register_modifier('request_form_val','request_form_val'); +$Smarty->register_modifier('get_thumb_num','get_thumb_num'); +$Smarty->register_modifier('ad','ad'); +$Smarty->register_modifier('get_user_level','get_user_level'); +$Smarty->register_modifier('is_online','is_online'); +$Smarty->register_modifier('get_age','get_age'); +$Smarty->register_modifier('outgoing_link','outgoing_link'); +$Smarty->register_modifier('nicetime','nicetime'); +$Smarty->register_modifier('country','get_country'); +$Smarty->register_modifier('cbsearch',new cbsearch()); +$Smarty->register_modifier('flag_type','flag_type'); +$Smarty->register_modifier('get_username','get_username'); +$Smarty->register_modifier('formatfilesize','formatfilesize'); +$Smarty->register_modifier('getWidth','getWidth'); +$Smarty->register_modifier('getHeight','getHeight'); +$Smarty->register_modifier('get_collection_name','get_collection_name'); +$Smarty->register_modifier('json_decode','jd'); +$Smarty->register_modifier('getGroupPrivacy','getGroupPrivacy'); + +assign('updateEmbedCode','updateEmbed'); +/* + * Registering Video Remove Functions + */ +register_action_remove_video('remove_video_thumbs'); +register_action_remove_video('remove_video_log'); +register_action_remove_video('remove_video_files'); + + +include('admin.functions.php'); +//error_reporting(E_ALL ^E_NOTICE ^E_DEPRECATED); + + +////Removing www. as it effects SEO and updating Config +//$wwwcheck = preg_match('/:\/\/www\./',$baseurl,$matches); +//if(count($matches)>0) +//{ +// $baseurl = preg_replace('/:\/\/www\./','://',$baseurl); +// $myquery->Set_Website_Details('baseurl',$baseurl); +//} + + //Other settings + define("SEND_COMMENT_NOTIFICATION",config("send_comment_notification")); + define("SEND_VID_APPROVE_EMAIL",config("approve_video_notification")); + + + +?> \ No newline at end of file diff --git a/upload/includes/config.inc.php b/upload/includes/config.inc.php new file mode 100644 index 00000000..b68ce694 --- /dev/null +++ b/upload/includes/config.inc.php @@ -0,0 +1,59 @@ +template); +define('TEMPLATEURL',BASEURL.'/'.TEMPLATEFOLDER.'/'.$Cbucket->template); +define('LAYOUT',TEMPLATEDIR.'/layout'); +define('ADMINLAYOUT',BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/'.$Cbucket->template.'/layout'); + +Assign('baseurl',BASEURL); +Assign('imageurl',TEMPLATEURL.'/images'); +Assign('admimageurl',BASEURL.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/'.$Cbucket->template.'/images'); +Assign('layout',TEMPLATEURL.'/layout'); +Assign('theme',TEMPLATEURL.'/theme'); +Assign('admtheme',BASEURL.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/'.$Cbucket->template.'/theme'); +Assign('template_dir',TEMPLATEDIR); +Assign('style_dir',LAYOUT); + + + + +//Assigning JS Files +Assign('jsArray',$Cbucket->JSArray); +//Assigning Module Files +Assign('module_list',$Cbucket->moduleList); + + +//Checking Website is closed or not +if(config('closed') && THIS_PAGE!='ajax' && !$in_bg_cron && THIS_PAGE!='cb_install') +{ + + if(!has_access("admin_access",TRUE)) + { e($row['closed_msg'],"w"); + template("global_header.html"); + template("message.html"); + exit(); + }else{ + e(lang("ATTENTION: THIS WEBSITE IS IN OFFLINE MODE"),"w"); + } +} + +//Configuring Uploader +uploaderDetails(); +isSectionEnabled(PARENT_PAGE,true); + +//setting quicklist +assign('total_quicklist',$cbvid->total_quicklist()); + +?> \ No newline at end of file diff --git a/upload/includes/configs/index.php b/upload/includes/configs/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/configs/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/conversion.conf.php b/upload/includes/conversion.conf.php new file mode 100644 index 00000000..628e9964 --- /dev/null +++ b/upload/includes/conversion.conf.php @@ -0,0 +1,172 @@ +Get_Website_Details(); + $email_data = $myquery->Get_Email_Settings(); + $ads = $myquery->Get_Advertisments(); + +//Website Details + + define('TITLE',$row['site_title']); + define('SLOGAN',$row['site_slogan']); + + //Seo URLS + + define('SEO',$row['seo']); //Set yes / no + + //Required Modules and Their Paths (Editable In Admin Panel) + + define('FFMPEG_BINARY', $row['ffmpegpath']); + define('FFMPEG_FLVTOOLS_BINARY', $row['flvpath']); + define('FFMPEG_MENCODER_BINARY', $row['mencoderpath']); + define('FFMPEG_MPLAYER_BINARY', $row['mplayerpath']); + define('PHP_PATH', $row['php_path']); + + //Registration & Email Settings + + define('EMAIL_VERIFICATION',$row['email_verification']); + define('ALLOW_REGISTERATION',$row['allow_registration']); + define('WEBSITE_EMAIL',$email_data['website_email']); + define('SUPPORT_EMAIL',$email_data['support_email']); + define('WELCOME_EMAIL',$email_data['welcome_email']); + define('VIDEO_REQUIRE_LOGIN',@$row['video_require_login']); + define('ACTIVATION',$row['activation']); + + //Listing Of Videos , Channels + + define('VLISTPP',$row['videos_list_per_page']); //Video List Per page + define('VLISTPT',$row['videos_list_per_tab']); //Video List Per tab + define('CLISTPP',$row['channels_list_per_page']); //Channels List Per page + define('CLISTPT',$row['channels_list_per_tab']); //Chaneels List Per tab + define('GLISTPP',$row['groups_list_per_page']); //Groups List Per page + + //Video Options + + define('VIDEO_COMMENT',$row['video_comments']); + define('VIDEO_RATING',$row['video_rating']); + define('COMMENT_RATING',$row['comment_rating']); + define('VIDEO_DOWNLOAD',$row['video_download']); + define('VIDEO_EMBED',$row['video_embed']); + + //Required Settings For Video Conversion + + define('VBRATE', $row['vbrate']); + define('SRATE', $row['srate']); + define('SBRATE', $row['sbrate']); + define('R_HEIGHT', $row['r_height']); + define('R_WIDTH', $row['r_width']); + define('RESIZE', $row['resize']); + define('KEEP_ORIGINAL', $row['keep_original']); + define('MAX_UPLOAD_SIZE', $row['max_upload_size']); + define('THUMB_HEIGHT', $row['thumb_height']); + define('THUMB_WIDTH', $row['thumb_width']); + define('FFMPEG_TYPE', $row['ffmpeg_type']); + if(FFMPEG_TYPE == 's'){ + define('FFMPEG_BINARY', MODULEDIR.'/encoders/ffmpeg'); + }else{ + define('FFMPEG_BINARY', $row['ffmpegpath']); + } + define('FFMPEG_FLVTOOLS_BINARY', $row['flvpath']); + define('PHP_PATH', $row['php_path']); + define('FFMPEG_MENCODER_BINARY', $row['mencoderpath']); + define('FFMPEG_MPLAYER_BINARY', $row['mplayerpath']); + + //Required Paths Relative and Direct (Editable In Admin Panel) + + if(is_dir($row['basedir'])){ + define('BASEDIR',$row['basedir']); + }else{ + define('BASEDIR',dirname(__FILE__).'/..'); + } + define('BASEURL',$row['baseurl']); //Direct Path To Script ie http://yourwebsite.com/subdir + + define('TEMPLATEFOLDER','styles'); //Template Folder Name, usually STYLES + define('TEMPLATE',$row['template_dir']); //Select Any Template Name, usually 'clipbucketblue' + define('FLVPLAYER',$row['player_file']); //Select FLV Player For Your Script + define('JSDIR','js'); //Javascript Directory Name + define('ADMINDIR','admin_area'); //Admin Accissble Folder + define('MODULEDIR',BASEDIR.'/modules'); //Modules Directory + + //DIRECT PATHS OF VIDEO FILES + define('FILES_DIR',BASEDIR.'/files'); + define('VIDEOS_DIR',FILES_DIR.'/videos'); + define('THUMBS_DIR',FILES_DIR.'/thumbs'); + define('ORIGINAL_DIR',FILES_DIR.'/original'); + define('TEMP_DIR',FILES_DIR.'/temp'); + + //DIRECT URL OF VIDEO FILES + define('FILES_URL',BASEURL.'/files'); + define('VIDEOS_URL',FILES_URL.'/videos'); + define('THUMBS_URL',FILES_URL.'/thumbs'); + define('ORIGINAL_URL',FILES_URL.'/original'); + define('TEMP_URL',FILES_URL.'/temp'); + + //Do No Edit Below This Line + + define('TEMPLATEDIR',BASEDIR.'/'.TEMPLATEFOLDER.'/'.TEMPLATE); + define('TEMPLATEURL',BASEURL.'/'.TEMPLATEFOLDER.'/'.TEMPLATE); + define('LAYOUT',TEMPLATEDIR.'/layout'); + define('ADMINLAYOUT',BASEDIR.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/'.TEMPLATE.'/layout'); + + //Assigning Smarty Tags & Values + + require BASEDIR.'/includes/templatelib/Template.class.php'; + require BASEDIR.'/includes/classes/template.class.php'; + require BASEDIR.'/includes/classes/TConfig.php'; + require BASEDIR.'/includes/classes/TError.php'; + require BASEDIR.'/includes/active.php'; + require BASEDIR.'/includes/defined_links.php'; + + $SYSTEM_OS = $row['sys_os'] ? $row['sys_os'] : 'linux'; + + //Including FFMPEG CLASS + if($SYSTEM_OS=='linux') + { + if($row['con_modules_type'] == 0){ + require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.class.php'); + }else{ + require_once(BASEDIR.'/includes/classes/conversion/multi.class.php'); + } + }else{ + require_once(BASEDIR.'/includes/classes/conversion/ffmpeg.win32.php'); + } + +?> \ No newline at end of file diff --git a/upload/includes/dbconnect.php b/upload/includes/dbconnect.php new file mode 100644 index 00000000..728bd1de --- /dev/null +++ b/upload/includes/dbconnect.php @@ -0,0 +1,40 @@ +debug = false; + $db->charpage = 'cp_utf8'; + $db->charset = 'utf8'; + if(!$db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME)) + { + exit($db->ErrorMsg()); + } + $db->Connect($DBHOST, $DBUSER, $DBPASS, $DBNAME); + + + $db->SetFetchMode(ADODB_FETCH_ASSOC); + + $db->Execute('SET NAMES utf8'); + $db->Execute('SET CHARACTER SET utf8'); + $db->Execute('SET COLLATION_CONNECTION="utf8_general_ci"'); + +?> \ No newline at end of file diff --git a/upload/includes/define_php_links.php b/upload/includes/define_php_links.php new file mode 100644 index 00000000..b52440fe --- /dev/null +++ b/upload/includes/define_php_links.php @@ -0,0 +1,67 @@ +','?','[',']','\\',';','"',',','.','/','*','+','~','`','=',"'"); + $entities_replace = array('','','','','','','','','','','','','','','','','','','','','','','',''); + $clean_text = str_replace($entities_match, $entities_replace, $text); + $clean_text = trim($clean_text); + $clean_text = preg_replace('/ /','-',$clean_text); + if ( $clean_text != '' ) + $slash = ( $slash ) ? '/' : NULL; + + + $clean_text = preg_replace('/\-{2,10}/','-',$clean_text); + + return $slash . $clean_text; +} + + if($seo_urls == 'yes'){ + + + + @define(compose_msg_link,'/message/compose'); + @define(login_success,'/login/success'); + @define(logout_success,'/logout/success'); + @define(signup_success,'/signup/success'); + @define(signup_link,'/signup.php'); + @define(myaccount_link,'/myaccount'); + @define(videos_link,'/videos'); + @define(view_group_link,'/group/view/'); + @define(user_account_link,'/manage/account'); + @define(search_result,'/search/result'); + //@define(edit_group_link,'/manage/group/edit/'); + @define(edit_group_link,'/edit_group.php?url='); + @define(admin_link,'/admin_area/'); + + + + }else{ + + @define(compose_msg_link,'/compose.php'); + @define(login_success,'/login_success.php'); + @define(logout_success,'/logout_success.php'); + @define(signup_success,'/signup_success.php'); + @define(signup_link,'/signup.php'); + @define(myaccount_link,'/myaccount.php'); + @define(videos_link,'/videos.php'); + @define(view_group_link,'/view_group.php?url='); + @define(user_account_link,'/user_account.php'); + @define(search_result,'/search_result.php'); + @define(edit_group_link,'/edit_group.php?url='); + @define(admin_link,'/admin_area/'); + + } +?> \ No newline at end of file diff --git a/upload/includes/defined_links.php b/upload/includes/defined_links.php new file mode 100644 index 00000000..a66a2b85 --- /dev/null +++ b/upload/includes/defined_links.php @@ -0,0 +1,78 @@ + Array([Non SEO Link], [SEO Link])) - Without BASEURL + */ + + +$cbLinks = array +( +'channels' =>array('channels.php','channels/'), +'compose_new' =>array('private_message.php?mode=new_msg','private_message.php?mode=new_msg'), +'contact_us' =>array('contact.php','contact'), +'create_group' =>array('create_group.php','create_group'), +'groups' =>array('groups.php','groups/'), +'inbox' =>array('private_message.php?mode=inbox','private_message.php?mode=inbox'), +'login' =>array('signup.php','signup.php'), +'login_success' =>array('login_success.php','login_success.php'), +'logout' =>array('logout.php','logout.php'), +'logout_success'=>array('logout_success.php','logout_success.php'), +'my_account' =>array('myaccount.php','my_account'), +'my_videos' =>array('manage_videos.php','manage_videos.php'), +'my_favorites' =>array('manage_videos.php?mode=favorites','manage_videos.php?mode=favorites'), +'my_playlists' =>array('manage_playlists.php','manage_playlists.php'), +'my_contacts' =>array('manage_contacts.php','manage_contacts.php'), +'notifications' =>array('private_message.php?mode=notification','private_message.php?mode=notification'), +'rss' =>array("rss.php?mode=","rss/"), +'search_result' =>array('search_result.php','search_result.php'), +'signup' =>array('signup.php','signup'), +'upload' =>array('upload.php','upload'), +'user_contacts' =>array('user_contacts.php?user=','user_contacts.php?user='), +'user_subscriptions' =>array('user_contacts.php?mode=subscriptions&user=','user_contacts.php?mode=subscriptions&user='), +'user_subscribers' =>array('user_contacts.php?mode=subscribers&user=','user_contacts.php?mode=subscribers&user='), +'user_favorites'=>array('user_videos.php?mode=favorites&user=','user_videos.php?mode=favorites&user='), +'user_videos' =>array('user_videos.php?user=','user_videos.php?user='), +'videos' =>array('videos.php','videos/'), + +); + +if(is_array($Cbucket->links)) + $Cbucket->links = array_merge($Cbucket->links,$cbLinks); + +/** + * Sortings + */ +function sorting_links() +{ + if(!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + if(!isset($_GET['time'])) + $_GET['time'] = 'all_time'; + + $array = array + ('most_recent' => lang('recent'), + 'most_viewed' => lang('viewed'), + 'featured' => lang('featured'), + 'top_rated' => lang('top_rated'), + 'most_commented' => lang('commented'), + ); + return $array; +} + +function time_links() +{ + $array = array + ('all_time' => lang('alltime'), + 'today' => lang('today'), + 'yesterday' => lang('yesterday'), + 'this_week' => lang('thisweek'), + 'last_week' => lang('lastweek'), + 'this_month' => lang('thismonth'), + 'last_month' => lang('lastmonth'), + 'this_year' => lang('thisyear'), + 'last_year' => lang('lastyear'), + ); + return $array; +} +?> \ No newline at end of file diff --git a/upload/includes/email_templates/activation_request.header.php b/upload/includes/email_templates/activation_request.header.php new file mode 100644 index 00000000..df512419 --- /dev/null +++ b/upload/includes/email_templates/activation_request.header.php @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/upload/includes/email_templates/activation_request.template.php b/upload/includes/email_templates/activation_request.template.php new file mode 100644 index 00000000..43f0c97c --- /dev/null +++ b/upload/includes/email_templates/activation_request.template.php @@ -0,0 +1,14 @@ + + Click Here To Goto Activation Page + +Direct Activation +========================================== +Click Here or Copy & Paste the following link in your browser +$baseurl/activation.php?username=$username&avcode=$avcode +" + ?> + \ No newline at end of file diff --git a/upload/includes/email_templates/email_verify.header.php b/upload/includes/email_templates/email_verify.header.php new file mode 100644 index 00000000..84c553f2 --- /dev/null +++ b/upload/includes/email_templates/email_verify.header.php @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/upload/includes/email_templates/email_verify.template.php b/upload/includes/email_templates/email_verify.template.php new file mode 100644 index 00000000..f5107e99 --- /dev/null +++ b/upload/includes/email_templates/email_verify.template.php @@ -0,0 +1,21 @@ + + Click Here + +$baseurl/activation.php?username=$username&avcode=$avcode + +==================== +Regards +$title" + ?> + \ No newline at end of file diff --git a/upload/includes/email_templates/index.php b/upload/includes/email_templates/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/email_templates/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/email_templates/share_video.header.php b/upload/includes/email_templates/share_video.header.php new file mode 100644 index 00000000..63174f80 --- /dev/null +++ b/upload/includes/email_templates/share_video.header.php @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/upload/includes/email_templates/share_video.template.php b/upload/includes/email_templates/share_video.template.php new file mode 100644 index 00000000..95342da5 --- /dev/null +++ b/upload/includes/email_templates/share_video.template.php @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + +
    $titleshare video
    $username wants to share Video With You
    Video Description
    + $videodes
    Personal Message
    + $message +
    +
    +Thanks,
    +$username
    copyrights 2007 $title
    + +" + ?> + \ No newline at end of file diff --git a/upload/includes/email_templates/template_writer.php b/upload/includes/email_templates/template_writer.php new file mode 100644 index 00000000..8c7929f6 --- /dev/null +++ b/upload/includes/email_templates/template_writer.php @@ -0,0 +1,105 @@ +Get_Email_Settings(); + $email_verify = $email_data['email_verification_template']; + $fp = fopen(BASEDIR."/includes/email_templates/email_verify.template.php", "w"); + fwrite($fp, ' + + '); + $email_header = $myquery->Get_Email_Settings_headers(); + $email_verify_header = $email_header['email_verification_template']; + $fp = fopen(BASEDIR."/includes/email_templates/email_verify.header.php", "w"); + fwrite($fp, ' + + '); + } + + //This Function Is Used To Write Welcome Message Template + function WriteWelcomeMessage(){ + $myquery = new myquery(); + $email_data = $myquery->Get_Email_Settings(); + $email_verify = $email_data['welcome_message_template']; + $fp = fopen(BASEDIR."/includes/email_templates/welcome_message.template.php", "w"); + fwrite($fp, ' + + '); + + $email_header = $myquery->Get_Email_Settings_headers(); + $email_verify_header = $email_header['welcome_message_template']; + $fp = fopen(BASEDIR."/includes/email_templates/welcome_message.header.php", "w"); + fwrite($fp, ' + + '); + } + + //This Function Is Used To Write Welcome Message Template + function WriteActvationRequest(){ + $myquery = new myquery(); + $email_data = $myquery->Get_Email_Settings(); + $email_verify = $email_data['activate_request_template']; + $fp = fopen(BASEDIR."/includes/email_templates/activation_request.template.php", "w"); + fwrite($fp, ' + + '); + + $email_header = $myquery->Get_Email_Settings_headers(); + $email_verify_header = $email_header['activate_request_template']; + $fp = fopen(BASEDIR."/includes/email_templates/activation_request.header.php", "w"); + fwrite($fp, ' + + '); + } + + //This Function Is Used To Write Share Video Template + function WriteShareVideo(){ + $myquery = new myquery(); + $email_data = $myquery->Get_Email_Settings(); + $email_verify = $email_data['share_video_template']; + $fp = fopen(BASEDIR."/includes/email_templates/share_video.template.php", "w"); + fwrite($fp, ' + + '); + + $email_header = $myquery->Get_Email_Settings_headers(); + $email_verify_header = $email_header['share_video_template']; + $fp = fopen(BASEDIR."/includes/email_templates/share_video.header.php", "w"); + fwrite($fp, ' + + '); + } + +?> \ No newline at end of file diff --git a/upload/includes/email_templates/welcome_message.header.php b/upload/includes/email_templates/welcome_message.header.php new file mode 100644 index 00000000..79af96f1 --- /dev/null +++ b/upload/includes/email_templates/welcome_message.header.php @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/upload/includes/email_templates/welcome_message.template.php b/upload/includes/email_templates/welcome_message.template.php new file mode 100644 index 00000000..9923bd53 --- /dev/null +++ b/upload/includes/email_templates/welcome_message.template.php @@ -0,0 +1,17 @@ + + Upload Videos +-> Share Videos +-> Make Friends and Send Messages +-> Now You Have Your Own Channel + +To Access Your Account Please Click Here and login + +Thank You For Joining Us, +Regards +$title Team" + ?> + \ No newline at end of file diff --git a/upload/includes/email_templates/welcome_messege.header.php b/upload/includes/email_templates/welcome_messege.header.php new file mode 100644 index 00000000..79af96f1 --- /dev/null +++ b/upload/includes/email_templates/welcome_messege.header.php @@ -0,0 +1,5 @@ + + + \ No newline at end of file diff --git a/upload/includes/email_templates/welcome_messege.template.php b/upload/includes/email_templates/welcome_messege.template.php new file mode 100644 index 00000000..bef68e43 --- /dev/null +++ b/upload/includes/email_templates/welcome_messege.template.php @@ -0,0 +1,17 @@ + + Upload Videos +-> Share Videos +-> Make Friends and Send Messeges +-> Now You Have Your Own Channel + +To Access Your Account Please Click Here and login + +Thank You For Joining Us, +Regards +$title Team" + ?> + \ No newline at end of file diff --git a/upload/includes/flv_player.php b/upload/includes/flv_player.php new file mode 100644 index 00000000..61c5d9f7 --- /dev/null +++ b/upload/includes/flv_player.php @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/upload/includes/functions.php b/upload/includes/functions.php new file mode 100644 index 00000000..49da47f3 --- /dev/null +++ b/upload/includes/functions.php @@ -0,0 +1,5938 @@ +true,'mysql_clean'=>false)) + { + if($array['no_html']) + $string = htmlentities($string); + if($array['special_html']) + $string = htmlspecialchars($string); + if($array['mysql_clean']) + $string = mysql_real_escape_string($string); + if($array['nl2br']) + $string = nl2br($string); + return $string; + } + + //This Fucntion is for Securing Password, you may change its combination for security reason but make sure dont not rechange once you made your script run + + function pass_code($string) { + $password = md5(md5(sha1(sha1(md5($string))))); + return $password; + } + + //Mysql Clean Queries + function sql_free($id) + { + if (!get_magic_quotes_gpc()) + { + $id = addslashes($id); + } + return $id; + } + + + function mysql_clean($id,$replacer=true){ + //$id = clean($id); + + if (get_magic_quotes_gpc()) + { + $id = stripslashes($id); + } + $id = htmlspecialchars(mysql_real_escape_string($id)); + if($replacer) + $id = Replacer($id); + return $id; + } + + function escape_gpc($in) + { + if (get_magic_quotes_gpc()) + { + $in = stripslashes($in); + } + return $in; + } + + + //Redirect Using JAVASCRIPT + + function redirect_to($url){ + echo ''; + exit("Javascript is turned off, click here to go to requested page"); + } + + //Test function to return template file + function Fetch($name,$inside=FALSE) + { + if($inside) + $file = CBTemplate::fetch($name); + else + $file = CBTemplate::fetch(LAYOUT.'/'.$name); + + return $file; + } + + //Simple Template Displaying Function + + function Template($template,$layout=true){ + global $admin_area; + if($layout) + CBTemplate::display(LAYOUT.'/'.$template); + else + CBTemplate::display($template); + + if($template == 'footer.html' && $admin_area !=TRUE){ + CBTemplate::display(BASEDIR.'/includes/templatelib/'.$template); + } + if($template == 'header.html'){ + CBTemplate::display(BASEDIR.'/includes/templatelib/'.$template); + } + } + + function Assign($name,$value) + { + CBTemplate::assign($name,$value); + } + + //Funtion of Random String + function RandomString($length) + { + $string = md5(microtime()); + $highest_startpoint = 32-$length; + $randomString = substr($string,rand(0,$highest_startpoint),$length); + return $randomString; + + } + + + //This Function Is Used To Display Tags Cloud + function TagClouds($cloudquery) + { + $tags = array(); + $cloud = array(); + $query = mysql_query($cloudquery); + while ($t = mysql_fetch_array($query)) + { + $db = explode(' ', $t[0]); + while (list($key, $value) = each($db)) + { + @$keyword[$value] += 1; + } + } + if (is_array(@$keyword)) + { + $minFont = 11; + $maxFont = 22; + $min = min(array_values($keyword)); + $max = max(array_values($keyword)); + $fix = ($max - $min == 0) ? 1 : $max - $min; + // Display the tags + foreach ($keyword as $tag => $count) + { + $size = $minFont + ($count - $min) * ($maxFont - $minFont) / $fix; + $cloud[] = '' . mysql_clean($tag) . ''; + } + $shown = join("\n", $cloud) . "\n"; + return $shown; + } + } + + + + /** + * Function used to send emails + * @Author : Arslan Hassan + * this is a very basic email function + * you can extend or replace this function easily + * read our docs.clip-bucket.com + */ + function cbmail($array) + { + $func_array = get_functions('email_functions'); + if(is_array($func_array)) + { + foreach($func_array as $func) + { + if(function_exists($func)) + { + return $func($array); + } + } + } + + $content = escape_gpc($array['content']); + $subject = escape_gpc($array['subject']); + $to = $array['to']; + $from = $array['from']; + $to_name = $array['to_name']; + $from_name = $array['from_name']; + + if($array['nl2br']) + $content = nl2br($content); + + # CHecking Content + if(preg_match('//',$content,$matches)) + { + if(empty($matches[1])) + { + $content = wrap_email_content($content); + } + } + $message .= $content; + + //ClipBucket uses PHPMailer for sending emails + include_once("classes/phpmailer/class.phpmailer.php"); + include_once("classes/phpmailer/class.smtp.php"); + + $mail = new PHPMailer(); // defaults to using php "mail()" + + $mail_type = config('mail_type'); + + //---Setting SMTP --- + if($mail_type=='smtp') + { + $mail->IsSMTP(); // telling the class to use SMTP + $mail->Host = config('smtp_host'); // SMTP server + if(config('smtp_auth')=='yes') + $mail->SMTPAuth = true; // enable SMTP authentication + $mail->Port = config('smtp_port'); // set the SMTP port for the GMAIL server + $mail->Username = config('smtp_user'); // SMTP account username + $mail->Password = config('smtp_pass'); // SMTP account password + } + //--- Ending Smtp Settings + + $mail->SetFrom($from, $from_name); + + if(is_array($to)) + { + foreach($to as $name) + { + $mail->AddAddress(strtolower($name), $to_name); + } + } else { + $mail->AddAddress(strtolower($to), $to_name); + } + + $mail->Subject = $subject; + $mail->MsgHTML($message); + + if(!$mail->Send()) + { + e("Mailer Error: " . $mail->ErrorInfo); + return false; + }else + return true; + } + function send_email($from,$to,$subj,$message) + { + return cbmail(array('from'=>$from,'to'=>$to,'subject'=>$subj,'content'=>$message)); + } + + /** + * Function used to wrap email content in + * HTML AND BODY TAGS + */ + function wrap_email_content($content) + { + return ''.$content.''; + } + + /** + * 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 strtolower(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; + } + + //Simple Validation + function isValidText($text){ + $pattern = "^^[_a-z0-9-]+$"; + if (eregi($pattern, $text)){ + return true; + }else { + return false; + } + } + + //Simple Width Fetcher + function getWidth($file) + { + $sizes = getimagesize($file); + if($sizes) + return $sizes[0]; + } + + //Simple Height Fetcher + function getHeight($file) + { + $sizes = getimagesize($file); + if($sizes) + return $sizes[1]; + } + + //Load Photo Upload Form + function loadPhotoUploadForm($params) + { + global $cbphoto; + return $cbphoto->loadUploadForm($params); + } + //Photo File Fetcher + function get_photo($params) + { + global $cbphoto; + return $cbphoto->getFileSmarty($params); + } + + //Photo Upload BUtton + function upload_photo_button($params) + { + global $cbphoto; + return $cbphoto->upload_photo_button($params); + } + + //Photo Embed Cides + function photo_embed_codes($params) + { + global $cbphoto; + return $cbphoto->photo_embed_codes($params); + } + + //Create download button + + function photo_download_button($params) + { + global $cbphoto; + return $cbphoto->download_button($params); + } + + //Function Used To Validate Email + + function isValidEmail($email){ + $pattern = "/[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"; + preg_match($pattern, $email,$matches); + if ($matches[0]!=''){ + return true; + } + else { + if(!DEVELOPMENT_MODE) + return false; + else + return true; + } + } + + + // THIS FUNCTION SETS HTMLSPECIALCHARS_DECODE IF FUNCTION DOESN'T EXIST + // INPUT: $text REPRESENTING THE TEXT TO DECODE + // $ent_quotes (OPTIONAL) REPRESENTING WHETHER TO REPLACE DOUBLE QUOTES, ETC + // OUTPUT: A STRING WITH HTML CHARACTERS DECODED + if(!function_exists('htmlspecialchars_decode')) { + function htmlspecialchars_decode($text, $ent_quotes = "") { + $text = str_replace(""", "\"", $text); + $text = str_replace("'", "'", $text); + $text = str_replace("<", "<", $text); + $text = str_replace(">", ">", $text); + $text = str_replace("&", "&", $text); + return $text; + } + } // END htmlspecialchars() FUNCTION + + //THIS FUNCTION IS USED TO LIST FILE TYPES IN FLASH UPLOAD + //INPUT FILE TYPES + //OUTPUT FILE TYPE IN PROPER FORMAT + function ListFileTypes($types){ + $types_array = preg_replace('/,/',' ',$types); + $types_array = explode(' ',$types_array); + $list = 'Video,'; + for($i=0;$i<=count($types_array);$i++){ + if($types_array[$i]!=''){ + $list .= '*.'.$types_array[$i]; + if($i!=count($types_array))$list .= ';'; + } + } + return $list; + } + + + + + /** + * Get Directory Size - get_video_file($vdata,$no_video,false); + */ + function get_directory_size($path) + { + $totalsize = 0; + $totalcount = 0; + $dircount = 0; + if ($handle = opendir ($path)) + { + while (false !== ($file = readdir($handle))) + { + $nextpath = $path . '/' . $file; + if ($file != '.' && $file != '..' && !is_link ($nextpath)) + { + if (is_dir ($nextpath)) + { + $dircount++; + $result = get_directory_size($nextpath); + $totalsize += $result['size']; + $totalcount += $result['count']; + $dircount += $result['dircount']; + } + elseif (is_file ($nextpath)) + { + $totalsize += filesize ($nextpath); + $totalcount++; + } + } + } + } + closedir ($handle); + $total['size'] = $totalsize; + $total['count'] = $totalcount; + $total['dircount'] = $dircount; + return $total; + } + //FUNCTION USED TO FORMAT FILE SIZE + //INPUT BYTES + //OUTPT MB , Kib + 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 THUMBNAIL + * @param ARRAY video_details, or videoid will also work + */ + + function get_thumb($vdetails,$num='default',$multi=false,$count=false,$return_full_path=true,$return_big=true,$size=false){ + global $db,$Cbucket,$myquery; + $num = $num ? $num : 'default'; + #checking what kind of input we have + if(is_array($vdetails)) + { + if(empty($vdetails['title'])) + { + #check for videoid + if(empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey'])) + { + if($multi) + return $dthumb[0] = default_thumb(); + return default_thumb(); + }else{ + if(!empty($vdetails['videoid'])) + $vid = $vdetails['videoid']; + elseif(!empty($vdetails['vid'])) + $vid = $vdetails['vid']; + elseif(!empty($vdetails['videokey'])) + $vid = $vdetails['videokey']; + else + { + if($multi) + return $dthumb[0] = default_thumb(); + return default_thumb(); + } + } + } + }else{ + if(is_numeric($vdetails)) + $vid = $vdetails; + else + { + if($multi) + return $dthumb[0] = default_thumb(); + return default_thumb(); + } + } + + + #checking if we have vid , so fetch the details + if(!empty($vid)) + $vdetails = $myquery->get_video_details($vid); + + if(empty($vdetails['title'])) + { + if($multi) + return default_thumb(); + return default_thumb(); + } + + #Checking if there is any custom function for + if(count($Cbucket->custom_get_thumb_funcs) > 0) + { + + foreach($Cbucket->custom_get_thumb_funcs as $funcs) + { + + //Merging inputs + $in_array = array( + 'num' => $num, + 'multi' => $multi, + 'count' => $count, + 'return_full_path' => $return_full_path, + 'return_big' => $return_big + ); + if(function_exists($funcs)) + { + $func_returned = $funcs($vdetails,$in_array); + if($func_returned) + return $func_returned; + } + } + } + + #get all possible thumbs of video + if($vdetails['file_name']) + $vid_thumbs = glob(THUMBS_DIR."/".$vdetails['file_name']."*"); + #replace Dir with URL + if(is_array($vid_thumbs)) + foreach($vid_thumbs as $thumb) + { + if(file_exists($thumb) && filesize($thumb)>0) + { + $thumb_parts = explode('/',$thumb); + $thumb_file = $thumb_parts[count($thumb_parts)-1]; + + if(!is_big($thumb_file) || $return_big) + { + if($return_full_path) + $thumbs[] = THUMBS_URL.'/'.$thumb_file; + else + $thumbs[] = $thumb_file; + } + }elseif(file_exists($thumb)) + unlink($thumb); + } + + if(count($thumbs)==0) + { + if($count) + return count($thumbs); + if($multi) + return $dthumb[0] = default_thumb(); + return default_thumb(); + } + else + { + if($multi) + return $thumbs; + if($count) + return count($thumbs); + + //Now checking for thumb + if($num=='default') + { + $num = $vdetails['default_thumb']; + } + if($num=='big' || $size=='big') + { + + $num = 'big-'.$vdetails['default_thumb']; + if(!file_exists(THUMBS_DIR.'/'.$vdetails['file_name'].'-'.$num.'.jpg')) + $num = 'big'; + } + + $default_thumb = array_find($vdetails['file_name'].'-'.$num,$thumbs); + + if(!empty($default_thumb)) + return $default_thumb; + return $thumbs[0]; + } + + } + + /** + * Function used to check weaether given thumb is big or not + */ + function is_big($thumb_file) + { + if(strstr($thumb_file,'big')) + return true; + else + return false; + } + function GetThumb($vdetails,$num='default',$multi=false,$count=false) + { + + return get_thumb($vdetails,$num,$multi,$count); + } + + /** + * function used to get detaulf thumb of ClipBucket + */ + function default_thumb() + { + if(file_exists(TEMPLATEDIR.'/images/thumbs/processing.png')) + { + return TEMPLATEURL.'/images/thumbs/processing.png'; + }elseif(file_exists(TEMPLATEDIR.'/images/thumbs/processing.jpg')) + { + return TEMPLATEURL.'/images/thumbs/processing.jpg'; + }else + return BASEURL.'/files/thumbs/processing.jpg'; + } + + /** + * Function used to check weather give thumb is deafult or not + */ + function is_default_thumb($i) + { + if(getname($i)=='processing.jpg') + return true; + else + return false; + } + + + //TEST EXCEC FUNCTION + function test_exec( $cmd ) + { + echo '
    '; + echo '

    ' . htmlentities( $cmd ) . '

    '; + + if (stristr(PHP_OS, 'WIN')) { + $cmd = $cmd; + }else{ + $cmd = "PATH=\$PATH:/bin:/usr/bin:/usr/local/bin bash -c \"$cmd\""; + } + $data = shell_exec( $cmd ); + if( $data === false ) + echo "

    FAILED: $cmd

    "; + echo '

    ' . htmlentities( $data ) . '

    '; + } + + /** + * Function used to get shell output + */ + function shell_output($cmd) + { + if (stristr(PHP_OS, 'WIN')) { + $cmd = $cmd; + }else{ + $cmd = "PATH=\$PATH:/bin:/usr/bin:/usr/local/bin bash -c \"$cmd\" 2>&1"; + } + $data = shell_exec( $cmd ); + return $data; + } + + /** + * Function used to get video link + * @param ARRAY video details + */ + function video_link($vdetails,$type=NULL) + { + global $myquery; + #checking what kind of input we have + if(is_array($vdetails)) + { + if(empty($vdetails['title'])) + { + #check for videoid + if(empty($vdetails['videoid']) && empty($vdetails['vid']) && empty($vdetails['videokey'])) + { + return BASEURL; + }else{ + if(!empty($vdetails['videoid'])) + $vid = $vdetails['videoid']; + elseif(!empty($vdetails['vid'])) + $vid = $vdetails['vid']; + elseif(!empty($vdetails['videokey'])) + $vid = $vdetails['videokey']; + else + return BASEURL; + } + } + }else{ + if(is_numeric($vdetails)) + $vid = $vdetails; + else + return BASEURL; + } + #checking if we have vid , so fetch the details + if(!empty($vid)) + $vdetails = $myquery->get_video_details($vid); + + //calling for custom video link functions + $functions = cb_get_functions('video_link'); + if($functions) + { + foreach($functions as $func) + { + $array = array('vdetails'=>$vdetails,'type'=>$type); + if(function_exists($func['func'])) + { + $returned = $func['func']($array); + if($returned) + { + $link = $returned; + return $link; + break; + } + } + } + } + + $plist = ""; + if(SEO == 'yes'){ + + if($vdetails['playlist_id']) + $plist = '?&play_list='.$vdetails['playlist_id']; + + switch(config('seo_vido_url')) + { + default: + $link = BASEURL.'/video/'.$vdetails['videokey'].'/'.SEO(clean(str_replace(' ','-',$vdetails['title']))).$plist; + break; + + case 1: + { + $link = BASEURL.'/'.SEO(clean(str_replace(' ','-',$vdetails['title']))).'_v'.$vdetails['videoid'].$plist; + } + break; + + case 2: + { + $link = BASEURL.'/video/'.$vdetails['videoid'].'/'.SEO(clean(str_replace(' ','-',$vdetails['title']))).$plist; + } + break; + + case 3: + { + $link = BASEURL.'/video/'.$vdetails['videoid'].'_'.SEO(clean(str_replace(' ','-',$vdetails['title']))).$plist; + } + break; + } + + + }else{ + if($vdetails['playlist_id']) + $plist = '&play_list='.$vdetails['playlist_id']; + $link = BASEURL.'/watch_video.php?v='.$vdetails['videokey'].$plist; + } + if(!$type || $type=='link') + return $link; + elseif($type=='download') + return BASEURL.'/download.php?v='.$vdetails['videokey']; + } + + + /** + * Function used to tell ClipBucket that it has closed the script + */ + function the_end() + { + if(!$isWorthyBuddy) + { + /* + echo base64_decode("PGgyPklsbGVnYWwgT3BlcmF0aW9uIEZvdW5k"); + echo "- Please VISIT "; + echo base64_decode("PGEgaHJlZj0iaHR0cDovL2NsaXAtYnVja2V0LmNvbS8iPkNsaXBCdWNrZXQ8L2E+"); + echo " for Details"; + */ + + //Dear user, i have spent too much time of my life on developing + //This software and if you want to return me in this way, + //its ok for me, but for those who told you how to do this... + echo ""; + echo 'i dont care if you try to play with my code, but what really pisses me off + is INSULT'; + } + } + + //Function That will use in creating SEO urls + function VideoLink($vdetails,$type=NULL) + { + return video_link($vdetails,$type); + } + + /** + * Group Link + */ + function group_link($params) + { + $grp = $params['details']; + $id = $grp['group_id']; + $name = $grp['group_name']; + $url = $grp['group_url']; + + if($params['type']=='' || $params['type']=='group') + { + if(SEO==yes) + return BASEURL.'/group/'.$url; + else + return BASEURL.'/view_group.php?url='.$url; + } + + if($params['type']=='view_members') + { + return BASEURL.'/view_group_members.php?url='.$url; + if(SEO==yes) + return BASEURL.'/group_members/'.$url; + else + return BASEURL.'/view_group_members.php?url='.$url; + } + + if($params['type']=='view_videos') + { + return BASEURL.'/view_group_videos.php?url='.$url; + if(SEO==yes) + return BASEURL.'/group_videos/'.$url; + else + return BASEURL.'/view_group_videos.php?url='.$url; + } + + if($params['type'] == 'view_topics') + { + if(SEO == "yes") + return BASEURL."/group/".$url."?mode=view_topics"; + else + return BASEURL."/view_group.php?url=".$url."&mode=view_topics"; + } + + if($params['type'] == 'view_report_form') + { + if(SEO == "yes") + return BASEURL."/group/".$url."?mode=view_report_form"; + else + return BASEURL."/view_group.php?url=".$url."&mode=view_report_form"; + } + } + + /** + * FUNCTION USED TO GET COMMENTS + * @param : array(); + */ + function getComments($params=NULL) + { + global $db; + $order = $params['order']; + $limit = $params['limit']; + $type = $params['type']; + $cond = ''; + if(empty($type)) + $type = "v"; + $cond .= tbl("comments.type")." = '".$type."'"; + + if($params['type_id'] && $params['sectionTable']) + { + if($cond != "") + $cond .= " AND "; + $cond .= tbl("comments.type_id")." = ".tbl($params['sectionTable'].".".$params['type_id']); + } + + if($params['cond']) + { + if($cond != "") + $cond .= " AND "; + $cond .= $params['cond']; + } + + if(!$params['count_only']) + $result = $db->select(tbl("comments".($params['sectionTable']?",".$params['sectionTable']:NULL)),"*",$cond,$limit,$order); + + //echo $db->db_query; + if($params['count_only']) + $result = $db->count(tbl("comments"),"*",$cond); + + if($result) + return $result; + else + return false; + } + + function getSmartyComments($params) + { + global $myquery; + $comments = $myquery->getComments($params); + + if($params['assign']) + assign($params['assign'],$comments); + else + return $comments; + } + + /** + * FUNCTION USED TO GET ADVERTISMENT + * @param : array(Ad Code, LIMIT); + */ + function getAd($params) + { + global $adsObj; + $data = ''; + if($params['style'] || $params['class'] || $params['align']) + $data .= '
    '; + $data .= ad($adsObj->getAd($params['place'])); + if($params['style'] || $params['class'] || $params['align']) + $data .= '
    '; + return $data; + } + + /** + * FUNCTION USED TO GET THUMBNAIL, MADE FOR SMARTY + * @ param : array("FLV"); + */ + function getSmartyThumb($params) + { + return get_thumb($params['vdetails'],$params['num'],$params['multi'],$params['count_only'],true,true,$params['size']); + } + + /** + * Function Used to format video duration + * @param : array(videoKey or ID,videok TITLE) + */ + + function videoSmartyLink($params) + { + $link = VideoLink($params['vdetails'],$params['type']); + if(!$params['assign']) + return $link; + else + assign($params['assign'],$link); + } + + /** + * FUNCTION USED TO GET VIDEO RATING IN SMARTY + * @param : array(pullRating($videos[$id]['videoid'],false,false,false,'novote'); + */ + function pullSmartyRating($param) + { + return pullRating($param['id'],$param['show5'],$param['showPerc'],$aram['showVotes'],$param['static']); + } + + /** + * FUNCTION USED TO CLEAN VALUES THAT CAN BE USED IN FORMS + */ + function cleanForm($string) + { + if(is_string($string)) + $string = htmlspecialchars($string); + if(get_magic_quotes_gpc()) + if(!is_array($string)) + $string = stripslashes($string); + return $string; + } + function form_val($string){return cleanForm($string); } + + //Escaping Magic Quotes + + /** + * FUNCTION USED TO MAKE TAGS MORE PERFECT + * @Author : Arslan Hassan + * @param tags text unformatted + * returns tags formatted + */ + function genTags($tags,$sep=',') + { + //Remove fazool spaces + $tags = preg_replace(array('/ ,/','/, /'),',',$tags); + $tags = preg_replace( "`[,]+`" , ",", $tags); + $tag_array = explode($sep,$tags); + foreach($tag_array as $tag) + { + if(isValidtag($tag)) + { + $newTags[] = $tag; + } + + } + //Creating new tag string + if(is_array($newTags)) + $tagString = implode(',',$newTags); + else + $tagString = 'no-tag'; + return $tagString; + } + + /** + * FUNCTION USED TO VALIDATE TAG + * @Author : Arslan Hassan + * @param tag + * return true or false + */ + function isValidtag($tag) + { + $disallow_array = array + ('of','is','no','on','off','a','the','why','how','what','in'); + if(!in_array($tag,$disallow_array) && strlen($tag)>2) + return true; + else + return false; + } + + + /** + * FUNCTION USED TO GET CATEGORY LIST + */ + function getCategoryList($params=false) + { + global $cats; + $cats = ""; + + $type = $params['type']; + switch($type) + { + default: + { + cb_call_functions('categoryListing',$params); + } + break; + + case "video":case "videos": + case "v": + { + global $cbvid; + $cats = $cbvid->cbCategories($params); + } + break; + + case "users":case "user": + case "u": case "channels": case "channels": + { + global $userquery; + $cats = $userquery->cbCategories($params); + } + break; + + case "group":case "groups": + case "g": + { + global $cbgroup; + $cats = $cbgroup->cbCategories($params); + } + break; + + case "collection":case "collections": + case "cl": + { + global $cbcollection; + $cats = $cbcollection->cbCategories($params); + } + break; + } + + return $cats; + } + /*function getCategoryList($type='video',$with_all=false,$return_html=false) + { + $use_subs = config('use_subs'); + + switch ($type) + { + case "video": + default: + { + global $cbvid; + + if($return_html && $use_subs == "1") { + $cats = $cbvid->cb_list_categories($type,$with_all); + } else { + if($with_all) + $all_cat = array(array('category_id'=>'all','category_name'=>'All')); + + $cats = $cbvid->get_categories(); + + if($all_cat && is_array($cats)) + $cats = array_merge($all_cat,$cats); + } + return $cats; + } + break; + case "user": + { + global $userquery; + + + if($return_html && $use_subs == "1") { + $cats = $userquery->cb_list_categories($type,$with_all); + } else { + if($with_all) + $all_cat = array(array('category_id'=>'all','category_name'=>'All')); + + $cats = $userquery->get_categories(); + + if($all_cat && is_array($cats)) + $cats = array_merge($all_cat,$cats); + } + return $cats; + } + break; + + case "group": + case "groups": + { + global $cbgroup; + + + if($return_html && $use_subs == "1") { + $cats = $cbgroup->cb_list_categories($type,$with_all); + } else { + if($with_all) + $all_cat = array(array('category_id'=>'all','category_name'=>'All')); + + $cats = $cbgroup->get_categories(); + + if($all_cat && is_array($cats)) + $cats = array_merge($all_cat,$cats); + } + return $cats; + } + break; + + case "collection": + case "collections": + { + global $cbcollection; + + + if($return_html && $use_subs == "1") { + $cats = $cbcollection->cb_list_categories($type,$with_all); + } else { + if($with_all) + $all_cat = array(array('category_id'=>'all','category_name'=>'All')); + + $cats = $cbcollection->get_categories(); + + if($all_cat && is_array($cats)) + $cats = array_merge($all_cat,$cats); + } + return $cats; + } + break; + } + }*/ + function cb_bottom() + { + //Woops..its gone + } + + + function getSmartyCategoryList($params) + { + return getCategoryList($params); + } + + + //Function used to register function as multiple modifiers + + + + /** + * Function used to insert data in database + * @param : table name + * @param : fields array + * @param : values array + * @param : extra params + */ + function dbInsert($tbl,$flds,$vls,$ep=NULL) + { + global $db ; + $db->insert($tbl,$flds,$vls,$ep); + } + + /** + * Function used to Update data in database + * @param : table name + * @param : fields array + * @param : values array + * @param : Condition params + * @params : Extra params + */ + function dbUpdate($tbl,$flds,$vls,$cond,$ep=NULL) + { + global $db ; + return $db->update($tbl,$flds,$vls,$cond,$ep); + } + + + + /** + * Function used to Delete data in database + * @param : table name + * @param : fields array + * @param : values array + * @params : Extra params + */ + function dbDelete($tbl,$flds,$vls,$ep=NULL) + { + global $db ; + return $db->delete($tbl,$flds,$vls,$ep); + } + + + /** + ** + */ + function cbRocks() + { + define("isCBSecured",TRUE); + //echo cbSecured(CB_SIGN); + } + + /** + * Insert Id + */ + function get_id($code) + { + global $Cbucket; + $id = $Cbucket->ids[$code]; + if(empty($id)) $id = $code; + return $id; + } + + /** + * Set Id + */ + function set_id($code,$id) + { + global $Cbucket; + return $Cbucket->ids[$code]=$id; + } + + + /** + * Function used to select data from database + */ + function dbselect($tbl,$fields='*',$cond=false,$limit=false,$order=false,$p=false) + { + global $db; + return $db->dbselect($tbl,$fields,$cond,$limit,$order,$p); + } + + + + /** + * An easy function for erorrs and messages (e is basically short form of exception) + * I dont want to use the whole Trigger and Exception code, so e pretty works for me :D + * @param TEXT $msg + * @param TYPE $type (e for Error, m for Message + * @param INT $id Any Predefined Message ID + */ + + function e($msg=NULL,$type='e',$id=NULL) + { + global $eh; + if(!empty($msg)) + return $eh->e($msg,$type,$id); + } + + + /** + * Function used to get subscription template + */ + function get_subscription_template() + { + global $LANG; + return lang('user_subscribe_message'); + } + + + /** + * Short form of print_r as pr + */ + function pr($text,$wrap_pre=false) + { + if(!$wrap_pre) + print_r($text); + else + { + echo "
    ";
    +			print_r($text);
    +			echo "
    "; + } + } + + + /** + * This function is used to call function in smarty template + * This wont let you pass parameters to the function, but it will only call it + */ + function FUNC($params) + { + global $Cbucket; + //Function used to call functions by + //{func namefunction_name} + // in smarty + $func=$params['name']; + if(function_exists($func)) + $func(); + } + + /** + * Function used to get userid anywhere + * if there is no user_id it will return false + */ + function user_id() + { + global $userquery; + if($userquery->userid !='' && $userquery->is_login) return $userquery->userid; else false; + } + //replica + function userid(){return user_id();} + + /** + * Function used to get username anywhere + * if there is no usern_name it will return false + */ + function user_name() + { + global $userquery; + if($userquery->user_name) + return $userquery->user_name; + else + return $userquery->get_logged_username(); + } + function username(){return user_name();} + + /** + * Function used to check weather user access or not + */ + function has_access($access,$check_only=TRUE,$verify_logged_user=true) + { + global $userquery; + + return $userquery->login_check($access,$check_only,$verify_logged_user); + } + + /** + * Function used to return mysql time + * @author : Fwhite + */ + function NOW() + { + return date('Y-m-d H:i:s', time()); + } + + + /** + * Function used to get Regular Expression from database + * @param : code + */ + function get_re($code) + { + global $db; + $results = $db->select(tbl("validation_re"),"*"," re_code='$code'"); + if($db->num_rows>0) + { + return $results[0]['re_syntax']; + }else{ + return false; + } + } + function get_regular_expression($code) + { + return get_re($code); + } + + /** + * Function used to check weather input is valid or not + * based on preg_match + */ + function check_re($syntax,$text) + { + preg_match('/'.$syntax.'/i',$text,$matches); + if(!empty($matches[0])) + { + return true; + }else{ + return false; + } + } + function check_regular_expression($code,$text) + { + return check_re($code,$text); + } + + /** + * Function used to check field directly + */ + function validate_field($code,$text) + { + $syntax = get_re($code); + if(empty($syntax)) + return true; + return check_regular_expression($syntax,$text); + } + + function is_valid_syntax($code,$text) + { + if(DEVELOPMENT_MODE && DEV_INGNORE_SYNTAX) + return true; + return validate_field($code,$text); + } + + /** + * Function used to apply function on a value + */ + function is_valid_value($func,$val) + { + if(!function_exists($func)) + return true; + elseif(!$func($val)) + return false; + else + return true; + } + + function apply_func($func,$val) + { + if(is_array($func)) + { + foreach($func as $f) + if(function_exists($f)) + $val = $f($val); + }else{ + $val = $func($val); + } + return $val; + } + + /** + * Function used to validate YES or NO input + */ + function yes_or_no($input,$return=yes) + { + $input = strtolower($input); + if($input!=yes && $input !=no) + return $return; + else + return $input; + } + + /** + * Function used to validate category + * INPUT $cat array + */ + function validate_vid_category($array=NULL) + { + global $myquery,$LANG,$cbvid; + if($array==NULL) + $array = $_POST['category']; + if(count($array)==0) + return false; + else + { + + foreach($array as $arr) + { + if($cbvid->category_exists($arr)) + $new_array[] = $arr; + } + } + if(count($new_array)==0) + { + e(lang('vdo_cat_err3')); + return false; + }elseif(count($new_array)>ALLOWED_VDO_CATS) + { + e(sprintf(lang('vdo_cat_err2'),ALLOWED_VDO_CATS)); + return false; + } + + return true; + } + + /** + * Function used to validate category + * INPUT $cat array + */ + function validate_group_category($array=NULL) + { + global $cbgroup; + return $cbgroup->validate_group_category($array); + } + + /** + * Function used to validate category + * INPUT $cat array + */ + function validate_collection_category($array=NULL) + { + global $cbcollection; + return $cbcollection->validate_collection_category($array); + } + + /** + * Function used to check videokey exists or not + * key_exists + */ + function vkey_exists($key) + { + global $db; + $db->select(tbl("video"),"videokey"," videokey='$key'"); + if($db->num_rows>0) + return true; + else + return false; + } + + /** + * Function used to check file_name exists or not + * as its a unique name so it will not let repost the data + */ + function file_name_exists($name) + { + global $db; + $results = $db->select(tbl("video"),"videoid,file_name"," file_name='$name'"); + + if($db->num_rows >0) + return $results[0]['videoid']; + else + return false; + } + + + + /** + * Function used to get video from conversion queue + */ + function get_queued_video($update=TRUE,$fileName=NULL) + { + global $db; + $max_conversion = config('max_conversion'); + $max_conversion = $max_conversion ? $max_conversion : 2; + $max_time_wait = config('max_time_wait'); //Maximum Time Wait to make PRocessing Video Automatcially OK + $max_time_wait = $max_time_wait ? $max_time_wait : 7200; + + //First Check How Many Videos Are In Queu Already + $processing = $db->count(tbl("conversion_queue"),"cqueue_id"," cqueue_conversion='p' "); + if(true) + { + if($fileName) + { + $queueName = getName($fileName); + $ext = getExt($fileName); + $fileNameQuery = " AND cqueue_name ='$queueName' AND cqueue_ext ='$ext' "; + } + $results = $db->select(tbl("conversion_queue"),"*","cqueue_conversion='no' $fileNameQuery",1); + $result = $results[0]; + if($update) + $db->update(tbl("conversion_queue"),array("cqueue_conversion","time_started"),array("p",time())," cqueue_id = '".$result['cqueue_id']."'"); + return $result; + }else + { + //Checking if video is taking more than $max_time_wait to convert so we can change its time to + //OK Automatically + //Getting All Videos That are being processed + $results = $db->select(tbl("conversion_queue"),"*"," cqueue_conversion='p' "); + foreach($results as $vid) + { + if($vid['time_started']) + { + if($vid['time_started']) + $time_started = $vid['time_started']; + else + $time_started = strtotime($vid['date_added']); + + $elapsed_time = time()-$time_started; + + if($elapsed_time>$max_time_wait) + { + //CHanging Status TO OK + $db->update(tbl("conversion_queue"),array("cqueue_conversion"), + array("yes")," cqueue_id = '".$result['cqueue_id']."'"); + } + } + } + return false; + } + } + + + + /** + * Function used to get video being processed + */ + function get_video_being_processed($fileName=NULL) + { + global $db; + + if($fileName) + { + $queueName = getName($fileName); + $ext = getExt($fileName); + $fileNameQuery = " AND cqueue_name ='$queueName' AND cqueue_ext ='$ext' "; + } + + $results = $db->select(tbl("conversion_queue"),"*","cqueue_conversion='p' $fileNameQuery"); + return $results; + } + + function get_video_details($vid=NULL) + { + global $myquery; + if(!$vid) + global $vid; + return $myquery->get_video_details($vid); + } + + + + /** + * Function used to get all video files + * @param Vdetails + * @param $count_only + * @param $with_path + */ + function get_all_video_files($vdetails,$count_only=false,$with_path=false) + { + $details = get_video_file($vdetails,true,$with_path,true,$count_only); + if($count_only) + return count($details); + return $details; + } + function get_all_video_files_smarty($params) + { + $vdetails = $params['vdetails']; + $count_only = $params['count_only']; + $with_path = $params['with_path']; + return get_all_video_files($vdetails,$count_only,$with_path); + } + + /** + * Function use to get video files + */ + function get_video_file($vdetails,$return_default=true,$with_path=true,$multi=false,$count_only=false,$hq=false) + { + global $Cbucket; + # checking if there is any other functions + # available + if(is_array($Cbucket->custom_video_file_funcs)) + foreach($Cbucket->custom_video_file_funcs as $func) + if(function_exists($func)) + { + $func_returned = $func($vdetails, $hq); + if($func_returned) + return $func_returned; + } + + #Now there is no function so lets continue as + if($vdetails['file_name']) + $vid_files = glob(VIDEOS_DIR."/".$vdetails['file_name']."*"); + + #replace Dir with URL + if(is_array($vid_files)) + foreach($vid_files as $file) + { + $files_part = explode('/',$file); + $video_file = $files_part[count($files_part)-1]; + + if($with_path) + $files[] = VIDEOS_URL.'/'.$video_file; + else + $files[] = $video_file; + } + + if(count($files)==0 && !$multi && !$count_only) + { + if($return_default) + { + if($with_path) + return VIDEOS_URL.'/no_video.flv'; + else + return 'no_video.flv'; + }else{ + return false; + } + }else{ + if($multi) + return $files; + if($count_only) + return count($files); + + foreach($files as $file) + { + if($hq) + { + if(getext($file)=='mp4') + { + return $file; + break; + } + }else{ + return $file; + break; + } + } + return $files[0]; + } + } + + /** + * FUnction used to get HQ ie mp4 video + */ + function get_hq_video_file($vdetails,$return_default=true) + { + return get_video_file($vdetails,$return_default,true,false,false,true); + } + + + /** + * Function used to display flash player for ClipBucket video + */ + function flashPlayer($param) + { + global $Cbucket,$swfobj; + + $param['player_div'] = $param['player_div'] ? $param['player_div'] : 'videoPlayer'; + + $key = $param['key']; + $flv = $param['flv'].'.flv'; + $code = $param['code']; + $flv_url = $file; + $embed = $param['embed']; + $code = $param['code']; + $height = $param['height'] ? $param['height'] : config('player_height'); + $width = $param['width'] ? $param['width'] : config('player_width'); + $param['height'] = $height; + $param['width'] = $width ; + + if(!$param['autoplay']) + $param['autoplay'] = config('autoplay_video'); + + assign('player_params',$param); + if(count($Cbucket->actions_play_video)>0) + { + foreach($Cbucket->actions_play_video as $funcs ) + { + + if(function_exists($funcs)) + { + $func_data = $funcs($param); + } + if($func_data) + { + $player_code = $func_data; + $show_player = true; + break; + } + } + } + + if(function_exists('cbplayer') && empty($player_code)) + $player_code = cbplayer($param,true); + + global $pak_player; + + if($player_code) + if(!$pak_player && $show_player) + { + assign("player_js_code",$player_code); + Template(PLAYER_DIR.'/player.html',false); + return false; + }else + { + return false; + } + + return blank_screen($param); + } + + + /** + * FUnctiuon used to plya HQ videos + */ + function HQflashPlayer($param) + { + return flashPlayer($param); + } + + + /** + * Function used to get player from website settings + */ + function get_player() + { + global $Cbucket; + return $Cbucket->configs['player_file']; + } + + + /** + * Function used to get user avatar + * @param ARRAY $userdetail + * @param SIZE $int + */ + function avatar($param) + { + global $userquery; + $udetails = $param['details']; + $size = $param['size']; + $uid = $param['uid']; + return $userquery->avatar($udetails,$size,$uid); + } + + + /** + * This funcion used to call function dynamically in smarty + */ + function load_form($param) + { + $func = $param['name']; + if(function_exists($func)) + return $func($param); + } + + + + /** + * Function used to get PHP Path + */ + function php_path() + { + if(PHP_PATH !='') + return PHP_PATH; + else + return "/usr/bin/php"; + } + + /** + * Functon used to get binary paths + */ + function get_binaries($path) + { + if(is_array($path)) + { + $type = $path['type']; + $path = $path['path']; + } + + if($type=='' || $type=='user') + { + $path = strtolower($path); + switch($path) + { + case "php": + return php_path(); + break; + + case "mp4box": + return config("mp4boxpath"); + break; + + case "flvtool2": + return config("flvtool2path"); + break; + + case "ffmpeg": + return config("ffmpegpath"); + break; + } + }else{ + $path = strtolower($path); + switch($path) + { + case "php": + $return_path = shell_output("which php"); + if($return_path) + return $return_path; + else + return "Unable to find PHP path"; + break; + + case "mp4box": + $return_path = shell_output("which MP4Box"); + if($return_path) + return $return_path; + else + return "Unable to find mp4box path"; + break; + + case "flvtool2": + $return_path = shell_output("which flvtool2"); + if($return_path) + return $return_path; + else + return "Unable to find flvtool2 path"; + break; + + case "ffmpeg": + $return_path = shell_output("which ffmpeg"); + if($return_path) + return $return_path; + else + return "Unable to find ffmpeg path"; + break; + } + } + } + + + /** + * Function in case htmlspecialchars_decode does not exist + */ + function unhtmlentities ($string) + { + $trans_tbl =get_html_translation_table (HTML_ENTITIES ); + $trans_tbl =array_flip ($trans_tbl ); + return strtr ($string ,$trans_tbl ); + } + + + + /** + * Function used to update processed video + * @param Files details + */ + function update_processed_video($file_array,$status='Successful',$ingore_file_status=false,$failed_status='') + { + global $db; + $file = $file_array['cqueue_name']; + $array = explode('-',$file); + + if(!empty($array[0])) + $file_name = $array[0]; + $file_name = $file; + + $file_path = VIDEOS_DIR.'/'.$file_array['cqueue_name'].'.flv'; + $file_size = @filesize($file_path); + + if(file_exists($file_path) && $file_size>0 && !$ingore_file_status) + { + $stats = get_file_details($file_name); + + //$duration = $stats['output_duration']; + //if(!$duration) + // $duration = $stats['duration']; + + $duration = parse_duration(LOGS_DIR.'/'.$file_array['cqueue_name'].'.log'); + + $db->update(tbl("video"),array("status","duration","failed_reason"), + array($status,$duration,$failed_status)," file_name='".$file_name."'"); + }else + { + $stats = get_file_details($file_name); + + //$duration = $stats['output_duration']; + //if(!$duration) + // $duration = $stats['duration']; + + $duration = parse_duration(LOGS_DIR.'/'.$file_array['cqueue_name'].'.log'); + + $db->update(tbl("video"),array("status","duration","failed_reason"), + array('Failed',$duration,$failed_status)," file_name='".$file_name."'"); + } + } + + + /** + * This function will activate the video if file exists + */ + function activate_video_with_file($vid) + { + global $db; + $vdetails = get_video_details($vid); + $file_name = $vdetails['file_name']; + $results = $db->select(tbl("conversion_queue"),"*"," cqueue_name='$file_name' AND cqueue_conversion='yes'"); + $result = $results[0]; + update_processed_video($result); + } + + + /** + * Function Used to get video file stats from database + * @param FILE_NAME + */ + function get_file_details($file_name) + { + global $db; + //$result = $db->select(tbl("video_files"),"*"," id ='$file_name' OR src_name = '$file_name' "); + //Reading Log File + $file = LOGS_DIR.'/'.$file_name.'.log'; + if(!file_exists($file)) + $file = $file_name; + if(file_exists($file)) + { + $data = file_get_contents($file); + //$file = file_get_contents('1260270267.log'); + + preg_match_all('/(.*) : (.*)/',trim($data),$matches); + + $matches_1 = ($matches[1]); + $matches_2 = ($matches[2]); + + for($i=0;$i> /dev/null &"); + exec($cmd); + //pclose(popen("start \"bla\" \"" . $exe . "\" " . escapeshellarg($args), "r")); + }else{ + exec($cmd . " > /dev/null &"); + } + } + + + /** + * Function used to get thumbnail number from its name + * Updated: If we provide full path for some reason and + * web-address has '-' in it, this means our result is messed. + * But we know our number will always be in last index + * So wrap it with end() and problem solved. + */ + function get_thumb_num($name) + { + $list = end(explode('-',$name)); + $list = explode('.',$list); + return $list[0]; + } + + + /** + * Function used to remove thumb + */ + function delete_video_thumb($file) + { + global $LANG; + $path = THUMBS_DIR.'/'.$file; + if(file_exists($path)) + { + unlink($path); + e(lang('video_thumb_delete_msg'),'m'); + }else{ + e(lang('video_thumb_delete_err')); + } + } + + + /** + * Function used to get array value + * if you know partial value of array and wants to know complete + * value of an array, this function is being used then + */ + function array_find($needle, $haystack) + { + foreach ($haystack as $item) + { + if (strpos($item, $needle) !== FALSE) + { + return $item; + break; + } + } + } + + + + /** + * Function used to give output in proper form + */ + function input_value($params) + { + $input = $params['input']; + $value = $input['value']; + + if($input['value_field']=='checked') + $value = $input['checked']; + + if($input['return_checked']) + return $input['checked']; + + if(function_exists($input['display_function'])) + return $input['display_function']($value); + elseif($input['type']=='dropdown') + { + if($input['checked']) + return $value[$input['checked']]; + else + return $value[0]; + }else + return $input['value']; + } + + /** + * Function used to convert input to categories + * @param input can be an array or #12# like + */ + function convert_to_categories($input) + { + if(is_array($input)) + { + foreach($input as $in) + { + if(is_array($in)) + { + foreach($in as $i) + { + if(is_array($i)) + { + foreach($i as $info) + { + $cat_details = get_category($info); + $cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']); + } + }elseif(is_numeric($i)){ + $cat_details = get_category($i); + $cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']); + } + } + }elseif(is_numeric($in)){ + $cat_details = get_category($in); + $cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']); + } + } + }else{ + preg_match_all('/#([0-9]+)#/',$default['category'],$m); + $cat_array = array($m[1]); + foreach($cat_array as $i) + { + $cat_details = get_category($i); + $cat_array[] = array($cat_details['categoryid'],$cat_details['category_name']); + } + } + + $count = 1; + if(is_array($cat_array)) + { + foreach($cat_array as $cat) + { + echo ''.$cat[1].''; + if($count!=count($cat_array)) + echo ', '; + $count++; + } + } + } + + + + /** + * Function used to get categorie details + */ + function get_category($id) + { + global $myquery; + return $myquery->get_category($id); + } + + + /** + * Sharing OPT displaying + */ + function display_sharing_opt($input) + { + foreach($input as $key => $i) + { + return $key; + break; + } + } + + /** + * Function used to get number of videos uploaded by user + * @param INT userid + * @param Conditions + */ + function get_user_vids($uid,$cond=NULL,$count_only=false) + { + global $userquery; + return $userquery->get_user_vids($uid,$cond,$count_only); + } + + + + /** + * Function used to get error_list + */ + function error_list() + { + global $eh; + return $eh->error_list; + } + + + /** + * Function used to get msg_list + */ + function msg_list() + { + global $eh; + return $eh->message_list; + } + + + /** + * Function used to add tempalte in display template list + * @param File : file of the template + * @param Folder : weather to add template folder or not + * if set to true, file will be loaded from inside the template + * such that file path will becom $templatefolder/$file + * @param follow_show_page : this param tells weather to follow ClipBucket->show_page + * variable or not, if show_page is set to false and follow is true, this template will not load + * otherwise there it WILL + */ + function template_files($file,$folder=false,$follow_show_page=true) + { + global $ClipBucket; + if(!$folder) + $ClipBucket->template_files[] = array('file' => $file,'follow_show_page'=>$follow_show_page); + else + $ClipBucket->template_files[] = array('file'=>$file, + 'folder'=>$folder,'follow_show_page'=>$follow_show_page); + } + + /** + * Function used to include file + */ + function include_template_file($params) + { + $file = $params['file']; + + if(file_exists(LAYOUT.'/'.$file)) + Template($file); + elseif(file_exists($file)) + Template($file,false); + } + + + /** + * Function used to call display + */ + function display_it() + { + global $ClipBucket; + $dir = LAYOUT; + foreach($ClipBucket->template_files as $file) + { + if(file_exists(LAYOUT.'/'.$file) || is_array($file)) + { + + if(!$ClipBucket->show_page && $file['follow_show_page']) + { + + }else + { + if(!is_array($file)) + $new_list[] = $file; + else + { + if($file['folder'] && file_exists($file['folder'].'/'.$file['file'])) + $new_list[] = $file['folder'].'/'.$file['file']; + else + $new_list[] = $file['file']; + } + } + } + } + + assign('template_files',$new_list); + + Template('body.html'); + + footer(); + } + + + /** + * Function used to display hint + */ + function hint($hint) + { + + } + + + + function showpagination($total,$page,$link,$extra_params=NULL,$tag='#page#') + { + global $pages; + return $pages->pagination($total,$page,$link,$extra_params,$tag); + } + + + /** + * Function used to check username is disallowed or not + * @param USERNAME + */ + function check_disallowed_user($username) + { + global $Cbucket; + $disallowed_user = $Cbucket->configs['disallowed_usernames']; + $censor_users = explode(',',$disallowed_user); + if(in_array($username,$censor_users)) + return false; + else + 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; + } + //Checking if its syntax is valid or not + $multi = config('allow_unicode_usernames'); + + //Checking Spaces + if(!config('allow_username_spaces')) + preg_match('/ /',$username,$matches); + if(!is_valid_syntax('username',$username) && $multi!='yes' || $matches) + e(lang("class_invalid_user")); + return true; + } + + + + + + /** + * Function used to check weather username already exists or not + * @input USERNAME + */ + function user_exists($user) + { + global $userquery; + return $userquery->username_exists($user); + } + + /** + * Function used to check weather email already exists or not + * @input email + */ + function email_exists($user) + { + global $userquery; + return $userquery->duplicate_email($user); + } + + /** + * function used to check weather group URL exists or not + */ + function group_url_exists($url) + { + global $cbgroup; + return $cbgroup->group_url_exists($url); + } + + + /** + * Function used to check weather erro exists or not + */ + function error($param='array') + { + if(count(error_list())>0) + { + if($param!='array') + { + if($param=='single') + $param = 0; + $msg = error_list(); + return $msg[$param]; + } + return error_list(); + }else{ + return false; + } + } + + /** + * Function used to check weather msg exists or not + */ + function msg($param='array') + { + if(count(msg_list())>0) + { + if($param!='array') + { + if($param=='single') + $param = 0; + $msg = msg_list(); + return $msg[$param]; + } + return msg_list(); + }else{ + return false; + } + } + + + + /** + * Function used to load plugin + * please check docs.clip-bucket.com + */ + function load_plugin() + { + global $cbplugin; + + } + + + + /** + * Function used to create limit functoin from current page & results + */ + function create_query_limit($page,$result) + { + $limit = $result; + if(empty($page) || $page == 0 || !is_numeric($page)){ + $page = 1; + + } + $from = $page-1; + $from = $from*$limit; + + return $from.','.$result; + } + + + /** + * Function used to get value from $_GET + */ + function get_form_val($val,$filter=false) + { + if($filter) + return form_val($_GET[$val]); + else + return $_GET[$val]; + }function get($val){ return get_form_val($val); } + + /** + * Function used to get value form $_POST + */ + function post_form_val($val,$filter=false) + { + if($filter) + return form_val($_POST[$val]); + else + $_POST[$val]; + } + + + /** + * Function used to get value from $_REQUEST + */ + function request_form_val($val,$filter=false) + { + if($filter) + return form_val($_REQUEST[$val]); + else + $_REQUEST[$val]; + } + + + /** + * Function used to return LANG variable + */ + function lang($var,$sprintf=false) + { + global $LANG,$Cbucket; + + $array_str = array + ( '{title}'); + $array_replace = array + ( $Cbucket->configs['site_title'] ); + + if($LANG[$var]) + { + $phrase = str_replace($array_str,$array_replace,$LANG[$var]); + }else + { + $phrase = str_replace($array_str,$array_replace,$var); + } + + if($sprintf) + { + $sprints = explode(',',$sprintf); + if(is_array($sprints)) + { + foreach($sprints as $sprint) + { + $phrase = sprintf($phrase,$sprint); + } + } + } + + return $phrase; + + } + function smarty_lang($param) + { + if($param['assign']=='') + return lang($param['code'],$param['sprintf']); + else + assign($param['assign'],lang($param['code'],$param['sprintf'])); + } + + + + /** + * function used to remove video thumbs + */ + function remove_video_thumbs($vdetails) + { + global $cbvid; + return $cbvid->remove_thumbs($vdetails); + } + + /** + * function used to remove video log + */ + function remove_video_log($vdetails) + { + global $cbvid; + return $cbvid->remove_log($vdetails); + } + + /** + * function used to remove video files + */ + function remove_video_files($vdetails) + { + global $cbvid; + return $cbvid->remove_files($vdetails); + } + + + /** + * Function used to get player logo + */ + function website_logo() + { + $logo_file = config('player_logo_file'); + if(file_exists(BASEDIR.'/images/'.$logo_file) && $logo_file) + return BASEURL.'/images/'.$logo_file; + + return BASEURL.'/images/logo.png'; + } + + /** + * Function used to assign link + */ + function cblink($params) + { + global $ClipBucket; + $name = $params['name']; + $ref = $param['ref']; + + if($name=='category') + { + return category_link($params['data'],$params['type']); + } + if($name=='sort') + { + return sort_link($params['sort'],'sort',$params['type']); + } + if($name=='time') + { + return sort_link($params['sort'],'time',$params['type']); + } + if($name=='tag') + { + return BASEURL.'/search_result.php?query='.urlencode($params['tag']).'&type='.$params['type']; + } + if($name=='category_search') + { + return BASEURL.'/search_result.php?category[]='.$params['category'].'&type='.$params['type']; + } + + + if(SEO!='yes') + { + preg_match('/http:\/\//',$ClipBucket->links[$name][0],$matches); + if($matches) + $link = $ClipBucket->links[$name][0]; + else + $link = BASEURL.'/'.$ClipBucket->links[$name][0]; + }else + { + preg_match('/http:\/\//',$ClipBucket->links[$name][1],$matches); + if($matches) + $link = $ClipBucket->links[$name][1]; + else + $link = BASEURL.'/'.$ClipBucket->links[$name][1]; + } + + $param_link = ""; + if(!empty($params['extra_params'])) + { + preg_match('/\?/',$link,$matches); + if(!empty($matches[0])) + { + $param_link = '&'.$params['extra_params']; + }else{ + $param_link = '?'.$params['extra_params']; + } + } + + if($params['assign']) + assign($params['assign'],$link.$param_link); + else + return $link.$param_link; + } + + /** + * Function used to check video is playlable or not + * @param vkey,vid + */ + function video_playable($id) + { + global $cbvideo,$userquery; + + if(isset($_POST['watch_protected_video'])) + $video_password = mysql_clean(post('video_password')); + else + $video_password = ''; + + if(!is_array($id)) + $vdo = $cbvideo->get_video($id); + else + $vdo = $id; + $uid = userid(); + if(!$vdo) + { + e(lang("class_vdo_del_err")); + return false; + }elseif($vdo['status']!='Successful') + { + e(lang("this_vdo_not_working")); + if(!has_access('admin_access',TRUE)) + return false; + else + return true; + }elseif($vdo['broadcast']=='private' + && !$userquery->is_confirmed_friend($vdo['userid'],userid()) + && !is_video_user($vdo) + && !has_access('video_moderation',true) + && $vdo['userid']!=$uid){ + e(lang('private_video_error')); + return false; + }elseif($vdo['active'] == 'pen'){ + e(lang("video_in_pending_list")); + if(has_access('admin_access',TRUE) || $vdo['userid'] == userid()) + return true; + else + return false; + }elseif($vdo['broadcast']=='logged' + && !userid() + && !has_access('video_moderation',true) + && $vdo['userid']!=$uid){ + e(lang('not_logged_video_error')); + return false; + }elseif($vdo['active']=='no' ) + { + e(lang("vdo_iac_msg")); + if(!has_access('admin_access',TRUE)) + return false; + else + return true; + } + //No Checking for video password + elseif($vdo['video_password'] + && $vdo['broadcast']=='unlisted' + && $vdo['video_password']!=$video_password + && !has_access('video_moderation',true) + && $vdo['userid']!=$uid) + { + if(!$video_password) + e(lang("video_pass_protected")); + else + e(lang("invalid_video_password")); + template_files("blocks/watch_video/video_password.html",false,false); + } + else + { + $funcs = cb_get_functions('watch_video'); + + if($funcs) + foreach($funcs as $func) + { + $data = $func['func']($vdo); + if($data) + return $data; + } + return true; + } + } + + + /** + * Function used to show rating + * @inputs + * class : class used to show rating usually rating_stars + * rating : rating of video or something + * ratings : number of rating + * total : total rating or out of + */ + function show_rating($params) + { + $class = $params['class'] ? $params['class'] : 'rating_stars'; + $rating = $params['rating']; + $ratings = $params['ratings']; + $total = $params['total']; + $style = $params['style']; + if(empty($style)) + $style = config('rating_style'); + //Checking Percent + + { + if($total<=10) + $total = 10; + $perc = $rating*100/$total; + $disperc = 100 - $perc; + if($ratings <= 0 && $disperc == 100) + $disperc = 0; + } + + $perc = $perc.'%'; + $disperc = $disperc."%"; + switch($style) + { + case "percentage": case "percent": + case "perc": default: + { + $likeClass = "UserLiked"; + if(str_replace('%','',$perc) < '50') + $likeClass = 'UserDisliked'; + + $ratingTemplate = '
    +
    + '.$perc.''; + if($ratings > 0) + $ratingTemplate .= '  '; + $ratingTemplate .='
    +
    '; + } + break; + + case "bars": case "Bars": case "bar": + { + $ratingTemplate = '
    +
    +
    +
    +
    +
    '; + } + break; + + case "numerical": case "numbers": + case "number": case "num": + { + $likes = round($ratings*$perc/100); + $dislikes = $ratings - $likes; + + $ratingTemplate = '
    +
    +
    + '.$likes.' Likes + '.$dislikes.' Dislikes +
    +
    +
    '; + } + break; + + case "custom": case "own_style": + { + $file = LAYOUT."/".$params['file']; + if(!empty($params['file']) && file_exists($file)) + { + // File exists, lets start assign things + assign("perc",$perc); assign("disperc",$disperc); + + // Likes and Dislikes + $likes = floor($ratings*$perc/100); + $dislikes = $ratings - $likes; + assign("likes",$likes); assign("dislikes",$dislikes); + Template($file,FALSE); + } else { + $params['style'] = "percent"; + return show_rating($params); + } + } + break; + } + /*$rating = '
    +
    +
     
    +
    +
    +
    ';*/ + return $ratingTemplate; + } + + + /** + * Function used to display + * Blank Screen + * if there is nothing to play or to show + * then show a blank screen + */ + function blank_screen($data) + { + global $swfobj; + $code = '
    No Player or Video File Found - Unable to Play Any Video
    '; + $swfobj->EmbedCode(unhtmlentities($code),$data['player_div']); + return $swfobj->code; + } + + + /** + * Function used to check weather video has Mp4 file or not + */ + function has_hq($vdetails,$is_file=false) + { + if(!$is_file) + $file = get_hq_video_file($vdetails); + else + $file = $vdetails; + + if(getext($file)=='mp4') + return $file; + else + return false; + } + + /** + * Function used to display an ad + */ + function ad($in) + { + return stripslashes(htmlspecialchars_decode($in)); + } + + + /** + * Function used to get + * available function list + * for special place , read docs.clip-bucket.com + */ + function get_functions($name) + { + global $Cbucket; + $funcs = $Cbucket->$name; + if(is_array($funcs) && count($funcs)>0) + return $funcs; + else + return false; + } + + + /** + * Function used to add js in ClipBuckets JSArray + * see docs.clip-bucket.com + */ + function add_js($files) + { + global $Cbucket; + return $Cbucket->addJS($files); + } + + /** + * Function add_header() + * this will be used to add new files in header array + * this is basically for plugins + * for specific page array('page'=>'file') + * ie array('uploadactive'=>'datepicker.js') + */ + function add_header($files) + { + global $Cbucket; + return $Cbucket->add_header($files); + } + function add_admin_header($files) + { + global $Cbucket; + return $Cbucket->add_admin_header($files); + } + + + /** + * Function used to get config value + * of ClipBucket + */ + function config($input) + { + global $Cbucket; + return $Cbucket->configs[$input]; + } + function get_config($input){ return config($input); } + + + /** + * Funcion used to call functions + * when video is going to watched + * ie in watch_video.php + */ + function call_watch_video_function($vdo) + { + global $userquery; + + $funcs = get_functions('watch_video_functions'); + + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + + if(function_exists($func)) + { + $func($vdo); + } + } + } + + increment_views($vdo['videoid'],'video'); + + if(userid()) + $userquery->increment_watched_vides(userid()); + + } + + /** + * Funcion used to call functions + * when video is going + * on CBvideo::remove_files + */ + function call_delete_video_function($vdo) + { + $funcs = get_functions('on_delete_video'); + if(is_array($funcs) && count($funcs) > 0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($vdo); + } + } + } + } + + + /** + * Funcion used to call functions + * when video is going to dwnload + * ie in download.php + */ + function call_download_video_function($vdo) + { + global $db; + $funcs = get_functions('download_video_functions'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($vdo); + } + } + } + + //Updating Video Downloads + $db->update(tbl("video"),array("downloads"),array("|f|downloads+1"),"videoid = '".$vdo['videoid']."'"); + //Updating User Download + if(userid()) + $db->update(tbl("users"),array("total_downloads"),array("|f|total_downloads+1"),"userid = '".userid()."'"); + } + + + /** + * Funcion used to call functions + * when user view channel + * ie in view_channel.php + */ + function call_view_channel_functions($u) + { + $funcs = get_functions('view_channel_functions'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($u); + } + } + } + + increment_views($u['userid'],"channel"); + } + + + + + /** + * Funcion used to call functions + * when user view topic + * ie in view_topic.php + */ + function call_view_topic_functions($tdetails) + { + $funcs = get_functions('view_topic_functions'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($tdetails); + } + } + } + + increment_views($tdetails['topic_id'],"topic"); + } + + + + + /** + * Funcion used to call functions + * when user view group + * ie in view_group.php + */ + function call_view_group_functions($gdetails) + { + $funcs = get_functions('view_group_functions'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($gdetails); + } + } + } + increment_views($gdetails['group_id'],"group"); + } + + /** + * Funcion used to call functions + * when user view collection + * ie in view_collection.php + */ + function call_view_collection_functions($cdetails) + { + $funcs = get_functions('view_collection_functions'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func($cdetails); + } + } + }; + + increment_views($cdetails['collection_id'],"collection"); + } + + + /** + * Function used to incream number of view + * in object + */ + function increment_views($id,$type=NULL) + { + global $db; + switch($type) + { + case 'v': + case 'video': + default: + { + if(!isset($_COOKIE['video_'.$id])){ + $db->update(tbl("video"),array("views","last_viewed"),array("|f|views+1",NOW())," videoid='$id' OR videokey='$id'"); + setcookie('video_'.$id,'watched',time()+3600); + } + } + break; + case 'u': + case 'user': + case 'channel': + + { + + if(!isset($_COOKIE['user_'.$id])){ + $db->update(tbl("users"),array("profile_hits"),array("|f|profile_hits+1")," userid='$id'"); + setcookie('user_'.$id,'watched',time()+3600); + } + } + break; + case 't': + case 'topic': + + { + if(!isset($_COOKIE['topic_'.$id])){ + $db->update(tbl("group_topics"),array("total_views"),array("|f|total_views+1")," topic_id='$id'"); + setcookie('topic_'.$id,'watched',time()+3600); + } + } + break; + break; + case 'g': + case 'group': + + { + if(!isset($_COOKIE['group_'.$id])){ + $db->update(tbl("groups"),array("total_views"),array("|f|total_views+1")," group_id='$id'"); + setcookie('group_'.$id,'watched',time()+3600); + } + } + break; + case "c": + case "collect": + case "collection": + { + if(!isset($_COOKIE['collection_'.$id])){ + $db->update(tbl("collections"),array("views"),array("|f|views+1")," collection_id = '$id'"); + setcookie('collection_'.$id,'viewed',time()+3600); + } + } + break; + + case "photos": + case "photo": + case "p": + { + if(!isset($_COOKIE['photo_'.$id])) + { + $db->update(tbl('photos'),array("views","last_viewed"),array("|f|views+1",NOW())," photo_id = '$id'"); + setcookie('photo_'.$id,'viewed',time()+3600); + } + } + } + + } + + + /** + * Function used to get post var + */ + function post($var) + { + return $_POST[$var]; + } + + + /** + * Function used to show sharing form + */ + function show_share_form($array) + { + + assign('params',$array); + Template('blocks/share_form.html'); + } + + /** + * Function used to show flag form + */ + function show_flag_form($array) + { + assign('params',$array); + Template('blocks/flag_form.html'); + } + + /** + * Function used to show flag form + */ + function show_playlist_form($array) + { + global $cbvid; + assign('params',$array); + + $playlists = $cbvid->action->get_playlists(); + assign('playlists',$playlists); + + Template('blocks/playlist_form.html'); + } + + /** + * Function used to show collection form + */ + function show_collection_form($params) + { + global $db,$cbcollection; + if(!userid()) + $loggedIn = "not"; + else + { + $collectArray = array("order"=>" collection_name ASC","type"=>"videos","user"=>userid()); + $collections = $cbcollection->get_collections($collectArray); + + $contributions = $cbcollection->get_contributor_collections(userid()); + + if($contributions) + { + if(!$collections) + $collections = $contributions; + else + { + $collections = array_merge($collections,$contributions); + } + } + + assign("collections",$collections); + assign("contributions",$contributions); + } + Template("/blocks/collection_form.html"); + } + + + function cbdate($format=NULL,$timestamp=NULL) + { + if(!$format) + { + $format = config("datE_format"); + } + if(!$timestamp) + return date($format); + else + return date($format,$timestamp); + } + + + /** + * Function used to count pages + * @param TOTAL RESULTS NUM + * @param NUMBER OF RESULTS to DISPLAY NUM + */ + function count_pages($total,$count) + { + if($count<1) $count = 1; + $records = $total/$count; + return $total_pages = round($records+0.49,0); + } + + /** + * Function used to return level name + * @param levelid + */ + function get_user_level($id) + { + global $userquery; + return $userquery->usr_levels[$id]; + } + + + + /** + * This function used to check + * weather user is online or not + * @param : last_active time + * @param : time margin + */ + function is_online($time,$margin='5') + { + $margin = $margin*60; + $active = strtotime($time); + $curr = time(); + $diff = $curr - $active; + if($diff > $margin) + return 'offline'; + else + return 'online'; + } + + + /** + * ClipBucket Form Validator + * this function controls the whole logic of how to operate input + * validate it, generate proper error + */ + function validate_cb_form($input,$array) + { + + if(is_array($input)) + foreach($input 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']; + if(is_string($val)) + { + if(!isUTF8($val)) + $val = utf8_decode($val); + $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); + } + + if(!is_valid_syntax($field['syntax_type'],$val)) + { + if(!empty($invalid_err)) + e($invalid_err); + } + if(isset($max_len)) + { + if($length > $max_len || $length < $min_len) + e(sprintf(lang('please_enter_val_bw_min_max'), + $title,$min_len,$field['max_length'])); + } + if(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); + } + if($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 check weather tempalte file exists or not + * input path to file + */ + function template_file_exists($file,$dir) + { + if(!file_exists($dir.'/'.$file) && !empty($file) && !file_exists($file)) + { + echo sprintf(lang("temp_file_load_err"),$file,$dir); + return false; + }else + return true; + } + + /** + * Function used to count age from date + */ + function get_age($input) + { + $time = strtotime($input); + $iMonth = date("m",$time); + $iDay = date("d",$time); + $iYear = date("Y",$time); + + $iTimeStamp = (mktime() - 86400) - mktime(0, 0, 0, $iMonth, $iDay, $iYear); + $iDays = $iTimeStamp / 86400; + $iYears = floor($iDays / 365 ); + return $iYears; + } + + + + + /** + * Function used to check time span + * A time difference function that outputs the + * time passed in facebook's style: 1 day ago, + * or 4 months ago. I took andrew dot + * macrobert at gmail dot com function + * and tweaked it a bit. On a strict enviroment + * it was throwing errors, plus I needed it to + * calculate the difference in time between + * a past date and a future date. + * thanks to yasmary at gmail dot com + */ + function nicetime($date,$istime=false) + { + if(empty($date)) { + return lang('no_date_provided'); + } + + $periods = array(lang("second"), lang("minute"), lang("hour"), lang("day"), lang("week"), lang("month"), lang("year"), lang("decade")); + $lengths = array(lang("60"),lang("60"),lang("24"),lang("7"),lang("4.35"),lang("12"),lang("10")); + + $now = time(); + + if(!$istime) + $unix_date = strtotime($date); + else + $unix_date = $date; + + // check validity of date + if(empty($unix_date) || $unix_date<1) { + return lang("bad_date"); + } + + // is it future date or past date + if($now > $unix_date) { + //time_ago + $difference = $now - $unix_date; + $tense = "time_ago"; + + } else { + //from_now + $difference = $unix_date - $now; + $tense = "from_now"; + } + + for($j = 0; $difference >= $lengths[$j] && $j < count($lengths)-1; $j++) { + $difference /= $lengths[$j]; + } + + $difference = round($difference); + + if($difference != 1) { + $periods[$j].= "s"; + } + + + return sprintf(lang($tense),$difference,$periods[$j]); + } + + + /** + * Function used to format outgoing link + */ + function outgoing_link($out) + { + preg_match("/http/",$out,$matches); + if(empty($matches[0])) + $out = "http://".$out; + return ''.$out.''; + } + + /** + * Function used to get country via country code + */ + function get_country($code) + { + global $db; + $result = $db->select(tbl("countries"),"name_en,iso2"," iso2='$code' OR iso3='$code'"); + if($db->num_rows>0) + { + $flag = ''; + $result = $result[0]; + if(SHOW_COUNTRY_FLAG) + $flag = ' '; + return $flag.$result['name_en']; + }else + return false; + } + + + /** + * function used to get vidos + */ + function get_videos($param) + { + global $cbvideo; + return $cbvideo->get_videos($param); + } + + /** + * function used to get photos + */ + function get_photos($param) + { + global $cbphoto; + return $cbphoto->get_photos($param); + } + + /** + * function used to get photos + */ + function get_collections($param) + { + global $cbcollection; + return $cbcollection->get_collections($param); + } + + + /** + * function used to get vidos + */ + function get_users($param) + { + global $userquery; + return $userquery->get_users($param); + } + + + /** + * function used to get groups + */ + function get_groups($param) + { + global $cbgroup; + return $cbgroup->get_groups($param); + } + + /** + * Function used to call functions + */ + function call_functions($in,$params=NULL) + { + if(is_array($in)) + { + foreach($in as $i) + { + if(function_exists($i)) + if(!$params) + $i(); + else + $i($params); + } + }else + { + if(function_exists($in)) + if(!$params) + $in(); + else + $in($params); + } + + } + + + + + /** + * In each plugin + * we will define a CONST + * such as plguin_installed + * that will be used weather plugin is installed or not + * ie define("editorspick_install","installed"); + * is_installed('editorspic'); + */ + function is_installed($plugin) + { + if(defined($plugin."_install")) + return true; + else + return false; + } + + + /** + * Category Link is used to return + * Category based link + */ + function category_link($data,$type) + { + switch($type) + { + case 'video':case 'videos':case 'v': + { + + + if(SEO=='yes') + return BASEURL.'/videos/'.$data['category_id'].'/'.SEO($data['category_name']).'/'.$_GET['sort'].'/'.$_GET['time'].'/'; + else + return BASEURL.'/videos.php?cat='.$data['category_id'].'&sort='.$_GET['sort'].'&time='.$_GET['time'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + + case 'channels':case 'channel':case'c':case'user': + { + + if(SEO=='yes') + return BASEURL.'/channels/'.$data['category_id'].'/'.SEO($data['category_name']).'/'.$_GET['sort'].'/'.$_GET['time'].'/'; + else + return BASEURL.'/channels.php?cat='.$data['category_id'].'&sort='.$_GET['sort'].'&time='.$_GET['time'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + + default: + { + + if(THIS_PAGE=='photos') + $type = 'photos'; + + if(defined("IN_MODULE")) + { + $url = 'cat='.$data['category_id'].'&sort='.$_GET['sort'].'&time='.$_GET['time'].'&page='.$_GET['page'].'&seo_cat_name='.$_GET['seo_cat_name']; + global $prefix_catlink; + $url = $prefix_catlink.$url; + + $rm_array = array("cat","sort","time","page","seo_cat_name"); + $p = ""; + if($prefix_catlink) + $rm_array[] = 'p'; + $plugURL = queryString($url,$rm_array); + return $plugURL; + } + + if(SEO=='yes') + return BASEURL.'/'.$type.'/'.$data['category_id'].'/'.SEO($data['category_name']).'/'.$_GET['sort'].'/'.$_GET['time'].'/'; + else + return BASEURL.'/'.$type.'.php?cat='.$data['category_id'].'&sort='.$_GET['sort'].'&time='.$_GET['time'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + } + } + + /** + * Sorting Links is used to return + * Sorting based link + */ + function sort_link($sort,$mode='sort',$type) + { + switch($type) + { + case 'video': + case 'videos': + case 'v': + { + if(!isset($_GET['cat'])) + $_GET['cat'] = 'all'; + if(!isset($_GET['time'])) + $_GET['time'] = 'all_time'; + if(!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + if(!isset($_GET['page'])) + $_GET['page'] = 1; + if(!isset($_GET['seo_cat_name'])) + $_GET['seo_cat_name'] = 'All'; + + if($mode == 'sort') + $sorting = $sort; + else + $sorting = $_GET['sort']; + if($mode == 'time') + $time = $sort; + else + $time = $_GET['time']; + + if(SEO=='yes') + return BASEURL.'/videos/'.$_GET['cat'].'/'.$_GET['seo_cat_name'].'/'.$sorting.'/'.$time.'/'.$_GET['page']; + else + return BASEURL.'/videos.php?cat='.$_GET['cat'].'&sort='.$sorting.'&time='.$time.'&page='.$_GET['page'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + + case 'channels': + case 'channel': + { + if(!isset($_GET['cat'])) + $_GET['cat'] = 'all'; + if(!isset($_GET['time'])) + $_GET['time'] = 'all_time'; + if(!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + if(!isset($_GET['page'])) + $_GET['page'] = 1; + if(!isset($_GET['seo_cat_name'])) + $_GET['seo_cat_name'] = 'All'; + + if($mode == 'sort') + $sorting = $sort; + else + $sorting = $_GET['sort']; + if($mode == 'time') + $time = $sort; + else + $time = $_GET['time']; + + if(SEO=='yes') + return BASEURL.'/channels/'.$_GET['cat'].'/'.$_GET['seo_cat_name'].'/'.$sorting.'/'.$time.'/'.$_GET['page']; + else + return BASEURL.'/channels.php?cat='.$_GET['cat'].'&sort='.$sorting.'&time='.$time.'&page='.$_GET['page'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + + + default: + { + if(!isset($_GET['cat'])) + $_GET['cat'] = 'all'; + if(!isset($_GET['time'])) + $_GET['time'] = 'all_time'; + if(!isset($_GET['sort'])) + $_GET['sort'] = 'most_recent'; + if(!isset($_GET['page'])) + $_GET['page'] = 1; + if(!isset($_GET['seo_cat_name'])) + $_GET['seo_cat_name'] = 'All'; + + if($mode == 'sort') + $sorting = $sort; + else + $sorting = $_GET['sort']; + if($mode == 'time') + $time = $sort; + else + $time = $_GET['time']; + + if(THIS_PAGE=='photos') + $type = 'photos'; + + if(defined("IN_MODULE")) + { + $url = 'cat='.$_GET['cat'].'&sort='.$sorting.'&time='.$time.'&page='.$_GET['page'].'&seo_cat_name='.$_GET['seo_cat_name']; + $plugURL = queryString($url,array("cat","sort","time","page","seo_cat_name")); + return $plugURL; + } + + if(SEO=='yes') + return BASEURL.'/'.$type.'/'.$_GET['cat'].'/'.$_GET['seo_cat_name'].'/'.$sorting.'/'.$time.'/'.$_GET['page']; + else + return BASEURL.'/'.$type.'.php?cat='.$_GET['cat'].'&sort='.$sorting.'&time='.$time.'&page='.$_GET['page'].'&seo_cat_name='.$_GET['seo_cat_name']; + } + break; + } + } + + + + + /** + * Function used to get flag options + */ + function get_flag_options() + { + $action = new cbactions(); + $action->init(); + return $action->report_opts; + } + + /** + * Function used to display flag type + */ + function flag_type($id) + { + $flag_opts = get_flag_options(); + return $flag_opts[$id]; + } + + + /** + * Function used to load captcha field + */ + function get_captcha() + { + global $Cbucket; + if(count($Cbucket->captchas)>0) + { + return $Cbucket->captchas[0]; + }else + return false; + } + + /** + * Function used to load captcha + */ + define("GLOBAL_CB_CAPTCHA","cb_captcha"); + function load_captcha($params) + { + global $total_captchas_loaded; + switch($params['load']) + { + case 'function': + { + if($total_captchas_loaded!=0) + $total_captchas_loaded = $total_captchas_loaded+1; + else + $total_captchas_loaded = 1; + $_SESSION['total_captchas_loaded'] = $total_captchas_loaded; + if(function_exists($params['captcha']['load_function'])) + return $params['captcha']['load_function']().''; + } + break; + case 'field': + { + echo ''; + } + break; + + } + } + + + /** + * Function used to verify captcha + */ + function verify_captcha() + { + $var = post('cb_captcha_enabled'); + if($var=='yes') + { + $captcha = get_captcha(); + $val = $captcha['validate_function'](post(GLOBAL_CB_CAPTCHA)); + return $val; + }else + return true; + } + + + /** + * Function used to ingore errors + * that are created when there is wrong action done + * on clipbucket ie inavalid username etc + */ + function ignore_errors() + { + global $ignore_cb_errors; + $ignore_cb_errors = TRUE; + } + + /** + * Function used to set $ignore_cb_errors + * back to TRUE so our error catching system + * can generate errors + */ + function catch_error() + { + global $ignore_cb_errors; + $ignore_cb_errors = FALSE; + } + + + /** + * Function used to call sub_menu_easily + */ + function sub_menu() + { + /** + * Submenu function used to used to display submenu links + * after navbar + */ + $funcs = get_functions('sub_menu'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + return $func($u); + } + } + } + } + + + /** + * Function used to load clipbucket title + */ + function cbtitle($params=false) + { + global $cbsubtitle; + + $sub_sep = $params['sub_sep']; + if(!$sub_sep) + $sub_sep = '-'; + + //Getting Subtitle + echo TITLE; + if(!$cbsubtitle) + echo " $sub_sep ".SLOGAN; + else + echo " $sub_sep ".$cbsubtitle; + //echo " ".SUBTITLE; + } + + + /** + * @Script : ClipBucket + * @Author : Arslan Hassan + * @License : CBLA + * @Since : 2007 + * + * function whos_your_daddy + * Simply tells the name of script owner + * @return INTELLECTUAL BADASS + */ + function whos_your_daddy() + { + echo "

    Arslan Hassan

    "; + } + + /** + * function used to set website subtitle + */ + function subtitle($title) + { + global $cbsubtitle; + $cbsubtitle = $title; + } + + + /** + * FUnction used to get username from userid + */ + function get_username($uid) + { + global $userquery; + return $userquery->get_username($uid,'username'); + } + + /** + * Function used to get collection name from id + * Smarty Function + */ + function get_collection_field($cid,$field='collection_name') + { + global $cbcollection; + return $cbcollection->get_collection_field($cid,$field); + } + + /** + * Function used to delete photos if + * whole collection is being deleted + */ + function delete_collection_photos($details) + { + global $cbcollection,$cbphoto; + $type = $details['type']; + + if($type == 'photos') + { + $ps = $cbphoto->get_photos(array("collection"=>$details['collection_id'])); + if(!empty($ps)) + { + foreach($ps as $p) + { + $cbphoto->make_photo_orphan($details,$p['photo_id']); + } + unset($ps); // Empty $ps. Avoiding the duplication prob + } + } + } + + /** + * FUnction used to get head menu + */ + function head_menu($params=NULL) + { + global $Cbucket; + return $Cbucket->head_menu($params); + } + + function cbMenu($params=NULL) + { + global $Cbucket; + return $Cbucket->cbMenu($params); + } + + /** + * FUnction used to get foot menu + */ + function foot_menu($params=NULL) + { + global $Cbucket; + return $Cbucket->foot_menu($params); + } + + + + + /** + * FUNCTION Used to convert XML to Array + * @Author : http://www.php.net/manual/en/function.xml-parse.php#87920 + */ + function xml2array($url, $get_attributes = 1, $priority = 'tag',$is_url=true) + { + $contents = ""; + if (!function_exists('xml_parser_create')) + { + return false; + } + $parser = xml_parser_create(''); + + if($is_url) + { + if (!($fp = @ fopen($url, 'rb'))) + { + $ch = curl_init(); + curl_setopt($ch,CURLOPT_URL,$url); + curl_setopt($ch, CURLOPT_USERAGENT, + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/3.0.0.2'); + curl_setopt($ch,CURLOPT_RETURNTRANSFER,true); + curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true); + $contents = curl_exec($ch); + curl_close($ch); + + if(!$contents) + return false; + } + while (!feof($fp)) + { + $contents .= fread($fp, 8192); + } + fclose($fp); + }else{ + $contents = $url; + } + + xml_parser_set_option($parser, XML_OPTION_TARGET_ENCODING, "UTF-8"); + xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); + xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); + xml_parse_into_struct($parser, trim($contents), $xml_values); + xml_parser_free($parser); + if (!$xml_values) + return; //Hmm... + $xml_array = array (); + $parents = array (); + $opened_tags = array (); + $arr = array (); + $current = & $xml_array; + $repeated_tag_index = array (); + foreach ($xml_values as $data) + { + + unset ($attributes, $value); + extract($data); + $result = array (); + $attributes_data = array (); + if (isset ($value)) + { + if ($priority == 'tag') + $result = $value; + else + $result['value'] = $value; + } + if (isset ($attributes) and $get_attributes) + { + foreach ($attributes as $attr => $val) + { + if ($priority == 'tag') + $attributes_data[$attr] = $val; + else + $result['attr'][$attr] = $val; //Set all the attributes in a array called 'attr' + } + } + if ($type == "open") + { + $parent[$level -1] = & $current; + if (!is_array($current) or (!in_array($tag, array_keys($current)))) + { + $current[$tag] = $result; + if ($attributes_data) + $current[$tag . '_attr'] = $attributes_data; + $repeated_tag_index[$tag . '_' . $level] = 1; + $current = & $current[$tag]; + } + else + { + if (isset ($current[$tag][0])) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; + $repeated_tag_index[$tag . '_' . $level]++; + } + else + { + $current[$tag] = array ( + $current[$tag], + $result + ); + $repeated_tag_index[$tag . '_' . $level] = 2; + if (isset ($current[$tag . '_attr'])) + { + $current[$tag]['0_attr'] = $current[$tag . '_attr']; + unset ($current[$tag . '_attr']); + } + } + $last_item_index = $repeated_tag_index[$tag . '_' . $level] - 1; + $current = & $current[$tag][$last_item_index]; + } + } + elseif ($type == "complete") + { + if (!isset ($current[$tag])) + { + $current[$tag] = $result; + $repeated_tag_index[$tag . '_' . $level] = 1; + if ($priority == 'tag' and $attributes_data) + $current[$tag . '_attr'] = $attributes_data; + } + else + { + if (isset ($current[$tag][0]) and is_array($current[$tag])) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level]] = $result; + if ($priority == 'tag' and $get_attributes and $attributes_data) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; + } + $repeated_tag_index[$tag . '_' . $level]++; + } + else + { + $current[$tag] = array ( + $current[$tag], + $result + ); + $repeated_tag_index[$tag . '_' . $level] = 1; + if ($priority == 'tag' and $get_attributes) + { + if (isset ($current[$tag . '_attr'])) + { + $current[$tag]['0_attr'] = $current[$tag . '_attr']; + unset ($current[$tag . '_attr']); + } + if ($attributes_data) + { + $current[$tag][$repeated_tag_index[$tag . '_' . $level] . '_attr'] = $attributes_data; + } + } + $repeated_tag_index[$tag . '_' . $level]++; //0 and 1 index is already taken + } + } + } + elseif ($type == 'close') + { + $current = & $parent[$level -1]; + } + } + + return ($xml_array); + } + + + function array2xml($array, $level=1) + { + $xml = ''; + // if ($level==1) { + // $xml .= "\n"; + // } + foreach ($array as $key=>$value) { + $key = strtolower($key); + if (is_object($value)) {$value=get_object_vars($value);}// convert object to array + + if (is_array($value)) { + $multi_tags = false; + foreach($value as $key2=>$value2) { + if (is_object($value2)) {$value2=get_object_vars($value2);} // convert object to array + if (is_array($value2)) { + $xml .= str_repeat("\t",$level)."<$key>\n"; + $xml .= array2xml($value2, $level+1); + $xml .= str_repeat("\t",$level)."\n"; + $multi_tags = true; + } else { + if (trim($value2)!='') { + if (htmlspecialchars($value2)!=$value2) { + $xml .= str_repeat("\t",$level). + "<$key2>". // changed $key to $key2... didn't work otherwise. + "\n"; + } else { + $xml .= str_repeat("\t",$level). + "<$key2>$value2\n"; // changed $key to $key2 + } + } + $multi_tags = true; + } + } + if (!$multi_tags and count($value)>0) { + $xml .= str_repeat("\t",$level)."<$key>\n"; + $xml .= array2xml($value, $level+1); + $xml .= str_repeat("\t",$level)."\n"; + } + + } else { + if (trim($value)!='') { + echo "value=$value
    "; + if (htmlspecialchars($value)!=$value) { + $xml .= str_repeat("\t",$level)."<$key>". + "\n"; + } else { + $xml .= str_repeat("\t",$level). + "<$key>$value\n"; + } + } + } + } + //if ($level==1) { + // $xml .= "
    \n"; + // } + + return $xml; + } + + + + /** + * FUnction used to display widget + */ + function widget($params) + { + $name = $params['name']; + $content = $params['content']; + + return + '
    +
    + '.$name.' +
    +
    + '.$content.' +
    +
    '; + } + + + /** + * Function used to get latest ClipBucket version info + */ + function get_latest_cb_info() + { + if($_SERVER['HTTP_HOST']!='localhost') + $url = 'http://clip-bucket.com/versions.xml'; + else + $url = 'http://localhost/clipbucket/2.x/2/upload/tester/versions.xml'; + $version = xml2array($url); + if(!$version) + { + return false; + }else + { + return $version['phpbucket']['clipbucket'][0]; + } + } + + + /** + * function used to get allowed extension as in array + */ + function get_vid_extensions() + { + $exts = config('allowed_types'); + $exts = preg_replace("/ /","",$exts); + $exts = explode(",",$exts); + return $exts; + } + + + /** + * This function used to include headers in tag + * it will check weather to include the file or not + * it will take file and its type as an array + * then compare its type with THIS_PAGE constant + * if header has TYPE of THIS_PAGE then it will be inlucded + */ + function include_header($params) + { + $file = $params['file']; + $type = $params['type']; + + if($file=='global_header') + { + Template(BASEDIR.'/styles/global/head.html',false); + return false; + } + + if($file == 'admin_bar') + { + if(has_access('admin_access',TRUE)) + Template(BASEDIR.'/styles/global/admin_bar.html',false); + return false; + } + + if(!$type) + $type = "global"; + + if(is_includeable($type)) + Template($file,false); + + return false; + } + + + + + /** + * Function used to check weather to include + * given file or not + * it will take array of pages + * if array has ACTIVE PAGE or has GLOBAL value + * it will return true + * otherwise FALSE + */ + function is_includeable($array) + { + if(!is_array($array)) + $array = array($array); + if(in_array(THIS_PAGE,$array) || in_array('global',$array)) + { + return true; + }else + return false; + } + + /** + * This function works the same way as include_header + * but the only difference is , it is used to include + * JS files only + */ + $the_js_files = array(); + function include_js($params) + { + global $the_js_files; + + $file = $params['file']; + $type = $params['type']; + + if(!in_array($file,$the_js_files)) + { + $the_js_files[] = $file; + if($type=='global') + return ''; + elseif(is_array($type)) + { + foreach($type as $t) + { + if($t==THIS_PAGE) + return ''; + } + }elseif($type==THIS_PAGE) + return ''; + } + + return false; + } + + + /** + * Function used to check weather FFMPEG has Required Modules installed or not + */ + function get_ffmpeg_codecs($data=false) + { + $req_codecs = array + ('libxvid' => 'Required for DIVX AVI files', + 'libmp3lame'=> 'Required for proper Mp3 Encoding', + 'libfaac' => 'Required for AAC Audio Conversion', + // 'libfaad' => 'Required for AAC Audio Conversion', + 'libx264' => 'Required for x264 video compression and conversion', + 'libtheora' => 'Theora is an open video codec being developed by the Xiph.org', + 'libvorbis' => 'Ogg Vorbis is a new audio compression format', + ); + + if($data) + $version = $data; + else + $version = shell_output( get_binaries('ffmpeg').' -i xxx -acodec copy -vcodec copy -f null /dev/null 2>&1' ); + preg_match_all("/enable\-(.*) /Ui",$version,$matches); + $installed = $matches[1]; + + $the_codecs = array(); + + foreach($installed as $inst) + { + if(empty($req_codecs[$inst])) + $the_codecs[$inst]['installed'] = 'yes'; + } + + foreach($req_codecs as $key=>$codec) + { + $the_req_codecs[$key] = array(); + $the_req_codecs[$key]['required'] = 'yes'; + $the_req_codecs[$key]['desc'] = $req_codecs[$key]; + if(in_array($key,$installed)) + $the_req_codecs[$key]['installed'] = 'yes'; + else + $the_req_codecs[$key]['installed'] = 'no'; + } + + $the_codecs = array_merge($the_req_codecs,$the_codecs); + return $the_codecs; + } + + + /** + * Function used to cheack weather MODULE is INSTALLED or NOT + */ + function check_module_path($params) + { + $rPath = $path = $params['path']; + + if($path['get_path']) + $path = get_binaries($path); + $array = array(); + $result = shell_output($path." -version"); + + if($result) + { + if(strstr($result,'error') || strstr(($result),'No such file or directory')) + { + $error['error'] = $result; + + if($params['assign']) + assign($params['assign'],$error); + + return false; + } + + if($params['assign']) + { + $array['status'] = 'ok'; + $array['version'] = parse_version($params['path'],$result); + + assign($params['assign'],$array); + + }else + { + return $result; + } + }else + { + if($params['assign']) + assign($params['assign']['error'],"error"); + else + return false; + } + + } + + + /** + * Function used to parse version from info + */ + function parse_version($path,$result) + { + switch($path) + { + case 'ffmpeg': + { + //Gett FFMPEG SVN version + preg_match("/svn-r([0-9]+)/i",strtolower($result),$matches); + //pr($matches); + if(is_numeric(floatval($matches[1])) && $matches[1]) { + return 'Svn '.$matches[1]; + } + //Get FFMPEG version + preg_match("/FFmpeg version ([0-9.]+),/i",strtolower($result),$matches); + if(is_numeric(floatval($matches[1])) && $matches[1]) { + return $matches[1]; + } + + //Get FFMPEG GIT version + preg_match("/ffmpeg version n\-([0-9]+)/i",strtolower($result),$matches); + + if(is_numeric(floatval($matches[1])) && $matches[1]) { + return 'Git '.$matches[1]; + } + } + break; + case 'php': + { + return phpversion(); + } + break; + case 'flvtool2': + { + preg_match("/flvtool2 ([0-9\.]+)/i",$result,$matches); + if(is_numeric(floatval($matches[1]))){ + return $matches[1]; + } else { + return false; + } + } + break; + case 'mp4box': + { + preg_match("/version (.*) \(/Ui",$result,$matches); + //pr($matches); + if(is_numeric(floatval($matches[1]))){ + return $matches[1]; + } else { + return false; + } + } + } + } + + + /** + * function used to call clipbucket footers + */ + function footer() + { + $funcs = get_functions('clipbucket_footer'); + if(is_array($funcs) && count($funcs)>0) + { + foreach($funcs as $func) + { + if(function_exists($func)) + { + $func(); + } + } + } + } + + + + + + + + + /** + * Function used to generate RSS FEED links + */ + function rss_feeds($params) + { + /** + * setting up the feeds arrays.. + * if you want to call em in your functions..simply call the global variable $rss_feeds + */ + $rss_link = cblink(array("name"=>"rss")); + $rss_feeds = array(); + $rss_feeds[] = array("title"=>"Recently added videos","link"=>$rss_link."recent"); + $rss_feeds[] = array("title"=>"Most Viewed Videos","link"=>$rss_link."views"); + $rss_feeds[] = array("title"=>"Top Rated Videos","link"=>$rss_link."rating"); + $rss_feeds[] = array("title"=>"Videos Being Watched","link"=>$rss_link."watching"); + + $funcs = get_functions('rss_feeds'); + if(is_array($funcs)) + { + foreach($funcs as $func) + { + return $func($params); + } + } + + if($params['link_tag']) + { + foreach($rss_feeds as $rss_feed) + { + echo "\n"; + } + } + } + + /** + * Function used to insert Log + */ + function insert_log($type,$details) + { + global $cblog; + $cblog->insert($type,$details); + } + + /** + * Function used to get db size + */ + function get_db_size() + { + $result = mysql_query("SHOW TABLE STATUS"); + $dbsize = 0; + while( $row = mysql_fetch_array( $result ) ) + { + $dbsize += $row[ "Data_length" ] + $row[ "Index_length" ]; + } + return $dbsize; + } + + + /** + * Function used to check weather user has marked comment as spam or not + */ + function marked_spammed($comment) + { + $spam_voters = explode("|",$comment['spam_voters']); + $spam_votes = $comment['spam_votes']; + $admin_vote = in_array('1',$spam_voters); + if(userid() && in_array(userid(),$spam_voters)){ + return true; + }elseif($admin_vote){ + return true; + }else{ + return false; + } + } + + + /** + * function used to get all time zones + */ + function get_time_zones() + { + $timezoneTable = array( + "-12" => "(GMT -12:00) Eniwetok, Kwajalein", + "-11" => "(GMT -11:00) Midway Island, Samoa", + "-10" => "(GMT -10:00) Hawaii", + "-9" => "(GMT -9:00) Alaska", + "-8" => "(GMT -8:00) Pacific Time (US & Canada)", + "-7" => "(GMT -7:00) Mountain Time (US & Canada)", + "-6" => "(GMT -6:00) Central Time (US & Canada), Mexico City", + "-5" => "(GMT -5:00) Eastern Time (US & Canada), Bogota, Lima", + "-4" => "(GMT -4:00) Atlantic Time (Canada), Caracas, La Paz", + "-3.5" => "(GMT -3:30) Newfoundland", + "-3" => "(GMT -3:00) Brazil, Buenos Aires, Georgetown", + "-2" => "(GMT -2:00) Mid-Atlantic", + "-1" => "(GMT -1:00 hour) Azores, Cape Verde Islands", + "0" => "(GMT) Western Europe Time, London, Lisbon, Casablanca", + "1" => "(GMT +1:00 hour) Brussels, Copenhagen, Madrid, Paris", + "2" => "(GMT +2:00) Kaliningrad, South Africa", + "3" => "(GMT +3:00) Baghdad, Riyadh, Moscow, St. Petersburg", + "3.5" => "(GMT +3:30) Tehran", + "4" => "(GMT +4:00) Abu Dhabi, Muscat, Baku, Tbilisi", + "4.5" => "(GMT +4:30) Kabul", + "5" => "(GMT +5:00) Ekaterinburg, Islamabad, Karachi, Tashkent", + "5.5" => "(GMT +5:30) Bombay, Calcutta, Madras, New Delhi", + "6" => "(GMT +6:00) Almaty, Dhaka, Colombo", + "7" => "(GMT +7:00) Bangkok, Hanoi, Jakarta", + "8" => "(GMT +8:00) Beijing, Perth, Singapore, Hong Kong", + "9" => "(GMT +9:00) Tokyo, Seoul, Osaka, Sapporo, Yakutsk", + "9.5" => "(GMT +9:30) Adelaide, Darwin", + "10" => "(GMT +10:00) Eastern Australia, Guam, Vladivostok", + "11" => "(GMT +11:00) Magadan, Solomon Islands, New Caledonia", + "12" => "(GMT +12:00) Auckland, Wellington, Fiji, Kamchatka" + ); + return $timezoneTable; + } + + + /** + * Function used to get object type from its code + * ie v=>video + */ + function get_obj_type($type) + { + switch($type) + { + case "v": + { + return "video"; + } + break; + } + } + + + + function check_cbvideo() + { + + /** + * come, keep it for two more versions only + * it will be gone in next few updates by default :p + * + * but dont ever forget its name + * its a damn ClipBucket + */ + + if((!defined("isCBSecured") + || count(get_functions('clipbucket_footer'))== 0 ) + && !BACK_END) + { + echo cbSecured(CB_SIGN_C); + } + } + + /** + * Gives coversion process output + */ + function conv_status($in) + { + switch($in) + { + case "p": + return "Processing"; + break; + case "no": + return "Pending"; + break; + case "yes": + return "Done"; + break; + } + } + + function check_install($type) + { + global $while_installing,$Cbucket; + switch($type) + { + case "before": + { + if(file_exists('files/temp/install.me') && !file_exists('includes/clipbucket.php')) + { + header('Location: '.get_server_url().'/cb_install'); + } + } + break; + + case "after": + { + if(file_exists('files/temp/install.me')) + { + $Cbucket->configs['closed'] = 1; + } + } + break; + } + } + + function get_server_url() + { + $DirName = dirname($_SERVER['PHP_SELF']); + if(preg_match('/admin_area/i', $DirName)) + { + $DirName = str_replace('/admin_area','',$DirName); + } + if(preg_match('/cb_install/i', $DirName)) + { + $DirName = str_replace('/cb_install','',$DirName); + } + return get_server_protocol().$_SERVER['HTTP_HOST'].$DirName; + } + + function get_server_protocol() + { + if(isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on') + { + return 'https://'; + } + else + { + $protocol = preg_replace('/^([a-z]+)\/.*$/', '\\1', strtolower($_SERVER['SERVER_PROTOCOL'])); + $protocol .= '://'; + return $protocol; + } + } + + + /** + * Returns true if the string or array of string is encoded in UTF8. + * + * Example of use. If you want to know if a file is saved in UTF8 format : + * $array = file('one file.txt'); + * $isUTF8 = isUTF8($array); + * if (!$isUTF8) --> we need to apply utf8_encode() to be in UTF8 + * else --> we are in UTF8 :) + * + * @param mixed A string, or an array from a file() function. + * @return boolean + */ + function isUTF8($string) + { + if (is_array($string)) + { + $enc = implode('', $string); + return @!((ord($enc[0]) != 239) && (ord($enc[1]) != 187) && (ord($enc[2]) != 191)); + } + else + { + return (utf8_encode(utf8_decode($string)) == $string); + } + } + + /* + extract the file extension from any given path or url. + source: http://www.php.net/manual/en/function.basename.php#89127 + */ + function fetch_file_extension($filepath) + { + preg_match('/[^?]*/', $filepath, $matches); + $string = $matches[0]; + + $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); + + # check if there is any extension + if(count($pattern) == 1) + { + // no file extension found + return; + } + + if(count($pattern) > 1) + { + $filenamepart = $pattern[count($pattern)-1][0]; + preg_match('/[^?]*/', $filenamepart, $matches); + return $matches[0]; + } + } + + /* + extract the file filename from any given path or url. + source: http://www.php.net/manual/en/function.basename.php#89127 + */ + function fetch_filename($filepath) + { + preg_match('/[^?]*/', $filepath, $matches); + $string = $matches[0]; + #split the string by the literal dot in the filename + $pattern = preg_split('/\./', $string, -1, PREG_SPLIT_OFFSET_CAPTURE); + #get the last dot position + $lastdot = $pattern[count($pattern)-1][1]; + #now extract the filename using the basename function + $filename = basename(substr($string, 0, $lastdot-1)); + + #return the filename part + return $filename; + } + + /** + * Function used to generate + * embed code of embedded video + */ + function embeded_code($vdetails) + { + $code = ''; + $code .= ''; + $code .= ''; + $code .= ''; + //Replacing Height And Width + $h_w_p = array("{Width}","{Height}"); + $h_w_r = array(EMBED_VDO_WIDTH,EMBED_VDO_HEIGHT); + $embed_code = str_replace($h_w_p,$h_w_r,$vdetails['embed_code']); + $code .= unhtmlentities($embed_code); + $code .= ''; + return $code; + } + + + /** + * function used to convert input to proper date created formate + */ + function datecreated($in) + { + + $date_els = explode('-',$in); + + //checking date format + $df = config("date_format"); + $df_els = explode('-',$df); + + foreach($df_els as $key => $el) + ${strtolower($el).'id'} = $key; + + $month = $date_els[$mid]; + $day = $date_els[$did]; + $year = $date_els[$yid]; + + if($in) + return date("Y-m-d",strtotime($year.'-'.$month.'-'.$day)); + else + return '0000-00-00'; + } + + + /** + * After struggling alot with baseurl problem + * i finally able to found its nice and working solkution.. + * its not my original but its a genuine working copy + * its still in beta mode + */ + function baseurl() + { + $protocol = is_ssl() ? 'https://' : 'http://'; + if(!$sub_dir) + return $base = $protocol.$_SERVER['HTTP_HOST'].untrailingslashit(stripslashes(dirname(($_SERVER['SCRIPT_NAME'])))); + else + return $base = $protocol.$_SERVER['HTTP_HOST'].untrailingslashit(stripslashes(dirname(dirname($_SERVER['SCRIPT_NAME'])))); + + }function base_url(){ return baseurl();} + + /** + * SRC (WORD PRESS) + * Appends a trailing slash. + * + * Will remove trailing slash if it exists already before adding a trailing + * slash. This prevents double slashing a string or path. + * + * The primary use of this is for paths and thus should be used for paths. It is + * not restricted to paths and offers no specific path support. + * + * @since 1.2.0 + * @uses untrailingslashit() Unslashes string if it was slashed already. + * + * @param string $string What to add the trailing slash to. + * @return string String with trailing slash added. + */ + function trailingslashit($string) { + return untrailingslashit($string) . '/'; + } + + /** + * SRC (WORD PRESS) + * Removes trailing slash if it exists. + * + * The primary use of this is for paths and thus should be used for paths. It is + * not restricted to paths and offers no specific path support. + * + * @since 2.2.0 + * + * @param string $string What to remove the trailing slash from. + * @return string String without the trailing slash. + */ + function untrailingslashit($string) { + return rtrim($string, '/'); + } + + + /** + * Determine if SSL is used. + * + * @since 2.6.0 + * + * @return bool True if SSL, false if not used. + */ + function is_ssl() { + if ( isset($_SERVER['HTTPS']) ) { + if ( 'on' == strtolower($_SERVER['HTTPS']) ) + return true; + if ( '1' == $_SERVER['HTTPS'] ) + return true; + } elseif ( isset($_SERVER['SERVER_PORT']) && ( '443' == $_SERVER['SERVER_PORT'] ) ) { + return true; + } + return false; + } + + /** + * This will update stats like Favorite count, Playlist count + */ + function updateObjectStats($type='favorite',$object='video',$id,$op='+') + { + global $db; + + switch($type) + { + case "favorite": case "favourite": + case "favorites": case "favourties": + case "fav": + { + switch($object) + { + case "video": + case "videos": case "v": + { + $db->update(tbl('video'),array('favourite_count'),array("|f|favourite_count".$op."1")," videoid = '".$id."'"); + } + break; + + case "photo": + case "photos": case "p": + { + $db->update(tbl('photos'),array('total_favorites'),array("|f|total_favorites".$op."1")," photo_id = '".$id."'"); + } + break; + + /*case "collection": + case "collections": case "cl": + { + $db->update(tbl('photos'),array('total_favorites'),array("|f|total_favorites".$op."1")," photo_id = '".$id."'"); + } + break;*/ + } + } + break; + + case "playlist": case "playList": + case "plist": + { + switch($object) + { + case "video": + case "videos": case "v": + { + $db->update(tbl('video'),array('playlist_count'),array("|f|playlist_count".$op."1")," videoid = '".$id."'"); + } + } + } + } + } + + + /** + * FUnction used to check weather conversion lock exists or not + * if converson log exists it means no further conersion commands will be executed + * + * @return BOOLEAN + */ + function conv_lock_exists() + { + if(file_exists(TEMP_DIR.'/conv_lock.loc')) + return true; + else + return false; + } + + /** + * Function used to return a well-formed queryString + * for passing variables to url + * @input variable_name + */ + function queryString($var=false,$remove=false) + { + $queryString = $_SERVER['QUERY_STRING']; + + if($var) + $queryString = preg_replace("/&?$var=([\w+\s\b\.?\S]+|)/","",$queryString); + + if($remove) + { + if(!is_array($remove)) + $queryString = preg_replace("/&?$remove=([\w+\s\b\.?\S]+|)/","",$queryString); + else + foreach($remove as $rm) + $queryString = preg_replace("/&?$rm=([\w+\s\b\.?\S]+|)/","",$queryString); + + } + + if($queryString) + $preUrl = "?$queryString&"; + else + $preUrl = "?"; + + $preUrl = preg_replace(array("/(\&{2,10})/","/\?\&/"),array("&","?"),$preUrl); + + return $preUrl.$var; + } + + + /** + * Following two functions are taken from + * tutorialzine.com's post 'Creating a Facebook-like Registration Form with jQuery' + * These function are written by Martin Angelov. + * Read post here: http://tutorialzine.com/2009/08/creating-a-facebook-like-registration-form-with-jquery/ + */ + function generate_options($params) + { + $reverse=false; + + if($params['from']>$params['to']) + { + $tmp=$params['from']; + $params['from']=$params['to']; + $params['to']=$tmp; + + $reverse=true; + } + + + $return_string=array(); + for($i=$params['from'];$i<=$params['to'];$i++) + { + //$return_string[$i] = ($callback?$callback($i):$i); + $return_string[] = ''; + } + + if($reverse) + { + $return_string=array_reverse($return_string); + } + + + return join('',$return_string); + } + function callback_month($month) + { + return date('M',mktime(0,0,0,$month,1)); + } + + + /** + * Function use to download file to server + * + * @param URL + * @param destination + */ + function snatch_it($snatching_file,$destination,$dest_name,$rawdecode=true) + { + global $curl; + if($rawdecode==true) + $snatching_file= rawurldecode($snatching_file); + $destination.'/'.$dest_name; + $fp = fopen ($destination.'/'.$dest_name, 'w+'); + $ch = curl_init($snatching_file); + curl_setopt($ch, CURLOPT_TIMEOUT, 600); + curl_setopt($ch, CURLOPT_FILE, $fp); + curl_setopt($ch, CURLOPT_USERAGENT, + 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.2) Gecko/20070219 Firefox/2.0.0.2'); + curl_exec($ch); + curl_close($ch); + fclose($fp); + } + + + /** + * Function check curl + */ + function isCurlInstalled() + { + if (in_array ('curl', get_loaded_extensions())) { + return true; + } + else{ + return false; + } + } + + /** + * Function for loading + * uploader file url & other configurations + */ + function uploaderDetails() + { + global $uploaderType; + + $uploaderDetails = array + ( + 'uploadSwfPath' => JS_URL.'/uploadify/uploadify.swf', + 'uploadScriptPath' => BASEURL.'/actions/file_uploader.php', + ); + + $photoUploaderDetails = array + ( + 'uploadSwfPath' => JS_URL.'/uploadify/uploadify.swf', + 'uploadScriptPath' => BASEURL.'/actions/photo_uploader.php', + ); + + + assign('uploaderDetails',$uploaderDetails); + assign('photoUploaderDetails',$photoUploaderDetails); + //Calling Custom Functions + cb_call_functions('uploaderDetails'); + } + + + /** + * Function isSectionEnabled + * This function used to check weather INPUT section is enabled or not + */ + function isSectionEnabled($input,$restrict=false) + { + global $Cbucket; + + $section = $Cbucket->configs[$input.'Section']; + + if(!$restrict) + { + if($section =='yes') + return true; + else + return false; + }else + { + if($section =='yes' || THIS_PAGE=='cb_install') + { + return true; + }else + { + template_files('blocked.html'); + display_it(); + exit(); + } + } + + } + + + function array_depth($array) { + $ini_depth = 0; + + foreach($array as $arr) + { + if(is_array($arr)) + { + $depth = array_depth($arr) + 1; + + if($depth > $ini_depth) + $ini_depth = $depth; + } + } + + return $ini_depth; + } + + + /** + * JSON_ENCODE short + */ + function je($in){ return json_encode($in); } + /** + * JSON_DECODE short + */ + function jd($in,$returnClass=false){ if(!$returnClass) return json_decode($in,true); else return json_decode($in); } + + + /** + * function used to update last commented option + * so comment cache can be refreshed + */ + function update_last_commented($type,$id) + { + global $db; + + if($type && $id) + { + switch($type) + { + case "v": + case "video": + case "vdo": + case "vid": + case "videos": + $db->update(tbl("video"),array('last_commented'),array(now()),"videoid='$id'"); + break; + + case "c": + case "channel": + case "user": + case "u": + case "users": + case "channels": + $db->update(tbl("users"),array('last_commented'),array(now()),"userid='$id'"); + break; + + case "cl": + case "collection": + case "collect": + case "collections": + case "collects": + $db->update(tbl("collections"),array('last_commented'),array(now()),"collection_id='$id'"); + break; + + case "p": + case "photo": + case "photos": + case "picture": + case "pictures": + $db->update(tbl("photos"),array('last_commented'),array(now()),"photo_id='$id'"); + break; + + case "t": + case "topic": + case "topics": + $db->update(tbl("group_topics"),array('last_post_time'),array(now()),"topic_id='$id'"); + break; + + } + } + } + + + + + /** + * Function used to check + * input users are valid or not + * so that only registere usernames can be set + */ + function video_users($users) + { + global $userquery; + $users_array = explode(',',$users); + $new_users = array(); + foreach($users_array as $user) + { + if($user!=username() && !is_numeric($user) && $userquery->user_exists($user)) + { + $new_users[] = $user; + } + } + + $new_users = array_unique($new_users); + + if(count($new_users)>0) + return implode(',',$new_users); + else + return " "; + } + + /** + * function used to check weather logged in user is + * is in video users or not + */ + function is_video_user($vdo,$user=NULL) + { + + if(!$user) + $user = username(); + if(is_array($vdo)) + $video_users = $vdo['video_users']; + else + $video_users = $vdo; + + + $users_array = explode(',',$video_users); + + if(in_array($user,$users_array)) + return true; + else + return false; + } + /** + * Function used display privacy in text + * according to provided number + * 0 - Public + * 1 - Protected + * 2 - Private + */ + function getGroupPrivacy($privacyID) + { + { + switch($privacyID) + { + case "0": default: + { + return lang("group_is_public"); + } + break; + + case "1": + { + return lang("group_is_protected"); + } + break; + + case "2": + { + return lang("group_is_private"); + } + break; + } + } + } + + /** + * Function used to create user feed + * this function simple takes ID as input + * and do the rest seemlessli ;) + */ + function addFeed($array) + { + global $cbfeeds,$cbphoto,$userquery; + + $action = $array['action']; + if($array['uid']) + $userid = $array['uid']; + else + $userid = userid(); + + switch($action) + { + case "upload_photo": + { + + $feed['action'] = 'upload_photo'; + $feed['object'] = 'photo'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid;; + + $cbfeeds->addFeed($feed); + } + break; + case "upload_video": + case "add_favorite": + { + + $feed['action'] = $action; + $feed['object'] = 'video'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid; + + $cbfeeds->addFeed($feed); + } + break; + + case "signup": + { + + $feed['action'] = 'signup'; + $feed['object'] = 'signup'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid;; + + $cbfeeds->addFeed($feed); + } + break; + + case "create_group": + case "join_group": + { + $feed['action'] = $action; + $feed['object'] = 'group'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid; + + $cbfeeds->addFeed($feed); + } + break; + + case "add_friend": + { + $feed['action'] = 'add_friend'; + $feed['object'] = 'friend'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid; + + $cbfeeds->addFeed($feed); + } + break; + + case "add_collection": + { + $feed['action'] = 'add_collection'; + $feed['object'] = 'collection'; + $feed['object_id'] = $array['object_id']; + $feed['uid'] = $userid; + + $cbfeeds->addFeed($feed); + } + + } + } + + /** + * function used to get plugin directory name + */ + function this_plugin($pluginFile=NULL) + { + if(!$pluginFile) + global $pluginFile; + return basename(dirname($pluginFile)); + } + + /** + * function used to create folder for video + * and files + */ + function createDataFolders() + { + $year = date("Y"); + $month = date("m"); + $day = date("d"); + $folder = $year.'/'.$month.'/'.$day; + @mkdir(VIDEOS_DIR.'/'.$folder,0777,true); + @mkdir(THUMBS_DIR.'/'.$folder,0777,true); + @mkdir(ORIGINAL_DIR.'/'.$folder,0777,true); + @mkdir(PHOTOS_DIR.'/'.$folder,0777,true); + + return $folder; + } + + + /** + * function used to get user agent details + * Thanks to ruudrp at live dot nl 28-Nov-2010 11:31 PHP.NET + */ + function get_browser_details($in=NULL,$assign=false) + { + //Checking if browser is firefox + if(!$in) + $in = $_SERVER['HTTP_USER_AGENT']; + + $u_agent = $in; + $bname = 'Unknown'; + $platform = 'Unknown'; + $version= ""; + + //First get the platform? + if (preg_match('/linux/i', $u_agent)) { + $platform = 'linux'; + } + elseif (preg_match('/iPhone/i', $u_agent)) { + $platform = 'iphone'; + } + elseif (preg_match('/iPad/i', $u_agent)) { + $platform = 'ipad'; + } + elseif (preg_match('/macintosh|mac os x/i', $u_agent)) { + $platform = 'mac'; + } + elseif (preg_match('/windows|win32/i', $u_agent)) { + $platform = 'windows'; + } + + // Next get the name of the useragent yes seperately and for good reason + if(preg_match('/MSIE/i',$u_agent) && !preg_match('/Opera/i',$u_agent)) + { + $bname = 'Internet Explorer'; + $ub = "MSIE"; + } + elseif(preg_match('/Firefox/i',$u_agent)) + { + $bname = 'Mozilla Firefox'; + $ub = "Firefox"; + } + elseif(preg_match('/Chrome/i',$u_agent)) + { + $bname = 'Google Chrome'; + $ub = "Chrome"; + } + elseif(preg_match('/Safari/i',$u_agent)) + { + $bname = 'Apple Safari'; + $ub = "Safari"; + } + elseif(preg_match('/Opera/i',$u_agent)) + { + $bname = 'Opera'; + $ub = "Opera"; + } + elseif(preg_match('/Netscape/i',$u_agent)) + { + $bname = 'Netscape'; + $ub = "Netscape"; + } + elseif(preg_match('/Googlebot/i',$u_agent)) + { + $bname = 'Googlebot'; + $ub = "bot"; + }elseif(preg_match('/msnbot/i',$u_agent)) + { + $bname = 'MSNBot'; + $ub = "bot"; + }elseif(preg_match('/Yahoo\! Slurp/i',$u_agent)) + { + $bname = 'Yahoo Slurp'; + $ub = "bot"; + } + + + // finally get the correct version number + $known = array('Version', $ub, 'other'); + $pattern = '#(?' . join('|', $known) . + ')[/ ]+(?[0-9.|a-zA-Z.]*)#'; + if (!@preg_match_all($pattern, $u_agent, $matches)) { + // we have no matching number just continue + } + + // see how many we have + $i = count($matches['browser']); + if ($i != 1) { + //we will have two since we are not using 'other' argument yet + //see if version is before or after the name + if (strripos($u_agent,"Version") < strripos($u_agent,$ub)){ + $version= $matches['version'][0]; + } + else { + $version= $matches['version'][1]; + } + } + else { + $version= $matches['version'][0]; + } + + // check if we have a number + if ($version==null || $version=="") {$version="?";} + + $array= array( + 'userAgent' => $u_agent, + 'name' => $bname, + 'version' => $version, + 'platform' => $platform, + 'bname' => strtolower($ub), + 'pattern' => $pattern + ); + + if($assign) assign($assign,$array); else return $array; + } + + function update_user_voted($array,$userid=NULL) + { + global $userquery; + return $userquery->update_user_voted($array,$userid); + } + + /** + * function used to delete vidoe from collections + */ + function delete_video_from_collection($vdetails) + { + global $cbvid; + $cbvid->collection->deleteItemFromCollections($vdetails['videoid']); + } + + + /** + * function used to check + * remote link is valid or not + */ + + function checkRemoteFile($url) + { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL,$url); + // don't download content + curl_setopt($ch, CURLOPT_NOBODY, 1); + curl_setopt($ch, CURLOPT_FAILONERROR, 1); + curl_setopt($ch, CURLOPT_HEADER, 1); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($ch); + if($result!==FALSE) + { + return true; + } + else + { + return false; + } + } + + + /** + * function used to get counts from + * cb_counter table + */ + function get_counter($section,$query) + { + if(!config('use_cached_pagin')) + return false; + + global $db; + + $timeRefresh = config('cached_pagin_time'); + $timeRefresh = $timeRefresh*60; + + $validTime = time()-$timeRefresh; + + unset($query['order']); + $je_query = json_encode($query); + $query_md5 = md5($je_query); + $select = $db->select(tbl('counters'),"*","section='$section' AND query_md5='$query_md5' + AND '$validTime' < date_added"); + if($db->num_rows>0) + { + return $select[0]['counts']; + }else + return false; + } + + /** + * function used to insert or update counter + */ + function update_counter($section,$query,$counter) + { + global $db; + unset($query['order']); + $je_query = json_encode($query); + $query_md5 = md5($je_query); + $count = $db->count(tbl('counters'),"*","section='$section' AND query_md5='$query_md5'"); + if($count) + { + $db->update(tbl('counters'),array('counts','date_added'),array($counter,strtotime(now())), + "section='$section' AND query_md5='$query_md5'"); + }else + { + $db->insert(tbl('counters'),array('section','query','query_md5','counts','date_added'), + array($section,'|no_mc|'.$je_query,$query_md5,$counter,strtotime(now()))); + } + } + + /** + * function used to register a module file, that will be later called + * by load_modules() function + */ + function register_module($mod_name,$file) + { + global $Cbucket; + $Cbucket->modules_list[$mod_name][] = $file; + + } + + /** + * function used to load module files + */ + function load_modules() + { + global $Cbucket,$lang_obj,$signup,$Upload,$cbgroup, + $adsObj,$formObj,$cbplugin,$eh,$sess,$cblog,$imgObj, + $cbvideo,$cbplayer,$cbemail,$cbpm,$cbpage,$cbindex, + $cbcollection,$cbphoto,$cbfeeds,$userquery,$db,$pages,$cbvid; + + foreach($Cbucket->modules_list as $cbmod) + { + foreach($cbmod as $modfile) + if(file_exists($modfile)) + include($modfile); + } + } + + + /** + * function used to verify user age + */ + function verify_age($dob) + { + $allowed_age = config('min_age_reg'); + if($allowed_age < 1) return true; + + $age_time = strtotime($dob); + $diff = time() - $age_time; + + $diff = $diff / 60 / 60 / 24 / 364; + + if($diff >= $allowed_age ) return true; + + return false; + } + + + include('functions_db.php'); +?> \ No newline at end of file diff --git a/upload/includes/functions_db.php b/upload/includes/functions_db.php new file mode 100644 index 00000000..6b3e171d --- /dev/null +++ b/upload/includes/functions_db.php @@ -0,0 +1,133 @@ +_select($query); +} + +function db_update($tbl, $fields, $cond) +{ + global $db; + + $count = 0; + foreach ($fields as $field => $val) { + + if ($count > 0) + $fields_query .= ','; + + + $needle = substr($val, 0, 2); + + if ($needle != '{{') + $value = "'" . filter_sql($val) . "'"; + else + { + $val = substr($val, 2, strlen($val) - 4); + $value = filter_sql($val); + } + + $fields_query .= $field . "=$value "; + $count++; + } + + //Complete Query + $query = "UPDATE $tbl SET $fields_query WHERE $cond $ep"; + //if(!mysql_query($query)) die($query.'
    '.mysql_error()); + $db->total_queries++; + $db->total_queries_sql[] = $query; + $db->Execute($query); + + if (mysql_error()) + die($db->db_query . '
    ' . mysql_error()); + + return true; +} + +function db_insert($tbl, $fields) +{ + global $db; + + $count = 0; + + $query_fields = array(); + $query_values = array(); + + + foreach ($fields as $field => $val) { + + $query_fields[] = $field; + + $needle = substr($val, 0, 2); + + if ($needle != '{{') + $query_values[] = "'" . filter_sql($val) . "'"; + else + { + $val = substr($val, 2, strlen($val) - 4); + $query_values[] = filter_sql($val); + } + + $count++; + } + + $fields_query = implode(',', $query_fields); + $values_query = implode(',', $query_values); + + + + + //Complete Query + $query = "INSERT INTO $tbl ($fields_query) VALUES ($values_query) $ep"; + + //if(!mysql_query($query)) die($query.'
    '.mysql_error()); + $db->total_queries++; + $db->total_queries_sql[] = $query; + $db->Execute($query); + + if (mysql_error()) + { + //if(LOG_DB_ERRORS) + + die($db->db_query . '
    ' . mysql_error()); + } + + return $db->insert_id(); +} + +function filter_sql($data) +{ + $data = mysql_real_escape_string($data); + return $data; +} + +/** + * Function used to count fields in mysql + * @param TABLE NAME + * @param Fields + * @param condition + */ +function dbcount($tbl, $fields = '*', $cond = false) +{ + global $db; + if ($cond) + $condition = " Where $cond "; + $query = "Select Count($fields) From $tbl $condition"; + $result = $db->Execute($query); + $db->total_queries++; + $db->total_queries_sql[] = $query; + $fields = $result->fields; + + if ($fields) + { + foreach ($fields as $field) + return $field; + } + return false; +} + +?> diff --git a/upload/includes/index.php b/upload/includes/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/includes/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/includes/langs/en.lang b/upload/includes/langs/en.lang new file mode 100644 index 00000000..3cd74efa --- /dev/null +++ b/upload/includes/langs/en.lang @@ -0,0 +1 @@ +{"ad_name_error":"Please enter a name for the Advertisment","ad_code_error":"Error : Please enter a code for the Advertisement","ad_exists_error1":"Advertisement does not exist","ad_exists_error2":"Error : Advertisement with this name already exist","ad_add_msg":"Advertisment was added succesfully","ad_msg":"Ad Has Been ","ad_update_msg":"Advertisment has been Updated","ad_del_msg":"Advertisement has been Deleted","ad_deactive":"Deactivated","ad_active":"Activated","ad_placment_delete_msg":"Placement has been Removed","ad_placement_err1":"Placement already exists","ad_placement_err2":"Please Enter a name for the Placement","ad_placement_err3":"Please Enter a Code for the Placement","ad_placement_msg":"Placement has been Added","cat_img_error":"Please Upload JPEG, GIF or PNG image only","cat_exist_error":"Category doesn’t exist","cat_add_msg":"Category has been added successfully","cat_update_msg":"Category has been updated","grp_err":"Group Doesn’t Exist","grp_fr_msg":"Group has been set as featured","grp_fr_msg1":"Selected Groups Have Been Removed From The Featured List","grp_ac_msg":"Selected Groups Have Been Activated","grp_dac_msg":"Selected Groups Have Been Dectivated","grp_del_msg":"Group has been deleted","editor_pic_up":"Video Has Been Moved Up","editor_pic_down":"Video Has Been Moved Down","plugin_install_msg":"Plugin has been installed","plugin_no_file_err":"No file was found","plugin_file_detail_err":"Unknown plugin details found","plugin_installed_err":"Plugin already installed","plugin_no_install_err":"Plugin is not installed","grp_name_error":"Please enter group name","grp_name_error1":"Group Name Already Exists","grp_des_error":"Please Enter A Little Description For The Group","grp_tags_error":"Please Enter Tags For The Group","grp_url_error":"Please enter valid url for the Group","grp_url_error1":"Please enter Valid URL name","grp_url_error2":"Group URL Already Exists, Please Choose a Different URL","grp_tpc_error":"Please enter a topic to add","grp_comment_error":"You must enter a comment","grp_join_error":"You have already joined this group","grp_prvt_error":"This Group Is Private, Please Login to View this Group","grp_inact_error":"This Group Is Inactive, Please Contact Administrator for the problem","grp_join_error1":"You Have Not Joined This Group Yet","grp_exist_error":"Sorry, Group Doesn’t Exist","grp_tpc_error1":"This Topic is not approved by the Group Owner","grp_cat_error":"Please Select A Category For Your group","grp_tpc_error2":"Please enter a topic to add","grp_tpc_error3":"Your Topic Requires Approval From The Owner Of This Group","grp_tpc_msg":"Topic has been added","grp_comment_msg":"Comment has been added","grp_vdo_msg":"Videos Deleted","grp_vdo_msg1":"Videos Added Successfully","grp_vdo_msg2":"Videos Have Been Approved","grp_mem_msg":"Member Has Been Deleted","grp_mem_msg1":"Member Has Been Approved","grp_inv_msg":"Your Invitation Has Been Sent","grp_tpc_msg1":"Topic has been deleted","grp_tpc_msg2":"Topic Has Been Approved","grp_fr_msg2":"Group has been removed from featured list","grp_inv_msg1":"Has Invited You To Join ","grp_av_msg":"Group has been activated","grp_da_msg":"Group has been deactivated","grp_post_msg":"Post Has Been Deleted","grp_update_msg":"Group has been updated","grp_owner_err":"Only Owner Can Add Videos To This Group","grp_owner_err1":"You are not owner of this group","grp_owner_err2":"You are the owner of this group. You cannot leave your group.","grp_prvt_err1":"This group is private, you need invitiation from its owner in order to join","grp_rmv_msg":"Selected Groups Have Been Removed From Your Account","grp_tpc_err4":"Sorry, Topic Doesn’t Exist","grp_title_topic":"Groups - Topic - ","grp_add_title":"- Add Video","usr_sadmin_err":"You Cannot Set SuperAdmin Username as Blank","usr_cpass_err":"Confirm Password Doesn’t Match","usr_pass_err":"Old password is incorrect","usr_email_err":"Please Provide A Valid Email Address","usr_cpass_err1":"Confirm password is incorrect","usr_pass_err1":"Password is Incorrect","usr_cmt_err":"You Must Login First To Comment","usr_cmt_err1":"Please Type Something In the Comment Box","usr_cmt_err2":"You cannot comment on your video","usr_cmt_err3":"You Have Already Posted a Comment on this channel.","usr_cmt_err4":"Comment Has Been Added","usr_cmt_del_msg":"Comment Has Been Deleted","usr_cmt_del_err":"An Error Occured While deleting a Comment","usr_cnt_err":"You Cannot Add Yourself as a Contact","usr_cnt_err1":"You Have Already Added This User To Your Contact List","usr_sub_err":"You are already subscribed to %s","usr_exist_err":"User Doesnt Exist","usr_ccode_err":"Verification code you entered was wrong","usr_exist_err1":"Sorry, No User Exists With This Email","usr_exist_err2":"Sorry , User Doesn't Exist","usr_uname_err":"Username is empty","usr_uname_err2":"Username already exists","usr_pass_err2":"Password Is Empty","usr_email_err1":"Email is Empty","usr_email_err2":"Please Enter A Valid Email Address","usr_email_err3":"Email Address Is Already In Use","usr_pcode_err":"Postal Codes Only Contain Numbers","usr_fname_err":"First Name Is Empty","usr_lname_err":"Last Name Is Empty","usr_uname_err3":"Username Contains Unallowed Characters","usr_pass_err3":"Passwords MisMatched","usr_dob_err":"Please Select Date Of Birth","usr_ament_err":"Sorry, you need to agree to the terms of use and privacy policy to create an account","usr_reg_err":"Sorry, Registrations Are Temporarily Not Allowed, Please Try Again Later","usr_ban_err":"User account is banned, please contact website administrator","usr_login_err":"Username and Password Didn’t Match","usr_sadmin_msg":"Super Admin Has Been Updated","usr_pass_msg":"Your Password Has Been Changed","usr_cnt_msg":"This User Has Been Added To Your Contact List","usr_sub_msg":"You are now subsribed to %s","usr_uname_email_msg":"We Have Sent you an Email containing Your Username, Please Check It","usr_rpass_email_msg":"An Email Has Been Sent To You. Please Follow the Instructions there to Reset Your Password","usr_pass_email_msg":"Password has been changed successfully","usr_email_msg":"Email Settings Has Been Updated","usr_del_msg":"User has been deleted","usr_dels_msg":"Selected Users Have Been Deleted","usr_ac_msg":"User has been activated","usr_dac_msg":"User has been deactivated","usr_mem_ac":"Selected Members Have Been Activated","usr_mems_ac":"Selected Members Have Been Deactivated","usr_fr_msg":"User Has Been Made a Featured Member","usr_ufr_msg":"User Has Been Unfeatured","usr_frs_msg":"Selected Users Have Been Set As Featured","usr_ufrs_msg":"Selected Users Have Been Removed From The Featured List","usr_uban_msg":"User Has Been Banned","usr_uuban_msg":"User Has Been Unbanned","usr_ubans_msg":"Selected Members Have Been Banned","usr_uubans_msg":"Selected Members Have Been Unbanned","usr_pass_reset_conf":"Password Reset Confirmation","usr_dear_user":"Dear User","usr_pass_reset_msg":"You Requested A Password Reset, Follow The Link To Reset Your Password","usr_rpass_msg":"Password Has Been Reset","usr_rpass_req_msg":"You Requested A Password Reset, Here is your new password : ","usr_uname_req_msg":"You Requested to Recover Your Username, Here is your username: ","usr_uname_recovery":"Username Recovery Email","usr_add_succ_msg":"User Has Been Added","usr_upd_succ_msg":"User has been updated","usr_activation_msg":"Your account has been activated. Now you can login to your account and upload videos","usr_activation_err":"This user is already activated","usr_activation_em_msg":"We have sent you an email containing your activation code, please check your mail box","usr_activation_em_err":"Email Doesn’t Exist or a User With This Email is already Activated","usr_no_msg_del_err":"No Message Was Selected To Delete","usr_sel_msg_del_msg":"Selected Messages Have Been Deleted","usr_pof_upd_msg":"Profile has been updated","usr_arr_no_ans":"no answer","usr_arr_elementary":"Elementary","usr_arr_hi_school":"High School","usr_arr_some_colg":"Some College","usr_arr_assoc_deg":"Associates Degree","usr_arr_bach_deg":"Bachelor’s Degree","usr_arr_mast_deg":"Master’s Degree","usr_arr_phd":"Ph.D.","usr_arr_post_doc":"Postdoctoral","usr_arr_single":"Single","usr_arr_married":"Married","usr_arr_comitted":"Comitted","usr_arr_open_marriage":"Open Marriage","usr_arr_open_relate":"Open Relationship","title_crt_new_msg":"Compose New Message","title_forgot":"Forgot Something? Find it now !","title_inbox":" - Inbox","title_sent":" - Sent Folder","title_usr_contact":"’s Contact List","title_usr_fav_vids":"%s\u2019s Favorite Videos","title_view_channel":"’s Channel","title_edit_video":"Edit Video - ","vdo_title_err":"Please Enter Video Title","vdo_des_err":"Please Enter Video Description","vdo_tags_err":"Please Enter Tags For The Video","vdo_cat_err":"Please Choose Atleast 1 Category","vdo_cat_err1":"You Can Only Choose Up to 3 Categories","vdo_sub_email_msg":" and therefore this message is sent to you automatically that ","vdo_has_upload_nv":"Has Uploaded New Video","vdo_del_selected":"Selected Videos Have Been Deleted","vdo_cheat_msg":"Please Don't Try To Cheat","vdo_limits_warn_msg":"Please Don't Try To Cross Your Limits","vdo_cmt_del_msg":"Comment Has Been Deleted","vdo_iac_msg":"Video Is Inactive - Please Contact Admin For Details","vdo_is_in_process":"Video Is Being Processed - Please Contact Administrator for further details","vdo_upload_allow_err":"Uploading Is Not Allowed By Website Owner","vdo_download_allow_err":"Video Downloading Is Not Allowed","vdo_edit_owner_err":"You Are Not Video Owner","vdo_embed_code_wrong":"Embed Code Was Wrong","vdo_seconds_err":"Wrong Value Entered For Seconds Field","vdo_mins_err":"Wrong Value Entered For Minutes Field","vdo_thumb_up_err":"Error In Uploading Thumb","class_error_occured":"Sorry, An Error Occured","class_cat_del_msg":"Category has been deleted","class_vdo_del_msg":"Video has been deleted","class_vdo_fr_msg":"Video has been marked as “Featured Video”","class_fr_msg1":"Video has been removed from “Featured Videos”","class_vdo_act_msg":"Video has been activated","class_vdo_act_msg1":"Vidoe has been deactivated","class_vdo_update_msg":"Video details have been updated","class_comment_err":"You Must Login Before Postings Comments","class_comment_err1":"Please Type Something In The Comment Box","class_comment_err2":"You Cannot Post a Comment on Your Own Video","class_comment_err3":"You Have Already Posted a Comment, Please Wait for the others.","class_comment_err4":"You Have Already Replied To That a Comment, Please Wait for the others.","class_comment_err5":"You Cannot Post a Reply To Yourself","class_comment_msg":"Comment Has Been Added","class_comment_err6":"Please login to rate comment","class_comment_err7":"You have already rated this comment","class_vdo_fav_err":"This Video is Already Added To Your Favorites","class_vdo_fav_msg":"This Video Has Been Added To Your Favorites","class_vdo_flag_err":"You Have Already Flagged This Video","class_vdo_flag_msg":"This Video Has Been Flagged As Inappropriate","class_vdo_flag_rm":"Flag(s) Has\/Have Been Removed","class_send_msg_err":"Please Enter a Username or Select any User to Send Message","class_invalid_user":"Invalid Username","class_subj_err":"Message subject was empty","class_msg_err":"Please Type Something In Message Box","class_sent_you_msg":"Sent You A Message","class_sent_prvt_msg":"Sent You A Private Message on ","class_click_inbox":"Please Click here To View Your Inbox","class_click_login":"Click Here To Login","class_email_notify":"Email Notification","class_msg_has_sent_to":"Message Has Been Sent To ","class_inbox_del_msg":"Message Has Been Delete From Inbox ","class_sent_del_msg":"Message Has Been Delete From Sent Folder","class_msg_exist_err":"Message Doesn't Exist","class_vdo_del_err":"Video does not exist","class_unsub_msg":"You have been unsubscribed sucessfully","class_sub_exist_err":"Subscription Does Not Exist","class_vdo_rm_fav_msg":"Video Has Been Removed From Favourites","class_vdo_fav_err1":"This Video Is Not In Your Favourites List","class_cont_del_msg":"Contact Has Been Deleted","class_cot_err":"Sorry, This Contact Is Not In Your Contact List","class_vdo_ep_add_msg":"Video Has Been Added To Editor’s Pick","class_vdo_ep_err":"Video Is Already In The Editor’s Pick","class_vdo_ep_err1":"You Have Already Picked 10 Videos Please Delete Alteast One to Add More","class_vdo_ep_msg":"Video Has Been Removed From Editor’s Pick","class_vdo_exist_err":"Sorry, Video Doesn't Exist","class_img_gif_err":"Please Upload Gif Image Only","class_img_png_err":"Please Upload Png Image Only","class_img_jpg_err":"Please Upload Jpg Image Only","class_logo_msg":"Logo Has Been Changed. Please Clear Cache If You Are Not Able To See the Changed Logo","com_forgot_username":"Forgot Username | Password","com_join_now":"Join Now","com_my_account":"My Account","com_manage_vids":"Manage Videos","com_view_channel":"View My Channel","com_my_inbox":"My Inbox","com_welcome":"Welcome","com_top_mem":"Top Members ","com_vidz":"Videos","com_sign_up_now":"Sign Up Now !","com_my_videos":"My Videos","com_my_channel":"My Channel","com_my_subs":"My Subscriptions","com_user_no_contacts":"User Does Not Have Any Contact","com_user_no_vides":"User Does Not Have Any Favourite Video","com_user_no_vid_com":"User Has No Video Comments","com_view_all_contacts":"View All Contacts of","com_view_fav_all_videos":"View All Favourite Videos Of","com_login_success_msg":"You Have Been Successfully Logged In.","com_logout_success_msg":"You Have Been Successfully Logged Out.","com_not_redirecting":"You are now Redirecting .","com_not_redirecting_msg":"if your are not redirecting","com_manage_contacts":"Manage Contacts ","com_send_message":"Send Message","com_manage_fav":"Manage Favorites ","com_manage_subs":"Manage Subscriptions","com_subscribe_to":"Subscribe to %s’s channel","com_total_subs":"Total Subscribtions","com_total_vids":"Total Videos","com_date_subscribed":"Date Subscribed","com_search_results":"Search Results","com_advance_results":"Advanced Search","com_search_results_in":"Search Results In","videos_being_watched":"Recently Viewed...","latest_added_videos":"Recent Additions","most_viewed":"Most Viewed","recently_added":"Recently Added","featured":"Featured","highest_rated":"Highest Rated","most_discussed":"Most Discussed","style_change":"Style Change","rss_feed_latest_title":"RSS Feed for Most Recent Videos","rss_feed_featured_title":"RSS Feed for Featured Videos","rss_feed_most_viewed_title":"RSS Feed for Most Popular Videos","lang_folder":"en","reg_closed":"Registration Closed","reg_for":"Registration for","is_currently_closed":"is currently closed","about_us":"About Us","account":"Account","added":"Added","advertisements":"Advertisements","all":"All","active":"Active","activate":"Activate","age":"Age","approve":"Approve","approved":"Approved","approval":"Approval","books":"Books","browse":"Browse","by":"by","cancel":"Cancel","categories":"Categories","category":"Category","channels":"channels","check_all":"Check All","click_here":"Click Here","comments":"Comments","community":"Community","companies":"Companies","contacts":"Contacts","contact_us":"Contact Us","country":"Country","created":"Created","date":"Date","date_added":"Date Added","date_joined":"Date Joined","dear":"Dear","delete":"Delete","delete_selected":"Delete Selected","des_title":"Description:","duration":"Duration","education":"Education","email":"email","embed":"Embed","embed_code":"Embed Code","favourite":"Favorite","favourited":"Favorited","favourites":"Favorites","female":"Female","filter":"Filter","forgot":"Forgot","friends":"Friends","from":"From","gender":"Gender","groups":"Groups","hello":"Hello","help":"Help","hi":"Hi","hobbies":"Hobbies","Home":"Home","inbox":"Inbox","interests":"Interests","join_now":"Join Now","joined":"Joined","join":"Join","keywords":"Keywords","latest":"Latest","leave":"Leave","location":"Location","login":"Login","logout":"Logout","male":"Male","members":"Members","messages":"Messages","message":"Message","minutes":"minutes","most_members":"Most Members","most_recent":"Most Recent","most_videos":"Most Videos","music":"Music","my_account":"My Account","next":"Next","no":"No","no_user_exists":"No User Exists","no_video_exists":"No Video Exists","occupations":"Occupations","optional":"optional","owner":"Owner","password":"password","please":"Please","privacy":"Privacy","privacy_policy":"Privacy Policy","random":"Random","rate":"Rate","request":"Request","related":"Related","reply":"Reply","results":"Results","relationship":"Relationship","seconds":"seconds","select":"Select","send":"Send","sent":"Sent","signup":"Signup","subject":"Subject","tags":"Tags","times":"Times","to":"To","type":"Type","update":"Update","upload":"Upload","url":"Url","verification":"Verification","videos":"Videos","viewing":"Viewing","welcome":"Welcome","website":"Website","yes":"Yes","of":"of","on":"on","previous":"Previous","rating":"Rating","ratings":"Ratings","remote_upload":"Remote Upload","remove":"Remove","search":"Search","services":"Services","show_all":"Show All","signupup":"Sign Up","sort_by":"Sort","subscriptions":"Subscriptions","subscribers":"Subscribers","tag_title":"Tags","time":"time","top":"Top","tos_title":"Terms of Use","username":"Username","views":"Views","proccession_wait":"Processing, Please Wait","mostly_viewed":"Most Viewed","most_comments":"Most Comments","group":"Group","not_logged_in":"You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:","fill_auth_form":"You are not logged in. Fill in the form below and try again.","insufficient_privileges":"You may not have sufficient privileges to access this page.","admin_disabled_you":"The site administrator may have disabled your account, or it may be awaiting activation.","Recover_Password":"Recover Password","Submit":"Submit","Reset_Fields":"Reset Fields","admin_reg_req":"The administrator may have required you to register before you can view this page.","lang_change":"Language Change","lang_changed":"Your language has been changed","lang_choice":"Language","if_not_redir":"Click here to continue if you are not automatically redirected.","style_changed":"Your style has been changed","style_choice":"Style","vdo_edit_vdo":"Edit Video","vdo_stills":"Video Stills","vdo_watch_video":"Watch Video","vdo_video_details":"Video Details","vdo_title":"Title","vdo_desc":"Description","vdo_cat":"Video Category","vdo_cat_msg":"You May Select Up To %s Categories","vdo_tags_msg":"Tags are separated by commas ie Arslan Hassan, Awesome, ClipBucket","vdo_br_opt":"Broadcast Options","vdo_br_opt1":"Public - Share your video with Everyone! (Recommended)","vdo_br_opt2":"Private - Viewable by you and your friends only.","vdo_date_loc":"Date And Location","vdo_date_rec":"Date Recorded","vdo_for_date":"format MM \/ DD \/ YYYY ","vdo_add_eg":"e.g London Greenland, Sialkot Mubarak Pura","vdo_share_opt":"Sharing and privacy options","vdo_allow_comm":"Allow Comments ","vdo_dallow_comm":"Do Not Allow Comments","vdo_comm_vote":"Comments Voting","vdo_allow_com_vote":"Allow Voting on Comments","vdo_dallow_com_vote":"Do Not Allow on Comments","vdo_allow_rating":"Yes, Allow Rating on this video","vdo_dallow_ratig":"No, Do Not Allow Rating on this video","vdo_embedding":"Embedding","vdo_embed_opt1":"Yes, People can play this video on other websites","vdo_embed_opt2":"No, People cannot play this video on other websites","vdo_update_title":"Update","vdo_inactive_msg":"Your Account is Inactive. Please Activate it to Upload Videos, To Activate your account Please","vdo_click_here":"Click Here","vdo_continue_upload":"Continue to Upload","vdo_upload_step1":"Video Upload","vdo_upload_step2":"Video Step %s\/2","vdo_upload_step3":"(Step 2\/2)","vdo_select_vdo":"Select a video to upload.","vdo_enter_remote_url":"Enter Url Of The Video.","vdo_enter_embed_code_msg":"Enter Embed Video Code from other websites ie Youtube or Metacafe.","vdo_enter_embed_code":"Enter Embed Code","vdo_enter_druation":"Enter Duration","vdo_select_vdo_thumb":"Select Video Thumb","vdo_having_trouble":"Having Trouble?","vdo_if_having_problem":"if you are having problems with the uploader","vdo_clic_to_manage_all":"Click Here To Manage All Videos","vdo_manage_vdeos":"Manage Videos ","vdo_status":"Status","vdo_rawfile":"RawFile","vdo_video_upload_complete":"Video Upload - Upload Complete","vdo_thanks_you_upload_complete_1":"Thank you! Your upload is complete","vdo_thanks_you_upload_complete_2":"This video will be available in","vdo_after_it_has_process":"after it has finished processing.","vdo_embed_this_video_on_web":"Embed this video on your website.","vdo_copy_and_paste_the_code":"Copy and paste the code below to embed this video.","vdo_upload_another_video":"Upload Another Video","vdo_goto_my_videos":"Goto My Videos","vdo_sperate_emails_by":"seperate emails by commas","vdo_personal_msg":"Personal Message","vdo_related_tags":"Related Tags","vdo_reply_to_this":"Reply To This ","vdo_add_reply":"Add Reply","vdo_share_video":"Share Video","vdo_about_this_video":"About This Video","vdo_post_to_a_services":"Post to an Aggregating Service","vdo_commentary":"Commentary","vdo_post_a_comment":"Post A Comment","grp_add_vdo_msg":"Add Videos To Group ","grp_no_vdo_msg":"You Don’t Have Any Video","grp_add_to":"Add To Group","grp_add_vdos":"Add Videos","grp_name_title":"Group name","grp_tag_title":"Tags:","grp_des_title":"Description:","grp_tags_msg":"Enter one or more tags, separated by spaces.","grp_tags_msg1":"Enter one or more tags, separated by spaces. Tags are keywords used to describe your group so it can be easily found by other users. For example, if you have a group for surfers, you might tag it: surfing, beach, waves.","grp_url_title":"Choose a unique group name URL:","grp_url_msg":"Enter 3-18 characters with no spaces (such as “skateboarding skates”), that will become part of your group’s web address. Please note, the group name URL you pick is permanent and can’t be changed.","grp_cat_tile":"Group Category:","grp_vdo_uploads":"Video Uploads:","grp_forum_posting":"Forum Posting:","grp_join_opt1":"Public, anyone can join.","grp_join_opt2":"Protected, requires founder approval to join.","grp_join_opt3":"Private, by founder invite only, only members can view group details.","grp_vdo_opt1":"Post videos immediately.","grp_vdo_opt2":"Founder approval required before video is available.","grp_vdo_opt3":"Only Founder can add new videos.","grp_post_opt1":"Post topics immediately.","grp_post_opt2":"Founder approval required before topic is available.","grp_post_opt3":"Only Founder can create a new topic.","grp_crt_grp":"Create Group","grp_thumb_title":"Group Thumb","grp_upl_thumb":"Upload Group Thumb","grp_must_be":"Must Be","grp_90x90":"90 x 90 Ratio Will Give Best Quality","grp_thumb_warn":"Do Not Upload Vulgar or Copyrighted Material","grp_del_confirm":"Are You Sure You Want To Delete This Group","grp_del_success":"You Have Successfully Deleted","grp_click_go_grps":"Click Here To Go To Groups","grp_edit_grp_title":"Edit Group","grp_manage_vdos":"Manage Videos","grp_manage_mems":"Manage Members","grp_del_group_title":"Delete Group","grp_add_vdos_title":"Add Videos","grp_join_grp_title":"Join Group","grp_leave_group_title":"Leave Group","grp_invite_grp_title":"Invite Members","grp_view_mems":"View Members","grp_view_vdos":"View Videos","grp_create_grp_title":"Create A New Group","grp_most_members":"Most Members","grp_most_discussed":"Most Discussed","grp_invite_msg":"Invite Users To This Group","grp_invite_msg1":"Has Invited You To Join","grp_invite_msg2":"Enter Emails or Usernames (seperate by commas)","grp_url_title1":"Group url","grp_invite_msg3":"Send Invitation","grp_join_confirm_msg":"Are You Sure You Want To Join This Group","grp_join_msg_succ":"You have successfully joined group","grp_click_here_to_go":"Click Here To Go To","grp_leave_confirm":"Are You Sure You Want To Leave This Group","grp_leave_succ_msg":"You have left the group","grp_manage_members_title":"Manage Members ","grp_for_approval":"For Approval","grp_rm_videos":"Remove Videos","grp_rm_mems":"Remove Members","grp_groups_title":"Manage Groups","grp_remove_group":"Remove Group","grp_bo_grp_found":"No Group Found","grp_joined_groups":"Joined Groups","grp_owned_groups":"Owned Groups","grp_edit_this_grp":"Edit This Group","grp_topics_title":"Topics","grp_topic_title":"Topic","grp_posts_title":"Posts","grp_discus_title":"Discussions","grp_author_title":"Author","grp_replies_title":"Replies","grp_last_post_title":"Last Post ","grp_viewl_all_videos":"View All Videos of This Group","grp_add_new_topic":"Add New Topic","grp_attach_video":"Attach Video ","grp_add_topic":"Add Topic","grp_please_login":"Please login to post topics","grp_please_join":"Please Join This Group To Post Topics","grp_inactive_account":"Your Account Is Inactive And Requires Activation From The Group Owner","grp_about_this_grp":"About This Group ","grp_no_vdo_err":"This Group Has No Vidoes","grp_posted_by":"Posted by","grp_add_new_comment":"Add New Comment","grp_add_comment":"Add Comment","grp_pls_login_comment":"Please Login To Post Comments","grp_pls_join_comment":"Please Join This Group To Post Comments","usr_activation_title":"User Activation","usr_actiavation_msg":"Enter Your Username and Activation Code that has been sent to your email.","usr_actiavation_msg1":"Request Activation Code","usr_activation_code_tl":"Activation Code","usr_compose_msg":"Compose Message","usr_inbox_title":"Inbox","usr_sent_title":"Sent","usr_to_title":"To: (Enter Username)","usr_or_select_frm_list":"or select from contact list","usr_attach_video":"Attach Video","user_attached_video":"Attached Video","usr_send_message":"Send Message","user_no_message":"No Message","user_delete_message_msg":"Delete This Message","user_forgot_message":"Forgot password","user_forgot_message_2":"Dont Worry, recover it now","user_pass_reset_msg":"Password Reset","user_pass_forgot_msg":"if you have forgot your password, please enter you username and verification code in the box, and password reset instructions will be sent to your mail box.","user_veri_code":"Verification Code","user_reocover_user":"Recover Username","user_user_forgot_msg":"Forgot Username?","user_recover":"Recover","user_reset":"Reset","user_inactive_msg":"Your account is inactive, please activate your account by going to activation page<\/a>","user_dashboard":"Dash Board","user_manage_prof_chnnl":"Manage Profile & Channel","user_manage_friends":"Manage Friends & Contacts","user_prof_channel":"Profile\/Channel","user_message_box":"Message Box","user_new_messages":"New Messages","user_goto_inbox":"Go to Inbox","user_goto_sentbox":"Go to Sent Box","user_compose_new":"Compose New Messages","user_total_subs_users":"Total Subscribed Users","user_you_have":"You Have","user_fav_videos":"Favorite Videos","user_your_vids_watched":"Your Videos Watched","user_times":"Times","user_you_have_watched":"You Have Watched","user_channel_profiles":"Channel & Profile","user_channel_views":"Channel Views","user_channel_comm":"Channel Comments ","user_manage_prof":"Manage Profile \/ Channel","user_you_created":"You Have Created","user_you_joined":"You Have Joined","user_create_group":"Create New Group","user_manage_my_account":"Manage My Account ","user_manage_my_videos":"Manage My Videos","user_manage_my_channel":"Manage My Channel","user_sent_box":"My sent items","user_manage_channel":"Manage Channel","user_manage_my_contacts":"Manage My Contacts","user_manage_contacts":"Manage Contacts","user_manage_favourites":"Manage Favourite Videos","user_mem_login":"Members Login","user_already_have":"Please Login Here if You Already have an account of","user_forgot_username":"Forgot Username","user_forgot_password":"Forgot Password","user_create_your":"Create Your ","user_all_fields_req":"All Fields Are Required","user_valid_email_addr":"Valid Email Address","user_allowed_format":"Letters A-Z or a-z , Numbers 0-9 and Underscores _","user_confirm_pass":"Confirm Password","user_reg_msg_0":"Register as ","user_reg_msg_1":"member, its free and easy just fill out the form below","user_date_of_birth":"Date Of Birth","user_enter_text_as_img":"Enter Text As Seen In The Image","user_refresh_img":"Refresh Image","user_i_agree_to_the":"I Agree to Terms of Service<\/a> and Privacy Policy","user_thanks_for_reg":"Thank You For Registering on ","user_email_has_sent":"An email has been sent to your inbox containing Your Account","user_and_activation":"& Activation","user_details_you_now":"Details. You may now do the following things on our network","user_upload_share_vds":"Upload, Share Videos","user_make_friends":"Make Friends","user_send_messages":"Send Messages","user_grow_your_network":"Grow Your Networks by Inviting more Friends","user_rate_comment":"Rate and Comment Videos","user_make_customize":"Make and Customize Your Channel","user_to_upload_vid":"To Upload Video, You Need to Activate your account first, activation details has been sent to your email account, it may take sometimes to reach your inbox","user_click_to_login":"Click here To Login To Your Account","user_view_my_channel":"View My Channel","user_change_pass":"Change Password","user_email_settings":"Email Settings","user_profile_settings":"Profile Settings","user_usr_prof_chnl_edit":"User Profile & Channel Edit","user_personal_info":"Personal Information","user_fname":"First Name","user_lname":"Last Name","user_gender":"Gender","user_relat_status":"Relationship Status","user_display_age":"Display Age","user_about_me":"About Me","user_website_url":"Website Url","user_eg_website":"e.g www.cafepixie.com","user_prof_info":"Professional Information","user_education":"Education","user_school_colleges":"Schools \/ Colleges","user_occupations":"Occupation(s)","user_companies":"Companies","user_sperate_by_commas":"seperate with commas","user_interests_hobbies":"Interests and Hobbies","user_fav_movs_shows":"Favorite Movies & Shows","user_fav_music":"Favorite Music","user_fav_books":"Favorite Books","user_user_avatar":"User Avatar","user_upload_avatar":"Upload Avatar","user_channel_info":"Channel Info","user_channel_title":"Channel Title","user_channel_description":"Channel Description","user_channel_permission":"Channel Permissions","user_allow_comments_msg":"users can comment","user_dallow_comments_msg":"users cannot comment","user_allow_rating":"Allow Rating","user_dallow_rating":"Do Not Allow Rating","user_allow_rating_msg1":"users can rate","user_dallow_rating_msg1":"users cannot rate","user_channel_feature_vid":"Channel Featured Video","user_select_vid_for_fr":"Select Video To set as Featured","user_chane_channel_bg":"Change Channel Background","user_remove_bg":"Remove Background","user_currently_you_d_have_pic":"Currently You Don’t Have a Background Picture","user_change_email":"Change Email","user_email_address":"Email Address","user_new_email":"New Email","user_notify_me":"Notify Me When User Sends Me A Message","user_old_pass":"Old Password","user_new_pass":"New Password","user_c_new_pass":"Confirm New Password","user_doesnt_exist":"User Doesn’t Exist","user_do_not_have_contact":"User Does Not Have Any Contacts","user_no_fav_video_exist":"User does not have any Favorite Videos selected","user_have_no_vide":"User doesn't have any videos","user_s_channel":"%s’s Channel ","user_last_login":"Last Login","user_send_message":"Send Message","user_add_contact":"Add Contact","user_dob":"DoB","user_movies_shows":"Movies & Shows","user_add_comment":"Add Comment ","user_view_all_comments":"View All Comments","user_no_fr_video":"User Has Not Selected Any Video To Set As Featured","user_view_all_video_of":"View All Videos of ","menu_home":"Home","menu_videos":"Videos","menu_upload":"Upload","menu_signup":"SignUp","menu_account":"Account","menu_groups":"Groups","menu_channels":"Channels","menu_community":"Community","menu_inbox":"Inbox","vdo_cat_err2":"You cannot select more than %d categories","user_subscribe_message":"Hello %subscriber%\nYou Have Subscribed To %user% and therefore this message is sent to you automatically, because %user% Has Uploaded a New Video\n\n%website_title%","user_subscribe_subject":"%user% has uploaded a new video","you_already_logged":"You are already logged in","you_not_logged_in":"You are not logged in","invalid_user":"Invalid User","vdo_cat_err3":"Please select at least 1 category","embed_code_invalid_err":"Invalid video embed code","invalid_duration":"Invalid duration","vid_thumb_changed":"Video default thumb has been changed","vid_thumb_change_err":"Video thumbnail was not found","upload_vid_thumbs_msg":"All video thumbs have been uploaded","video_thumb_delete_msg":"Video thumb has been deleted","video_thumb_delete_err":"Could not delete video thumb","no_comment_del_perm":"You dont have permission to delete this comment","my_text_context":"My test context","user_contains_disallow_err":"Username contains disallowed characters","add_cat_erro":"Category already exists","add_cat_no_name_err":"Please enter a name for the category","cat_default_err":"Default cannot be deleted, please choose another category as “default” and then delete this one","pic_upload_vali_err":"Please upload valid JPG, GIF or PNG image","cat_dir_make_err":"Unable to create the category thumb directory","cat_set_default_ok":"Category has been set as default","vid_thumb_removed_msg":"Video thumbs have been removed","vid_files_removed_msg":"Video files have been removed","vid_log_delete_msg":"Video log has been deleted","vdo_multi_del_erro":"Videos has have been deleted","add_fav_message":"This %s has been added to your favorites","obj_not_exists":"%s does not exist","already_fav_message":"This %s is already added to your favorites","obj_report_msg":"this %s has been reported","obj_report_err":"You have already reported this %s","user_no_exist_wid_username":"‘%s’ does not exist","share_video_no_user_err":"Please enter usernames or emails to send this %s","uploaded":"Uploaded","today":"Today","yesterday":"Yesterday","thisweek":"This Week","lastweek":"Last Week","thismonth":"This Month","lastmonth":"Last Month","thisyear":"This Year","lastyear":"Last Year","favorites":"Favorites","alltime":"All Time","insufficient_privileges_loggin":"You cannot access this page Click Here to Login or Register","profile_title":"Profile Title","show_dob":"Show Date of Birth","profile_tags":"Profile Tags","profile_desc":"Profile Description","online_status":"User Status","show_profile":"Show Profile","allow_ratings":"Allow Profile Ratings","postal_code":"Postal Code","temp_file_load_err":"Unable to load tempalte file ‘%s’ in directory ‘%s’","no_date_provided":"No date provided","second":"second","minute":"minute","bad_date":"Never","users_videos":"%s’s Videos","please_login_subscribe":"Please login to Subsribe %s","users_subscribers":"%s’s Subscribers","user_no_subscribers":"%s has no subsribers","user_subscriptions":"%s’s Subscriptions","user_no_subscriptions":"%s has no subscriptions","usr_avatar_bg_update":"User avatar and background have been updated","user_email_confirm_email_err":"Confirm email mismatched","email_change_msg":"Email has been changed successfully","no_edit_video":"You cannot edit this video","confirm_del_video":"Are you sure you want to delete this video ?","remove_fav_video_confirm":"Are you sure you want to remove this video from your favorites ?","fav_remove_msg":"%s has been removed from your favorites","unknown_favorite":"Unknown favorite %s","vdo_multi_del_fav_msg":"Videos have been removed from your favorites","unknown_sender":"Unknown Sender","please_enter_message":"Please enter something for message","unknown_reciever":"Unknown reciever","no_pm_exist":"Private message does not exist","pm_sent_success":"Private message has been sent successfully","msg_delete_inbox":"Message has been deleted from inbox","msg_delete_outbox":"Message has been deleted from your outbox","private_messags_deleted":"Private messages have been deleted","ban_users":"Ban Users","spe_users_by_comma":"separate usernames by comma","user_ban_msg":"User block list has been updated","no_user_ban_msg":"No user is banned from your account!","thnx_sharing_msg":"Thanks for sharing this %s","no_own_commen_rate":"You cannot rate your own comment","no_comment_exists":"Comment does not exist","thanks_rating_comment":"Thanks for rating comment","please_login_create_playlist":"Please login to creat playlists","play_list_with_this_name_arlready_exists":"Playlist with name ‘%s’ already exists","please_enter_playlist_name":"Please enter playlist name","new_playlist_created":"New playlist has been created","playlist_not_exist":"Playlist does not exist","playlist_item_not_exist":"Playlist item does not exist","playlist_item_delete":"Playlist item has been deleted","play_list_updated":"Playlist has been updated","you_dont_hv_permission_del_playlist":"You do not have permission to delete the playlist","playlist_delete_msg":"Playlist has been deleted","playlist_name":"Playlist Name","add_new_playlist":"Add Playlist","this_thing_added_playlist":"This %s has been added to playlist","this_already_exist_in_pl":"This %s already exists in your playlist","edit_playlist":"Edit Playlist","remove_playlist_item_confirm":"Are you sure you want to remove this from your playlist","remove_playlist_confirm":"Are you sure you want to delete this playlist?","avcode_incorrect":"Activation code is incorrect","group_join_login_err":"Please login in order to join this group","manage_playlist":"Manage playlist","my_notifications":"My notifications","users_contacts":"%s’s contacts","type_flags_removed":"%s flags have been removed","terms_of_serivce":"Terms of services","users":"Users","login_to_mark_as_spam":"Please login to mark as spam","no_own_commen_spam":"You cannot mark your own comment as spam","already_spammed_comment":"You have already marked this comment as spam","spam_comment_ok":"Comment has been marked as spam","arslan_hassan":"Arslan Hassan","you_not_allowed_add_grp_vids":"You are not member of this group so cannot add videos","sel_vids_updated":"Selected videos have been updated","unable_find_download_file":"Unable to find download file","you_cant_edit_group":"You cannot edit this group","you_cant_invite_mems":"You cannot invite members","you_cant_moderate_group":"You cannot moderate this group","page_doesnt_exist":"Page does not exist","pelase_select_img_file_for_vdo":"Please select image file for video thumb","new_mem_added":"New member has been added","this_vdo_not_working":"This video might not work properly","email_template_not_exist":"Email template does not exist","email_subj_empty":"Email subject was empty","email_msg_empty":"Email message was empty","email_tpl_has_updated":"Email Template has been updated","page_name_empty":"Page name was empty","page_title_empty":"Page title was empty","page_content_empty":"Page content was empty","new_page_added_successfully":"New page has been added successfully","page_updated":"Page has been updated","page_deleted":"Page has been deleted successfully","page_activated":"Page has been activated","page_deactivated":"Page has been deactivated","you_cant_delete_this_page":"You cannot delete this page","ad_placement_err4":"Placement does not exist","grp_details_updated":"Group details have been updated","you_cant_del_topic":"You cannot delete this topic","you_cant_del_user_topics":"You cannot delete user topics","topics_deleted":"Topics have been deleted","you_cant_delete_grp_topics":"You cannot delete group topics","you_not_allowed_post_topics":"You are not allowed to post topics","you_cant_add_this_vdo":"You cannot add this video","video_added":"Video has been added","you_cant_del_this_vdo":"You cannot remove this video","video_removed":"Video has been removed","user_not_grp_mem":"User is not group member","user_already_group_mem":"User has already joined this group","invitations_sent":"Invitations have been sent","you_not_grp_mem":"You are not a member of this group","you_cant_delete_this_grp":"You cannot delete this group","grp_deleted":"Group has been deleted","you_cant_del_grp_mems":"You cannot delete group members","mems_deleted":"Members have been deleted","you_cant_del_grp_vdos":"You cannot delete group videos","thnx_for_voting":"Thanks for voting","you_hv_already_rated_vdo":"You have already rated this video","please_login_to_rate":"Please login to rate","you_not_subscribed":"You are not subscribed","you_cant_delete_this_user":"You cannot delete this user”","you_dont_hv_perms":"You don't have sufficient permissions","user_subs_hv_been_removed":"User subscriptions have been removed","user_subsers_hv_removed":"User subscribers have been removed","you_already_sent_frend_request":"You have already sent friend request","friend_added":"Friend has been added","friend_request_sent":"Friend request has been sent","friend_confirm_error":"Either the user has not requested your friend request or you have already confirmed it","friend_confirmed":"Friend has been confirmed","friend_request_not_found":"No friend request found","you_cant_confirm_this_request":"You cannot confirm this request","friend_request_already_confirmed":"Friend request is already confirmed","user_no_in_contact_list":"User is not in your contact list","user_removed_from_contact_list":"User has been removed from your contact list","cant_find_level":"Cannot find level","please_enter_level_name":"Please enter level name","level_updated":"Level has been updated","level_del_sucess":"User level has been deleted, all users of this level has been transfered to %s","level_not_deleteable":"This level is not deletable","pass_mismatched":"Passwords Mismatched","user_blocked":"User has been blocked","user_already_blocked":"User is already blocked","you_cant_del_user":"You cannot block this user","user_vids_hv_deleted":"User videos have been deleted","user_contacts_hv_removed":"User contacts have been removed","all_user_inbox_deleted":"All User inbox messages have been deleted","all_user_sent_messages_deleted":"All user sent messages have been deleted","pelase_enter_something_for_comment":"Please type something in a comment box","please_enter_your_name":"Please enter your name","please_enter_your_email":"Please enter your email","template_activated":"Template has been activated","error_occured_changing_template":"An error occured while changing the template","phrase_code_empty":"Phrase code was empty","phrase_text_empty":"Phrase text was empty","language_does_not_exist":"Language does not exist","name_has_been_added":"%s has been added","name_already_exists":"‘%s’ already exist","lang_doesnt_exist":"language does not exist","no_file_was_selected":"No file was selected","err_reading_file_content":"Error reading file content","cant_find_lang_name":"Cant find language name","cant_find_lang_code":"Cant find language code","no_phrases_found":"No phrases were found","language_already_exists":"Language already exists","lang_added":"Language has been added successfully","error_while_upload_file":"Error occured while uploading language file","default_lang_del_error":"This is the default language, please select another language as “default” and then delete this pack","lang_deleted":"Language pack has been deleted","lang_name_empty":"Language name was empty","lang_code_empty":"Language code was empty","lang_regex_empty":"Language regular expression was empty","lang_code_already_exist":"Language code already exists","lang_updated":"Language has been updated","player_activated":"Player has been activated","error_occured_while_activating_player":"An error occured while activating player","plugin_has_been_s":"Plugin has been %s","plugin_uninstalled":"Plugin has been Uninstalled","perm_code_empty":"Permission code is empty","perm_name_empty":"Permission name is empty","perm_already_exist":"Permission already exists","perm_type_not_valid":"Permission type is not valid","perm_added":"New Permission has been added","perm_deleted":"Permission has been deleted","perm_doesnt_exist":"Permission does not exist","acitvation_html_message":"Please enter your username and activation code in order to activate your account, please check your inbox for the Activation code, if you didn't get one, please request it by filling the next form","acitvation_html_message2":"Please enter your email address to request your activation code","admin_panel":"Admin Panel","moderate_videos":"Moderate Videos","moderate_users":"Moderate Users","revert_back_to_admin":"Revert back to admin","more_options":"More Options","downloading_string":"Downloading %s ...","download_redirect_msg":"click here if you don't redirect automatically<\/a> - Click Here to Go Back to Video Page<\/a>","account_details":"Account Details","profile_details":"Profile Details","update_profile":"Update Profile","please_select_img_file":"Please select image file","or":"or","pelase_enter_image_url":"Please Enter Image URL","user_bg":"Channel Background","user_bg_img":"Channel Background Image","please_enter_bg_color":"Please Enter Background Color","bg_repeat_type":"Background Repeat Type (if using image as a background)","fix_bg":"Fix Background","delete_this_img":"Delete this image","current_email":"Current Email","confirm_new_email":"Confirm New Email","no_subs_found":"No subscriptions found","video_info_all_fields_req":"Video Information - All fields are required","update_group":"Update Group","default":"Default","grp_info_all_fields_req":"Group Information - All Fields Are Required","date_recorded_location":"Date recorded & Location","update_video":"Update Video","click_here_to_recover_user":"Click here to recover username","click_here_reset_pass":"Click here to reset password","remember_me":"Remember Me","howdy_user":"Howdy %s","notifications":"Notifications","playlists":"Playlists","friend_requests":"Friend Requests","after_meny_guest_msg":"Welcome Guest ! Please Login<\/a> or Register<\/a>","being_watched":"Being Watched","change_style_of_listing":"Change Style of Listing","website_members":"%s Members","guest_homeright_msg":"Watch, Upload, Share and more","reg_for_free":"Register for free","rand_vids":"Random Videos","t_10_users":"Top 10 Users","pending":"Pending","confirm":"Confirm","no_contacts":"No Contacts","you_dont_hv_any_grp":"You do not have any groups","leave_groups":"Leave Groups","manage_grp_mems":"Manage Group Members","pending_mems":"Pending Members","active_mems":"Active Members","disapprove":"Disapprove","manage_grp_vids":"Manage Group Videos","pending_vids":"Pending Videos","no_pending_vids":"No Pending Videos","no_active_videos":"No Active Videos","active_videos":"Active Videos","manage_playlists":"Manage Playlists","total_items":"Total Items","play_now":"PLAY NOW","no_video_in_playlist":"This playlist has no video","view":"View","you_dont_hv_fav_vids":"You do not have any favorite videos","private_messages":"Private Messages","new_private_msg":"New private message","search_for_s":"Search For %s","signup_success_usr_ok":"

    Just One More Step<\/h2> \t

    Your are just one step behind from becoming an official memeber of our website. Please check your email, we have sent you a confirmation email which contains a confirmation link from our website, Please click it to complete your registration.<\/p>","signup_success_usr_emailverify":"

    Welcome To our community<\/h2>\r\n \t

    Your email has been confirmed, Please click here to login<\/a><\/strong> and continue as our registered member.<\/p>","if_you_already_hv_account":"if you already have an account, please login here ","signup_message_under_login":"

    Our website is the home for video online:<\/p>\r\n \r\n

    • Watch<\/strong> millions of videos<\/li>
    • Share favorites<\/strong> with friends and family<\/li>\r\n
    • Connect with other users<\/strong> who share your interests<\/li>
    • Upload your videos<\/strong> to a worldwide audience\r\n\r\n<\/li><\/ul>","new_mems_signup_here":"New Members Signup Here","register_as_our_website_member":"Register as a member, it's free and easy just ","video_complete_msg":"

      Video Upload Has Been Completed<\/h2>\r\nThank you! Your upload is complete.<\/span>
      \r\nThis video will be available in
      My Videos<\/strong><\/a> after it has finished processing.<\/span> \r\n

    ";a.utils.setOuterHTML(f,v);t=document.getElementById(f.id)}else{var s=document.createElement("object");s.setAttribute("type","application/x-shockwave-flash");s.setAttribute("data",g.src);s.setAttribute("width","100%");s.setAttribute("height","100%");s.setAttribute("bgcolor","#000000");s.setAttribute("id",f.id);s.setAttribute("name",f.id);s.setAttribute("tabindex",0);m(s,"allowfullscreen","true");m(s,"allowscriptaccess","always");m(s,"seamlesstabbing","true");m(s,"wmode",p);m(s,"flashvars",c(q));f.parentNode.replaceChild(s,f);t=s}j.container=t;j.setPlayer(t,"flash")};this.supportsConfig=function(){if(a.utils.hasFlash()){if(l){var o=a.utils.getFirstPlaylistItemFromConfig(l);if(typeof o.file=="undefined"&&typeof o.levels=="undefined"){return true}else{if(o.file){return flashCanPlay(o.file,o.provider)}else{if(o.levels&&o.levels.length){for(var n=0;n0){j.skin=j.skin.replace(/\.zip/i,".xml")}var l=new (a.html5(c)).setup(j);f.container=document.getElementById(f.id);f.setPlayer(l,"html5")}else{return null}};this.supportsConfig=function(){if(!!a.vid.canPlayType){if(b){var j=a.utils.getFirstPlaylistItemFromConfig(b);if(typeof j.file=="undefined"&&typeof j.levels=="undefined"){return true}else{if(j.file){return html5CanPlay(a.vid,j.file,j.provider,j.playlistfile)}else{if(j.levels&&j.levels.length){for(var h=0;h0){D+=F.length;var J=F.indexOf("playlist"),I=F.indexOf("controlbar");if(J>=0&&I>=0){F[J]=F.splice(I,1,F[J])[0]}o(l,F,true)}}else{if(!(navigator&&navigator.vendor&&navigator.vendor.indexOf("Apple")==0)){o(B,G,true)}}y()}function o(J,G,H){var F=[];for(var E=0;E-1){percentage=parseFloat(x.width.substring(0,x.width.lastIndexOf("%")))/100;E=Math.round(window.innerWidth*percentage)}if(typeof x.height=="string"&&x.height.lastIndexOf("%")>-1){percentage=parseFloat(x.height.substring(0,x.height.lastIndexOf("%")))/100;F=Math.round(window.innerHeight*percentage)}return{position:"absolute",width:(E-d.parseDimension(s.style.left)-d.parseDimension(s.style.right)),height:(F-d.parseDimension(s.style.top)-d.parseDimension(s.style.bottom)),zIndex:H}}function B(E,F){return{position:"fixed",width:x.width,height:x.height,zIndex:F}}function y(){if(!d.exists(x.getMedia())){return}s.style.position="absolute";var H=x.getMedia().getDisplayElement();if(H&&H.tagName.toLowerCase()=="video"){H.style.position="absolute";var E,I;if(s.style.width.toString().lastIndexOf("%")>-1||s.style.width.toString().lastIndexOf("%")>-1){var F=s.getBoundingClientRect();E=Math.abs(F.left)+Math.abs(F.right);I=Math.abs(F.top)+Math.abs(F.bottom)}else{E=d.parseDimension(s.style.width);I=d.parseDimension(s.style.height)}if(H.parentNode){H.parentNode.style.left=s.style.left;H.parentNode.style.top=s.style.top}d.stretch(u.jwGetStretching(),H,E,I,H.videoWidth?H.videoWidth:400,H.videoHeight?H.videoHeight:300)}else{var G=x.plugins.object.display.getDisplayElement();if(G){x.getMedia().resize(d.parseDimension(G.style.width),d.parseDimension(G.style.height))}else{x.getMedia().resize(d.parseDimension(s.style.width),d.parseDimension(s.style.height))}}}function e(F){var G={position:"absolute",margin:0,padding:0,top:null};var E=x.plugins.config[F].currentPosition.toLowerCase();switch(E.toUpperCase()){case b.html5.view.positions.TOP:G.top=d.parseDimension(s.style.top);G.left=d.parseDimension(s.style.left);G.width=g-d.parseDimension(s.style.left)-d.parseDimension(s.style.right);G.height=x.plugins.object[F].height;s.style[E]=d.parseDimension(s.style[E])+x.plugins.object[F].height+"px";s.style.height=d.parseDimension(s.style.height)-G.height+"px";break;case b.html5.view.positions.RIGHT:G.top=d.parseDimension(s.style.top);G.right=d.parseDimension(s.style.right);G.width=x.plugins.object[F].width;G.height=C-d.parseDimension(s.style.top)-d.parseDimension(s.style.bottom);s.style[E]=d.parseDimension(s.style[E])+x.plugins.object[F].width+"px";s.style.width=d.parseDimension(s.style.width)-G.width+"px";break;case b.html5.view.positions.BOTTOM:G.bottom=d.parseDimension(s.style.bottom);G.left=d.parseDimension(s.style.left);G.width=g-d.parseDimension(s.style.left)-d.parseDimension(s.style.right);G.height=x.plugins.object[F].height;s.style[E]=d.parseDimension(s.style[E])+x.plugins.object[F].height+"px";s.style.height=d.parseDimension(s.style.height)-G.height+"px";break;case b.html5.view.positions.LEFT:G.top=d.parseDimension(s.style.top);G.left=d.parseDimension(s.style.left);G.width=x.plugins.object[F].width;G.height=C-d.parseDimension(s.style.top)-d.parseDimension(s.style.bottom);s.style[E]=d.parseDimension(s.style[E])+x.plugins.object[F].width+"px";s.style.width=d.parseDimension(s.style.width)-G.width+"px";break;default:break}return G}this.resize=j;this.fullscreen=function(H){if(navigator&&navigator.vendor&&navigator.vendor.indexOf("Apple")===0){if(x.getMedia().getDisplayElement().webkitSupportsFullscreen){if(H){try{x.getMedia().getDisplayElement().webkitEnterFullscreen()}catch(G){}}else{try{x.getMedia().getDisplayElement().webkitExitFullscreen()}catch(G){}}}}else{if(H){document.onkeydown=h;clearInterval(p);var F=document.body.getBoundingClientRect();x.width=Math.abs(F.left)+Math.abs(F.right);x.height=window.innerHeight;var E={position:"fixed",width:"100%",height:"100%",top:0,left:0,zIndex:2147483000};c(w,E);E.zIndex=1;if(x.getMedia()&&x.getMedia().getDisplayElement()){c(x.getMedia().getDisplayElement(),E)}E.zIndex=2;c(s,E)}else{document.onkeydown="";x.width=g;x.height=C;c(w,{position:"relative",height:x.height,width:x.width,zIndex:0})}j(x.width,x.height)}}};function a(e){return([b.html5.view.positions.TOP,b.html5.view.positions.RIGHT,b.html5.view.positions.BOTTOM,b.html5.view.positions.LEFT].toString().indexOf(e.toUpperCase())>-1)}b.html5.view.positions={TOP:"TOP",RIGHT:"RIGHT",BOTTOM:"BOTTOM",LEFT:"LEFT",OVER:"OVER",NONE:"NONE"}})(jwplayer);(function(a){var b={backgroundcolor:"",margin:10,font:"Arial,sans-serif",fontsize:10,fontcolor:parseInt("000000",16),fontstyle:"normal",fontweight:"bold",buttoncolor:parseInt("ffffff",16),position:a.html5.view.positions.BOTTOM,idlehide:false,layout:{left:{position:"left",elements:[{name:"play",type:"button"},{name:"divider",type:"divider"},{name:"prev",type:"button"},{name:"divider",type:"divider"},{name:"next",type:"button"},{name:"divider",type:"divider"},{name:"elapsed",type:"text"}]},center:{position:"center",elements:[{name:"time",type:"slider"}]},right:{position:"right",elements:[{name:"duration",type:"text"},{name:"blank",type:"button"},{name:"divider",type:"divider"},{name:"mute",type:"button"},{name:"volume",type:"slider"},{name:"divider",type:"divider"},{name:"fullscreen",type:"button"}]}}};_utils=a.utils;_css=_utils.css;_hide=function(c){_css(c,{display:"none"})};_show=function(c){_css(c,{display:"block"})};a.html5.controlbar=function(l,V){var k=l;var D=_utils.extend({},b,k.skin.getComponentSettings("controlbar"),V);if(D.position==a.html5.view.positions.NONE||typeof a.html5.view.positions[D.position]=="undefined"){return}if(_utils.mapLength(k.skin.getComponentLayout("controlbar"))>0){D.layout=k.skin.getComponentLayout("controlbar")}var ac;var P;var ab;var E;var v="none";var g;var j;var ad;var f;var e;var y;var Q={};var p=false;var c={};var Y;var h=false;var o;var d;var S=false;var G=false;var W=new a.html5.eventdispatcher();_utils.extend(this,W);function J(){if(!Y){Y=k.skin.getSkinElement("controlbar","background");if(!Y){Y={width:0,height:0,src:null}}}return Y}function N(){ab=0;E=0;P=0;if(!p){var ak={height:J().height,backgroundColor:D.backgroundcolor};ac=document.createElement("div");ac.id=k.id+"_jwplayer_controlbar";_css(ac,ak)}var aj=(k.skin.getSkinElement("controlbar","capLeft"));var ai=(k.skin.getSkinElement("controlbar","capRight"));if(aj){x("capLeft","left",false,ac)}var al={position:"absolute",height:J().height,left:(aj?aj.width:0),zIndex:0};Z("background",ac,al,"img");if(J().src){Q.background.src=J().src}al.zIndex=1;Z("elements",ac,al);if(ai){x("capRight","right",false,ac)}}this.getDisplayElement=function(){return ac};this.resize=function(ak,ai){_utils.cancelAnimation(ac);document.getElementById(k.id).onmousemove=A;e=ak;y=ai;if(G!=k.jwGetFullscreen()){G=k.jwGetFullscreen();d=undefined}var aj=w();A();I({id:k.id,duration:ad,position:j});u({id:k.id,bufferPercent:f});return aj};this.show=function(){if(h){h=false;_show(ac);T()}};this.hide=function(){if(!h){h=true;_hide(ac);aa()}};function q(){var aj=["timeSlider","volumeSlider","timeSliderRail","volumeSliderRail"];for(var ak in aj){var ai=aj[ak];if(typeof Q[ai]!="undefined"){c[ai]=Q[ai].getBoundingClientRect()}}}function A(ai){if(h){return}if(D.position==a.html5.view.positions.OVER||k.jwGetFullscreen()){clearTimeout(o);switch(k.jwGetState()){case a.api.events.state.PAUSED:case a.api.events.state.IDLE:if(!D.idlehide||_utils.exists(ai)){U()}if(D.idlehide){o=setTimeout(function(){z()},2000)}break;default:if(ai){U()}o=setTimeout(function(){z()},2000);break}}}function z(ai){aa();_utils.cancelAnimation(ac);_utils.fadeTo(ac,0,0.1,1,0)}function U(){T();_utils.cancelAnimation(ac);_utils.fadeTo(ac,1,0,1,0)}function H(ai){return function(){if(S&&d!=ai){d=ai;W.sendEvent(ai,{component:"controlbar",boundingRect:O()})}}}var T=H(a.api.events.JWPLAYER_COMPONENT_SHOW);var aa=H(a.api.events.JWPLAYER_COMPONENT_HIDE);function O(){if(D.position==a.html5.view.positions.OVER||k.jwGetFullscreen()){return _utils.getDimensions(ac)}else{return{x:0,y:0,width:0,height:0}}}function Z(am,al,ak,ai){var aj;if(!p){if(!ai){ai="div"}aj=document.createElement(ai);Q[am]=aj;aj.id=ac.id+"_"+am;al.appendChild(aj)}else{aj=document.getElementById(ac.id+"_"+am)}if(_utils.exists(ak)){_css(aj,ak)}return aj}function M(){ah(D.layout.left);ah(D.layout.right,-1);ah(D.layout.center)}function ah(al,ai){var am=al.position=="right"?"right":"left";var ak=_utils.extend([],al.elements);if(_utils.exists(ai)){ak.reverse()}for(var aj=0;aj0||al.indexOf("divider")===0){var an={height:J().height,position:"absolute",display:"block",top:0};if((al.indexOf("next")===0||al.indexOf("prev")===0)&&k.jwGetPlaylist().length<2){aj=false;an.display="none"}var at;if(al.indexOf("Text")>0){al.innerhtml="00:00";an.font=D.fontsize+"px/"+(J().height+1)+"px "+D.font;an.color=D.fontcolor;an.textAlign="center";an.fontWeight=D.fontweight;an.fontStyle=D.fontstyle;an.cursor="default";at=14+3*D.fontsize}else{if(al.indexOf("divider")===0){if(ai){if(!isNaN(parseInt(ai))){at=parseInt(ai)}}else{if(ak){var ap=k.skin.getSkinElement("controlbar",ak);if(ap){an.background="url("+ap.src+") repeat-x center left";at=ap.width}}else{an.background="url("+k.skin.getSkinElement("controlbar","divider").src+") repeat-x center left";at=k.skin.getSkinElement("controlbar","divider").width}}}else{an.background="url("+k.skin.getSkinElement("controlbar",al).src+") repeat-x center left";at=k.skin.getSkinElement("controlbar",al).width}}if(ao=="left"){an.left=isNaN(am)?ab:am;if(aj){ab+=at}}else{if(ao=="right"){an.right=isNaN(am)?E:am;if(aj){E+=at}}}if(_utils.typeOf(ar)=="undefined"){ar=Q.elements}an.width=at;if(p){_css(Q[al],an)}else{var aq=Z(al,ar,an);if(_utils.exists(k.skin.getSkinElement("controlbar",al+"Over"))){aq.onmouseover=function(au){aq.style.backgroundImage=["url(",k.skin.getSkinElement("controlbar",al+"Over").src,")"].join("")};aq.onmouseout=function(au){aq.style.backgroundImage=["url(",k.skin.getSkinElement("controlbar",al).src,")"].join("")}}}}}function F(){k.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_LOADED,B);k.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_ITEM,s);k.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_BUFFER,u);k.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE,r);k.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_TIME,I);k.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_MUTE,ag);k.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_VOLUME,m);k.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_COMPLETE,L)}function B(){N();M();w();ae()}function s(ai){ad=k.jwGetPlaylist()[ai.index].duration;I({id:k.id,duration:ad,position:0});u({id:k.id,bufferProgress:0})}function ae(){I({id:k.id,duration:k.jwGetDuration(),position:0});u({id:k.id,bufferProgress:0});ag({id:k.id,mute:k.jwGetMute()});r({id:k.id,newstate:a.api.events.state.IDLE});m({id:k.id,volume:k.jwGetVolume()})}function R(ak,al,aj){if(p){return}if(_utils.exists(k.skin.getSkinElement("controlbar",ak))){var ai=Q[ak];if(_utils.exists(ai)){_css(ai,{cursor:"pointer"});if(al=="fullscreen"){ai.onmouseup=function(am){am.stopPropagation();k.jwSetFullscreen(!k.jwGetFullscreen())}}else{ai.onmouseup=function(am){am.stopPropagation();if(_utils.exists(aj)){k[al](aj)}else{k[al]()}}}}}}function X(ai){if(p){return}var aj=Q[ai+"Slider"];_css(Q.elements,{cursor:"pointer"});_css(aj,{cursor:"pointer"});aj.onmousedown=function(ak){v=ai};aj.onmouseup=function(ak){ak.stopPropagation();af(ak.pageX)};aj.onmousemove=function(ak){if(v=="time"){g=true;var al=ak.pageX-c[ai+"Slider"].left-window.pageXOffset;_css(Q.timeSliderThumb,{left:al})}}}function af(aj){g=false;var ai;if(v=="time"){ai=aj-c.timeSliderRail.left+window.pageXOffset;var al=ai/c.timeSliderRail.width*ad;if(al<0){al=0}else{if(al>ad){al=ad-3}}if(k.jwGetState()==a.api.events.state.PAUSED||k.jwGetState()==a.api.events.state.IDLE){k.jwPlay()}k.jwSeek(al)}else{if(v=="volume"){ai=aj-c.volumeSliderRail.left-window.pageXOffset;var ak=Math.round(ai/c.volumeSliderRail.width*100);if(ak<0){ak=0}else{if(ak>100){ak=100}}if(k.jwGetMute()){k.jwSetMute(false)}k.jwSetVolume(ak)}}v="none"}function u(aj){if(_utils.exists(aj.bufferPercent)){f=aj.bufferPercent}if(c.timeSliderRail){var ak=c.timeSliderRail.width;var ai=isNaN(Math.round(ak*f/100))?0:Math.round(ak*f/100);_css(Q.timeSliderBuffer,{width:ai})}}function ag(ai){if(ai.mute){_hide(Q.muteButton);_show(Q.unmuteButton);_hide(Q.volumeSliderProgress)}else{_show(Q.muteButton);_hide(Q.unmuteButton);_show(Q.volumeSliderProgress)}}function r(ai){if(ai.newstate==a.api.events.state.BUFFERING||ai.newstate==a.api.events.state.PLAYING){_show(Q.pauseButton);_hide(Q.playButton)}else{_hide(Q.pauseButton);_show(Q.playButton)}A();if(ai.newstate==a.api.events.state.IDLE){_hide(Q.timeSliderBuffer);_hide(Q.timeSliderProgress);_hide(Q.timeSliderThumb);I({id:k.id,duration:k.jwGetDuration(),position:0})}else{_show(Q.timeSliderBuffer);if(ai.newstate!=a.api.events.state.BUFFERING){_show(Q.timeSliderProgress);_show(Q.timeSliderThumb)}}}function L(ai){u({bufferPercent:0});I(_utils.extend(ai,{position:0,duration:ad}))}function I(al){if(_utils.exists(al.position)){j=al.position}if(_utils.exists(al.duration)){ad=al.duration}var aj=(j===ad===0)?0:j/ad;var am=c.timeSliderRail;if(am){var ai=isNaN(Math.round(am.width*aj))?0:Math.round(am.width*aj);var ak=ai;if(Q.timeSliderProgress){Q.timeSliderProgress.style.width=ai+"px";if(!g){if(Q.timeSliderThumb){Q.timeSliderThumb.style.left=ak+"px"}}}}if(Q.durationText){Q.durationText.innerHTML=_utils.timeFormat(ad)}if(Q.elapsedText){Q.elapsedText.innerHTML=_utils.timeFormat(j)}}function n(){var am,aj;var ak=document.getElementById(ac.id+"_elements");if(!ak){return}var al=ak.childNodes;for(var ai in ak.childNodes){if(isNaN(parseInt(ai,10))){continue}if(al[ai].id.indexOf(ac.id+"_divider")===0&&aj&&aj.id.indexOf(ac.id+"_divider")===0&&al[ai].style.backgroundImage==aj.style.backgroundImage){al[ai].style.display="none"}else{if(al[ai].id.indexOf(ac.id+"_divider")===0&&am&&am.style.display!="none"){al[ai].style.display="block"}}if(al[ai].style.display!="none"){aj=al[ai]}am=al[ai]}}function w(){n();if(k.jwGetFullscreen()){_show(Q.normalscreenButton);_hide(Q.fullscreenButton)}else{_hide(Q.normalscreenButton);_show(Q.fullscreenButton)}var aj={width:e};var ai={};if(D.position==a.html5.view.positions.OVER||k.jwGetFullscreen()){aj.left=D.margin;aj.width-=2*D.margin;aj.top=y-J().height-D.margin;aj.height=J().height}var al=k.skin.getSkinElement("controlbar","capLeft");var ak=k.skin.getSkinElement("controlbar","capRight");ai.left=al?al.width:0;ai.width=aj.width-ai.left-(ak?ak.width:0);var am=!_utils.exists(k.skin.getSkinElement("controlbar","timeSliderCapLeft"))?0:k.skin.getSkinElement("controlbar","timeSliderCapLeft").width;_css(Q.timeSliderRail,{width:(ai.width-ab-E),left:am});if(_utils.exists(Q.timeSliderCapRight)){_css(Q.timeSliderCapRight,{left:am+(ai.width-ab-E)})}_css(ac,aj);_css(Q.elements,ai);_css(Q.background,ai);q();return aj}function m(am){if(_utils.exists(Q.volumeSliderRail)){var ak=isNaN(am.volume/100)?1:am.volume/100;var al=_utils.parseDimension(Q.volumeSliderRail.style.width);var ai=isNaN(Math.round(al*ak))?0:Math.round(al*ak);var an=_utils.parseDimension(Q.volumeSliderRail.style.right);var aj=(!_utils.exists(k.skin.getSkinElement("controlbar","volumeSliderCapLeft")))?0:k.skin.getSkinElement("controlbar","volumeSliderCapLeft").width;_css(Q.volumeSliderProgress,{width:ai,left:aj});if(_utils.exists(Q.volumeSliderCapLeft)){_css(Q.volumeSliderCapLeft,{left:0})}}}function t(){N();M();q();p=true;F();D.idlehide=(D.idlehide.toString().toLowerCase()=="true");if(D.position==a.html5.view.positions.OVER&&D.idlehide){ac.style.opacity=0;S=true}else{setTimeout((function(){S=true;T()}),1)}ae()}t();return this}})(jwplayer);(function(b){var a=["width","height","state","playlist","item","position","buffer","duration","volume","mute","fullscreen"];var c=b.utils;b.html5.controller=function(z,w,h,v){var C=z;var G=h;var g=v;var o=w;var J=true;var e=-1;var A=c.exists(G.config.debug)&&(G.config.debug.toString().toLowerCase()=="console");var m=new b.html5.eventdispatcher(o.id,A);c.extend(this,m);var E=[];var d=false;function r(M){if(d){m.sendEvent(M.type,M)}else{E.push(M)}}function K(M){if(!d){m.sendEvent(b.api.events.JWPLAYER_READY,M);if(b.utils.exists(window.playerReady)){playerReady(M)}if(b.utils.exists(window[h.config.playerReady])){window[h.config.playerReady](M)}while(E.length>0){var O=E.shift();m.sendEvent(O.type,O)}if(h.config.autostart&&!b.utils.isIOS()){t(G.item)}while(p.length>0){var N=p.shift();x(N.method,N.arguments)}d=true}}G.addGlobalListener(r);G.addEventListener(b.api.events.JWPLAYER_MEDIA_BUFFER_FULL,function(){G.getMedia().play()});G.addEventListener(b.api.events.JWPLAYER_MEDIA_TIME,function(M){if(M.position>=G.playlist[G.item].start&&e>=0){G.playlist[G.item].start=e;e=-1}});G.addEventListener(b.api.events.JWPLAYER_MEDIA_COMPLETE,function(M){setTimeout(s,25)});function u(){try{f(G.item);if(G.playlist[G.item].levels[0].file.length>0){if(J||G.state==b.api.events.state.IDLE){G.getMedia().load(G.playlist[G.item]);J=false}else{if(G.state==b.api.events.state.PAUSED){G.getMedia().play()}}}return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function I(){try{if(G.playlist[G.item].levels[0].file.length>0){switch(G.state){case b.api.events.state.PLAYING:case b.api.events.state.BUFFERING:G.getMedia().pause();break}}return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function D(M){try{if(G.playlist[G.item].levels[0].file.length>0){if(typeof M!="number"){M=parseFloat(M)}switch(G.state){case b.api.events.state.IDLE:if(e<0){e=G.playlist[G.item].start;G.playlist[G.item].start=M}u();break;case b.api.events.state.PLAYING:case b.api.events.state.PAUSED:case b.api.events.state.BUFFERING:G.seek(M);break}}return true}catch(N){m.sendEvent(b.api.events.JWPLAYER_ERROR,N)}return false}function n(M){if(!c.exists(M)){M=true}try{G.getMedia().stop(M);return true}catch(N){m.sendEvent(b.api.events.JWPLAYER_ERROR,N)}return false}function k(){try{if(G.playlist[G.item].levels[0].file.length>0){if(G.config.shuffle){f(y())}else{if(G.item+1==G.playlist.length){f(0)}else{f(G.item+1)}}}if(G.state!=b.api.events.state.IDLE){var N=G.state;G.state=b.api.events.state.IDLE;m.sendEvent(b.api.events.JWPLAYER_PLAYER_STATE,{oldstate:N,newstate:b.api.events.state.IDLE})}u();return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function j(){try{if(G.playlist[G.item].levels[0].file.length>0){if(G.config.shuffle){f(y())}else{if(G.item===0){f(G.playlist.length-1)}else{f(G.item-1)}}}if(G.state!=b.api.events.state.IDLE){var N=G.state;G.state=b.api.events.state.IDLE;m.sendEvent(b.api.events.JWPLAYER_PLAYER_STATE,{oldstate:N,newstate:b.api.events.state.IDLE})}u();return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function y(){var M=null;if(G.playlist.length>1){while(!c.exists(M)){M=Math.floor(Math.random()*G.playlist.length);if(M==G.item){M=null}}}else{M=0}return M}function t(N){if(!G.playlist||!G.playlist[N]){return false}try{if(G.playlist[N].levels[0].file.length>0){var O=G.state;if(O!==b.api.events.state.IDLE){if(G.playlist[G.item].provider==G.playlist[N].provider){n(false)}else{n()}}f(N);u()}return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function f(M){if(!G.playlist[M]){return}G.setActiveMediaProvider(G.playlist[M]);if(G.item!=M){G.item=M;J=true;m.sendEvent(b.api.events.JWPLAYER_PLAYLIST_ITEM,{index:M})}}function H(N){try{f(G.item);var O=G.getMedia();switch(typeof(N)){case"number":O.volume(N);break;case"string":O.volume(parseInt(N,10));break}return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function q(N){try{f(G.item);var O=G.getMedia();if(typeof N=="undefined"){O.mute(!G.mute)}else{if(N.toString().toLowerCase()=="true"){O.mute(true)}else{O.mute(false)}}return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function l(N,M){try{G.width=N;G.height=M;g.resize(N,M);m.sendEvent(b.api.events.JWPLAYER_RESIZE,{width:G.width,height:G.height});return true}catch(O){m.sendEvent(b.api.events.JWPLAYER_ERROR,O)}return false}function B(N){try{if(typeof N=="undefined"){G.fullscreen=!G.fullscreen;g.fullscreen(!G.fullscreen)}else{if(N.toString().toLowerCase()=="true"){G.fullscreen=true;g.fullscreen(true)}else{G.fullscreen=false;g.fullscreen(false)}}m.sendEvent(b.api.events.JWPLAYER_RESIZE,{width:G.width,height:G.height});m.sendEvent(b.api.events.JWPLAYER_FULLSCREEN,{fullscreen:N});return true}catch(M){m.sendEvent(b.api.events.JWPLAYER_ERROR,M)}return false}function L(M){try{n();G.loadPlaylist(M);f(G.item);return true}catch(N){m.sendEvent(b.api.events.JWPLAYER_ERROR,N)}return false}b.html5.controller.repeatoptions={LIST:"LIST",ALWAYS:"ALWAYS",SINGLE:"SINGLE",NONE:"NONE"};function s(){switch(G.config.repeat.toUpperCase()){case b.html5.controller.repeatoptions.SINGLE:u();break;case b.html5.controller.repeatoptions.ALWAYS:if(G.item==G.playlist.length-1&&!G.config.shuffle){t(0)}else{k()}break;case b.html5.controller.repeatoptions.LIST:if(G.item==G.playlist.length-1&&!G.config.shuffle){n();f(0)}else{k()}break;default:n();break}}var p=[];function F(M){return function(){if(d){x(M,arguments)}else{p.push({method:M,arguments:arguments})}}}function x(O,N){var M=[];for(i=0;i';this.xml=null;if(window.DOMParser){parser=new DOMParser();this.xml=parser.parseFromString(this.text,"text/xml")}else{this.xml=new ActiveXObject("Microsoft.XMLDOM");this.xml.async="false";this.xml.loadXML(this.text)}return this}})(jwplayer);(function(a){_utils=a.utils;_css=_utils.css;_hide=function(b){_css(b,{display:"none"})};_show=function(b){_css(b,{display:"block"})};a.html5.display=function(k,G){var j={icons:true,showmute:false};var Q=_utils.extend({},j,G);var h=k;var P={};var e;var u;var w;var N;var s;var I;var A;var J=!_utils.exists(h.skin.getComponentSettings("display").bufferrotation)?15:parseInt(h.skin.getComponentSettings("display").bufferrotation,10);var q=!_utils.exists(h.skin.getComponentSettings("display").bufferinterval)?100:parseInt(h.skin.getComponentSettings("display").bufferinterval,10);var z=-1;var t="";var K=true;var d;var g=false;var n=false;var H=new a.html5.eventdispatcher();_utils.extend(this,H);var D={display:{style:{cursor:"pointer",top:0,left:0,overflow:"hidden"},click:m},display_icon:{style:{cursor:"pointer",position:"absolute",top:((h.skin.getSkinElement("display","background").height-h.skin.getSkinElement("display","playIcon").height)/2),left:((h.skin.getSkinElement("display","background").width-h.skin.getSkinElement("display","playIcon").width)/2),border:0,margin:0,padding:0,zIndex:3,display:"none"}},display_iconBackground:{style:{cursor:"pointer",position:"absolute",top:((u-h.skin.getSkinElement("display","background").height)/2),left:((e-h.skin.getSkinElement("display","background").width)/2),border:0,backgroundImage:(["url(",h.skin.getSkinElement("display","background").src,")"]).join(""),width:h.skin.getSkinElement("display","background").width,height:h.skin.getSkinElement("display","background").height,margin:0,padding:0,zIndex:2,display:"none"}},display_image:{style:{display:"none",width:e,height:u,position:"absolute",cursor:"pointer",left:0,top:0,margin:0,padding:0,textDecoration:"none",zIndex:1}},display_text:{style:{zIndex:4,position:"relative",opacity:0.8,backgroundColor:parseInt("000000",16),color:parseInt("ffffff",16),textAlign:"center",fontFamily:"Arial,sans-serif",padding:"0 5px",fontSize:14}}};h.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE,p);h.jwAddEventListener(a.api.events.JWPLAYER_MEDIA_MUTE,p);h.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_ITEM,p);h.jwAddEventListener(a.api.events.JWPLAYER_ERROR,o);L();function L(){P.display=C("div","display");P.display_text=C("div","display_text");P.display.appendChild(P.display_text);P.display_image=C("img","display_image");P.display_image.onerror=function(R){_hide(P.display_image)};P.display_image.onload=y;P.display_icon=C("div","display_icon");P.display_iconBackground=C("div","display_iconBackground");P.display.appendChild(P.display_image);P.display_iconBackground.appendChild(P.display_icon);P.display.appendChild(P.display_iconBackground);f();setTimeout((function(){n=true;if(Q.icons.toString()=="true"){F()}}),1)}this.getDisplayElement=function(){return P.display};this.resize=function(S,R){_css(P.display,{width:S,height:R});_css(P.display_text,{width:(S-10),top:((R-P.display_text.getBoundingClientRect().height)/2)});_css(P.display_iconBackground,{top:((R-h.skin.getSkinElement("display","background").height)/2),left:((S-h.skin.getSkinElement("display","background").width)/2)});if(e!=S||u!=R){e=S;u=R;d=undefined;F()}c();p({})};this.show=function(){if(g){g=false;r(h.jwGetState())}};this.hide=function(){if(!g){B();g=true}};function y(R){w=P.display_image.naturalWidth;N=P.display_image.naturalHeight;c()}function c(){_utils.stretch(h.jwGetStretching(),P.display_image,e,u,w,N)}function C(R,T){var S=document.createElement(R);S.id=h.id+"_jwplayer_"+T;_css(S,D[T].style);return S}function f(){for(var R in P){if(_utils.exists(D[R].click)){P[R].onclick=D[R].click}}}function m(R){if(typeof R.preventDefault!="undefined"){R.preventDefault()}else{R.returnValue=false}if(h.jwGetState()!=a.api.events.state.PLAYING){h.jwPlay()}else{h.jwPause()}}function O(R){if(A){B();return}P.display_icon.style.backgroundImage=(["url(",h.skin.getSkinElement("display",R).src,")"]).join("");_css(P.display_icon,{width:h.skin.getSkinElement("display",R).width,height:h.skin.getSkinElement("display",R).height,top:(h.skin.getSkinElement("display","background").height-h.skin.getSkinElement("display",R).height)/2,left:(h.skin.getSkinElement("display","background").width-h.skin.getSkinElement("display",R).width)/2});b();if(_utils.exists(h.skin.getSkinElement("display",R+"Over"))){P.display_icon.onmouseover=function(S){P.display_icon.style.backgroundImage=["url(",h.skin.getSkinElement("display",R+"Over").src,")"].join("")};P.display_icon.onmouseout=function(S){P.display_icon.style.backgroundImage=["url(",h.skin.getSkinElement("display",R).src,")"].join("")}}else{P.display_icon.onmouseover=null;P.display_icon.onmouseout=null}}function B(){if(Q.icons.toString()=="true"){_hide(P.display_icon);_hide(P.display_iconBackground);M()}}function b(){if(!g&&Q.icons.toString()=="true"){_show(P.display_icon);_show(P.display_iconBackground);F()}}function o(R){A=true;B();P.display_text.innerHTML=R.error;_show(P.display_text);P.display_text.style.top=((u-P.display_text.getBoundingClientRect().height)/2)+"px"}function E(){P.display_image.style.display="none"}function p(R){if((R.type==a.api.events.JWPLAYER_PLAYER_STATE||R.type==a.api.events.JWPLAYER_PLAYLIST_ITEM)&&A){A=false;_hide(P.display_text)}var S=h.jwGetState();if(S==t){return}t=S;if(z>=0){clearTimeout(z)}if(K||h.jwGetState()==a.api.events.state.PLAYING||h.jwGetState()==a.api.events.state.PAUSED){r(h.jwGetState())}else{z=setTimeout(l(h.jwGetState()),500)}}function l(R){return(function(){r(R)})}function r(R){if(_utils.exists(I)){clearInterval(I);I=null;_utils.animations.rotate(P.display_icon,0)}switch(R){case a.api.events.state.BUFFERING:if(_utils.isIOS()){E();B()}else{if(h.jwGetPlaylist()[h.jwGetItem()].provider=="sound"){v()}s=0;I=setInterval(function(){s+=J;_utils.animations.rotate(P.display_icon,s%360)},q);O("bufferIcon");K=true}break;case a.api.events.state.PAUSED:if(!_utils.isIOS()){if(h.jwGetPlaylist()[h.jwGetItem()].provider!="sound"){_css(P.display_image,{background:"transparent no-repeat center center"})}O("playIcon");K=true}break;case a.api.events.state.IDLE:if(h.jwGetPlaylist()[h.jwGetItem()]&&h.jwGetPlaylist()[h.jwGetItem()].image){v()}else{E()}O("playIcon");K=true;break;default:if(h.jwGetPlaylist()[h.jwGetItem()]&&h.jwGetPlaylist()[h.jwGetItem()].provider=="sound"){if(_utils.isIOS()){E();K=false}else{v()}}else{E();K=false}if(h.jwGetMute()&&Q.showmute){O("muteIcon")}else{B()}break}z=-1}function v(){if(h.jwGetPlaylist()[h.jwGetItem()]&&h.jwGetPlaylist()[h.jwGetItem()].image){_css(P.display_image,{display:"block"});P.display_image.src=_utils.getAbsolutePath(h.jwGetPlaylist()[h.jwGetItem()].image)}}function x(R){return function(){if(!n){return}if(!g&&d!=R){d=R;H.sendEvent(R,{component:"display",boundingRect:_utils.getDimensions(P.display_iconBackground)})}}}var F=x(a.api.events.JWPLAYER_COMPONENT_SHOW);var M=x(a.api.events.JWPLAYER_COMPONENT_HIDE);return this}})(jwplayer);(function(a){_css=a.utils.css;a.html5.dock=function(p,u){function q(){return{align:a.html5.view.positions.RIGHT}}var k=a.utils.extend({},q(),u);if(k.align=="FALSE"){return}var f={};var s=[];var g;var v;var d=false;var t=false;var e={x:0,y:0,width:0,height:0};var r;var j=new a.html5.eventdispatcher();_utils.extend(this,j);var m=document.createElement("div");m.id=p.id+"_jwplayer_dock";p.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE,l);this.getDisplayElement=function(){return m};this.setButton=function(A,x,y,z){if(!x&&f[A]){a.utils.arrays.remove(s,A);m.removeChild(f[A].div);delete f[A]}else{if(x){if(!f[A]){f[A]={}}f[A].handler=x;f[A].outGraphic=y;f[A].overGraphic=z;if(!f[A].div){s.push(A);f[A].div=document.createElement("div");f[A].div.style.position="relative";m.appendChild(f[A].div);f[A].div.appendChild(document.createElement("img"));f[A].div.childNodes[0].style.position="absolute";f[A].div.childNodes[0].style.left=0;f[A].div.childNodes[0].style.top=0;f[A].div.childNodes[0].style.zIndex=10;f[A].div.childNodes[0].style.cursor="pointer";f[A].div.appendChild(document.createElement("img"));f[A].div.childNodes[1].style.position="absolute";f[A].div.childNodes[1].style.left=0;f[A].div.childNodes[1].style.top=0;if(p.skin.getSkinElement("dock","button")){f[A].div.childNodes[1].src=p.skin.getSkinElement("dock","button").src}f[A].div.childNodes[1].style.zIndex=9;f[A].div.childNodes[1].style.cursor="pointer";f[A].div.onmouseover=function(){if(f[A].overGraphic){f[A].div.childNodes[0].src=f[A].overGraphic}if(p.skin.getSkinElement("dock","buttonOver")){f[A].div.childNodes[1].src=p.skin.getSkinElement("dock","buttonOver").src}};f[A].div.onmouseout=function(){if(f[A].outGraphic){f[A].div.childNodes[0].src=f[A].outGraphic}if(p.skin.getSkinElement("dock","button")){f[A].div.childNodes[1].src=p.skin.getSkinElement("dock","button").src}};if(f[A].overGraphic){f[A].div.childNodes[0].src=f[A].overGraphic}if(f[A].outGraphic){f[A].div.childNodes[0].src=f[A].outGraphic}if(p.skin.getSkinElement("dock","button")){f[A].div.childNodes[1].src=p.skin.getSkinElement("dock","button").src}}if(x){f[A].div.onclick=function(B){B.preventDefault();a(p.id).callback(A);if(f[A].overGraphic){f[A].div.childNodes[0].src=f[A].overGraphic}if(p.skin.getSkinElement("dock","button")){f[A].div.childNodes[1].src=p.skin.getSkinElement("dock","button").src}}}}}h(g,v)};function h(x,J){if(s.length>0){var y=10;var I=y;var F=-1;var G=p.skin.getSkinElement("dock","button").height;var E=p.skin.getSkinElement("dock","button").width;var C=x-E-y;var H,B;if(k.align==a.html5.view.positions.LEFT){F=1;C=y}for(var z=0;z((K+1)*J)){I=((K+1)*J)+y;K=Math.floor(I/J)}var A=f[s[z]].div;A.style.top=(I%J)+"px";A.style.left=(C+(p.skin.getSkinElement("dock","button").width+y)*K*F)+"px";var D={x:a.utils.parseDimension(A.style.left),y:a.utils.parseDimension(A.style.top),width:E,height:G};if(!H||(D.x<=H.x&&D.y<=H.y)){H=D}if(!B||(D.x>=B.x&&D.y>=B.y)){B=D}I+=p.skin.getSkinElement("dock","button").height+y}e={x:H.x,y:H.y,width:B.x-H.x+B.width,height:H.y-B.y+B.height}}if(t!=p.jwGetFullscreen()||g!=x||v!=J){g=x;v=J;t=p.jwGetFullscreen();r=undefined;setTimeout(n,1)}}function b(x){return function(){if(!d&&r!=x&&s.length>0){r=x;j.sendEvent(x,{component:"dock",boundingRect:e})}}}function l(x){if(a.utils.isIOS()){switch(x.newstate){case a.api.events.state.IDLE:o();break;default:c();break}}}var n=b(a.api.events.JWPLAYER_COMPONENT_SHOW);var w=b(a.api.events.JWPLAYER_COMPONENT_HIDE);this.resize=h;var o=function(){_css(m,{display:"block"});if(d){d=false;n()}};var c=function(){_css(m,{display:"none"});if(!d){w();d=true}};this.hide=c;this.show=o;return this}})(jwplayer);(function(a){a.html5.eventdispatcher=function(d,b){var c=new a.events.eventdispatcher(b);a.utils.extend(this,c);this.sendEvent=function(e,f){if(!a.utils.exists(f)){f={}}a.utils.extend(f,{id:d,version:a.version,type:e});c.sendEvent(e,f)}}})(jwplayer);(function(a){var b={prefix:"",file:"",link:"",margin:8,out:0.5,over:1,timeout:5,hide:true,position:"bottom-left"};_css=a.utils.css;a.html5.logo=function(n,r){var q=n;var u;var d;var t;var h=false;g();function g(){o();c();l()}function o(){if(b.prefix){var v=n.version.split(/\W/).splice(0,2).join("/");if(b.prefix.indexOf(v)<0){b.prefix+=v+"/"}}if(r.position==a.html5.view.positions.OVER){r.position=b.position}d=a.utils.extend({},b,r)}function c(){t=document.createElement("img");t.id=q.id+"_jwplayer_logo";t.style.display="none";t.onload=function(v){_css(t,k());q.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE,j);p()};if(!d.file){return}if(d.file.indexOf("http://")===0){t.src=d.file}else{t.src=d.prefix+d.file}}if(!d.file){return}this.resize=function(w,v){};this.getDisplayElement=function(){return t};function l(){if(d.link){t.onmouseover=f;t.onmouseout=p;t.onclick=s}else{this.mouseEnabled=false}}function s(v){if(typeof v!="undefined"){v.stopPropagation()}if(!h){return}q.jwPause();q.jwSetFullscreen(false);if(d.link){window.open(d.link,"_top")}return}function p(v){if(d.link&&h){t.style.opacity=d.out}return}function f(v){if(d.hide.toString()=="true"&&h){t.style.opacity=d.over}return}function k(){var x={textDecoration:"none",position:"absolute",cursor:"pointer"};x.display=(d.hide.toString()=="true")?"none":"block";var w=d.position.toLowerCase().split("-");for(var v in w){x[w[v]]=d.margin}return x}function m(){if(d.hide.toString()=="true"){t.style.display="block";t.style.opacity=0;a.utils.fadeTo(t,d.out,0.1,parseFloat(t.style.opacity));u=setTimeout(function(){e()},d.timeout*1000)}h=true}function e(){h=false;if(d.hide.toString()=="true"){a.utils.fadeTo(t,0,0.1,parseFloat(t.style.opacity))}}function j(v){if(v.newstate==a.api.events.state.BUFFERING){clearTimeout(u);m()}}return this}})(jwplayer);(function(a){var c={ended:a.api.events.state.IDLE,playing:a.api.events.state.PLAYING,pause:a.api.events.state.PAUSED,buffering:a.api.events.state.BUFFERING};var e=a.utils;var b=e.css;var d=e.isIOS();a.html5.mediavideo=function(h,s){var r={abort:n,canplay:k,canplaythrough:k,durationchange:G,emptied:n,ended:k,error:u,loadeddata:G,loadedmetadata:G,loadstart:k,pause:k,play:n,playing:k,progress:v,ratechange:n,seeked:k,seeking:k,stalled:k,suspend:k,timeupdate:D,volumechange:n,waiting:k,canshowcurrentframe:n,dataunavailable:n,empty:n,load:z,loadedfirstframe:n};var j=new a.html5.eventdispatcher();e.extend(this,j);var y=h,l=s,m,B,A,x,f,H=false,C,p,q;o();this.load=function(J,K){if(typeof K=="undefined"){K=true}x=J;e.empty(m);q=0;if(J.levels&&J.levels.length>0){if(J.levels.length==1){m.src=J.levels[0].file}else{if(m.src){m.removeAttribute("src")}for(var I=0;I0)){var I=m.buffered.length-1;if(I>=0){J=m.buffered.end(I)/m.duration*100}}}if(p===false&&B==a.api.events.state.BUFFERING){j.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER_FULL);p=true}if(!C){if(J==100){C=true}if(e.exists(J)&&(J>y.buffer)){y.buffer=Math.round(J);j.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER,{bufferPercent:Math.round(J)})}}}function D(J){if(e.exists(J)&&e.exists(J.target)){if(!isNaN(J.target.duration)&&(isNaN(y.duration)||y.duration<1)){if(J.target.duration==Infinity){y.duration=0}else{y.duration=Math.round(J.target.duration*10)/10}}if(!A&&m.readyState>0){m.style.display="block";E(a.api.events.state.PLAYING)}if(B==a.api.events.state.PLAYING){if(!A&&m.readyState>0){A=true;try{if(m.currentTime0?(Math.round(J.target.currentTime*10)/10):0;j.sendEvent(a.api.events.JWPLAYER_MEDIA_TIME,{position:y.position,duration:y.duration});if(y.position>=y.duration&&(y.position>0||y.duration>0)){w()}}}v(J)}function z(I){}function k(I){if(c[I.type]){if(I.type=="ended"){w()}else{E(c[I.type])}}}function G(I){var J={height:I.target.videoHeight,width:I.target.videoWidth,duration:Math.round(I.target.duration*10)/10};if((y.duration===0||isNaN(y.duration))&&I.target.duration!=Infinity){y.duration=Math.round(I.target.duration*10)/10}j.sendEvent(a.api.events.JWPLAYER_MEDIA_META,{metadata:J})}function u(K){if(B==a.api.events.state.IDLE){return}var J="There was an error: ";if((K.target.error&&K.target.tagName.toLowerCase()=="video")||K.target.parentNode.error&&K.target.parentNode.tagName.toLowerCase()=="video"){var I=!e.exists(K.target.error)?K.target.parentNode.error:K.target.error;switch(I.code){case I.MEDIA_ERR_ABORTED:J="You aborted the video playback: ";break;case I.MEDIA_ERR_NETWORK:J="A network error caused the video download to fail part-way: ";break;case I.MEDIA_ERR_DECODE:J="The video playback was aborted due to a corruption problem or because the video used features your browser did not support: ";break;case I.MEDIA_ERR_SRC_NOT_SUPPORTED:J="The video could not be loaded, either because the server or network failed or because the format is not supported: ";break;default:J="An unknown error occurred: ";break}}else{if(K.target.tagName.toLowerCase()=="source"){q--;if(q>0){return}J="The video could not be loaded, either because the server or network failed or because the format is not supported: "}else{e.log("An unknown error occurred. Continuing...");return}}_stop(false);J+=F();_error=true;j.sendEvent(a.api.events.JWPLAYER_ERROR,{error:J});return}function F(){var K="";for(var J in x.levels){var I=x.levels[J];var L=l.ownerDocument.createElement("source");K+=a.utils.getAbsolutePath(I.file);if(J<(x.levels.length-1)){K+=", "}}return K}function t(){if(!e.exists(f)){f=setInterval(function(){v()},100)}}function g(){clearInterval(f);f=null}function w(){if(B!=a.api.events.state.IDLE){_stop(false);j.sendEvent(a.api.events.JWPLAYER_MEDIA_COMPLETE)}}}})(jwplayer);(function(a){var c={ended:a.api.events.state.IDLE,playing:a.api.events.state.PLAYING,pause:a.api.events.state.PAUSED,buffering:a.api.events.state.BUFFERING};var b=a.utils.css;a.html5.mediayoutube=function(j,e){var f=new a.html5.eventdispatcher();a.utils.extend(this,f);var l=j;var h=document.getElementById(e.id);var g=a.api.events.state.IDLE;var n,m;function k(p){if(g!=p){var q=g;l.state=p;g=p;f.sendEvent(a.api.events.JWPLAYER_PLAYER_STATE,{oldstate:q,newstate:p})}}this.getDisplayElement=function(){return h};this.play=function(){if(g==a.api.events.state.IDLE){f.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER,{bufferPercent:100});f.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER_FULL);k(a.api.events.state.PLAYING)}else{if(g==a.api.events.state.PAUSED){k(a.api.events.state.PLAYING)}}};this.pause=function(){k(a.api.events.state.PAUSED)};this.seek=function(p){};this.stop=function(p){if(!_utils.exists(p)){p=true}l.position=0;k(a.api.events.state.IDLE);if(p){b(h,{display:"none"})}};this.volume=function(p){l.volume=p;f.sendEvent(a.api.events.JWPLAYER_MEDIA_VOLUME,{volume:Math.round(p)})};this.mute=function(p){h.muted=p;l.mute=p;f.sendEvent(a.api.events.JWPLAYER_MEDIA_MUTE,{mute:p})};this.resize=function(q,p){if(q*p>0&&n){n.width=m.width=q;n.height=m.height=p}f.sendEvent(a.api.events.JWPLAYER_MEDIA_RESIZE,{fullscreen:l.fullscreen,width:q,height:p})};this.fullscreen=function(p){if(p===true){this.resize("100%","100%")}else{this.resize(l.config.width,l.config.height)}};this.load=function(p){o(p);b(n,{display:"block"});k(a.api.events.state.BUFFERING);f.sendEvent(a.api.events.JWPLAYER_MEDIA_BUFFER,{bufferPercent:0});f.sendEvent(a.api.events.JWPLAYER_MEDIA_LOADED);this.play()};this.hasChrome=function(){return(g!=a.api.events.state.IDLE)};function o(v){var s=v.levels[0].file;s=["http://www.youtube.com/v/",d(s),"&hl=en_US&fs=1&autoplay=1"].join("");n=document.createElement("object");n.id=h.id;n.style.position="absolute";var u={movie:s,allowfullscreen:"true",allowscriptaccess:"always"};for(var p in u){var t=document.createElement("param");t.name=p;t.value=u[p];n.appendChild(t)}m=document.createElement("embed");n.appendChild(m);var q={src:s,type:"application/x-shockwave-flash",allowfullscreen:"true",allowscriptaccess:"always",width:n.width,height:n.height};for(var r in q){m.setAttribute(r,q[r])}n.appendChild(m);n.style.zIndex=2147483000;if(h!=n&&h.parentNode){h.parentNode.replaceChild(n,h)}h=n}function d(q){var p=q.split(/\?|\#\!/);var s="";for(var r=0;r=0){s=q.substr(q.indexOf("/v/")+3)}else{if(q.indexOf("youtu.be")>=0){s=q.substr(q.indexOf("youtu.be/")+9)}else{s=q}}}if(s.indexOf("?")>-1){s=s.substr(0,s.indexOf("?"))}if(s.indexOf("&")>-1){s=s.substr(0,s.indexOf("&"))}return s}this.embed=m;return this}})(jwplayer);(function(jwplayer){var _configurableStateVariables=["width","height","start","duration","volume","mute","fullscreen","item","plugins","stretching"];jwplayer.html5.model=function(api,container,options){var _api=api;var _container=container;var _model={id:_container.id,playlist:[],state:jwplayer.api.events.state.IDLE,position:0,buffer:0,config:{width:480,height:320,item:-1,skin:undefined,file:undefined,image:undefined,start:0,duration:0,bufferlength:5,volume:90,mute:false,fullscreen:false,repeat:"",stretching:jwplayer.utils.stretching.UNIFORM,autostart:false,debug:undefined,screencolor:undefined}};var _media;var _eventDispatcher=new jwplayer.html5.eventdispatcher();var _components=["display","logo","controlbar","playlist","dock"];jwplayer.utils.extend(_model,_eventDispatcher);for(var option in options){if(typeof options[option]=="string"){var type=/color$/.test(option)?"color":null;options[option]=jwplayer.utils.typechecker(options[option],type)}var config=_model.config;var path=option.split(".");for(var edge in path){if(edge==path.length-1){config[path[edge]]=options[option]}else{if(!jwplayer.utils.exists(config[path[edge]])){config[path[edge]]={}}config=config[path[edge]]}}}for(var index in _configurableStateVariables){var configurableStateVariable=_configurableStateVariables[index];_model[configurableStateVariable]=_model.config[configurableStateVariable]}var pluginorder=_components.concat([]);if(jwplayer.utils.exists(_model.plugins)){if(typeof _model.plugins=="string"){var userplugins=_model.plugins.split(",");for(var userplugin in userplugins){if(typeof userplugins[userplugin]=="string"){pluginorder.push(userplugins[userplugin].replace(/^\s+|\s+$/g,""))}}}}if(jwplayer.utils.isIOS()){pluginorder=["display","logo","dock","playlist"];if(!jwplayer.utils.exists(_model.config.repeat)){_model.config.repeat="list"}}else{if(_model.config.chromeless){pluginorder=["logo","dock","playlist"];if(!jwplayer.utils.exists(_model.config.repeat)){_model.config.repeat="list"}}}_model.plugins={order:pluginorder,config:{},object:{}};if(typeof _model.config.components!="undefined"){for(var component in _model.config.components){_model.plugins.config[component]=_model.config.components[component]}}for(var pluginIndex in _model.plugins.order){var pluginName=_model.plugins.order[pluginIndex];var pluginConfig=!jwplayer.utils.exists(_model.plugins.config[pluginName])?{}:_model.plugins.config[pluginName];_model.plugins.config[pluginName]=!jwplayer.utils.exists(_model.plugins.config[pluginName])?pluginConfig:jwplayer.utils.extend(_model.plugins.config[pluginName],pluginConfig);if(!jwplayer.utils.exists(_model.plugins.config[pluginName].position)){if(pluginName=="playlist"){_model.plugins.config[pluginName].position=jwplayer.html5.view.positions.NONE}else{_model.plugins.config[pluginName].position=jwplayer.html5.view.positions.OVER}}else{_model.plugins.config[pluginName].position=_model.plugins.config[pluginName].position.toString().toUpperCase()}}if(typeof _model.plugins.config.dock!="undefined"){if(typeof _model.plugins.config.dock!="object"){var position=_model.plugins.config.dock.toString().toUpperCase();_model.plugins.config.dock={position:position}}if(typeof _model.plugins.config.dock.position!="undefined"){_model.plugins.config.dock.align=_model.plugins.config.dock.position;_model.plugins.config.dock.position=jwplayer.html5.view.positions.OVER}}function _loadExternal(playlistfile){var loader=new jwplayer.html5.playlistloader();loader.addEventListener(jwplayer.api.events.JWPLAYER_PLAYLIST_LOADED,function(evt){_model.playlist=new jwplayer.html5.playlist(evt);_loadComplete(true)});loader.addEventListener(jwplayer.api.events.JWPLAYER_ERROR,function(evt){_model.playlist=new jwplayer.html5.playlist({playlist:[]});_loadComplete(false)});loader.load(playlistfile)}function _loadComplete(){if(_model.config.shuffle){_model.item=_getShuffleItem()}else{if(_model.config.item>=_model.playlist.length){_model.config.item=_model.playlist.length-1}else{if(_model.config.item<0){_model.config.item=0}}_model.item=_model.config.item}_eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYLIST_LOADED,{playlist:_model.playlist});_eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_PLAYLIST_ITEM,{index:_model.item})}_model.loadPlaylist=function(arg){var input;if(typeof arg=="string"){if(arg.indexOf("[")==0||arg.indexOf("{")=="0"){try{input=eval(arg)}catch(err){input=arg}}else{input=arg}}else{input=arg}var config;switch(jwplayer.utils.typeOf(input)){case"object":config=input;break;case"array":config={playlist:input};break;default:_loadExternal(input);return;break}_model.playlist=new jwplayer.html5.playlist(config);if(jwplayer.utils.extension(_model.playlist[0].file)=="xml"){_loadExternal(_model.playlist[0].file)}else{_loadComplete()}};function _getShuffleItem(){var result=null;if(_model.playlist.length>1){while(!jwplayer.utils.exists(result)){result=Math.floor(Math.random()*_model.playlist.length);if(result==_model.item){result=null}}}else{result=0}return result}function forward(evt){if(evt.type==jwplayer.api.events.JWPLAYER_MEDIA_LOADED){_container=_media.getDisplayElement()}_eventDispatcher.sendEvent(evt.type,evt)}var _mediaProviders={};_model.setActiveMediaProvider=function(playlistItem){if(playlistItem.provider=="audio"){playlistItem.provider="sound"}var provider=playlistItem.provider;var current=_media?_media.getDisplayElement():null;if(provider=="sound"||provider=="http"||provider==""){provider="video"}if(!jwplayer.utils.exists(_mediaProviders[provider])){switch(provider){case"video":_media=new jwplayer.html5.mediavideo(_model,current?current:_container);break;case"youtube":_media=new jwplayer.html5.mediayoutube(_model,current?current:_container);break}if(!jwplayer.utils.exists(_media)){return false}_media.addGlobalListener(forward);_mediaProviders[provider]=_media}else{if(_media!=_mediaProviders[provider]){if(_media){_media.stop()}_media=_mediaProviders[provider]}}return true};_model.getMedia=function(){return _media};_model.seek=function(pos){_eventDispatcher.sendEvent(jwplayer.api.events.JWPLAYER_MEDIA_SEEK,{position:_model.position,offset:pos});return _media.seek(pos)};_model.setupPlugins=function(){if(!jwplayer.utils.exists(_model.plugins)||!jwplayer.utils.exists(_model.plugins.order)||_model.plugins.order.length==0){jwplayer.utils.log("No plugins to set up");return _model}for(var i=0;i<_model.plugins.order.length;i++){try{var pluginName=_model.plugins.order[i];if(jwplayer.utils.exists(jwplayer.html5[pluginName])){if(pluginName=="playlist"){_model.plugins.object[pluginName]=new jwplayer.html5.playlistcomponent(_api,_model.plugins.config[pluginName])}else{_model.plugins.object[pluginName]=new jwplayer.html5[pluginName](_api,_model.plugins.config[pluginName])}}else{_model.plugins.order.splice(plugin,plugin+1)}if(typeof _model.plugins.object[pluginName].addGlobalListener=="function"){_model.plugins.object[pluginName].addGlobalListener(forward)}}catch(err){jwplayer.utils.log("Could not setup "+pluginName)}}};return _model}})(jwplayer);(function(a){a.html5.playlist=function(b){var d=[];if(b.playlist&&b.playlist instanceof Array&&b.playlist.length>0){for(var c in b.playlist){if(!isNaN(parseInt(c))){d.push(new a.html5.playlistitem(b.playlist[c]))}}}else{d.push(new a.html5.playlistitem(b))}return d}})(jwplayer);(function(a){var c={size:180,position:a.html5.view.positions.NONE,itemheight:60,thumbs:true,fontcolor:"#000000",overcolor:"",activecolor:"",backgroundcolor:"#f8f8f8",font:"_sans",fontsize:"",fontstyle:"",fontweight:""};var b={_sans:"Arial, Helvetica, sans-serif",_serif:"Times, Times New Roman, serif",_typewriter:"Courier New, Courier, monospace"};_utils=a.utils;_css=_utils.css;_hide=function(d){_css(d,{display:"none"})};_show=function(d){_css(d,{display:"block"})};a.html5.playlistcomponent=function(r,B){var w=r;var e=a.utils.extend({},c,w.skin.getComponentSettings("playlist"),B);if(e.position==a.html5.view.positions.NONE||typeof a.html5.view.positions[e.position]=="undefined"){return}var x;var l;var C;var d;var g;var f;var k=-1;var h={background:undefined,item:undefined,itemOver:undefined,itemImage:undefined,itemActive:undefined};this.getDisplayElement=function(){return x};this.resize=function(F,D){l=F;C=D;if(w.jwGetFullscreen()){_hide(x)}else{var E={display:"block",width:l,height:C};_css(x,E)}};this.show=function(){_show(x)};this.hide=function(){_hide(x)};function j(){x=document.createElement("div");x.id=w.id+"_jwplayer_playlistcomponent";switch(e.position){case a.html5.view.positions.RIGHT:case a.html5.view.positions.LEFT:x.style.width=e.size+"px";break;case a.html5.view.positions.TOP:case a.html5.view.positions.BOTTOM:x.style.height=e.size+"px";break}A();if(h.item){e.itemheight=h.item.height}x.style.backgroundColor="#C6C6C6";w.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_LOADED,s);w.jwAddEventListener(a.api.events.JWPLAYER_PLAYLIST_ITEM,u);w.jwAddEventListener(a.api.events.JWPLAYER_PLAYER_STATE,m)}function p(){var D=document.createElement("ul");_css(D,{width:x.style.width,minWidth:x.style.width,height:x.style.height,backgroundColor:e.backgroundcolor,backgroundImage:h.background?"url("+h.background.src+")":"",color:e.fontcolor,listStyle:"none",margin:0,padding:0,fontFamily:b[e.font]?b[e.font]:b._sans,fontSize:(e.fontsize?e.fontsize:11)+"px",fontStyle:e.fontstyle,fontWeight:e.fontweight,overflowY:"auto"});return D}function y(D){return function(){var E=f.getElementsByClassName("item")[D];var F=e.fontcolor;var G=h.item?"url("+h.item.src+")":"";if(D==w.jwGetPlaylistIndex()){if(e.activecolor!==""){F=e.activecolor}if(h.itemActive){G="url("+h.itemActive.src+")"}}_css(E,{color:e.overcolor!==""?e.overcolor:F,backgroundImage:h.itemOver?"url("+h.itemOver.src+")":G})}}function o(D){return function(){var E=f.getElementsByClassName("item")[D];var F=e.fontcolor;var G=h.item?"url("+h.item.src+")":"";if(D==w.jwGetPlaylistIndex()){if(e.activecolor!==""){F=e.activecolor}if(h.itemActive){G="url("+h.itemActive.src+")"}}_css(E,{color:F,backgroundImage:G})}}function q(I){var P=d[I];var O=document.createElement("li");O.className="item";_css(O,{height:e.itemheight,display:"block",cursor:"pointer",backgroundImage:h.item?"url("+h.item.src+")":"",backgroundSize:"100% "+e.itemheight+"px"});O.onmouseover=y(I);O.onmouseout=o(I);var J=document.createElement("div");var F=new Image();var K=0;var L=0;var M=0;if(v()&&(P.image||P["playlist.image"]||h.itemImage)){F.className="image";if(h.itemImage){K=(e.itemheight-h.itemImage.height)/2;L=h.itemImage.width;M=h.itemImage.height}else{L=e.itemheight*4/3;M=e.itemheight}_css(J,{height:M,width:L,"float":"left",styleFloat:"left",cssFloat:"left",margin:"0 5px 0 0",background:"black",overflow:"hidden",margin:K+"px",position:"relative"});_css(F,{position:"relative"});J.appendChild(F);F.onload=function(){a.utils.stretch(a.utils.stretching.FILL,F,L,M,this.naturalWidth,this.naturalHeight)};if(P["playlist.image"]){F.src=P["playlist.image"]}else{if(P.image){F.src=P.image}else{if(h.itemImage){F.src=h.itemImage.src}}}O.appendChild(J)}var E=l-L-K*2;if(C0){G.className="duration";_css(G,{fontSize:(e.fontsize?e.fontsize:11)+"px",fontWeight:(e.fontweight?e.fontweight:"bold"),width:"40px",height:e.fontsize?e.fontsize+10:20,lineHeight:24,"float":"right",styleFloat:"right",cssFloat:"right"});G.innerHTML=_utils.timeFormat(P.duration);D.appendChild(G)}var N=document.createElement("span");N.className="title";_css(N,{padding:"5px 5px 0 "+(K?0:"5px"),height:e.fontsize?e.fontsize+10:20,lineHeight:e.fontsize?e.fontsize+10:20,overflow:"hidden","float":"left",styleFloat:"left",cssFloat:"left",width:((P.duration>0)?E-50:E)-10+"px",fontSize:(e.fontsize?e.fontsize:13)+"px",fontWeight:(e.fontweight?e.fontweight:"bold")});N.innerHTML=P?P.title:"";D.appendChild(N);if(P.description){var H=document.createElement("span");H.className="description";_css(H,{display:"block","float":"left",styleFloat:"left",cssFloat:"left",margin:0,paddingLeft:N.style.paddingLeft,paddingRight:N.style.paddingRight,lineHeight:(e.fontsize?e.fontsize+4:16)+"px",overflow:"hidden",position:"relative"});H.innerHTML=P.description;D.appendChild(H)}O.appendChild(D);return O}function s(E){x.innerHTML="";d=w.jwGetPlaylist();if(!d){return}items=[];f=p();for(var F=0;F=0){o(k)();k=D.index}o(D.index)();n()}function m(){if(e.position==a.html5.view.positions.OVER){switch(w.jwGetState()){case a.api.events.state.IDLE:_show(x);break;default:_hide(x);break}}}function A(){for(var D in h){h[D]=t(D)}}function t(D){return w.skin.getSkinElement("playlist",D)}j();return this}})(jwplayer);(function(b){b.html5.playlistitem=function(d){var e={author:"",date:"",description:"",image:"",link:"",mediaid:"",tags:"",title:"",provider:"",file:"",streamer:"",duration:-1,start:0,currentLevel:-1,levels:[]};var c=b.utils.extend({},e,d);if(c.type){c.provider=c.type;delete c.type}if(c.levels.length===0){c.levels[0]=new b.html5.playlistitemlevel(c)}if(!c.provider){c.provider=a(c.levels[0])}else{c.provider=c.provider.toLowerCase()}return c};function a(e){if(b.utils.isYouTube(e.file)){return"youtube"}else{var f=b.utils.extension(e.file);var c;if(f&&b.utils.extensionmap[f]){if(f=="m3u8"){return"video"}c=b.utils.extensionmap[f].html5}else{if(e.type){c=e.type}}if(c){var d=c.split("/")[0];if(d=="audio"){return"sound"}else{if(d=="video"){return d}}}}return""}})(jwplayer);(function(a){a.html5.playlistitemlevel=function(b){var d={file:"",streamer:"",bitrate:0,width:0};for(var c in d){if(a.utils.exists(b[c])){d[c]=b[c]}}return d}})(jwplayer);(function(a){a.html5.playlistloader=function(){var c=new a.html5.eventdispatcher();a.utils.extend(this,c);this.load=function(e){a.utils.ajax(e,d,b)};function d(g){var f=[];try{var f=a.utils.parsers.rssparser.parse(g.responseXML.firstChild);c.sendEvent(a.api.events.JWPLAYER_PLAYLIST_LOADED,{playlist:new a.html5.playlist({playlist:f})})}catch(h){b("Could not parse the playlist")}}function b(e){c.sendEvent(a.api.events.JWPLAYER_ERROR,{error:e?e:"could not load playlist for whatever reason. too bad"})}}})(jwplayer);(function(a){a.html5.skin=function(){var b={};var c=false;this.load=function(d,e){new a.html5.skinloader(d,function(f){c=true;b=f;e()},function(){new a.html5.skinloader("",function(f){c=true;b=f;e()})})};this.getSkinElement=function(d,e){if(c){try{return b[d].elements[e]}catch(f){a.utils.log("No such skin component / element: ",[d,e])}}return null};this.getComponentSettings=function(d){if(c){return b[d].settings}return null};this.getComponentLayout=function(d){if(c){return b[d].layout}return null}}})(jwplayer);(function(a){a.html5.skinloader=function(f,p,k){var o={};var c=p;var l=k;var e=true;var j;var n=f;var s=false;function m(){if(typeof n!="string"||n===""){d(a.html5.defaultSkin().xml)}else{a.utils.ajax(a.utils.getAbsolutePath(n),function(t){try{if(a.utils.exists(t.responseXML)){d(t.responseXML);return}}catch(u){h()}d(a.html5.defaultSkin().xml)},function(t){d(a.html5.defaultSkin().xml)})}}function d(y){var E=y.getElementsByTagName("component");if(E.length===0){return}for(var H=0;H0){var K=z.getElementsByTagName("setting");for(var P=0;P0){var M=L.getElementsByTagName("group");for(var w=0;w'; + return $code; + }else + return false; + } + + /** + * Writing CB Player function to play videos on facebook + */ + function cb_facebook_embed($params) + { + $vdetails = $params['video']; + $config = urlencode(BASEURL."/player/".CB_PLAYER."/embed_player.php?vid=" + .$vdetails['videoid']."&autoplay=".config('autoplay_embed')); + $embed_src = BASEURL.'/player/'.CB_PLAYER.'/player.swf?config='.$config; + return $embed_src; + } + + + register_embed_function('cbplayer_embed_src'); + register_actions_play_video('cb_player'); + cb_register_function('cb_facebook_embed','fb_embed_video'); + //include Pak Player JS File + $Cbucket->add_header(CB_PLAYER_DIR.'/cbplayer_header.html'); + $Cbucket->add_admin_header(CB_PLAYER_DIR.'/cbplayer_header.html'); + + /** + * Including plugin files + */ + include("cbplayer.plugin.php"); +} +?> \ No newline at end of file diff --git a/upload/player/cbplayer/cbplayer.plugin.php b/upload/player/cbplayer/cbplayer.plugin.php new file mode 100644 index 00000000..8dce5a57 --- /dev/null +++ b/upload/player/cbplayer/cbplayer.plugin.php @@ -0,0 +1,4 @@ + \ No newline at end of file diff --git a/upload/player/cbplayer/cbplayer_header.html b/upload/player/cbplayer/cbplayer_header.html new file mode 100644 index 00000000..081a7407 --- /dev/null +++ b/upload/player/cbplayer/cbplayer_header.html @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/upload/player/cbplayer/embed_player.php b/upload/player/cbplayer/embed_player.php new file mode 100644 index 00000000..3c3fec84 --- /dev/null +++ b/upload/player/cbplayer/embed_player.php @@ -0,0 +1,104 @@ +"no video details found"))); + +header('Content-Type: text/xml'); + +$video = $vdetails; + + +//Loading video files +$vid_file = get_video_file($vdetails,true,true); +$hd_file = get_hq_video_file($vdetails,false); + +/* Checking for youtube */ +$ref = $video['refer_url']; +//Trying other method +if(function_exists('get_refer_url_from_embed_code')) +{ + $ref_details = get_refer_url_from_embed_code(unhtmlentities(stripslashes($video['embed_code']))); + $ytcode = $ref_details['ytcode']; +} +?> + + + + + + http://youtube.com/watch?v= + + + + + + true + /skins/glow/glow.xml + hd-2,plugins/related/related.swf + + + + + + + + + + http + + youtube + + + + + + /plugins/related/related_videos.php?vid=&title=&tags= + false + More suggested videos + + + + + + + + + + 3 + 1 + 0.5 + + + + + + + + \ No newline at end of file diff --git a/upload/player/cbplayer/player.swf b/upload/player/cbplayer/player.swf new file mode 100644 index 00000000..7d024beb Binary files /dev/null and b/upload/player/cbplayer/player.swf differ diff --git a/upload/player/cbplayer/plugins/hd.swf b/upload/player/cbplayer/plugins/hd.swf new file mode 100644 index 00000000..86718bc6 Binary files /dev/null and b/upload/player/cbplayer/plugins/hd.swf differ diff --git a/upload/player/cbplayer/plugins/related/related.js b/upload/player/cbplayer/plugins/related/related.js new file mode 100644 index 00000000..47160767 --- /dev/null +++ b/upload/player/cbplayer/plugins/related/related.js @@ -0,0 +1 @@ +(function(a){var b=function(e,t,w){var l;var g;var i;var q;var v;var u;var s;var j={cursor:"pointer",position:"absolute",left:"0px",top:"0px",margin:"0px",padding:"0px",display:"block",width:"50px",height:"50px"};var n={backgroundImage:"url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAQAAAGQCAYAAACJccGfAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAJlJREFUeNrskksKwDAIRFV6/+v1Nv0sQymkBD+jVchGdOY5hIlop6GEHrXd75hOnNqNIA5Y0cQaPisLGiZgQbbzFdhrS0/ksUUhhb02aKW0Rh6w0i55OCqRdmLd6Mb4C7nzKJkYCqkPh4nLv0QXNIJsg9BRVkpz+Nj6oKOQ+qSuYZuH9HVCcka4qCEgiYnLtWze+Garfu0lwAArHE4YPfyZuAAAAABJRU5ErkJggg==)",backgroundRepeat:"no-repeat",backgroundSize:"100% 100%",opacity:0,webkitTransition:"opacity 150ms linear",MozTransition:"opacity 150ms linear",msTransition:"opacity 150ms linear",transition:"opacity 150ms linear",cursor:"pointer",visibility:"hidden"};var o={position:"absolute",border:"none",color:"#FFF",display:"block",font:"16px/24px Arial,sans-serif",overflow:"hidden",width:"240px",margin:"0 0 0 0",textAlign:"center",textTransform:"none",textShadow:"#000 1px 1px 0",padding:"0 0 0 0"};var z="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAArlJREFUeNrsWe1xozAQhZv8hw7sDkQH5CpwOnA6oATSQdIB7sC5CshVgFMBuQqcq0BZzT3N7SiAFiw7nol2ZkcyWi16Wn28xUkSJUqUKN9CtNYlaUPa68/So01BvXanjiddAGBFxY70lvRA+kz64piZtnvSNX6/oc+Q3R1pgbb7NE3/XCIKG9IjaWciIrTrUd94otv57EKC0FgKmdCuQr1FOQUmQx99NjBmOWG2Gqkd6RaD2rIBHrE0p3w0ErulQMyMdlI7FgkOorbREfjpJHZzQSgMoBTaNQMgKrYHtO+Uwp7xvnMukEYYjYYdq2MgSskSZVFpQgIxp04ttPOB6Oz9IfBXS+zmABGFmA18CkRnDwHhhatDgchmAuk8IOzSunogEhB2w68uBmTB0qo9IDp7DF80Igs3+xSI6is3+9zj1wdCf9XxWwovxJJR89FIzLwQVRJSZlIU7bBfC2IvoR44YMJTlIWkUTsgGikZPCtpXEjjWxaJ5ipo/AmJ1VGSMIVIrG5m5cVp+oteVNi0lepjqa6xeUeqWyDVLcj+3ZPqFhdJdQdoe6iPD2USJUqUKFFOSMLUGfyqKSZxDiClgBCaG79aQFi998yPmcRROQNfeSJUOlEyN3g+YJONTEwWerZ7psrSbJ498ogwrtWirFmOYZMvhf7Wz4ZNWM8+gPfBbn6e5FD5aJcHZrRnM2uBVGxgG/a8ZsA75lPZfAf+a+b/GHRpEZl7ZcvjCR8GODHkYojkLQDsRlyaPgf4OTAflkCad/5FWxIMCBMz+LsUYoBQ8duxeYHdQ/LvD58xPzn3w58zuzw4jWez/YAvNWvU145NDuqeAwyn72tsYuNnR/Wn5P+/Wz8RQeu/GIj2aTm783uLTbp31vkj3xdoN/U9s2nxLMOead2sk/WvsWdUEiVKlChRrlE+BBgA99ZhJqocsJoAAAAASUVORK5CYII=";var A="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAytJREFUeNrsWC2T2zAQdToBAQUGBYaGgYGBBgUGBwwPHAg8UFB4P+VgQMGBgoMGBQcLAw0NCgwKDAoMOpPuJk/TrWpL68S5Xue0Mxp/PUt6q11pd6MoSJAgQf4nmZ36436/T+myosbX2PrcUqupfcXz2oebzWbNsxIhAjyZAhPjwStMRoohGYsJ7wZwS2oJvj0SofbiRIjEEiR4sJIGrRW4d9R+YpKVY3VzEB/EueTNSBLXWIGth4TB8SosqP2gdoNvf2vz2NcW/1wP4c4mIsxpR4OyxjofDqbCWv5M7RvMpwCmj0zHfePfQdy5K3IwEwzkxcF3+P5R+MsnmE7htPXjGK0PN5oIaSbBZEolrsFKSBIlnPrg4MC6pAQunXJFeOtshnzCwr3FxG0SZge7h8+sPatSQyGrKYmkcEINbuEg8YCVmuO7TyolTk0k7tn/h3A+EhGcX+PItRI3bvtVytJDohzrxP+KSOohwedLJ7bqF0vki4dEa+KvU0ORc4i0Sqdj3HsPCT7srnCvWd12SiK1OAN8uLmHRC6wGn+rpyTCE0gUh9MOE75xkOD77yK8d6UIiQ83iggOp1po04dj03rqIVHB0WtX7kEkFsDXY3IUrbPz+RDTIIUCxxr/YJHYgYQ5a1ySK3HjiWCH4Y5XTAZac+FanPJXIipYuRIn7hOKWp2SYF06sYqFuV00sXqdqW5P2O4tKiiLDztFdB0kSJAgQV6J8KGpiMtUkQS19eQZIh+Cdk0KMVJqxV/xUOFgAG/I26lCgpjNK3MlgQ067JCbHOIhEVM1eP+AE3qD/zJ6frKiARPeM5lDDZmuHM5k/B4h0BaKyPBfPcnJz0R4UmK5zURvjRah5Vtxv+npJzMmh35irNBHs0JsStRygc8mWxErPZUF7MRoCpr1lUI5cGSl3CHYbGA+rP07eh+NSIVPJtInHWuSK+nQaOfDR8eyqTGbHNkkl2TvRYb47OUg1moB8yqiP0uri57aVQ6cId0hnV3AjFL4l9ypYg05LZFGaLvDsykwNNBuE/2u2DdwaLsIXeL/TDxHlnNXYoOo8D6NggQJEiTIS5RfAgwAwPzrJ/KrwvYAAAAASUVORK5CYII=";var B=function(){if(q){e.pause(true);w.style.visibility="visible";w.style.opacity=1;try{e.getPlugin("display").hide();e.getPlugin("dock").hide()}catch(C){}}};function y(C){if(t.oncomplete!==false){setTimeout(B,50)}}function k(C){if(C==q){console.log("RELATED: Failed to load "+C)}else{console.log("RELATED: "+C)}q=undefined;u.innerHTML="";d();if(t.usedock!==false){e.getPlugin("dock").setButton("related",B,A)}}function d(C){setTimeout(r,200);w.style.opacity=0;try{e.getPlugin("display").show();e.getPlugin("dock").show()}catch(D){}}function r(){w.style.visibility="hidden"}function p(D){q=undefined;u.innerHTML="";d();var C=e.getPlaylist()[D.index];if(C["related.file"]){q=C["related.file"]}else{if(t.file){q=t.file}}if(q){if(t.usedock!==false){e.getPlugin("dock").setButton("related",B,z)}a.utils.ajax(q,f,k)}else{k("No related videos file found")}}function f(D){var J=[];var K=[];try{J=a.utils.parsers.rssparser.parse(D.responseXML.firstChild)}catch(I){k("This feed is not valid XML and/or RSS.");return}for(var H=0;Hi[4]){if(L==i[3]-1||(i[1]+10)*(L+2)>i[5]-40){break}else{L++;E=0}}else{E++}}c(i[4],i[5])}else{k("RSS feed has 0 entries that contain title,link and image.")}}function h(){if(e.getRenderingMode()=="flash"){return}e.onPlaylistItem(p);e.onComplete(y);m(w,n);w.onclick=d;s=document.createElement("div");m(s,j);m(s,{background:"transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAABKhJREFUeNrsWF1IY1cQvtGsVruSoCiKoqH+FVFvQClBxITimw/aLir4orCgxRfz5pOkqa9K1lSs+tCksKKomAgSlJImBRHqi0YRKihJ4y8oXuuu/z/TmXDvchH3p5uke6X3gyFzT85Jzndm5szMZRgZMmTIkCFDhoz/FwBAjfIM5bvHSkCJwgaDwd84jgOLxQI4vPSYCChQMq+vr394jUAdTk9Pwel0QklJCcTHx3/zGEh8jvLt1dXVKjwAsszY2Ngrq9X67FEQWVtbO4e34O7uDjY2NmBkZKRX8q6VmZkJZrMZDg4O3sYH1tfXoauryy51L2uOi4sDnU4Xio2TkxNwuVwwODgINzc3ISKXl5ehsZycnJeR+tPYKBDx3d7eBra3tw2zs7OfraysMKgzAwMDDF4CTFVVFRMbG8skJCQwaLXSxcVFNa6ZC/dPlVGyyi8o3uPjY83U1JRCqVQSCcDnL30+348syz5Rq9WMVquluVopxMRTlHKUr1G+QlG9Z36G2+3+ldzr4uICJicnKb94IrGXmDDXF+OG3Pjp3tra+qO9vf34PRu7zsrK+pMUhUIRcrFIIVwi15g3TklJSkpiCgoKSFW/Y74KA72CFIwj5uzsTDJEuL29vU2BSHl5OZOXl0c+zz7gVvEYJyXZ2dmhmDg/P2d2d3clkzeejo6O/oSnG7pW8YQBgxuQjI9OXzTvCYoBb689IZesrq5CZWVlxGIkbNTU1Jimp6ffJDt0NcDsDg6H43d8bEJ5jvIz5pBdYc7R0RH09vYSCekQSU9P/6Kpqekl5gv4EJDV6LZKS0sTKmJWMqk8MTHRgDkBMAG+kwRZor+/H5KTkwVr2KRYmthUKhU0NjbCzMwMbG5uwv7+PmBAh+JheHgYKioqAK9cgYRfHEdSgop3FfhAYRkZMmSIk6ceJWo5I+a/JOP1eg3RSoAx/+JEWRQLvUdAWeLHLHyK8KPU8mPNKCZ+jGB54LeaRd/TZw5vMZNoTq34OZIWoarWiE2RNzc3V9PZ2cnRGJbjLzAZajiOox6cyGiwgfoeC0hvfn5+AGGsr6+/T8bY1tbmxbUBbIc1VqvV29DQQC2AEdtfYfMtPT09VGCaIu7jHo9HyAF0gp7Dw0M/jZFOlqquriZrmfgXchw/z4SAvr6+Dn49zVW1trZyc3NzDrIIfU8bRt3W0dFBC2gdpKamkhs2R6vV9aL8RUp3d7dmeXmZVPJ9hvSJiQkDWoQe7cI8wvz8fF1paSmTkpJClg2YzWbv+Pi4lvoSEV4YjcYW7O+dWBU4saevw7G6aAe702AwMDs7O0bcoNFut1MvUqfT6ZZbWloYvV5/TL5PLrKwsOB801IWF5O7BIqKigxDQ0OBjIwMjfAduppPo9EsY6epRbcSDuPvaLmWh39WYVPlEF4k4ulSHPiDwaAFS3jw+0OxzOEa8nH/PdfyCIFOv2Gz2UCIBboI6K0kX4vVRusG1d+7PlV8BSvERLMQE6g7+M1wIj8Xr/eIikebUAnTepfLJaz7pIlPIGL6iLVkYa6srMz2yUt8igt+Ix9DhC0sLFwSbjwpVCQ5YWyElQoJGTJkSBD/CDAA0ma8tkQpWYgAAAAASUVORK5CYII=)"});s.onclick=x;w.appendChild(s);g=document.createElement("div");m(g,j);m(g,{background:"transparent url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAA0xJREFUeNrsVz1IW1EUjtKtQyh0yRQr2kFCIlHB7cUMBhpCXKKY5UVBnfwZWgUppFvHOEUkg84ucXBxeg1ChiKmUCQ0EV+K1Q4BnyKImujtOem95fp8pvTHeIX7weHlnXNeON+955x7rs0mISEhISEhISEh0UgQQoIgOyBvfuPnBvkM8lZEEiHCYWpqioA6buHnrVQqVeY3MzODfglhiFxfX1eICX19fRikypF4fnV1VTX7oQnELgSR9fX198QC/f39p2D2wM+nZ2dnJbN9aGiIEVFE2RRlcHCQwIrfIjMxMVG+vLz8aNZHIhFGQigimBqK1+vNn5yckHo4Pz8n4McI5EQicYNQR0fHzt7eniWJ3d1d4na7eRJ2m8Cw+/3+L1ZEVFV9NCSwOz07PDwsWhEBPenu7r7RzUQl8bJarX6tVyMXFxckEAgUhN0RiNEP58mNtgUtl8RiMbK/v3+L0MjIiC4cGYjrlTlQbMVdXV21mnA6neTo6OguMuIAVv67Ocienh5W2Bis4nK5vlmlmlDnyNLS0ms+uPHxcRaggSc7dfOEQqFT3m92dla8AxGCJNvb23xwKGGTnxoMBkmhUCDz8/O8n1C1kuACs5x+KeImv4RNQkLiUd3ZNZAHaaPN//sPfT7fh4c4E5r/YfXjIAY91xJ17CjTnD5Bv9FBwlRnp7tJ6NPTqBTCO7gOc9Rya2uroes66e3txQA1RVHI5OTktNlOdQoI3kMSeC+Zm5vDUz8MujQckEhWQ30+n89x08C9EolvbGyk6QzlpKJDMDoSWV1d1Xg7+gOIgkbYoVwuhys/3dbWhsEjQTzp9a2tLYPtDOjTfxLTk78lk81mB+DxDgTvHs6mpqYX7e3tGry3mO3sm0wm40P74uJiaXh4eKFYLJbgu07QLYyNjbWwMqPPgUbUyBrcMWywwLX8xndN036NI5ubm7wddysGxNZGR0cxuBWHw9GZTCYXjo+PMfhP+D00iRrRaDS6kkqlShyhe08v1TB+1vrBwcEy3sGBDKZPbZLFdKJ2A1IG7TpNLVbUBqQgNgl08pTL5RxrApFIBPVaI7ueSsd0fvDTuPYbp3aDGyDt1IeN+Ozu7uH0ekOKXUJCQkJCguKHAAMAvduPUQLB93IAAAAASUVORK5CYII=)"});g.onclick=d;w.appendChild(g);v=document.createElement("div");if(t.heading){v.innerHTML=t.heading}else{v.innerHTML="Watch related videos"}m(v,o);w.appendChild(v);u=document.createElement("div");w.appendChild(u);m(u,{position:"absolute"})}e.onReady(h);this.resize=function(E,C){if(e.getRenderingMode()=="flash"){return}if(!i){i=[140,80,5,2,E,C,0,0];if(t.dimensions){var F=t.dimensions.split(",");for(var D=0;D<4;D++){i[D]=Number(F[D])}}}c(E,C)};function c(D,C){m(w,{height:C+"px",width:D+"px"});m(g,{left:(D-50)+"px"});m(u,{left:Math.round(D/2-i[6]/2)+"px",top:Math.round(C/2-i[7]/2)+"px"});m(v,{left:Math.round(D/2-i[6]/2)+"px",width:i[6]+"px",top:Math.round(C/2-i[7]/2-30)+"px"})}function x(C){e.seek(0)}function m(C,D){for(var E in D){C.style[E]=D[E]}}};a().registerPlugin("related",b,"./related.swf")})(jwplayer);(function(a){if(a.related){return}a.related={};a.related.thumb=function(e,g,j,i,p){var b;var d={border:"1px solid #000",webkitBoxShadow:"0 0 4px #000",MozBoxShadow:"0 0 4px #000",msBoxShadow:"0 0 4px #000",boxShadow:"0 0 4px #000",backgroundColor:"#000",backgroundSize:"cover",position:"absolute",textDecoration:"none",display:"block",margin:"0 0 0 0",padding:"0 0 0 0"};var l;var o={psition:"absolute",left:"0px",top:"0px",border:"none",margin:"0 0 0 0",padding:"0 0 0 0"};var n;var k={backgroundColor:"rgba(0,0,0,0.8)",left:"0px",position:"absolute",border:"none",color:"#FFF",display:"block",font:"12px/26px Arial,sans-serif",overflow:"hidden",margin:"0 0 0 0",textAlign:"center",textDecoration:"none",textTransform:"none",padding:"0 0 0 0",height:"26px"};function f(q){c(b,{border:"1px solid #FFF",webkitBoxShadow:"0 0 4px #FFF",MozBoxShadow:"0 0 4px #FFF",msBoxShadow:"0 0 4px #FFF",boxShadow:"0 0 4px #FFF"})}function m(q){c(b,{border:"1px solid #000",webkitBoxShadow:"0 0 4px #000",MozBoxShadow:"0 0 4px #000",msBoxShadow:"0 0 4px #000",boxShadow:"0 0 4px #000"})}function h(){b=document.createElement("a");b.setAttribute("href",i);b.setAttribute("target","_top");b.onmouseout=m;b.onmouseover=f;c(b,d);c(b,{backgroundImage:"url("+j+")",width:(e-2)+"px",height:(g-2)+"px"});l=document.createElement("img");l.setAttribute("src","data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAKAAAABGCAYAAABL0p+yAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAACF9JREFUeNrsXYtO20gUtccWILoIFgS0IKDQAoUusEBBS///c6IQqwIJoqAdT/z2PO487NjJvZIJNxBnYE7u48yxx/9+9PWCEOL5vs+O+HuhH3+fPOcnzyl9Ep8nPwfhPU/i1xV+XvOn75s9L/Tzx3zs0/eR+tnY8/FwfXZ+kT89Vzqe9G+c/r2A8ZD0/arjkYxPOp7qXObnIjwf9Cg6d35o2Ds9BmHxRKXJVvnFx3QCMj8HoxwMKbBVk0+4wK5NttQHgrEABp8UPjAp0AsTkE1izSecD15hElW+8P0lj+n7p/9P3vikwK7Mla/y87nSBN4fegzpOV5jJwyCoBKZ9MAommzloyjqEc5kC31RlFX5kKjrK8AgGZ8QjNXIIwcjOMpVo3Ap6laBzQ8SNaAD5jA2IPgmCfAG9HXj4g/CIrCqqbYc5UQD9hVgsABjEfhKMGpEIgswlic5PxfJokHFTya/6kujnBYYFFEZEnU1wagR9eI0+0yPEX3tB+8X4ClYI+U2DsZq/ecIjOk/O32/ul+s88RgFEZhk5TrHIwAcBIxGIFR74UeEX1tpPpFsxTMmfz8ky9qYAp1HdfnROEC+KQ+AUSiki+rpzh1FNfXTLktglEUdUt+YW7LPil/8IhWkzFK6rs3aEEoTcFyMHD+AE0wQrpZcdQV+LXuWu7Lu1lRlJOkYOnkE/4HURp1+d2s0NfoZqH1oAJ4cX03TCLe2NO0kNAIqAQfB4zcbtaku4V0r6UOzITa4Ly/KCprp1wVGCDg1AMjr6Fx0c1qUivvSVMReRYWBoRoDhhIrTQCRnueTZpypSlY3M3CqQ07Dq/a3WY+mEN0Qq2UaBRbYxFQRCA7o1a0GwhFai0V+SKS1STlWgK9RTDqNRBAqoU+7/ncJkNIo9gDENLdzrqbhRLKgkhgRigbdLNgDtFVNytb3ZCDERj1lDSKNQADKRjUYAR1t8putgFCGdxNmoARSiibjEcMRtNu1oBQBtMoTlKwiGqpURc6dV4J0C5TriWhbA1GCfWiAUZ5nQdvaGxSLifqadMobiKgDqGsmmSnS21mYJR2sxqEMoxaEVAtEGpFVedJga6XciWEshWN4qQG9B1EOSNC2WppSxV1Ad2sorsV11mVyfZFvizqVsdnSygTALBLUc8JjeIuBTtMudarG5pg7LM8SkUoy31IPZjPTQI8pzSK4y7YjVYPRijry6Oa1eoZ8my6qxuWWj1DQnlCj0ZoFDcAtNLqFf2OaPVMRAkgrR4w5XZHq/dOj0ZpFPsmhCdGcCKPklAXHdTqma8mmKRgt/IoTnf7Qo+Izm3kddzqcqwOyaOqEzSf8ijoeABg9PwR/TIMw/DN64nJ5VgtglHd0MC0ei6A3h2tHohqieu7YRzxKPDGXs8sLAKp+1o929UNS60emNBuXquX1HeDpaWlyOux5SkYrBJpSKunSyg71+qZy6NU4zG58kyyhvsnjnjLy8uv3hzYNAXPUB4F5xRno9XTJ5Rt5FrCBofRKPS5AQXe2Jsjq6dg68sidVc39LR6XZVHyTlE1bXUAjDSNEu/PFN/tLKy8uHNoRVSsIFWz3hpC6rVK/ouo24HtXp+6XUv9Hej1dXVyJtzy1JwtZt1Tij3UaunkEeZavVEKZc+jugzw09/fXrzFsRCEhCFPKrhi7+dyKNIZ7R6BvIoRqPQ5yIKvLG3YBYWU9zMtXpObosh4Bgbl0fppdy4voubirW1tchbYAsDElho9YBpsUmtnsllkaArz3QJZZhWz0tolPX19VcPbZqCXcujzC/+7opWzzmhPKF+DLwBBd4YYVeNgBqrG+CLv53Lo4DdrEN5lK1Wj61WEP85bi42NjY+EG4cAJY+qb3T6jm+E4GCWtGQRzE1yt+bmxFCTEnDkI5q9aAp10yrJ5JHcX0ooe2TUVzfbW5tviG0wF1wYKEaMetmtQnlLmn1KgCP6zv6OqZG2drawvrOJAI2qdXrvzxKGHWZGmV7exvTrPVaMHCtVny9rwt5lOXqRktavaSbHe7s7CCN4i4Fq7V67d6JQMIxNnhbDKEihqVZxt8NdnZ3Mc26T8GOL/5uVKtnurqh0OrxtXvsop6YRtn9/BlplHZSsGOtnpDQVmv13F/8Db4SjdEoX/a+YH032xQsoC56Jo/S0OoxGmVvbw9plFZTsPVGLS2B0dlGLaUaMruoZ39/H+u7WURAkYq43Y1a2tHqFYAdq40HBwcHmGZnXQM2K48y36hFBUbDjVoYjXJweIg0SjdScOBUq9dNeVScZj1GoxweHWGa7WQEnKFWr8HVjYxGOfp6hDRKJwEYEMuNWhTCgdls1MJolOPjY6zv+hIB3Wj12pNH8XwvoVFOTk6QRulNDZjwgO52DWpIqyfeNSijUU6+fcP6rn8pOKhr9WxSLkCrZyqPqvhMjfL99BTTbP9TcF+0en52b5TTszOkUeZmJaT78qhJArzB2fkZptn5ioBBl3cNSm4x64/Of5wjjTK/EbD9jVoUYGQ0yo+LC6zvFqEG7MpGLaka5eLyEmmUxUvBwO7WvVYvo1Euf/7E+m5Rm5AZyKNofecN/rm6wjS76BGwTa1eem+Uq+srpFHQch7QhTxKckPxCT0Do1Gubq4xzaIpeEAAGIEpN1OjXN/cII2CJucBHSpSGI3y7+0t1ndolilYA4wpjXJ7d4c0CppuCjau/ybx9lBxxLu7v8f6Ds00BWvLo5ga5f7hF6ZZNNsICN81iIkCPH/46/EBaRQ0ewD6NUU0t5vN1CgPj4+YZtEcRsA0BUs2PI536qHAQxoFrYEaMCC8bpbRKP89PWF9h9Z8BCxcB8w2PH76/RtpFLS2uuDk3ijEjyjwsL5Da9X+F2AAdhpbcs9KP5oAAAAASUVORK5CYII=");c(l,o);c(l,{width:e-2+"px",height:g-20+"px"});b.appendChild(l);if(p){n=document.createElement("div");n.innerHTML=p;c(n,k);c(n,{top:(g-28)+"px",width:(e-2)+"px"});b.appendChild(n)}return b}function c(q,r){for(var s in r){q.style[s]=r[s]}}return h()}})(jwplayer); \ No newline at end of file diff --git a/upload/player/cbplayer/plugins/related/related.swf b/upload/player/cbplayer/plugins/related/related.swf new file mode 100644 index 00000000..2d0c1131 Binary files /dev/null and b/upload/player/cbplayer/plugins/related/related.swf differ diff --git a/upload/player/cbplayer/plugins/related/related.xml b/upload/player/cbplayer/plugins/related/related.xml new file mode 100644 index 00000000..82dd491b --- /dev/null +++ b/upload/player/cbplayer/plugins/related/related.xml @@ -0,0 +1,31 @@ + + Related + related.swf + 1.0 + Compatible with 5.0 + LongTail Video + This plugin displays a menu with related videos. + http://developer.longtailvideo.com/trac/browser/plugins/related/ + + + + file + + + URL link to an mRSS playlist containing related video metadata. + If not set or empty, the "related videos" screen will display "No related videos found" + + + + oncomplete + true + Show the related videos screen when the video completes. + + + usedock + true + If false, the dock button for popping the related videos will not be shown. + + + + diff --git a/upload/player/cbplayer/plugins/related/related_videos.php b/upload/player/cbplayer/plugins/related/related_videos.php new file mode 100644 index 00000000..3f3ff426 --- /dev/null +++ b/upload/player/cbplayer/plugins/related/related_videos.php @@ -0,0 +1,28 @@ +$title,'tags'=>$tags, +'exclude'=>$videoid,'show_related'=>'yes','limit'=>8,'order'=>'date_added DESC')); +if(!$related_videos) + $related_videos = get_videos(array('exclude'=>$videoid,'limit'=>12,'order'=>'date_added DESC')); +?> + + + + + <?=$video['title']?> + + + + + + \ No newline at end of file diff --git a/upload/player/cbplayer/preview.jpg b/upload/player/cbplayer/preview.jpg new file mode 100644 index 00000000..503abb32 Binary files /dev/null and b/upload/player/cbplayer/preview.jpg differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/background.png b/upload/player/cbplayer/skins/glow/controlbar/background.png new file mode 100644 index 00000000..3ccf7d9d Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/background.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/blankButton.png b/upload/player/cbplayer/skins/glow/controlbar/blankButton.png new file mode 100644 index 00000000..010159f3 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/blankButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/divider.png b/upload/player/cbplayer/skins/glow/controlbar/divider.png new file mode 100644 index 00000000..77cd829a Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/divider.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/fullscreenButton.png b/upload/player/cbplayer/skins/glow/controlbar/fullscreenButton.png new file mode 100644 index 00000000..e06aa50c Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/fullscreenButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/fullscreenButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/fullscreenButtonOver.png new file mode 100644 index 00000000..d2bc4fc7 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/fullscreenButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/muteButton.png b/upload/player/cbplayer/skins/glow/controlbar/muteButton.png new file mode 100644 index 00000000..40c40ab2 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/muteButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/muteButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/muteButtonOver.png new file mode 100644 index 00000000..96fe7bb0 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/muteButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/normalscreenButton.png b/upload/player/cbplayer/skins/glow/controlbar/normalscreenButton.png new file mode 100644 index 00000000..22295074 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/normalscreenButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/normalscreenButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/normalscreenButtonOver.png new file mode 100644 index 00000000..15db44d4 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/normalscreenButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/pauseButton.png b/upload/player/cbplayer/skins/glow/controlbar/pauseButton.png new file mode 100644 index 00000000..e399bf34 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/pauseButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/pauseButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/pauseButtonOver.png new file mode 100644 index 00000000..409d89d2 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/pauseButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/playButton.png b/upload/player/cbplayer/skins/glow/controlbar/playButton.png new file mode 100644 index 00000000..f8d9a007 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/playButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/playButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/playButtonOver.png new file mode 100644 index 00000000..3fe28484 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/playButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/timeSliderBuffer.png b/upload/player/cbplayer/skins/glow/controlbar/timeSliderBuffer.png new file mode 100644 index 00000000..73b371ab Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/timeSliderBuffer.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapLeft.png b/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapLeft.png new file mode 100644 index 00000000..72322171 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapLeft.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapRight.png b/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapRight.png new file mode 100644 index 00000000..626444a6 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/timeSliderCapRight.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/timeSliderProgress.png b/upload/player/cbplayer/skins/glow/controlbar/timeSliderProgress.png new file mode 100644 index 00000000..132a8e7d Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/timeSliderProgress.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/timeSliderRail.png b/upload/player/cbplayer/skins/glow/controlbar/timeSliderRail.png new file mode 100644 index 00000000..27851dfd Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/timeSliderRail.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/unmuteButton.png b/upload/player/cbplayer/skins/glow/controlbar/unmuteButton.png new file mode 100644 index 00000000..3658453c Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/unmuteButton.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/unmuteButtonOver.png b/upload/player/cbplayer/skins/glow/controlbar/unmuteButtonOver.png new file mode 100644 index 00000000..138ebb35 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/unmuteButtonOver.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/volumeSliderBuffer.png b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderBuffer.png new file mode 100644 index 00000000..5074decc Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderBuffer.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/volumeSliderProgress.png b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderProgress.png new file mode 100644 index 00000000..033c2e54 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderProgress.png differ diff --git a/upload/player/cbplayer/skins/glow/controlbar/volumeSliderRail.png b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderRail.png new file mode 100644 index 00000000..d0b49daf Binary files /dev/null and b/upload/player/cbplayer/skins/glow/controlbar/volumeSliderRail.png differ diff --git a/upload/player/cbplayer/skins/glow/display/background.png b/upload/player/cbplayer/skins/glow/display/background.png new file mode 100644 index 00000000..391152f5 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/display/background.png differ diff --git a/upload/player/cbplayer/skins/glow/display/bufferIcon.png b/upload/player/cbplayer/skins/glow/display/bufferIcon.png new file mode 100644 index 00000000..a3819c1e Binary files /dev/null and b/upload/player/cbplayer/skins/glow/display/bufferIcon.png differ diff --git a/upload/player/cbplayer/skins/glow/display/muteIcon.png b/upload/player/cbplayer/skins/glow/display/muteIcon.png new file mode 100644 index 00000000..e0408bbd Binary files /dev/null and b/upload/player/cbplayer/skins/glow/display/muteIcon.png differ diff --git a/upload/player/cbplayer/skins/glow/display/playIcon.png b/upload/player/cbplayer/skins/glow/display/playIcon.png new file mode 100644 index 00000000..cb384278 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/display/playIcon.png differ diff --git a/upload/player/cbplayer/skins/glow/dock/button.png b/upload/player/cbplayer/skins/glow/dock/button.png new file mode 100644 index 00000000..391152f5 Binary files /dev/null and b/upload/player/cbplayer/skins/glow/dock/button.png differ diff --git a/upload/player/cbplayer/skins/glow/glow.xml b/upload/player/cbplayer/skins/glow/glow.xml new file mode 100644 index 00000000..ff58439b --- /dev/null +++ b/upload/player/cbplayer/skins/glow/glow.xml @@ -0,0 +1,115 @@ + + + + + + + + + + + + + + + + + + + + + +
    '; + } + + + function get_announcement() + { + global $db; + $exec = $db->Execute('SELECT * FROM '.tbl("global_announcement")); + $ann = $exec->getrows(); + return $ann[0][0]; + } + + //Function used to update announcement + function update_announcement($text) + { + global $db; + $text = $text; + $db->Execute("UPDATE ".tbl("global_announcement")." SET announcement='$text'"); + } + +} + +//Function used to get annoucment for smarty +$Smarty->register_function('get_announcement','get_announcement'); +register_anchor_function(array('global_announcement'=>'global')); +add_admin_menu('Global Announcement','Edit Announcement','edit_announcement.php'); +?> \ No newline at end of file diff --git a/upload/plugins/global_announcement/install_global_announcement.php b/upload/plugins/global_announcement/install_global_announcement.php new file mode 100644 index 00000000..e11ef334 --- /dev/null +++ b/upload/plugins/global_announcement/install_global_announcement.php @@ -0,0 +1,23 @@ +Execute( + 'CREATE TABLE IF NOT EXISTS '.tbl("global_announcement").' ( + `announcement` text NOT NULL + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;;' + ); + + //inserting new announcment + $db->Execute("INSERT INTO ".tbl('global_announcement')." (announcement) VALUES ('')"); +} + + +//This will first check if plugin is installed or not, if not this function will install the plugin details +install_global_announcement(); + +?> \ No newline at end of file diff --git a/upload/plugins/global_announcement/uninstall_global_announcement.php b/upload/plugins/global_announcement/uninstall_global_announcement.php new file mode 100644 index 00000000..7fe1fc10 --- /dev/null +++ b/upload/plugins/global_announcement/uninstall_global_announcement.php @@ -0,0 +1,12 @@ +Execute( + 'DROP TABLE '.tbl("global_announcement").'' + ); + } + + un_install_global_announcement(); +?> \ No newline at end of file diff --git a/upload/plugins/pakplayer/admin/pakplayer.html b/upload/plugins/pakplayer/admin/pakplayer.html new file mode 100644 index 00000000..50f20ca9 --- /dev/null +++ b/upload/plugins/pakplayer/admin/pakplayer.html @@ -0,0 +1,40 @@ +

    Pakplayer License


    +
    +
    +
    + +
    +
    +
    +
    + + + + + +{foreach from=$pakconfigs item=config key=name} + + + + +{/foreach} + + + + + + + + +
    Pakplayer license
    {$config.title} +
    + +
    +
      
     
    +
    +
    +
    + +{FlashPlayer width="520" height="300"} +
    +
    \ No newline at end of file diff --git a/upload/plugins/pakplayer/admin/pakplayer.php b/upload/plugins/pakplayer/admin/pakplayer.php new file mode 100644 index 00000000..6103e881 --- /dev/null +++ b/upload/plugins/pakplayer/admin/pakplayer.php @@ -0,0 +1,50 @@ + array("default"=>"#75dc18","type" => "textfield" , 'title' => 'Buffer Color','isColor'=>true), +'backgroundGradient' => array("default"=>"high","type" => "textfield" , 'title' => 'Background Gradient',), +'backgroundColor' => array("default"=>"#222222","type" => "textfield" , 'title' => 'Background Color','isColor'=>true), +'timeBgColor' => array("default"=>"#222222","type" => "textfield" , 'title' => 'Time bgcolor','isColor'=>true), +'autoHide' => array("default"=>"never","type" => "textfield" , 'title' => 'Auto hide'), +'volumeColor' => array("default"=>"#18dc73","type" => "textfield" , 'title' => 'Volume color','isColor'=>true), +'borderRadius' => array("default"=>"10","type" => "textfield" , 'title' => 'Border radius'), +'sliderColor' => array("default"=>"#e3bad0","type" => "textfield" , 'title' => 'Slider color','isColor'=>true), +'tooltipColor' => array("default"=>"#000000","type" => "textfield" , 'title' => 'Tooltip Color','isColor'=>true), +'timeColor' => array("default"=>"#ffffff","type" => "textfield" , 'title' => 'Time color','isColor'=>true), +'buttonOverColor' => array("default"=>"#e3bcba","type" => "textfield" , 'title' => 'Button over color','isColor'=>true), +'timeBorder' => array("default"=>"0px solid rgba(0, 0, 0, 0.3)","type" => "textfield" , 'title' => 'Time border','isGradient'=>true), +'progressColor' => array("default"=>"#babfe3","type" => "textfield" , 'title' => 'Progress color','isColor'=>true), +'buttonColor' => array("default"=>"#f6f0c6","type" => "textfield" , 'title' => 'Button color','isColor'=>true), +'sliderBorder' => array("default"=>"1px solid rgba(128, 128, 128, 0.7)","type" => "textfield" , 'title' => 'Slider Border','isGradient'=>true), +'timeSeparator' => array("default"=>" ","type" => "textfield" , 'title' => 'Time separator'), +'tooltipTextColor' => array("default"=>"#ffffff","type" => "textfield" , 'title' => 'Tooltip text color','isColor'=>true), +'sliderGradient' => array("default"=>"none","type" => "textfield" , 'title' => 'Slider Gradient'), +'bufferGradient' => array("default"=>"none","type" => "textfield" , 'title' => 'Buffer Gradient'), +'volumeBorder' => array("default"=>"1px solid rgba(128, 128, 128, 0.7)","type" => "textfield", 'title' => 'Volume Border' ,'isGradient'=>true), +'progressGradient' => array("default"=>"none","type" => "textfield" , 'title' => 'Progress Gradient'), +'volumeSliderGradient' => array("default"=>"none","type" => "textfield" , 'title' => 'Volume Slider Gradient'), +'volumeSliderColor' => array("default"=>"#f00023","type" => "textfield" , 'title' => 'Volume Slider Color','isColor'=>true), +'durationColor' => array("default"=>"#bae3d0","type" => "textfield" , 'title' => 'Duration Color','isColor'=>true), +); + +assign('pakconfigs',$pakconfigs); + + + +if(isset($_POST['update'])) +{ + $license = $_POST['pak_license']; + $db->update(tbl("config"),array("value"),array($license)," name='pak_license'"); + e("Player license has been updated","m"); +} +assign("configs",$Cbucket->get_configs()); + + +$Cbucket->add_admin_header(PLUG_DIR.'/pakplayer/header.html'); + +template_files('pakplayer.html',PAKPLAYER_PLUG_DIR.'/admin/'); + +?> \ No newline at end of file diff --git a/upload/plugins/pakplayer/header.html b/upload/plugins/pakplayer/header.html new file mode 100644 index 00000000..a4a8284c --- /dev/null +++ b/upload/plugins/pakplayer/header.html @@ -0,0 +1,22 @@ + + + \ No newline at end of file diff --git a/upload/plugins/pakplayer/install_pakplayer.php b/upload/plugins/pakplayer/install_pakplayer.php new file mode 100644 index 00000000..2426903c --- /dev/null +++ b/upload/plugins/pakplayer/install_pakplayer.php @@ -0,0 +1,6 @@ +insert(tbl("config"),array("name","value"),array("pak_license","")); + + +?> \ No newline at end of file diff --git a/upload/plugins/pakplayer/pakplayer.php b/upload/plugins/pakplayer/pakplayer.php new file mode 100644 index 00000000..83367b73 --- /dev/null +++ b/upload/plugins/pakplayer/pakplayer.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/upload/plugins/pakplayer/uninstall_pakplayer.php b/upload/plugins/pakplayer/uninstall_pakplayer.php new file mode 100644 index 00000000..48889e79 --- /dev/null +++ b/upload/plugins/pakplayer/uninstall_pakplayer.php @@ -0,0 +1,3 @@ +Execute("DELETE FROM ".tbl("config")." WHERE name='pak_license' "); +?> \ No newline at end of file diff --git a/upload/plugins/recaptcha/captcha.html b/upload/plugins/recaptcha/captcha.html new file mode 100644 index 00000000..e69de29b diff --git a/upload/plugins/recaptcha/install_recaptcha.php b/upload/plugins/recaptcha/install_recaptcha.php new file mode 100644 index 00000000..f3c26346 --- /dev/null +++ b/upload/plugins/recaptcha/install_recaptcha.php @@ -0,0 +1,8 @@ +insert(tbl("config"),array("name","value"),array("reCaptcha_public_key","6LcQI8ESAAAAALN1vYQovst9c6nlU52iHdqWExp8")); +$db->insert(tbl("config"),array("name","value"),array("reCaptcha_private_key","6LcQI8ESAAAAALc_oz1xuNsBVRNx554CaJHjcoXt")); + +?> \ No newline at end of file diff --git a/upload/plugins/recaptcha/reCaptcha_header.html b/upload/plugins/recaptcha/reCaptcha_header.html new file mode 100644 index 00000000..c567f1f9 --- /dev/null +++ b/upload/plugins/recaptcha/reCaptcha_header.html @@ -0,0 +1,9 @@ +{literal} +{/literal} \ No newline at end of file diff --git a/upload/plugins/recaptcha/recaptcha.php b/upload/plugins/recaptcha/recaptcha.php new file mode 100644 index 00000000..b2a1aa62 --- /dev/null +++ b/upload/plugins/recaptcha/recaptcha.php @@ -0,0 +1,48 @@ +configs['reCaptcha_public_key']; +$privatekey = $Cbucket->configs['reCaptcha_private_key']; + +# the response from reCAPTCHA +$resp = null; +# the error code from reCAPTCHA, if any +$error = null; + +function cbRecaptcha(){ global $publickey, $privatekey, $error; return recaptcha_get_html($publickey, $error);} + +function validateCbRecaptcha($val=NULL) +{ + global $privatekey; + if ($_POST["recaptcha_response_field"]) + { + $resp = recaptcha_check_answer ($privatekey, + $_SERVER["REMOTE_ADDR"], + $_POST["recaptcha_challenge_field"], + $_POST["recaptcha_response_field"]); + + if ($resp->is_valid) + return true; + else + return false; + } +} + +register_cb_captcha('cbRecaptcha','validateCbRecaptcha',false); +register_anchor('; Recaptcha.reload ();','onClickAddComment'); +add_header(PLUG_DIR.'/recaptcha/reCaptcha_header.html'); +?> \ No newline at end of file diff --git a/upload/plugins/recaptcha/recaptchalib.php b/upload/plugins/recaptcha/recaptchalib.php new file mode 100644 index 00000000..d4927498 --- /dev/null +++ b/upload/plugins/recaptcha/recaptchalib.php @@ -0,0 +1,278 @@ + $value ) + $req .= $key . '=' . urlencode( stripslashes($value) ) . '&'; + + // Cut the last '&' + $req=substr($req,0,strlen($req)-1); + return $req; +} + + + +/** + * Submits an HTTP POST to a reCAPTCHA server + * @param string $host + * @param string $path + * @param array $data + * @param int port + * @return array response + */ +function _recaptcha_http_post($host, $path, $data, $port = 80) { + + $req = _recaptcha_qsencode ($data); + + $http_request = "POST $path HTTP/1.0\r\n"; + $http_request .= "Host: $host\r\n"; + $http_request .= "Content-Type: application/x-www-form-urlencoded;\r\n"; + $http_request .= "Content-Length: " . strlen($req) . "\r\n"; + $http_request .= "User-Agent: reCAPTCHA/PHP\r\n"; + $http_request .= "\r\n"; + $http_request .= $req; + + $response = ''; + if( false == ( $fs = @fsockopen($host, $port, $errno, $errstr, 10) ) ) { + die ('Could not open socket'); + } + + fwrite($fs, $http_request); + + while ( !feof($fs) ) + $response .= fgets($fs, 1160); // One TCP-IP packet + fclose($fs); + $response = explode("\r\n\r\n", $response, 2); + + return $response; +} + + + +/** + * Gets the challenge HTML (javascript and non-javascript version). + * This is called from the browser, and the resulting reCAPTCHA HTML widget + * is embedded within the HTML form it was called from. + * @param string $pubkey A public key for reCAPTCHA + * @param string $error The error given by reCAPTCHA (optional, default is null) + * @param boolean $use_ssl Should the request be made over ssl? (optional, default is false) + + * @return string - The HTML to be embedded in the user's form. + */ +function recaptcha_get_html ($pubkey, $error = null, $use_ssl = false) +{ + if ($pubkey == null || $pubkey == '') { + die ("To use reCAPTCHA you must get an API key from
    https://www.google.com/recaptcha/admin/create"); + } + + if ($use_ssl) { + $server = RECAPTCHA_API_SECURE_SERVER; + } else { + $server = RECAPTCHA_API_SERVER; + } + + $errorpart = ""; + if ($error) { + $errorpart = "&error=" . $error; + } + return ' + + + '; +} + + + + +/** + * A ReCaptchaResponse is returned from recaptcha_check_answer() + */ +class ReCaptchaResponse { + var $is_valid; + var $error; +} + + +/** + * Calls an HTTP POST function to verify if the user's guess was correct + * @param string $privkey + * @param string $remoteip + * @param string $challenge + * @param string $response + * @param array $extra_params an array of extra variables to post to the server + * @return ReCaptchaResponse + */ +function recaptcha_check_answer ($privkey, $remoteip, $challenge, $response, $extra_params = array()) +{ + if ($privkey == null || $privkey == '') { + die ("To use reCAPTCHA you must get an API key from https://www.google.com/recaptcha/admin/create"); + } + + if ($remoteip == null || $remoteip == '') { + die ("For security reasons, you must pass the remote ip to reCAPTCHA"); + } + + + + //discard spam submissions + if ($challenge == null || strlen($challenge) == 0 || $response == null || strlen($response) == 0) { + $recaptcha_response = new ReCaptchaResponse(); + $recaptcha_response->is_valid = false; + $recaptcha_response->error = 'incorrect-captcha-sol'; + return $recaptcha_response; + } + + $response = _recaptcha_http_post (RECAPTCHA_VERIFY_SERVER, "/recaptcha/api/verify", + array ( + 'privatekey' => $privkey, + 'remoteip' => $remoteip, + 'challenge' => $challenge, + 'response' => $response + ) + $extra_params + ); + + $answers = explode ("\n", $response [1]); + $recaptcha_response = new ReCaptchaResponse(); + + if (trim ($answers [0]) == 'true') { + $recaptcha_response->is_valid = true; + } + else { + $recaptcha_response->is_valid = false; + $recaptcha_response->error = $answers [1]; + } + return $recaptcha_response; + +} + +/** + * gets a URL where the user can sign up for reCAPTCHA. If your application + * has a configuration page where you enter a key, you should provide a link + * using this function. + * @param string $domain The domain where the page is hosted + * @param string $appname The name of your application + */ +function recaptcha_get_signup_url ($domain = null, $appname = null) { + return "https://www.google.com/recaptcha/admin/create?" . _recaptcha_qsencode (array ('domains' => $domain, 'app' => $appname)); +} + +function _recaptcha_aes_pad($val) { + $block_size = 16; + $numpad = $block_size - (strlen ($val) % $block_size); + return str_pad($val, strlen ($val) + $numpad, chr($numpad)); +} + +/* Mailhide related code */ + +function _recaptcha_aes_encrypt($val,$ky) { + if (! function_exists ("mcrypt_encrypt")) { + die ("To use reCAPTCHA Mailhide, you need to have the mcrypt php module installed."); + } + $mode=MCRYPT_MODE_CBC; + $enc=MCRYPT_RIJNDAEL_128; + $val=_recaptcha_aes_pad($val); + return mcrypt_encrypt($enc, $ky, $val, $mode, "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"); +} + + +function _recaptcha_mailhide_urlbase64 ($x) { + return strtr(base64_encode ($x), '+/', '-_'); +} + +/* gets the reCAPTCHA Mailhide url for a given email, public key and private key */ +function recaptcha_mailhide_url($pubkey, $privkey, $email) { + if ($pubkey == '' || $pubkey == null || $privkey == "" || $privkey == null) { + die ("To use reCAPTCHA Mailhide, you have to sign up for a public and private key, " . + "you can do so at http://www.google.com/recaptcha/mailhide/apikey"); + } + + + $ky = pack('H*', $privkey); + $cryptmail = _recaptcha_aes_encrypt ($email, $ky); + + return "http://www.google.com/recaptcha/mailhide/d?k=" . $pubkey . "&c=" . _recaptcha_mailhide_urlbase64 ($cryptmail); +} + +/** + * gets the parts of the email to expose to the user. + * eg, given johndoe@example,com return ["john", "example.com"]. + * the email is then displayed as john...@example.com + */ +function _recaptcha_mailhide_email_parts ($email) { + $arr = preg_split("/@/", $email ); + + if (strlen ($arr[0]) <= 4) { + $arr[0] = substr ($arr[0], 0, 1); + } else if (strlen ($arr[0]) <= 6) { + $arr[0] = substr ($arr[0], 0, 3); + } else { + $arr[0] = substr ($arr[0], 0, 4); + } + return $arr; +} + +/** + * Gets html to display an email address given a public an private key. + * to get a key, go to: + * + * http://www.google.com/recaptcha/mailhide/apikey + */ +function recaptcha_mailhide_html($pubkey, $privkey, $email) { + $emailparts = _recaptcha_mailhide_email_parts ($email); + $url = recaptcha_mailhide_url ($pubkey, $privkey, $email); + + return htmlentities($emailparts[0]) . "...@" . htmlentities ($emailparts [1]); + +} + + +?> diff --git a/upload/plugins/recaptcha/uninstall_recaptcha.php b/upload/plugins/recaptcha/uninstall_recaptcha.php new file mode 100644 index 00000000..96440561 --- /dev/null +++ b/upload/plugins/recaptcha/uninstall_recaptcha.php @@ -0,0 +1,8 @@ +delete(tbl("config"),array("name"),array("reCaptcha_public_key")); +$db->delete(tbl("config"),array("name"),array("reCaptcha_private_key")); + +?> \ No newline at end of file diff --git a/upload/plugins/signup_captcha/captcha.php b/upload/plugins/signup_captcha/captcha.php new file mode 100644 index 00000000..43a3939a --- /dev/null +++ b/upload/plugins/signup_captcha/captcha.php @@ -0,0 +1,10 @@ +generates_image($word,true); +?> \ No newline at end of file diff --git a/upload/plugins/signup_captcha/captcha/class.files.php b/upload/plugins/signup_captcha/captcha/class.files.php new file mode 100644 index 00000000..5345dd1c --- /dev/null +++ b/upload/plugins/signup_captcha/captcha/class.files.php @@ -0,0 +1,116 @@ +_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 "
    ";
    +            print_r($file_list);
    +            echo "
    "; + } + + // Returns file list + return $file_list; + } + + function _error($mensagem, $tipo) + { + if($tipo == E_USER_ERROR) + { + $topo = "Error!"; + } + else + { + $topo = "Notification"; + } + + echo "" . $topo . ": " . $mensagem . "

    "; + + if($tipo == E_USER_ERROR) + { + exit; + } + } +} +?> \ No newline at end of file diff --git a/upload/plugins/signup_captcha/captcha/class.img_validator.php b/upload/plugins/signup_captcha/captcha/class.img_validator.php new file mode 100644 index 00000000..3abd031a --- /dev/null +++ b/upload/plugins/signup_captcha/captcha/class.img_validator.php @@ -0,0 +1,329 @@ + 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); + preg_match("/$given/",$recorded,$matches); + + if($matches) + { + $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); + } +} +?> \ No newline at end of file diff --git a/upload/plugins/signup_captcha/captcha/class.img_validator.php.bak b/upload/plugins/signup_captcha/captcha/class.img_validator.php.bak new file mode 100644 index 00000000..70c5a597 --- /dev/null +++ b/upload/plugins/signup_captcha/captcha/class.img_validator.php.bak @@ -0,0 +1,330 @@ + 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); + preg_match("/$given/",$recorded,$matches); + + if($matches) + { + $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") + { + //error_reporting(E_ALL); + header("Content-type: image/jpeg"); + imagejpeg($background_image); + } + else + { + header("Content-type: image/png"); + imagepng($background_image); + } + + imagedestroy($background_image); + } +} +?> \ No newline at end of file diff --git a/upload/plugins/signup_captcha/captcha/index.php b/upload/plugins/signup_captcha/captcha/index.php new file mode 100644 index 00000000..403f2e18 --- /dev/null +++ b/upload/plugins/signup_captcha/captcha/index.php @@ -0,0 +1,3 @@ + \ No newline at end of file diff --git a/upload/plugins/signup_captcha/img/bg1.jpg b/upload/plugins/signup_captcha/img/bg1.jpg new file mode 100644 index 00000000..11a9448d Binary files /dev/null and b/upload/plugins/signup_captcha/img/bg1.jpg differ diff --git a/upload/plugins/signup_captcha/img/bg2.jpg b/upload/plugins/signup_captcha/img/bg2.jpg new file mode 100644 index 00000000..560d09c0 Binary files /dev/null and b/upload/plugins/signup_captcha/img/bg2.jpg differ diff --git a/upload/plugins/signup_captcha/img/bg3.jpg b/upload/plugins/signup_captcha/img/bg3.jpg new file mode 100644 index 00000000..29559a10 Binary files /dev/null and b/upload/plugins/signup_captcha/img/bg3.jpg differ diff --git a/upload/plugins/signup_captcha/img/bg4.jpg b/upload/plugins/signup_captcha/img/bg4.jpg new file mode 100644 index 00000000..d1b20138 Binary files /dev/null and b/upload/plugins/signup_captcha/img/bg4.jpg differ diff --git a/upload/plugins/signup_captcha/img/fonts/arial.ttf b/upload/plugins/signup_captcha/img/fonts/arial.ttf new file mode 100644 index 00000000..ff0815cd Binary files /dev/null and b/upload/plugins/signup_captcha/img/fonts/arial.ttf differ diff --git a/upload/plugins/signup_captcha/img/fonts/comicbd.ttf b/upload/plugins/signup_captcha/img/fonts/comicbd.ttf new file mode 100644 index 00000000..75be5048 Binary files /dev/null and b/upload/plugins/signup_captcha/img/fonts/comicbd.ttf differ diff --git a/upload/plugins/signup_captcha/img/fonts/impact.ttf b/upload/plugins/signup_captcha/img/fonts/impact.ttf new file mode 100644 index 00000000..114e6c19 Binary files /dev/null and b/upload/plugins/signup_captcha/img/fonts/impact.ttf differ diff --git a/upload/plugins/signup_captcha/img/fonts/monofont.ttf b/upload/plugins/signup_captcha/img/fonts/monofont.ttf new file mode 100644 index 00000000..ec6c51b2 Binary files /dev/null and b/upload/plugins/signup_captcha/img/fonts/monofont.ttf differ diff --git a/upload/plugins/signup_captcha/img/fonts/verdana.ttf b/upload/plugins/signup_captcha/img/fonts/verdana.ttf new file mode 100644 index 00000000..8f25a642 Binary files /dev/null and b/upload/plugins/signup_captcha/img/fonts/verdana.ttf differ diff --git a/upload/plugins/signup_captcha/signup_captcha.php b/upload/plugins/signup_captcha/signup_captcha.php new file mode 100644 index 00000000..2eb809d3 --- /dev/null +++ b/upload/plugins/signup_captcha/signup_captcha.php @@ -0,0 +1,50 @@ +
    + Refresh'; + } + + $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); + register_cb_captcha('signup_captcha','signup_captcha_check',TRUE); +} +?> \ No newline at end of file diff --git a/upload/privacy.php b/upload/privacy.php new file mode 100644 index 00000000..20c3bf03 --- /dev/null +++ b/upload/privacy.php @@ -0,0 +1,16 @@ +page_redir(); +subtitle('privacy'); +Template('header.html'); +Template('message.html'); +Template('privacy.html'); +Template('footer.html'); +?> \ No newline at end of file diff --git a/upload/private_message.php b/upload/private_message.php new file mode 100644 index 00000000..7efb89ac --- /dev/null +++ b/upload/private_message.php @@ -0,0 +1,169 @@ +logincheck(); +$udetails = $userquery->get_user_details(userid()); +assign('user',$udetails); +assign('p',$userquery->get_user_profile($udetails['userid'])); + + +$mode = $_GET['mode']; + +//Deleting Multple Message +if(isset($_POST['delete_pm'])) +{ + if($mode=='inbox' || $mode =='notification') + $box = 'in'; + else + $box = 'out'; + + $total = count($_POST['msg_id']); + for($pms=0;$pms<$total;$pms++) + { + if(!empty($_POST['msg_id'][$pms])) + { + $cbpm->delete_msg($_POST['msg_id'][$pms],userid(),$box); + } + + $eh->flush(); + e(lang('private_messags_deleted'),'m'); + } +} + + + +switch($mode) +{ + case 'inbox': + default: + { + + assign('mode','inbox'); + + //Deleting Message + if($_GET['delete_mid']) + { + $mid = mysql_clean($_GET['delete_mid']); + $cbpm->delete_msg($mid,userid()); + } + + //Getting Message + if($_GET['mid']) + { + $mid = mysql_clean($_GET['mid']); + $pr_msg = $cbpm->get_inbox_message($mid,userid()); + if($pr_msg['message_status'] =='unread') + $cbpm->set_message_status($mid,'read'); + assign('pr_msg',$pr_msg); + } + + //Get User Messages + assign('user_msgs',$cbpm->get_user_inbox_messages(userid())); + + subtitle(lang("com_my_inbox")); + } + break; + + case 'sent': + { + assign('mode','sent'); + + + //Deleting Message + if($_GET['delete_mid']) + { + $mid = mysql_clean($_GET['delete_mid']); + $cbpm->delete_msg($mid,userid(),'out'); + } + + //Getting Message + if($_GET['mid']) + { + $mid = mysql_clean($_GET['mid']); + assign('pr_msg',$cbpm->get_outbox_message($mid,userid())); + } + + //Get User Messages + assign('user_msgs',$cbpm->get_user_outbox_messages(userid())); + + subtitle(lang("user_sent_box")); + } + + break; + + case 'notification': + { + assign('mode','notification'); + + //Deleting Message + if($_GET['delete_mid']) + { + $mid = mysql_clean($_GET['delete_mid']); + $cbpm->delete_msg($mid,userid()); + } + + //Getting Message + if($_GET['mid']) + { + $mid = mysql_clean($_GET['mid']); + assign('pr_msg',$cbpm->get_inbox_message($mid,userid())); + } + + //Get User Messages + assign('user_msgs',$cbpm->get_user_notification_messages(userid())); + + subtitle(lang("my_notifications")); + } + break; + + case 'new_msg': + case 'compose': + { + assign('mode','new_msg'); + + //Checkking If reply + if($_GET['reply']!='') + { + $mid = mysql_clean($_GET['reply']); + if(!isset($_POST['send_message']) && $cbpm->is_reply($mid,userid())) + { + $reply_msg = $cbpm->get_inbox_message($mid,userid()); + $_POST['to'] = $userquery->get_user_field_only($reply_msg['message_from'],'username'); + $_POST['subj'] = "Re:".$reply_msg['message_subject']; + } + } + + //sending message + if(isset($_POST['send_message'])) + { + $array = $_POST; + $array['reply_to'] = mysql_clean($_GET['reply']); + $array['is_pm'] = true; + $array['from'] = userid(); + $cbpm->send_pm($array); + + if(!error()) + $_POST = ''; + } + + subtitle(lang("title_crt_new_msg")); + } + +} + +template_files('private_message.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/readme b/upload/readme new file mode 100644 index 00000000..8a6d4b13 --- /dev/null +++ b/upload/readme @@ -0,0 +1 @@ +something goes here.. \ No newline at end of file diff --git a/upload/rss.php b/upload/rss.php new file mode 100644 index 00000000..cf7f2fda --- /dev/null +++ b/upload/rss.php @@ -0,0 +1,140 @@ +'."\n"; + +$limit = 20; +$page = $_GET['page']; +if($page<1 || !is_numeric ) + $page = 1; + +if($page) +{ + $from = ($page-1)*$limit; + $limit = "$from,$limit"; +} + +$mode = $_GET['mode']; +switch($mode) +{ + case 'recent': + default: + { + $videos = get_videos(array('limit'=>$limit,'order'=>'date_added DESC')); + $title = "Recently Added Videos"; + } + break; + + case 'views': + { + + $videos = get_videos(array('limit'=>$limit,'order'=>'views DESC')); + $title = "Most Viewed Videos"; + } + break; + + case 'rating': + { + $videos = get_videos(array('limit'=>$limit,'order'=>'rating DESC')); + $title = "Top Rated Videos"; + } + break; + + case 'watching': + { + $videos = get_videos(array('limit'=>$limit,'order'=>'last_viewed DESC')); + $title = "Videos Being Watched"; + } + break; + case 'user': + { + $user = mysql_clean($_GET['username']); + //Get userid from username + $uid = $userquery->get_user_field_only($user,'userid'); + $uid = $uid ? $uid : 'x'; + $videos = get_videos(array('limit'=>$limit,'user'=>$uid,'order'=>'date_added DESC')); + //Count Total Videos of this user + $total_vids = get_videos(array('count_only'=>true,'user'=>$uid)); + $title = "Videos uploaded by ".$user; + } + + break; +} + +subtitle($title); +?> + + + +<?=cbtitle()?> + + + + + <?=cbtitle()?> + + configs['description']?> + + + + + + + <?=substr($video['title'],0,50)?> + + + + + + +
    + + + + Rating /10
    + Views
    + Duration + + + + +
    + ]]> +
    + + + + + + + + + + +
    + + +
    +
    \ No newline at end of file diff --git a/upload/search_result.php b/upload/search_result.php new file mode 100644 index 00000000..5f55fa73 --- /dev/null +++ b/upload/search_result.php @@ -0,0 +1,82 @@ +page_redir(); + +$page = mysql_clean($_GET['page']); +$type = mysql_clean($_GET['type']) ; +$type = $type ? $type : 'videos'; +$chkType = $type; +//Checking if search for specific section is allowed or not +if($type=='users') $chkType = 'channels'; +isSectionEnabled($chkType,true); + +$search = cbsearch::init_search($type); + +$search->key = mysql_clean($_GET['query']); + +if(!is_array($_GET['category'])) + $_GET['category'] = mysql_clean($_GET['category']); + +if($type!='videos') + $search->category = $_GET['category']; +else +{ + $child_ids = array(); + if($_GET['category']) + foreach($_GET['category'] as $category) + { + $childs = $cbvid->get_sub_categories(mysql_clean($category)); + if($childs) + foreach($childs as $child) + { + $child_ids[] = $child['category_id']; + $subchilds = $childs = $cbvid->get_sub_categories($child['category_id']); + if($subchilds) + foreach($subchilds as $subchild) + { + $child_ids[] = $subchild['category_id']; + } + } + $child_ids[] = mysql_clean($category); + } + + $search->category = $child_ids; +} +$search->date_margin = mysql_clean($_GET['datemargin']); +$search->sort_by = mysql_clean($_GET['sort']); +$search->limit = create_query_limit($page,$search->results_per_page); +$results = $search->search(); +//echo $db->db_query; +//Collecting Data for Pagination +$total_rows = $search->total_results; +$total_pages = count_pages($total_rows,$search->results_per_page); + +//Pagination +$pages->paginate($total_pages,$page); + + +Assign('results',$results ); +Assign('template_var',$search->template_var); +Assign('display_template',$search->display_template); +if(empty($search->key)) + Assign('search_type_title',$search->search_type[$type]['title']); +else + Assign('search_type_title',sprintf(lang('searching_keyword_in_obj'),mysql_clean(get('query')),$search->search_type[$type]['title'])); + +if(mysql_clean(get('query'))) +{ + subtitle($search->search_type[$type]['title'].' » '.mysql_clean(get('query'))); +} +//Displaying The Template +template_files('search.html'); +display_it(); +//pr($db); +?> \ No newline at end of file diff --git a/upload/signup.php b/upload/signup.php new file mode 100644 index 00000000..f25fcb73 --- /dev/null +++ b/upload/signup.php @@ -0,0 +1,79 @@ +login_check('',true)){ + redirect_to(BASEURL); +} + + /** + * Function used to call all signup functions + */ + if(cb_get_functions('signup_page')) cb_call_functions('signup_page'); + + + /** + * Signing up new user + */ + if(isset($_POST['signup'])){ + + if(!config('allow_registeration')) + e(lang('usr_reg_err')); + else + { + $signup = $userquery->signup_user($_POST); + if($signup) + { + $udetails = $userquery->get_user_details($signup); + $eh->flush(); + assign('udetails',$udetails); + assign('mode','signup_success'); + } + } + } + + +//Login User + +if(isset($_POST['login'])){ + $username = $_POST['username']; + $username = mysql_clean(clean($username)); + $password = mysql_clean(clean($_POST['password'])); + + $remember = false; + if($_POST['rememberme']) + $remember = true; + + if($userquery->login_user($username,$password,$remember)) + { + if($_COOKIE['pageredir']) + redirect_to($_COOKIE['pageredir']); + else + redirect_to(cblink(array('name'=>'my_account'))); + } + +} + +//Checking Ban Error +if(!isset($_POST['login']) && !isset($_POST['signup'])){ + if(@$_GET['ban'] == true){ + $msg = lang('usr_ban_err'); + } +} + +subtitle(lang("signup")); +//Displaying The Template +template_files('signup.html'); +display_it() +?> \ No newline at end of file diff --git a/upload/sitemap.php b/upload/sitemap.php new file mode 100644 index 00000000..3e813458 --- /dev/null +++ b/upload/sitemap.php @@ -0,0 +1,64 @@ +' . "\n"; + +$limit = 100; +$videos = get_videos(array('limit'=>$limit,'active'=>'yes','order'=>'date_added DESC')); + +?> + + + + + + + +/player/old_players/embed_player.swf?file= + +]]> +]]> + + + +'; + } +?> + +yes + + + + + \ No newline at end of file diff --git a/upload/styles/.htaccess b/upload/styles/.htaccess new file mode 100644 index 00000000..8c79ff9d --- /dev/null +++ b/upload/styles/.htaccess @@ -0,0 +1,4 @@ + +order allow,deny +satisfy all + diff --git a/upload/styles/cbv2new/images/ajax-loader-big.gif b/upload/styles/cbv2new/images/ajax-loader-big.gif new file mode 100644 index 00000000..e66abbdb Binary files /dev/null and b/upload/styles/cbv2new/images/ajax-loader-big.gif differ diff --git a/upload/styles/cbv2new/images/ajax-loader.gif b/upload/styles/cbv2new/images/ajax-loader.gif new file mode 100644 index 00000000..61e4993f Binary files /dev/null and b/upload/styles/cbv2new/images/ajax-loader.gif differ diff --git a/upload/styles/cbv2new/images/alert.png b/upload/styles/cbv2new/images/alert.png new file mode 100644 index 00000000..d64c533f Binary files /dev/null and b/upload/styles/cbv2new/images/alert.png differ diff --git a/upload/styles/cbv2new/images/big_stars.png b/upload/styles/cbv2new/images/big_stars.png new file mode 100644 index 00000000..91c1e35d Binary files /dev/null and b/upload/styles/cbv2new/images/big_stars.png differ diff --git a/upload/styles/cbv2new/images/blocks.png b/upload/styles/cbv2new/images/blocks.png new file mode 100644 index 00000000..9ccbd052 Binary files /dev/null and b/upload/styles/cbv2new/images/blocks.png differ diff --git a/upload/styles/cbv2new/images/buttons.png b/upload/styles/cbv2new/images/buttons.png new file mode 100644 index 00000000..5532c976 Binary files /dev/null and b/upload/styles/cbv2new/images/buttons.png differ diff --git a/upload/styles/cbv2new/images/cancel.png b/upload/styles/cbv2new/images/cancel.png new file mode 100644 index 00000000..33c876b2 Binary files /dev/null and b/upload/styles/cbv2new/images/cancel.png differ diff --git a/upload/styles/cbv2new/images/cancel_upload.png b/upload/styles/cbv2new/images/cancel_upload.png new file mode 100644 index 00000000..35682b01 Binary files /dev/null and b/upload/styles/cbv2new/images/cancel_upload.png differ diff --git a/upload/styles/cbv2new/images/category_buttons.png b/upload/styles/cbv2new/images/category_buttons.png new file mode 100644 index 00000000..29ad5275 Binary files /dev/null and b/upload/styles/cbv2new/images/category_buttons.png differ diff --git a/upload/styles/cbv2new/images/cb_button.png b/upload/styles/cbv2new/images/cb_button.png new file mode 100644 index 00000000..f3bda1c6 Binary files /dev/null and b/upload/styles/cbv2new/images/cb_button.png differ diff --git a/upload/styles/cbv2new/images/clean.png b/upload/styles/cbv2new/images/clean.png new file mode 100644 index 00000000..3f4e6099 Binary files /dev/null and b/upload/styles/cbv2new/images/clean.png differ diff --git a/upload/styles/cbv2new/images/cross.png b/upload/styles/cbv2new/images/cross.png new file mode 100644 index 00000000..1d65bad2 Binary files /dev/null and b/upload/styles/cbv2new/images/cross.png differ diff --git a/upload/styles/cbv2new/images/dot.gif b/upload/styles/cbv2new/images/dot.gif new file mode 100644 index 00000000..35d42e80 Binary files /dev/null and b/upload/styles/cbv2new/images/dot.gif differ diff --git a/upload/styles/cbv2new/images/dow.png b/upload/styles/cbv2new/images/dow.png new file mode 100644 index 00000000..8e58ab9c Binary files /dev/null and b/upload/styles/cbv2new/images/dow.png differ diff --git a/upload/styles/cbv2new/images/down.png b/upload/styles/cbv2new/images/down.png new file mode 100644 index 00000000..347ccbf7 Binary files /dev/null and b/upload/styles/cbv2new/images/down.png differ diff --git a/upload/styles/cbv2new/images/error.png b/upload/styles/cbv2new/images/error.png new file mode 100644 index 00000000..a9e4ff39 Binary files /dev/null and b/upload/styles/cbv2new/images/error.png differ diff --git a/upload/styles/cbv2new/images/feature_bg.png b/upload/styles/cbv2new/images/feature_bg.png new file mode 100644 index 00000000..9a22a87c Binary files /dev/null and b/upload/styles/cbv2new/images/feature_bg.png differ diff --git a/upload/styles/cbv2new/images/foot_search.png b/upload/styles/cbv2new/images/foot_search.png new file mode 100644 index 00000000..54337e06 Binary files /dev/null and b/upload/styles/cbv2new/images/foot_search.png differ diff --git a/upload/styles/cbv2new/images/forget.png b/upload/styles/cbv2new/images/forget.png new file mode 100644 index 00000000..a121b8b5 Binary files /dev/null and b/upload/styles/cbv2new/images/forget.png differ diff --git a/upload/styles/cbv2new/images/gradients.png b/upload/styles/cbv2new/images/gradients.png new file mode 100644 index 00000000..9d1fba6b Binary files /dev/null and b/upload/styles/cbv2new/images/gradients.png differ diff --git a/upload/styles/cbv2new/images/group/add.png b/upload/styles/cbv2new/images/group/add.png new file mode 100644 index 00000000..61d25953 Binary files /dev/null and b/upload/styles/cbv2new/images/group/add.png differ diff --git a/upload/styles/cbv2new/images/hq.png b/upload/styles/cbv2new/images/hq.png new file mode 100644 index 00000000..4aadc57e Binary files /dev/null and b/upload/styles/cbv2new/images/hq.png differ diff --git a/upload/styles/cbv2new/images/icon.png b/upload/styles/cbv2new/images/icon.png new file mode 100644 index 00000000..71c46ef9 Binary files /dev/null and b/upload/styles/cbv2new/images/icon.png differ diff --git a/upload/styles/cbv2new/images/icons.png b/upload/styles/cbv2new/images/icons.png new file mode 100644 index 00000000..b3543142 Binary files /dev/null and b/upload/styles/cbv2new/images/icons.png differ diff --git a/upload/styles/cbv2new/images/icons/balloon-small.png b/upload/styles/cbv2new/images/icons/balloon-small.png new file mode 100644 index 00000000..3b538de0 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/balloon-small.png differ diff --git a/upload/styles/cbv2new/images/icons/balloons-box.png b/upload/styles/cbv2new/images/icons/balloons-box.png new file mode 100644 index 00000000..414b9b14 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/balloons-box.png differ diff --git a/upload/styles/cbv2new/images/icons/black-user.png b/upload/styles/cbv2new/images/icons/black-user.png new file mode 100644 index 00000000..f6e4dc8a Binary files /dev/null and b/upload/styles/cbv2new/images/icons/black-user.png differ diff --git a/upload/styles/cbv2new/images/icons/blue-document.png b/upload/styles/cbv2new/images/icons/blue-document.png new file mode 100644 index 00000000..6b2545a5 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/blue-document.png differ diff --git a/upload/styles/cbv2new/images/icons/calender.png b/upload/styles/cbv2new/images/icons/calender.png new file mode 100644 index 00000000..8a3452a4 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/calender.png differ diff --git a/upload/styles/cbv2new/images/icons/camcorder.png b/upload/styles/cbv2new/images/icons/camcorder.png new file mode 100644 index 00000000..a225bc9a Binary files /dev/null and b/upload/styles/cbv2new/images/icons/camcorder.png differ diff --git a/upload/styles/cbv2new/images/icons/collection.png b/upload/styles/cbv2new/images/icons/collection.png new file mode 100644 index 00000000..97ef8389 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/collection.png differ diff --git a/upload/styles/cbv2new/images/icons/comment.png b/upload/styles/cbv2new/images/icons/comment.png new file mode 100644 index 00000000..9fde69bf Binary files /dev/null and b/upload/styles/cbv2new/images/icons/comment.png differ diff --git a/upload/styles/cbv2new/images/icons/comments_small.png b/upload/styles/cbv2new/images/icons/comments_small.png new file mode 100644 index 00000000..f0bf0060 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/comments_small.png differ diff --git a/upload/styles/cbv2new/images/icons/cross.png b/upload/styles/cbv2new/images/icons/cross.png new file mode 100644 index 00000000..a0fcee37 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/cross.png differ diff --git a/upload/styles/cbv2new/images/icons/delete.png b/upload/styles/cbv2new/images/icons/delete.png new file mode 100644 index 00000000..55e388b4 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/delete.png differ diff --git a/upload/styles/cbv2new/images/icons/embed_small.png b/upload/styles/cbv2new/images/icons/embed_small.png new file mode 100644 index 00000000..9cf5db87 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/embed_small.png differ diff --git a/upload/styles/cbv2new/images/icons/group.png b/upload/styles/cbv2new/images/icons/group.png new file mode 100644 index 00000000..7fb4e1f1 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/group.png differ diff --git a/upload/styles/cbv2new/images/icons/heart.png b/upload/styles/cbv2new/images/icons/heart.png new file mode 100644 index 00000000..d9ee53e5 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/heart.png differ diff --git a/upload/styles/cbv2new/images/icons/heart_small.png b/upload/styles/cbv2new/images/icons/heart_small.png new file mode 100644 index 00000000..1b32d7db Binary files /dev/null and b/upload/styles/cbv2new/images/icons/heart_small.png differ diff --git a/upload/styles/cbv2new/images/icons/image.png b/upload/styles/cbv2new/images/icons/image.png new file mode 100644 index 00000000..fc3c393c Binary files /dev/null and b/upload/styles/cbv2new/images/icons/image.png differ diff --git a/upload/styles/cbv2new/images/icons/images.png b/upload/styles/cbv2new/images/icons/images.png new file mode 100644 index 00000000..184860d1 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/images.png differ diff --git a/upload/styles/cbv2new/images/icons/photo.png b/upload/styles/cbv2new/images/icons/photo.png new file mode 100644 index 00000000..6a543172 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/photo.png differ diff --git a/upload/styles/cbv2new/images/icons/photos.png b/upload/styles/cbv2new/images/icons/photos.png new file mode 100644 index 00000000..8836fe6c Binary files /dev/null and b/upload/styles/cbv2new/images/icons/photos.png differ diff --git a/upload/styles/cbv2new/images/icons/playlist.png b/upload/styles/cbv2new/images/icons/playlist.png new file mode 100644 index 00000000..bd9f3af7 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/playlist.png differ diff --git a/upload/styles/cbv2new/images/icons/playlist_small.png b/upload/styles/cbv2new/images/icons/playlist_small.png new file mode 100644 index 00000000..ef525f69 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/playlist_small.png differ diff --git a/upload/styles/cbv2new/images/icons/quicklist_check_small.png b/upload/styles/cbv2new/images/icons/quicklist_check_small.png new file mode 100644 index 00000000..978ff19c Binary files /dev/null and b/upload/styles/cbv2new/images/icons/quicklist_check_small.png differ diff --git a/upload/styles/cbv2new/images/icons/quicklist_small.png b/upload/styles/cbv2new/images/icons/quicklist_small.png new file mode 100644 index 00000000..d868892d Binary files /dev/null and b/upload/styles/cbv2new/images/icons/quicklist_small.png differ diff --git a/upload/styles/cbv2new/images/icons/report_small.png b/upload/styles/cbv2new/images/icons/report_small.png new file mode 100644 index 00000000..ea4a57e0 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/report_small.png differ diff --git a/upload/styles/cbv2new/images/icons/share_small.png b/upload/styles/cbv2new/images/icons/share_small.png new file mode 100644 index 00000000..2b598680 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/share_small.png differ diff --git a/upload/styles/cbv2new/images/icons/shield.png b/upload/styles/cbv2new/images/icons/shield.png new file mode 100644 index 00000000..394c32d4 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/shield.png differ diff --git a/upload/styles/cbv2new/images/icons/star.png b/upload/styles/cbv2new/images/icons/star.png new file mode 100644 index 00000000..b88c8578 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/star.png differ diff --git a/upload/styles/cbv2new/images/icons/user.png b/upload/styles/cbv2new/images/icons/user.png new file mode 100644 index 00000000..79f35ccb Binary files /dev/null and b/upload/styles/cbv2new/images/icons/user.png differ diff --git a/upload/styles/cbv2new/images/icons/user_add.png b/upload/styles/cbv2new/images/icons/user_add.png new file mode 100644 index 00000000..deae99bc Binary files /dev/null and b/upload/styles/cbv2new/images/icons/user_add.png differ diff --git a/upload/styles/cbv2new/images/icons/user_comment.png b/upload/styles/cbv2new/images/icons/user_comment.png new file mode 100644 index 00000000..e54ebeba Binary files /dev/null and b/upload/styles/cbv2new/images/icons/user_comment.png differ diff --git a/upload/styles/cbv2new/images/icons/video.png b/upload/styles/cbv2new/images/icons/video.png new file mode 100644 index 00000000..4471d5d0 Binary files /dev/null and b/upload/styles/cbv2new/images/icons/video.png differ diff --git a/upload/styles/cbv2new/images/line_sps.png b/upload/styles/cbv2new/images/line_sps.png new file mode 100644 index 00000000..4047efa4 Binary files /dev/null and b/upload/styles/cbv2new/images/line_sps.png differ diff --git a/upload/styles/cbv2new/images/log_button.png b/upload/styles/cbv2new/images/log_button.png new file mode 100644 index 00000000..7cec371f Binary files /dev/null and b/upload/styles/cbv2new/images/log_button.png differ diff --git a/upload/styles/cbv2new/images/login_button.png b/upload/styles/cbv2new/images/login_button.png new file mode 100644 index 00000000..a6b2381c Binary files /dev/null and b/upload/styles/cbv2new/images/login_button.png differ diff --git a/upload/styles/cbv2new/images/login_grad.png b/upload/styles/cbv2new/images/login_grad.png new file mode 100644 index 00000000..96f1be37 Binary files /dev/null and b/upload/styles/cbv2new/images/login_grad.png differ diff --git a/upload/styles/cbv2new/images/logo.png b/upload/styles/cbv2new/images/logo.png new file mode 100644 index 00000000..2ed0c398 Binary files /dev/null and b/upload/styles/cbv2new/images/logo.png differ diff --git a/upload/styles/cbv2new/images/logo348x53.png b/upload/styles/cbv2new/images/logo348x53.png new file mode 100644 index 00000000..73b59ade Binary files /dev/null and b/upload/styles/cbv2new/images/logo348x53.png differ diff --git a/upload/styles/cbv2new/images/main_bg.png b/upload/styles/cbv2new/images/main_bg.png new file mode 100644 index 00000000..8b944986 Binary files /dev/null and b/upload/styles/cbv2new/images/main_bg.png differ diff --git a/upload/styles/cbv2new/images/main_box.png b/upload/styles/cbv2new/images/main_box.png new file mode 100644 index 00000000..a91fa886 Binary files /dev/null and b/upload/styles/cbv2new/images/main_box.png differ diff --git a/upload/styles/cbv2new/images/main_vid_bg.png b/upload/styles/cbv2new/images/main_vid_bg.png new file mode 100644 index 00000000..bb9fc312 Binary files /dev/null and b/upload/styles/cbv2new/images/main_vid_bg.png differ diff --git a/upload/styles/cbv2new/images/messagebox_warning.png b/upload/styles/cbv2new/images/messagebox_warning.png new file mode 100644 index 00000000..d5f6551d Binary files /dev/null and b/upload/styles/cbv2new/images/messagebox_warning.png differ diff --git a/upload/styles/cbv2new/images/nav_grads.png b/upload/styles/cbv2new/images/nav_grads.png new file mode 100644 index 00000000..1b4153d1 Binary files /dev/null and b/upload/styles/cbv2new/images/nav_grads.png differ diff --git a/upload/styles/cbv2new/images/no_user.png b/upload/styles/cbv2new/images/no_user.png new file mode 100644 index 00000000..2e3b8a5f Binary files /dev/null and b/upload/styles/cbv2new/images/no_user.png differ diff --git a/upload/styles/cbv2new/images/ok.png b/upload/styles/cbv2new/images/ok.png new file mode 100644 index 00000000..34ecbdae Binary files /dev/null and b/upload/styles/cbv2new/images/ok.png differ diff --git a/upload/styles/cbv2new/images/ok_16.png b/upload/styles/cbv2new/images/ok_16.png new file mode 100644 index 00000000..dba9b286 Binary files /dev/null and b/upload/styles/cbv2new/images/ok_16.png differ diff --git a/upload/styles/cbv2new/images/player.png b/upload/styles/cbv2new/images/player.png new file mode 100644 index 00000000..12a4c7ef Binary files /dev/null and b/upload/styles/cbv2new/images/player.png differ diff --git a/upload/styles/cbv2new/images/preview.png b/upload/styles/cbv2new/images/preview.png new file mode 100644 index 00000000..1cb0b1f6 Binary files /dev/null and b/upload/styles/cbv2new/images/preview.png differ diff --git a/upload/styles/cbv2new/images/private.png b/upload/styles/cbv2new/images/private.png new file mode 100644 index 00000000..727f82d3 Binary files /dev/null and b/upload/styles/cbv2new/images/private.png differ diff --git a/upload/styles/cbv2new/images/quick_icon.png b/upload/styles/cbv2new/images/quick_icon.png new file mode 100644 index 00000000..bf7d8b59 Binary files /dev/null and b/upload/styles/cbv2new/images/quick_icon.png differ diff --git a/upload/styles/cbv2new/images/search.png b/upload/styles/cbv2new/images/search.png new file mode 100644 index 00000000..cffafc01 Binary files /dev/null and b/upload/styles/cbv2new/images/search.png differ diff --git a/upload/styles/cbv2new/images/search_footer.png b/upload/styles/cbv2new/images/search_footer.png new file mode 100644 index 00000000..b70b6f27 Binary files /dev/null and b/upload/styles/cbv2new/images/search_footer.png differ diff --git a/upload/styles/cbv2new/images/shadows.png b/upload/styles/cbv2new/images/shadows.png new file mode 100644 index 00000000..ec9c9dec Binary files /dev/null and b/upload/styles/cbv2new/images/shadows.png differ diff --git a/upload/styles/cbv2new/images/side_bg.png b/upload/styles/cbv2new/images/side_bg.png new file mode 100644 index 00000000..54588ae5 Binary files /dev/null and b/upload/styles/cbv2new/images/side_bg.png differ diff --git a/upload/styles/cbv2new/images/simple_gradient.png b/upload/styles/cbv2new/images/simple_gradient.png new file mode 100644 index 00000000..e267e826 Binary files /dev/null and b/upload/styles/cbv2new/images/simple_gradient.png differ diff --git a/upload/styles/cbv2new/images/small_stars.png b/upload/styles/cbv2new/images/small_stars.png new file mode 100644 index 00000000..ccaf7908 Binary files /dev/null and b/upload/styles/cbv2new/images/small_stars.png differ diff --git a/upload/styles/cbv2new/images/stars.png b/upload/styles/cbv2new/images/stars.png new file mode 100644 index 00000000..7ccb080e Binary files /dev/null and b/upload/styles/cbv2new/images/stars.png differ diff --git a/upload/styles/cbv2new/images/tabs_bg.png b/upload/styles/cbv2new/images/tabs_bg.png new file mode 100644 index 00000000..348a1044 Binary files /dev/null and b/upload/styles/cbv2new/images/tabs_bg.png differ diff --git a/upload/styles/cbv2new/images/tabs_sp.png b/upload/styles/cbv2new/images/tabs_sp.png new file mode 100644 index 00000000..8a984338 Binary files /dev/null and b/upload/styles/cbv2new/images/tabs_sp.png differ diff --git a/upload/styles/cbv2new/images/tag_blue.png b/upload/styles/cbv2new/images/tag_blue.png new file mode 100644 index 00000000..6fb1ca40 Binary files /dev/null and b/upload/styles/cbv2new/images/tag_blue.png differ diff --git a/upload/styles/cbv2new/images/thumbs.png b/upload/styles/cbv2new/images/thumbs.png new file mode 100644 index 00000000..7b921fc7 Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs.png differ diff --git a/upload/styles/cbv2new/images/thumbs/group_thumb-small.png b/upload/styles/cbv2new/images/thumbs/group_thumb-small.png new file mode 100644 index 00000000..361a02ef Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs/group_thumb-small.png differ diff --git a/upload/styles/cbv2new/images/thumbs/group_thumb.png b/upload/styles/cbv2new/images/thumbs/group_thumb.png new file mode 100644 index 00000000..58522225 Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs/group_thumb.png differ diff --git a/upload/styles/cbv2new/images/thumbs/no_avatar-small.png b/upload/styles/cbv2new/images/thumbs/no_avatar-small.png new file mode 100644 index 00000000..8f0af01b Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs/no_avatar-small.png differ diff --git a/upload/styles/cbv2new/images/thumbs/no_avatar.png b/upload/styles/cbv2new/images/thumbs/no_avatar.png new file mode 100644 index 00000000..2e3b8a5f Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs/no_avatar.png differ diff --git a/upload/styles/cbv2new/images/thumbs/processing.png b/upload/styles/cbv2new/images/thumbs/processing.png new file mode 100644 index 00000000..9815b296 Binary files /dev/null and b/upload/styles/cbv2new/images/thumbs/processing.png differ diff --git a/upload/styles/cbv2new/images/top_user.png b/upload/styles/cbv2new/images/top_user.png new file mode 100644 index 00000000..ea2ae28a Binary files /dev/null and b/upload/styles/cbv2new/images/top_user.png differ diff --git a/upload/styles/cbv2new/images/top_users_grad.png b/upload/styles/cbv2new/images/top_users_grad.png new file mode 100644 index 00000000..5604d50a Binary files /dev/null and b/upload/styles/cbv2new/images/top_users_grad.png differ diff --git a/upload/styles/cbv2new/images/up.png b/upload/styles/cbv2new/images/up.png new file mode 100644 index 00000000..39180823 Binary files /dev/null and b/upload/styles/cbv2new/images/up.png differ diff --git a/upload/styles/cbv2new/images/up_down.png b/upload/styles/cbv2new/images/up_down.png new file mode 100644 index 00000000..77ca0cad Binary files /dev/null and b/upload/styles/cbv2new/images/up_down.png differ diff --git a/upload/styles/cbv2new/images/upload_bg.png b/upload/styles/cbv2new/images/upload_bg.png new file mode 100644 index 00000000..8a331a3d Binary files /dev/null and b/upload/styles/cbv2new/images/upload_bg.png differ diff --git a/upload/styles/cbv2new/images/uploading_bar.png b/upload/styles/cbv2new/images/uploading_bar.png new file mode 100644 index 00000000..d5b9d16b Binary files /dev/null and b/upload/styles/cbv2new/images/uploading_bar.png differ diff --git a/upload/styles/cbv2new/images/verticle_bg.png b/upload/styles/cbv2new/images/verticle_bg.png new file mode 100644 index 00000000..6ce8b341 Binary files /dev/null and b/upload/styles/cbv2new/images/verticle_bg.png differ diff --git a/upload/styles/cbv2new/images/view_channel.png b/upload/styles/cbv2new/images/view_channel.png new file mode 100644 index 00000000..cb8dad79 Binary files /dev/null and b/upload/styles/cbv2new/images/view_channel.png differ diff --git a/upload/styles/cbv2new/images/watch_video_bars.png b/upload/styles/cbv2new/images/watch_video_bars.png new file mode 100644 index 00000000..2c3a79b2 Binary files /dev/null and b/upload/styles/cbv2new/images/watch_video_bars.png differ diff --git a/upload/styles/cbv2new/images/watch_video_details_bg.png b/upload/styles/cbv2new/images/watch_video_details_bg.png new file mode 100644 index 00000000..ceef40f4 Binary files /dev/null and b/upload/styles/cbv2new/images/watch_video_details_bg.png differ diff --git a/upload/styles/cbv2new/layout/403.html b/upload/styles/cbv2new/layout/403.html new file mode 100644 index 00000000..0555b021 --- /dev/null +++ b/upload/styles/cbv2new/layout/403.html @@ -0,0 +1,2 @@ +

    403 Error

    +

    Sorry, you cannot access this page.

    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/404.html b/upload/styles/cbv2new/layout/404.html new file mode 100644 index 00000000..21bf59ab --- /dev/null +++ b/upload/styles/cbv2new/layout/404.html @@ -0,0 +1,2 @@ +

    404 Error

    +

    Requested page not found.

    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/activation.html b/upload/styles/cbv2new/layout/activation.html new file mode 100644 index 00000000..651698de --- /dev/null +++ b/upload/styles/cbv2new/layout/activation.html @@ -0,0 +1,34 @@ + +
    +
    +

    {lang code='usr_activation_title'}

    +
    +
    {lang code='acitvation_html_message'}
    +
    + +
    +
    + + + +
    + + +
    +
    + + +
    +

    {lang code='usr_actiavation_msg1'}

    +
    +
    {lang code='acitvation_html_message2'}
    +
    + +
    +
    + + +
    +
    +
    + diff --git a/upload/styles/cbv2new/layout/add_group_videos.html b/upload/styles/cbv2new/layout/add_group_videos.html new file mode 100644 index 00000000..a17b8fb7 --- /dev/null +++ b/upload/styles/cbv2new/layout/add_group_videos.html @@ -0,0 +1,41 @@ +{include file="$style_dir/blocks/group/group_left.html"} +
    +
    {$group.group_name}
    +
    + +
    + {if $usr_vids} +
    {lang code='grp_add_vdo_msg'}
    +
    + + {foreach from=$usr_vids item=video} + {if $cbgroup->is_group_video($video.videoid,$group.group_id)} + {assign var='check_this' value='yes'} + {else} + {assign var='check_this' value=''} + {/if} + {include file="$style_dir/blocks/video.html" video=$video display_type='add_type'} + {/foreach} + +
    + {include file="$style_dir/blocks/pagination.html"} +
    + +
    +
    + + {else} +
    {lang code='you_dont_have_any_videos'}
    + {/if} + +
    +
    +
    + +{include file="$style_dir/blocks/group/group_right.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocked.html b/upload/styles/cbv2new/layout/blocked.html new file mode 100644 index 00000000..a2e328b8 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocked.html @@ -0,0 +1,10 @@ +

    Content you are trying to access is blocked

    +

    This content is blocked by website adminstrator, there could be following possible reasons

    +
      +
    • You are not logged in or you do not have previliges to access this page
    • +
    • Website adminstrator has completely disabled this section
    • +
    • Content is removed by administrator
    • +
    • You have landed on planet "Pandora"
    • +
    +

    Please contact website adminstartor to resolve this issue.

    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/category_list.html b/upload/styles/cbv2new/layout/blocks/category_list.html new file mode 100644 index 00000000..87a05de8 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/category_list.html @@ -0,0 +1,8 @@ +
    +{lang code='categories'} +
    +
      + {cbCategories type=$type echo="TRUE" list_style="collapsed" output="list" with_all="TRUE"} +
    +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/collection.html b/upload/styles/cbv2new/layout/blocks/collection.html new file mode 100644 index 00000000..38a128d0 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/collection.html @@ -0,0 +1,41 @@ +{if $display_type == "" || $display_type == "normal"} +
    +
    + + {$collection.total_objects|number_format} {$collection.type|capitalize} +
    +
    +

    {$collection.collection_name|truncate:30}

    +

    {$collection.views} {lang code="views"}

    +

    {$collection.username|truncate:16}

    + +
    {show_rating class='rating' rating=$collection.rating ratings=$collection.rated_by total='10'}
    +
    +
    +{/if} + +{if $display_type == "view_collection"} +
    + {if $type == "videos"} +
    + + {$object.title} + +
    + {/if} + + {if $type == "photos"} + + {/if} +
    +{/if} + +{if $display_type == "user_collections"} +
    + +
    +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/collection_form.html b/upload/styles/cbv2new/layout/blocks/collection_form.html new file mode 100644 index 00000000..fd7a6ac6 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/collection_form.html @@ -0,0 +1,22 @@ + +
    +
    Add this {$params.type} to collection {if $params.type=='video'} or playlist{/if}
    +
    + + + +
    + Please select collection name from following
    + + + +
    +
    +
    + diff --git a/upload/styles/cbv2new/layout/blocks/comments/add_comment.html b/upload/styles/cbv2new/layout/blocks/comments/add_comment.html new file mode 100644 index 00000000..9cab9d36 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/comments/add_comment.html @@ -0,0 +1,61 @@ +
    +

    {lang code='grp_add_comment'}

    + + + +{if $userquery->login_check('',true) || $Cbucket->configs.anonym_comments == 'yes'} +
    + + + + {if !$userquery->login_check('',true) && $Cbucket->configs.anonym_comments == 'yes'} + +
    +
    + +
    +
    + {else} + Name : {$userquery->username}
    + {/if} + + {ANCHOR place='before_compose_box'} + + +
    + + + {if config('comments_captcha')=='all' || ( config('comments_captcha')=='guests' && !$userquery->login_check('',true) )} + +
    + {lang code='please_enter_confimation_ode'} + + {assign var=captcha value=func->get_captcha()} + {if $captcha} + {if $captcha.show_field} +
    + {load_captcha captcha=$captcha load=field field_params = ' id="captcha" class="input" '} +
    + {/if} + + + {load_captcha captcha=$captcha load=function} + +
    + {/if} + +
    + {/if} + +
    {ANCHOR place='after_compose_box'}
    + +
    + + +
    +
    +{else} + {lang code='please_login_to_comment'} +{/if} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/comments/comment.html b/upload/styles/cbv2new/layout/blocks/comments/comment.html new file mode 100644 index 00000000..e6e6fbe7 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/comments/comment.html @@ -0,0 +1,65 @@ +{if marked_spammed($comment)} + {assign var='comment_attr' value='style="display:none"'} + {assign var='spam_attr' value='style="display:block"'} +{else} +{assign var='comment_attr' value=''} + {assign var='spam_attr' value='style="display:none"'} +{/if} + +
    +
    + +
    +
    +
    +
    + {lang code='user_commented_time' assign='user_commented_time'} + {assign var="nicetime" value=$comment.date_added|niceTime} + {if $comment.userid !='' && $comment.userid!=0} + {assign var="comm_link" value=$userquery->profile_link($comment)} + {assign var="comm_owner" value=$comment.username} + {else} + {assign var="comm_id" value="#comment_"} + {assign var="comm_link" value=$comment.comment_id} + {assign var="comm_owner" value=$comment.anonym_name} + {/if} + + {$user_commented_time|sprintf:"$comm_id$comm_link":$comm_owner:$nicetime} + +
    +
    {lang code='reply'} | {lang code='spam'} + + {if has_access('admin_del_access') || $comment.userid==userid() || $comment.type_owner_id==userid()} | {lang code='delete'}{/if}
    +
    + +
    + + {if $comment.parent_id} + {assign var=parentid value=$comment.parent_id} + {assign var=thisParent value=$parents.$parentid} + + {if $thisParent} +
    + + {if $thisParent.username}@{$thisParent.username} : + {/if}{$thisParent.comment|comment} +
    + {/if} + {/if} + + {$comment.comment|comment} + +
    + + {if $type=='video' && $comments_voting=='yes' && $Cbucket->configs.comment_rating} +
    Thumbs UpThumbs Down{$comment.vote|comment_rating}
    + {/if} + +
    +
    + +
    + {lang code='marked_as_spam_comment_by_user' assign='marked_as_spam_comment_by_user'} + + {if $comment.username}{$marked_as_spam_comment_by_user|sprintf:$comment.username}{else}{$marked_as_spam_comment_by_user|sprintf:$comment.anonym_name}{/if} | {lang code='delete'} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/comments/comments.html b/upload/styles/cbv2new/layout/blocks/comments/comments.html new file mode 100644 index 00000000..fccf0d68 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/comments/comments.html @@ -0,0 +1,20 @@ +{if $comments} +
    + {foreach from=$comments.comments item=comment} + {include file="$style_dir/blocks/comments/comment.html" comment=$comment type=$type parents=$comments.parents} + {/foreach} + +
    + + +{else} +
    +
    + {lang code='no_comments' assign=no_comments} {$no_comments|sprintf:$object_type} +
    +
    + +{/if} +{if $comments} +
    +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/editor_pick/index_featured_video.html b/upload/styles/cbv2new/layout/blocks/editor_pick/index_featured_video.html new file mode 100644 index 00000000..ac7203bc --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/editor_pick/index_featured_video.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/editor_pick/video_block.html b/upload/styles/cbv2new/layout/blocks/editor_pick/video_block.html new file mode 100644 index 00000000..beb31447 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/editor_pick/video_block.html @@ -0,0 +1,8 @@ +
    {$video.title}
    + + diff --git a/upload/styles/cbv2new/layout/blocks/feed.html b/upload/styles/cbv2new/layout/blocks/feed.html new file mode 100644 index 00000000..a449fa86 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/feed.html @@ -0,0 +1,131 @@ + +{literal} + + +{/literal} + + +
    +
    + + {if $u.userid==userid() || has_access('admin_access',true)} + + + {/if} +
    +
    + + {$feed.user.username} +
    +
    +
    + {if !$feed.action_title} + {$feed.user.username} + {else} + {$feed.action_title} + {/if} +
    + +
    + + {if $feed.thumb} + {if $feed.link} + + {/if} + + {if $feed.link} + + {/if} + {/if} + +
    + {if $feed.link} + {$feed.title} + {elseif $feed.title} + {$feed.title} + {/if} + + {if $feed.object_content} +
    + {$feed.object_content} +
    + {/if} +
    + + +
    +
    + + +
    + {if $feed.icon} + + {/if} + {$feed.datetime} + + {if $feed.links} + {foreach from=$feed.links item=link} + . + {if $link.link}{/if}{$link.text}{if $link.link}{/if} + {/foreach} + {/if} + +
    + +
    +
    + + +
    + diff --git a/upload/styles/cbv2new/layout/blocks/flag_form.html b/upload/styles/cbv2new/layout/blocks/flag_form.html new file mode 100644 index 00000000..b34a29aa --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/flag_form.html @@ -0,0 +1,21 @@ + +
    +
    Flag this {$params.type} — cancel
    +
    + + + +
    + Please select the category that most closely reflects your concern about the video, so that we can review it and determine whether it violates our Community Guidelines or isn't appropriate for all viewers. Abusing this feature is also a violation of the Community Guidelines, so don't do it. + {assign var='flag_options' value=func->get_flag_options($type)} + +
    + +
    +
    +
    + diff --git a/upload/styles/cbv2new/layout/blocks/group.html b/upload/styles/cbv2new/layout/blocks/group.html new file mode 100644 index 00000000..0f652a93 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group.html @@ -0,0 +1,10 @@ + +
    + + {$group.group_name} + {lang code='views'} : {$group.total_views|number_format} + {lang code="total_members"}:{$group.total_members|number_format} + {lang code="total_videos"} : {$group.total_videos|number_format} + {lang code="total_topics"} : {$group.total_topics|number_format} + {lang code="owner"} : {$group.username} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/group/add_topic.html b/upload/styles/cbv2new/layout/blocks/group/add_topic.html new file mode 100644 index 00000000..7e7d12b3 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group/add_topic.html @@ -0,0 +1,14 @@ +
    +
    + {assign var='form_fields' value=$cbgroup->load_add_topic_form_fields()} + + {foreach from=$form_fields item=field} +
    +
    +
    {$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}{ANCHOR place=$field.anchor_after}
    +
    + {/foreach} + +
    +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/group/group_header.html b/upload/styles/cbv2new/layout/blocks/group/group_header.html new file mode 100644 index 00000000..45a52109 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group/group_header.html @@ -0,0 +1,156 @@ + + +
    + +
    +
    +
    +
    + {lang code='group_options'} +
      + {assign var=join_link value=$cbgroup->group_opt_link($group,'join')} + {if $join_link}
    • {$join_link}
    • {/if} + + {assign var=invite_link value=$cbgroup->group_opt_link($group,'invite')} + {if $invite_link}
    • {$invite_link}
    • {/if} + + {assign var=leave_link value=$cbgroup->group_opt_link($group,'leave')} + {if $leave_link}
    • {$leave_link}
    • {/if} + + {if isSectionEnabled('videos')} + {assign var=add_videos_link value=$cbgroup->group_opt_link($group,'add_videos')} + {if $add_videos_link}
    • {$add_videos_link}
    • {/if} + {/if} + + {if isSectionEnabled('videos')} + {assign var=manage_videos_link value=$cbgroup->group_opt_link($group,'manage_videos')} + {if $manage_videos_link}
    • {$manage_videos_link}
    • {/if} + {/if} + + {if isSectionEnabled('channels')} + {assign var=manage_members_link value=$cbgroup->group_opt_link($group,'manage_members')} + {if $manage_members_link}
    • {$manage_members_link}
    • {/if} + {/if} + + {assign var=edit_group_link value=$cbgroup->group_opt_link($group,'edit_group')} + {if $edit_group_link}
    • {$edit_group_link}
    • {/if} + + {assign var=remove_group_link value=$cbgroup->group_opt_link($group,'remove_group')} + {if $remove_group_link}
    • {$remove_group_link}
    • {/if} + +
    +
    + +
    + + +
    +
    +
    +
      +
    • {lang code='info'}
    • + {if isSectionEnabled('channels') && $isviewable} +
    • {lang code='members'}
    • + {/if} + {if isSectionEnabled('videos') && $isviewable} +
    • {lang code='videos'}
    • + {/if} +
    • {lang code='report_this'}
    • +
    + +
    +
    +
    + + +
    + +
    + +
    +
    {lang code='basic_info'}
    +
    + {lang code='grp_name_title'} {$group.group_name} +
    + {assign var=owner value=$userquery->get_user_details($group.userid)} + {lang code='group_owner'} {$owner.username} +
    + + {lang code='total_mems'} {$group.total_members|number_format} +
    + + {lang code='com_total_vids'} {$group.total_videos|number_format} +
    + + {lang code='total_topics'} {$group.total_topics|number_format} +
    + + {lang code='views'} {$group.total_views|number_format} +
    + + {lang code='grp_url'} + +
    +
    +
    + +
    +
    {lang code='more_details'}
    + +
    +
    + + + + + + + + + + + + + +
    +
    +
    + + + +
    + + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/group/group_left.html b/upload/styles/cbv2new/layout/blocks/group/group_left.html new file mode 100644 index 00000000..cf57bffb --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group/group_left.html @@ -0,0 +1,35 @@ +
    +
    + +
    + + {isGroupAdmin + groupid = $group.group_id + group = $group + user = $userquery->udetails + uid = $userquery->udetails.userid + checkowner = 'yes' + assign = isGroupAdmin} + + + {if $isGroupAdmin} +
    Admin Links
    + + {/if} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/group/group_right.html b/upload/styles/cbv2new/layout/blocks/group/group_right.html new file mode 100644 index 00000000..de4c194e --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group/group_right.html @@ -0,0 +1,29 @@ +
    +
    {lang code="members"}
    +
    + {assign var=users_items_group_page value=func->config(users_items_group_page)} + {assign var=members value=$cbgroup->get_members($group.group_id,"yes",$users_items_group_page)} + {if $members} + {foreach from=$members item=member} + {include file="$style_dir/blocks/user.html" user=$member block_type='friends'} + {/foreach} + {/if} +
    +
    +
    {lang code="Links"}
    + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/group/group_topics.html b/upload/styles/cbv2new/layout/blocks/group/group_topics.html new file mode 100644 index 00000000..9963e2b3 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group/group_topics.html @@ -0,0 +1,29 @@ + +{if !$topics} + {assign var=topics value=$cbgroup->get_group_topics($group.group_id)} +{/if} + +{if $topics} +{foreach from=$topics item=topic} +{assign var=user value=$userquery->get_user_details($topic.userid)} +{if $topic.last_poster} + {assign var=last_poster value=$userquery->get_user_details($topic.last_poster)} +{else} + {assign var=last_poster value=''} +{/if} +
  • + +
    +

    {$user.username}

    +
    +

    {$topic.topic_title}

    +
    +
    {$topic.topic_post|description|strip_tags|truncate:100}
    +
    + {$topic.date_added|niceTime} – {if $last_poster}{lang code="last_reply"} {lang code="by"} {$last_poster.username} ({$topic.last_post_time|niceTime}){else}Participate{/if} {if has_access('admin_access') || $topic.userid == $userquery->userid} – Delete{/if} +
    +
  • +{/foreach} +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_collections.html b/upload/styles/cbv2new/layout/blocks/manage/account_collections.html new file mode 100644 index 00000000..2990b716 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_collections.html @@ -0,0 +1,89 @@ +{if $mode ==''}{assign var='mode' value='manage'}{/if} +{if $display_type == "" || $display_type == "collections"} + +{/if} + +{if $display_type == "items"} + {if $type == "videos"} + + {/if} + + {if $type == "photos"} + + {/if} +{/if} + +{if $display_type == "favorite"} + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_group.html b/upload/styles/cbv2new/layout/blocks/manage/account_group.html new file mode 100644 index 00000000..185b931a --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_group.html @@ -0,0 +1,38 @@ +{if $control =='full'} + +{/if} + +{if $control =='basic'} + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_head.html b/upload/styles/cbv2new/layout/blocks/manage/account_head.html new file mode 100644 index 00000000..a69732ce --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_head.html @@ -0,0 +1,30 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_left.html b/upload/styles/cbv2new/layout/blocks/manage/account_left.html new file mode 100644 index 00000000..4f653f92 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_left.html @@ -0,0 +1,14 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_photo.html b/upload/styles/cbv2new/layout/blocks/manage/account_photo.html new file mode 100644 index 00000000..cf5c05a7 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_photo.html @@ -0,0 +1,69 @@ +{if $control == 'full'} + +{/if} + +{if $control == "partail"} + +{/if} + +{if $control == 'orphan'} + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_user.html b/upload/styles/cbv2new/layout/blocks/manage/account_user.html new file mode 100644 index 00000000..281f1c45 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_user.html @@ -0,0 +1,23 @@ +
    + + + + + + + + + +
    {$user.username}{$user.username} + {assign var=uid value=$user.userid} + {if ($makeAdmin=='yes' || $rmAdmins.$uid=='yes') && $makeAdmins.$uid!='yes'} + Make admin + {/if} + {if ($removeAdmin=='yes' || $makeAdmins.$uid=='yes') && $rmAdmins.$uid!='yes'} + Remove admin + {/if} + {$user.profile_hits|number_format}{$status} + {if $del_link}{/if} + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/account_video.html b/upload/styles/cbv2new/layout/blocks/manage/account_video.html new file mode 100644 index 00000000..ec2e9d75 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/account_video.html @@ -0,0 +1,95 @@ +{if $control=='' || $control =='view'} +{if $mode ==''}{assign var='mode' value='favorites'}{/if} + +{/if} + +{if $control =='full'} + +{/if} + + +{if $control=='playlist'} + + +{/if} + + +{if $control=='basic'} + + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/group_manage_links.html b/upload/styles/cbv2new/layout/blocks/manage/group_manage_links.html new file mode 100644 index 00000000..04189353 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/group_manage_links.html @@ -0,0 +1,16 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/manage/user_account_pagination.html b/upload/styles/cbv2new/layout/blocks/manage/user_account_pagination.html new file mode 100644 index 00000000..1dc638d2 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/manage/user_account_pagination.html @@ -0,0 +1,8 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/new_pagination.html b/upload/styles/cbv2new/layout/blocks/new_pagination.html new file mode 100644 index 00000000..6f6de447 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/new_pagination.html @@ -0,0 +1,4 @@ +{if $page_no}{assign var=ajaxPage value=$page_no}{else}{assign var=ajaxPage value=2}{/if} +
    + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/pagination.html b/upload/styles/cbv2new/layout/blocks/pagination.html new file mode 100644 index 00000000..1816e8ac --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/pagination.html @@ -0,0 +1,28 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/photo.html b/upload/styles/cbv2new/layout/blocks/photo.html new file mode 100644 index 00000000..2fa549a7 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/photo.html @@ -0,0 +1,55 @@ +{if $display_type == ""} +
    + {get_photo details=$photo output='html' width="110" class='photoThumbBox moveL'} + + + {$photo.views|number_format} {lang code="views"} + +
    + {assign var=cName value=$photo.collection_id|get_collection_field} + {$cName|truncate:30} +
    + +
    +{/if} + +{if $display_type == 'related_photos'} +
    + {get_photo details=$photo output='html' width='120' class='photoThumbBox moveL' style='margin-right:5px;'} + + {$photo.views|number_format} {lang code="views"}
    {$photo.total_comments} {lang code="comments"}
    +
    + {show_rating rating=$photo.rating total='10' class='rating moveL'} +
    +{/if} + +{if $display_type == 'subscription'} +
    + {get_photo details=$photo output='html' class='photoThumbBox' width='110'} + + {show_rating rating=$photo.rating total='10' class='rating'} +
    {$photo.views|number_format} {lang code="views"}
    + {$photo.username|truncate:20} +
    +{/if} + +{if $display_type == "side_photos"} + +{/if} + +{if $display_type == "channel_page"} +
  • + {get_photo details=$photo output='html' width='110' height='64' size='m' style='display:block;margin:0px auto;'} +
  • +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/playlist_form.html b/upload/styles/cbv2new/layout/blocks/playlist_form.html new file mode 100644 index 00000000..78d62cd1 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/playlist_form.html @@ -0,0 +1,26 @@ + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/pm/messages.html b/upload/styles/cbv2new/layout/blocks/pm/messages.html new file mode 100644 index 00000000..b910dae1 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/pm/messages.html @@ -0,0 +1,86 @@ + + +
    +
    + +
    + + +
    +
    + + +
    + +
    + + + {assign var='bg' value='fff'} + {section name=msg loop=$user_msgs} + {if $user_msgs[msg].message_id == $smarty.get.mid} + {assign var='bg' value='c6d7e0'} + {/if} + + {if $bg=='fff'} + {assign var='bg' value='EFF5F8'} + {else} + {assign var='bg' value='fff'} + {/if} + + {sectionelse} +
    {lang code='you_dont_hv_any_pm'}
    + {/section} +
    + +
    + +
    + + + + +{if $pr_msg !=''} + +
    +
    + + +
    +
    +
    {lang code='from'} : {$pr_msg.username} - {$pr_msg.date_added|date_format:"%A, %B %e, %Y %I:%M %p"}
    +
    {lang code='Subject'} : {$pr_msg.message_subject}
    +
    +
    +
    + {private_message pm=$pr_msg} +
    +
    + +{/if} + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/quicklist/block.html b/upload/styles/cbv2new/layout/blocks/quicklist/block.html new file mode 100644 index 00000000..8380348b --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/quicklist/block.html @@ -0,0 +1,29 @@ +
    +
    +{lang code='show_hide'} - {lang code='quicklists'}({$cbvid->total_quicklist()}) - {lang code='remove'}
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/quicklist/video_block.html b/upload/styles/cbv2new/layout/blocks/quicklist/video_block.html new file mode 100644 index 00000000..88b312f1 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/quicklist/video_block.html @@ -0,0 +1,18 @@ + +{if !$videoLink} + {videoLink vdetails=$video assign='videoLink'} +{/if} +
    +
    {$smarty.section.item.iteration}
    +
    + + {if $show_delete=='yes'} +
    + quicklist
    + {/if} +
    {$video.duration|SetTime}
    + +
    +
    + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/rating.html b/upload/styles/cbv2new/layout/blocks/rating.html new file mode 100644 index 00000000..6f40b6a4 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/rating.html @@ -0,0 +1,34 @@ + + +
    +
    + Like
    +
    +
    +
    +
    + Dislike
    + +
    {if $rating_msg}{$rating_msg}{else}{$likes} Likes, {$dislikes} Dislikes{/if}
    + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/share_form.html b/upload/styles/cbv2new/layout/blocks/share_form.html new file mode 100644 index 00000000..987647b5 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/share_form.html @@ -0,0 +1,81 @@ + + + diff --git a/upload/styles/cbv2new/layout/blocks/subscriptions.html b/upload/styles/cbv2new/layout/blocks/subscriptions.html new file mode 100644 index 00000000..41d6574e --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/subscriptions.html @@ -0,0 +1,38 @@ +{if userid()} +
    + {lang code='subscriptions'} + +
    + + {* assign var=subs_vids value=$userquery->get_subscribed_videos($userquery->userid,10)* } + {assign var=subs_uploads value=$userquery->getSubscriptionsUploadsWeek($userquery->userid,10)} + {if $subs_uploads} + {foreach from=$subs_uploads item=item key=type} + {if $type == 'videos'} +
    +

    {$item.title} ({$item.total} {$type})

    + {foreach from=$item.items item=videos} + {include file="$style_dir/blocks/video.html" video=$videos} + {/foreach} +
    + {/if} + {if $type == 'photos'} +
    +

    {$item.title} ({$item.total} {$type})

    + {foreach from=$item.items item=photos} + {include file="$style_dir/blocks/photo.html" photo=$photos display_type = "subscription"} + {/foreach} +
    + {/if} + {/foreach} + {else} + {lang code='no_new_subs_video'} + {/if} + +
    + + +
    +
    +
    {AD place='ad_468x60'}
    +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/upload/form.html b/upload/styles/cbv2new/layout/blocks/upload/form.html new file mode 100644 index 00000000..2cb7dda3 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/upload/form.html @@ -0,0 +1,77 @@ +{assign var='video_fields' value=$Upload->load_video_fields($input)} + + +
    +

    {$vdo_upload_step|sprintf:1}

    +
    + + + + {foreach from=$video_fields item=field_group} +
    + {* Hide fields if group is not required *} + {if $field_group.group_id!='required_fields'} + {$field_group.group_name} + + {/if} +
    + {/foreach} + + +
    +
    +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/upload/photo_form.html b/upload/styles/cbv2new/layout/blocks/upload/photo_form.html new file mode 100644 index 00000000..e966595b --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/upload/photo_form.html @@ -0,0 +1,43 @@ +{assign var='reqFields' value=$cbphoto->load_required_forms($photoArray)} +{assign var='otherFields' value=$cbphoto->load_other_forms($photoArray)} + + +
    + +
    +
    +
    + {foreach from=$reqFields item=item} +
    +
    + {$formObj->createField($item)} + {if $item.hint_1} +
    + {$item.hint_1} + {/if} +
    + {/foreach} +
    + +
    +
    + +
    +
    +
    + +
    + + +
    + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/upload_head.html b/upload/styles/cbv2new/layout/blocks/upload_head.html new file mode 100644 index 00000000..fd9579bc --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/upload_head.html @@ -0,0 +1,67 @@ +{if $c} + {if $cbphoto->is_addable($c)} +
    +
    You are about to add new photos in {$c.collection_name}
    +
    +
    + +
    +
    + +
    +
    + Total Items: {$c.total_objects}
    + Views: {$c.views|number_format}
    + Date Added: {$c.date_added|niceTime} +
    +
    +
    +
    +
    + {else} +
    +
    You can not add new photos in collection because of following reasons:
    +
    +
  • Collection does not exist.
  • +
  • It is unactive.
  • +
  • It is private.
  • +
  • Your are not owner of collection.
  • +
  • You can select collection once your photos have been uploaded.
  • +
    +
    + {/if} +{else} + +
    + + + +
    +
    + + +
    +
    + +
    + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/user.html b/upload/styles/cbv2new/layout/blocks/user.html new file mode 100644 index 00000000..25e52064 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/user.html @@ -0,0 +1,38 @@ +{if $block_type == '' || $block_type=='normal'} +
    +
    +
    + +{if isSectionEnabled('videos')}{$user.total_videos|number_format} {lang code="videos"}{/if} {$user.profile_hits|number_format} {lang code="views"}
    +{$user.subscribers|number_format} {lang code="subscribers"} +{if isSectionEnabled('photos')}{$user.total_photos|number_format} {lang code="photos"}{/if} +
    +{lang code="last_active"} : {$user.last_active|nicetime}
    +{/if} + +{if $block_type =='small'} + +{/if} + +{if $block_type =='medium'} +
    +
    +
    + +{$user.total_videos|number_format} {lang code="videos"} {$user.profile_hits|number_format} {lang code="views"}
    +{/if} + +{if $block_type == "friends"} +
    + {$user.username} +
    +{/if} + +{if $block_type == "topic_view"} + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/video.html b/upload/styles/cbv2new/layout/blocks/video.html new file mode 100644 index 00000000..ef0935d3 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/video.html @@ -0,0 +1,87 @@ +{if $cur_class==''} +{assign var=cur_class value=$smarty.cookies.current_style} +{/if} + + +{if $display_type =='normal' || $display_type==''} + +
    +
    + {$video.title} + {$video.duration|SetTime} + Quicklist + {if $video.broadcast=='private'} +   + {/if} + {ANCHOR place='in_video_thumb' data=$video} +
    +
    +

    {$video.title|truncate:40}

    + +
    + {show_rating class='rating' rating=$video.rating ratings=$video.rated_by total='10' } +
    +

    {$video.description|description|truncate:100}

    +

    {$video.views} View(s) | {$video.comments_count} Comment(s)

    +

    Uploaded By {$video.username} ({$video.date_added|niceTime})

    +
    +
    + +{if $only_once} +
    +{/if} + +{/if} + + +{if $display_type == "channel_page"} +
  • +
    {$video.title}
    +
  • +{/if} + +{if $display_type=='add_type'} +
    +
    + {ANCHOR place='in_video_thumb' data=$video} + + {if $check_type=='array'} + + {else} + + {/if} +
    {$video.duration|SetTime}
    + +
    +
    +
    + + + {show_rating class='rating' rating=$video.rating ratings=$video.rated_by total='10'} + +
    + +
    +
    {$video.description|description|strip_tags|truncate:100}
    +
    Time: {$video.duration|SetTime:false}
    +
    + +
    +
    {$video.views} view(s)
    +
    + + + + +
    +
    +
    +{if $only_once} +
    +{/if} + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/channel_global.html b/upload/styles/cbv2new/layout/blocks/view_channel/channel_global.html new file mode 100644 index 00000000..fbbfaa6a --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/view_channel/channel_global.html @@ -0,0 +1,12 @@ +
    getUserBg($u,true)} + style="background-position:center;background-image: + {if $userquery->getUserBg($u)} + url('{$userquery->getUserBg($u)}');background-repeat: {$u.background_repeat}; + {/if} + {if $u.background_color!=''} + background-color:{$u.background_color}{/if}; + {if $u.background_attachement=='yes'} + background-attachment:fixed + {/if}" + {/if}> \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/channel_item.html b/upload/styles/cbv2new/layout/blocks/view_channel/channel_item.html new file mode 100644 index 00000000..b2d8ae4f --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/view_channel/channel_item.html @@ -0,0 +1,32 @@ +{if $object.photo_id} +
    {$object.photo_title}
    +
    {get_photo details=$object output='html' size='l' width='370'}
    + +
    + +
    {show_rating class='rating' rating=$object.rating ratings=$object.rated_by total='10'}
    +
    {lang code='views'} {$object.views|number_format}
    +
    + {$object.photo_description|description|truncate:200}
    + +
    +{/if} + + +{if $object.videoid} +
    {$object.title}
    + {FlashPlayer vdetails=$object width='100%' height='280' autoplay=true} +
    + +
    {show_rating class='rating' rating=$object.rating ratings=$object.rated_by total='10'}
    +
    {lang code='views'} {$object.views|number_format}
    +
    + {$object.description|description|truncate:200}
    + +
    + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html b/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html new file mode 100644 index 00000000..a6e11856 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/view_channel/channel_left.html @@ -0,0 +1,81 @@ +
    + +
    {if $userquery->perm_check('admin_access')=='yes'}
    {ANCHOR place=view_channel_admin_options data=$u}
    {/if}
    + + {assign var=isSubscribed value=$userquery->is_subscribed($u.userid)} +
    + +
    + +{if $p.show_my_friends!='no'} +
    +
    {lang code="friends"} {lang code="view_all"}
    + {assign var=userFriends value=$userquery->get_contacts($u.userid,'0','yes')} + {if $userFriends} + {foreach from=$userFriends item=friend} + {include file="$style_dir/blocks/user.html" user=$friend block_type="friends"} + {/foreach} + {else} + User dont any friends yet. + {/if} +
    +{/if} + +{if isSectionEnabled('collections') && $p.show_my_collections!='no'} +
    +
    {lang code="Collections"}
    + {assign var=climit value=func->config(collection_channel_page)} + {get_collections assign=userCollections user=$u.userid limit=10 order=" date_added DESC" limit=$climit} + {if $userCollections} + {foreach from=$userCollections item=collection} + {include file="$style_dir/blocks/collection.html" collection=$collection display_type="user_collections"} + {/foreach} + + {else} + {lang code='user_doesnt_any_collection'} + {/if} +
    +{/if} + +{if $p.show_my_subscriptions!='no'} +
    +
    {lang code='user_subscriptions' assign='users_videos'}{$users_videos|sprintf:$u.username}
    + {assign var=users_items_subscriptions value=func->config(users_items_subscriptions)} + {assign var='usr_subs' value=$userquery->get_user_subscriptions($u.userid,$users_items_subscriptions)} + {if $usr_subs} + {foreach from=$usr_subs item=sub} + {include file="$style_dir/blocks/user.html" user=$sub block_type="friends"} + {/foreach} + {else} + {lang code='user_no_subscriptions' assign='user_subs'}{$user_subs|sprintf:$u.username} + {/if} +
    +{/if} + +{if $userquery->userid!=$u.userid} + +{/if} +{show_flag_form id=$u.userid type=User} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/channel_top.html b/upload/styles/cbv2new/layout/blocks/view_channel/channel_top.html new file mode 100644 index 00000000..1806f145 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/view_channel/channel_top.html @@ -0,0 +1,17 @@ + +
    +
    +
    +
    {$u.username}
    +
    {lang code='user_s_channel' assign='usr_s'}{$usr_s|sprintf:$u.username}
    +
    + {assign var='channel_links' value=$userquery->get_inner_channel_top_links($u)} + +
    +
    +
    + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/view_channel/user_block.html b/upload/styles/cbv2new/layout/blocks/view_channel/user_block.html new file mode 100644 index 00000000..d85df61c --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/view_channel/user_block.html @@ -0,0 +1,34 @@ + +
    + +{/if} + {show_flag_form id=$u.userid type=User}
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/watch_video/playlist_box.html b/upload/styles/cbv2new/layout/blocks/watch_video/playlist_box.html new file mode 100644 index 00000000..ccf79474 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/watch_video/playlist_box.html @@ -0,0 +1,43 @@ +{if $cb_playlist==''} + {assign var=cb_playlist value=$cbvid->action->get_playlist($smarty.get.play_list)} +{/if} + +{if $cb_playlist} +Playlist : {$cb_playlist.playlist_name} +
    + + +{if $cb_playlist_items==''} +{assign var=cb_playlist_items value=$cbvid->get_playlist_items($cb_playlist.playlist_id)} +{/if} +{assign var='bg' value='fff'} +{section name=item loop=$cb_playlist_items} + {include file="$style_dir/blocks/quicklist/video_block.html" video=$cb_playlist_items[item] selected=$selected bg=$bg} + + {if $bg=='fff'} + {assign var='bg' value='EFF5F8'} + {else} + {assign var='bg' value='fff'} + {/if} + + {if $selected==$cb_playlist_items[item].videoid} + {assign var='pre_lock' value='yes'} + {else} + {if !$pre_lock} + {videoLink vdetails=$cb_playlist_items[item] assign='pre_vid'} + {else} + {if !$next_lock} + {videoLink vdetails=$cb_playlist_items[item] assign='next_vid'} + {assign var='next_lock' value='yes'} + {/if} + {/if} + {/if} +{/section} +
    +
    +{/if} + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/blocks/watch_video/video_box.html b/upload/styles/cbv2new/layout/blocks/watch_video/video_box.html new file mode 100644 index 00000000..5726fbb6 --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/watch_video/video_box.html @@ -0,0 +1,21 @@ + + +{if $display_type =='normal' || $display_type==''} +
    +
    + + +
    {$video.duration|SetTime}
    + quicklist +
    +
    + {$video.title|truncate:30}
    +{lang code='views'}: {$video.views|number_format}
    + +{$video.username} + +
    + +
    +{/if} + diff --git a/upload/styles/cbv2new/layout/blocks/watch_video/video_password.html b/upload/styles/cbv2new/layout/blocks/watch_video/video_password.html new file mode 100644 index 00000000..df99d80c --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/watch_video/video_password.html @@ -0,0 +1,15 @@ +
    + {lang code='video_is_password_protected' assign='pass_protect_phrase'} +

    {$pass_protect_phrase|sprintf:$vdo.title}

    + +
    + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/body.html b/upload/styles/cbv2new/layout/body.html new file mode 100644 index 00000000..fe7115df --- /dev/null +++ b/upload/styles/cbv2new/layout/body.html @@ -0,0 +1,42 @@ +{* Including Global Header *} +{include file="$style_dir/global_header.html"} + +{include_header file="admin_bar"} + + +
    + {include file="$style_dir/header.html" } +
    + + +
    + + {ANCHOR place='global'} + + + {include file="$style_dir/message.html"} + {foreach from=$template_files item=file} + {include_template_file file=$file} + {/foreach} +
    +
    + + +
    +
    + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/channels.html b/upload/styles/cbv2new/layout/channels.html new file mode 100644 index 00000000..89e4c11a --- /dev/null +++ b/upload/styles/cbv2new/layout/channels.html @@ -0,0 +1,37 @@ + + + {include file="$style_dir/blocks/category_list.html" type='user'} + + +
    +
    + +
      +
    • {lang code='sort_by'} :
    • + {assign var=sorting_links value=func->sorting_links()} + {foreach from=$sorting_links item=name key=sort} +
    • {$name}
    • + {/foreach} +
    + + +
    + +
    +{assign var=time_links value=func->time_links()} +{foreach from=$time_links item=name key=sort name=times} + {$name} {if !$smarty.foreach.times.last}|{/if} +{/foreach} +
    + {section name=u_list loop=$users} + {include file="$style_dir/blocks/user.html" user=$users[u_list]} + {sectionelse} + {lang code='no_results_found'} + {/section} +
    +
    + +
    {AD place='ad_160x600'}
    +
    + +{include file="$style_dir/blocks/pagination.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/collections.html b/upload/styles/cbv2new/layout/collections.html new file mode 100644 index 00000000..0f0caa4d --- /dev/null +++ b/upload/styles/cbv2new/layout/collections.html @@ -0,0 +1,45 @@ + + {include file="$style_dir/blocks/category_list.html" type='collections'} + + +
    + +
    +
      +
    • {lang code='sort_by'} :
    • + {assign var=sorting_links value=$cbcollection->sorting_links()} + {foreach from=$sorting_links item=name key=sort} +
    • {$name}
    • + {/foreach} +
    +
    + + +
    +{assign var=time_links value=func->time_links()} +{foreach from=$time_links item=name key=sort name=times} + {$name} {if !$smarty.foreach.times.last}|{/if} +{/foreach} +
    + + + +{section name=c_list loop=$collections} + {include file="$style_dir/blocks/collection.html" collection=$collections[c_list]} +{sectionelse} + {lang code='no_results_found'} +{/section} +
    + +
    +
    + {AD place='ad_160x600'} +
    + +
    + +
    + +{include file="$style_dir/blocks/pagination.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/contact.html b/upload/styles/cbv2new/layout/contact.html new file mode 100644 index 00000000..53a9968c --- /dev/null +++ b/upload/styles/cbv2new/layout/contact.html @@ -0,0 +1,30 @@ +

    {lang code="contact_us"}

    + +

    {lang code="contact_us_msg"}

    +
    + + +
    + + +
    + + +
    + + +
    + +{assign var=captcha value=func->get_captcha()} +{if $captcha} + {if $captcha.show_field} + + {load_captcha captcha=$captcha load=field field_params = ' id="verification_code" '} + {/if} +
     {load_captcha captcha=$captcha load=function}
    +{/if} + +
    +
    +

     

    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/create_group.html b/upload/styles/cbv2new/layout/create_group.html new file mode 100644 index 00000000..dce07dd3 --- /dev/null +++ b/upload/styles/cbv2new/layout/create_group.html @@ -0,0 +1,47 @@ +{assign var='requiredFields' value=$cbgroup->load_required_fields()} +{assign var='optionFields' value=$cbgroup->load_other_fields()} +{assign var='customFields' value=$cbgroup->custom_group_fields} + +
    +
    +

    {lang code='grp_crt_grp'}

    +
    + + +
    + required fields + {foreach from=$requiredFields item=field} +
    + + {if $field.hint_1}
    {$field.hint_1}

    {/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} + {if $field.hint_2}
    +
    {$field.hint_2}
    {/if} +
    + {/foreach} + +
    + + + + + {lang code='more_options'} + + +
    +
    +
    +
    diff --git a/upload/styles/cbv2new/layout/download.html b/upload/styles/cbv2new/layout/download.html new file mode 100644 index 00000000..9f3e9a69 --- /dev/null +++ b/upload/styles/cbv2new/layout/download.html @@ -0,0 +1,25 @@ + + + +
    + +{lang code='downloading_string' assign='downloadingstring'} + +

    {$downloadingstring|sprintf:$vdo.title}

    + +{lang code='download_redirect_msg' assign='redirectmsg'} +{videoLink vdetails=$vdo assign='vidlink'} +{assign value=$vdo.download_file var='downloadfile'} + +

    {$redirectmsg|sprintf:$downloadfile:$vidlink}

    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/edit_account.html b/upload/styles/cbv2new/layout/edit_account.html new file mode 100644 index 00000000..4a1b7482 --- /dev/null +++ b/upload/styles/cbv2new/layout/edit_account.html @@ -0,0 +1,344 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + + + +{/if} + + + +{if $mode == 'avatar_bg'} + + +
    +
    + +{/if} + + + + +{if $mode == 'change_email'} + + + + + +{/if} + + + + +{if $mode == 'change_password'} + + + + +{/if} + +{if $mode == 'block_users'} + + + +{/if} + + +{if $mode=='subs'} +

    {lang code='com_manage_subs'}

    + + + {if $subs} + + + + + + + + + +
     Usernameviews 
    + + {foreach from=$subs item=sub} +
    + + + + + + + + + +
    {$sub.username}{$sub.username} | {lang code='grp_view_vdos'}{$sub.profile_hits|number_format}
    +
    + {/foreach} +{else} +
    {lang code='no_subs_found'}
    + {/if} + + + + + +{/if} +
    diff --git a/upload/styles/cbv2new/layout/edit_group.html b/upload/styles/cbv2new/layout/edit_group.html new file mode 100644 index 00000000..d7eeff1c --- /dev/null +++ b/upload/styles/cbv2new/layout/edit_group.html @@ -0,0 +1,91 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/edit_photo.html b/upload/styles/cbv2new/layout/edit_photo.html new file mode 100644 index 00000000..58a280a2 --- /dev/null +++ b/upload/styles/cbv2new/layout/edit_photo.html @@ -0,0 +1,47 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/edit_video.html b/upload/styles/cbv2new/layout/edit_video.html new file mode 100644 index 00000000..126d25e3 --- /dev/null +++ b/upload/styles/cbv2new/layout/edit_video.html @@ -0,0 +1,80 @@ +{assign var='video_fields' value=$Upload->load_video_fields($v)} +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/footer.html b/upload/styles/cbv2new/layout/footer.html new file mode 100644 index 00000000..80b84541 --- /dev/null +++ b/upload/styles/cbv2new/layout/footer.html @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/forgot.html b/upload/styles/cbv2new/layout/forgot.html new file mode 100644 index 00000000..759a1051 --- /dev/null +++ b/upload/styles/cbv2new/layout/forgot.html @@ -0,0 +1,71 @@ +{if $pass_recover=='success'} + + +{lang code='pass_changed_success'} + +{else} + +
    + + {if $mode=='' || $mode=='reset_pass' } +
    +

    {lang code='user_forgot_message'}{lang code='click_here_to_recover_user'}

    +
    +
    {lang code=user_pass_forgot_msg'}
    +
    + +
    +
    + {assign var=captcha value=func->get_captcha()} + {if $captcha} + {if $captcha.show_field} + + {load_captcha captcha=$captcha load=field field_params = ' id="verification_code" '} + {/if} +
    + +
    + {load_captcha captcha=$captcha load=function} +
    + {/if} + +
    + + +
    +
    + {/if} + + {if $mode=='recover_username'} + + +
    +

    {lang code='user_reocover_user'}{lang code='click_here_reset_pass'}

    +
    + +
    +
    + {assign var=captcha value=func->get_captcha()} + {if $captcha} + {if $captcha.show_field} + + {load_captcha captcha=$captcha load=field field_params = ' id="verification_code" '} + {/if} +
    + +
    + {load_captcha captcha=$captcha load=function} +
    + {/if} + +
    + + +
    +
    + {/if} + +
    + + +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/global_header.html b/upload/styles/cbv2new/layout/global_header.html new file mode 100644 index 00000000..36aa00cc --- /dev/null +++ b/upload/styles/cbv2new/layout/global_header.html @@ -0,0 +1,206 @@ + + + + + + + + + + + +{rss_feeds link_tag=true} + + + + + + +{cbtitle} + + + + +{php} + if(!$_COOKIE['current_style']) + $_COOKIE['current_style'] = 'grid_view'; +{/php} + + + + + + +{include_header file='global_header'} + + +{if $smarty.const.THIS_PAGE =='private_message' && $smarty.get.mid} + +{/if} + + + + + +{literal} + +{/literal} +{literal} + +{/literal} + +{literal} + +{/literal} + + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/groups.html b/upload/styles/cbv2new/layout/groups.html new file mode 100644 index 00000000..242879d1 --- /dev/null +++ b/upload/styles/cbv2new/layout/groups.html @@ -0,0 +1,50 @@ + + + {include file="$style_dir/blocks/category_list.html" type='groups'} + + + +
    +
    + +
      +
    • {lang code='sort_by'} :
    • + {assign var=sorting_links value=func->sorting_links()} + {foreach from=$sorting_links item=name key=sort} +
    • {$name}
    • + {/foreach} +
    + + +
    + +
    +{assign var=time_links value=func->time_links()} +{foreach from=$time_links item=name key=sort name=times} + {$name} {if !$smarty.foreach.times.last}|{/if} +{/foreach} +
    + + + +{section name=glist loop=$groups} + {include file="$style_dir/blocks/group.html" group=$groups[glist]} +{sectionelse} + {lang code='no_results_found'} +{/section} + +
    + + +
    +
    + {AD place='ad_160x600'} +
    + +
    + +
    + +{include file="$style_dir/blocks/pagination.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/header.html b/upload/styles/cbv2new/layout/header.html new file mode 100644 index 00000000..8ae993a3 --- /dev/null +++ b/upload/styles/cbv2new/layout/header.html @@ -0,0 +1,104 @@ +
    +
    + +
    + + +
    +
    +
      + {cbMenu echo='yes'} +
    + +
    + +
    + + + {ANCHOR place='anything'} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/index.html b/upload/styles/cbv2new/layout/index.html new file mode 100644 index 00000000..73e1f05c --- /dev/null +++ b/upload/styles/cbv2new/layout/index.html @@ -0,0 +1,153 @@ + +
    + + {if is_installed('editorspick')} +
    +
    + {section name=e_list loop=$editor_picks max=1} + {include file="$style_dir/blocks/editor_pick/video_block.html" video=$editor_picks[e_list]} + {sectionelse} +
    + There is no video in editor's pick, Please Add Videos In Editor's Pick
    + Videos Manager > Add to editor's pick +
    + {/section} +
    +
    + {section name=e_list loop=$editor_picks} + {include file="$style_dir/blocks/editor_pick/index_featured_video.html" video=$editor_picks[e_list]} + {/section} +
    +
    +
    + + {/if} + +
    {AD place='ad_468x60'}
    + + {if isSectionEnabled('videos') || isSectionEnabled('photos')} + {include file="$style_dir/blocks/subscriptions.html"} + {/if} + + {if isSectionEnabled('videos')} + +
    +
    +
    +
    + {lang code='change_style_of_listing'} +
    + +
    + +
    + + +
    +
    +
    + {/if} + {if isSectionEnabled('photos')} + +
    + +
    + +
    + + +
    +
    +
    + {/if} +
    + +
    + + + {AD place=ad_300x250} + + {if !$userquery->login_check('',true)} + + {/if} + + + + + {if isSectionEnabled('videos')} + + {assign var=videos_items_columns value=func->config(videos_items_columns)} + {get_videos assign=ran_vids limit=$videos_items_columns order=RAND()} + + {if $ran_vids} +
    + {lang code='rand_vids'} +
    + {section name=uvlist loop=$ran_vids} + {include file="$style_dir/blocks/watch_video/video_box.html" video=$ran_vids[uvlist]} + {/section} +
    +
    +
    +
    + {/if} + {/if} + + {if isSectionEnabled('photos')} + + {assign var=limit value=func->config(photo_other_limit)} + {get_photos assign=ran_ph limit=$limit order=RAND()} + + {if $ran_ph} +
    + {lang code='rand_photos'} +
    + {section name=plist loop=$ran_ph} + {include file="$style_dir/blocks/photo.html" photo=$ran_ph[plist] display_type="side_photos"} + {/section} +
    +
    +
    +
    + {/if} + {/if} + + {if isSectionEnabled('channels')} +
    +
    +

    {lang code='t_10_users'}

    + {get_users assign=topusers limit=10 order=' total_videos DESC '} + + {section name=tusers loop=$topusers} +
    +
    {$smarty.section.tusers.iteration}
    +
    +
    {$topusers[tusers].username}{lang code='views'} : {$topusers[tusers].profile_hits|number_format} - {lang code='videos'} : {$topusers[tusers].total_videos|number_format} +
    +
    +
    + {/section} +
    +
    + {/if} + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/manage_collections.html b/upload/styles/cbv2new/layout/manage_collections.html new file mode 100644 index 00000000..03139aab --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_collections.html @@ -0,0 +1,166 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/manage_contacts.html b/upload/styles/cbv2new/layout/manage_contacts.html new file mode 100644 index 00000000..5346a44d --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_contacts.html @@ -0,0 +1,96 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/manage_groups.html b/upload/styles/cbv2new/layout/manage_groups.html new file mode 100644 index 00000000..3afc459f --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_groups.html @@ -0,0 +1,296 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + + + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/manage_photos.html b/upload/styles/cbv2new/layout/manage_photos.html new file mode 100644 index 00000000..740fe773 --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_photos.html @@ -0,0 +1,134 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + +
    diff --git a/upload/styles/cbv2new/layout/manage_playlists.html b/upload/styles/cbv2new/layout/manage_playlists.html new file mode 100644 index 00000000..fdec7c93 --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_playlists.html @@ -0,0 +1,123 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/manage_videos.html b/upload/styles/cbv2new/layout/manage_videos.html new file mode 100644 index 00000000..a7b02134 --- /dev/null +++ b/upload/styles/cbv2new/layout/manage_videos.html @@ -0,0 +1,121 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/message.html b/upload/styles/cbv2new/layout/message.html new file mode 100644 index 00000000..a1996949 --- /dev/null +++ b/upload/styles/cbv2new/layout/message.html @@ -0,0 +1,37 @@ +{assign var=msg value=$eh->message_list} +{assign var=err value=$eh->error_list} +{assign var=war value=$eh->warning_list} + +{if $err.0 neq '' || $err.1 != ''} +
    +
      +{foreach from=$err item=show_msg} +
    • {$show_msg}
    • +{/foreach} +
    +
    +{/if} + + +{if $msg.0 neq ''} +
    +
      +{foreach from=$msg item=show_msg} +
    • {$show_msg}
    • +{/foreach} +
    +
    +{/if} + + +{if $war.0 neq ''} +
    +
      + +{foreach from=$war item=show_msg} +
    • {$show_msg}
    • +{/foreach} +
    +
    +
    +{/if} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/myaccount.html b/upload/styles/cbv2new/layout/myaccount.html new file mode 100644 index 00000000..5baec1a8 --- /dev/null +++ b/upload/styles/cbv2new/layout/myaccount.html @@ -0,0 +1,23 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/photo_upload.html b/upload/styles/cbv2new/layout/photo_upload.html new file mode 100644 index 00000000..3d9adad3 --- /dev/null +++ b/upload/styles/cbv2new/layout/photo_upload.html @@ -0,0 +1,34 @@ +
    +
    +{if $step == 1 || $step == ""} +

    Select Photo Files

    + {loadPhotoUploadForm buttonClass='LoadMoreButton moveR'} +{/if} + +{if $step == 2} +

    Enter Information

    + {foreach item=item from=$photos} + {include file="$style_dir/blocks/upload/photo_form.html" photo=$item} + {/foreach} + +{/if} + +{if $step == 3} +
    +
    {lang code="photo_success_heading"}
    + +
    + You can manage your photos from {lang code='manage_photos'}. +
    +
    +{/if} +
    +
    + +
    +
    + {lang code='upload_right_guide_photo'} +
    +
    + {AD place='ad_300x250'} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/photos.html b/upload/styles/cbv2new/layout/photos.html new file mode 100644 index 00000000..3798d4dc --- /dev/null +++ b/upload/styles/cbv2new/layout/photos.html @@ -0,0 +1,40 @@ +
    +
    + +
      +
    • {lang code='sort_by'} :
    • + {assign var=sorting_links value=func->sorting_links()} + {foreach from=$sorting_links item=name key=sort} +
    • {$name}
    • + {/foreach} +
    + + +
    + +
    +{assign var=time_links value=func->time_links()} +{foreach from=$time_links item=name key=sort name=times} + {$name} {if !$smarty.foreach.times.last}|{/if} +{/foreach} +
    +
    + {section name=p_list loop=$photos} + {include file="$style_dir/blocks/photo.html" photo=$photos[p_list]} + {sectionelse} + {lang code='no_results_found'} + {/section} +
    +
    +
    + +
    +
    + {AD place='ad_160x600'} +
    + +
    + +
    + +{include file="$style_dir/blocks/pagination.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/private_message.html b/upload/styles/cbv2new/layout/private_message.html new file mode 100644 index 00000000..9141660d --- /dev/null +++ b/upload/styles/cbv2new/layout/private_message.html @@ -0,0 +1,50 @@ +
    + {include file="$style_dir/blocks/manage/account_left.html"} + + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/search.html b/upload/styles/cbv2new/layout/search.html new file mode 100644 index 00000000..ccb07eef --- /dev/null +++ b/upload/styles/cbv2new/layout/search.html @@ -0,0 +1,77 @@ +
    + + + +{lang code='more_options'} + +
    +
    {$search_type_title}
    +
    + +
    + {if $results} + {foreach item=result from=$results} + {assign var=$template_var value =$result} + {include file="$display_template" } + {/foreach} + {else} + {lang code='no_results_found'} + {/if} +
    + +
    +
    + {AD place='ad_160x600'} +
    + +
    +
    + +{include file="$style_dir/blocks/pagination.html"} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/signup.html b/upload/styles/cbv2new/layout/signup.html new file mode 100644 index 00000000..734a8741 --- /dev/null +++ b/upload/styles/cbv2new/layout/signup.html @@ -0,0 +1,113 @@ +{assign var='required_fields' value=$userquery->load_signup_fields()} +{assign var='custom_field' value=$userquery->custom_signup_fields} + +{if $mode == 'signup_success'} +
    + {if $udetails.usr_status !='Ok'} + {lang code='signup_success_usr_ok'} + {else} + {lang code='signup_success_usr_emailverify' assign='signupsuccessusremailverify'} + {link name='login' assign='login_link'} + {$signupsuccessusremailverify|sprintf:$login_link} +{/if}
    +{else} + + +{/if} +
    diff --git a/upload/styles/cbv2new/layout/upload.html b/upload/styles/cbv2new/layout/upload.html new file mode 100644 index 00000000..814a807f --- /dev/null +++ b/upload/styles/cbv2new/layout/upload.html @@ -0,0 +1,72 @@ +{lang code='vdo_upload_step2' assign='vdo_upload_step'} +
    + + + + {if $step =='1'} + + {assign var='no_upload' value='yes'} + {assign var=opt_list value=$Upload->load_upload_options()} +
      + {foreach from=$opt_list item=opt key=divid} + + {* Checking weather to show uploadin option to user or not *} + {assign var=uploadOptId value=$opt.load_func} + {if $Cbucket->configs.$uploadOptId=='yes'} + {assign var='no_upload' value='no'} +
    • {$opt.title}
    • + {/if} + {/foreach} +
    +
    +
    + {foreach from=$opt_list item=opt key=divid} + {* Checking weather to show uploadin option to user or not *} + {assign var=uploadOptId value=$opt.load_func} + {if $Cbucket->configs.$uploadOptId=='yes'} + + {/if} + {/foreach} + + {if $no_upload=='yes'} +
    + {lang code='no_upload_opt'} +
    + {/if} +
    + {literal} + + {/literal} + {/if} + + + + + + {if $step==3} +
    + {lang code='video_complete_msg' assign='video_complete_msg'} + {link name='upload' assign='uploadlink'} + {link name='my_videos' assign='myvidslink'} + {$video_complete_msg|sprintf:$myvidslink:$uploadlink:$myvidslink} +
    + {/if} + + +
    + +
    +
    + {lang code='upload_right_guide'} +
    +
    + {AD place='ad_300x250'} +
    +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/user_collections.html b/upload/styles/cbv2new/layout/user_collections.html new file mode 100644 index 00000000..bc6c986e --- /dev/null +++ b/upload/styles/cbv2new/layout/user_collections.html @@ -0,0 +1,30 @@ +{include file="$style_dir/global_header.html"} + +{include file="$style_dir/blocks/view_channel/channel_global.html" } +
    + {include file="$style_dir/header.html"} +
    + {include file="$style_dir/message.html"} + +
    + {include file="$style_dir/blocks/view_channel/channel_left.html"} +
    +
    +
    +

    {$the_title}

    + {section name=c_list loop=$collections} + {include file="$style_dir/blocks/collection.html" collection=$collections[c_list]} + {/section} +
    + {include file="$style_dir/blocks/pagination.html"} +
    +
    +
    +
    + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/user_contacts.html b/upload/styles/cbv2new/layout/user_contacts.html new file mode 100644 index 00000000..77f7bd62 --- /dev/null +++ b/upload/styles/cbv2new/layout/user_contacts.html @@ -0,0 +1,47 @@ +{include file="$style_dir/global_header.html"} + +{include file="$style_dir/blocks/view_channel/channel_global.html" } +
    + {include file="$style_dir/header.html"} +
    + {include file="$style_dir/message.html"} + +
    + {include file="$style_dir/blocks/view_channel/channel_left.html"} +
    +
    +
    + {if $mode == '' || $mode == 'contacts'} + {lang code='users_contacts' assign='users_contacts'} +

    {$users_contacts|sprintf:$u.username}

    + {if $friends} + {foreach from=$friends item=friend} + {if $u.userid!=$friend.userid} + {assign var=user_detail value=$userquery->get_user_details($friend.userid)} + {else} + {assign var=user_detail value=$userquery->get_user_details($friend.contact_userid)} + {/if} + {include file="$style_dir/blocks/user.html" user=$user_detail} + {/foreach} + {else} + This user has no contacts + {/if} + {else} +

    {$heading}

    + {if $userSubs} + {foreach from=$userSubs item=item} + {include file="$style_dir/blocks/user.html" user=$item} + {/foreach} + {/if} + {/if} +
    +
    +
    +
    + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/user_photos.html b/upload/styles/cbv2new/layout/user_photos.html new file mode 100644 index 00000000..ceb3a6c9 --- /dev/null +++ b/upload/styles/cbv2new/layout/user_photos.html @@ -0,0 +1,30 @@ +{include file="$style_dir/global_header.html"} + +{include file="$style_dir/blocks/view_channel/channel_global.html" } +
    + {include file="$style_dir/header.html"} +
    + {include file="$style_dir/message.html"} + +
    + {include file="$style_dir/blocks/view_channel/channel_left.html"} +
    +
    +
    +

    {$the_title}

    + {section name=p_list loop=$photos} + {include file="$style_dir/blocks/photo.html" photo=$photos[p_list]} + {/section} +
    + {include file="$style_dir/blocks/pagination.html"} +
    +
    +
    +
    + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/user_videos.html b/upload/styles/cbv2new/layout/user_videos.html new file mode 100644 index 00000000..243d6826 --- /dev/null +++ b/upload/styles/cbv2new/layout/user_videos.html @@ -0,0 +1,34 @@ +{lang code='channel' assign='object_type'} +{include file="$style_dir/global_header.html"} + +{include file="$style_dir/blocks/view_channel/channel_global.html" } +
    + {include file="$style_dir/header.html"} +
    + {include file="$style_dir/message.html"} + +
    + {include file="$style_dir/blocks/view_channel/channel_left.html"} +
    +
    +
    +

    {$the_title}

    + {section name=v_list loop=$videos} + {include file="$style_dir/blocks/video.html" video=$videos[v_list]} + {/section} + +
    + {include file="$style_dir/blocks/pagination.html"} +
    +
    + +
    + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/videos.html b/upload/styles/cbv2new/layout/videos.html new file mode 100644 index 00000000..9ddee63a --- /dev/null +++ b/upload/styles/cbv2new/layout/videos.html @@ -0,0 +1,52 @@ + + + {include file="$style_dir/blocks/category_list.html" type='video'} + + +
    +
    + +
      +
    • {lang code='sort_by'} :
    • + {assign var=sorting_links value=func->sorting_links()} + {foreach from=$sorting_links item=name key=sort} +
    • {$name}
    • + {/foreach} +
    + + +
    + +
    +{assign var=time_links value=func->time_links()} +{foreach from=$time_links item=name key=sort name=times} + {$name} {if !$smarty.foreach.times.last}|{/if} +{/foreach} +
    + +
    +
    +
    + {lang code='change_style_of_listing'} +
    + +
    + {section name=v_list loop=$videos} + {include file="$style_dir/blocks/video.html" video=$videos[v_list]} + {sectionelse} + {lang code='no_results_found'} + {/section} +
    +
    +
    + +
    +
    + {AD place='ad_160x600'} +
    + +
    + +
    + +{include file="$style_dir/blocks/pagination.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_channel.html b/upload/styles/cbv2new/layout/view_channel.html new file mode 100644 index 00000000..3b875952 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_channel.html @@ -0,0 +1,325 @@ +{lang code='channel' assign='object_type'} +{include file="$style_dir/global_header.html"} + +{include file="$style_dir/blocks/view_channel/channel_global.html" } +
    + {include file="$style_dir/header.html"} +
    + {include file="$style_dir/message.html"} + + +
    + {include file="$style_dir/blocks/view_channel/channel_left.html"} +
    +
    + {if isSectionEnabled('photos') || isSectionEnabled('videos')} + + {if $p.show_my_photos !='no'} + {get_photos assign=latestP order=" date_added DESC" limit=10 user=$u.userid} + {/if} + + {get_videos assign=latestV order=" date_added DESC" limit=10 user=$u.userid status="Successful" broadcast="public"} + {if $latestP || $latestV} +
    + {if $p.show_my_photos !='no' && $latestP} + +
    + +
    +
      + {if $latestP} + test + {section name=plist loop=$latestP} + {if $smarty.section.plist.iteration==1} + {if !$profile_item} + {assign var='profile_item' value=$latestP[plist]} + {/if} + {/if} + {include file="$style_dir/blocks/photo.html" photo=$latestP[plist] display_type='channel_page'} + {/section} + {else} +
      {lang code='found_no_photos'}
      + {/if} +
    +
    + +
    + {/if} + + {if $p.show_my_photos !='no' || $p.show_my_videos !='no'} +
    +
    + +
    +
    + {/if} + + + {if $p.show_my_videos !='no' && $latestV} +
    + + +
    +
      + + {section name=vlist loop=$latestV} + {if !$profile_item} + {assign var='profile_item' value=$latestV[vlist]} + {/if} + {include file="$style_dir/blocks/video.html" video=$latestV[vlist] display_type='channel_page'} + {/section} + + +
    +
    + +
    + {/if} +
    + {/if} + {/if} + + {* Fetching Profile item File*} + + {if $profile_item} + + + {/if} + +
    + +
    + + + + {if isSectionEnabled('feeds')} + + {/if} +
    +
    + +
    +
    + {lang code="comments"} + + +
    + +
    + + {if $myquery->is_commentable($p,'u')} + {include file="$style_dir/blocks/comments/add_comment.html" id=$u.userid type=c} + {else} +
    {lang code='coments_disabled_profile'}
    + {/if} +
    +
    +
    +
    +
    + +
    + + + + + + + \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_collection.html b/upload/styles/cbv2new/layout/view_collection.html new file mode 100644 index 00000000..37a62ca2 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_collection.html @@ -0,0 +1,208 @@ +{literal} + +{/literal} + + +{lang code='collection' assign='object_type'} + +
    +{uploadButton details=$c output='link' target="_blank" class='moveR small_button non_button'} +
    {$c.collection_name}
    + + + +
    {lang code="by"|capitalize} {$c.username|capitalize} - {lang code="view"|capitalize} {$c.username|capitalize} {lang code="videos"|capitalize} {if $c.userid == $userquery->userid} - {lang code="edit_collection"} - {link name='manage_items' assign='miLink'} {lang code="manage_items"}{/if}
    + +
    + +
    {$c.type|capitalize} ({$c.total_objects})
    + +
    +
    +
    +
    + {section name=list loop=$objects} + {include file="$style_dir/blocks/collection.html" object=$objects[list] display_type=view_collection type=$c.type} + {sectionelse} +
    {$c.collection_name} has 0 items.
    + {/section} +
    +
    +
    + +
    {include file="$style_dir/blocks/new_pagination.html"}
    + + +
    +
    + + + {if $c.userid != userid()} + {if !$cbcollection->is_contributor($c.collection_id,userid())} + + + + {else} + + + + + + {/if} + + {/if} + + + + +
    + {lang code="date_added"} +
    + {$c.date_added|niceTime} +
    + + {lang code="views"} +
    + {$c.views|number_format} {lang code="views"} +
    + + {lang code="categories"} +
    + {$c.category|categories:collections} +
    + + {lang code="tags"} +
    + {$c.collection_tags|tags:collections} + + + +
    + +
    + {$c.collection_description|description} +
    +
    + {assign var=rating value=$cbcollection->collection_rating($c.collection_id,'collection')} + + {if $Cbucket->configs.collection_rating} +
    + {show_video_rating rating=$c.rating ratings=$c.rated_by total='10' id=$c.collection_id type=collection} +
    + {/if} + + + +
    +
    {AD place=ad_728x90}
    +
    + {show_share_form id=$c.collection_id type=Collection} + {show_flag_form id=$c.collection_id type=Collection} + +
    +
    + + {if $myquery->is_commentable($c,'collection')} +
    +

    {lang code="comments"} ({$c.total_comments})

    +
    + +
    + +
    + +
    +
    + {else} +
    + {lang code='comm_disabled_for_collection'} +
    + + {/if} + +
    + + + {if $myquery->is_commentable($c,'collection')} +
    + {include file="$style_dir/blocks/comments/add_comment.html" id=$c.collection_id type='cl'} + {/if} + +
    {AD place=ad_300x250}
    +
    +
    diff --git a/upload/styles/cbv2new/layout/view_group.html b/upload/styles/cbv2new/layout/view_group.html new file mode 100644 index 00000000..3f605b92 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_group.html @@ -0,0 +1,120 @@ +{include file="$style_dir/blocks/group/group_left.html"} + +
    +
    {$group.group_name|htmlspecialchars_decode}
    +
    + +
    + {if $mode == "" || $mode == "main"} +
    {lang code="basic_info"}
    +
    +
    {lang code="vdo_desc"}
    +
    {$group.group_description}
    +
    +
    +
    {lang code="category"}
    +
    {$group.category|categories:group}
    +
    +
    +
    {lang code="tags"}
    +
    {$group.group_tags|tags:group}
    +
    +
    +
    {lang code="privacy"}
    +
    {$group.group_privacy|getGroupPrivacy}
    +
    +
    {lang code="Group Stats"}
    +
    +
    {lang code="Since"}
    +
    {$group.date_added|date_format:"%B %e, %Y"}
    +
    +
    +
    {lang code="total_mems"}
    +
    {$group.total_members|number_format} {lang code="members"}
    +
    +
    +
    {lang code="com_total_vids"}
    +
    {$group.total_videos|number_format} {lang code="videos"}
    +
    +
    +
    {lang code="total_topics"}
    +
    {$group.total_topics|number_format} {lang code="grp_topics_title"}
    +
    +
    +
    {lang code="viewed"}
    +
    {$group.total_views|number_format} {lang code="user_times"}
    +
    + {/if} + {if $mode=='invite_group'} +
    {lang code='grp_invite_grp_title'}
    + {if $friends} +
    + + + + + + + +
     Usernameviews
    + {foreach from=$friends item=friend} + {if userid()!=$friend.userid} + {assign var=user_detail value=$userquery->get_user_details($friend.userid)} + {else} + {assign var=user_detail value=$userquery->get_user_details($friend.contact_userid)} + {/if} + +
    + + + + + + + +
    {$user_detail.username}{$user_detail.username}{$user_detail.profile_hits|number_format}
    +
    + {/foreach} +
    +
    + {else} + No Contact + {/if} + {/if} + {if $mode == "view_members"} +
    {lang code="group"} {lang code="members"}
    + {section name=u_list loop=$users} + {include file="$style_dir/blocks/user.html" user=$users[u_list]} + {/section} + {/if} + + {if $mode == "view_videos"} +
    {lang code="group"} {lang code="videos"}
    + {section name=v_list loop=$videos} + {include file="$style_dir/blocks/video.html" video=$videos[v_list]} + {/section} + {/if} + + {if $mode == "view_topics"} +
    {lang code="group"} {lang code="grp_topics_title"} - {lang code="grp_add_new_topic"}
    +
    + {include file="$style_dir/blocks/group/add_topic.html"} +
    + {include file="$style_dir/blocks/group/group_topics.html" group=$group} + {/if} + + {if $mode == "view_report_form"} +
    {lang code="Report"} {lang code="group"}
    + {show_flag_form id=$group.group_id type=Group display="block"} + {/if} +
    +
    +
    + +{include file="$style_dir/blocks/group/group_right.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_item.html b/upload/styles/cbv2new/layout/view_item.html new file mode 100644 index 00000000..01493d40 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_item.html @@ -0,0 +1,46 @@ +
    + + +
    + {if $type !='videos'} + + + + +
    + {assign var=objctid value=$object.ci_id} + {assign var=collid value=$object.collection_id} +
  • + {assign var=preLink value=$cbphoto->collection->get_next_prev_item($objctid,$collid,'prev')} + Previous +
  • +
  • + {assign var=nextLink value=$cbphoto->collection->get_next_prev_item($objctid,$collid,'next')} + Next +
  • +
    + + + {/if} +
    +
    + {if $type == 'photos'} + {include file="$style_dir/view_photo.html" photo=$object user=$user} + {/if} + + {if $type == 'videos'} + {include file="$style_dir/watch_video.html" vdo=$object user=$user} + {/if} + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_page.html b/upload/styles/cbv2new/layout/view_page.html new file mode 100644 index 00000000..2c241ac3 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_page.html @@ -0,0 +1 @@ +
    {$page.page_content|page}
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_photo.html b/upload/styles/cbv2new/layout/view_photo.html new file mode 100644 index 00000000..921821de --- /dev/null +++ b/upload/styles/cbv2new/layout/view_photo.html @@ -0,0 +1,110 @@ + +{lang code='photo' assign='object_type'} + +
    +{assign var=json value=$photo.photo_details|json_decode} + + {ANCHOR place="video_bookmarks" data=$photo} +
    +
    +
    + {show_video_rating rating=$photo.rating ratings=$photo.rated_by total='10' id=$photo.photo_id type=photo} +
    + +
    +
    + {show_share_form id=$photo.photo_id type=Photo} + {show_flag_form id=$photo.photo_id type=Photo} + + +
    +
    +
    +

    {lang code='comments'}

    + +
    + + {if $myquery->is_commentable($photo,'p')} + {include file="$style_dir/blocks/comments/add_comment.html" id=$photo.photo_id type=p} + {else} +
    {lang code='Comments disabled for this photo'}
    + {/if} +
    +
    + +
    +
    + {$user.username}
     
    + + {lang code="videos"} | {lang code="favorites"} | {lang code='contacts'} + +
     
    + +
    + +
    +
    +
    {$photo.photo_title}
    +
    + {$photo.photo_description} +
    +
    {$photo.photo_tags|tags:photos}
    +
    +{AD place="ad_300x250"} +
    +{if $userquery->userid == $photo.userid} + Edit Photo +{/if} +{DownloadButtonP details=$photo class='LoadMoreButton' style='display:inline-block; *display:inline; margin-left:5px;' output='div'} +{get_photos assign=uphotos user=$photo.userid exclude=$photo.photo_id order=RAND() limit='5'} +{if $uphotos} +
    +
    More Photos From {$user.username}
    +
    +{section name=list loop=$uphotos} + {include file="$style_dir/blocks/photo.html" display_type="related_photos" photo=$uphotos[list]} +{/section} +
    +{/if} + +{get_photos assign=related collection=$photo.collection_id show_related=TRUE title=$photo.photo_title tags=$photo.photo_tags exclude=$photo.photo_id limit='5'} +{if $related} +
    +
    Related Photos
    +
    +{section name=list loop=$related} + {include file="$style_dir/blocks/photo.html" display_type="related_photos" photo=$related[list]} +{/section} +
    +{/if} +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/view_topic.html b/upload/styles/cbv2new/layout/view_topic.html new file mode 100644 index 00000000..1ddef694 --- /dev/null +++ b/upload/styles/cbv2new/layout/view_topic.html @@ -0,0 +1,47 @@ + +{lang code='topic' assign='object_type'} + +{include file="$style_dir/blocks/group/group_left.html"} + +
    +
    {$group.group_name}
    +
    + +
    + +
    +
    +
    {$topic.topic_title}
    + {assign var=topic_starter value=$userquery->get_user_details($topic.userid)} + {include file="$style_dir/blocks/user.html" user=$topic_starter block_type="topic_view"} +
    + {$topic.topic_post|description} +
    +
    {lang code="Added"}: {$topic.date_added|niceTime}
    +
    +
    + +
    +Re-load Posts +
    + +
    +
    +{include file="$style_dir/blocks/comments/add_comment.html" id=$topic.topic_id type=t} +
    +
    +
    +{include file="$style_dir/blocks/group/group_right.html"} \ No newline at end of file diff --git a/upload/styles/cbv2new/layout/watch_video.html b/upload/styles/cbv2new/layout/watch_video.html new file mode 100644 index 00000000..bc9a2df4 --- /dev/null +++ b/upload/styles/cbv2new/layout/watch_video.html @@ -0,0 +1,269 @@ + +{lang code='video' assign='object_type'} + + +{assign var=videos_items_columns value=func->config(videos_items_columns)} +{get_videos nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids show_related=yes title=$vdo.title tags=$vdo.tags} + +
    +
    {$vdo.title}
    + {if $userquery->perm_check('admin_access')=='yes'}
    {ANCHOR place=watch_admin_options data=$vdo}
    {/if} + + + {ANCHOR place="before_watch_player" data=$vdo } + + + {if has_hq($vdo)} + + + + + + {/if} +
    + + +
    + +
    + {FlashPlayer vdetails = $vdo} +
    + + + +
    +
    + {show_video_rating rating=$vdo.rating ratings=$vdo.rated_by total='10' id=$vdo.videoid type=video} +
    + + +
    + + + +
    + {show_share_form id=$vdo.videoid type=Video} + {show_flag_form id=$vdo.videoid type=Video} + + {show_playlist_form id=$vdo.videoid type=Video} +
    + + + +
    + + +
    + + +
    {lang code='subscribe'}
    +
    + +
    {ANCHOR place="video_bookmarks" data=$vdo} +
    + {lang code='uploaded_by_s' assign='uploaded_by_s'} + {$uploaded_by_s|sprintf:$vdo.username} — {$vdo.date_added|nicetime} +
    +
    +
      +
    • {lang code='views'} : {$vdo.views|number_format}
    • +
    • {lang code='duration'} : {$vdo.duration|SetTime}
    • +
    • {lang code='comments'} : {$vdo.comments_count|number_format}
    • +
    +
    +
    + +
    +
    + {$vdo.description|description|truncate:200}{if strlen($vdo.description)>200}{lang code='more'}{/if} +
    + + +
    + + +
    +
    {$vdo.tags|tags:videos}
    +
    Category : {$vdo.category|categories:video}
    +
    + +
    + +
    + + + + +
    +

    {lang code='comments'} ({$vdo.comments_count})

    + +
    + + + {if $myquery->is_commentable($vdo,'v')} + {include file="$style_dir/blocks/comments/add_comment.html" id=$vdo.videoid type=v} + {else} +
    {lang code='comm_disabled_for_vid'}
    + {/if} +
    +
    + +
    + + + + + +
    +
    {AD place=ad_300x250}
    + + + {if $Cbucket->configs.video_download==1 && $cbvid->downloadable($vdo)} {/if} + + {ANCHOR place="watch_video_right" data=$vdo} + + +{if $open_collection} + + {$c.collection_name} +
    + +
    + {assign var=objctid value=$vdo.ci_id} + {assign var=collid value=$vdo.collection_id} +
  • + {assign var=preLink value=$cbvid->collection->get_next_prev_item($objctid,$collid,'prev')} + Previous +
  • +
  • + {assign var=nextLink value=$cbvid->collection->get_next_prev_item($objctid,$collid,'next')} + Next +
  • +
    + +
    + {foreach from=$items item=item} + {if $bg=='fff'} + {assign var='bg' value='EFF5F8'} + {else} + {assign var='bg' value='fff'} + {/if} + + {include file="$style_dir/blocks/quicklist/video_block.html" video=$item selected=$vdo.videoid bg=$bg + videoLink=$cbphoto->photo_links($item,'view_item')} + + {if $vdo.videoid==$item.videoid} + {assign var='pre_lock' value='yes'} + {else} + {if !$pre_lock} + {videoLink vdetails=$item assign='pre_vid'} + {else} + {if !$next_lock} + {videoLink vdetails=$item assign='next_vid'} + {assign var='next_lock' value='yes'} + {/if} + {/if} + {/if} + + + {/foreach} +
    +
    + +{/if} + + +{if userid()} + {lang code='collections'} + +{/if} + + + + {include file="$style_dir/blocks/watch_video/playlist_box.html" selected=$vdo.videoid } + + + + + +{assign var=videos_items_columns value=func->config(videos_items_columns)} +{get_videos user=$vdo.userid limit=$videos_items_columns assign=user_vids exclude=$vdo.videoid} +{if $user_vids} + + +{lang code='more_from' assign='more_from'} +{$more_from|sprintf:$vdo.username} +
    +{section name=uvlist loop=$user_vids} + {include file="$style_dir/blocks/watch_video/video_box.html" video=$user_vids[uvlist]} +{/section} +
    +
    +{/if} + + + +{* get_videos category=$vid_cat nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids show_related=yes title=$vdo.title*} + + +{if $related_vids} +{lang code='related_videos'} + +{/if} + + +
    + +
    \ No newline at end of file diff --git a/upload/styles/cbv2new/template.xml b/upload/styles/cbv2new/template.xml new file mode 100644 index 00000000..18d0f0bb --- /dev/null +++ b/upload/styles/cbv2new/template.xml @@ -0,0 +1,9 @@ + + \ No newline at end of file diff --git a/upload/styles/cbv2new/theme/ie7.css b/upload/styles/cbv2new/theme/ie7.css new file mode 100644 index 00000000..1ea7860d --- /dev/null +++ b/upload/styles/cbv2new/theme/ie7.css @@ -0,0 +1,35 @@ +/* + Stylesheet to make Clipbucket V2 Compatible with Shitty IE7 + If you are reading this, I beg you please update your browser to Firefox or Chrome or Safari or Opera. If you still insists using on Internet Explorer, please use Internet Explorer 8 +*/ + +body,html{overflow-x:hidden} +.clearfix { display:inline-block; } +.foot_s_con { margin:10px auto 0; padding:0px; } +.foot_s_con input[type=submit] { background:url(../images/foot_search.png) top repeat-x; border:1px solid #555555; height:35px; padding:0px 6px; margin:1px 0px 0px; color:#FFF; font-family:Verdana,Tahoma,Arial,sans-serif; } + +.searchbar { background:url(../images/dot.gif); width:200px; border:none; margin:2px 0px 0px 0px; font-size:11px; color:#323232; font-family:Verdana,Tahoma,sans-serif; padding:6px 5px 7px; float:left; border-right:1px solid #ccc; display:inline; } +.searchbutton { background:url(../images/dot.gif); text-indent:-5000px; border:0px; width:64px; height:26px; line-height:18px; cursor:pointer; margin-top:2px; margin-left:5px; font-weight:bold; font-family:tahoma; font-size:11px; display:block; } +.s_type { background:url(../images/dot.gif) repeat; float:left; margin:7px 9px 0px 1px; padding:0px 0px; font-size:10px; font-family:Verdana,Arial,sans-serif; border:0px none; color:#323232; } + + + +#add_comment h2, #commentsContainer h2, .group_view h2 { font-size:14px; margin:0px; padding:0px } +#commentsContainer h2, .group_view h2 { margin:10px 0; } + +.search_field_button{background:url(../images/blocks.png); width:25px; height:22px; border:0px; background-position:-160px -180px; padding:0px; margin:0px; text-indent:-50000000px; float:left; cursor:pointer; outline:none; } + +.top_tabs { z-index:100; position:relative; } +.collectItemBox { display:inline; zoom:1; } +#selectedSearch { position:relative; width:82px; margin:0px; padding:9px 0px 5px 0px; text-align:center; font:bold 11px Tahoma; overflow:hidden; color:#000;} +#selectedSearch:hover { cursor:pointer; } +#searchSelectWrapper { padding:0px; margin:0px; position:relative; display:none;} +#searchSelectWrapper ul { position:absolute; background:#EEE; width:104%; top:1px; text-align:center; list-style:none; z-index:999999; padding:0px; margin:0px; border:1px solid #ccc; border-top:0px none; left:-1px; } +#searchSelectWrapper ul li { padding:5px 0px; list-style:none; margin:0px; color:#000; display:block; float:none; border:0px none; position:relative; border:1px solid transparent; margin:0 -1px -1px -1px; } +#searchSelectWrapper ul li a { margin:0px; font:normal 11px Tahoma; color:#000; text-transform:none; display:block; } +#searchSelectWrapper ul li:hover, #searchSelectWrapper ul li.selected { background:#333; border-color:#000; } +#searchSelectWrapper ul li:hover a, #searchSelectWrapper ul li.selected a { color:#FFF; } + +/* + I'm still at your mercy please update your browsers T_T PLEASE +*/ diff --git a/upload/styles/cbv2new/theme/main.css b/upload/styles/cbv2new/theme/main.css new file mode 100644 index 00000000..85caa887 --- /dev/null +++ b/upload/styles/cbv2new/theme/main.css @@ -0,0 +1,1017 @@ +/* +ClipBucket 'ClipBucket v2(New)' Template Theme by Fawaz Tahir +-------------------------------------------------------------- +Style name: ClipBucket v2(New) +-------------------------------------------------------------- +*/ + +@import url("view_channel.css"); +@import url("rating.css"); + +body,html {background-color:#fff; margin:0px; padding:0px; +font-family:Arial, Helvetica, sans-serif; color:#333; font-size:11px; +word-wrap:break-word;} + +#content{} +/* CLEARS */ +.clearfix { } +.clearfix:after{ content: "."; display:block; height:0; font-size:0; clear:both; visibility:hidden; } + +/* GENERAL CSS */ +a{ color:#0066cc; text-decoration:underline; outline:none; } +a:hover,a:active { /*color:#464646; */ color:#d54e21; outline:none; } +a[rel=sponsors] { padding:5px; background:#0099cc; border:1px solid transparent; } +a[rel=sponsors]:hover { background:#555; border:1px solid #232323; } +img, a img { border:0px none; } +.video_thumb { background:#FFF; border:1px solid #ccc; padding:1px; float:left; margin-right:5px; margin-bottom:5px; position:relative } +.video_thumb .duration{ position:absolute; right:1px; bottom:1px; background-color:#333; color:#fff; font-size:9px; display:inline; padding:1px} +.video_thumb:hover { border:1px solid #aaa; } +.vid_sp { padding:5px 0px; margin-bottom:10px; border-bottom:1px solid #ccc; clear:both; } + +.moveL { float:left; } +.moveR { float:right; } + +.heading{font-size:12px; color:#003; background-image:url(../images/nav_grads.png); background-position:-0px -195px; background-repeat:repeat-x; height:28px; display:block; color:#fff; line-height:28px; font-weight:bold; padding-left:5px; +} + + + +/** +Rating +*/ +.rating{width:50px;height:15px;} +.rating .stars_blank { background:url(../images/small_stars.png) ;background-repeat:repeat-x; background-position:bottom; height:12px; width:100%; } +.rating .stars_filled { background:url(../images/small_stars.png);background-repeat:repeat-x; background-position:top left; height:12px; float:left; } + +.viewCollectionRating { width:140px; height:28px; } +.viewCollectionRating .stars_blank { background:url(../images/big_stars.png) ;background-repeat:repeat-x; background-position:bottom; height:28px; width:100%; } +.viewCollectionRating .stars_filled { background:url(../images/big_stars.png);background-repeat:repeat-x; background-position:top left; height:28px; float:left; } + +.big_stars{width:140px; height:28px; position:relative} +.big_stars .stars_blank { background:url(../images/big_stars.png) ;background-repeat:repeat-x; background-position:bottom; height:28px; width:100%; } +.big_stars .stars_filled { background:url(../images/big_stars.png);background-repeat:repeat-x; background-position:top left; height:28px; float:left; } +.big_stars li:hover,.big_stars .stars_highlight{background:url(../images/big_stars.png);background-repeat:repeat-x; background-position:center left; height:28px; float:left;} + +.big_stars ul{position:absolute; top:0px; left:0px} +.big_stars ul, .big_stars ul li{margin:0px; padding:0px; list-style:none; float:left; } +.big_stars li{display:block; float:left; width:28px; cursor:pointer; text-indent:-50000px} +.big_stars li:hover{} + +/* CONTAINERS */ +.container_container{} +.container { width:1000px; margin:0px auto; padding:0px; position:relative; } +.topHead{background:#FFF !important} +.content_con { width:660px; margin:0px auto; padding:0px; float:left; margin-left:8px; } +.login_con { width:325px; float:right; margin:0px; padding:0px; position:absolute; top:0px; right:0px; z-index:999; } +.side_con { top repeat-x; width:305px; min-height:391px; margin:0px 8px 0px 0px; padding:5px; float:right; } +.feature_con { background:url(../images/simple_gradient.png) bottom repeat-x; border:2px solid #ccc; background-color:#fff; min-height:287px; padding-bottom:4px;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px;} +.search_con { float:right; margin:0px; padding:0px;margin-right:4px; margin-top:3px; } +.foot_s_con { width:500px; margin:10px auto 0px; padding:10px 0px 0px; } + +/* HEADER */ +#header { margin:0px 0px 15px; padding:1px 0px 0px 5px; } + +/* LOGO */ +.logo { background:url(../images/logo.png) left bottom no-repeat; float:left; margin:2px 2px 10px 3px; padding:0px; } + +/* LOGIN FORM */ +#user_login{ background:url(../images/log_button.png) top repeat-x; border:1px solid #ccc; padding:0px 8px; margin:0px auto; height:25px; line-height:25px; border-top:0px none; position:relative; bottom:1px; float:right; margin-right:15px; -moz-border-radius-bottomright:5px; -webkit-border-bottom-right-radius:5px; z-index:2000; overflow:hidden; } +#user_login a { display:block; text-decoration:none; text-align:center; text-shadow:1px 1px 1px #FFF; color:#555; text-transform:uppercase; } +#user_login a:hover { color:#aaa; } +.user_login { background:#f3f3f3; border:1px solid #ccc; border-top:0px none; margin-right:5px; padding:2px 5px; margin:0px; margin-right:10px; position:relative; z-index:1100;} +.user_login input[type=text], .user_login input[type=password] { padding:4px; font-size:11px; margin-bottom:2px; border:1px solid #ccc; background:#fff; color:#aaa; width:125px; font-family:Calibri,Tahoma,Verdana,Arial,sans-serif; } +.user_login input[type=text]:hover, .user_login input[type=password]:hover, +.user_login input[type=text]:focus, .user_login input[type=password]:focus { color:#555; border:1px solid #aaa; } +.user_login input[type=submit] { background:url(../images/login_button.png) top repeat-x; height:23px; border:1px solid #555; padding:0px; line-height:19px; font-size:10px; color:#FFF; text-align:center; width:50px; margin:5px 0px 5px 3px; } +.user_login input[type=submit]:hover { background:url(../images/login_button.png) bottom repeat-x; height:23px; cursor:pointer; border:1px solid #228bb3; } +.user_login input[type=submit]:active { background:#2ba0cd; } +.user_login input[type=checkbox] { width:10px; height:10px; vertical-align:middle; } +.user_login a.forget { background:url(../images/forget.png) top no-repeat; width:19px; height:19px; margin-top:3px; padding:0px; float:right; } +.user_login a.forget:hover { background:url(../images/forget.png) bottom no-repeat; } +span.remember { font-size:10px; } +.user_login .avatar { padding:1px; width:40px; height:40px; background:#fff; margin:0px 5px 2px 0px; border:1px solid #ccc; float:left; } +.user_login .avatar:hover { border:1px solid #aaa; } +.user_login .txt { font-size:11px; margin-bottom:8px; } +.user_login .txt a { color:#cc0000; text-decoration:none; padding:1px; } +.user_login .txt a:hover { background:#cc0000; color:#fff; } +.user_login .links { font-size:10px; } + +/* TOP TABS */ +.top_tabs { margin:0px; padding:0px; clear:both;overflow:hidden;} +.top_tabs ul { margin:0px; padding:0px; list-style:none; float:left; position:relative; left:50%; } +.top_tabs ul li { margin:0px; padding:0px; float:left; list-style:none; position:relative; right:50%; top:1px; } +.top_tabs ul li a { width:120px; display:block; padding:5px 0px; background:#62b3ff; text-align:center; text-decoration:none; color:#FFF; margin-right:0px; font-size:13px; background:url(../images/nav_grads.png); background-position:-0px -169px; background-repeat:repeat-x; border-right:1px solid #115683} +.top_tabs ul li a:hover { background:#0099cc; } +.top_tabs ul li.selected a { background:url(../images/nav_grads.png) -0px -7px; repeat-x; border:1px solid #006699; border-bottom:0px none; font-weight:bold} +.top_tabs ul li:first-child a{ -moz-border-radius-topleft:5px; -webkit-border-top-left-radius:5px;} +.top_tabs ul li:last-child a{ -moz-border-radius-topright:5px; -webkit-border-top-right-radius:5px; border-right:none} + +/* NAVIGATION */ +#navi_con { background:#14669c; padding:5px; margin:0px; border-top:1px solid #006699; } +.navi { background:url(../images/nav_grads.png) 0px -33px repeat-x; height:35px; border:1px solid #444; margin:auto; padding:0px; line-height:35px; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; width:1000px} +.navi ul { margin:0px; padding:0px; list-style:none; } +.navi ul li { margin:0px; padding:0px; float:left; padding-left:5px; list-style:none; font-size:11px; height:15px; margin-top:8px ; line-height:15px; padding-left:10px; color:#fff; border-left:1px solid #5f5f5f; padding-right:5px;border-right:1px solid #343434} +.navi ul li:first-child { margin-left:10px; border-left:none; padding-left:0px } +.navi ul li:last-child{border-right:none;} +.navi ul li a { color:#fff; text-decoration:none; font-family:tahoma; font-size:11px; font-weight:bold; text-transform:uppercase } +.navi ul li a:hover{color:#00bfff} +.nav_shadow { height:10px; margin:0px; margin-top:1px; padding:0px; } + +/* SEARCH */ +.s_bg { background:url(../images/search.png) no-repeat; width:359px; height:29px; margin:0px; padding:0px; -moz-border-radius:4px 0px 0px 4px; border:1px solid transparent; } +.searchbar { background:none; width:200px; border:none; margin:2px 0px 0px 0px; font-size:11px; color:#323232; font-family:Verdana,Tahoma,sans-serif; float:left; padding:6px 5px 7px; float:left; border-right:1px solid #ccc; } +.searchbutton { background:none; text-indent:-5000px; border:0px; width:59px; height:25px; line-height:18px; cursor:pointer; margin-top:2px; margin-left:5px; font-weight:bold; font-family:tahoma; font-size:11px; } +.s_type { background:url(../images/dot.gif) repeat; float:left; margin:7px 9px 0px 1px; padding:0px 0px; font-size:10px; font-family:Verdana,Arial,sans-serif; border:0px none; color:#323232; width:64px; } + + + + +/* FEATURED VIDEO SECTION */ +.feature_left { float:left; margin:0px; padding:0px; width:460px } +.feature_left .feature_heading{background-image:url(../images/nav_grads.png); background-position:0px -417px; height:24px; line-height:24px; color:#fff; text-shadow:0px 0px 8px #000; width:98%; display:block; margin-top:10px;border-radius:0px 8px 8px 0px; -moz-border-radius:0px 8px 8px 0px; -webkit-border-top-right-radius:8px; -webkit-border-bottom-right-radius:8px; padding-left:10px; font-weight:bold; text-transform:uppercase; font-family:Tahoma,Verdana,sans-serif; } +.feature_right { float:right; position:relative; width:28%; margin:4px 3px 0px 0px;font-size:10px; overflow:auto; height:360px;} +.feature_shadow { background:url(../images/shadows.png) 0px -31px no-repeat; width:660px; height:35px; margin:0px; padding:0px; } + + +/* FEATURED VIDEO HEADING */ +.feature_head { background:#88c5ff; width:100%; margin:0px 0px; padding:0px; height:20px; line-height:20px; position:relative; text-align:center; } +.feature_head h2 { font-size:18px; font-family:Tahoma; color:#fff; text-shadow:1px 1px 1px #44627f; } +.feature_head .left_side { background:url(../images/blocks.png) -277px -50px no-repeat; width:10px; height:57px; position:absolute; top:-6px; left:-6px; } +.feature_head .right_side { background:url(../images/blocks.png) -293px -56px no-repeat; width:9px; height:44px; position:absolute; right:-9px; } + +/* FEATURED VIDEO LEFT SIDE */ +.feature_vid { margin:3px auto; width:350px; padding:0px; font-weight:lighter; } +.feature_left .sp2 { background:url(line_sp2.png) repeat-x; height:2px; margin:6px 0px; padding:0px; } + +/* FEATURED VIDEO RIGHT SIDE */ +.feature_right ul { margin:0px; padding:0px; list-style:none; } +.feature_right ul li { padding:0px; margin:0px; margin-bottom:3px; color:#193f77; font-size:9px; } +.feature_right .sp { background:url(../images/line_sps.png) top repeat-x; margin:5px 0px; padding:0px; height:2px; } +.feature_right .details_block { float:left; width:50%; margin:0px; padding:0px; color:#999 } +.feature_right .title a{font-size:9px; font-weight:bold; text-decoration:none; color:#fff} +.feature_right .title { font-size:10px; clear:both; padding:0px; overflow:hidden} +.featured_vid_con{cursor:pointer; background:#FFF url(../images/nav_grads.png) -0px -260px; padding:5px; border-radius:5px 0px 0px 5px;-moz-border-radius:5px 0px 0px 5px; -webkit-border-top-left-radius:5px; -webkit-border-bottom-left-radius:5px; background-color:#FFF; margin:3px 0px 3px} +.featured_vid_con .video_thumb{border:0px; padding:0px; float:left; } +.featured_vid_con:hover{background-position:-0px -338px; } +.featured_video_details{width:440px; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; background-color:#fff; padding:5px; margin:5px} +.featured_video_player{width:440px; height:250px; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; background-color:#000; padding:5px; margin:5px} + +/* MAIN VIDEOS BLOCK */ +.tabs { background:url(../images/tabs_bg.png) top repeat-x; height:41px; margin:0px; line-height:41px; padding:0px; border:1px solid #ccc; border-radius:5px 5px 0px 0px ;-moz-border-radius:5px 5px 0px 0px ; -webkit-border-top-left-radius:5px; -webkit-border-top-right-radius:5px; } +.tabs ul { margin:0px; padding:0px; list-style:none; } +.tabs ul li { margin:0px; padding:0px 0px; list-style:none; float:left; } +.tabs ul li a { background:url(../images/tabs_sp.png) right repeat-y; padding:13px 12px 14px; text-decoration:none; } +.tabs ul li.selected { background:url(../images/tabs_bg.png) bottom repeat-x; } +.tabs ul li.selected a { color:#d36a4a; text-decoration:none; font-weight:bold } + +.main_vids { border:1px solid #ccc; border-top:0px none; background:url(../images/main_vid_bg.png) bottom repeat-x; padding:8px; } +.main_vid_shadow { background:url(../images/shadows.png) 0px -152px no-repeat; width:660px; height:6px; margin:0px; padding:0px; } + +/* CHANGE LIST STYLE */ +#style_change { border-bottom:1px solid #ccc; padding:0px 5px 8px; margin:0px 0px 15px; font-size:10px; color:#232323; } +#style_change a { text-decoration:none; } +#grid { float:right; background:url(../images/blocks.png) -325px -78px no-repeat; padding:1px; border:1px solid #ccc; width:11px; height:11px; } +#list { background:url(../images/blocks.png) -344px -78px no-repeat; padding:1px; border:1px solid #ccc; width:19px; height:11px; float:right; margin-right:10px; } +#grid:hover,#list:hover { cursor:pointer; border:1px solid #aaa; } + +/* SOME IMPORTANT CLASSES */ +.moveL { float:left; } +.moveR { float:right; } +.clear { clear:both; } + +/* NEW LISTING OF VIDEOS */ +#vid_wrap { maring:0px; padding:0px; } + +.grid_view { height:150px; padding:0px; width:114px; margin:0px 10px 12px 0px; float:left; } +.list_view { width:100%; border-bottom:1px solid #ccc; height:85px; } +.grid_view a, .list_view a { text-decoration:none; font-weight:bold; } +.grid_view h2.title, .list_view h2.title { font-size:11px; margin:2px 0px 3px 2px; padding:0px;} +.grid_view .vid_info, .list_view .vid_info { font-size:10px; margin:2px 2px; padding:0px; } + +.vid_thumb { margin:0px; background:#FFF; position:relative; } +.vid_thumb a img { width:110px; height:66px; border:1px solid #ccc; padding:1px;} +.vid_thumb:hover a img { border:1px solid #aaa; } +.vid_thumb .vid_time { position:absolute; bottom:2px; right:2px; padding:1px; background:#333; font-size:9px; color:#FFF;font-family:tahoma } + +.vid_info_wrap { width:100%; display:block; margin:0px; padding:0px; } + +.grid_view #desc { display:none; } +.grid_view span.info_list, .grid_view span.list_up_time { display:none; } +.grid_view span.list_commnets { display:none; } + +.list_view #desc { display:block; clear:both; font-size:11px; margin:2px 0px 3px 2px; text-align:left; } +.list_view span.info_list, .list_view span.list_up_time { display:inline; } +.list_view span.list_commnets { display:inline; } + +.list_view .vid_info_wrap { float:right; width:81%; } +.list_view h2.title { display:inline; float:left; } +.list_view .vid_thumb { float:left; } +.list_view .rating { float:right; } + +.vertical a,.horizantal a{text-decoration:none; font-weight:bold} + +/* VERTICAL LISTING STYLE */ + +.vertical { width:118px; margin:0px 6px 10px 0px; padding:0px 0px 10px; float:left; height:150px } + +.vertical .details_block { float:none; width:100%; } +.vertical .lvl1, .vertical .lvl2, .vertical .lvl3, .vertical .lvl4 { display:block; } + +.vertical .lvl1 .title { font-size:11px; } +.vertical .lvl1 .rating { margin-top:5px; width:50px; } +.vertical .lvl2 { display:none; } + +.vertical .lvl3 { font-size:10px; } +.vertical .lvl3 .views span { font-weight:lighter; } + + +.vertical .lvl4 { font-size:10px; } +.vertical .lvl5{display:none} + + +/* SIDEBAR INDEX */ +.box { background:#FFF; border:1px solid #b6e2fe; padding:2px; width:300px; margin:0px auto 10px; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px } + + +/* LOGIN/REGISTER BOX */ +.login { background:url(../images/main_box.png) repeat-x; height:92px; width:300px; position:relative; margin:auto} +.login_box_cont{border-radius:10px;-moz-border-radius:10px;-webkit-border-radius:10px;} +.login .login_title{font-size:12px; font-weight:bold; text-transform:uppercase; font-family:tahoma; color:#0099cc; margin:9px 0px 0px 91px; height:23px; line-height:23px; text-align:center} +.login .some_info{ margin-left:91px; font-size:10px; font-weight:bold; text-transform:uppercase; font-family:tahoma; color:#333; height:30px; padding-top:15px} + +.login .regist_link{width:147px; height:16px; background-image:url(../images/main_box.png); background-position:-0px -92px; position:absolute; bottom:7px; left:87px; text-align:center; line-height:16px} +.login .regist_link a{color:#FFF; text-transform:uppercase; text-decoration:none; font-size:10px; font-weight:bold} + + +.login .login_link{width:54px; height:16px; background-image:url(../images/main_box.png); background-position:-152px -92px; position:absolute; bottom:7px; left:239px; text-align:center; line-height:16px} +.login .login_link a{color:#0099cc; text-transform:uppercase; text-decoration:none; font-size:10px; font-weight:bold} + + +/* TOP USERS */ +.top_bg { background: url(../images/simple_gradient.png) repeat-x bottom; min-height:81px; background-color:#fff; border:1px solid #85a8c8; margin:0px; padding:0px 2px; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;-khtml-border-radius:5px } +.top_bg h2 { margin:5px 2px 8px; padding:0px; color:#21759b; font-size:18px; font-family:Tahoma; text-transform:uppercase; font-weight:bold; } +.top_user { background:url(../images/top_user.png) repeat-x; height:35px; border:1px solid #CCC; margin-bottom:15px; font-size:9px; padding:0px 8px; position:relative; background-color:#FFF; color:#666} +.top_user:hover{background-position:bottom} +.top_user a{font-size:12px; font-family:Arial, Helvetica, sans-serif; color:#333; text-decoration:none; font-weight:bold} +.top_user a:hover{color:#0099cc} +.avatar { width:30px; height:30px; padding:0px; margin:2px 5px 0px 20px; vertical-align:super; float:left; border:1px #ccc solid } +.top_user > .user_no { background:url(../images/blocks.png) -231px -56px no-repeat; width:19px; height:45px; position:absolute; top:-5px; left:5px; font-size:11px; color:#FFF; text-shadow:1px 1px 1px #6fa1b7; text-indent:4px; line-height:45px; } +.top_bg .utitle { margin-top:5px} +.top_bg .utitle a{display:block} + +/* FOOTER SEARCH */ +.search_footer { background:url(../images/search_footer.png) repeat-x; height:57px; margin:0px; padding:0px; clear:both; } +.advance { background:url(../images/blocks.png) left -123px no-repeat; width:33px; height:35px; text-indent:-9000px; float:left; margin:2px 6px 0px 0px; padding:0px; } +.foot_s_con form { margin:0px; padding:0px; display:inline; } +.foot_s_con input[type=text] { background:#fff; border:1px solid #CCC; width:280px; font-family:Verdana,Tahoma,Arial,sans-serif; color:#555; float:left; margin:0px 6px 0px 0px; padding:9px 12px; } +.foot_s_con input[type=text]:focus { border:1px solid #aaa; } +.foot_s_con input[type=submit] { background:url(../images/foot_search.png) top repeat-x; border:1px solid #555555; height:35px; padding:0px 18px; margin:1px 0px 0px; color:#FFF; font-family:Verdana,Tahoma,Arial,sans-serif; } +.foot_s_con input[type=submit]:hover { background:url(../images/foot_search.png) bottom repeat-x; border:1px solid #228bb3; cursor:pointer; } + +/* FOOTER */ +#footer { background:#333; padding:10px 0px; margin:0px; } +.footer_sp { background:url(../images/line_sps.png) bottom repeat-x; margin:12px 0px; padding:0px; clear:both; height:2px; } +.footer { padding:0px 8px; margin:5px 0px 0px; font-size:11px; color:#fff; font-weight:bold } +.footer ul { padding:0px; margin:0px; list-style:none; display:inline; float:right} +.footer ul li { margin:0px; margin-right:8px; padding:0px; float:left; list-style:none; border-left:1px solid #999; padding-left:9px} +.footer ul li:first-child{border-left:none} +.footer a { color:#eee; text-decoration:none; } +.footer a:hover { color:#06c; text-shadow:1px 1px 1px #000; } +.footer .footer_copyr{float:left; display:inherit} + +/* CHANGER LANGUAGE/TEMPLATE */ +.copyright { color:#fff; font-weight:bold; float:right; text-shadow:1px 1px 1px #555; font-size:10px; } +.changer { background:#0099cc; padding:0px 8px; margin:0px; position:relative; height:26px; line-height:24px; } +.changer select { font-size:11px; margin:4px 0px 0px; } +.ch_left { background:url(../images/blocks.png) -278px top no-repeat; width:9px; height:33px; margin:0px; padding:0px; position:absolute; left:-8px; top:0px; } +.ch_right { background:url(../images/blocks.png) -289px top no-repeat; width:9px; height:33px; position:absolute; right:-8px; top:0px; } +.ch_shadow { background:url(../images/shadows.png) top no-repeat; width:1000px; height:9px; margin:0px; padding:0px; } + +/* EXAMPLE ADS */ +.ads { background:#f3f3f3; width:300px; height:250px; text-align:center; line-height:250px; font-size:15px; border:1px solid #ccc; } +.ad { width:468px; height:60px; background:#f3f3f3; border:1px solid #ccc; margin:0px auto 25px; padding:0px; text-align:center; font-size:15px; } + + +/* My ACcount */ +.my_account_left{width:180px; float:left; } +.my_account_left ul{margin:0px; padding:0px; display:block;} +.my_account_left li{margin:0px; padding:0px; list-style:none; display:block; margin:5px; margin-left:0px} +.my_account_left .li{font-size:12px; font-weight:bold; display:block; margin-bottom:10px}.my_account_left .li .heading{ display:block; width:170px; background-image:url(../images/blocks.png); background-position:-0px -160px; background-repeat:no-repeat; height:20px; line-height:20px; padding-left:5px; color:#333; margin-left:5px; color:#fff; text-transform:none} +.my_account_left .li li{font-weight:normal; padding-left:5px; border-left:3px #ccc solid; margin-left:5px} +.my_account_left .li li:hover{border-left:3px #999 solid;} +.my_account_left .li a{display:block; text-decoration:none; font-family:tahoma; font-weight:bold; color:#333} +.my_account_left .li a:hover{color:#0066cc} +.account_box{float:right; width:780px;border-left:5px #999 solid; padding-left:10px; margin-right:10px} + +.account_option_box{display:block; width:200px; margin:10px; padding:10px;float:left; background-color:#EFF5F8; border-radius:5px; -moz-border-radius:5px;-webkit-border-radius:5px; height:150px;} +.account_option_box .its_title{font-size:13px; font-weight:bold;} +.account_option_box li{list-style:none; border-bottom:1px dotted #999; padding-bottom:2px; margin-bottom:2px} +.account_option_box ul{margin:0px; padding:0px; display:block; padding-left:15px} +.account_option_box a{text-decoration:none; font-size:14px} +.account_option_box a:hover{color:#009} + +.account_head_container{border-bottom:1px dotted #CCC; padding-bottom:10px} +.account_thumb{max-height:150px; max-width:150px;border:1px solid #999; padding:3px; display:inline-block;} +.account_thumb_container{margin-left:5px;display:inline-block; float:left; margin-right:10px} +.stats .account_stat{font-size:11px; font-family:tahoma; display:block;} +.stats{ width:300px; float:left} + +.account_head_right{float:right} +.pm_box{width:90px; height:70px; background-color:#EFF5F8; border-radius:5px; -moz-border-radius:5px;-webkit-border-radius:5px; display:block} +.pm_box .messages{font-size:10px; font-family:tahoma; font-weight:bold; text-transform:uppercase; color:#333; text-align:center; display:block; padding:6px} +.pm_box {text-align:center; font-size:25px; font-weight:bold} + + +.account_form fieldset{border:1px solid #ccc; border-radius:5px; -moz-border-radius:5px;-webkit-border-radius:5px; margin:10px} +.account_form legend{ text-transform:uppercase; font-family:Tahoma; font-weight:bold} +.account_form input, .account_form textarea, .account_form select{border:1px solid #ccc; width:300px; padding:3px;} +.account_form input[type="radio"],.account_form input[type="checkbox"] { display:inline; width:auto} +.account_form select{margin-bottom:10px} + +.account_field_block{ border-bottom:1px solid #CCC; margin:5px 0px 5px 0px; padding-bottom:0px; padding-top:5px} +.account_field_block:hover{background-color:#F5F5F5} +.account_field_block .account_field_label{width:200px; float:left} +.account_field_block .account_field{ float:left; width:400px; padding-left:10px; padding-bottom:10px} + +.avatar_bg label{margin-top:10px; display:block} + +.messages_container{max-height:200px; overflow:auto; padding-bottom:10px; border-bottom:1px dashed #999} + +.private_message_container{padding:10px; border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px; border:1px solid #CCC; margin-top:15px; } + +.unread_msg, .unread_msg a{font-weight:bold; font-family:tahoma;} +.read_msg, .read_msg a{font-weight:normal; font-family:tahoma;} + +/** + my account + */ +.account_table{border:1px solid #c2c2c2; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; background-image:url(../images/gradients.png); background-position:0px -36px; height:19px} +.account_table tr td{border-right:1px solid #c2c2c2; text-indent:10px; font-family:Tahoma; font-size:11px; text-transform:uppercase; font-weight:bold} +.account_table .last_td{border-right:0px} + +.account_vid_list{ margin:5px 0px 5px 0px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; } +.account_vid_list tr td{text-indent:10px; font-family:Tahoma; font-size:11px; text-transform:uppercase; font-weight:bold} +.account_vid_list .last_td{border-right:0px} +.acc_usr_video_thumb{border:1px solid #999; margin:1px; padding:1px; display:block; float:left; width:50px;} + +.search_field{background:url(../images/blocks.png); width:150px; height:22px; border:none; padding-left:8px; padding-top:6px; font-size:11px; font-family:tahoma; margin:0px; float:left; background-position:0px -180px} +.search_field_button{background:url(../images/blocks.png); width:25px; height:22px; border:0px; background-position:-160px -180px; padding:0px; margin:0px; text-indent:-50000000px; float:left; cursor:pointer; outline:none} + +/** + * icons */ +.arrow_pointing,.edit_icon,.delete_icon,.reply_icon{background-image:url(../images/icons.png); background-repeat:no-repeat; } +.reply_icon,.edit_icon,.delete_icon{height:15px; width:15px; } +.delete_icon{background-position:-0px -63px } +.edit_icon{background-position:-15px -63px } +.reply_icon{background-position:-30px -63px } + +.video_control{font-weight:normal; margin-left:10px; font-size:10px} +.arrow_pointing{background-position:-0px -78px; width:24px; height:14px;} + + + +/*** + BUTONS + ***/ + +.cbSubmitUpload,.cb_button,.cb_button_2,.small_button{background:url(../images/buttons.png)} + +.cbSubmitUpload,.cb_button,.cb_button_2{display:inline-block;height:31px; width:135px; color:#fff; line-height:31px; text-align:center; font-size:14px; font-weight:bold; border:none; font-family:Arial, Helvetica, sans-serif; cursor:pointer} +.cbSubmitUpload:hover,.cb_button:hover,.cb_button_2:hover{background-position:-0px -31px} +.cbSubmitUpload,.cb_button_2{font-size:12px} + +input[disabled].cbSubmitUpload{ background:#f2f2f2; cursor:default; color:#999; border:1px solid #ccc; font:normal 11px Tahoma;} + + + +.small_button{display:inline-block;height:21px; width:94px; color:#fff; text-align:center; font-size:11px; font-weight:bold; border:none; font-family:Arial, Helvetica, sans-serif; cursor:pointer; background-position:-0px -62px} +.small_button:hover{background-position:-0px -83px} +.non_button{line-height:21px} + +/** + * Categories + */ + +/*.category_list{display:block; width:180px; margin:0px 5px 5px 5px; float:left} + +.category_list .categories{padding:0px; background:#efefef;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px} +.categories ul{margin:0px; padding:0px} +.categories ul li{padding:0px; margin:0px; position:relative; } +.categories ul li{list-style:none; display:block; margin-bottom:6px;} +.categories ul li:last-child{border-bottom:none} +.categories .selected { background-color:#ccc; display:block;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px} +.categories ul a{font:bold 14px arial;color:#0066cc; text-decoration:none; display:block; padding:4px 15px; } +.categories ul.sub_categories { padding:0px; margin:0px 0px 0px 0px; background:white; } +.categories ul.sub_categories li { padding:1px; margin:0px; } +.categories ul.sub_categories li a { font:bold 11px Tahoma; }*/ + +.category_list { float:left; width:180px; margin:0px 5px 5px; } +.category_list .categories { background:#fff; overflow:visible; } +.categories ul, .categories li { padding:0px; list-style:none; overflow:visible; margin:0px} +.categories li { display:block; position:relative; padding:3px 0px} +.categories li a { display:block; font:bold 13px Arial; text-decoration:none; overflow:visible; color:#222} +.categories .selected, .categories ul.sub_categories .selected { color:#0066cc; } +.categories a:hover, .categories .selected > a, .categories ul.sub_categories .selected > a { color:#0066cc; } + +.categories ul.sub_categories { background:white; padding:0px 0px; border-bottom:1px solid #ddd; padding-left:5px} +ul.sub_categories ul.sub_categories{border:none} +.categories ul.sub_categories li { padding:3px 0px } +.categories ul.sub_categories a { font-size:12px; font-weight:normal; color:#333; padding-left:3px 5px} + +.categories ul.sub_categories ul.sub_categories a { padding:3px 10px; } + +.categories li:first-child.selected { -moz-border-radius:5px 5px 0 0; } +.categories li:last-child.selected { -moz-border-radius: 0 0 5px 5px } + +.categories ul.sub_categories li:first-child.selected { -moz-border-radius:0px; } +.categories ul.sub_categories li:last-child.selected { -moz-border-radius: 0px } + +.sort_cont,.cat_heading{border-bottom:3px #d4d4d4 solid; font-size:15px; font-weight:bold; font-family:Arial; display:block; padding-bottom:3px; margin-bottom:3px} +.time_cont{border-bottom:1px solid #CCC; margin-bottom:5px; padding:5px; font-size:10px} +.time_cont a{ font-size:10px; color:#666; text-decoration:none} +.time_cont .selected{font-weight:bold} + +.sort_cont ul{display:inline-block} +.sort_cont ul,.sort_cont ul li{margin:0px; padding:0px} +.sort_cont li{float:left; list-style:none; height:18px; line-height:18px;} +.sort_cont a{font-weight:bold; color:#000; padding:0px; margin:0px; height:15px; line-height:15px; text-decoration:none; display:block; padding:0px 5px; border-right:1px #CCC solid; margin-top:1px; color:#333} +.sort_cont li:last-child a{border:none} +.sort_cont .selected a, .sort_cont a:hover{color:#0066cc} +/** + * Ad Box + */ +.vert_add_box{display:block; width:180px; margin:0px 5px 5px 5px; float:left} + + + +/** + * Pagination Class + */ +.pagination +{ + height:23px; + width:99%; + margin:auto; + line-height:23px; + color:#000;font-weight:bold; font-size:12px; font-family:Arial, Helvetica, sans-serif; +} + + +.pagination a,.pagination .selected{ +-moz-border-radius:5px; +border-radius: 5px; +-webkit-border-radius: 5px; +display:inline-block; padding:0 3px; height:18px; line-height:18px; text-align:center; background-image:url(../images/nav_grads.png); background-position:-0px -223px; border:1px solid #CCC; text-decoration:none} + +.pagination .selected{ background-position:-0px -241px; color:#fff; border-color:#0066cc} + +/** + * Watch Video CSS + */ + +.vid_top_container{position:relative; margin-bottom:10px; padding-left:10px} +.hq_button_cont{position:absolute; left:620px; bottom:0px} +.watch_left{width:670px; float:left; padding:5px; padding-top:0px; } +.video_title{font-size:18px; font-weight:bold; font-family:arial} +.watch_right{width:310px; float:right; padding-left:5px; display:block} +.player_container{display:block; background-color:#ffffff; padding:8px} + +.video_actions_cont{margin-top:10px} + +.add_to_fav,.report_this,.share_this,.add_to_play,.photo_embed_code{height:20px; width:20px} +.add_to_fav{background-image:url(../images/icons/heart_small.png);} +.report_this{background-image:url(../images/icons/report_small.png);} +.share_this{background-image:url(../images/icons/share_small.png);} +.add_to_play{background-image:url(../images/icons/playlist_small.png); } +.photo_embed_code { background-image:url(../images/icons/embed_small.png);} + +.video_actions_cont .rating_container{ float:left} + +.video_actions_cont .actions{margin-top:10px; float:right} +.video_actions_cont .actions ul{margin-top:10px} +.video_actions_cont .actions ul, .video_actions_cont .actions ul li{margin:0px; padding:0px;} +.video_actions_cont .actions li{ display:block;list-style:none; height:20px; line-height:20px; display:block; float:left;} +.video_actions_cont .actions a{color:#333; font-weight:bold; font-size:14px; display:block; margin-right:18px; text-decoration:none} +.video_actions_cont .actions a:hover{text-decoration:underline} +.video_actions_cont .actions a img{margin-right:5px; float:left; border:none; } + +.watch_collect_item{margin:5px; margin-top:0px; border-bottom:1px solid #CCC; padding-bottom:5px} +.watch_collect_item a{font-size:12px; font-weight:bold; text-decoration:none} + +.playlist_item,.add_comment_box .input,.add_comment_box,.comment,.video_details,.form_container .form_result,.action_box{border-radius:10px;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px; background-color:#F0F0F0; padding:10px} +.action_box{ margin:5px 0px;} +.action_box .action_box_title{color:#333; font-size:16px;font-weight:bold; text-transform:uppercase; font-family:arial; border-bottom:1px solid #CCC} +.form_container{border-top:1px solid #fff; padding-top:10px; font-size:11px} +.form_container .form_left{width:100%} +.form_container form{ margin:0px; padding:0px} +.form_container label{ display:block; font-size:11px; font-weight:bold; color:#333;margin-bottom:5px;} +.form_container label .example{font-weight:normal; } +.form_container .left_text_area{width:98%; border:1px #CCC solid; padding:3px; margin-bottom:5px} +.form_container .form_result{border:1px solid #0099cc; margin:5px; padding:5px;} +.action_box .error{color:#ed0000} +.action_box .msg{color:#0099cc} +.action_box .cancel a{font-size:10px; font-weight:bold; color:#333; text-decoration:none; } +.form_container select{border:1px solid #999; padding:2px; margin:5px} + +.ajaxMessages {border-radius:6px;-moz-border-radius:6px;-khtml-border-radius:6px;-webkit-border-radius:10px; background:url(../images/simple_gradient.png) bottom repeat-x; padding:6px; font:bold 11px Tahoma; margin-bottom:10px; } +.ajaxMessages.msg { color:#0099cc; border:1px solid #0099cc; } +.ajaxMessages.err { color:#ed0000; border:1px solid #ed0000; } + +.video_details{background:#fff url(../images/watch_video_details_bg.png) repeat-x bottom; border:1px solid #eee; margin-top:10px;} +.video_details .vd_user_container{margin-right:10px; float:left; width:120px;} +.video_details .vd_details{float:right; display:block; width:510px; z-index:10; font-size:11px; color:#333;} +.video_details .vd_stats{background-color:#333;border-radius:5px;-moz-border-radius:5px;-khtml-border-radius:5px;-webkit-border-radius:5px; padding:5px; margin-bottom:10px; color:#fff} + +.vd_stats{ overflow:hidden; } +.video_details .vd_stats ul{position:relative; left:50%; float:left;} +.video_details .vd_stats ul{margin:0px; padding:0px; list-style:none} +.vd_stats li{float:left;display:block;font-size:11px;margin-right:15px;position:relative;right:50%; font-family:tahoma;padding:0px; list-style:none} +.vd_details .uploading_detail{padding:5px; padding-left:0px;} +.vd_details .uploading_detail a,.vd_details .uploading_detail{font-size:14px; font-family:arial; color:#333; cursor:pointer; font-weight:bold; text-decoration:none} +.vd_details .uploading_detail a:hover,.vd_details .uploading_detail:hover{color:#09c} + +.vd_details .tags_cats{border-top:1px solid #ccc; padding:5px; margin-top:10px} +.tags_cats .tags{background-image:url(../images/tag_blue.png); background-repeat:no-repeat; line-height:15px; padding-left:20px} +.tags_cats .tags a{text-decoration:none; font-weight:bold; font-size:10px } +.tags_cats .category{margin-top:5px;font-weight:bold; font-size:11px}.tags_cats .category a{text-decoration:none; font-weight:bold; font-size:11px } +.vd_user_container .account_thumb{max-height:160px; max-width:120px;} +.vd_user_container ul{margin:0px; padding:0px; margin-bottom:5px} +.vd_user_container ul li{list-style:none; display:block; padding:0px; margin:0px} +.vd_user_container a{text-decoration:none; font-size:11px; color:#333} +.vd_user_container a:hover{color:#0099cc} + +.comment{ background:#fff url(../images/watch_video_details_bg.png) repeat-x; background-position:bottom; min-height:60px; padding:5px; border:1px solid #eee; font-family:tahoma; font-size:11px; margin-bottom:10px; } +.comment .user_com_thumb{ float:inherit; max-width:60px; max-height:80px; border:2px solid #fff; margin:0px;} +.comment .user_com_thumb_con{ float:left; margin:0px; } +.comment .comm_other{float:right; width:89.5%; } +.comment .user_bar{background:url(../images/nav_grads.png) 0px -240px repeat-x; height:18px; line-height:18px; padding:0px 5px 0px 5px; width:auto; } +.comment .user_bar, .comment .user_bar a{color:#fff; font-size:11px; text-decoration:none;} +.comment .comment_cont{float:left; width:515px; padding:3px;} +.comment .comment_rating_cont{ float:right; width:45px; margin-top:10px} +.comment .comment_rating_cont .comment_rating{font-size:16px; font-weight:bold;font-family:arial; text-align:center; display:block} +.comment .thumb_down{background:url(../images/up_down.png) ; width:19px; height:16px; display:inline-block; text-indent:-50000px; margin-right:0px; cursor:pointer; background-position:-21px 1px} +.comment .thumb_down:hover{background-position:-21px -16px} +.topic_comments .comment .comm_other{float:right; width:93%; } +.topic_comments .comment .comment_cont{ width:auto; max-width:835px; } + +.add_comment_result .error{color:#ed0000; padding:3px; border:1px solid #ed0000; margin:3px 0px} +.no_comments{ display:block; padding:5px; font-size:13px; font-weight:bold; margin:5px; border:1px solid #8F8059; background-color:#FFF6DF } +h2.commentHead{ padding-left:30px; background-image:url(../images/icons/comments_small.png); background-repeat:no-repeat; margin-bottom:0px; padding-bottom:5px} + +.comment .thumb_up{background:url(../images/up_down.png) ; width:19px; height:16px; display:inline-block; text-indent:-50000px; margin-right:0px; cursor:pointer;background-position:-0px 1px} +.comment .thumb_up:hover{background-position:-0px -16px} +.desc_cont{} +.upper_quote{background-image:url(../images/icons.png); background-position:0px -125px; height:32px; width:34px; display:inline-block; } +.lower_quote{background-image:url(../images/icons.png); background-position:0px -161px; height:32px; width:34px; display:inline-block; } + +.add_comment_box{background-color:#f0f0f0} +.add_comment_box .input{ border:1px solid #CCC; background-image:url(../images/watch_video_details_bg.png); background-position:10px; padding:5px; width:400px; background-repeat:repeat-x} + +#collectionComments .comment .comm_other{width:86%; } + +.cb_warning,.cb_error,.cb_message{border-radius:10px;-moz-border-radius:10px;-khtml-border-radius:10px;-webkit-border-radius:10px; padding:5px; border:1px #0099cc solid; margin:5px;background-image:url(../images/watch_video_details_bg.png); background-position:10px} +.cb_warning ul,.cb_error ul,.cb_message ul{display:block; margin:0px; padding:0px; padding-left:10px;} +.cb_warning ul li,.cb_error ul li,.cb_message ul li{border-left:3px solid #ccc; list-style:none; padding-left:10px; cursor:pointer} +.cb_error ul li{ color:#ed0000} +.cb_message ul li{ color:#0099cc} +.cb_warning ul li {color:#0066cc;border-left:none} +.cb_error ul li:hover{border-color:#ed0000} +.cb_message ul li:hover{border-color:#0099cc} + +.watch_video_box{width:90px; margin:2px 4px 0px 4px; float:left; height:110px; overflow:hidden} +.watch_video_box{ color:#999; font-size:10px;} +.watch_video_box a{font-size:10px; text-decoration:none; font-weight:bold;} +.watch_video_box .watch_video_box_thumb{border:1px solid #999; padding:2px; display:inline-block; margin:auto; position:relative} +.watch_video_box_thumb .duration{background-color:#333; color:#fff; font-size:8px; padding:1px; position:absolute; right:2px; bottom:2px} + +.watch_vids_head,.watch_vids_head_closed{background-image:url(../images/watch_video_bars.png); width:270px; height:26px; background-repeat:no-repeat; display:block; padding-left:30px; line-height:26px; color:#fff; font-size:14px; color:#fff; font-weight:bold; margin-top:10px; cursor:pointer;background-position:0px -26px;} +.watch_vids_head_closed{ background-position:0px -0px; color:#0099cc} + +.watch_vids_cont{width:300px; overflow:hidden; padding-bottom:10px; margin-bottom:10px; border-bottom:1px solid #CCC; padding-top:10px} + +.playlist_item{padding:5px; margin:3px 0px 3px 0px; height:30px;} +.playlist_item .pl_num{ width:25px; text-align:center; float:left; line-height:30px; height:30px;font-size:10px; color:#666} +.playlist_item .pl_thumb{width:45px; height:27px; border:2px solid #999;float:left; margin-right:5px } +.playlist_item .pl_details{font-size:10px; width:160px; float:left; cursor:pointer} +.playlist_item .pl_details a{font-size:10px; color:#0099cc; text-decoration:none; font-weight:bold} +.playlist_item .pl_duration{font-size:10px; color:#666; float:left} +.playlist_item .pl_delete{font-size:10px; color:#666;float:right} + + +.videosharing{width:280px;} +.videosharing input{border:1px solid #999; color:#999; font-size:10px} + +.user_block_small{width:70px; height:80px; margin:3px; float:left; padding:5px; font-size:10px; border:1px solid #CCC} +.user_block_small a{font-size:11px; font-weight:bold} +.user_mid_thumb{width:60px; height:60px;display:inline; border:1px solid #999; padding:2px;} + +/** UPLOAD CSS **/ +.upload_left{width:675px; float:left; padding:0px 5px} +.upload_opt,.upload_left .upload_info{ background:#fff url(../images/simple_gradient.png) repeat-x bottom;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; padding:5px; border:1px solid #ccc;} +.upload_right{width:300px; float:right; margin-right:10px} +.upload_right .instructions{background:#fff url(../images/simple_gradient.png) repeat-x bottom; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; padding:5px; border:1px solid #f0f0f0; } + + +.upload_form{padding:0px; margin:0px;} +.upload_form fieldset{padding:5px; border:none; } +.upload_form fieldset .form_head{display:block; background-color:#0099cc; padding:3px; color:#fff; font-size:13px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; margin-bottom:10px} + +.upload_form .label{cursor:pointer; display:block; font-size:14px; text-transform:uppercase; font-family:Arial, Helvetica, sans-serif; font-weight:bold; margin-bottom:2px} +.upload_form input[type=text],.upload_form input[type=textfield],.upload_form textarea{border:1px solid #999; width:400px; resize:auto; } +.upload_form .field{margin-bottom:10px} +.upload_form .hint{font-size:11px} +.upload_form label{cursor:pointer} + +.more_button,.more_button_up {display:block; border-bottom:1px #CCC solid; border-top:1px #CCC solid; color:#999; background:#fff url(../images/nav_grads.png) no-repeat right -441px; padding:2px; height:13px } +.more_button_up{ background-position:right -458px} +.more_button_up a,.more_button a{color:#333; text-decoration:none; font-weight:bold; font-family:Arial, Helvetica, sans-serif;font-size:11px; display:block}.more_button_up a,.more_button a:hover{color:#0099cc} + +ul.upload_opts { list-style:none; margin:0px; padding:0px; } +ul.upload_opts li { padding:8px; margin:0px 10px; top:1px; position:relative; border:1px solid transparent; } +ul.upload_opts li:hover { color:#0099cc; cursor:pointer; } +ul.upload_opts li.selected { cursor:pointer; background:none; border:1px solid; border-color:#bbb #ccc #fff; color:#0099cc; -moz-border-radius:5px 5px 0px 0px; -webkit-border-top-left-radius:5px; -webkit-border-top-right-radius:5px; border-radius:5px 5px 0px 0px; } +.upload_opt{ margin-bottom:10px } +.upload_opt_head{ font-size:14px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; } +.swfupload{margin:0px; margin-bottom:-5px} + +.upload_form_div{ margin:3px; border:1px solid #EAEAEA; background:#FFF; padding:4px; } +.progressWrapper { padding:8px; background:#d6f1ff; border:1px solid #0099ff; margin-top:5px;} +.progressBarStatus { padding:2px; font-size:10px; font-weight:bold; } +.divStatus{font-weight:bold; } + +.upload_link_button ul{margin:0px; padding:0px; display:block; padding:4px; margin-top:10px} +.upload_link_button ul li{list-style:none; float:left; display:block; margin-right:10px} +.upload_link_button a{text-decoration:none} + +/** SIGNUP CSS **/ +.signup_left{width:480px; float:left; padding:5px; padding-left:15px} +.signup_right{width:480px; float:right;padding:5px; padding-right:15px} +.signup_container{background:#FFF url(../images/simple_gradient.png) repeat-x bottom;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; padding:5px; border:1px solid #f0f0f0;} +.signup_container .label{ width:170px; float:left; text-align:right; margin-right:5px} +.signup_container .input_container{float:left; width:220px; margin-bottom:5px} +.signup_container input[type=textfield],.signup_container input[type=text],.signup_container input[type=password]{width:220px; border:1px solid #999;} +.signup_container .hint{display:block; font-size:11px} + + +/** + * Channel and user + */ +.user_block{ display:block; width:120px; height:180px; float:left; margin:10px; font-size:10px} +.user_block_med{display:block; width:80px; height:130px; float:left; margin:0px 10px 10px 0px; font-size:10px} +.user_block .thumb_container,.user_block_med .thumb_container_medium{ width:120px; height:120px; overflow:hidden; border:1px solid #99ccff; padding:1px; display:inline-table; vertical-align:middle}.user_block_med .thumb_container_medium{width:80px; height:80px} +.user_thumb_normal{width:120px; height:120px} +.user_thumb_medium{width:80px; height:80px} +.prof_title a{font-weight:bold; text-decoration:none} + + + +/** + * QUCKLIST ICON + */ +.cross_icon,.check_icon,.add_icon{background-image:url(../images/icons/quicklist_small.png); height:14px; width:14px; background-repeat:no-repeat; cursor:pointer;position:absolute; left:2px; bottom:2px;} +.check_icon{background-image:url(../images/icons/quicklist_check_small.png); } +.cross_icon{ background-image:url(../images/icons/cross.png);position:relative; z-index:10} +.private_video{background-image:url(../images/private.png); width:110px; height:66px;position:absolute; top:2px; left:2px; border:0px} +.quicklist_box{bottom:0px; right:0px; padding:5px; background-color:#333; width:300px; color:#fff; position:fixed; z-index:1000; border-radius:5px 5px 0px 0px;-moz-border-radius:5px 5px 0px 0px;-webkit-border-radius:5px 5px 0px 0px} +.my_quicklist{max-height:325px; overflow:auto; padding-right:8px} +.quicklist_box_head{background-image:url(../images/simple_gradient.png); background-position:bottom; height:20px;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; padding:5px; line-height:20px; color:#333; font-size:11px; font-weight:bold} +.quicklist_box_head a{color:#0099cc; font-size:11px; font-weight:bold; text-decoration:none} + +/** HQ BUTTONS **/ +.hq_button_sel,.hq_button{background-image:url(../images/hq.png); width:49px; height:26px; background-position:top} +.hq_button_sel{background-position:bottom} + + +.simple_container{background:#fff url(../images/simple_gradient.png) bottom repeat-x; border:1px solid #999;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px; padding:5px; margin:5px} + +.cbform .label{width:150px; float:left; display:block; text-align:right; margin-right:10px} +.cbform input[type=textfield],.cbform input[type=text]{border:1px solid #999; margin:0px; width:200px; float:left; margin-bottom:6px; height:23px; line-height:23px; padding-top:0px; padding-bottom:0px;} + +.h2_inner_link,.h2_inner_link a{font-size:13px; font-family:Georgia, "Times New Roman", Times, serif; font-style:italic; text-decoration:none; color:#0099cc} + + + + +/** + * Groups CSS + */ +.group_view{width:980px; margin:auto;} +.group_top_cont{background:#FFF url(../images/simple_gradient.png) repeat-x bottom; border:1px solid #f0f0f0; padding:5px;border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px;} +.grp_left_column{float:left; width:150px; padding-right:10px} +.grp_right_column{float:right; width:800px;} +.group_thumb_cont{ margin:auto} +.group_thumb_cont img{border:#99ccff 2px solid;} +.group_title{display:block; background-color:#333; color:#fff;border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; padding:5px; font-size:14px; font-weight:bold; font-family:tahoma; margin-bottom:10px; padding-bottom:0px} + +.group_details{} +.group_option_container{} +.group_option_container ul{margin:0px; padding:0px} +.group_option_container .grp_opt_title{background-color:#0066cc; color:#fff; display:block; padding:4px; margin-top:5px} +.group_option_container ul li{list-style:none;} +.group_detail_tabs{} +.group_detail_tabs ul{padding:0px; margin:10px 0px 0px 0px;} +.group_detail_tabs ul li{float:left; display:inline-block; padding:2px 5px; list-style:none; text-align:center; margin:0px 5px; border-bottom:none; cursor:pointer; font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif} +.group_detail_tabs ul .selected{color:#09c; background:#fff} + +.grp_info .info_cont{margin-bottom:10px} +.grp_info .info_title{border-bottom:1px solid #abc0c7; height:10px; margin-bottom:10px} +.grp_info .info_title span{line-height:20px; font-family:Tahoma; color:#333; font-weight:bold; background-color:#FFF; padding-right:8px; display:inline} +.info_cont span{display:block; margin-bottom:5px; cursor:pointer} +.info_cont span:hover{color:#06c} +.info_cont span span:first-child{width:100px; float:left; color:#666} +.info_cont span span:last-child{width:500px; float:left; color:#333} +.info_cont span .grp_url{border:1px solid #999; padding:0px; color:#999; width:300px} + +.group_info span{display:block} + +.topic_table_head{background:#FFF url(../images/simple_gradient.png) repeat-x bottom; border:1px solid #f0f0f0; font-weight:bold} +.topic_table td, .topic_table_head td{padding:4px 2px; color:#333; font-family:Tahoma;} +.topic_table:nth-child(2n+1){background-color:#f7f7f7} + +.topic_title{font-weight:bold; display:block; font-family:Tahoma, Geneva, sans-serif; border-bottom:1px solid #aaa; font-size:13px; padding-bottom:5px; margin-bottom:5px;} +.topic_title a{font-weight:bold; display:block; color:#333; text-decoration:none} +.topic_title a:hover{color:#06c} + +.add_topic{padding:5px; height:18px; line-height:16px; display:inline-block; border-radius:3px; -moz-border-radius:3px; -webkit-border-radius:3px; background-color:#E6F0FF; margin-bottom:5px; cursor:pointer;font-weight:bold;} +.add_topic:hover{color:#06c} +.add_topic img{display:inline; float:left; margin-right:5px 0px; } + +.add_topic_container{margin:auto;background:#FFF url(../images/simple_gradient.png) repeat-x bottom; border:1px solid #ccc; padding:5px; margin-bottom:10px} + +.topic_form .label{ display:block; font-size:12px; font-weight:bold; font-family:tahoma} +.topic_form input[type=text],.topic_form textarea,.topic_form input[type=select]{border:1px solid #999; padding:3px; margin-bottom:10px} +.topic_icon_cont{padding:3px} +.topic_icon_cont fieldset{margin:0px; border:1px solid #999;border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px;} +.topic_icon_cont label{display:block; width:70px; text-align:center; float:left; margin-bottom:5px} + +.topic_container{margin-top:10px} +.topic_detail_cont{float:right; width:890px} +.topic_detail_cont .topic_title{font-size:14px; font-weight:bold; line-height:32px; border-bottom:1px solid #dedcdc} +.topic_detail_cont .topic_title img{ margin-right:10px} +.topic_detail_cont .topic_title .date{font-size:11px; font-weight:normal; color:#999} + +.topic_post{ border-bottom:1px dashed #b9b9b9 ; padding-bottom:5px; margin-bottom:5px} +.topic_post .topic_post_user{float:left; width:75px} +.topic_post .topic_post_cont{float:left} +.topic_post:last-child{border-bottom:none} +.topic_post .topic_poster{display:block; color:#999} +.topic_post .topic_poster a{font-weight:bold; font-family:tahoma; text-decoration:none} +.topic_content { font:normal 11px Tahoma; color:#464646; } + +.manage_contacts_tbl_head{border:1px solid #c2c2c2; border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px; background-image:url(../images/gradients.png); background-position:0px -36px; height:19px} + +.manage_contacts_tbl{border-bottom:1px solid #999;} +.manage_contacts_tbl:nth-child(2n+1){background-color:#F5F5F5} + +.manage_contacts_tbl_head td{ padding-left:3px; font-weight:bold} +.manage_contacts_tbl_head td:nth-child(2),.manage_contacts_tbl_head td:nth-child(3){border-right:1px solid #c2c2c2;} +.manage_contacts_tbl_head td:last-child{border-right:none} + +.manage_contacts_tbl td{padding-left:3px; } + + +.grp_manage_links li, .cb_fb_style_button{background:url(../images/nav_grads.png) -0px -223px repeat-x; height:18px; line-height:18px; display:inline-block; padding:0px 5px; border:1px solid #999} +.grp_manage_links li a,.cb_fb_style_button,.cb_fb_style_button a{ color:#333;font-weight:bold; font-family:tahoma; font-size:11px; text-decoration:none} +.cb_pending{color:#333; font-style:italic; } + +.grp_manage_links li{border-right:none} +.grp_manage_links li:last-child{border-right:1px solid #999} + +.grp_manage_links ul{display:inline-block; float:right; padding:0px; margin:0x;} +.grp_manage_links li{float:left;} + + +/** + * Groups Block + */ +.group_block{float:left; width:45%; height:80px; margin:0px 20px 10px 0px; padding:5px} +.group_block:hover{background-color:#EEE} +.group_block:nth-child(2n){margin-right:0px; margin-left:15px} +.group_block .group_thumb{max-width:110px; max-height:80px; border:1px solid #333; padding:1px; display:block; float:left; margin-right:10px} +.group_block,.group_block a{font-size:10px; font-family:tahoma } +.group_block span{display:block;} +.group_block .group_name,.group_block .group_name a{font-size:12px; text-decoration:none} + +.search_type{display:block; float:left; width:31%; border-right:1px dotted #0099cc; padding-right:10px; margin-right:10px; height:100%; overflow:visible; position:relative} +.search_type:nth-child(3){border-right:none; margin-right:0px} +.search_type .label{display:block; font-size:11px; font:tahoma; font-weight:bold} +.search_type div{margin-bottom:10px} +.search_type input[type='textfied'],.search_type input[type='text'],.search_type select{width:200px; border:1px solid #999} + +.quick_search .title{font-size:15px; font-weight:bold} +.quick_search input[type=text],.quick_search select{width:200px; border:1px solid #939393; font-size:11px; padding:2px} + + + +.admin_bar{background-color:#1E1E1E; padding:5px; color:#fff; z-index:3000; position:relative; } +.admin_bar a{color:#53baff; font-weight:bold; text-decoration:none} + +.lang_selector{width:130px; border:none; padding:1px;} + +.spam{color:#999; font-family:verdana; font-size:11px; font-weight:bold; border-top:1px solid #999; border-bottom:1px solid #999; padding:2px 0px; margin:5px 0px 10px 0px} + +.contact_form label{font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; color:#333; display:inline-block; width:150px; text-align:right; vertical-align:top; padding-right:15px} +.contact_form input[type=text],.contact_form textarea{border:1px solid #999; padding:2px; font-size:14px; width:300px} + +.subsription a{text-decoration:none; font-size:14px; font-family:Arial, Helvetica, sans-serif; display:block; border-bottom:1px solid #CCC; padding-bottom:5px; margin-bottom:5px; color:#06c; font-weight:bold} + + +.remote_main_bar +{ + width:100%; + height:20px; + background-image:url(../images/uploading_bar.png); + border-width:0px 1px 0px 1px; border-color:#dedede; border-style:solid; +} +#rempteUploadFormDiv{padding-right:10px;} +.remote_prog_bar +{ + height:20px; + background-image:url(../images/uploading_bar.png); + background-position:-0px -20px; + text-align:center; + font:normal 13px "Arial Black", Gadget, sans-serif; + color:#fff; + line-height:20px; + width:0px +} + +.remoteDownloadStatus{ font-weight:bold; display:none } +#remote_upload_div .remoteUrlInput {width:100%; border-style:solid; border-color:#dedede; border-width:1px 1px 0px 1px; height:20px; color:#999999 } + +/* COLLECTION */ +.collect_grid { position:relative; } +.obj_title { width:110px; display:inline-block; } +.obj_title a { text-decoration:none; } + +.collectionTable { border-collapse:collapse; border-spacing:0px; width:100%; } +#collectionItemsList { } +.collectItemBox { vertical-align:middle; width:19%; display:inline-block; text-align:center; padding:10px 2px; } +a.CollectThumb { border:1px solid #ccc; display:inline-block; background:#FFF; } +.collect_grid img { display:block; margin:3px; } + +/* PHOTOS */ +.photoBox { background:url(../images/simple_gradient.png) repeat-x bottom; border:1px solid #ccc; margin-bottom:10px; border-radius:4px; -webkit-border-radius:4px; -moz-border-radius:4px; } +.photoBox .OptionalSettings { background:#f3f3f3; border:solid #ccc; border-width:1px 0px 0px; display:block;} +.photoBox .Heading a { padding:5px; display:block; border-bottom:1px solid #ccc; font:bold 11px Tahoma; text-decoration:none; } +.photoDetailsBox { padding:5px; } +.photoDetailsBox .field { margin-bottom:5px; } +.photoDetailsBox .field .label { font:bold 11px Tahoma; padding-top:6px; width:125px; display:inline-block; } +.photoDetailsBox input[type=text], .photoDetailsBox textarea, .photoDetailsBox select { font:normal 11px Tahoma; padding:4px; width:200px; } +.photoDetailsBox textarea { width:202px; height:50px; } +.photoDetailsBox select { width:212px; } +.photoDetailsBox .hint { color:#666; font:normal 10px Tahoma; float:right; } +.photoThumbBox { padding:1px; background:#FFF; border:1px solid #aaa; } +.OptionalBox { padding:5px; } +.PhotoHeading { margin:5px 0px; padding-bottom:5px; border-bottom:1px solid #ccc; font:bold 11px Tahoma; } +.PhotoHeading.hover:hover { cursor:pointer; } +.relatedPhotos { clear:both; margin-bottom:10px; } +.photoTitle { font:bold 11px Tahoma; } +.photoTitle a { text-decoration:none; } +.photoInfo { font:normal 10px Tahoma; color:#666; } +.photo_block { padding:0; width:114px; display:inline-block; vertical-align:middle; margin:0 10px 12px 0; *display:inline; } + +/* VIEW ITEM */ +.borderLine { border-bottom:1px solid #ccc; padding:5px 0px 0px; margin:0 0 5px; } +.NextPrevButtons { width:100%; margin-bottom:5px; } +.NextPrevButtons li { list-style:none; width:49%; } +.NextPrevButtons li a { font:bold 11px Tahoma, Geneva, sans-serif; text-decoration:none; } +.NextPrevButtons li a { display:block; text-align:center; padding:8px 0px; border:1px solid #ccc; background:url(../images/simple_gradient.png) repeat-x bottom; color:#000;} +.NextPrevButtons li a:hover { color:#FFF; background:#EEE url(../images/nav_grads.png) left top repeat-x; border:1px solid #053a5c } + +.LoadMoreButton { font:bold 11px Tahoma, Geneva, sans-serif; background:url(../images/simple_gradient.png) repeat-x bottom; border:1px solid #ccc; padding:6px; margin-top:5px; -moz-border-radius:4px; -webkit-border-radius:4px; border-radius:4px; } +.LoadMoreButton:hover { color:#FFF; background:#115582 url(../images/nav_grads.png) left top repeat-x; border:1px solid #053a5c; cursor:pointer; } +.LoadMoreButton:active { background:#115582; } +.LoadMoreButton[disabled], .LoadMoreButton[disabled]:hover, .LoadMoreButton[disabled]:active { background:#EEE; border:1px solid #ccc; cursor:default; color:#7b7b7b; } + +.CollectionResult { background:#FFF url(../images/simple_gradient.png) bottom repeat-x; border:1px solid #aaa; margin:8px 8px 0px; padding:5px; font:bold 11px Tahoma; color:#666; -moz-border-radius:5px; -webkit-border-radius:5px; border-radius:5px; } + +.CollectionResult .error { color:#ed0000; } +.CollectionResult .msg { color:#0099cc; } + +.PhotoRatingStats { list-style:none; float:left; margin-right: 15px; } + +.collectionComments input[type=text], .collectionComments textarea.input { width:95% } +.CollectionResult .msg { color:#0099cc; } + +.uploadErrorDiv, .uploadSuccessDiv{padding:2px 5px 5px 20px; background:url(../images/ok.png) no-repeat 0px 0px;} +.uploadErrorMsg, .uploadSuccessMsg{font-size:14px; font-weight:bold; color:#7fa534; display:inline-block;height:15px; vertical-align:middle} +.uploadErrorDiv{ background:url(../images/error.png) no-repeat 0px 0px;} +.uploadErrorMsg{color:#ed0000} + +.PhotoUploaderWrapper { border:1px solid #CCC; width:100%; background-color:#EEE; display:inline-block; padding:15px 0px; text-align:center; } + + +.updatedUpload { float:right; background:url(../images/upload_bg.png) top repeat-x; position:relative; top:-1px; height:25px; padding:0px 8px; border:solid #090909; margin:0 0px 0 0; border-width:0 1px 1px; display:block; text-decoration:none; text-align:center; color:#555; line-height:25px; overflow:visible; -moz-border-radius-bottomleft:5px; -webkit-border-bottom-left-radius:5px; z-index:1000; } +.updatedUpload a { display:inline-block; color:#fff; text-decoration:none; font-weight:bold; margin:0px 5px } +.updatedUpload a:hover{color:#53baff} + +#selectedSearch { position:relative; width:82px; margin:0px; padding:9px 0 5px 0px; text-align:center; font:bold 11px Tahoma; overflow:hidden; color:#000; } +#selectedSearch:hover { cursor:pointer; } +#searchSelectWrapper { padding:0px; margin:0px; position:relative; display:none;} +#searchSelectWrapper ul { position:absolute; background:#EEE; width:104%; top:1px; text-align:center; list-style:none; z-index:999999; padding:0px; margin:0px; border:1px solid #ccc; border-top:0px none; left:-1px; } +#searchSelectWrapper ul li { padding:5px 0px; list-style:none; margin:0px; color:#000; display:block; float:none; border:0px none; position:relative; border:1px solid transparent; margin:0 -1px -1px -1px; } +#searchSelectWrapper ul li a { margin:0px; font:normal 11px Tahoma; color:#000; text-transform:none; display:block; } +#searchSelectWrapper ul li:hover, #searchSelectWrapper ul li.selected { background:#333; border-color:#000; } +#searchSelectWrapper ul li:hover a, #searchSelectWrapper ul li.selected a { color:#FFF; } + +.CategoryToggler { position:absolute; width:14px; height:14px; right:1px; top:4px; } +.CategoryToggler:hover { cursor:pointer; } +.CategoryToggler.none { background:url(../images/down.png) } +.CategoryToggler.block { background:url(../images/up.png) } + +.channelFeatureBox { padding:6px 0px; } +.itemListing { display:inline-block; margin:0px; padding:0px; width:152px; overflow:hidden; min-height:250px; } +.listHeading { font:bold 11px Tahoma; text-align:center; padding:4px 0px; color:#464646; border-top:1px solid #ccc; margin-bottom:-1px; background:#f3f3f3} +.itemBox { padding:4px 0px; border:solid transparent; border-width:1px; margin:0 0 0px 0; } +.itemBox:hover { cursor:pointer; background:#f3f3f3; border-color:#ccc; } +.itemBox.selected { background:#006fb7; border-color:#053a5c; -moz-box-shadow: 0 0 4px 0px #000; -webkit-box-shadow: 0 0 4px 0px #000; box-shadow: 0 0 4px 0px #000; } +.viewItemBox { display:inline-block; *display:inline; margin:0px; padding:0px;width:375px; } +.viewingArea { padding:0px 15px; } +.itemTitle { text-align:center; font:bold 11px Tahoma; text-transform:uppercase; } + +.channelBox { padding:10px 6px; border-bottom:1px solid #ccc; } +.channelHeading { font:bold 14px Arial; margin-bottom:4px; } + +.carouselButton, .channelBar { border:solid #ccc; border-width:1px; width:100%; margin:0px 0px 0px 0px; font:bold 11px Tahoma; text-align:center; padding:2px 0px; background:url(../images/simple_gradient.png) repeat-x bottom; } + +.carouselButton:hover { background:#115582 url(../images/nav_grads.png) left top repeat-x; color:#FFF; border-color:#053a5c; cursor:pointer; } +.carouselButton:active { background:#0470b7; outline:none; } + +.channelBar { border-width:0 0 1px; margin:0 0 10px; width:100%; padding:0px; } +.channelBar li { float:left; list-style:none; display:block; } +.channelBar li a { font-weight:normal; padding:6px 10px; display:block; border-right:1px solid #ccc; border-left:1px solid #FFF; text-decoration:none; } +.channelBar li a.selected { font-weight:bold; } +.channelFieldset { border:0px none; padding-left:0px; padding-right:0px; } +.channelLegend { padding:4px 6px; background:#eee; font:bold 11px Tahoma; color:#464646; margin-bottom:5px; width:98%; border-top:1px solid #aaa; cursor:default; } +.channelRow { margin-bottom:10px; padding:0px 6px; } +.channelLabel { display:inline-block; width:18%; font:bold 11px Tahoma; color:#888; vertical-align:top; text-transform:capitalize; } +.channelDetail { display:inline-block; font:normal 11px Tahoma; width:80%; } +.channelInnerPadding { padding:0px 6px; } +.moreThings { clear:both; display:block; font:bold 11px Arial; margin-top:3px; } + +.watchMainWindow{border:#001853; background-color:#0066cc; font-weight:bold; padding:3px; margin-top:5px} +.watchMainWindow a{color:#fff; text-decoration:none; font-weight:bold} +.watchMainWindow a:hover{text-decoration:underline} + +/** + * View Channel + */ + + +.channel_action_links{display:block; text-align:left; margin:0px; padding:0px;line-height:normal} +.channel_action_links a{ line-height:normal; text-decoration:none; font-weight:bold; font-size:11px; font-family:tahoma } +.channel_action_links li{list-style:none;line-height:normal; margin:1px 0px} + +.viewChannelProfileThumb{background-color:#eaeaea; margin-bottom:2px; padding:5px} +.channelHeading a{text-decoration:none} +.viewChannelProfileThumb_outline{border:1px solid #eaeaea; padding:3px} + +.accntSettingHeadarrowup, .accntSettingHead{font-size:14px; font-weight:bold; background:url(../images/down.png) right no-repeat; display:block; margin:5px auto; padding:5px} +.accntSettingHeadarrowup{background-image:url(../images/up.png); !important} +.accntSettingHead:hover{background-color:#ECF8FD; cursor:pointer} + +.accountForm legend{background: #EEEEEE;border-top: 1px solid #AAAAAA; color: #464646; font: bold 11px Tahoma; padding: 4px 6px; width: 98%;} +.accountForm fieldset{border:none; !important} + +.channel_title{font-size:13px; font-weight:bold; margin-bottom:3px} +.channelCounts{font-size:16px; font-weight:bold; text-align:center;} +.channelBox{padding:0px 5px 5px 5px; background-color:#fff} + +/* NEW GROUP LAYOUT */ +.groupLeftSide { width:160px; float:left; padding:0 0px; } +.groupLeftSide .channelLegend, .groupContent .channelLegend, .groupRightSide .channelLegend { width:auto; } +.groupContent { width:588px; float:left; padding:0 0px; border:solid #aaa; border-width:0 1px; min-height:500px; height:500px; height:auto !important; } +.groupRightSide { width:250px; float:right; padding:0px 0px; } +.groupThumb { padding:0px 0px; margin-bottom:9px;} +.groupThumbBG { display:inline-block;padding:2px; background:#FFF; border:1px solid #ccc; margin:0px auto; } +.groupDropShadow { -moz-box-shadow:0 1px 0 rgba(0,0,0,0.1); -webkit-box-shadow:0 1px 0 rgba(0,0,0,0.1); box-shadow:0 1px 0 rgba(0,0,0,0.1); } +.groupTitle { background:#F0F2F7; border:solid #aaa; border-width:1px 0px; padding:8px; font:bold 14px Arial; } +.groupSep { background:#f3f3f3; text-align:center; margin-bottom:8px; } +.SepText { font:bold 11px 'Tahoma', Geneva, sans-serif; color:#787878; background:white; padding:3px 5px; text-transform:uppercase } +.groupsBar { margin:0px; padding:0px; list-style:none; padding:8px 0px; border-bottom:1px solid #ccc; margin-bottom:10px; } +.groupsBar li { font:bold 11px Tahoma; text-decoration:none; display:inline-block; margin-right:10px; margin-left:10px; } +.groupsBar li a { color:#00769d; text-decoration:none; vertical-align:middle; } +.groupsBar li.selected a { color:#232323; } +.topicRow { border-bottom:1px solid #ccc; padding:5px 5px; list-style:none; } +.topicStarter { margin:0px; padding:0px; text-transform:capitalize; text-decoration:none; font:bold 14px Arial; margin-bottom:4px; } +.topicStarter a { text-decoration:none; } +.topicTitle { font-size:11px; font-family:Tahoma; padding:0px; margin:0px; } +.topicTitle a { text-decoration:none; } +.topicStarterAvatar { padding:1px; border:1px solid #ccc; } +.topicStarterAvatarBG { display:block; text-indent:-9000px; } +.topicStarterAvatarBG a { display:block; height:100%;} +.topicPreview { font:normal 10px Tahoma; color:#787878; } +.topicPreviewContainer { padding:3px 5px 3px 5px; border-left:3px solid #eee; margin-bottom:6px; } +/* ICONS */ +.ballonBox, .camCorder, .blackUser, .blueDoc, .redShield, .ballonSmall { width:16px; height:16px; vertical-align:middle; padding-right:2px; } +.ballonBox { background:url(../images/icons/balloons-box.png) no-repeat } +.camCorder { background:url(../images/icons/camcorder.png) no-repeat } +.blackUser { background:url(../images/icons/black-user.png) no-repeat } +.blueDoc { background:url(../images/icons/blue-document.png) no-repeat } +.redShield { background:url(../images/icons/shield.png) no-repeat; } +.ballonSmall { background:url(../images/icons/balloon-small.png) no-repeat; } + +.play_now a{display:inline-block; padding:2px; text-decoration:none; float:right; margin:4px; background-color:#333; color:#fff; padding:5px; border:1px solid #000;border-radius:5px;-webkit-border-radius:5px;-moz-border-radius:5px; cursor:pointer; } + +.topic_comments .comm_other{width:88% !important} \ No newline at end of file diff --git a/upload/styles/cbv2new/theme/rating.css b/upload/styles/cbv2new/theme/rating.css new file mode 100644 index 00000000..02706cf3 --- /dev/null +++ b/upload/styles/cbv2new/theme/rating.css @@ -0,0 +1,107 @@ +/* $Id: rating_style.css 235 2009-08-25 12:39:17Z fwhite $ */ +.rating_container{width:140px; border-right:1px solid #CCC; height:40px; padding-right:10px} +.rating_container #rating_result_container{font-size:10px; font-weight:bold; color:#333} +.rating_container #rating_result_container .error{ color:#ed0000;} +.rating_container #rating_result_container .msg{ color:#0099cc;} + +.big_stars, +.big_stars a:hover, +.big_stars a:active, +.big_stars .current-rating{ + background: url(../images/big_stars.png) left -1000px repeat-x; +} +.big_stars{ + position:relative; + width:140px; + height:28px; + overflow:hidden; + list-style:none; + margin:0; + padding:0; + background-position: left bottom; +} +.big_stars li{ + display: inline; +} +.big_stars a, +.big_stars .current-rating{ + position:absolute; + top:0; + left:0; + text-indent:-1000em; + height:28px; + line-height:28px; + outline:none; + overflow:hidden; + border: none; + +} + +.big_stars a:hover{ + background-position: left center; +} +.big_stars a.one-star{ + width:20%; + z-index:6; +} +.big_stars a.two-stars{ + width:40%; + z-index:5; +} +.big_stars a.three-stars{ + width:60%; + z-index:4; +} +.big_stars a.four-stars{ + width:80%; + z-index:3; +} +.big_stars a.five-stars{ + width:100%; + z-index:2; +} +.big_stars .current-rating{ + z-index:1; + background-position: left top; +} + +.disabled a:hover{ + background: url(../images/big_stars.png) left -1000px repeat-x;!important width:inherit;!important +} + +/* Following is styles of new like and dislike buttons*/ +.newRating { border:1px solid #ccc; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; background-color:#f3f3f3; + background-image: -webkit-gradient(linear,left bottom,left top,from(#eeeeee),to(#ffffff)); + background-image: -moz-linear-gradient(bottom, #eeeeee, #ffffff); + background-image: -o-linear-gradient(bottom, #eeeeee, #ffffff); + filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#ffffff, endColorStr=#eeeeee); } +.newLike, .newDislike { background:none; border:0px; padding:0px; margin:0px; text-indent:-90000px; width:14px; height:14px; padding:5px; display:block;} +.newLike { background:url(../images/thumbs.png) -1px 1px no-repeat; float:left; border-right:1px solid #ccc; } +.newLike:hover { cursor:pointer; background-position:-1px -21px; } +.newLike:active { background-position:-1px -20px; } + +.newDislike { background:url(../images/thumbs.png) -31px 0px no-repeat; float:right; border-left:1px solid #ccc; } +.newDislike:hover { cursor:pointer; background-position:-31px -22px; } +.newDislike:active { background-position:-31px -21px; } +.greenBar { height:50%; background-color:#156200; + background-image: -webkit-gradient(linear,left bottom,left top,from(#156200),to(#1e8c01)); + background-image: -moz-linear-gradient(bottom, #156200, #1e8c01); + background-image: -o-linear-gradient(bottom, #156200, #1e8c01); + filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#1e8c01, endColorStr=#156200); float:left; position:relative; border-right:1px solid white; } + + +.redBar { height:50%; background-color:#990000; + background-image: -webkit-gradient(linear,left bottom,left top,from(#990000),to(#c40000)); + background-image: -moz-linear-gradient(bottom, #990000, #c40000); + background-image: -o-linear-gradient(bottom, #990000, #c40000); + filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#c40000, endColorStr=#990000); float:left; position:relative; margin-right:-1px; } + +.ratingText { font:normal 11px Arial; } +.UserDisliked, .UserLiked { background:url(../images/thumbs.png) -36px -28px no-repeat; width:14px; height:14px; display:inline-block; *display:inline; } +.UserLiked { background-position:-6px -26px; } + +.ratingContainer .LikeBar { height:4px; background:#060; margin-bottom:1px; } +.ratingContainer .DislikeBar { height:4px; background:#C00; } + +.LikeText, .DislikeText { display:block; margin-bottom:1px; } +.LikeText { color:green; } .DislikeText { color:red; } \ No newline at end of file diff --git a/upload/styles/cbv2new/theme/view_channel.css b/upload/styles/cbv2new/theme/view_channel.css new file mode 100644 index 00000000..a32ee996 --- /dev/null +++ b/upload/styles/cbv2new/theme/view_channel.css @@ -0,0 +1,71 @@ +@charset "utf-8"; +/* CSS Document */ + + +.channel_inner_box a{ font-weight:bold; text-decoration:none; color:#333 } + +.channel_box{background-color:#d7d8d8;} +.channel_inner_box{background-color:#fff;} + + +.channel_box +{ + + border-radius:5px; + -moz-border-radius:5px; + -webkit-border-radius:5px; + padding:5px; margin:auto; + margin-bottom:10px; + +} + +.channel_inner_box +{ + border-radius:3px; + -moz-border-radius:3px; + -webkit-border-radius:3px; + width:99%; margin:auto; + padding:5px; + font-size:12px; + background-color:#fff +} + +.channel_inner_box .error{color:#ed0000} +.channel_inner_box .msg{color:#0099cc} + +.channel_top{font-size:16px; font-weight:bold; font-family:Arial, Helvetica, sans-serif;} +.channel_heading_mid{font-size:12px; font-weight:bold; font-family:Arial, Helvetica, sans-serif;} + +.channel_heading{background-image:url(../images/view_channel.png); background-position:0px -375px; background-repeat:repeat-x; height:25px; display:block; margin-bottom:5px; padding-left:8px; line-height:25px; font-size:16px; color:#fff;border-radius:3px; + -moz-border-radius:3px; + -webkit-border-radius:3px; font-weight:bold; font-family:Arial, Helvetica, sans-serif; } +.channel_inner_box .usr_small_thumb +{ + width:40px; + float:left; +} + +.channel_top_user_box{float:left; display:inline-block} +.usr_channel{ display:inline-block; margin-right:15px } + +.top_channel_links{display:block; margin:0px; padding:0px; float:left; } +.top_channel_links li{list-style:none; padding:0px; margin:0px; display:block; float:left; width:100px; text-align:center; margin:0px 3px 0px 3px} +.top_channel_links li a{color:#fff; display:block; background-color:#0099cc;border-radius:5px; -webkit-border-radius:5px; -moz-border-radius:5px; height:20px} + +.usr_thumb_container{margin-bottom:10px} +.user_thumb{max-width:260px} + +.channel_action_links{display:block; text-align:center; margin:0px; padding:0px;line-height:normal} +.channel_action_links a{ line-height:normal} +.channel_action_links li{list-style:none;line-height:normal} + + +.show_info{clear:both} +.show_info .item_list{width:50%; display:block; font-size:11px; } +.show_info .item_list a{font-weight:normal} +.float_right{float:right} +.float_left{float:left} + + +.right_column{float:right; width:705px; margin-right:3px} +.right_column .channel_inner_box{margin-bottom:5px} \ No newline at end of file diff --git a/upload/styles/global/admin_bar.html b/upload/styles/global/admin_bar.html new file mode 100644 index 00000000..9528232a --- /dev/null +++ b/upload/styles/global/admin_bar.html @@ -0,0 +1,85 @@ + + + +{if $smarty.cookies.CBadminBar == 'hidden'} +
    Show Menu
    +{/if} \ No newline at end of file diff --git a/upload/styles/global/head.html b/upload/styles/global/head.html new file mode 100644 index 00000000..5a82d826 --- /dev/null +++ b/upload/styles/global/head.html @@ -0,0 +1,519 @@ + + +{if $Cbucket->configs.use_google_api} + + + +{else} + + +{/if} + + + + +{foreach from=$Cbucket->JSArray item=type} + {foreach from=$type item=scope key=file} + {include_js type=$scope file=$file} + {/foreach} +{/foreach} + + + +{foreach key=file item=type from=$Cbucket->header_files} + {include_header file=$file type=$type} +{/foreach} + + + + +{if $smarty.const.THIS_PAGE == 'upload'} + + + + + + + + +{else} + +{/if} + +{if $smarty.const.THIS_PAGE == 'photo_upload'} + + + + + +{/if} + +{if $smarty.const.THIS_PAGE == 'view_item'} + +{/if} + +{if $smarty.const.THIS_PAGE=='watch_video' || $object.videoid} + {if $object.videoid}{assign var=vdo value=$object} {/if} + + + + + {if $Cbucket->configs.facebook_embed=='yes'} + + + + + + {/if} + + + +{/if} + +{if $object.photo_id} + + + + +{/if} + + +{literal} + +{/literal} + + \ No newline at end of file diff --git a/upload/styles/global/jquery_ui.css b/upload/styles/global/jquery_ui.css new file mode 100644 index 00000000..e35be9b3 --- /dev/null +++ b/upload/styles/global/jquery_ui.css @@ -0,0 +1,572 @@ +/* + * jQuery UI CSS Framework 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Theming/API + */ + +/* Layout helpers +----------------------------------*/ +.ui-helper-hidden { display: none; } +.ui-helper-hidden-accessible { position: absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px,1px,1px,1px); } +.ui-helper-reset { margin: 0; padding: 0; border: 0; outline: 0; line-height: 1.3; text-decoration: none; font-size: 100%; list-style: none; } +.ui-helper-clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; } +.ui-helper-clearfix { display: inline-block; } +/* required comment for clearfix to work in Opera \*/ +* html .ui-helper-clearfix { height:1%; } +.ui-helper-clearfix { display:block; } +/* end clearfix */ +.ui-helper-zfix { width: 100%; height: 100%; top: 0; left: 0; position: absolute; opacity: 0; filter:Alpha(Opacity=0); } + + +/* Interaction Cues +----------------------------------*/ +.ui-state-disabled { cursor: default !important; } + + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { display: block; text-indent: -99999px; overflow: hidden; background-repeat: no-repeat; } + + +/* Misc visuals +----------------------------------*/ + +/* Overlays */ +.ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } + + +/* + * jQuery UI CSS Framework 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Theming/API + * + * To view and modify this theme, visit http://jqueryui.com/themeroller/?ffDefault=Lucida%20Grande,%20Lucida%20Sans,%20Arial,%20sans-serif&fwDefault=bold&fsDefault=1.1em&cornerRadius=5px&bgColorHeader=5c9ccc&bgTextureHeader=12_gloss_wave.png&bgImgOpacityHeader=55&borderColorHeader=4297d7&fcHeader=ffffff&iconColorHeader=d8e7f3&bgColorContent=fcfdfd&bgTextureContent=06_inset_hard.png&bgImgOpacityContent=100&borderColorContent=a6c9e2&fcContent=222222&iconColorContent=469bdd&bgColorDefault=dfeffc&bgTextureDefault=02_glass.png&bgImgOpacityDefault=85&borderColorDefault=c5dbec&fcDefault=2e6e9e&iconColorDefault=6da8d5&bgColorHover=d0e5f5&bgTextureHover=02_glass.png&bgImgOpacityHover=75&borderColorHover=79b7e7&fcHover=1d5987&iconColorHover=217bc0&bgColorActive=f5f8f9&bgTextureActive=06_inset_hard.png&bgImgOpacityActive=100&borderColorActive=79b7e7&fcActive=e17009&iconColorActive=f9bd01&bgColorHighlight=fbec88&bgTextureHighlight=01_flat.png&bgImgOpacityHighlight=55&borderColorHighlight=fad42e&fcHighlight=363636&iconColorHighlight=2e83ff&bgColorError=fef1ec&bgTextureError=02_glass.png&bgImgOpacityError=95&borderColorError=cd0a0a&fcError=cd0a0a&iconColorError=cd0a0a&bgColorOverlay=aaaaaa&bgTextureOverlay=01_flat.png&bgImgOpacityOverlay=0&opacityOverlay=30&bgColorShadow=aaaaaa&bgTextureShadow=01_flat.png&bgImgOpacityShadow=0&opacityShadow=30&thicknessShadow=8px&offsetTopShadow=-8px&offsetLeftShadow=-8px&cornerRadiusShadow=8px + */ + + +/* Component containers +----------------------------------*/ +.ui-widget { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1.1em; } +.ui-widget .ui-widget { font-size: 1em; } +.ui-widget input, .ui-widget select, .ui-widget textarea, .ui-widget button { font-family: Lucida Grande, Lucida Sans, Arial, sans-serif; font-size: 1em; } +.ui-widget-content { border: 1px solid #a6c9e2; background: #fcfdfd url(images/ui-bg_inset-hard_100_fcfdfd_1x100.png) 50% bottom repeat-x; color: #222222; } +.ui-widget-content a { color: #222222; } +.ui-widget-header { border: 1px solid #4297d7; background: #5c9ccc url(images/ui-bg_gloss-wave_55_5c9ccc_500x100.png) 50% 50% repeat-x; color: #ffffff; font-weight: bold; } +.ui-widget-header a { color: #ffffff; } + +/* Interaction states +----------------------------------*/ +.ui-state-default, .ui-widget-content .ui-state-default, .ui-widget-header .ui-state-default { border: 1px solid #c5dbec; background: #dfeffc url(images/ui-bg_glass_85_dfeffc_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #2e6e9e; } +.ui-state-default a, .ui-state-default a:link, .ui-state-default a:visited { color: #2e6e9e; text-decoration: none; } +.ui-state-hover, .ui-widget-content .ui-state-hover, .ui-widget-header .ui-state-hover, .ui-state-focus, .ui-widget-content .ui-state-focus, .ui-widget-header .ui-state-focus { border: 1px solid #79b7e7; background: #d0e5f5 url(images/ui-bg_glass_75_d0e5f5_1x400.png) 50% 50% repeat-x; font-weight: bold; color: #1d5987; } +.ui-state-hover a, .ui-state-hover a:hover { color: #1d5987; text-decoration: none; } +.ui-state-active, .ui-widget-content .ui-state-active, .ui-widget-header .ui-state-active { border: 1px solid #79b7e7; background: #f5f8f9 url(images/ui-bg_inset-hard_100_f5f8f9_1x100.png) 50% 50% repeat-x; font-weight: bold; color: #e17009; } +.ui-state-active a, .ui-state-active a:link, .ui-state-active a:visited { color: #e17009; text-decoration: none; } +.ui-widget :active { outline: none; } + +/* Interaction Cues +----------------------------------*/ +.ui-state-highlight, .ui-widget-content .ui-state-highlight, .ui-widget-header .ui-state-highlight {border: 1px solid #fad42e; background: #fbec88 url(images/ui-bg_flat_55_fbec88_40x100.png) 50% 50% repeat-x; color: #363636; } +.ui-state-highlight a, .ui-widget-content .ui-state-highlight a,.ui-widget-header .ui-state-highlight a { color: #363636; } +.ui-state-error, .ui-widget-content .ui-state-error, .ui-widget-header .ui-state-error {border: 1px solid #cd0a0a; background: #fef1ec url(images/ui-bg_glass_95_fef1ec_1x400.png) 50% 50% repeat-x; color: #cd0a0a; } +.ui-state-error a, .ui-widget-content .ui-state-error a, .ui-widget-header .ui-state-error a { color: #cd0a0a; } +.ui-state-error-text, .ui-widget-content .ui-state-error-text, .ui-widget-header .ui-state-error-text { color: #cd0a0a; } +.ui-priority-primary, .ui-widget-content .ui-priority-primary, .ui-widget-header .ui-priority-primary { font-weight: bold; } +.ui-priority-secondary, .ui-widget-content .ui-priority-secondary, .ui-widget-header .ui-priority-secondary { opacity: .7; filter:Alpha(Opacity=70); font-weight: normal; } +.ui-state-disabled, .ui-widget-content .ui-state-disabled, .ui-widget-header .ui-state-disabled { opacity: .35; filter:Alpha(Opacity=35); background-image: none; } + +/* Icons +----------------------------------*/ + +/* states and images */ +.ui-icon { width: 16px; height: 16px; background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-content .ui-icon {background-image: url(images/ui-icons_469bdd_256x240.png); } +.ui-widget-header .ui-icon {background-image: url(images/ui-icons_d8e7f3_256x240.png); } +.ui-state-default .ui-icon { background-image: url(images/ui-icons_6da8d5_256x240.png); } +.ui-state-hover .ui-icon, .ui-state-focus .ui-icon {background-image: url(images/ui-icons_217bc0_256x240.png); } +.ui-state-active .ui-icon {background-image: url(images/ui-icons_f9bd01_256x240.png); } +.ui-state-highlight .ui-icon {background-image: url(images/ui-icons_2e83ff_256x240.png); } +.ui-state-error .ui-icon, .ui-state-error-text .ui-icon {background-image: url(images/ui-icons_cd0a0a_256x240.png); } + +/* positioning */ +.ui-icon-carat-1-n { background-position: 0 0; } +.ui-icon-carat-1-ne { background-position: -16px 0; } +.ui-icon-carat-1-e { background-position: -32px 0; } +.ui-icon-carat-1-se { background-position: -48px 0; } +.ui-icon-carat-1-s { background-position: -64px 0; } +.ui-icon-carat-1-sw { background-position: -80px 0; } +.ui-icon-carat-1-w { background-position: -96px 0; } +.ui-icon-carat-1-nw { background-position: -112px 0; } +.ui-icon-carat-2-n-s { background-position: -128px 0; } +.ui-icon-carat-2-e-w { background-position: -144px 0; } +.ui-icon-triangle-1-n { background-position: 0 -16px; } +.ui-icon-triangle-1-ne { background-position: -16px -16px; } +.ui-icon-triangle-1-e { background-position: -32px -16px; } +.ui-icon-triangle-1-se { background-position: -48px -16px; } +.ui-icon-triangle-1-s { background-position: -64px -16px; } +.ui-icon-triangle-1-sw { background-position: -80px -16px; } +.ui-icon-triangle-1-w { background-position: -96px -16px; } +.ui-icon-triangle-1-nw { background-position: -112px -16px; } +.ui-icon-triangle-2-n-s { background-position: -128px -16px; } +.ui-icon-triangle-2-e-w { background-position: -144px -16px; } +.ui-icon-arrow-1-n { background-position: 0 -32px; } +.ui-icon-arrow-1-ne { background-position: -16px -32px; } +.ui-icon-arrow-1-e { background-position: -32px -32px; } +.ui-icon-arrow-1-se { background-position: -48px -32px; } +.ui-icon-arrow-1-s { background-position: -64px -32px; } +.ui-icon-arrow-1-sw { background-position: -80px -32px; } +.ui-icon-arrow-1-w { background-position: -96px -32px; } +.ui-icon-arrow-1-nw { background-position: -112px -32px; } +.ui-icon-arrow-2-n-s { background-position: -128px -32px; } +.ui-icon-arrow-2-ne-sw { background-position: -144px -32px; } +.ui-icon-arrow-2-e-w { background-position: -160px -32px; } +.ui-icon-arrow-2-se-nw { background-position: -176px -32px; } +.ui-icon-arrowstop-1-n { background-position: -192px -32px; } +.ui-icon-arrowstop-1-e { background-position: -208px -32px; } +.ui-icon-arrowstop-1-s { background-position: -224px -32px; } +.ui-icon-arrowstop-1-w { background-position: -240px -32px; } +.ui-icon-arrowthick-1-n { background-position: 0 -48px; } +.ui-icon-arrowthick-1-ne { background-position: -16px -48px; } +.ui-icon-arrowthick-1-e { background-position: -32px -48px; } +.ui-icon-arrowthick-1-se { background-position: -48px -48px; } +.ui-icon-arrowthick-1-s { background-position: -64px -48px; } +.ui-icon-arrowthick-1-sw { background-position: -80px -48px; } +.ui-icon-arrowthick-1-w { background-position: -96px -48px; } +.ui-icon-arrowthick-1-nw { background-position: -112px -48px; } +.ui-icon-arrowthick-2-n-s { background-position: -128px -48px; } +.ui-icon-arrowthick-2-ne-sw { background-position: -144px -48px; } +.ui-icon-arrowthick-2-e-w { background-position: -160px -48px; } +.ui-icon-arrowthick-2-se-nw { background-position: -176px -48px; } +.ui-icon-arrowthickstop-1-n { background-position: -192px -48px; } +.ui-icon-arrowthickstop-1-e { background-position: -208px -48px; } +.ui-icon-arrowthickstop-1-s { background-position: -224px -48px; } +.ui-icon-arrowthickstop-1-w { background-position: -240px -48px; } +.ui-icon-arrowreturnthick-1-w { background-position: 0 -64px; } +.ui-icon-arrowreturnthick-1-n { background-position: -16px -64px; } +.ui-icon-arrowreturnthick-1-e { background-position: -32px -64px; } +.ui-icon-arrowreturnthick-1-s { background-position: -48px -64px; } +.ui-icon-arrowreturn-1-w { background-position: -64px -64px; } +.ui-icon-arrowreturn-1-n { background-position: -80px -64px; } +.ui-icon-arrowreturn-1-e { background-position: -96px -64px; } +.ui-icon-arrowreturn-1-s { background-position: -112px -64px; } +.ui-icon-arrowrefresh-1-w { background-position: -128px -64px; } +.ui-icon-arrowrefresh-1-n { background-position: -144px -64px; } +.ui-icon-arrowrefresh-1-e { background-position: -160px -64px; } +.ui-icon-arrowrefresh-1-s { background-position: -176px -64px; } +.ui-icon-arrow-4 { background-position: 0 -80px; } +.ui-icon-arrow-4-diag { background-position: -16px -80px; } +.ui-icon-extlink { background-position: -32px -80px; } +.ui-icon-newwin { background-position: -48px -80px; } +.ui-icon-refresh { background-position: -64px -80px; } +.ui-icon-shuffle { background-position: -80px -80px; } +.ui-icon-transfer-e-w { background-position: -96px -80px; } +.ui-icon-transferthick-e-w { background-position: -112px -80px; } +.ui-icon-folder-collapsed { background-position: 0 -96px; } +.ui-icon-folder-open { background-position: -16px -96px; } +.ui-icon-document { background-position: -32px -96px; } +.ui-icon-document-b { background-position: -48px -96px; } +.ui-icon-note { background-position: -64px -96px; } +.ui-icon-mail-closed { background-position: -80px -96px; } +.ui-icon-mail-open { background-position: -96px -96px; } +.ui-icon-suitcase { background-position: -112px -96px; } +.ui-icon-comment { background-position: -128px -96px; } +.ui-icon-person { background-position: -144px -96px; } +.ui-icon-print { background-position: -160px -96px; } +.ui-icon-trash { background-position: -176px -96px; } +.ui-icon-locked { background-position: -192px -96px; } +.ui-icon-unlocked { background-position: -208px -96px; } +.ui-icon-bookmark { background-position: -224px -96px; } +.ui-icon-tag { background-position: -240px -96px; } +.ui-icon-home { background-position: 0 -112px; } +.ui-icon-flag { background-position: -16px -112px; } +.ui-icon-calendar { background-position: -32px -112px; } +.ui-icon-cart { background-position: -48px -112px; } +.ui-icon-pencil { background-position: -64px -112px; } +.ui-icon-clock { background-position: -80px -112px; } +.ui-icon-disk { background-position: -96px -112px; } +.ui-icon-calculator { background-position: -112px -112px; } +.ui-icon-zoomin { background-position: -128px -112px; } +.ui-icon-zoomout { background-position: -144px -112px; } +.ui-icon-search { background-position: -160px -112px; } +.ui-icon-wrench { background-position: -176px -112px; } +.ui-icon-gear { background-position: -192px -112px; } +.ui-icon-heart { background-position: -208px -112px; } +.ui-icon-star { background-position: -224px -112px; } +.ui-icon-link { background-position: -240px -112px; } +.ui-icon-cancel { background-position: 0 -128px; } +.ui-icon-plus { background-position: -16px -128px; } +.ui-icon-plusthick { background-position: -32px -128px; } +.ui-icon-minus { background-position: -48px -128px; } +.ui-icon-minusthick { background-position: -64px -128px; } +.ui-icon-close { background-position: -80px -128px; } +.ui-icon-closethick { background-position: -96px -128px; } +.ui-icon-key { background-position: -112px -128px; } +.ui-icon-lightbulb { background-position: -128px -128px; } +.ui-icon-scissors { background-position: -144px -128px; } +.ui-icon-clipboard { background-position: -160px -128px; } +.ui-icon-copy { background-position: -176px -128px; } +.ui-icon-contact { background-position: -192px -128px; } +.ui-icon-image { background-position: -208px -128px; } +.ui-icon-video { background-position: -224px -128px; } +.ui-icon-script { background-position: -240px -128px; } +.ui-icon-alert { background-position: 0 -144px; } +.ui-icon-info { background-position: -16px -144px; } +.ui-icon-notice { background-position: -32px -144px; } +.ui-icon-help { background-position: -48px -144px; } +.ui-icon-check { background-position: -64px -144px; } +.ui-icon-bullet { background-position: -80px -144px; } +.ui-icon-radio-off { background-position: -96px -144px; } +.ui-icon-radio-on { background-position: -112px -144px; } +.ui-icon-pin-w { background-position: -128px -144px; } +.ui-icon-pin-s { background-position: -144px -144px; } +.ui-icon-play { background-position: 0 -160px; } +.ui-icon-pause { background-position: -16px -160px; } +.ui-icon-seek-next { background-position: -32px -160px; } +.ui-icon-seek-prev { background-position: -48px -160px; } +.ui-icon-seek-end { background-position: -64px -160px; } +.ui-icon-seek-start { background-position: -80px -160px; } +/* ui-icon-seek-first is deprecated, use ui-icon-seek-start instead */ +.ui-icon-seek-first { background-position: -80px -160px; } +.ui-icon-stop { background-position: -96px -160px; } +.ui-icon-eject { background-position: -112px -160px; } +.ui-icon-volume-off { background-position: -128px -160px; } +.ui-icon-volume-on { background-position: -144px -160px; } +.ui-icon-power { background-position: 0 -176px; } +.ui-icon-signal-diag { background-position: -16px -176px; } +.ui-icon-signal { background-position: -32px -176px; } +.ui-icon-battery-0 { background-position: -48px -176px; } +.ui-icon-battery-1 { background-position: -64px -176px; } +.ui-icon-battery-2 { background-position: -80px -176px; } +.ui-icon-battery-3 { background-position: -96px -176px; } +.ui-icon-circle-plus { background-position: 0 -192px; } +.ui-icon-circle-minus { background-position: -16px -192px; } +.ui-icon-circle-close { background-position: -32px -192px; } +.ui-icon-circle-triangle-e { background-position: -48px -192px; } +.ui-icon-circle-triangle-s { background-position: -64px -192px; } +.ui-icon-circle-triangle-w { background-position: -80px -192px; } +.ui-icon-circle-triangle-n { background-position: -96px -192px; } +.ui-icon-circle-arrow-e { background-position: -112px -192px; } +.ui-icon-circle-arrow-s { background-position: -128px -192px; } +.ui-icon-circle-arrow-w { background-position: -144px -192px; } +.ui-icon-circle-arrow-n { background-position: -160px -192px; } +.ui-icon-circle-zoomin { background-position: -176px -192px; } +.ui-icon-circle-zoomout { background-position: -192px -192px; } +.ui-icon-circle-check { background-position: -208px -192px; } +.ui-icon-circlesmall-plus { background-position: 0 -208px; } +.ui-icon-circlesmall-minus { background-position: -16px -208px; } +.ui-icon-circlesmall-close { background-position: -32px -208px; } +.ui-icon-squaresmall-plus { background-position: -48px -208px; } +.ui-icon-squaresmall-minus { background-position: -64px -208px; } +.ui-icon-squaresmall-close { background-position: -80px -208px; } +.ui-icon-grip-dotted-vertical { background-position: 0 -224px; } +.ui-icon-grip-dotted-horizontal { background-position: -16px -224px; } +.ui-icon-grip-solid-vertical { background-position: -32px -224px; } +.ui-icon-grip-solid-horizontal { background-position: -48px -224px; } +.ui-icon-gripsmall-diagonal-se { background-position: -64px -224px; } +.ui-icon-grip-diagonal-se { background-position: -80px -224px; } + + +/* Misc visuals +----------------------------------*/ + +/* Corner radius */ +.ui-corner-tl { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; } +.ui-corner-tr { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bl { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-br { -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-top { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; } +.ui-corner-bottom { -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-right { -moz-border-radius-topright: 5px; -webkit-border-top-right-radius: 5px; border-top-right-radius: 5px; -moz-border-radius-bottomright: 5px; -webkit-border-bottom-right-radius: 5px; border-bottom-right-radius: 5px; } +.ui-corner-left { -moz-border-radius-topleft: 5px; -webkit-border-top-left-radius: 5px; border-top-left-radius: 5px; -moz-border-radius-bottomleft: 5px; -webkit-border-bottom-left-radius: 5px; border-bottom-left-radius: 5px; } +.ui-corner-all { -moz-border-radius: 5px; -webkit-border-radius: 5px; border-radius: 5px; } + +/* Overlays */ +.ui-widget-overlay { background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); } +.ui-widget-shadow { margin: -8px 0 0 -8px; padding: 8px; background: #aaaaaa url(images/ui-bg_flat_0_aaaaaa_40x100.png) 50% 50% repeat-x; opacity: .30;filter:Alpha(Opacity=30); -moz-border-radius: 8px; -webkit-border-radius: 8px; border-radius: 8px; }/* + * jQuery UI Resizable 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Resizable#theming + */ +.ui-resizable { position: relative;} +.ui-resizable-handle { position: absolute;font-size: 0.1px;z-index: 99999; display: block;} +.ui-resizable-disabled .ui-resizable-handle, .ui-resizable-autohide .ui-resizable-handle { display: none; } +.ui-resizable-n { cursor: n-resize; height: 7px; width: 100%; top: -5px; left: 0; } +.ui-resizable-s { cursor: s-resize; height: 7px; width: 100%; bottom: -5px; left: 0; } +.ui-resizable-e { cursor: e-resize; width: 7px; right: -5px; top: 0; height: 100%; } +.ui-resizable-w { cursor: w-resize; width: 7px; left: -5px; top: 0; height: 100%; } +.ui-resizable-se { cursor: se-resize; width: 12px; height: 12px; right: 1px; bottom: 1px; } +.ui-resizable-sw { cursor: sw-resize; width: 9px; height: 9px; left: -5px; bottom: -5px; } +.ui-resizable-nw { cursor: nw-resize; width: 9px; height: 9px; left: -5px; top: -5px; } +.ui-resizable-ne { cursor: ne-resize; width: 9px; height: 9px; right: -5px; top: -5px;}/* + * jQuery UI Selectable 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Selectable#theming + */ +.ui-selectable-helper { position: absolute; z-index: 100; border:1px dotted black; } +/* + * jQuery UI Accordion 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Accordion#theming + */ +/* IE/Win - Fix animation bug - #4615 */ +.ui-accordion { width: 100%; } +.ui-accordion .ui-accordion-header { cursor: pointer; position: relative; margin-top: 1px; zoom: 1; } +.ui-accordion .ui-accordion-li-fix { display: inline; } +.ui-accordion .ui-accordion-header-active { border-bottom: 0 !important; } +.ui-accordion .ui-accordion-header a { display: block; font-size: 1em; padding: .5em .5em .5em .7em; } +.ui-accordion-icons .ui-accordion-header a { padding-left: 2.2em; } +.ui-accordion .ui-accordion-header .ui-icon { position: absolute; left: .5em; top: 50%; margin-top: -8px; } +.ui-accordion .ui-accordion-content { padding: 1em 2.2em; border-top: 0; margin-top: -2px; position: relative; top: 1px; margin-bottom: 2px; overflow: auto; display: none; zoom: 1; } +.ui-accordion .ui-accordion-content-active { display: block; }/* + * jQuery UI Autocomplete 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Autocomplete#theming + */ +.ui-autocomplete { position: absolute; cursor: default; } + +/* workarounds */ +* html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */ + +/* + * jQuery UI Menu 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Menu#theming + */ +.ui-menu { + list-style:none; + padding: 2px; + margin: 0; + display:block; + float: left; +} +.ui-menu .ui-menu { + margin-top: -3px; +} +.ui-menu .ui-menu-item { + margin:0; + padding: 0; + zoom: 1; + float: left; + clear: left; + width: 100%; +} +.ui-menu .ui-menu-item a { + text-decoration:none; + display:block; + padding:.2em .4em; + line-height:1.5; + zoom:1; +} +.ui-menu .ui-menu-item a.ui-state-hover, +.ui-menu .ui-menu-item a.ui-state-active { + font-weight: normal; + margin: -1px; +} +/* + * jQuery UI Button 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Button#theming + */ +.ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */ +.ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */ +button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */ +.ui-button-icons-only { width: 3.4em; } +button.ui-button-icons-only { width: 3.7em; } + +/*button text element */ +.ui-button .ui-button-text { display: block; line-height: 1.4; } +.ui-button-text-only .ui-button-text { padding: .4em 1em; } +.ui-button-icon-only .ui-button-text, .ui-button-icons-only .ui-button-text { padding: .4em; text-indent: -9999999px; } +.ui-button-text-icon-primary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 1em .4em 2.1em; } +.ui-button-text-icon-secondary .ui-button-text, .ui-button-text-icons .ui-button-text { padding: .4em 2.1em .4em 1em; } +.ui-button-text-icons .ui-button-text { padding-left: 2.1em; padding-right: 2.1em; } +/* no icon support for input elements, provide padding by default */ +input.ui-button { padding: .4em 1em; } + +/*button icon element(s) */ +.ui-button-icon-only .ui-icon, .ui-button-text-icon-primary .ui-icon, .ui-button-text-icon-secondary .ui-icon, .ui-button-text-icons .ui-icon, .ui-button-icons-only .ui-icon { position: absolute; top: 50%; margin-top: -8px; } +.ui-button-icon-only .ui-icon { left: 50%; margin-left: -8px; } +.ui-button-text-icon-primary .ui-button-icon-primary, .ui-button-text-icons .ui-button-icon-primary, .ui-button-icons-only .ui-button-icon-primary { left: .5em; } +.ui-button-text-icon-secondary .ui-button-icon-secondary, .ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } +.ui-button-text-icons .ui-button-icon-secondary, .ui-button-icons-only .ui-button-icon-secondary { right: .5em; } + +/*button sets*/ +.ui-buttonset { margin-right: 7px; } +.ui-buttonset .ui-button { margin-left: 0; margin-right: -.3em; } + +/* workarounds */ +button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra padding in Firefox */ +/* + * jQuery UI Dialog 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Dialog#theming + */ +.ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; } +.ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; } +.ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; } +.ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; } +.ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; } +.ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; } +.ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; } +.ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; } +.ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset { float: right; } +.ui-dialog .ui-dialog-buttonpane button { margin: .5em .4em .5em 0; cursor: pointer; } +.ui-dialog .ui-resizable-se { width: 14px; height: 14px; right: 3px; bottom: 3px; } +.ui-draggable .ui-dialog-titlebar { cursor: move; } +/* + * jQuery UI Slider 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Slider#theming + */ +.ui-slider { position: relative; text-align: left; } +.ui-slider .ui-slider-handle { position: absolute; z-index: 2; width: 1.2em; height: 1.2em; cursor: default; } +.ui-slider .ui-slider-range { position: absolute; z-index: 1; font-size: .7em; display: block; border: 0; background-position: 0 0; } + +.ui-slider-horizontal { height: .8em; } +.ui-slider-horizontal .ui-slider-handle { top: -.3em; margin-left: -.6em; } +.ui-slider-horizontal .ui-slider-range { top: 0; height: 100%; } +.ui-slider-horizontal .ui-slider-range-min { left: 0; } +.ui-slider-horizontal .ui-slider-range-max { right: 0; } + +.ui-slider-vertical { width: .8em; height: 100px; } +.ui-slider-vertical .ui-slider-handle { left: -.3em; margin-left: 0; margin-bottom: -.6em; } +.ui-slider-vertical .ui-slider-range { left: 0; width: 100%; } +.ui-slider-vertical .ui-slider-range-min { bottom: 0; } +.ui-slider-vertical .ui-slider-range-max { top: 0; }/* + * jQuery UI Tabs 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Tabs#theming + */ +.ui-tabs { position: relative; padding: .2em; zoom: 1; } /* position: relative prevents IE scroll bug (element with position: relative inside container with overflow: auto appear as "fixed") */ +.ui-tabs .ui-tabs-nav { margin: 0; padding: .2em .2em 0; } +.ui-tabs .ui-tabs-nav li { list-style: none; float: left; position: relative; top: 1px; margin: 0 .2em 1px 0; border-bottom: 0 !important; padding: 0; white-space: nowrap; } +.ui-tabs .ui-tabs-nav li a { float: left; padding: .5em 1em; text-decoration: none; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected { margin-bottom: 0; padding-bottom: 1px; } +.ui-tabs .ui-tabs-nav li.ui-tabs-selected a, .ui-tabs .ui-tabs-nav li.ui-state-disabled a, .ui-tabs .ui-tabs-nav li.ui-state-processing a { cursor: text; } +.ui-tabs .ui-tabs-nav li a, .ui-tabs.ui-tabs-collapsible .ui-tabs-nav li.ui-tabs-selected a { cursor: pointer; } /* first selector in group seems obsolete, but required to overcome bug in Opera applying cursor: text overall if defined elsewhere... */ +.ui-tabs .ui-tabs-panel { display: block; border-width: 0; padding: 1em 1.4em; background: none; } +.ui-tabs .ui-tabs-hide { display: none !important; } +/* + * jQuery UI Datepicker 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Datepicker#theming + */ +.ui-datepicker { width: 17em; padding: .2em .2em 0; display: none; } +.ui-datepicker .ui-datepicker-header { position:relative; padding:.2em 0; } +.ui-datepicker .ui-datepicker-prev, .ui-datepicker .ui-datepicker-next { position:absolute; top: 2px; width: 1.8em; height: 1.8em; } +.ui-datepicker .ui-datepicker-prev-hover, .ui-datepicker .ui-datepicker-next-hover { top: 1px; } +.ui-datepicker .ui-datepicker-prev { left:2px; } +.ui-datepicker .ui-datepicker-next { right:2px; } +.ui-datepicker .ui-datepicker-prev-hover { left:1px; } +.ui-datepicker .ui-datepicker-next-hover { right:1px; } +.ui-datepicker .ui-datepicker-prev span, .ui-datepicker .ui-datepicker-next span { display: block; position: absolute; left: 50%; margin-left: -8px; top: 50%; margin-top: -8px; } +.ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; } +.ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; } +.ui-datepicker select.ui-datepicker-month-year {width: 100%;} +.ui-datepicker select.ui-datepicker-month, +.ui-datepicker select.ui-datepicker-year { width: 49%;} +.ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; } +.ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; } +.ui-datepicker td { border: 0; padding: 1px; } +.ui-datepicker td span, .ui-datepicker td a { display: block; padding: .2em; text-align: right; text-decoration: none; } +.ui-datepicker .ui-datepicker-buttonpane { background-image: none; margin: .7em 0 0 0; padding:0 .2em; border-left: 0; border-right: 0; border-bottom: 0; } +.ui-datepicker .ui-datepicker-buttonpane button { float: right; margin: .5em .2em .4em; cursor: pointer; padding: .2em .6em .3em .6em; width:auto; overflow:visible; } +.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current { float:left; } + +/* with multiple calendars */ +.ui-datepicker.ui-datepicker-multi { width:auto; } +.ui-datepicker-multi .ui-datepicker-group { float:left; } +.ui-datepicker-multi .ui-datepicker-group table { width:95%; margin:0 auto .4em; } +.ui-datepicker-multi-2 .ui-datepicker-group { width:50%; } +.ui-datepicker-multi-3 .ui-datepicker-group { width:33.3%; } +.ui-datepicker-multi-4 .ui-datepicker-group { width:25%; } +.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header { border-left-width:0; } +.ui-datepicker-multi .ui-datepicker-buttonpane { clear:left; } +.ui-datepicker-row-break { clear:both; width:100%; } + +/* RTL support */ +.ui-datepicker-rtl { direction: rtl; } +.ui-datepicker-rtl .ui-datepicker-prev { right: 2px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next { left: 2px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-prev:hover { right: 1px; left: auto; } +.ui-datepicker-rtl .ui-datepicker-next:hover { left: 1px; right: auto; } +.ui-datepicker-rtl .ui-datepicker-buttonpane { clear:right; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button { float: left; } +.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current { float:right; } +.ui-datepicker-rtl .ui-datepicker-group { float:right; } +.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header { border-right-width:0; border-left-width:1px; } +.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header { border-right-width:0; border-left-width:1px; } + +/* IE6 IFRAME FIX (taken from datepicker 1.5.3 */ +.ui-datepicker-cover { + display: none; /*sorry for IE5*/ + display/**/: block; /*sorry for IE5*/ + position: absolute; /*must have*/ + z-index: -1; /*must have*/ + filter: mask(); /*must have*/ + top: -4px; /*must have*/ + left: -4px; /*must have*/ + width: 200px; /*must have*/ + height: 200px; /*must have*/ +}/* + * jQuery UI Progressbar 1.8.8 + * + * Copyright 2010, AUTHORS.txt (http://jqueryui.com/about) + * Dual licensed under the MIT or GPL Version 2 licenses. + * http://jquery.org/license + * + * http://docs.jquery.com/UI/Progressbar#theming + */ +.ui-progressbar { height:2em; text-align: left; } +.ui-progressbar .ui-progressbar-value {margin: -1px; height:100%; } \ No newline at end of file diff --git a/upload/styles/global/upload_form.html b/upload/styles/global/upload_form.html new file mode 100644 index 00000000..13dcaed2 --- /dev/null +++ b/upload/styles/global/upload_form.html @@ -0,0 +1,16 @@ +
    + {lang code='upload_desktop_msg'} +
    + +
    + +
    +
    + {lang code='upload_videos_can_be' assign='uploadVidCanBe'} + {assign var=allowedSize value=$Cbucket->configs.max_upload_size} + {assign var=allowedDuration value=$Cbucket->configs.max_video_duration} + {$uploadVidCanBe|sprintf:"$allowedSize MB":"$allowedDuration minutes"} +
    +
    + +
    \ No newline at end of file diff --git a/upload/upload.php b/upload/upload.php new file mode 100644 index 00000000..67341b61 --- /dev/null +++ b/upload/upload.php @@ -0,0 +1,78 @@ +page_redir(); +subtitle('upload'); + +//Checking if user is guest +if(userid()) + $verify_logged_user = true; +else + $verify_logged_user = false; + +if(has_access('allow_video_upload',false,$verify_logged_user)) +{ + $file_name = time().RandomString(5); + assign('file_name',$file_name); + + $step = 1; + if(isset($_POST['submit_data'])) + { + $Upload->validate_video_upload_form(); + if(empty($eh->error_list)) + { + $step=2; + } + } + + if(isset($_POST['submit_upload'])) + { + if(!$_POST['file_name']) + $_POST['file_name'] = time().RandomString(5); + + //$Upload->validate_video_upload_form(NULL,TRUE); + if(empty($eh->error_list)) + { + $vid = $Upload->submit_upload(); + //echo $db->db_query; + //Call file so it can activate video + $Upload->do_after_video_upload($vid); + + if(!error()) + $step=3; + } + } + + //Assigning Form Name [RECOMMEND for submitting purpose] + Assign('upload_form_name','UploadForm'); + + //Adding Uploading JS Files + $Cbucket->add_js(array('swfupload/swfupload.js'=>'uploadactive')); + $Cbucket->add_js(array('swfupload/plugins/swfupload.queue.js'=>'uploadactive')); + $Cbucket->add_js(array('swfupload/plugins/handlers.js'=>'uploadactive')); + $Cbucket->add_js(array('swfupload/plugins/fileprogress.js'=>'uploadactive')); +}else +{ + $userquery->logincheck('allow_video_upload',true); +} + +Assign('step',$step); + +subtitle(lang('upload')); +//Displaying The Template +template_files('upload.html'); +display_it(); + +?> \ No newline at end of file diff --git a/upload/user_collections.php b/upload/user_collections.php new file mode 100644 index 00000000..87da1b5c --- /dev/null +++ b/upload/user_collections.php @@ -0,0 +1,74 @@ +page_redir(); +//$userquery->perm_check('view_videos',true); + +$u = $_GET['user']; +$u = $u ? $u : $_GET['userid']; +$u = $u ? $u : $_GET['username']; +$u = $u ? $u : $_GET['uid']; +$u = $u ? $u : $_GET['u']; + +$user = $userquery->get_user_details($u); +$page = mysql_clean($_GET['page']); + +if($user) +{ + assign('u',$user); + assign('p',$userquery->get_user_profile($udetails['userid'])); + + $mode = $_GET['mode']; + + switch($mode) + { + case "collections": + case "uploaded": + default: + { + $limit = create_query_limit($page,config('collection_user_collections')); + assign("the_title",$user['username']." ".lang('collections')); + $collections = get_collections(array("limit"=>$limit,"user"=>$user['userid'])); + $total_rows = get_collections(array("count_only"=>true,"user"=>$user['userid'])); + $total_pages = count_pages($total_rows,config('collection_user_collections')); + } + break; + + case "favorites": + case "fav_collections": + case "favorite": + { + $limit = create_query_limit($page,config('collection_user_favorites')); + assign("the_title",$user['username']." ".lang('favorite')." ".lang('collections')); + $favC = array("user"=>$user['userid'],"limit",$limit); + $collections = $cbcollection->action->get_favorites($favC); + $favC['count_only'] = true; + $total_rows = $cbcollection->action->get_favorites($favC); + $total_pages = count_pages($total_rows,config('collection_user_favorites')); + } + break; + } + + assign('collections',$collections); + + $pages->paginate($total_pages,$page); +} else { + e(lang("usr_exist_err")); + $Cbucket->show_page = false; +} + +if($Cbucket->show_page) +Template('user_collections.html'); +else +display_it(); +?> \ No newline at end of file diff --git a/upload/user_contacts.php b/upload/user_contacts.php new file mode 100644 index 00000000..e48fffdc --- /dev/null +++ b/upload/user_contacts.php @@ -0,0 +1,72 @@ +page_redir(); + + +$u = $_GET['user']; +$u = $u ? $u : $_GET['userid']; +$u = $u ? $u : $_GET['username']; +$u = $u ? $u : $_GET['uid']; +$u = $u ? $u : $_GET['u']; + +$u = mysql_clean($u); +$udetails = $userquery->get_user_details($u); +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,CLISTPP); + +if($udetails) +{ + assign("u",$udetails); + assign('p',$userquery->get_user_profile($udetails['userid'])); + $mode = $_GET['mode']; + switch($mode) + { + case "contacts": + default: + { + //assign("u",$udetails); + assign('p',$userquery->get_user_profile($udetails['userid'])); + assign('mode',$mode); + assign('friends',$userquery->get_contacts($udetails['userid'],0,"yes")); + } + break; + + case "subscriptions": + { + assign('mode',$mode); + assign('heading',sprintf(lang('user_subscriptions'),$udetails['username'])); + assign('userSubs',$userquery->get_user_subscriptions($udetails['userid'],NULL)); + } + break; + + case "subscribers": + { + assign('mode',$mode); + assign('heading',sprintf(lang('users_subscribers'),$udetails['username'])); + assign('userSubs',$userquery->get_user_subscribers_detail($udetails['userid'],NULL)); + } + break; + } + +}else{ + e(lang("usr_exist_err")); + $Cbucket->show_page = false; +} + + +subtitle(sprintf(lang("users_contacts"),$udetails['username'])); +if($Cbucket->show_page) +Template('user_contacts.html'); +else +display_it(); +?> \ No newline at end of file diff --git a/upload/user_photos.php b/upload/user_photos.php new file mode 100644 index 00000000..1c8e7054 --- /dev/null +++ b/upload/user_photos.php @@ -0,0 +1,74 @@ +page_redir(); +//$userquery->perm_check('view_videos',true); + +$u = $_GET['user']; +$u = $u ? $u : $_GET['userid']; +$u = $u ? $u : $_GET['username']; +$u = $u ? $u : $_GET['uid']; +$u = $u ? $u : $_GET['u']; + +$user = $userquery->get_user_details($u); +$page = mysql_clean($_GET['page']); + +if($user) +{ + assign('u',$user); + assign('p',$userquery->get_user_profile($udetails['userid'])); + + $mode = $_GET['mode']; + + switch($mode) + { + case "photos": + case "uploaded": + default: + { + $limit = create_query_limit($page,config('photo_user_photos')); + assign("the_title",$user['username']." ".lang('photos')); + $photos = get_photos(array("limit"=>$limit,"user"=>$user['userid'])); + $total_rows = get_photos(array("count_only"=>true,"user"=>$user['userid'])); + $total_pages = count_pages($total_rows,config('photo_user_photos')); + } + break; + + case "favorites": + case "fav_photos": + case "favorite": + { + $limit = create_query_limit($page,config('photo_user_favorites')); + assign("the_title",$user['username']." ".lang('Favorite')." ".lang('photos')); + $favP = array("user"=>$user['userid'],"limit",$limit); + $photos = $cbphoto->action->get_favorites($favP); + $favP['count_only'] = true; + $total_rows = $cbphoto->action->get_favorites($favP); + $total_pages = count_pages($total_rows,config('photo_user_favorites')); + } + break; + } + + assign('photos',$photos); + + $pages->paginate($total_pages,$page); +} else { + e(lang("usr_exist_err")); + $Cbucket->show_page = false; +} + +if($Cbucket->show_page) +Template('user_photos.html'); +else +display_it(); +?> \ No newline at end of file diff --git a/upload/user_videos.php b/upload/user_videos.php new file mode 100644 index 00000000..4c980571 --- /dev/null +++ b/upload/user_videos.php @@ -0,0 +1,79 @@ +page_redir(); +$userquery->perm_check('view_videos',true); + +$u = $_GET['user']; +$u = $u ? $u : $_GET['userid']; +$u = $u ? $u : $_GET['username']; +$u = $u ? $u : $_GET['uid']; +$u = $u ? $u : $_GET['u']; + +$udetails = $userquery->get_user_details($u); +$page = mysql_clean($_GET['page']); + +if($udetails) +{ + assign("u",$udetails); + $mode = $_GET['mode']; + + assign("u",$udetails); + assign('p',$userquery->get_user_profile($udetails['userid'])); + + switch($mode) + { + case 'uploads': + case 'videos': + default: + { + $get_limit = create_query_limit($page,config('videos_items_uvid_page')); + assign("the_title",$udetails['username']." videos"); + $videos = get_videos(array('user'=>$udetails['userid'],'limit'=>$get_limit)); + $total_rows = get_videos(array('user'=>$udetails['userid'],'count_only'=>true)); + subtitle(sprintf(lang("users_videos"),$udetails['username'])); + $total_pages = count_pages($total_rows,config('videos_items_uvid_page')); + + } + break; + case 'favorites': + { + $get_limit = create_query_limit($page,config('videos_items_ufav_page')); + assign("the_title",$udetails['username']." favorites"); + $params = array('userid'=>$udetails['userid'],'limit'=>$get_limit); + $videos = $cbvid->action->get_favorites($params); + $params['count_only'] = "yes"; + $total_rows = $cbvid->action->get_favorites($params); + subtitle(sprintf(lang("title_usr_fav_vids"),$udetails['username'])); + $total_pages = count_pages($total_rows,config('videos_items_ufav_page')); + } + } + +Assign('videos', $videos); + + +//Pagination +$pages->paginate($total_pages,$page); + +}else{ + e(lang("usr_exist_err")); + $Cbucket->show_page = false; +} + + + +if($Cbucket->show_page) +Template('user_videos.html'); +else +display_it(); +?> \ No newline at end of file diff --git a/upload/videos.php b/upload/videos.php new file mode 100644 index 00000000..6f0c6e37 --- /dev/null +++ b/upload/videos.php @@ -0,0 +1,108 @@ +page_redir(); +$userquery->perm_check('view_videos',true); + +//Setting Sort +$sort = $_GET['sort']; +$child_ids = ""; + +if($_GET['cat'] && $_GET['cat']!='all') +{ + $childs = $cbvid->get_sub_categories(mysql_clean($_GET['cat'])); + $child_ids = array(); + if($childs) + foreach($childs as $child) + { + $child_ids[] = $child['category_id']; + $subchilds = $childs = $cbvid->get_sub_categories($child['category_id']); + if($subchilds) + foreach($subchilds as $subchild) + { + $child_ids[] = $subchild['category_id']; + } + } + $child_ids[] = mysql_clean($_GET['cat']); +} + +//$vid_cond = array('category'=>$child_ids,'date_span'=>$_GET['time'],'sub_cats'); +//Thanks to florin.mandache +$vid_cond = array('category'=>$child_ids,'date_span'=>mysql_clean($_GET['time']),'sub_cats'); + + +switch($sort) +{ + case "most_recent": + default: + { + $vid_cond['order'] = " date_added DESC "; + } + break; + case "most_viewed": + { + $vid_cond['order'] = " views DESC "; + $vid_cond['date_span_column'] = 'last_viewed'; + } + break; + case "most_viewed": + { + $vid_cond['order'] = " views DESC "; + } + break; + case "featured": + { + $vid_cond['featured'] = "yes"; + } + break; + case "top_rated": + { + $vid_cond['order'] = " rating DESC, rated_by DESC"; + } + break; + case "most_commented": + { + $vid_cond['order'] = " comments_count DESC"; + } + break; +} + +//Getting Video List +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,VLISTPP); +$vlist = $vid_cond; +$count_query = $vid_cond; +$vlist['limit'] = $get_limit; +$videos = get_videos($vlist); +Assign('videos', $videos); + + +//Collecting Data for Pagination +$vcount = $vid_cond; +$counter = get_counter('video',$count_query); +if(!$counter) +{ + $vcount['count_only'] = true; + $total_rows = get_videos($vcount); + $total_pages = count_pages($total_rows,VLISTPP); + $counter = $total_rows; + update_counter('video',$count_query,$counter); +} + +$total_pages = count_pages($counter,VLISTPP); +//Pagination +$pages->paginate($total_pages,$page); + +subtitle(lang('videos')); +//Displaying The Template +template_files('videos.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_channel.php b/upload/view_channel.php new file mode 100644 index 00000000..36df34ff --- /dev/null +++ b/upload/view_channel.php @@ -0,0 +1,121 @@ +page_redir(); +$userquery->perm_check('view_channel',true); + + +$u = $_GET['user']; +$u = $u ? $u : $_GET['userid']; +$u = $u ? $u : $_GET['username']; +$u = $u ? $u : $_GET['uid']; +$u = $u ? $u : $_GET['u']; +$u = mysql_clean($u); + +$udetails = $userquery->get_user_details($u); +if($udetails) +{ + + //Subscribing User + if($_GET['subscribe']) + { + $userquery->subscribe_user($udetails['userid']); + } + + //Adding Comment + if(isset($_POST['add_comment'])) + { + $userquery->add_comment($_POST['comment'],$udetails['userid']); + } + //Calling view channel functions + call_view_channel_functions($udetails); + + assign("u",$udetails); + + //Getting profile details + $p = $userquery->get_user_profile($udetails['userid']); + assign('p',$p); + + //Checking Profile permissions + + $perms = $p['show_profile']; + if(userid()!=$udetails['userid']) + { + if(($perms == 'friends' || $perms == 'members') && !userid()) + { + e(lang('you_cant_view_profile')); + + if(!has_access('admin_access',true)) + $Cbucket->show_page = false; + }elseif($perms == 'friends' && !$userquery->is_confirmed_friend($udetails['userid'],userid())) + { + e(sprintf(lang('only_friends_view_channel'),$udetails['username'])); + + if(!has_access('admin_access',true)) + $Cbucket->show_page = false; + } + + //Checking if user is not banned by admin + if(userid()) + { + if($userquery->is_user_banned(username(),$udetails['userid'],$udetails['banned_users'])) + { + e(sprintf(lang('you_are_not_allowed_to_view_user_channel'),$udetails['username'])); + assign('isBlocked','yes'); + if(!has_access('admin_access',true)) + $Cbucket->show_page = false; + } + } + } + + + subtitle(sprintf(lang('user_s_channel'),$udetails['username'])); + + //Setting profilte item + $profileItem = $userquery->getProfileItem($udetails['userid'],true); + + assign('profile_item',$profileItem); +}else{ + + if($_GET['seo_diret']!='yes') + { + e(lang("usr_exist_err")); + $Cbucket->show_page = false; + }else{ + header("HTTP/1.0 404 Not Found"); + 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(); + exit(); + } +} +add_js(array('jquery_plugs/compressed/jquery.jCarousel.js'=>'view_channel')); + +if($Cbucket->show_page) + Template('view_channel.html'); +else +{ + $Cbucket->show_page = true; + if($udetails) + template_files('blocks/view_channel/user_block.html'); + display_it(); +} +?> \ No newline at end of file diff --git a/upload/view_collection.php b/upload/view_collection.php new file mode 100644 index 00000000..7af803c1 --- /dev/null +++ b/upload/view_collection.php @@ -0,0 +1,73 @@ +page_redir(); + +$c = mysql_clean($_GET['cid']); +$type = mysql_clean($_GET['type']); + +$page = mysql_clean($_GET['page']); +$get_limit = create_query_limit($page,COLLIP); +$order = tbl("collection_items").".ci_id DESC"; + +if($cbcollection->is_viewable($c)) +{ + $param = array("type"=>$type,"cid"=>$c); + $cdetails = $cbcollection->get_collection($c,"AND ".tbl($cbcollection->section_tbl).".type = '$type' "); + + if($cdetails) + { + switch($type) + { + case "videos": + case "video": + case "v": + { + $items = $cbvideo->collection->get_collection_items_with_details($c,$order,$get_limit); + //$count = $cbvideo->collection->get_collection_items_with_details($c,NULL,NULL,TRUE); + } + break; + + case "photos": + case "photo": + case "p": + { + $items = $cbphoto->collection->get_collection_items_with_details($c,$order,$get_limit); + //$count = $cbphoto->collection->get_collection_items_with_details($c,NULL,NULL,TRUE); + } + break; + } + + // Calling nesscary function for view collection + call_view_collection_functions($cdetails[0]); + $total_pages = count_pages($count,COLLIP); + + //Pagination + $pages->paginate($total_pages,$page); + + assign('objects',$items); + assign("c",$cdetails); + assign("type",$type); + assign("cid",$c); + subtitle($cdetails['collection_name']); + } else { + e(lang("collection_not_exists")); + $Cbucket->show_page = false; + } +} else { + $Cbucket->show_page = false; +} + + +template_files('view_collection.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_group.php b/upload/view_group.php new file mode 100644 index 00000000..22228098 --- /dev/null +++ b/upload/view_group.php @@ -0,0 +1,111 @@ +page_redir(); + +$url = mysql_clean($_GET['url']); +$mode = $_GET['mode']; + +$details = $cbgroup->group_details_url($url); + + +if($details) +{ + $shouldView = $cbgroup->is_viewable($details); + if(!$shouldView) + $Cbucket->show_page = false; + else + { + assign('isviewable',$shouldView); + if(isset($_POST['update_group'])) + { + //pr($_POST,true); + $_POST['group_id'] = $details['group_id']; + $cbgroup->update_group(); + $details = $cbgroup->get_group_details($details['group_id']); + } + //Joining Group + if($_GET['join']) + $cbgroup->join_group($details['group_id'],userid()); + //Leaving + if($_GET['leave']) + $cbgroup->leave_group($details['group_id'],userid()); + + //adding group topic + if(isset($_POST['add_topic'])) + { + $array = $_POST; + $array['group_id'] = $details['group_id']; + $cbgroup->add_topic($array); + if(!error()) $_POST = NULL; + } + + // Sending invitations + if(isset($_POST['invite_friends'])) + $cbgroup->invite_members($_POST['friend'],$details['group_id']); + + //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"); + } + + //Calling all functions when a topic is called + call_view_group_functions($details); + + switch($mode) + { + case 'view_topics': + { + if($_GET['topic_action'] == "delete") + { + if(!empty($_GET['topic_id'])) { + $tid = $_GET['topic_id']; + $cbgroup->delete_topic($tid); + } + } + } + break; + } + + //Getting list of topics + $topics = $cbgroup->get_topics(array('group'=>$details['group_id'])); + assign('topics',$topics); + assign('mode',$mode); + assign('group',$details); + } + subtitle($details['group_name']); +}else +{ + e(lang("grp_exist_error")); + $Cbucket->show_page = false; +} + + +template_files('view_group.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_group_members.php b/upload/view_group_members.php new file mode 100644 index 00000000..371d23ad --- /dev/null +++ b/upload/view_group_members.php @@ -0,0 +1,33 @@ +page_redir(); + +$url = mysql_clean($_GET['url']); + + +$details = $cbgroup->group_details_url($url); +assign('group',$details); + +if($details) +{ + //Getting List of all videos + $videos = $cbgroup->get_members($details['group_id'],"yes"); + assign("users",$videos); + assign("mode","view_members"); + subtitle($details['group_name']); +} + +template_files('view_group.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_group_videos.php b/upload/view_group_videos.php new file mode 100644 index 00000000..9b4f9c37 --- /dev/null +++ b/upload/view_group_videos.php @@ -0,0 +1,44 @@ +page_redir(); + +$url = mysql_clean($_GET['url']); + + +$details = $cbgroup->group_details_url($url); +assign('group',$details); + +if($details) +{ + ///Getting User Videos + $page = mysql_clean($_GET['page']); + $get_limit = create_query_limit($page,28); + + //Getting List of all videos + $videos = $cbgroup->get_group_videos($details['group_id'],"yes",$get_limit); + + $total_rows = $details['total_videos']; + $total_pages = count_pages($total_rows,28); + //Pagination + $pages->paginate($total_pages,$page); + + + assign("videos",$videos); + assign("mode","view_videos"); + subtitle($details['group_name']); +} + +template_files('view_group.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_item.php b/upload/view_item.php new file mode 100644 index 00000000..5ca7d12f --- /dev/null +++ b/upload/view_item.php @@ -0,0 +1,115 @@ +is_viewable($cid)) +{ + if(empty($item)) + header('location:'.BASEURL); + else + { + if(empty($type)) + header('location:'.BASEURL); + else + { + assign('type',$type); + $param = array("type"=>$type,"cid"=>$cid); + $cdetails = $cbcollection->get_collections($param); + $collect = $cdetails[0]; + switch($type) + { + case "videos": + case "v": + { + global $cbvideo; + $video = $cbvideo->get_video($item); + + if(video_playable($video)) + { + //Getting list of collection items + $page = mysql_clean($_GET['page']); + $get_limit = create_query_limit($page,20); + $order = tbl("collection_items").".ci_id DESC"; + + $items = $cbvideo->collection->get_collection_items_with_details($cid,$order,$get_limit); + assign('items',$items); + + assign('open_collection','yes'); + $info = $cbvideo->collection->get_collection_item_fields($cid,$video['videoid'],'ci_id,collection_id'); + if($info) + { + $video = array_merge($video,$info[0]); + increment_views($video['videoid'],'video'); + + assign('object',$video); + assign('user',$userquery->get_user_details($video['userid'])); + assign('c',$collect); + + subtitle($video['title']); + + } else { + e(lang("item_not_exist")); + $Cbucket->show_page = false; + } + } else { + e(lang("item_not_exist")); + $Cbucket->show_page = false; + } + + + } + break; + + case "photos": + case "p": + { + global $cbphoto; + $photo = $cbphoto->get_photo($item); + if($photo) + { + $info = $cbphoto->collection->get_collection_item_fields($cid,$photo['photo_id'],'ci_id'); + if($info) + { + $photo = array_merge($photo,$info[0]); + increment_views($photo['photo_id'],'photo'); + + assign('object',$photo); + assign('user',$userquery->get_user_details($photo['userid'])); + assign('c',$collect); + + subtitle($photo['photo_title'].' « '.$collect['collection_name']); + } else { + e(lang("item_not_exist")); + $Cbucket->show_page = false; + } + } else { + e(lang("item_not_exist")); + $Cbucket->show_page = false; + } + } + break; + } + + } + } +} else + $Cbucket->show_page = false; + +template_files('view_item.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_page.php b/upload/view_page.php new file mode 100644 index 00000000..146725f8 --- /dev/null +++ b/upload/view_page.php @@ -0,0 +1,31 @@ +page_redir(); + +$pid = $_GET['pid']; +$pid = mysql_clean($pid); + +$page = $cbpage->get_page($pid); +if($page) +{ + assign('page',$page); + subtitle($page['page_title']); +}else{ + e(lang("page_doesnt_exist")); + $Cbucket->show_page = false; +} + +//Displaying The Template +template_files('view_page.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/view_topic.php b/upload/view_topic.php new file mode 100644 index 00000000..9d43ec6b --- /dev/null +++ b/upload/view_topic.php @@ -0,0 +1,41 @@ +page_redir(); + +$tid = $_GET['tid']; +$tid = mysql_clean($tid); + +$tdetails = $cbgroup->get_topic_details($tid); + +if($tdetails) +{ + $grp_details = $cbgroup->get_group_details($tdetails['group_id']); + if($grp_details['post_type'] == 1 && !$cbgroup->is_member(userid(),$grp_details['group_id'],TRUE)) { + if($cbgroup->is_member(userid(),$grp_details['group_id'])) + e(lang("view_tp_inactive_user")); + else + e(lang("view_tp_join")); + $Cbucket->show_page = false; + } else { + assign('group',$grp_details); + assign('topic',$tdetails); + subtitle($grp_details['group_name']); + //Calling all functions when a topic is called + call_view_topic_functions($tdetails); + } +} + +template_files('view_topic.html'); +display_it(); +?> \ No newline at end of file diff --git a/upload/watch_video.php b/upload/watch_video.php new file mode 100644 index 00000000..79577cdc --- /dev/null +++ b/upload/watch_video.php @@ -0,0 +1,82 @@ +perm_check('view_video',true); +$pages->page_redir(); + +//Getting Video Key +$vkey = @$_GET['v']; +$vkey = mysql_clean($vkey); + +$vdo = $cbvid->get_video($vkey); +assign('vdo',$vdo); +if(video_playable($vdo)) +{ + + /** + * Please check http://code.google.com/p/clipbucket/issues/detail?id=168 + * for more details about following code + */ + + if(SEO=='yes') + { + //Checking if Video URL is Exactly What we have created + $vid_link = videoLink($vdo); + $vid_link_seo = explode('/',$vid_link); + $vid_link_seo = $vid_link_seo[count($vid_link_seo) -1 ]; + + //What we are getting + $server_link = $_SERVER['REQUEST_URI']; + $server_link_seo = explode('/',$server_link); + $server_link_seo = $server_link_seo[count($server_link_seo) -1 ]; + + //Now finally Checking if both are equal else redirect to new link + if($vid_link_seo != $server_link_seo) + { + /*//Redirect to valid link leaving mark 301 Permanent Redirect + header ('HTTP/1.1 301 Moved Permanently'); + header ('Location: '.$vid_link); + exit();*/ + } + + } + + //Checking for playlist + $pid = $_GET['play_list']; + if(!empty($pid)) + { + $plist = $cbvid->action->get_playlist($pid,userid()); + if($plist) + $_SESSION['cur_playlist'] = $pid; + } + //Calling Functions When Video Is going to play + call_watch_video_function($vdo); + + subtitle($vdo['title']); + +}else + $Cbucket->show_page = false; + +//Return category id without '#' +$v_cat = $vdo['category']; +if($v_cat[2] =='#') { +$video_cat = $v_cat[1]; +}else{ +$video_cat = $v_cat[1].$v_cat[2];} +$vid_cat = str_replace('%#%','',$video_cat); +assign('vid_cat',$vid_cat); + + +//Displaying The Template +template_files('watch_video.html'); +display_it(); +?> \ No newline at end of file