2080 lines
75 KiB
PHP
2080 lines
75 KiB
PHP
|
|
<?php
|
||
|
|
/* $Id: class_club.php 167 2009-05-19 22:30:52Z szerrade $ */
|
||
|
|
|
||
|
|
// THIS CLASS CONTAINS club-RELATED METHODS
|
||
|
|
// TODO!: club_media_delete
|
||
|
|
//
|
||
|
|
// METHODS IN THIS CLASS:
|
||
|
|
// se_club()
|
||
|
|
// club_total()
|
||
|
|
// club_list()
|
||
|
|
// club_create()
|
||
|
|
// club_delete()
|
||
|
|
// club_delete_selected()
|
||
|
|
// club_lastupdate()
|
||
|
|
// club_privacy_max()
|
||
|
|
// club_member_total()
|
||
|
|
// club_member_list()
|
||
|
|
// club_dir()
|
||
|
|
// club_photo()
|
||
|
|
// club_photo_upload()
|
||
|
|
// club_photo_delete()
|
||
|
|
// club_media_upload()
|
||
|
|
// club_media_space()
|
||
|
|
// club_media_total()
|
||
|
|
// club_media_list()
|
||
|
|
// club_topic_list()
|
||
|
|
// club_topic_total()
|
||
|
|
// club_post_list()
|
||
|
|
// club_post_total()
|
||
|
|
// club_post_bbcode_parse_clean()
|
||
|
|
// club_post_bbcode_parse_view()
|
||
|
|
|
||
|
|
defined('SE_PAGE') or exit();
|
||
|
|
use Aws\S3\S3Client;
|
||
|
|
|
||
|
|
class se_club
|
||
|
|
{
|
||
|
|
// INITIALIZE VARIABLES
|
||
|
|
var $is_error; // DETERMINES WHETHER THERE IS AN ERROR OR NOT
|
||
|
|
var $error_message; // CONTAINS RELEVANT ERROR MESSAGE
|
||
|
|
var $user_id; // CONTAINS THE USER ID OF THE USER WHOSE clubS WE ARE EDITING
|
||
|
|
var $user_rank; // CONTAINS THE USER'S ASSOCIATION TO THE club (LEADER - 2, OFFICER - 1, MEMBER - 0, NOT AFFILIATED - -1)
|
||
|
|
var $club_exists; // DETERMINES WHETHER THE club HAS BEEN SET AND EXISTS OR NOT
|
||
|
|
var $club_info; // CONTAINS THE club INFO OF THE club WE ARE EDITING
|
||
|
|
var $clubvalue_info; // CONTAINS THE clubVALUE INFO OF THE club WE ARE EDITING
|
||
|
|
var $clubowner_level_info; // CONTAINS THE club OWNER'S LEVEL INFO FOR THE club WE ARE EDITING
|
||
|
|
var $clubmember_info; // CONTAINS THE USER'S ASSOCIATION TO THE club FROM clubMEMBER TABLE
|
||
|
|
var $moderation_privacy; // CONTAINS THE PRIVACY LEVEL THAT IS ALLOWED TO MODERATE FOR THIS USER
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD SETS INITIAL VARS
|
||
|
|
// INPUT: $user_id (OPTIONAL) REPRESENTING THE USER ID OF THE USER WHOSE clubS WE ARE CONCERNED WITH
|
||
|
|
// $club_id (OPTIONAL) REPRESENTING THE club ID OF THE club WE ARE CONCERNED WITH
|
||
|
|
// OUTPUT:
|
||
|
|
function __construct($user_id = 0, $club_id = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
$this->user_id = $user_id;
|
||
|
|
$this->club_exists = 0;
|
||
|
|
$this->user_rank = -1;
|
||
|
|
$this->moderation_privacy = 3;
|
||
|
|
|
||
|
|
if( $club_id )
|
||
|
|
{
|
||
|
|
$club = $database->database_query("SELECT * FROM se_clubs WHERE club_id='{$club_id}' AND approved='1' LIMIT 1");
|
||
|
|
if($database->database_num_rows($club) == 1)
|
||
|
|
{
|
||
|
|
$this->club_exists = 1;
|
||
|
|
$this->club_info = $database->database_fetch_assoc($club);
|
||
|
|
|
||
|
|
$query1 = $database->database_query("SELECT user_username FROM se_users WHERE user_id='".$this->club_info['club_user_id']."'");
|
||
|
|
$row1=$database->database_fetch_array($query1);
|
||
|
|
$this->club_info['owner_username'] = $row1['user_username'];
|
||
|
|
$this->clubvalue_info = $database->database_fetch_assoc($database->database_query("SELECT * FROM se_clubvalues WHERE clubvalue_club_id='{$club_id}'"));
|
||
|
|
$this->clubowner_level_info = $database->database_fetch_assoc($database->database_query("SELECT se_levels.* FROM se_users LEFT JOIN se_levels ON se_users.user_level_id=se_levels.level_id WHERE se_users.user_id='{$this->club_info['club_user_id']}'"));
|
||
|
|
|
||
|
|
if( $this->user_id )
|
||
|
|
{
|
||
|
|
$clubmember = $database->database_query("SELECT clubmember_id, clubmember_rank, clubmember_status, clubmember_approved FROM se_clubmembers WHERE clubmember_user_id='{$this->user_id}' AND clubmember_club_id='{$club_id}' LIMIT 1");
|
||
|
|
if($database->database_num_rows($clubmember) == 1)
|
||
|
|
{
|
||
|
|
$this->clubmember_info = $database->database_fetch_assoc($clubmember);
|
||
|
|
if($this->clubmember_info['clubmember_status'] == 1)
|
||
|
|
{
|
||
|
|
$this->user_rank = $this->clubmember_info['clubmember_rank'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} // END se_club() METHOD
|
||
|
|
|
||
|
|
function club_totalowner($where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database, $user;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
NULL
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
/*
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers AS member_table
|
||
|
|
ON se_clubs.club_id=member_table.clubmember_club_id AND member_table.clubmember_status='1' AND member_table.clubmember_approved='1'
|
||
|
|
*/
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE club_user_id='".$user->user_info["user_id"]."'";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
$club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'";
|
||
|
|
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
$club_query .= " AND";
|
||
|
|
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " $where"; }
|
||
|
|
|
||
|
|
// ADD club BY
|
||
|
|
//$club_query .= " club BY club_id";
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$club_total = $database->database_num_rows($database->database_query($club_query));
|
||
|
|
return $club_total;
|
||
|
|
}
|
||
|
|
|
||
|
|
function club_listowner($start, $limit, $sort_by = "club_id DESC", $where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database, $user;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
se_clubs.*
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username,
|
||
|
|
se_users.user_fname,
|
||
|
|
se_users.user_lname,
|
||
|
|
se_users.user_photo
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE club_user_id='".$user->user_info["user_id"]."'";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
$club_query .= " AND ";
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$club_query .= "
|
||
|
|
/*
|
||
|
|
club BY
|
||
|
|
club_id
|
||
|
|
*/
|
||
|
|
ORDER BY
|
||
|
|
{$sort_by}
|
||
|
|
LIMIT
|
||
|
|
{$start}, {$limit}
|
||
|
|
";
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubs = $database->database_query($club_query);
|
||
|
|
|
||
|
|
// GET clubS INTO AN ARRAY
|
||
|
|
$club_array = Array();
|
||
|
|
while($club_info = $database->database_fetch_assoc($clubs))
|
||
|
|
{
|
||
|
|
// CREATE OBJECT FOR LEADER
|
||
|
|
if($user->user_info['user_id'] == $club_info['club_user_id'])
|
||
|
|
{
|
||
|
|
$leader = $user;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$leader = new se_user();
|
||
|
|
$leader->user_exists = 1;
|
||
|
|
$leader->user_info['user_id'] = $club_info['user_id'];
|
||
|
|
$leader->user_info['user_username'] = $club_info['user_username'];
|
||
|
|
$leader->user_info['user_photo'] = $club_info['user_photo'];
|
||
|
|
$leader->user_info['user_fname'] = $club_info['user_fname'];
|
||
|
|
$leader->user_info['user_lname'] = $club_info['user_lname'];
|
||
|
|
$leader->user_displayname();
|
||
|
|
}
|
||
|
|
|
||
|
|
// CREATE OBJECT FOR club
|
||
|
|
$club = new se_club($club_info['user_id']);
|
||
|
|
$club->club_exists = TRUE;
|
||
|
|
$club->club_info= $club_info;
|
||
|
|
|
||
|
|
// SET club ARRAY
|
||
|
|
$club_array[] = Array(
|
||
|
|
'club' => $club,
|
||
|
|
'club_leader' => $leader,
|
||
|
|
'club_rank' => $club_info['clubmember_rank'],
|
||
|
|
'club_members' => $club_info['num_members']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $club_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE TOTAL NUMBER OF clubS
|
||
|
|
// INPUT: $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// $club_details (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO RETRIEVE TOTAL MEMBERS, club LEADER, ETC
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE NUMBER OF clubS
|
||
|
|
function club_total($where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
NULL
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
/*
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers AS member_table
|
||
|
|
ON se_clubs.club_id=member_table.clubmember_club_id AND member_table.clubmember_status='1' AND member_table.clubmember_approved='1'
|
||
|
|
*/
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE approved=1 ";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
|
||
|
|
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " AND $where"; }
|
||
|
|
|
||
|
|
// ADD club BY
|
||
|
|
//$club_query .= " club BY club_id";
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$club_total = $database->database_num_rows($database->database_query($club_query));
|
||
|
|
return $club_total;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_total() METHOD
|
||
|
|
function club_admin_total($where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
NULL
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
/*
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers AS member_table
|
||
|
|
ON se_clubs.club_id=member_table.clubmember_club_id AND member_table.clubmember_status='1' AND member_table.clubmember_approved='1'
|
||
|
|
*/
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE 1=1 ";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
|
||
|
|
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " AND $where"; }
|
||
|
|
|
||
|
|
// ADD club BY
|
||
|
|
//$club_query .= " club BY club_id";
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$club_total = $database->database_num_rows($database->database_query($club_query));
|
||
|
|
return $club_total;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF clubS
|
||
|
|
// INPUT: $start REPRESENTING THE club TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF clubS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// $club_details (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO RETRIEVE TOTAL MEMBERS, club LEADER, ETC
|
||
|
|
// OUTPUT: AN ARRAY OF clubS
|
||
|
|
|
||
|
|
function club_list($start, $limit, $sort_by = "club_id DESC", $where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database, $user;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
se_clubs.*
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username,
|
||
|
|
se_users.user_fname,
|
||
|
|
se_users.user_lname,
|
||
|
|
se_users.user_photo
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE approved=1 ";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " AND $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$club_query .= "
|
||
|
|
/*
|
||
|
|
club BY
|
||
|
|
club_id
|
||
|
|
*/
|
||
|
|
ORDER BY
|
||
|
|
{$sort_by}
|
||
|
|
LIMIT
|
||
|
|
{$start}, {$limit}
|
||
|
|
";
|
||
|
|
// RUN QUERY
|
||
|
|
$clubs = $database->database_query($club_query);
|
||
|
|
|
||
|
|
// GET clubS INTO AN ARRAY
|
||
|
|
$club_array = Array();
|
||
|
|
while($club_info = $database->database_fetch_assoc($clubs))
|
||
|
|
{
|
||
|
|
// CREATE OBJECT FOR LEADER
|
||
|
|
if($user->user_info['user_id'] == $club_info['club_user_id'])
|
||
|
|
{
|
||
|
|
$leader = $user;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$leader = new se_user();
|
||
|
|
$leader->user_exists = 1;
|
||
|
|
$leader->user_info['user_id'] = $club_info['user_id'];
|
||
|
|
$leader->user_info['user_username'] = $club_info['user_username'];
|
||
|
|
$leader->user_info['user_photo'] = $club_info['user_photo'];
|
||
|
|
$leader->user_info['user_fname'] = $club_info['user_fname'];
|
||
|
|
$leader->user_info['user_lname'] = $club_info['user_lname'];
|
||
|
|
$leader->user_displayname();
|
||
|
|
}
|
||
|
|
|
||
|
|
// CREATE OBJECT FOR club
|
||
|
|
$club = new se_club($club_info['user_id']);
|
||
|
|
$club->club_exists = TRUE;
|
||
|
|
$club->club_info= $club_info;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
if(SE_DEBUG1){
|
||
|
|
$query = $database->database_query("SELECT COUNT(*) FROM se_clubmembers, se_users WHERE user_id=clubmember_user_id AND clubmember_club_id='".$club_info['club_id']."' AND clubmember_status=0 AND clubmember_approved=0 AND user_enabled=1");
|
||
|
|
$pending_members=$database->database_result($query, 0);
|
||
|
|
$club->club_info["pending_members"]= $pending_members;
|
||
|
|
|
||
|
|
}
|
||
|
|
// SET club ARRAY
|
||
|
|
$club_array[] = Array(
|
||
|
|
'club' => $club,
|
||
|
|
'club_leader' => $leader,
|
||
|
|
'club_rank' => $club_info['clubmember_rank'],
|
||
|
|
'club_members' => $club_info['num_members']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $club_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function club_admin_list($start, $limit, $sort_by = "club_id DESC", $where = "", $club_details = 0)
|
||
|
|
{
|
||
|
|
global $database, $user;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "
|
||
|
|
SELECT
|
||
|
|
se_clubs.*
|
||
|
|
";
|
||
|
|
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= ",
|
||
|
|
se_clubs.club_totalmembers AS num_members,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username,
|
||
|
|
se_users.user_fname,
|
||
|
|
se_users.user_lname,
|
||
|
|
se_users.user_photo
|
||
|
|
";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if( $this->user_id ) $club_query .= ",
|
||
|
|
se_clubmembers.clubmember_rank
|
||
|
|
";
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubs
|
||
|
|
";
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if( $this->user_id ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubmembers
|
||
|
|
ON se_clubmembers.clubmember_club_id=se_clubs.club_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if( $club_details ) $club_query .= "
|
||
|
|
LEFT JOIN
|
||
|
|
se_users
|
||
|
|
ON se_clubs.club_user_id=se_users.user_id
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$club_query .= " WHERE 1=1 ";
|
||
|
|
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " AND se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " AND $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$club_query .= "
|
||
|
|
/*
|
||
|
|
club BY
|
||
|
|
club_id
|
||
|
|
*/
|
||
|
|
ORDER BY
|
||
|
|
{$sort_by}
|
||
|
|
LIMIT
|
||
|
|
{$start}, {$limit}
|
||
|
|
";
|
||
|
|
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubs = $database->database_query($club_query);
|
||
|
|
|
||
|
|
|
||
|
|
// GET clubS INTO AN ARRAY
|
||
|
|
$club_array = Array();
|
||
|
|
while($club_info = $database->database_fetch_assoc($clubs))
|
||
|
|
{
|
||
|
|
// CREATE OBJECT FOR LEADER
|
||
|
|
if($user->user_info['user_id'] == $club_info['club_user_id'])
|
||
|
|
{
|
||
|
|
$leader = $user;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$leader = new se_user();
|
||
|
|
$leader->user_exists = 1;
|
||
|
|
$leader->user_info['user_id'] = $club_info['user_id'];
|
||
|
|
$leader->user_info['user_username'] = $club_info['user_username'];
|
||
|
|
$leader->user_info['user_photo'] = $club_info['user_photo'];
|
||
|
|
$leader->user_info['user_fname'] = $club_info['user_fname'];
|
||
|
|
$leader->user_info['user_lname'] = $club_info['user_lname'];
|
||
|
|
$leader->user_displayname();
|
||
|
|
}
|
||
|
|
|
||
|
|
// CREATE OBJECT FOR club
|
||
|
|
$club = new se_club($club_info['user_id']);
|
||
|
|
$club->club_exists = TRUE;
|
||
|
|
$club->club_info= $club_info;
|
||
|
|
|
||
|
|
// SET club ARRAY
|
||
|
|
$club_array[] = Array(
|
||
|
|
'club' => $club,
|
||
|
|
'club_leader' => $leader,
|
||
|
|
'club_rank' => $club_info['clubmember_rank'],
|
||
|
|
'club_members' => $club_info['num_members']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $club_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_list() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD CREATES A NEW club
|
||
|
|
// INPUT: $club_title REPRESENTING THE club TITLE
|
||
|
|
// $club_desc REPRESENTING THE club DESCRIPTION
|
||
|
|
// $club_clubcat_id REPRESENTING THE club CATEGORY ID
|
||
|
|
// $club_approval REPRESENTING WHETHER THE LEADER MUST APPROVE MEMBERSHIP REQUESTS
|
||
|
|
// $club_invite REPRESENTING WHETHER MEMBERS CAN INVITE FRIENDS TO JOIN
|
||
|
|
// $club_search REPRESENTING WHETHER THE club SHOULD BE SEARCHABLE
|
||
|
|
// $club_privacy REPRESENTING THE PRIVACY OF THE club
|
||
|
|
// $club_comments REPRESENTING WHO CAN POST COMMENTS ON THE club
|
||
|
|
// $club_discussion REPRESENTING WHO CAN CREATE AND POST IN DISCUSSION TOPICS IN THIS club
|
||
|
|
// $club_upload REPRESENTING WHO CAN UPLOAD PHOTOS IN THIS club
|
||
|
|
// $clubalbum_tag REPRESENTING WHO CAN TAG PHOTOS IN THIS club
|
||
|
|
// $club_field_query REPRESENTING THE PARTIAL QUERY TO SAVE IN THE club'S VALUE TABLE
|
||
|
|
// OUTPUT: THE NEWLY CREATED club'S club ID
|
||
|
|
function club_create($club_title, $club_desc, $club_clubcat_id, $club_approval, $club_invite, $club_search, $club_privacy, $club_comments, $club_discussion, $club_upload, $clubalbum_tag, $club_field_query) {
|
||
|
|
global $database;
|
||
|
|
$datecreated = time();
|
||
|
|
// ADD ROW TO clubS TABLE
|
||
|
|
$database->database_query("
|
||
|
|
INSERT INTO se_clubs (
|
||
|
|
club_user_id,
|
||
|
|
club_clubcat_id,
|
||
|
|
club_datecreated,
|
||
|
|
club_dateupdated,
|
||
|
|
club_title,
|
||
|
|
club_desc,
|
||
|
|
club_search,
|
||
|
|
club_privacy,
|
||
|
|
club_comments,
|
||
|
|
club_discussion,
|
||
|
|
club_upload,
|
||
|
|
club_approval,
|
||
|
|
club_invite,
|
||
|
|
club_totalmembers, displayofficers, category
|
||
|
|
) VALUES (
|
||
|
|
'{$this->user_id}',
|
||
|
|
'{$club_clubcat_id}',
|
||
|
|
'{$datecreated}',
|
||
|
|
'{$datecreated}',
|
||
|
|
'{$club_title}',
|
||
|
|
'{$club_desc}',
|
||
|
|
'{$club_search}',
|
||
|
|
'{$club_privacy}',
|
||
|
|
'{$club_comments}',
|
||
|
|
'{$club_discussion}',
|
||
|
|
'{$club_upload}',
|
||
|
|
'{$club_approval}',
|
||
|
|
'{$club_invite}',
|
||
|
|
'1', '".$database->database_real_escape_string($_POST["displayofficers"])."', '".$database->database_real_escape_string($_POST["category"])."'
|
||
|
|
)
|
||
|
|
");
|
||
|
|
|
||
|
|
$club_id = $database->database_insert_id();
|
||
|
|
|
||
|
|
// ADD club FIELD VALUES
|
||
|
|
$database->database_query("INSERT INTO se_clubvalues (clubvalue_club_id) VALUES ('$club_id')");
|
||
|
|
if($club_field_query != "") {
|
||
|
|
$database->database_query("UPDATE se_clubvalues SET $club_field_query WHERE clubvalue_club_id='$club_id'");
|
||
|
|
}
|
||
|
|
// MAKE OWNER A MEMBER
|
||
|
|
$database->database_query("INSERT IGNORE INTO se_clubmembers (clubmember_user_id, clubmember_club_id, clubmember_status, clubmember_approved, clubmember_rank) VALUES ('".$this->user_id."', '$club_id', '1', '1', '2')");
|
||
|
|
|
||
|
|
addspampoint(15, $this->user_id);
|
||
|
|
wrapup("create_club");
|
||
|
|
// ADD club STYLES ROW
|
||
|
|
// $database->database_query("INSERT INTO se_clubstyles (clubstyle_club_id) VALUES ('$club_id')");
|
||
|
|
// ADD club ALBUM
|
||
|
|
$database->database_query("INSERT INTO se_clubalbums (clubalbum_club_id, clubalbum_datecreated, clubalbum_dateupdated, clubalbum_title, clubalbum_desc, clubalbum_search, clubalbum_privacy, clubalbum_comments, clubalbum_tag) VALUES ('$club_id', '$datecreated', '$datecreated', '', '', '$club_search', '$club_privacy', '$club_comments', '$clubalbum_tag')");
|
||
|
|
// ADD club DIRECTORY
|
||
|
|
$club_directory = $this->club_dir($club_id);
|
||
|
|
$club_path_array = explode("/", $club_directory);
|
||
|
|
array_pop($club_path_array);
|
||
|
|
array_pop($club_path_array);
|
||
|
|
$subdir = implode("/", $club_path_array)."/";
|
||
|
|
/* if(!is_dir($subdir)) {
|
||
|
|
mkdir($subdir, 0777);
|
||
|
|
chmod($subdir, 0777);
|
||
|
|
$handle = fopen($subdir."index.php", 'x+');
|
||
|
|
fclose($handle);
|
||
|
|
}
|
||
|
|
mkdir($club_directory, 0777);
|
||
|
|
chmod($club_directory, 0777);
|
||
|
|
$handle = fopen($club_directory."/index.php", 'x+');
|
||
|
|
fclose($handle);*/
|
||
|
|
return $club_id;
|
||
|
|
} // END club_create() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD DELETES A club
|
||
|
|
// INPUT: $club_id (OPTIONAL) REPRESENTING THE ID OF THE club TO DELETE
|
||
|
|
// OUTPUT:
|
||
|
|
function club_delete($club_id = 0) {
|
||
|
|
global $database;
|
||
|
|
if($club_id == 0) { $club_id = $this->club_info['club_id']; }
|
||
|
|
|
||
|
|
$query=$database->database_query("SELECT * FROM se_clubmedia, se_clubalbums WHERE se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id AND se_clubalbums.clubalbum_club_id='$club_id'");
|
||
|
|
|
||
|
|
while($row=$database->database_fetch_array($query))
|
||
|
|
{
|
||
|
|
|
||
|
|
$database->database_query("DELETE FROM se_clubmediacomments WHERE clubmediacomment_clubmedia_id='".$row["clubmedia_id"]."'");
|
||
|
|
}
|
||
|
|
|
||
|
|
$query=$database->database_query("SELECT * FROM se_club_videos WHERE video_club_id='$club_id'");
|
||
|
|
while($row=$database->database_fetch_array($query))
|
||
|
|
{
|
||
|
|
$database->database_query("DELETE FROM clubvideocomments WHERE object_id='".$row["video_id"]."'");
|
||
|
|
$database->database_query("DELETE FROM clubvideoratings WHERE video_id='".$row["video_id"]."'");
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
$database->database_query("DELETE FROM se_club_videos WHERE video_club_id='$club_id'");
|
||
|
|
|
||
|
|
|
||
|
|
$query=$database->database_query("SELECT * FROM se_clubmedia, se_clubalbums WHERE se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id AND se_clubalbums.clubalbum_club_id='$club_id'");
|
||
|
|
while($row=$database->database_fetch_array($query))
|
||
|
|
{
|
||
|
|
|
||
|
|
|
||
|
|
$database->database_query("DELETE FROM se_clubmedia WHERE clubmedia_id='".$row["clubmedia_id"]."'");
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
// DELETE club ALBUM, MEDIA, MEDIA COMMENTS
|
||
|
|
$database->database_query("DELETE FROM se_clubalbums WHERE se_clubalbums.clubalbum_club_id='$club_id'");
|
||
|
|
//$database->database_query("DELETE FROM se_clubmedia WHERE se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id AND se_clubalbums.clubalbum_club_id='$club_id'");
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// DELETE ALL MEMBERS
|
||
|
|
$database->database_query("DELETE FROM se_clubmembers WHERE se_clubmembers.clubmember_club_id='$club_id'");
|
||
|
|
// DELETE ALL SUBSCRIPTIONS
|
||
|
|
$database->database_query("DELETE FROM se_clubsubscribes WHERE se_clubsubscribes.clubsubscribe_club_id='$club_id'");
|
||
|
|
// DELETE club VALUES
|
||
|
|
$database->database_query("DELETE FROM se_clubvalues WHERE se_clubvalues.clubvalue_club_id='$club_id'");
|
||
|
|
// DELETE club STYLE
|
||
|
|
//$database->database_query("DELETE FROM se_clubstyles WHERE clubstyle_club_id='$club_id'");
|
||
|
|
|
||
|
|
// DELETE club ROW
|
||
|
|
$database->database_query("DELETE FROM se_clubs WHERE se_clubs.club_id='$club_id'");
|
||
|
|
|
||
|
|
// DELETE club COMMENTS
|
||
|
|
$database->database_query("DELETE FROM se_clubcomments WHERE se_clubcomments.clubcomment_club_id='$club_id'");
|
||
|
|
|
||
|
|
// DELETE club DISCUSSION POSTS
|
||
|
|
$database->database_query("DELETE FROM se_clubposts WHERE clubpost_clubtopic_id IN (SELECT clubtopic_id from se_clubtopics WHERE clubtopic_club_id='$club_id')");
|
||
|
|
// DELETE club DISCUSSION TOPICS
|
||
|
|
$database->database_query("DELETE FROM se_clubtopics WHERE clubtopic_club_id='$club_id'");
|
||
|
|
|
||
|
|
// DELETE club'S FILES
|
||
|
|
if(is_dir($this->club_dir($club_id))) {
|
||
|
|
$dir = $this->club_dir($club_id);
|
||
|
|
} else {
|
||
|
|
$dir = ".".$this->club_dir($club_id);
|
||
|
|
}
|
||
|
|
|
||
|
|
$client = new MyS3Wrapper([
|
||
|
|
'region' => 'us-north-1',
|
||
|
|
'version' => 'latest',
|
||
|
|
'endpoint' => ENDPOINT,
|
||
|
|
'credentials' => [
|
||
|
|
'key' => AWS_KEY,
|
||
|
|
'secret' => AWS_SECRET_KEY
|
||
|
|
],
|
||
|
|
|
||
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
||
|
|
// instead of bucket.objects.dreamhost.com
|
||
|
|
'use_path_style_endpoint' => true
|
||
|
|
]);
|
||
|
|
|
||
|
|
if($dh = @opendir($dir)) {
|
||
|
|
while(($file = @readdir($dh)) !== false) {
|
||
|
|
if($file != "." & $file != "..") {
|
||
|
|
@unlink($dir.$file);
|
||
|
|
@unlink($dir.str_replace(".", "_thumb.", $file));
|
||
|
|
|
||
|
|
try {
|
||
|
|
$client->deleteObject(array(
|
||
|
|
'Bucket'=>'bateworld',
|
||
|
|
'Key' => str_replace("./", "", $dir).$file,
|
||
|
|
|
||
|
|
));}catch (Exception $e) {}
|
||
|
|
try {
|
||
|
|
$client->deleteObject(array(
|
||
|
|
'Bucket'=>'bateworld',
|
||
|
|
'Key' => str_replace("./", "", $dir).str_replace(".", "_thumb.", $file),
|
||
|
|
|
||
|
|
));}catch (Exception $e) {}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
@closedir($dh);
|
||
|
|
}
|
||
|
|
@rmdir($dir);
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_delete() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD DELETES SELECTED clubS
|
||
|
|
// INPUT: $start REPRESENTING THE club TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF clubS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// $club_details (OPTIONAL) REPRESENTING A BOOLEAN THAT DETERMINES WHETHER TO RETRIEVE TOTAL MEMBERS, club LEADER, ETC
|
||
|
|
// OUTPUT: AN ARRAY OF clubS
|
||
|
|
function club_delete_selected($start, $limit, $sort_by = "club_id DESC", $where = "", $club_details = 0) {
|
||
|
|
global $database, $user;
|
||
|
|
// BEGIN QUERY
|
||
|
|
$club_query = "SELECT se_clubs.club_id";
|
||
|
|
// SELECT RELEVANT club DETAILS IF NECESSARY
|
||
|
|
if($club_details == 1) { $club_query .= ", count(member_table.clubmember_id) AS num_members, se_users.user_id, se_users.user_username, se_users.user_photo"; }
|
||
|
|
// IF USER ID NOT EMPTY, GET USER AS MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= ", se_clubmembers.clubmember_rank"; }
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$club_query .= " FROM";
|
||
|
|
// IF USER ID NOT EMPTY, SELECT FROM clubMEMBER TABLE
|
||
|
|
if($this->user_id != 0) {
|
||
|
|
$club_query .= " se_clubmembers LEFT JOIN se_clubs ON se_clubmembers.clubmember_club_id=se_clubs.club_id ";
|
||
|
|
} else {
|
||
|
|
$club_query .= " se_clubs";
|
||
|
|
}
|
||
|
|
// CONTINUE QUERY IF NECESSARY
|
||
|
|
if($club_details == 1) { $club_query .= " LEFT JOIN se_clubmembers AS member_table ON se_clubs.club_id=member_table.clubmember_club_id AND member_table.clubmember_status='1' AND member_table.clubmember_approved='1' LEFT JOIN se_users ON se_clubs.club_user_id=se_users.user_id"; }
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($where != "" || $this->user_id != 0) { $club_query .= " WHERE"; }
|
||
|
|
// IF USER ID NOT EMPTY, MAKE SURE USER IS A MEMBER
|
||
|
|
if($this->user_id != 0) { $club_query .= " se_clubmembers.clubmember_user_id='{$this->user_id}'"; }
|
||
|
|
// INSERT AND IF NECESSARY
|
||
|
|
if($this->user_id != 0 && $where != "") { $club_query .= " AND"; }
|
||
|
|
// ADD WHERE CLAUSE, IF NECESSARY
|
||
|
|
if($where != "") { $club_query .= " $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$club_query .= " club BY club_id ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
// RUN QUERY
|
||
|
|
$clubs = $database->database_query($club_query);
|
||
|
|
// GET clubS INTO AN ARRAY
|
||
|
|
while($club_info = $database->database_fetch_assoc($clubs))
|
||
|
|
{
|
||
|
|
$var = "delete_club_".$club_info['club_id'];
|
||
|
|
if($_POST[$var] == 1)
|
||
|
|
{
|
||
|
|
$this->club_delete($club_info['club_id']);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
} // END club_delete_selected() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD UPDATES THE club'S LAST UPDATE DATE
|
||
|
|
// INPUT:
|
||
|
|
// OUTPUT:
|
||
|
|
function club_lastupdate() {
|
||
|
|
global $database;
|
||
|
|
$database->database_query("UPDATE se_clubs SET club_dateupdated='".time()."' WHERE club_id='{$this->club_info['club_id']}' LIMIT 1");
|
||
|
|
|
||
|
|
} // END club_lastupdate() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS MAXIMUM PRIVACY LEVEL VIEWABLE BY A USER WITH REGARD TO THE CURRENT club
|
||
|
|
// INPUT: $other_user REPRESENTING A USER OBJECT
|
||
|
|
// OUTPUT: RETURNS PRIVACY LEVEL OF GIVEN USER WITH RESPECT TO CURRENT club
|
||
|
|
function club_privacy_max($user) {
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
switch(TRUE) {
|
||
|
|
// club LEADER
|
||
|
|
case($this->club_info['club_user_id'] == $user->user_info['user_id']):
|
||
|
|
return 1;
|
||
|
|
break;
|
||
|
|
// club OFFICER
|
||
|
|
case($database->database_num_rows($database->database_query("SELECT clubmember_id FROM se_clubmembers WHERE clubmember_user_id='{$user->user_info['user_id']}' AND clubmember_club_id='{$this->club_info['club_id']}' AND clubmember_status='1' AND clubmember_rank='1'")) != 0):
|
||
|
|
return 2;
|
||
|
|
break;
|
||
|
|
// club MEMBER
|
||
|
|
case($database->database_num_rows($database->database_query("SELECT clubmember_id FROM se_clubmembers WHERE clubmember_user_id='{$user->user_info['user_id']}' AND clubmember_club_id='{$this->club_info['club_id']}' AND clubmember_status='1'")) != 0):
|
||
|
|
return 4;
|
||
|
|
break;
|
||
|
|
// club LEADER'S FRIEND
|
||
|
|
/*case($database->database_num_rows($database->database_query("SELECT friend_id FROM se_friends WHERE friend_status='1' AND friend_user_id1='{$this->club_info['club_user_id']}' AND friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
||
|
|
return 8;
|
||
|
|
break;
|
||
|
|
// club MEMBER'S FRIEND
|
||
|
|
/*case($database->database_num_rows($database->database_query("SELECT se_friends.friend_id FROM se_clubmembers LEFT JOIN se_friends ON se_clubmembers.clubmember_user_id=se_friends.friend_user_id1 WHERE se_clubmembers.clubmember_status='1' AND se_clubmembers.clubmember_club_id='{$this->club_info['club_id']}' AND se_friends.friend_status='1' AND se_friends.friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
||
|
|
return 16;
|
||
|
|
break;
|
||
|
|
|
||
|
|
// FRIEND OF club MEMBER'S FRIENDS
|
||
|
|
/*case($database->database_num_rows($database->database_query("SELECT t2.friend_user_id2 FROM se_clubmembers LEFT JOIN se_friends AS t1 ON se_clubmembers.clubmember_user_id=t1.friend_user_id1 LEFT JOIN se_friends AS t2 ON t1.friend_user_id2=t2.friend_user_id1 WHERE se_clubmembers.clubmember_status='1' AND se_clubmembers.clubmember_club_id='{$this->club_info['club_id']}' AND t1.friend_status='1' AND t2.friend_status='1' AND t2.friend_user_id2='{$user->user_info['user_id']}'")) != 0):
|
||
|
|
return 32;
|
||
|
|
break;
|
||
|
|
*/
|
||
|
|
// REGISTERED USER
|
||
|
|
case($user->user_exists == 1):
|
||
|
|
return 64;
|
||
|
|
break;
|
||
|
|
// DEFAULT EVERYONE
|
||
|
|
default:
|
||
|
|
return 128;
|
||
|
|
}
|
||
|
|
} // END club_privacy_max() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE TOTAL NUMBER OF MEMBERS IN A club
|
||
|
|
// INPUT: $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// $member_details (OPTIONAL) REPRESENTING WHETHER TO JOIN TO THE USER TABLE FOR SEARCH PURPOSES
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE NUMBER OF club MEMBERS
|
||
|
|
function club_member_total($where = "", $member_details = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// See if it has been cached in parent table
|
||
|
|
if( !$where && isset($this->club_info['club_totalmembers']) )
|
||
|
|
return $this->club_info['club_totalmembers'];
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmember_query = "SELECT NULL FROM se_clubmembers";
|
||
|
|
// JOIN TO USER TABLE IF NECESSARY
|
||
|
|
//if($member_details == 1)
|
||
|
|
{ $clubmember_query .= " LEFT JOIN se_users ON se_clubmembers.clubmember_user_id=se_users.user_id "; }
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($this->club_exists != 0)
|
||
|
|
{ $clubmember_query .= " WHERE se_users.user_enabled=1 "; }
|
||
|
|
// IF club ID IS SET
|
||
|
|
if($this->club_exists != 0) { $clubmember_query .= " AND se_clubmembers.clubmember_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmember_query .= " "; }
|
||
|
|
// ADD REST OF WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmember_query .= " AND $where"; }
|
||
|
|
//if(SE_DEBUG){echo $clubmember_query;}
|
||
|
|
// RUN QUERY
|
||
|
|
$clubmember_total = $database->database_num_rows($database->database_query($clubmember_query));
|
||
|
|
return $clubmember_total;
|
||
|
|
} // END club_member_total() METHOD
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF club MEMBERS
|
||
|
|
// INPUT: $start REPRESENTING THE club MEMBER TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF club MEMBERS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN ARRAY OF club MEMBERS
|
||
|
|
function club_member_list1($start, $limit, $sort_by = "clubmember_id DESC", $where = "") {
|
||
|
|
global $database, $user;
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmember_query = "SELECT
|
||
|
|
se_clubmembers.*,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username,
|
||
|
|
se_users.user_fname,
|
||
|
|
se_users.user_lname,
|
||
|
|
se_users.user_photo,
|
||
|
|
se_users.user_dateupdated,
|
||
|
|
se_users.user_lastlogindate,
|
||
|
|
se_users.user_signupdate,
|
||
|
|
CASE
|
||
|
|
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_users.user_id AND friend_status='1' LIMIT 1)
|
||
|
|
THEN 2
|
||
|
|
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_users.user_id AND friend_status='0' LIMIT 1)
|
||
|
|
THEN 1
|
||
|
|
ELSE 0
|
||
|
|
END
|
||
|
|
AS is_viewers_friend,
|
||
|
|
CASE
|
||
|
|
WHEN (SELECT TRUE FROM se_users AS se_users2 WHERE se_users2.user_id=se_users.user_id AND (user_blocklist LIKE '{$user->user_info['user_id']},%' OR user_blocklist LIKE '%,{$user->user_info['user_id']}' OR user_blocklist LIKE '%,{$user->user_info['user_id']},%') LIMIT 1)
|
||
|
|
THEN TRUE
|
||
|
|
ELSE FALSE
|
||
|
|
END
|
||
|
|
AS is_viewer_blocklisted
|
||
|
|
FROM se_clubmembers
|
||
|
|
LEFT JOIN se_users
|
||
|
|
ON se_clubmembers.clubmember_user_id=se_users.user_id";
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
//if($this->club_exists != 0 || $where != "") { $clubmember_query .= " WHERE"; }
|
||
|
|
if($this->club_exists != 0)
|
||
|
|
{ $clubmember_query .= " WHERE se_users.user_enabled=1 "; }
|
||
|
|
// IF club ID IS SET
|
||
|
|
if($this->club_exists != 0) { $clubmember_query .= " AND se_clubmembers.clubmember_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmember_query .= " "; }
|
||
|
|
// ADD REST OF WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmember_query .= " AND $where"; }
|
||
|
|
// ADD ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubmember_query .= " ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubmembers = $database->database_query($clubmember_query);
|
||
|
|
// GET club MEMBERS INTO AN ARRAY
|
||
|
|
$clubmember_array = Array();
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubmembers;
|
||
|
|
} // END club_member_list() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF club MEMBERS
|
||
|
|
// INPUT: $start REPRESENTING THE club MEMBER TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF club MEMBERS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN ARRAY OF club MEMBERS
|
||
|
|
function club_member_list($start, $limit, $sort_by = "clubmember_id DESC", $where = "") {
|
||
|
|
global $database, $user;
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmember_query = "SELECT
|
||
|
|
se_clubmembers.*,
|
||
|
|
se_users.user_id,
|
||
|
|
se_users.user_username,
|
||
|
|
se_users.user_fname,
|
||
|
|
se_users.user_lname,
|
||
|
|
se_users.user_photo,
|
||
|
|
se_users.user_dateupdated,
|
||
|
|
se_users.user_lastlogindate,
|
||
|
|
se_users.user_signupdate,se_users.online,
|
||
|
|
CASE
|
||
|
|
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_users.user_id AND friend_status='1' LIMIT 1)
|
||
|
|
THEN 2
|
||
|
|
WHEN (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_users.user_id AND friend_status='0' LIMIT 1)
|
||
|
|
THEN 1
|
||
|
|
ELSE 0
|
||
|
|
END
|
||
|
|
AS is_viewers_friend,
|
||
|
|
CASE
|
||
|
|
WHEN (SELECT TRUE FROM se_users AS se_users2 WHERE se_users2.user_id=se_users.user_id AND (user_blocklist LIKE '{$user->user_info['user_id']},%' OR user_blocklist LIKE '%,{$user->user_info['user_id']}' OR user_blocklist LIKE '%,{$user->user_info['user_id']},%') LIMIT 1)
|
||
|
|
THEN TRUE
|
||
|
|
ELSE FALSE
|
||
|
|
END
|
||
|
|
AS is_viewer_blocklisted
|
||
|
|
FROM se_clubmembers
|
||
|
|
LEFT JOIN se_users
|
||
|
|
ON se_clubmembers.clubmember_user_id=se_users.user_id";
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
//if($this->club_exists != 0 || $where != "") { $clubmember_query .= " WHERE"; }
|
||
|
|
if($this->club_exists != 0)
|
||
|
|
{ $clubmember_query .= " WHERE se_users.user_enabled=1 "; }
|
||
|
|
// IF club ID IS SET
|
||
|
|
if($this->club_exists != 0) { $clubmember_query .= " AND se_clubmembers.clubmember_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmember_query .= " "; }
|
||
|
|
// ADD REST OF WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmember_query .= " AND $where"; }
|
||
|
|
// ADD ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubmember_query .= " ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
// RUN QUERY
|
||
|
|
$clubmembers = $database->database_query($clubmember_query);
|
||
|
|
// GET club MEMBERS INTO AN ARRAY
|
||
|
|
$clubmember_array = Array();
|
||
|
|
while($clubmember_info = $database->database_fetch_assoc($clubmembers))
|
||
|
|
{
|
||
|
|
// CREATE OBJECT FOR MEMBER
|
||
|
|
$member = new se_user();
|
||
|
|
$member->user_exists = 1;
|
||
|
|
$member->user_info['user_id'] = $clubmember_info['user_id'];
|
||
|
|
$member->user_info['user_username'] = $clubmember_info['user_username'];
|
||
|
|
$member->user_info['user_photo'] = $clubmember_info['user_photo'];
|
||
|
|
$member->user_info['user_dateupdated'] = $clubmember_info['user_dateupdated'];
|
||
|
|
$member->user_info['user_lastlogindate'] = $clubmember_info['user_lastlogindate'];
|
||
|
|
$member->user_info['user_signupdate'] = $clubmember_info['user_signupdate'];
|
||
|
|
$member->user_info['user_fname'] = $clubmember_info['user_fname'];
|
||
|
|
$member->user_info['user_lname'] = $clubmember_info['user_lname'];
|
||
|
|
$member->is_viewers_friend = $clubmember_info['is_viewers_friend'];
|
||
|
|
$member->is_viewers_blocklist = $clubmember_info['is_viewers_blocklist'];
|
||
|
|
$member->user_displayname();
|
||
|
|
$member->online_now();
|
||
|
|
|
||
|
|
// SET club ARRAY
|
||
|
|
$clubmember_array[] = Array(
|
||
|
|
'clubmember_id' => $clubmember_info['clubmember_id'],
|
||
|
|
'clubmember_rank' => $clubmember_info['clubmember_rank'],
|
||
|
|
'clubmember_title' => $clubmember_info['clubmember_title'],
|
||
|
|
'clubmember_approved' => $clubmember_info['clubmember_approved'],
|
||
|
|
'clubmember_status' => $clubmember_info['clubmember_status'],
|
||
|
|
'membership_id' => $clubmember_info['membership_id'],
|
||
|
|
'member' => $member
|
||
|
|
);
|
||
|
|
}
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubmember_array;
|
||
|
|
} // END club_member_list() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE PATH TO THE GIVEN club'S DIRECTORY
|
||
|
|
// INPUT: $club_id (OPTIONAL) REPRESENTING A club'S club_ID
|
||
|
|
// OUTPUT: A STRING REPRESENTING THE RELATIVE PATH TO THE club'S DIRECTORY
|
||
|
|
function club_dir($club_id = 0) {
|
||
|
|
if($club_id == 0 & $this->club_exists) { $club_id = $this->club_info['club_id']; }
|
||
|
|
$subdir = $club_id+999-(($club_id-1)%1000);
|
||
|
|
$clubdir = "./uploads_club/{$subdir}/{$club_id}/";
|
||
|
|
return $clubdir;
|
||
|
|
} // END club_dir() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD OUTPUTS THE PATH TO THE club'S PHOTO OR THE GIVEN NOPHOTO IMAGE
|
||
|
|
// INPUT: $nophoto_image (OPTIONAL) REPRESENTING THE PATH TO AN IMAGE TO OUTPUT IF NO PHOTO EXISTS
|
||
|
|
// $thumb (OPTIONAL) REPRESENTING WHETHER TO RETRIEVE THE SQUARE THUMBNAIL OR NOT
|
||
|
|
// OUTPUT: A STRING CONTAINING THE PATH TO THE club'S PHOTO
|
||
|
|
function club_photo($nophoto_image = "", $thumb = FALSE) {
|
||
|
|
global $database;
|
||
|
|
$ex=explode(".", $this->club_info['club_photo']);
|
||
|
|
|
||
|
|
if(is_numeric($ex[0])){
|
||
|
|
$query=$database->database_query("SELECT approved FROM se_clubmedia WHERE clubmedia_id={$ex[0]}");
|
||
|
|
$row=$database->database_fetch_assoc($query);
|
||
|
|
if($row["approved"]!=1){$this->club_photo['club_photo']="";}
|
||
|
|
}
|
||
|
|
$club_photo = $this->club_dir($this->club_info['club_id']).$this->club_info['club_photo'];
|
||
|
|
if($thumb)
|
||
|
|
{
|
||
|
|
$club_thumb = substr($club_photo, 0, strrpos($club_photo, "."))."_thumb".substr($club_photo, strrpos($club_photo, "."));
|
||
|
|
$club_photo = $club_thumb;
|
||
|
|
}
|
||
|
|
//if(!file_exists($club_photo) || $this->club_info['club_photo'] == "") { $club_photo = $nophoto_image; }
|
||
|
|
return IMAGECDN1.str_replace("./", "", $club_photo);
|
||
|
|
|
||
|
|
} // END club_photo() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD UPLOADS A club PHOTO ACCORDING TO SPECIFICATIONS AND RETURNS club PHOTO
|
||
|
|
// INPUT: $photo_name REPRESENTING THE NAME OF THE FILE INPUT
|
||
|
|
// OUTPUT:
|
||
|
|
function club_photo_upload($photo_name)
|
||
|
|
{
|
||
|
|
global $database, $url;
|
||
|
|
|
||
|
|
// SET KEY VARIABLES
|
||
|
|
$file_maxsize = "4194304";
|
||
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($this->clubowner_level_info['level_club_photo_exts'])));
|
||
|
|
$file_types = explode(",", str_replace(" ", "", strtolower("image/jpeg, image/jpg, image/jpe, image/pjpeg, image/pjpg, image/x-jpeg, x-jpg, image/gif, image/x-gif, image/png, image/x-png")));
|
||
|
|
$file_maxwidth = $this->clubowner_level_info['level_club_photo_width'];
|
||
|
|
$file_maxheight = $this->clubowner_level_info['level_club_photo_height'];
|
||
|
|
$photo_newname = "0_".rand(1000, 9999).".jpg";
|
||
|
|
// $file_dest = $this->club_dir($this->club_info['club_id']).$photo_newname;
|
||
|
|
//$thumb_dest = substr($file_dest, 0, strrpos($file_dest, "."))."_thumb".substr($file_dest, strrpos($file_dest, "."));
|
||
|
|
|
||
|
|
$pathinfo = pathinfo($_FILES[$photo_name]['name']);
|
||
|
|
$filename = $pathinfo['filename'];
|
||
|
|
$filename = md5(uniqid());
|
||
|
|
$ext = $pathinfo['extension'];
|
||
|
|
$uniq=uniqid();
|
||
|
|
$photo_newname = $uniq.".".$ext;
|
||
|
|
$photo_newname1 = $uniq."_thumb.".$ext;
|
||
|
|
$file_dest = $this->club_dir($this->club_info['club_id']).$photo_newname;
|
||
|
|
$thumb_dest = $this->club_dir($this->club_info['club_id']).$photo_newname1;
|
||
|
|
|
||
|
|
|
||
|
|
$new_photo = new se_upload();
|
||
|
|
$new_photo->new_upload($photo_name, $file_maxsize, $file_exts, $file_types, $file_maxwidth, $file_maxheight);
|
||
|
|
|
||
|
|
// UPLOAD AND RESIZE PHOTO IF NO ERROR
|
||
|
|
if($new_photo->is_error == 0)
|
||
|
|
{
|
||
|
|
// DELETE OLD AVATAR IF EXISTS
|
||
|
|
$this->club_photo_delete();
|
||
|
|
if(in_array($ext, Array('jpg', 'jpeg', 'png', 'bmp', 'gif'))){$new_media->is_image =1;}
|
||
|
|
// UPLOAD THUMB
|
||
|
|
// CHECK IF IMAGE RESIZING IS AVAILABLE, OTHERWISE MOVE UPLOADED IMAGE
|
||
|
|
if( $new_photo->is_image )
|
||
|
|
{
|
||
|
|
|
||
|
|
$new_photo->upload_photo($file_dest);
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$new_photo->upload_file($file_dest);
|
||
|
|
}
|
||
|
|
|
||
|
|
$new_photo->upload_thumb($thumb_dest);
|
||
|
|
$new_photo->upload_thumb1($thumb_dest);
|
||
|
|
//if(!$database->database_ping())
|
||
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
||
|
|
{
|
||
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
||
|
|
$database =NULL;
|
||
|
|
$database =& SEDatabase::getInstance();
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
// UPDATE club INFO WITH IMAGE IF STILL NO ERROR
|
||
|
|
if( !$new_photo->is_error )
|
||
|
|
{
|
||
|
|
$database->database_query("UPDATE se_clubs SET club_photo='{$photo_newname}' WHERE club_id='{$this->club_info['club_id']}'");
|
||
|
|
$this->club_info['club_photo'] = $photo_newname;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
$this->is_error = $new_photo->is_error;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_photo_upload() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD DELETES A club PHOTO
|
||
|
|
// INPUT:
|
||
|
|
// OUTPUT:
|
||
|
|
function club_photo_delete()
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
$club_photo = $this->club_photo();
|
||
|
|
if($club_photo != "")
|
||
|
|
{
|
||
|
|
@unlink($club_photo);
|
||
|
|
|
||
|
|
@unlink(str_replace(".", "_thumb.", $club_photo));
|
||
|
|
$client = new MyS3Wrapper([
|
||
|
|
'region' => 'us-north-1',
|
||
|
|
'version' => 'latest',
|
||
|
|
'endpoint' => ENDPOINT,
|
||
|
|
'credentials' => [
|
||
|
|
'key' => AWS_KEY,
|
||
|
|
'secret' => AWS_SECRET_KEY
|
||
|
|
],
|
||
|
|
|
||
|
|
// Set the S3 class to use objects.dreamhost.com/bucket
|
||
|
|
// instead of bucket.objects.dreamhost.com
|
||
|
|
'use_path_style_endpoint' => true
|
||
|
|
]);
|
||
|
|
|
||
|
|
try {
|
||
|
|
$client->deleteObject(array(
|
||
|
|
'Bucket'=>'bateworld',
|
||
|
|
'Key' => str_replace("./", "", $club_photo),
|
||
|
|
|
||
|
|
));}catch (Exception $e) {}
|
||
|
|
|
||
|
|
try {
|
||
|
|
$client->deleteObject(array(
|
||
|
|
'Bucket'=>'bateworld',
|
||
|
|
'Key' => str_replace("./", "", str_replace(".", "_thumb.", $club_photo)),
|
||
|
|
|
||
|
|
));}catch (Exception $e) {}
|
||
|
|
|
||
|
|
$database->database_query("UPDATE se_clubs SET club_photo='' WHERE club_id='{$this->club_info['club_id']}'");
|
||
|
|
$this->club_info['club_photo'] = "";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_photo_delete() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD UPLOADS MEDIA TO A club ALBUM
|
||
|
|
// INPUT: $file_name REPRESENTING THE NAME OF THE FILE INPUT
|
||
|
|
// $clubalbum_id REPRESENTING THE ID OF THE club ALBUM TO UPLOAD THE MEDIA TO
|
||
|
|
// $space_left REPRESENTING THE AMOUNT OF SPACE LEFT
|
||
|
|
// OUTPUT:
|
||
|
|
function club_media_upload($file_name, $clubalbum_id, &$space_left)
|
||
|
|
{
|
||
|
|
global $database, $url, $user;
|
||
|
|
|
||
|
|
// SET KEY VARIABLES
|
||
|
|
$file_maxsize = $this->clubowner_level_info['level_club_album_maxsize'];
|
||
|
|
$file_exts = explode(",", str_replace(" ", "", strtolower($this->clubowner_level_info['level_club_album_exts'])));
|
||
|
|
$file_types = explode(",", str_replace(" ", "", strtolower($this->clubowner_level_info['level_club_album_mimes'])));
|
||
|
|
$file_maxwidth = $this->clubowner_level_info['level_club_album_width'];
|
||
|
|
$file_maxheight = $this->clubowner_level_info['level_club_album_height'];
|
||
|
|
|
||
|
|
$new_media = new se_upload();
|
||
|
|
$new_media->new_upload($file_name, $file_maxsize, $file_exts, $file_types, $file_maxwidth, $file_maxheight);
|
||
|
|
|
||
|
|
// UPLOAD AND RESIZE PHOTO IF NO ERROR
|
||
|
|
if($new_media->is_error == 0)
|
||
|
|
{
|
||
|
|
// INSERT ROW INTO MEDIA TABLE
|
||
|
|
$database->database_query("
|
||
|
|
INSERT INTO se_clubmedia (
|
||
|
|
clubmedia_clubalbum_id,
|
||
|
|
clubmedia_user_id,
|
||
|
|
clubmedia_date, ai, filename
|
||
|
|
) VALUES (
|
||
|
|
'{$clubalbum_id}',
|
||
|
|
'{$user->user_info['user_id']}',
|
||
|
|
'".time()."', '".$database->database_real_escape_string($_POST["ai"])."', '".$database->database_real_escape_string($_FILES[$file_name]['name'])."'
|
||
|
|
)
|
||
|
|
");
|
||
|
|
$clubmedia_id = $database->database_insert_id();
|
||
|
|
|
||
|
|
wrapup("clubupload_photo");
|
||
|
|
|
||
|
|
$pathinfo = pathinfo($_FILES[$file_name]['name']);
|
||
|
|
|
||
|
|
$filename = $pathinfo['filename'];
|
||
|
|
$filename = md5(uniqid());
|
||
|
|
$ext = $pathinfo['extension'];
|
||
|
|
|
||
|
|
$photo_newname = $clubmedia_id.".".$ext;
|
||
|
|
$photo_newname1 = $clubmedia_id."_thumb.".$ext;
|
||
|
|
if(in_array($ext, Array('jpg', 'jpeg', 'png', 'bmp', 'gif'))){$new_media->is_image =1;}
|
||
|
|
|
||
|
|
// CHECK IF IMAGE RESIZING IS AVAILABLE, OTHERWISE MOVE UPLOADED IMAGE
|
||
|
|
if($new_media->is_image == 1)
|
||
|
|
{
|
||
|
|
//$file_dest = $this->club_dir($this->club_info['club_id']).$clubmedia_id.".jpg";
|
||
|
|
//$thumb_dest = $this->club_dir($this->club_info['club_id']).$clubmedia_id."_thumb.jpg";
|
||
|
|
$file_dest = $this->club_dir($this->club_info['club_id']).$photo_newname;
|
||
|
|
$thumb_dest = $this->club_dir($this->club_info['club_id']).$photo_newname1;
|
||
|
|
// UPLOAD THUMB {$newheight1}
|
||
|
|
|
||
|
|
// UPLOAD FILE
|
||
|
|
$new_media->upload_photo($file_dest);
|
||
|
|
$new_media->upload_thumb($thumb_dest, 200);
|
||
|
|
$file_ext = $ext;
|
||
|
|
//$file_filesize = filesize($file_dest);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$file_dest = $this->club_dir($this->club_info['club_id']).$clubmedia_id.".".$new_media->file_ext;
|
||
|
|
$thumb_dest = $this->club_dir($this->club_info['club_id']).$clubmedia_id."_thumb.jpg";
|
||
|
|
|
||
|
|
// UPLOAD THUMB IF NECESSARY
|
||
|
|
if($new_media->file_ext == 'gif')
|
||
|
|
{
|
||
|
|
$thumb_dest = $this->club_dir($this->club_info['club_id']).$clubmedia_id."_thumb.jpg";
|
||
|
|
$new_media->upload_thumb($thumb_dest, 200);
|
||
|
|
}
|
||
|
|
|
||
|
|
$new_media->upload_file($file_dest);
|
||
|
|
$file_ext = $new_media->file_ext;
|
||
|
|
//$file_filesize = filesize($file_dest);
|
||
|
|
}
|
||
|
|
|
||
|
|
// CHECK SPACE LEFT
|
||
|
|
if($file_filesize > $space_left) {
|
||
|
|
$new_media->is_error = 2000250;
|
||
|
|
} else {
|
||
|
|
$space_left = $space_left-$file_filesize;
|
||
|
|
}
|
||
|
|
// if(!$database->database_ping())
|
||
|
|
if (!is_object($database) && !$database instanceof mysqli)
|
||
|
|
{
|
||
|
|
global $database, $database_host, $database_username, $database_password, $database_name;
|
||
|
|
$database =NULL;
|
||
|
|
$database =& SEDatabase::getInstance();
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
// DELETE FROM DATABASE IF ERROR
|
||
|
|
if( $new_media->is_error )
|
||
|
|
{
|
||
|
|
$database->database_query("DELETE FROM se_clubmedia WHERE clubmedia_id='$clubmedia_id' AND clubmedia_clubalbum_id='$clubalbum_id'");
|
||
|
|
@unlink($file_dest);
|
||
|
|
}
|
||
|
|
|
||
|
|
// UPDATE ROW IF NO ERROR
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$sql = "UPDATE se_clubmedia SET clubmedia_ext='$file_ext', clubmedia_filesize='$file_filesize', cloud=1 WHERE clubmedia_id='$clubmedia_id' AND clubmedia_clubalbum_id='$clubalbum_id'";
|
||
|
|
$resource = $database->database_query($sql);
|
||
|
|
|
||
|
|
// UPDATE PARENT TABLE ROW
|
||
|
|
if( !is_numeric($file_filesize) ) $file_filesize = 0;
|
||
|
|
$sql = "UPDATE se_clubalbums SET clubalbum_totalfiles=clubalbum_totalfiles+1, clubalbum_totalspace=clubalbum_totalspace+'{$file_filesize}' WHERE clubalbum_id='{$clubalbum_id}' LIMIT 1";
|
||
|
|
$resource = $database->database_query($sql);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// RETURN FILE STATS
|
||
|
|
$file_result = Array(
|
||
|
|
'is_error' => $new_media->is_error,
|
||
|
|
'file_name' => $_FILES[$file_name]['name'],
|
||
|
|
'clubmedia_id' => $clubmedia_id,
|
||
|
|
'clubmedia_ext' => $file_ext,
|
||
|
|
'clubmedia_filesize' => $file_filesize
|
||
|
|
);
|
||
|
|
|
||
|
|
return $file_result;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_media_upload() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE SPACE USED
|
||
|
|
// INPUT: $clubalbum_id (OPTIONAL) REPRESENTING THE ID OF THE ALBUM TO CALCULATE
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE SPACE USED
|
||
|
|
function club_media_space($clubalbum_id = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmedia_query = "SELECT sum(se_clubmedia.clubmedia_filesize) AS total_space";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubmedia_query .= " FROM se_clubalbums LEFT JOIN se_clubmedia ON se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($this->club_exists != 0 || $clubalbum_id != 0) { $clubmedia_query .= " WHERE"; }
|
||
|
|
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
if($this->club_exists != 0) { $clubmedia_query .= " se_clubalbums.clubalbum_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $clubalbum_id != 0) { $clubmedia_query .= " AND"; }
|
||
|
|
|
||
|
|
// SPECIFY ALBUM ID IF NECESSARY
|
||
|
|
if($clubalbum_id != 0) { $clubmedia_query .= " se_clubalbums.clubalbum_id='{$clubalbum_id}'"; }
|
||
|
|
|
||
|
|
// GET AND RETURN TOTAL SPACE USED
|
||
|
|
$space_info = $database->database_fetch_assoc($database->database_query($clubmedia_query));
|
||
|
|
return $space_info["total_space"];
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_media_space() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE NUMBER OF club MEDIA
|
||
|
|
// INPUT: $clubalbum_id (OPTIONAL) REPRESENTING THE ID OF THE club ALBUM TO CALCULATE
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE NUMBER OF FILES
|
||
|
|
function club_media_total1($clubalbum_id = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmedia_query = "SELECT COUNT(*) as clubalbum_totalfiles";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubmedia_query .= " FROM se_clubmedia, se_clubalbums , se_clubs ";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$clubmedia_query .= " WHERE";
|
||
|
|
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
$clubmedia_query .= " se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id AND se_clubalbums.clubalbum_club_id=se_clubs.club_id AND se_clubs.club_privacy!=7";
|
||
|
|
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmedia_query .= " AND"; }
|
||
|
|
|
||
|
|
// ADD ADDITIONAL WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmedia_query .= " $where"; }
|
||
|
|
|
||
|
|
if( $this->club_exists && $clubalbum_id ) $clubmedia_query .= " AND ";
|
||
|
|
|
||
|
|
|
||
|
|
if( $clubalbum_id ) $clubmedia_query .= "
|
||
|
|
se_clubalbums.clubalbum_id='{$clubalbum_id}'
|
||
|
|
";
|
||
|
|
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
//$clubmedia_query .= " club BY clubmedia_id";
|
||
|
|
|
||
|
|
// NEW HANDLING
|
||
|
|
$sql = "
|
||
|
|
SELECT
|
||
|
|
COUNT(*) as clubalbum_totalfiles
|
||
|
|
FROM
|
||
|
|
se_clubmedia
|
||
|
|
|
||
|
|
";
|
||
|
|
|
||
|
|
if( $this->club_exists ) $sql .= "
|
||
|
|
clubalbum_club_id='{$this->club_info['club_id']}'
|
||
|
|
";
|
||
|
|
|
||
|
|
if( $this->club_exists && $clubalbum_id ) $sql .= " && ";
|
||
|
|
|
||
|
|
|
||
|
|
if( $clubalbum_id ) $sql .= "
|
||
|
|
clubalbum_id='{$clubalbum_id}'
|
||
|
|
";
|
||
|
|
|
||
|
|
//if($_SERVER['REMOTE_ADDR']=="98.192.194.204"){ echo $clubmedia_query ;}
|
||
|
|
|
||
|
|
$resource = $database->database_query($clubmedia_query);
|
||
|
|
|
||
|
|
if( !$resource )
|
||
|
|
{ return FALSE;}
|
||
|
|
|
||
|
|
$total_files = $database->database_fetch_assoc($resource);
|
||
|
|
return (int) $total_files['clubalbum_totalfiles'];
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
function club_media_total($clubalbum_id = 0)
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
if( !$this->club_exists && !$clubalbum_id ) return FALSE;
|
||
|
|
|
||
|
|
|
||
|
|
// NEW HANDLING
|
||
|
|
$sql = "
|
||
|
|
SELECT COUNT(clubmedia_id) as
|
||
|
|
clubalbum_totalfiles
|
||
|
|
FROM
|
||
|
|
se_clubalbums, se_clubmedia
|
||
|
|
WHERE clubmedia_clubalbum_id=clubalbum_id
|
||
|
|
";
|
||
|
|
|
||
|
|
if( $this->club_exists ) $sql .= "
|
||
|
|
AND clubalbum_club_id='{$this->club_info['club_id']}'
|
||
|
|
";
|
||
|
|
|
||
|
|
// if( $this->club_exists && $clubalbum_id ) $sql .= " && ";
|
||
|
|
|
||
|
|
|
||
|
|
if( $clubalbum_id ) $sql .= "
|
||
|
|
AND clubalbum_id='{$clubalbum_id}'
|
||
|
|
";
|
||
|
|
//if(SE_DEBUG1){echo $sql;}
|
||
|
|
$resource = $database->database_query($sql);
|
||
|
|
|
||
|
|
if( !$resource )
|
||
|
|
return FALSE;
|
||
|
|
|
||
|
|
$total_files = $database->database_fetch_assoc($resource);
|
||
|
|
return (int) $total_files['clubalbum_totalfiles'];
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_media_total() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF club MEDIA
|
||
|
|
// INPUT: $start REPRESENTING THE club MEDIA TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF club MEDIA TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN ARRAY OF club MEDIA
|
||
|
|
function club_media_list($start, $limit, $sort_by = "clubmedia_id DESC", $where = "")
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmedia_query = "SELECT se_clubmedia.*, se_clubalbums.clubalbum_id, se_clubalbums.clubalbum_club_id, se_clubalbums.clubalbum_title, count(se_clubmediacomments.clubmediacomment_id) AS total_comments";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubmedia_query .= " FROM se_clubmedia LEFT JOIN se_clubmediacomments ON se_clubmediacomments.clubmediacomment_clubmedia_id=se_clubmedia.clubmedia_id LEFT JOIN se_clubalbums ON se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($this->club_exists != 0 || $where != "") { $clubmedia_query .= " WHERE"; }
|
||
|
|
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
if($this->club_exists != 0) { $clubmedia_query .= " se_clubalbums.clubalbum_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmedia_query .= " AND"; }
|
||
|
|
|
||
|
|
// ADD ADDITIONAL WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmedia_query .= " $where"; }
|
||
|
|
|
||
|
|
// ADD group BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubmedia_query .= " group BY clubmedia_id ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
//if($_SERVER['REMOTE_ADDR']=="24.47.141.40"){ echo $clubmedia_query ;}
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubmedia = $database->database_query($clubmedia_query);
|
||
|
|
|
||
|
|
// GET club MEDIA INTO AN ARRAY
|
||
|
|
$clubmedia_array = Array();
|
||
|
|
while($clubmedia_info = $database->database_fetch_assoc($clubmedia))
|
||
|
|
{
|
||
|
|
// CREATE ARRAY OF MEDIA DATA
|
||
|
|
$clubmedia_array[] = Array(
|
||
|
|
'clubmedia_id' => $clubmedia_info['clubmedia_id'],
|
||
|
|
'clubmedia_clubalbum_id' => $clubmedia_info['clubmedia_clubalbum_id'],
|
||
|
|
'clubmedia_date' => $clubmedia_info['clubmedia_date'],
|
||
|
|
'clubmedia_title' => $clubmedia_info['clubmedia_title'],
|
||
|
|
'clubmedia_desc' => str_replace("<br>", "\r\n", $clubmedia_info['clubmedia_desc']),
|
||
|
|
'clubmedia_ext' => $clubmedia_info['clubmedia_ext'],
|
||
|
|
'clubmedia_filesize' => $clubmedia_info['clubmedia_filesize'],
|
||
|
|
'clubmedia_comments_total' => $clubmedia_info['total_comments']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubmedia_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_media_list() METHOD
|
||
|
|
function club_media_list1($start, $limit, $sort_by = "clubmedia_id DESC", $where = "")
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubmedia_query = "SELECT se_clubmedia.*, se_clubalbums.*, se_clubs.*";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubmedia_query .= " FROM se_clubmedia, se_clubalbums , se_clubs ";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$clubmedia_query .= " WHERE";
|
||
|
|
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
$clubmedia_query .= " se_clubalbums.clubalbum_id=se_clubmedia.clubmedia_clubalbum_id AND se_clubalbums.clubalbum_club_id=se_clubs.club_id AND se_clubs.club_privacy!=7";
|
||
|
|
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubmedia_query .= " AND"; }
|
||
|
|
|
||
|
|
// ADD ADDITIONAL WHERE CLAUSE
|
||
|
|
if($where != "") { $clubmedia_query .= " $where"; }
|
||
|
|
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubmedia_query .= " club BY clubmedia_id ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
//if($_SERVER['REMOTE_ADDR']=="98.192.194.204"){ echo $clubmedia_query ;}
|
||
|
|
// RUN QUERY
|
||
|
|
$clubmedia = $database->database_query($clubmedia_query);
|
||
|
|
|
||
|
|
// GET club MEDIA INTO AN ARRAY
|
||
|
|
$clubmedia_array = Array();
|
||
|
|
while($clubmedia_info = $database->database_fetch_assoc($clubmedia))
|
||
|
|
{
|
||
|
|
$clubmedia_array[]=$clubmedia_info;
|
||
|
|
// CREATE ARRAY OF MEDIA DATA
|
||
|
|
$clubmedia_array[] = Array(
|
||
|
|
'clubmedia_id' => $clubmedia_info['clubmedia_id'],
|
||
|
|
'clubmedia_clubalbum_id' => $clubmedia_info['clubmedia_clubalbum_id'],
|
||
|
|
'clubmedia_date' => $clubmedia_info['clubmedia_date'],
|
||
|
|
'clubmedia_title' => $clubmedia_info['clubmedia_title'],
|
||
|
|
'clubmedia_desc' => str_replace("<br>", "\r\n", $clubmedia_info['clubmedia_desc']),
|
||
|
|
'clubmedia_ext' => $clubmedia_info['clubmedia_ext'],
|
||
|
|
'clubmedia_filesize' => $clubmedia_info['clubmedia_filesize'],
|
||
|
|
'clubmedia_comments_total' => $clubmedia_info['total_comments']
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubmedia_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF club TOPICS
|
||
|
|
// INPUT: $start REPRESENTING THE club TOPIC TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF club TOPICS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN ARRAY OF club TOPICS
|
||
|
|
function club_topic_list($start, $limit, $sort_by = "clubtopic_date DESC", $where = "")
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubtopic_query = "
|
||
|
|
SELECT
|
||
|
|
se_clubtopics.*,
|
||
|
|
se_clubposts.*,
|
||
|
|
se_clubtopics.clubtopic_totalposts AS total_posts,
|
||
|
|
creator.user_id AS creator_user_id,
|
||
|
|
creator.user_username AS creator_user_username,
|
||
|
|
creator.user_fname AS creator_user_fname,
|
||
|
|
creator.user_lname AS creator_user_lname,
|
||
|
|
lastposter.user_id AS lastposter_user_id,
|
||
|
|
lastposter.user_username AS lastposter_user_username,
|
||
|
|
lastposter.user_fname AS lastposter_user_fname,
|
||
|
|
lastposter.user_lname AS lastposter_user_lname,
|
||
|
|
lastposter.user_photo AS lastposter_user_photo
|
||
|
|
";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubtopic_query .= "
|
||
|
|
FROM
|
||
|
|
se_clubtopics
|
||
|
|
LEFT JOIN
|
||
|
|
se_clubposts
|
||
|
|
ON se_clubtopics.clubtopic_id=se_clubposts.clubpost_clubtopic_id
|
||
|
|
";
|
||
|
|
// JOIN TO USER TABLE (CREATOR)
|
||
|
|
$clubtopic_query .= " LEFT JOIN se_users AS creator ON se_clubtopics.clubtopic_creatoruser_id=creator.user_id";
|
||
|
|
// JOIN TO USER TABLE (LAST POSTER)
|
||
|
|
$clubtopic_query .= " LEFT JOIN se_users AS lastposter ON se_clubposts.clubpost_authoruser_id=lastposter.user_id";
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
$clubtopic_query .= " WHERE se_clubposts.clubpost_id = (SELECT MAX(clubpost_id) FROM se_clubposts WHERE clubpost_clubtopic_id=se_clubtopics.clubtopic_id)";
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
if($this->club_exists != 0) { $clubtopic_query .= " AND se_clubtopics.clubtopic_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
// ADD ADDITIONAL WHERE CLAUSE
|
||
|
|
if($where != "") { $clubtopic_query .= " AND $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubtopic_query .= " ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubtopics = $database->database_query($clubtopic_query);
|
||
|
|
// GET club TOPICS INTO AN ARRAY
|
||
|
|
$clubtopic_array = Array();
|
||
|
|
while($clubtopic_info = $database->database_fetch_assoc($clubtopics))
|
||
|
|
{
|
||
|
|
$creator = new se_user();
|
||
|
|
if($clubtopic_info['creator_user_id'] != $clubtopic_info['clubtopic_creatoruser_id'])
|
||
|
|
{
|
||
|
|
$creator->user_exists = 0;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$creator->user_exists = 1;
|
||
|
|
$creator->user_info['user_id'] = $clubtopic_info['creator_user_id'];
|
||
|
|
$creator->user_info['user_username'] = $clubtopic_info['creator_user_username'];
|
||
|
|
$creator->user_info['user_fname'] = $clubtopic_info['creator_user_fname'];
|
||
|
|
$creator->user_info['user_lname'] = $clubtopic_info['creator_user_lname'];
|
||
|
|
$creator->user_displayname();
|
||
|
|
}
|
||
|
|
$lastposter = new se_user();
|
||
|
|
if($clubtopic_info['lastposter_user_id'] != $clubtopic_info['clubpost_authoruser_id'])
|
||
|
|
{
|
||
|
|
$lastposter->user_exists = 0;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$lastposter->user_exists = 1;
|
||
|
|
$lastposter->user_info['user_id'] = $clubtopic_info['lastposter_user_id'];
|
||
|
|
$lastposter->user_info['user_username'] = $clubtopic_info['lastposter_user_username'];
|
||
|
|
$lastposter->user_info['user_fname'] = $clubtopic_info['lastposter_user_fname'];
|
||
|
|
$lastposter->user_info['user_lname'] = $clubtopic_info['lastposter_user_lname'];
|
||
|
|
$lastposter->user_info['user_photo'] = $clubtopic_info['lastposter_user_photo'];
|
||
|
|
$lastposter->user_displayname();
|
||
|
|
}
|
||
|
|
// SET PART OF ARRAY
|
||
|
|
$clubtopic_info['creator'] = $creator;
|
||
|
|
$clubtopic_info['lastposter'] = $lastposter;
|
||
|
|
// CREATE ARRAY OF TOPIC DATA
|
||
|
|
$clubtopic_array[] = $clubtopic_info;
|
||
|
|
}
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubtopic_array;
|
||
|
|
} // END club_topic_list() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE NUMBER OF club TOPICS
|
||
|
|
// INPUT: $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE NUMBER OF TOPICS
|
||
|
|
function club_topic_total($where = "")
|
||
|
|
{
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// NEW SHORT HANDLING
|
||
|
|
if( !$where && isset($this->club_info['club_totaltopics']) )
|
||
|
|
{
|
||
|
|
return (int) $this->club_info['club_totaltopics'];
|
||
|
|
}
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubtopic_query = "SELECT se_clubtopics.*, count(se_clubposts.clubpost_id) AS total_posts";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubtopic_query .= " FROM se_clubtopics LEFT JOIN se_clubposts ON se_clubposts.clubpost_clubtopic_id=se_clubtopics.clubtopic_id";
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($this->club_exists != 0 || $where != "") { $clubtopic_query .= " WHERE"; }
|
||
|
|
// IF club EXISTS, SPECIFY club ID
|
||
|
|
if($this->club_exists != 0) { $clubtopic_query .= " se_clubtopics.clubtopic_club_id='{$this->club_info['club_id']}'"; }
|
||
|
|
// ADD AND IF NECESSARY
|
||
|
|
if($this->club_exists != 0 && $where != "") { $clubtopic_query .= " AND"; }
|
||
|
|
// ADD ADDITIONAL WHERE CLAUSE
|
||
|
|
if($where != "") { $clubtopic_query .= " $where"; }
|
||
|
|
// ADD club BY, ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubtopic_query .= " club BY clubtopic_id";
|
||
|
|
// RUN QUERY
|
||
|
|
$total_topics = $database->database_num_rows($database->database_query($clubtopic_query));
|
||
|
|
// RETURN TOTAL TOPICS
|
||
|
|
return $total_topics;
|
||
|
|
} // END club_topic_total() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS AN ARRAY OF club POSTS
|
||
|
|
// INPUT: $start REPRESENTING THE club POST TO START WITH
|
||
|
|
// $limit REPRESENTING THE NUMBER OF club POSTS TO RETURN
|
||
|
|
// $sort_by (OPTIONAL) REPRESENTING THE ORDER BY CLAUSE
|
||
|
|
// $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN ARRAY OF club POSTS
|
||
|
|
function club_post_list($start, $limit, $sort_by = "clubpost_date DESC", $where = "") {
|
||
|
|
global $database;
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubpost_query = "SELECT se_clubposts.*, se_users.user_id, se_users.user_username, se_users.user_fname, se_users.user_lname, se_users.user_photo";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubpost_query .= " FROM se_clubposts LEFT JOIN se_users ON se_clubposts.clubpost_authoruser_id=se_users.user_id";
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($where != "") { $clubpost_query .= " WHERE $where"; }
|
||
|
|
// ADD ORDER, AND LIMIT CLAUSE
|
||
|
|
$clubpost_query .= " ORDER BY $sort_by LIMIT $start, $limit";
|
||
|
|
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$clubposts = $database->database_query($clubpost_query);
|
||
|
|
// GET club POSTS INTO AN ARRAY
|
||
|
|
$clubpost_array = Array();
|
||
|
|
while($clubpost_info = $database->database_fetch_assoc($clubposts))
|
||
|
|
{
|
||
|
|
// Get post author
|
||
|
|
$author = new se_user();
|
||
|
|
if($clubpost_info['clubpost_authoruser_id'] != $clubpost_info['user_id'])
|
||
|
|
{
|
||
|
|
$author->user_exists = 0;
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$author->user_exists = 1;
|
||
|
|
$author->user_info['user_id'] = $clubpost_info['user_id'];
|
||
|
|
$author->user_info['user_username'] = $clubpost_info['user_username'];
|
||
|
|
$author->user_info['user_fname'] = $clubpost_info['user_fname'];
|
||
|
|
$author->user_info['user_lname'] = $clubpost_info['user_lname'];
|
||
|
|
$author->user_info['user_photo'] = $clubpost_info['user_photo'];
|
||
|
|
$author->user_displayname();
|
||
|
|
}
|
||
|
|
|
||
|
|
$clubpost_info['clubpost_author'] =& $author;
|
||
|
|
|
||
|
|
// Get last post editor
|
||
|
|
if( !empty($clubpost_info['clubpost_lastedit_user_id']) )
|
||
|
|
{
|
||
|
|
if( $clubpost_info['clubpost_lastedit_user_id']==$clubpost_info['clubpost_authoruser_id'] )
|
||
|
|
{
|
||
|
|
$clubpost_info['clubpost_lastedit_user_object'] =& $clubpost_info['clubpost_author'];
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
$clubpost_info['clubpost_lastedit_user_object'] = new se_user(array($clubpost_info['clubpost_lastedit_user_id']));
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// Format post body
|
||
|
|
$clubpost_info['clubpost_body_formatted'] = $this->club_post_bbcode_parse_view($clubpost_info['clubpost_body']);
|
||
|
|
$clubpost_info['clubpost_body_formatted'] = stripslashes($clubpost_info['clubpost_body_formatted']);
|
||
|
|
|
||
|
|
// CREATE ARRAY OF POST DATA
|
||
|
|
$clubpost_array[] = $clubpost_info;
|
||
|
|
|
||
|
|
unset($author);
|
||
|
|
}
|
||
|
|
|
||
|
|
// RETURN ARRAY
|
||
|
|
return $clubpost_array;
|
||
|
|
}
|
||
|
|
|
||
|
|
// END club_post_list() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// THIS METHOD RETURNS THE NUMBER OF club POSTS
|
||
|
|
// INPUT: $where (OPTIONAL) REPRESENTING ADDITIONAL THINGS TO INCLUDE IN THE WHERE CLAUSE
|
||
|
|
// OUTPUT: AN INTEGER REPRESENTING THE NUMBER OF POSTS
|
||
|
|
function club_post_total($where = "", $clubtopic_id=NULL) {
|
||
|
|
global $database;
|
||
|
|
|
||
|
|
// TRY CACHED
|
||
|
|
if( $clubtopic_id && !$where )
|
||
|
|
{
|
||
|
|
//$sql = "SELECT clubtopic_totalposts FROM se_clubtopics WHERE clubtopic_id='{$clubtopic_id}' LIMIT 1";
|
||
|
|
$sql = "SELECT COUNT(*) clubtopic_totalposts FROM se_clubposts WHERE se_clubposts.clubpost_clubtopic_id='{$clubtopic_id}' AND clubpost_deleted=0 LIMIT 1";
|
||
|
|
|
||
|
|
$resource = $database->database_query($sql);
|
||
|
|
|
||
|
|
if( $resource )
|
||
|
|
{
|
||
|
|
$total_posts = $database->database_fetch_assoc($resource);
|
||
|
|
return (int) $total_posts['clubtopic_totalposts'];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
// BEGIN QUERY
|
||
|
|
$clubpost_query = "SELECT se_clubposts.clubpost_id, se_users.user_id";
|
||
|
|
|
||
|
|
// CONTINUE QUERY
|
||
|
|
$clubpost_query .= " FROM se_clubposts LEFT JOIN se_users ON se_clubposts.clubpost_authoruser_id=se_users.user_id";
|
||
|
|
|
||
|
|
// ADD WHERE IF NECESSARY
|
||
|
|
if($where != "") { $clubpost_query .= " WHERE $where"; }
|
||
|
|
|
||
|
|
// RUN QUERY
|
||
|
|
$total_posts = $database->database_num_rows($database->database_query($clubpost_query));
|
||
|
|
|
||
|
|
// RETURN TOTAL POSTS
|
||
|
|
return $total_posts;
|
||
|
|
|
||
|
|
} // END club_post_total() METHOD
|
||
|
|
|
||
|
|
|
||
|
|
function club_post_bbcode_parse_clean($string)
|
||
|
|
{
|
||
|
|
global $setting;
|
||
|
|
|
||
|
|
// Fix line breaks
|
||
|
|
$string = htmlspecialchars_decode($string, ENT_QUOTES);
|
||
|
|
$string = censor($string);
|
||
|
|
$string = preg_replace(array("/\\r\\n/", "/\\r/", "/\\n/"), array("[br]", "[br]", "[br]"), $string);
|
||
|
|
|
||
|
|
// DO [code]
|
||
|
|
$open_code = preg_match_all('/\[code\=?(.*?)\]/i', $string, $matches);
|
||
|
|
$close_code = preg_match_all('/\[\/code\]/i', $string, $matches);
|
||
|
|
$total_tags = ( ($open_code > $close_code) ? $close_code : $open_code );
|
||
|
|
|
||
|
|
if( $total_tags )
|
||
|
|
{
|
||
|
|
$string = preg_replace_callback(
|
||
|
|
'/(\[code\=?.*?\])(.*?)(\[\/code\])/i',
|
||
|
|
create_function(
|
||
|
|
'$matches',
|
||
|
|
'return $matches[1].str_replace("&", "[AMP]", htmlspecialchars(htmlspecialchars_decode($matches[2], ENT_QUOTES), ENT_QUOTES)).$matches[3];'
|
||
|
|
),
|
||
|
|
$string,
|
||
|
|
$total_tags
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
// Clean HTML
|
||
|
|
//$string = str_replace('&', '[AMP]', $string);
|
||
|
|
$string = cleanHTML($string, $setting['setting_club_discussion_html'], Array("style"));
|
||
|
|
$string = str_replace('[AMP]', '&', $string);
|
||
|
|
|
||
|
|
// Fix line breaks
|
||
|
|
$string = str_replace("[br]", "<br>", $string);
|
||
|
|
$string = preg_replace('/\s+<br>\s+/i', '<br>', $string);
|
||
|
|
$string = preg_replace('/(<br>){3,}/is', '<br><br>', $string);
|
||
|
|
|
||
|
|
return $string;
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
function club_post_bbcode_parse_view($string)
|
||
|
|
{
|
||
|
|
// DO [quote]
|
||
|
|
$open_quote = preg_match_all('/\[quote\=(.*?)\]/i', $string, $matches);
|
||
|
|
$close_quote = preg_match_all('/\[\/quote\]/i', $string, $matches);
|
||
|
|
$total_tags = ( $open_quote>$close_quote ? $close_quote : $open_quote );
|
||
|
|
|
||
|
|
if( $total_tags )
|
||
|
|
{
|
||
|
|
$string = preg_replace('/\[quote\=(.*?)\]/i', "<div class='club_discussion_quote'><div>".SE_Language::get(2000323, Array('$1'))."</div>", $string, $total_tags);
|
||
|
|
$string = strrev(preg_replace('/\]etouq\/\[/i', ">vid/<", strrev($string), $total_tags));
|
||
|
|
}
|
||
|
|
|
||
|
|
// DO [code]
|
||
|
|
$open_code = preg_match_all('/\[code\=?(.*?)\]/i', $string, $matches);
|
||
|
|
$close_code = preg_match_all('/\[\/code\]/i', $string, $matches);
|
||
|
|
$total_tags = ( ($open_code > $close_code) ? $close_code : $open_code );
|
||
|
|
|
||
|
|
if( $total_tags )
|
||
|
|
{
|
||
|
|
$string = preg_replace('/\[code\=?(.*?)\](.*?)\[\/code\]/ie', "'<div class=\'club_discussion_code\'>'.( '\\1'!='' ? '<div class=\'club_discussion_code_title\'>'.'\\1'.'</div>' : '').'\\2'.'</div>'", $string, $total_tags);
|
||
|
|
}
|
||
|
|
|
||
|
|
return $string;
|
||
|
|
}
|
||
|
|
function album_media_rotate($media_id, $dir)
|
||
|
|
{
|
||
|
|
global $database, $url, $user;
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// ENSURE MEDIA BELONGS TO USER
|
||
|
|
$media = $database->database_query("SELECT se_clubmedia.* FROM se_clubmedia WHERE clubmedia_id='$media_id' AND clubmedia_user_id='".$user->user_info["user_id"]."'");
|
||
|
|
if($database->database_num_rows($media) != 1) { return; }
|
||
|
|
$media_info = $database->database_fetch_assoc($media);
|
||
|
|
|
||
|
|
$media_path = club_dir($this->club_info["club_id"]).$media_info["clubmedia_id"].".".$media_info["clubmedia_ext"];
|
||
|
|
$thumb_path = club_dir($this->club_info["club_id"]).$media_info["clubmedia_id"]."_thumb.".$media_info["clubmedia_ext"];
|
||
|
|
|
||
|
|
// GET IMAGE INFORMATION
|
||
|
|
|
||
|
|
$media_dimensions = @getimagesize($media_path);
|
||
|
|
$media_width = $media_dimensions[0];
|
||
|
|
$media_height = $media_dimensions[1];
|
||
|
|
|
||
|
|
// ROTATE IMAGE
|
||
|
|
|
||
|
|
$old = imagecreatefromjpeg($media_path);
|
||
|
|
//mail("leprakhauns@gmail.com", "AAA", $media_path);
|
||
|
|
$rotate = imagerotate($old, $dir, 0);
|
||
|
|
imagejpeg($rotate, $media_path, 100);
|
||
|
|
ImageDestroy($old);
|
||
|
|
ImageDestroy($rotate);
|
||
|
|
// ROTATE THUMB
|
||
|
|
if(file_exists($thumb_path)){
|
||
|
|
$old = imagecreatefromjpeg($thumb_path);
|
||
|
|
$rotate = imagerotate($old, $dir, 0);
|
||
|
|
imagejpeg($rotate, $thumb_path, 100);
|
||
|
|
ImageDestroy($old);
|
||
|
|
ImageDestroy($rotate);
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
/*$cf_cache_v1 = new cloudflare_cache(
|
||
|
|
array(
|
||
|
|
"tkn" => "b4fafa93f2bcd7ce518553d2df2793edd06e8",
|
||
|
|
"email" => "lepslair@gmail.com",
|
||
|
|
"z" => "bateworld.com"
|
||
|
|
)
|
||
|
|
);*/
|
||
|
|
highwindsdelete(IMAGECDN.substr($media_path,2));
|
||
|
|
highwindsdelete(IMAGECDN.substr($thumb_path,2));
|
||
|
|
|
||
|
|
# Update cache all in domain
|
||
|
|
//$res = $cf_cache_v1->purge_file("https://bateworld.com/".substr($media_path,2));
|
||
|
|
//$res = $cf_cache_v1->purge_file("https://bateworld.com/".substr($thumb_path,2));
|
||
|
|
//$res = $cf_cache_v1->purge_file(true);
|
||
|
|
//$res = $cf_cache_v1->purge_all();
|
||
|
|
//mail("leprakhauns@gmail.com", "rotate", "/".substr($thumb_path,2));
|
||
|
|
|
||
|
|
# Update cache file(s) (url)
|
||
|
|
//mail("leprakhauns@gmail.com", "rrr", $media_path);
|
||
|
|
return $media_info["clubmedia_ext"];
|
||
|
|
}
|
||
|
|
}
|
||
|
|
?>
|