Bravo List
Register
Go Back   > Bravo List > Sourcecode > YSE
Reply
  #1  
Old 13-02-13, 21:19
mat22's Avatar
mat22 mat22 is offline
Senior Member
 
Join Date: Jun 2009
Latvia
Posts: 119
Default Promoting to VIP for certain time. Auto demote.
Hello!
So I've been struggling with this whole day and I feel really stupid because I can't get this to work even partly.

So what I tried to do is make a system where I can promote users to VIP for certain time (1 week, 2 weeks etc.) and after the time ends - they get automatically demoted (that part I haven't made yet but that's the easiest part). Problem is - even promoting isn't working. That's so annoying. Haha.
So I thought maybe someone can take a quick look at my code and say what's wrong.

userdetails.php part of code
Code:
// VIP ar termiņu
print("<tr><td class=\"rowhead\"" . (!$warned ? " rowspan=\"2\"": "") . ">VIP uz laiku</td>
<td align=\"left\" width=\"20%\">" .
( $viptime
  ? "<input name=\"viptime\" value=\"yes\" type=\"radio\" checked>".$tracker_lang['yes']."<input name=\"viptime\" value=\"no\" type=\"radio\">".$tracker_lang['no'].""
 	: "".$tracker_lang['no']."" ) ."</td>");

	if ($viptime) {
		$vipuntil = $user['vipuntil'];
		if ($vipuntil == '0000-00-00 00:00:00')
    		print("<td align=\"center\">Uz bezgalīgu termiņu</td></tr>\n");
		else {
    		print("<td align=\"center\">Līdz $vipuntil");
	    	print(" (" . mkprettytime(strtotime($vipuntil) - gmtime()) . " palicis)</td></tr>\n");
 	    }
  } else {
    print("<td>VIP līdz<select name=\"viplength\">\n");
    print("<option value=\"0\">------</option>\n");
    print("<option value=\"1\">1 ".$tracker_lang['week']."</option>\n");
    print("<option value=\"2\">2 ".$tracker_lang['weeks']."</option>\n");
    print("<option value=\"4\">4 ".$tracker_lang['weeks']."</option>\n");
    print("<option value=\"8\">8 ".$tracker_lang['weeks']."</option>\n");
    print("<option value=\"255\">".$tracker_lang['unlimited']."</option>\n");
    print("</select></td></tr>\n");
    print("<tr><td colspan=\"2\" align=\"left\">&nbsp;&nbsp;Komentārs PZ:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"text\" size=\"60\" name=\"vippm\"></td></tr>");
  }
// VIP ar termiņu beigas
modtask.php code part
Code:
//VIP time
if ($viptime && $curvip != $viptime) {
    $updateset[] = "viptime = " . sqlesc($viptime);
    $updateset[] = "viptime = '0000-00-00 00:00:00'";
	$updateset[] = "class = ".$arr['oldclass'].;
    $oldclass = $arr['class'];
    if ($viptime == 'no') {
        $modcomment = gmdate("Y-m-d") . " - VIP noņēma - " . $CURUSER['username'] . ".\n". $modcomment;
        $msg = sqlesc("" . $CURUSER['username'] . " - Noņēma tev VIP.");
    }
    
    $added = sqlesc(get_date_time());
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    
} elseif ($viplength) {
    
    if ($viplength == 255) {
        $modcomment = gmdate("Y-m-d") . " - Tev VIP uzlika " . $CURUSER['username'] . "\nIemesls: $vippm\n" . $modcomment;
        $msg = sqlesc("Jūs tikātpaaugstināts uz VIP no $CURUSER[username]." . ($vippm ? "\nIemesls: $vippm" : ""));
        $updateset[] = "vipuntil = '0000-00-00 00:00:00'";
		mysql_query("UPDATE users SET oldclass=$oldclass AND class = '6'") or sqlerr(__FILE__, __LINE__);
    } else {
        $vipuntil = get_date_time(gmtime() + $viplength * 604800);
        $dur = $viplength . " nedēļ" . ($viplength > 1 ? "ām" : "u");
        $msg = sqlesc("Jūs tikāt paaugstināts par VIP uz $dur no " . $CURUSER['username'] . "." . ($warnpm ? "\nIemesls: $vippm" : ""));
        $modcomment = gmdate("Y-m-d") . " - Paaugstināts par VIP uz $dur no " . $CURUSER['username'] .  "\nIemesls: $vippm\n" . $modcomment;
		mysql_query("UPDATE users SET oldclass=$oldclass AND class = '6'") or sqlerr(__FILE__, __LINE__);
	   $updateset[] = "vipuntil = '$vipuntil'";
    }
    
    $added = sqlesc(get_date_time());
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    $updateset[] = "viptime = 'yes', vipby=$CURUSER[id], oldclass=$oldclass, class = '6'";
}

// VIP time - end
And database part
Code:
ALTER TABLE  `users` ADD  `viptime` ENUM(  'yes',  'no' ) CHARACTER SET latin1 COLLATE latin1_swedish_ci NOT NULL DEFAULT  'no',
ADD  `vipuntil` DATETIME NOT NULL ,
ADD  `vipby` VARCHAR( 40 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT  '0000-00-00 00:00:00',
ADD  `oldclass` INT NOT NULL ;
P.S. For database I was to lazy to write everything myself with hand so I used phpmyadmin and added rows to users table that's why there's that "ALTER TABLE" thing.:D

Last edited by mat22; 13-02-13 at 21:31.
Reply With Quote
  #2  
Old 13-02-13, 22:32
joeroberts's Avatar
joeroberts joeroberts is offline
BT.Manager Owner
 
Join Date: Jan 2008
United States
Posts: 1,988
Default
first off you need to define a few things

$viptime=??

$curvip=???
__________________
Do not ask me to help you work on your site that is not phpMyBitTorrent
Do not ask me to make a mod for any other source
Do not Ask me to setup your site.
I will no longer help you setup your site, there is a setup script if you have trouble with it post in the forum here or in BT.Managerô forum
My Current Demo is here http://demo.btmanager.org/
Reply With Quote
The Following User Says Thank You to joeroberts For This Useful Post:
mat22 (28-03-13)
  #3  
Old 14-02-13, 08:41
mat22's Avatar
mat22 mat22 is offline
Senior Member
 
Join Date: Jun 2009
Latvia
Posts: 119
Default
Sorry my bad. Forgot to copy few lines. I'll add them as soon as I get home to my computer.

Edit
$viptime in userdetails.php
Code:
$viptime = $user["viptime"] == "yes";
and modtask.php lines I forgot to copy
Code:
$curvip = $arr["viptime"];
$viptime = $_POST["viptime"];
$vipength = 0 + $_POST["viplength"];
$vippm = $_POST["vippm"];
Edit 2
Changed some stuff in modtask.php and now it doesn't work at all. LOL.
Code:
//VIP time

if ($viptime && $curvip != $viptime) {
    $updateset[] = "viptime = " . sqlesc($viptime);
    $updateset[] = "viptime = '0000-00-00 00:00:00'";
	$updateset[] = "class = ".$arr['oldclass'].;
    $oldclass = $arr['class'];
    if ($viptime == 'no') {
        $modcomment = gmdate("Y-m-d") . " - VIP noņēma - " . $CURUSER['username'] . ".\n". $modcomment;
        $msg = sqlesc("" . $CURUSER['username'] . " - Noņēma tev VIP.");
    }
    
    $added = sqlesc(get_date_time());
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    
} elseif ($viplength) {
    
    if ($viplength == 255) {
        $modcomment = gmdate("Y-m-d") . " - Tev VIP uzlika " . $CURUSER['username'] . "\nIemesls: $vippm\n" . $modcomment;
        $msg = sqlesc("Jūs tikātpaaugstināts uz VIP no $CURUSER[username]." . ($vippm ? "\nIemesls: $vippm" : ""));
        $updateset[] = "vipuntil = '0000-00-00 00:00:00'";
		mysql_query("UPDATE users SET oldclass=$oldclass AND class = '6'") or sqlerr(__FILE__, __LINE__);
    } else {
        $vipuntil = get_date_time(gmtime() + $viplength * 604800);
        $dur = $viplength . " nedēļ" . ($viplength > 1 ? "ām" : "u");
        $msg = sqlesc("Jūs tikāt paaugstināts par VIP uz $dur no " . $CURUSER['username'] . "." . ($warnpm ? "\nIemesls: $vippm" : ""));
        $modcomment = gmdate("Y-m-d") . " - Paaugstināts par VIP uz $dur no " . $CURUSER['username'] .  "\nIemesls: $vippm\n" . $modcomment;
		mysql_query("UPDATE users SET oldclass=$oldclass AND class = '6'") or sqlerr(__FILE__, __LINE__);
	   $updateset[] = "vipuntil = '$vipuntil'";
    }
    
    $added = sqlesc(get_date_time());
    mysql_query("INSERT INTO messages (sender, receiver, msg, added) VALUES (0, $userid, $msg, $added)") or sqlerr(__FILE__, __LINE__);
    $updateset[] = "viptime = 'yes', vipby=$CURUSER[id], oldclass=$oldclass, class = '6'";
}

// VIP time - end

Last edited by mat22; 14-02-13 at 13:10.
Reply With Quote
Reply

Tags
auto , demote , promoting , time , vip

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



All times are GMT +2. The time now is 06:00. vBulletin skin by ForumMonkeys. Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2017, vBulletin Solutions Inc.