|
#1
|
|||
|
|||
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\"> Komentārs PZ: <input type=\"text\" size=\"60\" name=\"vippm\"></td></tr>"); } // VIP ar termiņu beigas 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 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 ; Last edited by mat22; 13th February 2013 at 21:31. |
#2
|
||||
|
||||
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/ |
The Following User Says Thank You to joeroberts For This Useful Post: | ||
mat22 (28th March 2013)
|
#3
|
|||
|
|||
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"; Code:
$curvip = $arr["viptime"]; $viptime = $_POST["viptime"]; $vipength = 0 + $_POST["viplength"]; $vippm = $_POST["vippm"]; 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; 14th February 2013 at 13:10. |
Tags |
auto , demote , promoting , time , vip |
|
|