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 on his new season of podcasts. The Brit-com bigwig discusses his popular Internet show and his many other projects, including ''Extras'' and his American stepchild, ''The Office'' by Gary Susman You know Ricky Gervais as the creator/star of the original British The Office and HBO's Extras, but over the last year, he's given himself a new nickname: The Podfather. That's because The Ricky Gervais Show, his hilarious weekly online audio program, claims to be the most downloaded podcast on the Internet, with about 8 million downloads to date, he says. With a third season launching Aug. 22 and past shows available for purchase at audible.com, Gervais called EW.com from London to talk about his many projects, but especially The Ricky Gervais Show. Which could just as easily be called The Karl Pilkington Show since, as Gervais is quick to point out, the comedy in each half-hour podcast consists largely of Gervais and frequent collaborator Stephen Merchant simply allowing their friend Pilkington to spout off on space travel, sideshow freaks, monkeys, and whatever else crosses his mind.

EW.COM: How do you account for the podcast's popularity?

RICKY GERVAIS: It's engaging, it's real. It's a man who sees the world differently from us. It's like we download his head so everyone can see it. We prod him and we shake him, and interesting trinkets fall out. It all comes from a good place, this slightly confused man who wanders around the world and sees things from a slightly different angle than the rest of us. As inarticulate as he may sound, there is a poetry to his strange words of wisdom. Often, he's sort of right, once you know what he means. The things he takes to his bosom, and the things he rejects are often the other way around for most of us. He thinks painting is pointless and he thinks choice is confusing, and those are the things we cherish. He's just different but very nice and honest. Even the things he says that sound heartless, they come from a good place. He's not trying to be funny. He's just a fascinating little creature. He's like a fictional character. He's the closest thing to a living Homer Simpson. Steve and I see ourselves as carnival barkers who've found the most fascinating creature in the world. We really think of ourselves as some sort of Victorian entrepreneurs, bringing out the Elephant Man. I feel like Anthony Hopkins, taking out John Merrick, going, ''Look what I found.'' Not only is it our own experiment, and fascinating to us, but we want the whole world to see the amazing Eighth Wonder of the World that is the mind of Karl Pilkington.

Does he get self-conscious about the way he comes off on the show?

He doesn't understand it. He doesn't understand the websites that have cropped up about him or why people like the things he says, because that's how he talks. He doesn't know why some of the things are funny or controversial. They're just his opinions. But we won't let him stop, even if he wants to. [Meantime, a book of Pilkington's musings, Ricky Gervais Presents: The World of Karl Pilkington, will be published in the U.S. on Oct. 3.]

How planned, structured, and scripted are the podcasts?

It's not scripted at all. It's all stuff that happened to us. Karl will have a Monkey News because he looks at the Internet and finds something out about monkeys each week. So we never script anything as such, but we all come armed with what we've done that week.

Does a lot get edited out?


Well, we stop sometimes for a cup of tea because it gets hot in that little studio. But it's not contrived. We don't do anything twice. We don't edit like that. We just get the best half hour out of the hour we're in there. It's pretty much as it is, really. There's no manipulation. There's no, ''That would be funnier if you said this.'' It's all real, just tidied up.

Will you keep the podcast going for a while, or will you quit before it has a chance to jump the shark, as you did with the original Office?


I love it because it's organic, it's fun, it's two mates. I love it because it's new. I'm excited about the technology and being in the forefront of this revolution. I love the freedom. I love that we own our own labor. We do it ourselves in our own studio, which we built, and we've put it on the Internet. I love the fact that it's global, that anyone in the world with a computer or an iPod or access can listen to something that we said in a little room in the West End of London. I love it that there's no pressure. It's a joy to me, it's not like a job. But then we do take it very seriously. When you're charging for it, you want to make sure it's as good a half hour as you can have. And you do it for like-minded people. It's not meant to be broad or come into the homes of 10 million viewers. People choose to go there and download it. But you don't want to overstay your welcome. And you don't know what's going to happen with podcasting, really. But at the moment, we're certainly looking forward to putting another series out there. And the archive is still there, so people coming to it now can still get everything in the backlog. We want to do at least one more series of six. We don't want to do it every day. We don't want to milk it. We'll do it as long as we have something to say and think it's still fun. But it's the favorite thing that I do at the moment. I love being in a room for an hour with Karl Pilkington and downloading his mind. It's like I bootleg his mind and put it on the Internet for people. It's fun, but you don't want to do a project that's more fun for you than anyone else. You don't want to ruin what's funny about Karl. You don't want to overexpose him, turn him into someone knowing. I don't want to have a Lawnmower Man on my hands.

Are you pleased with the way the American version of The Office has evolved into its own show?


It's my favorite sitcom. You try to make shows that you want to watch. I did with The Office, I'm doing it now with Extras. It's the show you wish someone else had made, but I had to make it. With the American Office, it's the best of both worlds because someone else made it, and it's just how I wanted it. So it's a joy. It's exactly how I'd want something, but I didn't have to make it. I can say this because I genuinely regard the American Office as someone else's work. It's audacious, it's wickedly funny. The cast are amazing. Steve Carell is just going to take over the world. I salute all those involved and NBC for not panicking. I'm so glad they stuck to their guns. It was uncompromising, and it got better and better. And the more they went their own way, the better it got. So I can't praise them enough. But I get the money. Well, I get what's left. I say, ''Just give me what you can.''

Will we be seeing more of you in movies?


I've done three cameos in three films this year, all three days long, all on screen for two minutes. So I've stuck my toe in the water. I've done a little cameo in Ben Stiller's new film, A Night at the Museum, I've done Christopher Guest's For Your Consideration, and I've just done a couple days on a film called Stardust with Robert De Niro and Michelle Pfeiffer.

What was that like, working alongside a thespian as serious as De Niro?


Amazing and incredible. I had eight hours of bravado, being a normal person, and then before the last shot, I broke and went [in cracked, high-pitched voice] ''I think you're the best actor in the world. You're brilliant.'' It was awesome, quite an experience. I still pinch myself that I'm working with these people. It's ridiculous. It's madness. There's not many things I have left to do now. I just have to appear in The Sopranos or 24. What else? I'll give you a list, you sort it out for me. You can't bring back Laurel and Hardy, can you?

Is the De Niro incident going to make it into Extras?


Well, yeah. How does one get celebrities to set aside their egos and make fun of themselves on a show like Extras? Well, I don't think there's anything more flattering that you could say to someone than, ''We want you to play yourself.'' And it gets better when you say, ''And the version of yourself is X, Y, and Zed.'' The people we choose are the people we like and that we know have a good sense of humor. They're in on the joke. They get it. They're secure enough in themselves to know they're not like that. It's quite liberating to deconstruct yourself and take the mickey out of yourself. When you have everyone running round and saying, ''Yes'' all the time, it must be a load off your mind when someone says, ''Listen, we want to show you to be a complete putz. How does that grab you? The money's rubbish, and we're filming near Slough.''

What's next for you?


Me and Steve have written an episode of the American Office. That'll be part of season 3. Podcast starts on the 22nd of August. Extras will be out after Christmas. So the next thing you'll probably see me in is For Your Consideration, in November. And then Night in the Museum around Christmas. With a schedule that busy, do you ever take a vacation? It's fun for me. It's hard work. And I'm always working. But the hard work takes place between the hours of 10 in the morning and 4 in the afternoon. And I have weekends off. So I can't complain. It's doing what I love doing, coming up with silly stuff to make people laugh. So it's one long vacation.

Anything else we should ask about the podcast?


I don't think I should ever be asked anything. It still constantly surprises me that anyone wants to know what I think. (Posted:08/17/06)




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