Bravo List

Bravo List (http://www.bvlist.com/index.php)
-   Yuna Scatari Edition (YSE) (http://www.bvlist.com/forumdisplay.php?f=22)
-   -   Promoting to VIP for certain time. Auto demote. (http://www.bvlist.com/showthread.php?t=8874)


");

        if ($viptime) {
                $vipuntil = $user['vipuntil'];
                if ($vipuntil == '0000-00-00 00:00:00')
                    print("\n");
                else {
                    print("\n");
            }
  } else {
    print("\n");
    print("");
  }
// 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
mat22 13th February 2013 21:19

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.:mad:

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("
VIP uz laiku " .
( $viptime
  ? "".$tracker_lang['yes']."".$tracker_lang['no'].""
        : "".$tracker_lang['no']."" ) ."
Uz bezgalīgu termiņu
Līdz $vipuntil");
                    print(" (" . mkprettytime(strtotime($vipuntil) - gmtime()) . " palicis)
VIP līdz
  Komentārs PZ:     

joeroberts 13th February 2013 22:32

first off you need to define a few things

$viptime=??

$curvip=???

mat22 14th February 2013 08:41

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



All times are GMT +2. The time now is 15:46.

Powered by vBulletin® Version 3.8.11 Beta 3
Copyright ©2000 - 2024, vBulletin Solutions Inc.