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"; ?>


RICKY GERVAIS IS furious about the terrorist threat plaguing UK airports. How will he cope without loads of hand luggage? Specifically, without his iPod? He's got two trips to America coming up and says he wants to ring up the airline to tell them to have an iPod ready and waiting for him when he gets on board. He can do without books: "Not allowed to take novels on flights? Not a problem. Never read 'em!"

He would like a full set of magazines, though. "Loads of back copies of heat would be good to have on the plane ... there are still some things about Grace I don't know!"

He lets out a huge, rasping cackle which echoes round the bare walls of his office. Then he clasps his hands in front of his mouth to get the effect of a tannoy announcement: "We will be landing in one minute ... " he says, adopting the tone of an airline captain, "You still have time to read two copies of heat!"

He apologises for making fun - "What the fuck am I doing? I'm biting the hand that feeds ... You're the magazine that said The Office was the best comedy ever made!" - then explains that heat is mentioned repeatedly in the new series of Extras. Why? Because when we last saw Ricky's character Andy Millman, he was about to have his own sitcom made by the BBC. In this series, he becomes famous and gets embroiled in the insane world of celebrity. A world where, for example, you're given 2,500 watches for free. heat has noticed the stunning TAG Heuer timepiece on Ricky's wrist, which doesn't seem like the kind of item he'd buy for himself. Sure enough, he explains that it was given to him by American GQ for being their Man Of The Year. He leans into heat's recording device and says loudly, "That's American GQ ... Man Of The Year. Man Of The Year. .. in America!"

After another signature cackle, he leans back and relaxes in his swivel chair for the rest of the conversation ...

So, you've been filming Series Two of Extras while Big Brother was on. Did you keep in touch with it?
Yeah, well, it was good that Big Brother was on at 9pm most of the time - I could watch it, then go to bed. But then on Wednesdays it was on at ten, after The F Word, which was annoying. I have to have my eight hours of sleep. And filming starts at Sam. No idea why. We finished at 4pm. Why couldn't we just do lOam till 6pm, like normal jobs? But me and Jane [Ricky's partner] thought Love Island was better.
Really? How come?
Guaranteed madness every episode. Someone screaming and crying and going mental every night. Sometimes Big Brother was just Pete in the Diary Room, and that would take up 24 minutes! [Laughs.]
But, hang on, didn't you hate Love Island last year?
Yeah, but last year everyone in it annoyed me. This lot didn't annoy me so much. They were madder this time, but not as needy. I've got rules! Madness annoys me less than neediness. But it is so entertaining. The ultimate guilty pleasure. It's just like putting insects in a jar and shaking it up and seeing who wins. I know it's awful to compare humans to insects ...
I don't think this lot would be bothered ...
No, they're happy to be insects in the jar as long as it's a televised jar. I remember last year when Jonathan Ross said, "Turn over to Love Island," so I did and they all seemed happy. That's not what I want - I want misery and conflict. So I switched off. This time they gave me what I wanted. And Paul Danan never disappoints ...
In what way?
He goes berserk. That's his job. I think they have less inhibitions on Love Island. With BB you know you're in London in front of hundreds of cameras, but on Love Island they're on a beach and they think they can hide behind a tree; they forget that this is for the telly. They seem to think they really are on holiday - they forget what they've said and done.
Have you ever voted during Big Brother?
No. Never. I'm one of those people who laughs at people doing karaoke but would never go up there and do it myself.
Are you happy with how this series of Extras has turned out?
Well, this is a dangerous thing to say, but I think Series Two of Extras is the funniest thing we've done. I'd like to say it's the best thing we've done, but I don't think it'll have the romantic depth or emotional resonance of The Office. It's more out-andout funny, though.
How does it develop from the first series?
Well, what is different is that if Extras Series One looked like a vehicle for Ricky Gervais, this new girl [Ashley Jensen] and a load of star cameos, Series Two is much more about the four of us: me, Maggie, Steve [Merchant] as my agent and Barry from EastEnders. It's all of us, like a gang, against the world.
And your character becomes a celebrity?
Yeah, it starts off with me getting to make the sitcom I've always wanted to do, and I wanted it to be subtle but everyone's interfered and it's turned into a monstrosity. Maggie is still an extra and she's working on a courtroom romcom with Orlando Bloom. It explores what happens when you put out a comedy that you're not happy with. It's a case of "Be Careful What You Wish For" ...
And among the guest stars is Jonathan Ross?
Yep. I don't want to say too much but there's a scene in Episode Six where me and Jonathan are wrestling each other with our shirts off. It's like Women In Love. But it's all right ... he's got kids and everything.
Is it true that you have to kiss Ian McKellen?
Very nearly. But not quite ... Whoever reported that got it twice removed from what actually happens. But Andy does get involved with Ian McKellen. Professionally.
Which of the guest stars surprised you the most?
The one cameo that is amazing and brilliant is Keith Chegwin. It's in Episode One. I won't say much more about it, all I'll say is that he plays the worst man in the world and he's brilliant. I don't know why he doesn't act full-time. He was remarkable. Generally, the things that we've asked people to do are off the scale. People like Richard and Judy. I still don't know why they say yes.
Last time we spoke, you were looking for a new house. Have you found one?
Yeah, and we are moving out of central London.
Really? Where to?
Hampstead. It's near Jonathan Ross, David Baddiel and the Paltrow-Martins. So I've already got a social network set up! Jonathan's got the tennis court, Chris Martin has a tabletennis table and I'll have a virtual golf course. An indoor golf range. I'm spending my earnings on toys ... [Shakes his head in disbelief.]
You said the next thing you and Steve Merchant write might be a drama ...
Yes, but I never said I'd give up comedy. How could I give up comedy? I've been doing comedy for 44 years. [Thinks.] Wait a minute ... I'm 45 -why did I say I've been doing it for 44 years? What happened in the first year?
Maybe you weren't funny before you were a year old?
[Cackles.] Yeah, I wasn't funny in my silent days. As soon as I could talk, words were my tool! No, I think I forgot that I was 45. My birthday was just recently. So now I forgot how old I am.
So you would like to do a drama series?
Yeah, but I wouldn't necessarily film it in Britain. I'd want it to be like 24 or The Sopranos. I wonder why we've never done anything like those shows in this country. Maybe it's something to do with the climate or our accents or something. But I'd want to try to do a big, brilliantly made drama. And I wouldn't necessarily be in it ...
You said that about Extras ...
[Laughs.] Oh, I know. But you know what? I love acting now ... I got to act with Robert De Niro recently [in the film Stardust] and I loved it. One day's work. And I spent the day ad-libbing, trying to put him off and make him laugh.
And did you succeed?
Yeah. And when he eventually lost it and laughed, I wanted to run round the room celebrating. Then, when we finished, I did that thing of suddenly letting everything flood out and being a nerd. I said, "I think you're brilliant ... you're the best actor in the world ... I've seen everything you've ever done ... " And he looked at me and said, "Thank you very much ... "
So you enjoy doing cameos in big movies now?
Well, yes, I'll always do something if I think it'll be a great experience. Especially if it's just going to take a day or two ... I'll always remember that day with Robert De Niro. And this is the difference between Hollywood and over here: I did this cameo in the new Ben Stiller film (Night At The Museum) and when I arrived, I was taken to this beautiful hotel with an incredible suite. Then I went on set and I'm given this unbelievable trailer, and the director Shaun Levy comes up to me and goes, "Is your trailer OK?" and I said, "It's fine. It's bigger than my hotel room!" and he said, "Well, we can get you a bigger hotel room ... " That's the difference ...
Did you see the French & Saunders joke about you in their Christmas special?
No, I didn't, but Jane told me about it. They said I was "the little fat one with the big ego" or something. I think that's fair comedic satire, the joke being that Dawn French considers herself to be the little fat one with the big ego. I don't think they were having a go. And let's face it, I'm bang to rights! [Pause.] Although I do think she's got a few pounds on me.
Your partner Jane has written a novel that's about to be published, but you don't read novels ... Have you read hers?
No, I haven't read it. It's true I've only ever read one: The Catcher In The Rye, when I was 28. So maybe this should be the second. The thing is, I just don't ever feel the urge to read novels. I'm saving them up for when I can't walk. But my eyes will have gone, so it'll have to be audiobooks.

------------------------------------------------

Extras Series 2 begins Thurs 14 September on BBC2




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