Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. class foo { function bar() { echo "I am Foo"; } }//end class class footoo extends foo { function bar() { parent::foo();//note the use of :: echo "And I am footoo"; } } Nevermind you were missing an echo statement
  2. SELECT * FROM tb_a3866796_users @Brian W that should be: $result = mysql_query($SQL) or trigger_error(mysql_error());
  3. No need to thank me or anything after all it's my script that your using..
  4. Yes we know Let him first try it the hard way so he will see the advantage of using Phing later on. @rhodry_korb look at my post http://www.phpfreaks.com/forums/index.php/topic,280606.msg1329192.html#msg1329192 All that is left for you to do is provide an implementation for installApplication($applicationDirectory) which could be something like: function installApplication($applicationDirectory) { $sqlFile = $applicationDirectory . DIRECTORY_SEPARATOR . 'install.sql'; if (file_exists($sqlFile)) { $sql = readfile($sqlFile); .. } }
  5. He has difficulties writing his own installation script imagine him using Phing to do this job for him...
  6. function getMySQLResult($result, $mode = MYSQL_ASSOC) { $rows = array(); while ($row = mysql_fetch_array($result, $mode)) { $rows[] = $row; } return $rows; } function getDirectoriesFrom($directory) { $directories = array(); $directory = rtrim($directory, '\/'); if ($dh =@ opendir($directory)) { while (false !== ($file = readdir($dh))) { if (!isDot($file) && is_dir($directory . DIRECTORY_SEPARATOR . $file)) { $directories[] = $directory . DIRECTORY_SEPARATOR . $file; } } closedir($dh); } return $directories; } function isDot($file) { return $file !== '.' && $file !== '..'; } function installApplication($applicationDirectory) { // your logic here } // assuming you don't move the directories and the installation directory has the same residence as the applications $query = 'SELECT directoryname FROM applications'; if ($result = mysql_query($query, $databaseConnection)) { $directoryNames = getMySQLResult($result); $directories = getDirectoriesFrom($directory); foreach ($directories as $applicationDirectory) { if (!in_array(basename($applicationDirectory), $directoryNames)) { installApplication($applicationDirectory); } } }
  7. @thorpe Phing is a good solution for you and I but out-of-proportion for the OP's needs.
  8. $transportConfig = array('smtp_host' => 'smtp.gmail.com', 'smtp_port' => '456', 'smtp_ssl' => '1', 'smtp_user' => 'mail@gmail.com', 'smtp_password' => 'mail password'); $transport = new Zend_Mail_Transport_Smtp('smtp.gmail.com', $transportConfig); $mail = new Zend_Mail(); $mail->setFrom('user@mail.com'); $mail->setReplyTo('user@mail.com'); $mail->setReturnPath('user@mail.com');// in case of failed delivery $mail->setSubject('Mail Subject'); $mail->addTo('mail@gmail.com'); $mail->setBodyText('Mail Message');// or $mail->setBodyHtml('Html Mail Message'); $mail->send($transport);
  9. Try this class written by Manuel Lemos: http://www.phpclasses.org/blog/package/9/post/1-Sending-email-using-SMTP-servers-of-Gmail-Hotmail-or-Yahoo-with-PHP.html
  10. 1) No. If this is your only validation 2) Stop using the hungarian notation
  11. I just wrote the code here off-the-bat probably that is the reason why it doesn't work no worry i'll look into it!
  12. You should note that at some point in the future you may delete a file and thus this n+1, n-1 analogy doesn't any longer work while it actually should. function getFileParts($file) { return explode('_', pathinfo($file, PATHINFO_FILENAME); } function changeArrayPointerTo(&$array, $number) { while ($file = current($array)) { list(, $fn) = getFileParts($file); if ($fn === $number) { return; } } } $directory = dirname(__FILE__); $files = scandir($directory); natsort($files); list (, $number) = getFileParts(__FILE__); changeArrayPointerTo($files, $number); echo prev($files); echo next($files);
  13. Wrong topic. Have you looked at Google? Are you looking for a paid- or free solution?
  14. No. But you can add it easily: return preg_match('/image\/(jpg|jpeg|gif|png)/', $imageSize['mime']) && filesize($imagePath) > 0; Fit for your needs.
  15. 1) Fixed your cleanString function function cleanString($string) { $string = htmlentities(mysql_real_escape_string($string)); return $string; } 2) Use something different then $loggedIn = false|true because if your server accidentically supports register_globals you'll in for some trouble when I type ?loggedIn=true I would use something like a challenge key 3) Don't store a user password in the session.
  16. just add an else on if (move_uploaded_file(..))
  17. Fixed <?php function isValidImage($imagePath) { $imageSize = getimagesize($imagePath); return preg_match('/image\/(jpg|jpeg|gif|png)/', $imageSize['mime']); } function formatBytes($bytes) { $abbr = array('KB', 'MB', 'GB', 'TB'); while ($bytes > 1024 && next($abbr)) { $bytes /= 1024; } return $bytes . ' ' . current($abbr); } $f = $_FILES['file']; if (isValidImage($f['tmp_name'])) { if (UPLOAD_ERR_OK !== $f['error']) { echo 'Return Code: ' . $f['error'] . '<br />'; } else { echo 'Upload: ' . $f['name'] . '<br />'; echo 'Type: ' . $f['type'] . '<br />'; echo 'Size: ' . formatBytes($f['size']) . '<br />'; echo 'Temp file: ' . $f['tmp_name'] . '<br />'; $filePath = implode(DIRECTORY_SEPARATOR, array('images', 'imageuploads', $f['name'])); if (file_exists($filePath)) { echo $f['name'] . ' already exists. '; } else { if (move_uploaded_file($f['tmp_name'], $filePath)) { echo 'Stored in: ' . $filePath; } } } } ?> The most important thing here is that you realize that you could have solved this problem yourself if you would have kept your code readable. Don't forget that you or someone else in the future may be reviewing this code just like you now review my code.
  18. I really like your title: "WHYISNT THIS MYSQL STATEMNT NOT WORKING?" So your SQL statement works IS NOT .. NOT
  19. Are you sure the directories exists and you have permission to create files?
  20. Hehe yeah those damn body parts don't they know they should obey the almighty brain?
  21. @Tonic: Like cags said "None of the advice given so far fits in with my understanding of the problem. " I don't understand why you even would point the OP in the direction of CRON?? @cags: You mean: SELECT * FROM show WHERE time > NOW() ORDER BY time ASC LIMIT 1 CREATE TABLE playday ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id)); CREATE TABLE playhour ( id tinyint NOT NULL auto_increment, start time, PRIMARY KEY (id)); CREATE TABLE playlist ( playday_id tinyint NOT NULL, playhour_id tinyint NOT NULL, show_id tinyint NOT NULL, dj_id tinyint NOT NULL, PRIMARY KEY (playday_id, playhour_id, show_id, dj_id)); CREATE TABLE show ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id)); CREATE TABLE dj ( id tinyint NOT NULL auto_increment, name varchar(32), PRIMARY KEY (id));
  22. <?php function isValidImage($imagePath) { $imageSize = getimagesize($imagePath); return preg_match('/image\/(jpg|jpeg|gif|png)/', $imageSize['mime']); } function formatBytes($bytes) { $abbr = array('KB', 'MB', 'GB', 'TB'); while ($bytes > 1024 && next($abbr)) { $bytes /= 1024; } return $bytes . ' ' . current($abbr); } $f = $_FILES['file']; if (isValidImage($f['tmp_name'])) { if (UPLOAD_ERR_OK !== $f['error']) { echo 'Return Code: ' . $f['error'] . '<br />'; } else { echo 'Upload: ' . $f['name'] . '<br />'; echo 'Type: ' . $f['type'] . '<br />'; echo 'Size: ' . formatBytes($f['size']) . '<br />'; echo 'Temp file: ' . $f['tmp_name'] . '<br />'; $filePath = implode(DIRECTORY_SEPARATOR, array('upload', $f['name'])); if (file_exists($filePath)) { echo $f['name'] . " already exists. "; } else { if (move_uploaded_file($f['tmp_name'], $filePath)) { echo "Stored in: " . "images/imageuploads/" . $_FILES["file"]["name"]; } } } } ?>
×
×
  • 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.