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

October 2006
By Anna Carugati

Widely considered one of the most talented comics working today, Ricky Gervais came to comedy in a roundabout way. He began his career in pop music, managing a band called Suede. He then got a job at a fledgling radio station, where he met up with Stephen Merchant. Together they hosted a radio show and became creative partners, unleashing their zaniness in radio, then in the mega-hit comedy The Office, which won Gervais critical international acclaim and a Golden Globe. In true Gervais form, in front of the audience at the awards ceremony, he started his acceptance speech with, "I'm from a little place called England - we used to run the world before you." Gervais recently wrapped up the second season of Extras, a BBC-HBO co-production, has appeared in a number of feature films, and is still thrilling his fans on radio and through podcasts.

TV EUROPE: Given your experience working on The Office for the BBC and for the U.S. version that airs on NBC, what differences are there between writing and producing comedy in the U.K. and in the U.S.? The U.S. uses writing teams - is that common in the U.K.?

GERVAIS: I don't think team writing is big in the U.K., but then we [Gervais and his partner, Stephen Merchant] are very rare as well. I don't know that anyone else writes and directs and executive-produces their own sitcom, like we do. We have control over the finished product, which is probably just as rare in England as team writing is. But in the States I've never seen so many writers and executive producers, but that's why they come up with better stuff than we do. We rarely come up with something as special as The Simpsons or Arrested Development or The Larry Sanders Show. I can list ten great American sitcoms, but I'd certainly struggle to come up with ten great British ones - that's my personal opinion. My favorites have always been American: Laurel and Hardy, the Marx Brothers, Woody Allen, sitcoms like Taxi, Cheers and the other ones that I've just mentioned. We are very, very influenced by America. If The Office was influenced by things like Spinal Tap and Laurel and Hardy, then Extras is influenced by things like The Larry Sanders Show. And also British sitcoms never really care about the heart as much as the Americans do. Americans have been injecting a little romance in their comedies from I Love Lucy right up to Friends. And it's something slightly more filmic. The other difference with The Office is we have no laughter track; we have no stars; we have no jokes - sounds dreadful, doesn't it, on paper? In fact, some of the biggest jokes were left on the cutting-room floor because they interfered with the realism of the show, and we really kept to that. There were bits when we were watching it and we thought, "My God, the viewers are going to tune out, it's too slow." But you've got to hold out, you've got to really stick to your guns, and then you'll excite people. If you pander, you might even get more viewers, but it won't resonate as much, they won't love it - even if they think they do - they won't love it like they would if they thought it was made for them. And there are enough like-minded people around the world that you don't have to compromise.

TV EUROPE: You and your partner, Stephen Merchant, consider yourself "fundamentalist comedians," and you don't go after the easy gag, do you?

GERVAIS: No, it doesn't interest me, because it's too easy. It's just too easy. Anyone can do it. I just don't go for this broad comedy where everything is very overacted and overdressed and over-enunciated and watered down. It just doesn't interest me. I like some broad comedy, but it's just not what I do. I think you've got to be able to bring something new to the table. The most exciting thing for me is the creative process, and originality is one of the most important things, really. What's the point of just doing something again unless you change it a bit or improve on it?

TV EUROPE: In the episode of Extras that starred Kate Winslet, you went after the disabled and pedophile priests. Is any topic taboo?

GERVAIS: "Going after" suggests that they were the butt of the jokes, and clearly they weren't. The butt of the joke was middle-class angst, the uncomfortable nature of dealing with differences or an awkward social situation. Clearly, the girl with cerebral palsy was not the butt of the joke, Andy was - his awkwardness was - just like David Brent going up to the black guy in The Office and only talking about Sidney Poitier. The black guy wasn't the butt of the joke. White middle-class anxiety - that was the butt of the joke. Taboo is a funny subject because everybody knows what it feels like to be embarrassed or feel awkward. When you live in a society where you're not starving and you're not at war, the worst thing that happens to you every day is an embarrassing encounter, or an argument with a bus driver, or you slip on the pavement. These are the worst things that happen to you. So you've got to write about what you know. You don't need high incidents, because everyone understands what it's like to be embarrassed or to be caught lying.

TV EUROPE: Have you found that comedy can reveal certain aspects about human behavior even better than drama at times?

GERVAIS: Absolutely. So many people use humor to get through things, to get over things, to hide things. And satire done well is a formidable weapon. Comedy is drama, comedy is contextual, you need conflicts for drama and you need drama for comedy. If there's a decapitated character that doesn't care or interact with the world, he's not as funny as if he does. Someone coming out and slipping on a banana skin is funny, but if he does that, and his wife has just left him, and she's standing there with her new boyfriend - do you know what I mean? The more you up the conflict and the drama, the funnier it is - in a weird way. I love the comedy of embarrassment; I absolutely love it. I love asking, What's the worst thing for this chap to say? But you can't just have a character come in and say something stupid, because you don't know him. David Brent [the character Gervais played in The Office] thought that he had become someone; he thought he'd impressed someone - this was his jeopardy. His life was in free fall, it hadn't turned out like he wanted it to, he had loads and loads of jeopardy, whereas if he had just danced in, done a funny turn and walked away, you might have laughed, but you wouldn't have cared.

TV EUROPE: Do you write about things you have seen in real life?

GERVAIS: Well, I did work in an office for seven years and it was a true observational comedy. And there are loads of things in The Office that I wanted to get off my chest, things about comedy. I've always written about very similar themes: social faux pas, taboos, desperation, ego, and comedy itself. The Office was a comedy about comedy itself. We had a go at people just shouting catchphrases instead of coming up with something more original, so they did impressions of [the actor] Michael Crawford and they thought props and inflatable penises were funny and it was a swipe at bad comedy.

TV EUROPE: What can you tell us about the second season of Extras? At the end of the first season, the main character, Andy [an actor who never manages to get an important role], was pitching a sitcom. Will it actually get made?

GERVAIS: Season two hits the ground on the day that he's recording the first episode of the sitcom for the BBC. And he wanted to make a classy comedy with no laughter track and not filmed in front of a studio audience, and he wanted it to go out on BBC Two, and of course because of interference the sitcom turns out to be quite the opposite. It's broad, interfered with, it's in front of a live studio audience, it's going on BBC One, and it's full of catchphrases. And it's how he copes with that.

TV EUROPE: Is there improvisation on your part or on Stephen's part when you're shooting, or is it all very much scripted?

GERVAIS: It's all scripted. Of course, I do a little bit of improv at the beginning and end of scenes and I do lots of different takes to try and explore stuff, but it's 99 percent scripted.

TV EUROPE: Tell me about your experience writing an episode for The Simpsons.

GERVAIS: The Simpsons to me is just the best comedy on TV. It's up there with Laurel and Hardy, and Homer Simpson is one of the greatest, sweetest, most interesting comedy characters of a generation. And when they asked me to be in it, that was one thing. But then they said, "Do you want to write an episode?" It was like I'd won a competition. I don't know what I'm doing to deserve all this, really. It's madness, it's not a career, it's like someone said, "Just give him what he wants." Being part of The Simpsons was intimidating, but it's such great fun, and I got to write a song. And I was a first-rate musician and I'll always sneak a song in when I can!

TV EUROPE: You come from a fairly modest background and you've held on to the values your family gave you. You haven't let fame go to your head, have you?

GERVAIS: That's because fame has never been impressive. My family was never really impressed by it. The most important thing was working for a living, and outside of that it was having a laugh. Fame to me is the worst bit of this. And by fame I mean being recognized. I also don't want to be associated with celebrities, because there is a side of it that is just, "Me, me, me." I don't go to red-carpet events. I don't do panel shows. I don't phone up my P.R. person when I break a nail. To me it's the work; I want to work in an office down the road from where I live. And the fun for me is knowing that I've created something that is going to be around forever. The legacy is as important to me as enjoying the moment, and I just happen not to enjoy being in a room full of people whose faces I recognize off the telly, but who I've nothing in common with at all. I feel a lot more affinity with people who are working in America at the moment, people like Larry David and Christopher Guest, because I enjoy what they do.

TV EUROPE: You've also done a couple of feature films lately. Can you tell us about those?

GERVAIS: I've done a little cameo in Christopher Guest's new movie, For Your Consideration. I did a part for Ben Stiller, returning the favor he did for me by being in Extras, which was great fun. I did a three-day film in Vancouver, Night at the Museum, which looks like a fantastic film, from what I've seen. And I just worked with Robert De Niro - this was incredible - on a film called Stardust. It's funny because I met him and we got on and I was ad-libbing and doing the work and it was really going fabulously, and then after about eight hours, all my bravado just drifted away and I went, "I think you're the best actor in the world! I think you're brilliant, I love you."

TV EUROPE: You work in radio, in television, and you've done feature films. Do you have a favorite medium?

GERVAIS: Yeah, radio, I'd say. My favorites at the moment are the podcasts with Stephen Merchant and Karl Pilkington, because it's like I've discovered a new species - Karl Pilkington - he's got very special qualities. He's the closest thing to Homer Simpson. He's like a cross between Homer Simpson and a pet. But it's very much an experiment. I feel very much like I'm in this Victorian freak show where someone would go around and say, "Behold, a man with a roundish head. Be him. Touch him. He is humanoid. May I present Karl Pilkington!" I want to go around like Anthony Hopkins in The Elephant Man, saying, "Look what I found." So yeah, that's my favorite thing at the moment, the podcast.

TV EUROPE: Could you tell us a little bit about Karl and how you met him?

GERVAIS: Stephen and I did a local radio show and Karl worked in the studio. He was the guy who made the jingles and pressed the buttons for us and then he started opening his mouth and saying the most amazing things. And we couldn't get enough of him. He's a man who believes only what he reads, but he doesn't even finish reading beyond the headline. He's fascinated with the world. He's fascinated by differences. He carries a book around called The World's 50 Top Freaks. He thinks the best invention of all time - which is clearly a joke that he saw - is mops that you put on cats' feet so they can do housecleaning. And he said, "Because cats are lazy, they never do anything around the house." He's incredible. If you Google Pilkipedia they've got all his quotes. They're just the most ridiculous bizarre things, but yeah, Karl Pilkington for President!

TV EUROPE: How important was Monty Python for you?

GERVAIS: Monty Python was amazing in many ways. It gave me an inherent need to deconstruct and to look at context. There was a naughtiness to it, there was an anti-establishment edge to it. The laughingstocks were judges and police and politicians. And also the acting was very natural. As mad as everything was, there was always a normal one who said, "What are you doing?," which I liked, and not everyone was mad at the same time. That teaches a certain context, really, that you have to have an everyman in there. You have to have Tim next to David [in The Office]. You have to have an Ollie next to Stan. And the films were great. What Terry Gilliam did was never done before. And John Cleese came out with Fawlty Towers, still considered the best sitcom from England.

TV EUROPE: Many believe The Office is.

GERVAIS: Wow, thank you very much.

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


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