Jump to content

ignace

Moderators
  • Posts

    6,457
  • Joined

  • Last visited

  • Days Won

    26

Everything posted by ignace

  1. How can we help you if you post no code for us to examine?
  2. After looking through the code I concur, the code is a mess. What is the actual problem? What does or does not happen? Or could you pinpoint to what we should be looking for?
  3. http://us2.php.net/manual/en/function.ignore-user-abort.php
  4. You need to chmod() the directory to 777, by default a directory created by php has the same access privileges as in which php.exe is executed. I do not recommend modifying it to 777, this will allow anyone to modify the directory. Thus, if you want only one person to be able to modify the directory then you'll have to do this programmatically using group-, role-, or user-based access control.
  5. I made some modifications to your code - define() outisde of the function, it only has to be called once not on each and every call to saveThumb() - $uploadDirectory is now a global variable and allows you to modify the path to the upload directory and saveThumb() doesn't need to be modified - added some basic security $gal = basename($gal) which ensures that your function won't load a security file or something ($gal = ../../ $fn = somehighsecurityfile which would result in: uploads/../../somehighsecurityfile <?php define('MAX_XY', 250); // maximum width or height of thumbnail image $uploadDirectory = realpath('uploads'); function saveThumb($gal,$fn) { global $uploadDirectory; $gal = basename($gal); $fn = basename($fn); $fpath = implode(DIRECTORY_SEPARATOR, array($uploadDirectory, $gal, $fn)); //print $fpath."\n"; /* GetImageSize returns an array: * $info[0] - horizontal size of image in pixels * $info[1] - vertical size of image in pixels * $info[2] - type of image (1=GIF, 2=JPEG, 3=PNG) */ $info = getimagesize($fpath); //print_r($info); // do we need to resize image? if ($info[0] > MAX_XY || $info[1] > MAX_XY) { // is image landscape? if ($info[0] >= $info[1]) { $width = MAX_XY; $height = $info[1]*MAX_XY/$info[0]; // or portrait? } else { $height = MAX_XY; $width = $info[0]*MAX_XY/$info[1]; } } else { // use original dimensions $width = $info[0]; $height = $info[1]; } // create new thumbnail image //echo "<br>$width - $height<br>"; $im = ImageCreateTrueColor($width, $height); /* determine image type and load original image. Notice new tests for image * types. The GD extension has changed a lot over the years, dropping GIFs * and adding PNG support. By testing, we avoid trying to process an image * PHP can't deal with */ $im_big = ""; // default is no image switch ($info[2]) { case 1 : if (ImageTypes() & IMG_GIF) // test for GIF support $im_big = ImageCreateFromGIF("$fpath"); break; case 2 : if (ImageTypes() & IMG_JPG) // test for JPEG support $im_big = ImageCreateFromJPEG("$fpath"); break; case 3 : if (ImageTypes() & IMG_PNG) // test for PNG support $im_big = ImageCreateFromPNG("$fpath"); break; case 4 : if (ImageTypes() & IMG_BMP) // test for BMP support $im_big = ImageCreateFromBMP("$fpath"); break; } if ($im_big) { /* resize original image into thumbnail - see PHP Manual for details on * the arguements ImageCopyResized takes */ ImageCopyResized($im,$im_big,0,0,0,0,$width,$height,$info[0],$info[1]); } else { // couldn't load original image, so generate 'no thumbnail' image instead $width = 100; $height = 100; $im = ImageCreate($width, $height); // create a blank image $bgc = ImageColorAllocate($im, 0, 0, 0); // background color = black $tc = ImageColorAllocate($im, 255, 255, 255); // text color = white ImageFilledRectangle($im, 0, 0, $width, $height, $bgc); // draw rectangle ImageString($im, 3, 9, 36, "No thumbnail", $tc); // add text ImageString($im, 3, 17, 48, "available", $tc); } /* save our image in thumb directory - if the second argument is left out, * the image gets sent to the browser, as in thumbnail.php */ ImageJPEG($im, "uploads/".$gal."/t_".$fn); // clean up our working images ImageDestroy($im_big); ImageDestroy($im); } ?>
  6. File extension ain't safe either you could create executable code and rename it to a .jpg. When it opens, it executes the code. Same thing that happens with those higly believable 300 kb large .mp3 files.. A file extension is merely to add a recognition for us humans.
  7. I think it's also possible by using nowdoc; Nowdoc is available as of php v5.3
  8. Thank you for providing constructive feedback Been staying up all night solving and helping problems... im pretty tried and grumpy. If your comment has no added value then save yourself the bother.
  9. You don't need to refresh the page, just fill the second select with the value from the first select once the first select contains a value. $firstSelectData = array(); $query = 'SELECT id, name FROM categories'; $result = mysql_query($query, $db/*from mysql_connect()*/); while (list($id, $name) = mysql_fetch_array($result, MYSQL_NUM)) { $firstSelectData[$id] = $name; } $secondSelectData = array(); if (!empty($_POST)) {//user selected something from the first select if (!empty($_POST['first_select']) && /*make sure something was selected*/ empty($_POST['second_select'])/*second is empty, fill it!*/) { $query = 'SELECT id, name FROM subcategories WHERE category_id = ' . $_POST['first_select']; $result = mysql_query($query, $db); while (list($id, $name) = mysql_query($result, MYSQL_NUM)) { $secondSelectData[$id] = $name; } } else if (!empty($_POST['first_select']) && /*something was selected from the first select*/ !empty($_POST['second_select'])/*and the second select now also contains data*/) { $first_select_id = $_POST['first_select']; $second_select_id = $_POST['second_select']; } }
  10. $most_chosen_texts = array('a' => 'Mostly A\'s: ..', 'b' => 'Mostly B\'s: ..', 'c' => 'Mostly C\'s: ..'); $most_chosen = key($chosen_most); print $most_chosen_texts[$most_chosen];
  11. No not refresh, fill. $secondSelectData = array(); if (!empty($_POST)) {//something was posted // assuming first field is filled and second field is awaiting data if (!empty($_POST['first_select']) && empty($_POST['second_select'])) {//nothing selected in $query = 'SELECT id, name FROM table WHERE parent_id = ' . $_POST['first_select'];//don't use it like this just an example $result = mysql_query($query, $db); .. while (list($id, $name) = mysql_fetch_array($result, MYSQL_NUM)) { $secondSelectData[$id] = $name; } } else if (!empty($_POST['first_select']) && !empty($_POST['second_select'])) { $first_select = $_POST['first_select']; $second_select = $_POST['second_select']; } }
  12. Because select * from profiles select's all profiles while select p.profileid, p.profilename from profiles as p join profileaccess as a on p.profileid = a.profileid order by p.profilename select's only one matching row. Which is retrieved by: $row = mysql_fetch_array($result); $row = array('profileid' => .., 'profilename' => ..); and overwritten by: while ($row = mysql_fetch_array($result)) $row = false;
  13. Use google analytics and use it's API to retrieve that information.
  14. $row = mysql_fetch_array($result) or die(mysql_error()); while($row = mysql_fetch_array($result)) You are calling mysql_fetch_array() twice. P.S. remove 'or die()' your users don't know what 'SQL syntax error near ..' means.
  15. maxlifetime is defined in seconds. You defined 1 second as the maximum lifetime however you could browse the website for 2 whole minutes. Garbage collection runs sporadically as you previously said it expired after exactly 1 minute and now after 2 minutes. However like I said maxlifetime is not the thing you are looking for as it will expire all sessions regardless of activity.
  16. I think he is trying to build an advertising kind of thing for jobs. How higher the frequency (and the money) the more it is shown, would be my best bet
  17. If you set session.gc_maxlifetime to 600 your session will expire in 10 minutes regardless of your activities.
  18. What do you mean by: If you mean that the server should clean expired sessions up for you then he does. If you mean that the server should expire a session because a user didn't click for x minutes then he doesn't. If you want to expire a session because a user didn't click for x minutes, then you need to write this functionality.
  19. What is 'OP'? Everyone is using it and I have no idea about what you all are talking about. Did I miss a memo?
  20. In my opinion that is what garbage collection does and I fail to see how this will expire a session due to the user not clicking within a certain interval (for example 5 mins). You suggest to set the maxlifetime to 5 mins meaning that both active and idle users will have to re-login after 5 mins regardless of which garbage collection method you use. As this was the actual question:
  21. Will throw Notice: undefined index 'a'. $most_chosen_arr[$_POST["group" . $i]]++ will receive the value null on which you perform an integer operation (++) which results in 1. This fixes this problem: if (!isset($most_chosen_arr[$_POST['group' . $i]])) { $most_chosen_arr[$_POST['group' . $i]] = 1; } else { $most_chosen_arr[$_POST['group' . $i]]++; }
  22. $chosen_most = array('a' => 0, 'b' => 0, 'c' => 0); if (!empty($_POST)) {//an answer has been posted switch ($answer) { case 'a': $chosen_most['a']++; break; case 'b': $chosen_most['b']++; break; case 'c': $chosen_most['c']++; break; } } arsort($chosen_most); echo 'You chose mostly: ', array_shift(array_keys($chosen_most));
  23. That's not true. If you modify session maxlifetime then your session will expire (garbage collected) even if you were clicking the hell out of your mouse. You can only expire a session due to inactivity programmatically, like I explained here: http://www.phpfreaks.com/forums/index.php/topic,262461.msg1236391.html#msg1236391
  24. Most would advice JavaScript and the onchange event, however for usabilities sake I discourage this, use this instead: $query = $_POST['query']; $type = $_POST['type']; switch ($type) { case 'games': header('Location: http://games.google.com?q=' . $query); break; case 'apps': header('Location: http://apps.google.com?q=' . $query); break; }
  25. if (!empty($_POST)) {//something was posted if (!empty($_POST['first_select']) && empty($_POST['second_select'])) {//nothing selected in $query = 'SELECT * FROM table WHERE parent_id = ' . $_POST['first_select'];//don't use it like this just an example $result = mysql_query($query, $db); .. } else if (!empty($_POST['first_select']) && !empty($_POST['second_select'])) { $first_select = $_POST['first_select']; $second_select = $_POST['second_select']; } }
×
×
  • 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.