time = time(); $this->startSession(); } /** * startSession - Performs all the actions necessary to * initialize this session object. Tries to determine if the * the user has logged in already, and sets the variables * accordingly. Also takes advantage of this page load to * update the active visitors tables. */ function startSession(){ global $database; //The database connection session_start(); //Tell PHP to start the session /* Determine if user is logged in */ $this->logged_in = $this->checkLogin(); /** * Set guest value to users not logged in, and update * active guests table accordingly. */ if(!$this->logged_in){ $this->username = $_SESSION['username'] = GUEST_NAME; $this->userlevel = GUEST_LEVEL; $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time); } /* Update users last active timestamp */ else{ $database->addActiveUser($this->username, $this->time); } /* Remove inactive visitors from database */ $database->removeInactiveUsers(); $database->removeInactiveGuests(); /* Set referrer page */ if(isset($_SESSION['url'])){ $this->referrer = $_SESSION['url']; }else{ $this->referrer = "/"; } /* Set current url */ $this->url = $_SESSION['url'] = $_SERVER['PHP_SELF']; } /** * checkLogin - Checks if the user has already previously * logged in, and a session with the user has already been * established. Also checks to see if user has been remembered. * If so, the database is queried to make sure of the user's * authenticity. Returns true if the user has logged in. */ function checkLogin(){ global $database; //The database connection /* Check if user has been remembered */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){ $this->username = $_SESSION['username'] = $_COOKIE['cookname']; $this->userid = $_SESSION['userid'] = $_COOKIE['cookid']; } /* Username and userid have been set and not guest */ if(isset($_SESSION['username']) && isset($_SESSION['userid']) && $_SESSION['username'] != GUEST_NAME){ /* Confirm that username and userid are valid */ if($database->confirmUserID($_SESSION['username'], $_SESSION['userid']) != 0){ /* Variables are incorrect, user not logged in */ unset($_SESSION['username']); unset($_SESSION['userid']); return false; } /* User is logged in, set class variables */ $this->userinfo = $database->getUserInfo($_SESSION['username']); $this->username = $this->userinfo['username']; $this->userid = $this->userinfo['userid']; $this->userlevel = $this->userinfo['userlevel']; return true; } /* User not logged in */ else{ return false; } } /** * login - The user has submitted his username and password * through the login form, this function checks the authenticity * of that information in the database and creates the session. * Effectively logging in the user if all goes well. */ function login($subuser, $subpass, $subremember){ global $database, $form; //The database and form object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Check if username is not alphanumeric */ if(!eregi("^([0-9a-z])*$", $subuser)){ $form->setError($field, "* only letters and numbers allowed and no spaces"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } /* Checks that username is in database and password is correct */ $subuser = stripslashes($subuser); $result = $database->confirmUserPass($subuser, md5($subpass)); /* Check error codes */ if($result == 1){ $field = "user"; $form->setError($field, "* Username not found"); } else if($result == 2){ $field = "pass"; $form->setError($field, "* Invalid password"); } /* Return if form errors exist */ if($form->num_errors > 0){ return false; } /* Username and password correct, register session variables */ $this->userinfo = $database->getUserInfo($subuser); $this->username = $_SESSION['username'] = $this->userinfo['username']; $this->userid = $_SESSION['userid'] = $this->generateRandID(); $this->userlevel = $this->userinfo['userlevel']; /* Insert userid into database and update active users table */ $database->updateUserField($this->username, "userid", $this->userid); $database->addActiveUser($this->username, $this->time); $database->removeActiveGuest($_SERVER['REMOTE_ADDR']); /** * This is the cool part: the user has requested that we remember that * he's logged in, so we set two cookies. One to hold his username, * and one to hold his random value userid. It expires by the time * specified in constants.php. Now, next time he comes to our site, we will * log him in automatically, but only if he didn't log out before he left. */ if($subremember){ setcookie("cookname", $this->username, time()+COOKIE_EXPIRE, COOKIE_PATH); setcookie("cookid", $this->userid, time()+COOKIE_EXPIRE, COOKIE_PATH); } /* Login completed successfully */ return true; } /** * logout - Gets called when the user wants to be logged out of the * website. It deletes any cookies that were stored on the users * computer as a result of him wanting to be remembered, and also * unsets session variables and demotes his user level to guest. */ function logout(){ global $database; //The database connection /** * Delete cookies - the time must be in the past, * so just negate what you added when creating the * cookie. */ if(isset($_COOKIE['cookname']) && isset($_COOKIE['cookid'])){ setcookie("cookname", "", time()-COOKIE_EXPIRE, COOKIE_PATH); setcookie("cookid", "", time()-COOKIE_EXPIRE, COOKIE_PATH); } /* Unset PHP session variables */ unset($_SESSION['username']); unset($_SESSION['userid']); /* Reflect fact that user has logged out */ $this->logged_in = false; /** * Remove from active users table and add to * active guests tables. */ $database->removeActiveUser($this->username); $database->addActiveGuest($_SERVER['REMOTE_ADDR'], $this->time); /* Set user level to guest */ $this->username = GUEST_NAME; $this->userlevel = GUEST_LEVEL; } /** * register - Gets called when the user has just submitted the * registration form. Determines if there were any errors with * the entry fields, if so, it records the errors and returns * 1. If no errors were found, it registers the new user and * returns 0. Returns 2 if registration failed. */ function register($subuser, $subpass, $subemail){ global $database, $form, $mailer; //The database, form and mailer object /* Username error checking */ $field = "user"; //Use field name for username if(!$subuser || strlen($subuser = trim($subuser)) == 0){ $form->setError($field, "* Username not entered"); } else{ /* Spruce up username, check length */ $subuser = stripslashes($subuser); if(strlen($subuser) < 5){ $form->setError($field, "* Username below 5 characters"); } else if(strlen($subuser) > 30){ $form->setError($field, "* Username above 30 characters"); } /* Check if username is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", $subuser)){ $form->setError($field, "* * only letters and numbers allowed and no spaces"); } /* Check if username is reserved */ else if(strcasecmp($subuser, GUEST_NAME) == 0){ $form->setError($field, "* Username reserved word"); } /* Check if username is already in use */ else if($database->usernameTaken($subuser)){ $form->setError($field, "* Username already in use"); } /* Check if username is banned */ else if($database->usernameBanned($subuser)){ $form->setError($field, "* Username banned"); } } /* Password error checking */ $field = "pass"; //Use field name for password if(!$subpass){ $form->setError($field, "* Password not entered"); } else{ /* Spruce up password and check length*/ $subpass = stripslashes($subpass); if(strlen($subpass) < 4){ $form->setError($field, "* Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subpass = trim($subpass)))){ $form->setError($field, "* * only letters and numbers allowed and no spaces"); } /** * Note: I trimmed the password only after I checked the length * because if you fill the password field up with spaces * it looks like a lot more characters than 4, so it looks * kind of stupid to report "password too short". */ } /* Email error checking */ $field = "email"; //Use field name for email if(!$subemail || strlen($subemail = trim($subemail)) == 0){ $form->setError($field, "* Email not entered"); } else{ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return 1; //Errors with form } /* No errors, add the new account to the */ else{ if($database->addNewUser($subuser, md5($subpass), $subemail)){ if(EMAIL_WELCOME){ $mailer->sendWelcome($subuser,$subemail,$subpass); } return 0; //New user added succesfully }else{ return 2; //Registration attempt failed } } } /** * editAccount - Attempts to edit the user's account information * including the password, which it first makes sure is correct * if entered, if so and the new password is in the right * format, the change is made. All other fields are changed * automatically. */ function editAccount($subcurpass, $subnewpass, $subemail){ global $database, $form; //The database and form object /* New password entered */ if($subnewpass){ /* Current Password error checking */ $field = "curpass"; //Use field name for current password if(!$subcurpass){ $form->setError($field, "* Current Password not entered"); } else{ /* Check if password too short or is not alphanumeric */ $subcurpass = stripslashes($subcurpass); if(strlen($subcurpass) < 4 || !eregi("^([0-9a-z])+$", ($subcurpass = trim($subcurpass)))){ $form->setError($field, "* Current Password incorrect"); } /* Password entered is incorrect */ if($database->confirmUserPass($this->username,md5($subcurpass)) != 0){ $form->setError($field, "* Current Password incorrect"); } } /* New Password error checking */ $field = "newpass"; //Use field name for new password /* Spruce up password and check length*/ $subpass = stripslashes($subnewpass); if(strlen($subnewpass) < 4){ $form->setError($field, "* New Password too short"); } /* Check if password is not alphanumeric */ else if(!eregi("^([0-9a-z])+$", ($subnewpass = trim($subnewpass)))){ $form->setError($field, "* New Password not alphanumeric"); } } /* Change password attempted */ else if($subcurpass){ /* New Password error reporting */ $field = "newpass"; //Use field name for new password $form->setError($field, "* New Password not entered"); } /* Email error checking */ $field = "email"; //Use field name for email if($subemail && strlen($subemail = trim($subemail)) > 0){ /* Check if valid email address */ $regex = "^[_+a-z0-9-]+(\.[_+a-z0-9-]+)*" ."@[a-z0-9-]+(\.[a-z0-9-]{1,})*" ."\.([a-z]{2,}){1}$"; if(!eregi($regex,$subemail)){ $form->setError($field, "* Email invalid"); } $subemail = stripslashes($subemail); } /* Errors exist, have user correct them */ if($form->num_errors > 0){ return false; //Errors with form } /* Update password since there were no errors */ if($subcurpass && $subnewpass){ $database->updateUserField($this->username,"password",md5($subnewpass)); } /* Change Email */ if($subemail){ $database->updateUserField($this->username,"email",$subemail); } /* Success! */ return true; } /** * isAdmin - Returns true if currently logged in user is * an administrator, false otherwise. */ function isAdmin(){ return ($this->userlevel == ADMIN_LEVEL || $this->username == ADMIN_NAME); } /** * generateRandID - Generates a string made up of randomized * letters (lower and upper case) and digits and returns * the md5 hash of it to be used as a userid. */ function generateRandID(){ return md5($this->generateRandStr(16)); } /** * generateRandStr - Generates a string made up of randomized * letters (lower and upper case) and digits, the length * is a specified parameter. */ function generateRandStr($length){ $randstr = ""; for($i=0; $i<$length; $i++){ $randnum = mt_rand(0,61); if($randnum < 10){ $randstr .= chr($randnum+48); }else if($randnum < 36){ $randstr .= chr($randnum+55); }else{ $randstr .= chr($randnum+61); } } return $randstr; } }; /** * Initialize session object - This must be initialized before * the form object because the form uses session variables, * which cannot be accessed unless the session has started. */ $session = new Session; /* Initialize form object */ $form = new Form; ?> Ricky Gervais... Obviously. " ."" .""; $forminput = "" ."" ."" . ""; if($session->logged_in){ $toptagline ="" ."" .""; $forminput = ""; } else{ /** * User not logged in, display the login form. * If user has already tried to login, but errors were * found, display the total number of errors. * If errors occurred, they will be displayed. */ if($form->num_errors > 0){ $errorline = ""; } } $membersline = "There are ".$database->getNumMembers()." members signed up to Ricky Gervais.Com - ". $database->num_active_users ." are signed in now and there are " . $database->num_active_guests. " people just visiting"; ?>



Ben Stiller. Ricky Gervais. Together for the first time since Extras with wild comedy Night At The Museum. Total Film pairs up the planet's leading comic talents to sound off on ego, slapped monkeys and sleeping like a snake ...

WORDS JONATHAN DEAN, TOTAL FILM

Ben   Ricky ...

Ricky   Oh, you again.

Ben   How's it going?

Ricky   Good, thanks. To kick off, I'd just like to say that Ben Stiller is not only one of the best comic actors in the world, he is also a talented comedian, writer, director and producer. He's an honest man, he is a handsome man ... I'd like to thank him for the opportunity to work on Night At The Museum and I'd like to thank him for his appearance in Extras, series one, episode two. You can also catch the new series of Extras on HBO from 14 January, but if that's not your bag, why not download my podcasts on iTunes? Both audiobooks. I'm off to have dinner with Christopher Guest later ... So, your turn ...

Total Film   How can you come back to that, Ben?

Ben   I think he said it all, I think that sums up Ricky. That's everything you need to know about him as a person. Of course I was excited to work with Ricky again after Extras - even though that experience was kind of funny. He'd said, "Hey, can you do a part on my show?" And I was like, "Yeah, definitely:' So I was committed before I'd read the script. After reading, I was horrified that that's how Ricky saw me. I thought it was going to be some great funny turn, but instead I'm this monster. I literally called my agent after I did the show and wanted to see if I could get it taken off the air. I was so mortified ...

Ricky   No, that's not true! [Laughs]

Ben   No, it's not true, but I was so freaked out. I was freaked because, while I thought it was hilarious, I thought, "Are people going to know that it's funny and is supposed to be a joke?" And that to me is what's so great about Ricky's humour - there's a fine line between reality and what's funny that can be so uncomfortable...

Total Film   So Ricky, where did you hear about the diva-rumours that you then exaggerated for Ben's character in Extras?

Ricky   I totally made it up! I never dreamt he was like that! I've got no evidence that he is like that. I... No ... I... Oh, I'm being wound up here aren't I?

Ben   Listen to him stutter, you've got him in a bad way.

Ricky   No, the first time I met Ben, I thought he was actually refreshingly shy. And I never, I never dreamt... Like the speech where he goes Along Came Polly grossing this, grossing that, all the films and that ... we didn't write that, that was an ad-lib. I don't know where he got that from.

Ben   I don't know either, it just sort of came out of the ether. What really freaked me out was that, when I read it, I was like "Oh my God, he's really tapped into my true dark self:'

Total Film   On the spot then, five words to describe each other ...

Ricky   If Ben can hear, I think three of them would be 'talented; then two would be 'handsome' ...

Ben   [Laughs] I would say 'comedy; 'genius' and then you don't even need three words after that.

Ricky   Actually, I'd try and make it grammatically correct so I'd say "Ben Stiller is a man:' And then I'd have run out of words.

Total Film   Sounds like you guys would like to work together again.

Ricky   We certainly are going to - I don't think that's giving too much away. Ben, what do you think?

Ben   If we can figure out a contract able to support it. Because Ricky has a huge perk-package. Like trailer, entourage, private jet...

Ricky   Or, it could be filmed in my flat, because all that stuff about having to get up early, going somewhere to film it and then waiting around ... That really, really annoys me.

Ben   It is known that Ricky won't work before noon or after 4pm there are four hours during the day that Ricky calls the "Sweet Spot" for him. That's when the good stuff comes.

Ricky   Yeah, 2pm is the golden hour. That's when I've got enough bloodsugar, but I will have to sleep soon. Like a snake.

Ben   He sleeps about 12 hours a day.

Ricky   So yeah, you've really got to catch me.

Ben   Got a pad by the bed for the dreams. That's where a lot of the inspiration comes from. The dreams.

Ricky   But yeah, Ben and I have been racking our brains because we do want to work together again. We had a good time on Extras, but that was very intense. And Night At The Museum was only three days, but there was one scene in particular where we found a mutual dynamic that really, really worked.

Ben   Yeah! [Laughs]

Ricky   Something just happened, and neither of us, neither of us could look the other one in the eye, which has got to be a good thing. If an actor's laughing, then something's funny.

Ben   Yeah, that scene ... Basically Ricky's the curator at the museum and I'm the night guard there and, as you know, the exhibits come to life at night - but obviously nobody believes that happens. So I'm trying to explain to him what happened and he thinks I'm pulling his leg, so he berates me. But the way he started reacting to my character's explanation, he sort of did this mock-laughter in my face, where he'd hold his belly ... [Laughs] .

Ricky   It's an interesting dynamic. That scene's funny. Or, I don't know ... With Ben, maybe he'd taken some crack as well.

Ben   It was just enjoyable. It actually reminded me of Meet The Parents. I remember during the first scene I had to do with Robert De Niro, I broke up laughing in his face and was mortified because he did something that made me laugh: I was like, "Oh my God, this is my first scene with De Niro and I'm laughing in his face!" And yet it was the same experience, working with Ricky. I think Ricky's dead on when he says that you want actors to laugh because then you know that something real is going on and they're feeling it.

Ricky   I'd just like to say that when you do the article, remember what Ben said. The headline should be "Working With Ricky Was Like Working With De Niro:'

Ben   Yeah, "Ricky Gervais Is My Hero:'

Total Film   Noted. Ben, what first attracted you to Night At The Museum? It's refreshing to have a family film this Christmas that isn't a cartoon ...

Ben   I was attracted to it on a gut level. Even the title intrigued me because I grew up in New York City, about four or five blocks from the Museum Of Natural History, so I was going there all the time as a kid. Any museum of that kind has a magical quality - the stuffed animals, dioramas and dinosaur skeletons, so I really just felt a gut childhood connection. I've been discovering kids'movies in the last five years since I've had my own and I've really been appreciating the good ones that you can watch with them. People don't really make live-action movies like they did any more, so I thought this was a chance for a movie that, like you said, wasn't an animated movie, but yet had a magical quality. And wasn't too cheesy. I didn't want it to be too sappy.

Ricky   I never thought about doing a big family blockbuster, but Ben sent me an e-mail about it and when I read the film, I thought, "Wow, it's really, really good:' I like a film that's funny, but with heart. I like to do comedy. I don't want to do action. It would be absurd! Imagine me in a vest, going, "Yippie-ki-yay, motherfucker!" It just wouldn't work would it? Bruce Willis does it well, but you know ...

Total Film   Also, it's a couple of days shooting with Ben ...

Ricky   Yeah, I've jumped straight to cameo. I didn't build up a film career, become a leading man and do good work for 20 years. They say it's two weeks filming, I go, "I can give you three days:' I enjoy filming these things - they're like days off for me, diversions. A couple of days filming with De Niro [2007's Stardust], a couple of days filming with Ben ...

Ben   This has got a really interesting amalgam of actors in it, though. Mickey Rooney, Dick Van Dyke, Owen Wilson, Steve Coogan there's this sort of crazy combination of cross-generational people. And on top of that there's dinosaurs, lions, elephants and CG woolly mammoths and Attila the Hun ... I mean what do you do with that?

Ricky   Yeah! There's one hilarious scene, which I've never quite seen the likes of before in a film, where Ben's having a fight with a monkey and he's slapping the monkey, he's having a slapping fight with this monkey! And then Robin Williams ppears as Theodore Roosevelt and says, "My God man, why are you slapping a monkey?" Which is one of the best questions you can ever ask in any situation in life. "My God man, why are you slapping a monkey?" [Huge great belly laugh]

Total Film   You're in a museum and the artefacts come to life ... What historical characters would you like to have a conversation with?

Ricky   Well, anything would amazing.

Ben   For me, I love all American history so perhaps someone from the American Revolution. Or of course Teddy Roosevelt, a guy who stands so many ideals - a masculine thing, a sense of self and sayings about man finding his own strength in his own resources, of finding your own ideals and fighting for them. But what was Teddy really like, as a person? To us he's a statue outside a museum with a big stick. Who was that person really? I'm just interested in history, really, so any of,those historical characters or figures as real people would be interesting.

Total Film   And how would you explain to Roosevelt what you do?

Ben   [Laughs] He's a President and a soldier ... Well, I'd explain to hiin that I'm an entertainer, actor. It all falls under amusement.

Ricky   I'd like to go back and talk to pioneers. I'd say, "What were you thinking there? Why did you do that?" Just thinking of a world when there wasn't so much stuff... How did the Greek philosophers... Where did they start? What did they have to go on? It's incredible, y'know, that Newton quote, "If I have seen farther than others, it is because I've stood on the shoulders of giants:' And it's great that the further you go back, the less shoulders you have to ' stand on. I was trying to inflaine Karl Pilkington and I told him that quote. And he went, "Well, that's annoying. Why isn't he giving people a namecheck? I'd be annoyed if I was one of those whose shoulders he'd stood on. I'd go, 'Oh, why isn't he naming me? Why is he keeping it to himself?'" He should have gone, "Well, there was Ted, he gave me the idea for the apple:' Science fascinates me.

Ben   And human beings have obviously created so much and are so sophisticated, but then you take regular people, like us ... If I went to the past and had to explain the concept of electricity, I wouldn't know shit. We have all these incredible advancements that human kind has come up with, but I'm just a guy who watches TV.

Total Film   Ricky, just to make him blush - what stand-outs for you from Ben's career?

Ricky   Ben plays the put-uponbloke-with -bad -luck-that's-tryingto-do-the-right-thing better than anyone in the world at the moment. It's just great, it's engaging. He's got likeability and he's also got edge. One of my favourite bits in a comedy film is in Meet The Parents where his girlfriend comes into his room and he's just sitting cross-legged. She goes, "Hey, what's up?" and he goes, "Oh, I'm just sitting here going over some of the answers I gave on the polygraph test that your father just gave me ... " It's just the way he plays it. [Laughs] Just a little bit of sarcasm, a little bit stunned. He's out of his depth.

Total Film   And Ben, if you had to write a character for Ricky in Extras, to get him back for your one, how would you do that?

Ben   [Laughs] Ricky ... I think he's already created the ultimate selfinvolved, insecure character in David Brent. But he's always the first person to wind himself up and he's so self-effacing. But he could play the totally self-involved Ricky Gervais ... I'd write him as a self-effacing guy, but then when he's alone, you'd see that he was a total megalomaniacal, egotistical, self-involved guy, who in public plays the nice funny guy ... But, go a level back, and it's all just an act. Ricky I could do that ... I could do that, yeah! Ego is the funniest thing. It's funny that comedians keep coming back to that. It's pretension, ego, the blind-spot. I think it's maybe one of the single funniest things to look at, y'know - the difference between how you see yourself and how people see you. Ben Of course, that is in no way like how he really is. He really is one of the sweetest guys I've met in this business.

Total Film   Someone who is now a recognisable face over in Hollywood ...

Ricky   A recognisable fat face ... With bad teeth. A recognisable round, red face. Apparently, I'm Hollywood's hottest Brit. [Loud, high-pitched laugh] Until someone else comes along!

Total Film   Who's the competition?

Ricky   [Huge, ear piercing laugh as he bangs on the table] I think it's still Sean Connery!

Night At The Museum opens on 26 December and will be reviewed in a future issue of Total Film.




Sign up now and you'll have full access to the site and get the odd email from Ricky when he's got something to tell you.

" ."sign up | forgotten your password?

Already signed up? Sign in here...

username:value("user")."\">".$form->error("user")."
password:value("pass")."\">".$form->error("pass")."

Hello, " .$session->username .". You're signed in.

" ."username\">my details | " ."edit details"; if($session->isAdmin()){ $toptagline = $toptagline." | admin"; } $toptagline = $toptagline." | sign off
".$form->num_errors." error(s) found