Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. You are looking for this: http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html
  2. I am not entirely sure how getafreelancer works but I would file a complaint or ask my money back. Even if you modify this code you still would have a serious security problem not to mention a database overhead (drop table, create table).
  3. Session's don't expire themselfs, however they do expire: - When a user closes his browser (destroying the session cookie) - When session_destroy() or session_write_close() is called.
  4. Sure their is: if (!isset($_SESSION['last_click'])) { $_SESSION['last_click'] = time(); } else if ((time() - $_SESSION['last_click']) > 300) {//inactive for 5 minutes $_SESSION = array(); } else { $_SESSION['last_click'] = time();//update last_click }
  5. A session's live depends on the sole existence of a cookie on the client browser which contains the session id. If this cookie is removed or expires, the session is ready for garbage collection. You can extend the lifetime of the cookie by using: session_set_cookie_params($sessionLifetimeInSeconds); Now your cookie (and your session) will live as long as $sessionLifetimeInSeconds defines. By default the cookie's lifetime equals 0 which means that if you close your browser, the cookie is removed and the session expires. What the actual purpose is of session_cache_expire() I don't know, the description says: "session.cache_expire specifies time-to-live for cached session pages in minutes" Are they referring to real pages, like html? Or to the session files that are created in the temporary directory?
  6. I think die('! you evil scumbag, eat my headers'); would be more appropriate
  7. That's not a problem considering the purpose it's a good choice. How do you exactly mean time out? Nothing with this process either.
  8. mysql_query("create table if not exists tourne_report (Host TEXT, Date_Time DATETIME, PlayersCount INT, Winner TEXT, WinnerEmail TEXT, SecondPlace TEXT, SecondEmail TEXT, ThirdPlace TEXT, ThirdEmail TEXT, ThirdPlace2 TEXT, ThirdEmail2 TEXT)"); mysql_query("create table if not exists emails (PlayerName char(30) key not null, email TEXT)"); mysql_query("create table if not exists points (PlayerName char(30) key not null, Points INT, Date_Time DateTime)"); These only need to be executed once (not on each and every request), put it in a separate file called install.php or something. mysql_connect(null, "havensd1_tourn", "z(:wI,VL91SL"); This needs an actual value not null and store the value it returns you need it. mysql_select_db("havensd1_tournaments") or die(mysql_error());//Put databasename here Remove 'or die()' your visitors don't know what 'You have an error in your sql syntax near ..' means. mysql_query("drop table tourne_report"); mysql_query("drop table emails"); mysql_query("drop table points"); mysql_query("create table if not exists tourne_report (Host TEXT, Date_Time DATETIME, PlayersCount INT, Winner TEXT, WinnerEmail TEXT, SecondPlace TEXT, SecondEmail TEXT, ThirdPlace TEXT, ThirdEmail TEXT, ThirdPlace2 TEXT, ThirdEmail2 TEXT)"); mysql_query("create table if not exists emails (PlayerName char(30) key not null, email TEXT)"); mysql_query("create table if not exists points (PlayerName char(30) key not null, Points INT, Date_Time DateTime)"); He never heard of truncate, did he? This script is seriously FUBAR (F***ed Up Beyond All Repair) Who the hell wrote this?
  9. What exactly do you put in the heredoc the php code block or only the ****** text?
  10. Woeps, there goes free will I'll try to explain it by example: class Niko { public function getFirstname() { return $this->_firstName; } } class Bruno { public function getName() { return $this->_firstName; } } Both Niko and Bruno are persons however they use both a different method to retrieve their firstname which complicates it for you as a programmer because you would always need to check if an object is an instanceof Bruno or an instanceof Niko. $persons = array(new Niko(), new Bruno()); foreach ($persons as $person) { if ($person instanceof Bruno) { print $person->getName(); } else if ($person instanceof Niko) { print $person->getFirstname(); } // What if you had 200 persons? Each implementing their own firstname method? } To make sure all classes use the same interface (use the same methods) you create an interface. interface IPerson { public function getFirstname(); } class Niko implements IPerson { public function getFirstname() { $this->_firstName; } } class Bruno implements IPerson { public function getFirstname() { $this->_firstName; } } Now you know that if an object implements IPerson it also has the method getFirstname() $persons = array(new Niko(), new Bruno()); foreach ($persons as $person) { print $person->getFirstname(); } Now when use an interface and when use an abstract class? You generally use an abstract class when you want to specify default behavior for some methods and leave others to be implemented by the child classes. If you can't provide default behavior for any of the needed methods then you generally use an interface.
  11. I'm a bit confused by this why let People implement iPerson if you would throw an exception if they use setName($name) and if you use getName() you'd actually get multiple names. In my opinion People shouldn't even implement iPerson.
  12. Thanks and apologies What does it print if you execute the code? Still 14447?
  13. That's because you need to pass it some values: $validator = new Validator(); Should be: $validator = new Validator($field_name, $number_chars, $allowed_chars, $character_check, $error);
  14. 0D=\r 0A=\n On windows this typically is: 0D0A
  15. You are not always only validating if a string has a certain length: abstract class Validator { abstract public function performValidation(ValidatorArray $va); } class StringLengthValidator extends Validator { protected $_strLen = 0; protected $_minLen = 0; protected $_maxLen = 0; public function __construct($string, $minLenght, $maxLength) { $this->_strLen = strlen($string); $this->_minLen = $minLength; $this->_maxLen = $maxLength; } public function performValidation(ValidatorArray $va) { $valid = true; if ($this->_strLen < $minLength) { $va->addErrorMsg('To short'); $valid = false; } else if ($this->_strLen > $maxLength) { $va->addErrorMsg('To long'); $valid = false; } return $valid; } } class ValidatorArray { protected $_errorMsgs = array(); protected $_passed = array(); public function getErrorMsgs() { return $this->_errorMsgs; } public function addErrorMsg($errorMsg) { $this->_errorMsgs[] = $errorMsg; } public function validate() { foreach ($this->_validators as $validator) { $className = get_class($validator); $this->_passed[$className] = $validator->performValidation($this); } } public function didPass($validator) { return isset($this->_passed[$validator]) && $this->_passed[$validator]; } }
  16. You just gave me an great idea a function that allows you to sync between local and remote directories. I'll post the code once i'm done. I had actually written most of the code but when I submitted nothing changed my post meaning the time you may edit a post had expired.. Damn I really hate when that happens..
  17. You can save you the bother of creating the ftp yourself: http://us3.php.net/manual/en/book.ftp.php
  18. While typing my next question, I just realised your problem. Sometimes when I download a file and open it using notepad.exe everything is on the first line. However when using wordpad.exe it display's just fine. So possibly you are using an editor that uses an unix line-delimiter. You are opening it using php (under windows?) which uses the windows line-delimiter (PHP_EOL). You read the first line, pop off the e-mail address and end up with only one e-mail address. Open the file using notepad and see if it is all on one-line. If it is open your editor and change it's settings to use the windows line-delimiter. 0D0A EOF: 1A
  19. Use Zend_Form and Zend_Validator to accomplish this. You'll otherwise have to write to much.
  20. modify from: select * from issues where id == '%".$searchterm."%' to: select * from issues where id = '".$searchterm."'
  21. $paymentDetails['creditcardpercent'] = str_replace('.', '', $paymentDetails['creditcardpercent']);
  22. safe_mode is probably on
  23. if (something) { } else { // something else }
  24. Actually you get: row: 0; col: 0 row: 0; col: 1 row: 0; col: 2 row: 0; col: 3 row: 1; col: 0 row: 1; col: 1 row: 1; col: 2 row: 1; col: 3 row: 2; col: 0 row: 2; col: 1 row: 2; col: 2 row: 2; col: 3 But only if you do "view source". Anyhow it just shows you the mechanism how one can create rows and cols. The first loop creates the rows, while the second loop creates the cols for a row. Use the faq snippet by crayon or ober as suggested by wildteen.
  25. ignace

    

    PFMaBiSmAd sometimes forget's he's talking to mere mortals
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.