General Stats Mod

Enter this sql into your database(sql button in phpmyadmin) (backup first)

ALTER TABLE `messages` ADD `message_status` VARCHAR( 20 ) NOT NULL ;
ALTER TABLE `member_profile` ADD `video_viewed` INT( 10 ) NOT NULL DEFAULT '0';
ALTER TABLE `member_profile` ADD `uploaded` INT( 10 ) NOT NULL DEFAULT '0';

Make these changes to your files (backup first)
Open inner_index_2.htm and add this code somewhere where you would like to display the stats

<table id="table38" border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody>
<tr>
<td width="17"></td>
<td class="table_border_l_b_r">
<table id="about" border="0" cellspacing="0" cellpadding="0" width="100%" bgcolor="#e4eff8">
<p align="center"></p>
<h3>Welcome Back</h3>
<h4>Welcome back <!--[var.user_name;ope=max:15;comm]--></h4>
New Messages : <a href="http://www.yourdomain.com/emailinbox.php"><!--[var.msg_num;ope=max:15;comm] --></a>
New Friend Requests : <a href="http://www.yourdomain.com/inviteread.php"><!--[var.mate_req;ope=max:15;comm] --></a>
Videos I've Watched : <!--[var.myvids;ope=max:15;comm] -->
Videos I've uploaded : <a href="http://www.pugsx.co.uk/myvideos.php"><!--[var.nummyvids;ope=max:15;comm] --></a>
<h4>Some site stats</h4>
Total Members : <!--[var.members;ope=max:15;comm] -->
New Members Today: <!--[var.todaymem;ope=max:15;comm] -->
New Members Yesterday : <!--[var.yesdaymem;ope=max:15;comm] -->
Total Videos : <!--[var.tvids;ope=max:15;comm] -->
Latest Member : <a href="http://www.yourdomain.com/memberprofile.php?uid=&lt;!--[var.late_uid;ope=max:15;comm] --&gt;"><!--[var.late_mem;ope=max:15;comm] --></a>
Watched Videos : <!--[var.watvid;ope=max:15;comm] -->
Online Visitors : (<script src="http://fastonlineusers.com/online.php?d=www.yourdomain.com"></script>)</table>
</td>
</tr>
</tbody></table>

open index.php and add this towards the top of the file

//Msg count
$sql2 = "SELECT * FROM messages WHERE to_id = $user_id AND message_status = 'unread'";
$query2 = @mysql_query($sql2);
$msg_num = @mysql_num_rows($query2);
 
//friends requests
$sql2 = "SELECT * FROM friends WHERE invitation_status = 'pending' AND friends_id = $user_id";
$query2 = @mysql_query($sql2);
$mate_req = @mysql_num_rows($query2);
 
//total members
$sql2 = "SELECT * FROM member_profile";
$query2 = @mysql_query($sql2);
$members = @mysql_num_rows($query2);
 
//Total vids
$sql2 = "SELECT * FROM videos WHERE approved='yes'";
$query2 = @mysql_query($sql2);
$tvids = @mysql_num_rows($query2);
 
//vids ive watched
$sql2 = "select video_viewed from member_profile where user_id = $user_id";
$query2 = @mysql_query($sql2);
$row = @mysql_fetch_row($query2);
$myvids = $row[0];
 
//watched vids
$sql2 = "SELECT sum(number_of_views) from videos";
$query2 = @mysql_query($sql2);
$watvid = @mysql_result($query2 , 0);
 
//my vids
$sql2 = "SELECT * FROM videos WHERE user_id = $user_id AND approved='yes'";
$query2 = @mysql_query($sql2);
$nummyvids = @mysql_num_rows($query2);
 
//new members today
$today = $config["date_format"];
$sql2 = "SELECT * FROM member_profile where date_created LIKE '%$today%'";
$query2 = @mysql_query($sql2);
$todaymem = @mysql_num_rows($query2);
 
//yesterday members new
$Yesterday = date("d-m-y",mktime(0,0,0,date("m") ,date("d")-1,date("Y")));
$sql2 = "SELECT * FROM member_profile where date_created LIKE '%$Yesterday%'";
$query2 = @mysql_query($sql2);
$yesdaymem = @mysql_num_rows($query2);
 
//new videos today
$today = $config["date_format"];
$sql2 = "SELECT * FROM videos where date_uploaded LIKE '%$today%'";
$query2 = @mysql_query($sql2);
$todayvids = @mysql_num_rows($query2);
 
//latest mem
$sql2 = "select user_name, user_id from member_profile order by user_id desc";
$query2 = @mysql_query($sql2);
$row = @mysql_fetch_row($query2);
$late_mem = $row[0];
$late_uid = $row[1];
 
//Most viewed video
$sql2 = "SELECT title, MAX(`number_of_views`), indexer FROM `videos` GROUP BY number_of_views DESC LIMIT 1";
$query2 = @mysql_query($sql2);
$row = @mysql_fetch_row($query2);
$mvtitle = $row[0];
$numv = $row[1];
$mvind = $row[2];
 
//Most uploaded
$sql2 = "SELECT user_id, user_name, MAX(`uploaded`) FROM `member_profile` GROUP BY uploaded DESC LIMIT 1";
$query2 = @mysql_query($sql2);
$row = @mysql_fetch_row($query2);
$usrid = $row[0];
$uname = $row[1];
$uup = $row[2];

open emailread.php and find the following

///////////////////////////////////////////
//show message
///////////////////////////////////////////
 
$sql = "SELECT * FROM messages WHERE to_id =$user_id AND indexer = $indexer";
$query = @mysql_query($sql);
$result = @mysql_fetch_array($query);
$message = wordwrap($result['message'], 20, " ", true);
$subject = wordwrap($result['subject'], 20, " ", true);
$email_id= $result['indexer'];

And change it to

///////////////////////////////////////////
//show message
///////////////////////////////////////////
 
$sql = "SELECT * FROM messages WHERE to_id =$user_id AND indexer = $indexer";
$query = @mysql_query($sql);
$result = @mysql_fetch_array($query);
$message = wordwrap($result['message'], 20, " ", true);
$subject = wordwrap($result['subject'], 20, " ", true);
$email_id= $result['indexer'];
 
$sql2 = "UPDATE messages SET message_status = 'read' WHERE to_id =$user_id AND indexer = $indexer";
@mysql_query($sql2);

And open and edit emailcompose.php and find

////////////////
//record message
////////////////
 
$sql = "INSERT into messages (from_username, subject, message, todays_date, to_id) VALUES ('$user_name', '$subject', '$message', '$todays_date', $to_id)";
@mysql_query($sql) or die(header("Location: " . "system_error.php?code=101"));

And change to

 ////////////////
//record message
////////////////
 
$sql = "INSERT into messages (from_username, subject, message, todays_date, to_id, message_status) VALUES ('$user_name', '$subject', '$message', '$todays_date', $to_id, 'unread')";
@mysql_query($sql) or die(header("Location: " . "system_error.php?code=101"));

Open play.php
add

$sql = "UPDATE member_profile SET video_viewed=(video_viewed + 1) WHERE user_id = $user_id";
$query = @mysql_query($sql);

after

$sql = "UPDATE videos SET number_of_views = $views_counter WHERE indexer = $vid";
$query = @mysql_query($sql);

Open uploader_finished.php and add

$sql2 = "UPDATE member_profile SET uploaded=(uploaded + 1) WHERE user_id = $user_id";
@mysql_query($sql2);

After

$sql = "INSERT INTO videos
(video_id, GID, title, description, tags, channel, date_uploaded, location_recorded, video_length, allow_comments, allow_embedding, rating_number_votes,
rating_total_points, updated_rating, public_private, approved, number_of_views, user_id) VALUES ('$uploaded_file_name', '$GID', '$title', '$description', '$tags',
'$channel', '$date_uploaded', '$location_recorded', '0h 0mins', '$allow_comments', '$allow_embedding', 0, 0, 0, '$public_private', 'pending_conversion', 0, $user_id)";
 
@mysql_query($sql);

Open myvideos.php and add

 $sql = "UPDATE member_profile SET uploaded=(uploaded - 1) WHERE user_id = $user_id";
@mysql_query($sql);

After

 //delete from videocomments
$sql = "DELETE FROM videocomments WHERE video_id = $video_id";
@mysql_query($sql);

Leave a Reply

Listed on BlogShares