Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP
Author Message
wHiTeHaT
Life Cycles Becoming CPU Cycles



Joined: Jul 18, 2004
Posts: 579

PostPosted: Sun Aug 02, 2009 3:43 pm Reply with quote

Hello @all ,

I'm having a little issue wich i cant resolve.
I need to execute a function 1 time only until the user logs out.
i have tried several scenarios like

$execute = false

if !execute function() etc etc
So as the interval option $a --- $a++

However these fale couse the mainfile is called everytime , especialy the function is_user ( for what my function going to be).

Is there a workaround for this?
The function is_user i place here for a quick reference:
Code:
function is_user($user) {


    if (!$user) { return 0; }

    static $userSave;
    if (isset($userSave)) return $userSave;
    if (!is_array($user)) {
        $user = base64_decode($user);
        $user = addslashes($user);
        $user = explode(':', $user);
    }
    $uid = $user[0];
    $pwd = $user[2];
    $uid = intval($uid);
    if (!empty($uid) AND !empty($pwd)) {
        global $db, $user_prefix;
        $sql = 'SELECT user_password, user_email FROM '.$user_prefix.'_users WHERE user_id=\''.$uid.'\'';
        $result = $db->sql_query($sql);
        $row = $db->sql_fetchrow($result);
        if ($row[0] == $pwd && !empty($row[0])) {

       ///Here i need to call my function 1 time only
        if(!isset($_COOKIE['whitehat'])) {
        myfunction();
        setcookie('whitehat', session_id, 0);
        }
     
       
            return $userSave = 1;
        }
    }
    return $userSave = 0;
}

[EDIT]
Great ..how a man can find out himself.

FYI:
Code:



 if(!isset($_COOKIE['whitehat'])) {
      myfunction();
    setcookie('whitehat', session_id, 0);
}


Then when logout let the cookie delete.
 
View user's profile Send private message Send e-mail
Dawg
RavenNuke(tm) Development Team



Joined: Nov 07, 2003
Posts: 928

PostPosted: Sun Aug 02, 2009 5:20 pm Reply with quote

Over the years of posting here I have always found it easier to solve my own problems after making my post here....Why? Because YOU KNOW these guys are going to ask really good questions about what ever youa re doing so you try really hard to explain it and break it down so they can understand....and POOF....the solution just seems to come.

Dawg
 
View user's profile Send private message
eldorado
Involved
Involved



Joined: Sep 10, 2008
Posts: 424
Location: France,Translator

PostPosted: Mon Aug 03, 2009 5:34 am Reply with quote

hehe , yes indeed dawg , happens to me everytime.

_________________
United-holy-dragons.net (My RN site)- Rejekz(cod4 clan) - gamerslounge 
View user's profile Send private message Visit poster's website MSN Messenger
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> PHP

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©