Jump to content

son

Members
  • Content Count

    1,024
  • Joined

  • Last visited

Everything posted by son

  1. son

    Loop help needed

    I got the following the display categories in two levels as: // get the top level halos first$haloQuery = 'SELECT haloID, halo FROM haloTable WHERE haloParent = 0';$haloResult = mysqli_query($dbc, $haloQuery);if (mysqli_num_rows($haloResult) > 0){ while ($row = mysqli_fetch_array ($haloResult, MYSQL_ASSOC)) { $haloID = $row['haloID']; $halo = $row['halo']; echo "<option value=\"halos.php?hid={$haloID}\">" . $halo . "</option>\n"; // get the sub halos now $haloQuery2 = "SELECT haloID, halo FROM haloTable WHERE haloParent = $haloID"; $haloResult2 = mysqli_query ($dbc, $haloQuery2); if (mysqli_num_rows($haloResult2) > 0) { while ($row = mysqli_fetch_array ($haloResult2, MYSQL_ASSOC)) { $haloSubID = $row['haloID']; $haloSub = $row['halo']; echo "<option value=\"halos.php?hid={$haloSubID}\" style=\"padding-left:10px;\">" . $halo . "</option>\n"; } } }} Now, where I cannot get my head around: if I was to allow that the not only the top level halos could be choosen as parent, but also all other halos who can I loop this somehow that it will go as deep as needed to display "top level halos, level 2 halos relevant to top level halo just listed, level 3 halos relevant to level 2 halo just listed etc... I hope you know what I mean... Son
  2. son

    Image upload resize function

    Actually, just an important improvement for this great funtion. Use: $extVar = explode('.',$src);$ext = strtolower(array_pop($extVar)); instead of: $ext = strtolower(array_pop(explode('.', $src))); I got "Only variables should be passed by reference" when I used the function on another page with image upload and the small change solved the issue... Son
  3. Have the following in .htaccess ErrorDocument 401 /401.phpErrorDocument 403 /401.phpErrorDocument 404 /404.phpErrorDocument 500 /500.php and works fine for web root requests. However, does not work if wrong file accessed within a directory. Have tried to have full system paths and is the same situation. Do I need to have .htaccess for each folder then? Or how can I improve this? Thanks,Son
  4. son

    Image upload resize function

    Thanks a lot. Have it working now:-) Son
  5. I am trying to use the function: function resize_image($opts){ $src = isset($opts['source']) ? $opts['source'] : ''; $dest = isset($opts['dest']) ? $opts['dest'] : ''; $w = isset($opts['w']) ? intval($opts['w']) : 0; $h = isset($opts['h']) ? intval($opts['h']) : 0; if ($src == '') { return; } if ($w == 0 && $h == 0) { return; } if ($dest == '') $dest = $src; // resize in place // open the image $ext = strtolower(array_pop(explode('.', $src))); switch ($ext) { case 'jpg': case 'jpeg': $i = imagecreatefromjpeg($src); break; case 'gif': $i = imagecreatefromgif($src); break; case 'png': $i = imagecreatefrompng($src); break; default: return; } $new_w = imagesx($i); $new_h = imagesy($i); if (($w != 0 && $new_w <= $w && $h == 0) || ($w == 0 && $h != 0 && $new_h <= $h) || ($w != 0 && $new_w <= $w && $h != 0 && $new_h <= $h)) { // image is small enough if ($dest != $src) copy($src, $dest); return; } // determine new size if ($w != 0 && $new_w > $w) { $new_h = ($w / $new_w) * $new_h; $new_w = $w; } if ($h != 0 && $new_h > $h) { $new_w = ($h / $new_h) * $new_w; $new_h = $h; } // resize $new = imagecreatetruecolor($new_w, $new_h); if ($ext == 'png' || $ext == 'gif') { $trnprt_indx = imagecolortransparent($i); // If we have a specific transparent color if ($trnprt_indx >= 0) { // Get the original image's transparent color's RGB values $trnprt_color = imagecolorsforindex($i, $trnprt_indx); // Allocate the same color in the new image resource $trnprt_indx = imagecolorallocate($new, $trnprt_color['red'], $trnprt_color['green'], $trnprt_color['blue']); // Completely fill the background of the new image with allocated color. imagefill($new, 0, 0, $trnprt_indx); // Set the background color for new image to transparent imagecolortransparent($new, $trnprt_indx); } // Always make a transparent background color for PNGs that don't have one allocated already elseif ($ext == 'png') { // Turn off transparency blending (temporarily) imagealphablending($new, false); // Create a new transparent color for image $color = imagecolorallocatealpha($new, 0, 0, 0, 127); // Completely fill the background of the new image with allocated color. imagefill($new, 0, 0, $color); // Restore transparency blending imagesavealpha($new, true); } } imagecopyresampled($new, $i, 0, 0, 0, 0, $new_w, $new_h, imagesx($i), imagesy($i)); imagedestroy($i); // save the image switch ($ext) { case 'jpg': case 'jpeg': imagejpeg($new, $dest); break; case 'gif': imagegif($new, $dest); break; case 'png': imagepng($new, $dest); break; } imagedestroy($new);} by calling it via: resize_image($absMainPathImgNew, $absMainPathImgNew, 550, 550);resize_image($absMainPathImgNew, $absPreviewPathImgNew, 150, 150); It does move the first image ok, but does not create the smaller file. It also does not resize (in both cases). Where am I going wrong? Son
  6. They did not let me do this without signing a contract that says that we are responsible if there are any issues arising (is this normal?), but could get the script working with their help. Thanks,Son
  7. Yes. There it is a Javascript Gallery and I will certainly try to figure this out... Thanks for your suggestion. Son
  8. Ok. Will do and see what they say... Many thanks,Son
  9. I have found one issue which was that the file did not have permission which I fixed. Now running the schedule it says:Your script returned the following:X-Powered-By: PHP/5.2.17Content-type: text/htmlwhich looked promising, but no backup generated. I tried to remove the path, but no difference and also tried passthru to see if it works when run in a browser. No luck with this either. You say I should run the script inside a shell... I have nver done this before and believe it is when you run something in MS DOS or similar. Is this correct and how would I do this? Also, in what general cases is this useful? Son
  10. Now I got you, but still not working. I have now: /usr/bin/php5<?phpecho exec('mysqldump -h localhost -p[data] -u [data] [data] > testdump.sql');?> Also tried shell_exec and path to PHP inside php tags, but same result.... Son
  11. I had it within php tags, but not within function. However, still not working as <?php/usr/bin/php5function exec(){mysqldump -h localhost -p[pass] -u [user] [db] > testdump.sql}exec();?> Where am I going wrong? Son
  12. I would like to run a scheduled task via server (hosted) that generates a backup. I uploaded for this reason a file called backup.php to root directory and it has the following code: /usr/bin/php5mysqldump -h localhost -p[PASSWORD] -u [USERNAME] [DATABASENAME] > testdump.sql I cannot get it work and wondered where am I going wrong... Son
  13. Thanks guys. Your inputs really gave me some good pointers... However, if we even assumed the 5 sec rule was true, then the images would all be well within this and the page would load quick. But this is not the case. I tested on different machines with different internet providers and it takes ages for the 1139ms image for example to load... Son
  14. Thanks for this... I have bookmarked the web page and will delve in and out whenever I can... Very helpful!Son
  15. I had a look in Firefoxes web and error console and it shows on page load:[09:24:37.601] GET http://www.domain.com/ [HTTP/1.1 200 OK 188ms][09:24:37.856] GET http://www.domain.com/img/small/info.php?id=1 [HTTP/1.1 200 OK 124ms] (file that brings in the images for gallery) Then clicking to next photo (on load of website the first image of default photo cat shows immediately)[09:30:07.048] GET http://www.domain.co.uk/img/main/holiday.jpg [HTTP/1.1 200 OK 1139ms]Going to server and checking the sizefor photo, the photo is 366KB (710px/493px)Checking a quicker one ([09:30:19.572] GET http://www.domain.co.uk/img/main/road.jpg [HTTP/1.1 200 OK 250ms]) the size is 66KB (720px/512px) What is normally expected for loading time? What setting should the image being saved before using the web admin upload facility and/or is there a way to downsize automatically with my photo upload script? Currently I check for dimensions and resize if too wide or high... Son
  16. I use Javascript as this p is directly under a javascript generated slideshow and I only want to show text if javascript is enabled... Son
  17. Thanks. That is very helpful. I will create a homepage, one for the ones you can update/delete and another one for the gallery... I am not to verses in object-oriented programming, but have great includes for header and footer that include all the general stuff and might just need some tweaking here and there. Would it be better to learn object-oriented programming? Till now, I have not used this at all as there was no need... Son
  18. Images have varying sizes, anything in between 39KB and 433KB at present... Son
  19. I have build basic options for user to update the content on their websites and think now it the time to build one global version that I can use again and again without me spending hours each time to do a new system... This will also be better to update when needed. The parts I have so far are great and with some mod rewrite all also very URL-friendly. However, I have a theoretical question that I find hard to solve with my pen and paper here. Maybe some of you can share their experience when you build systems like this... As for the websites in general: Thee homepage is a bit different from the rest and cannot be deleted. There are some other pages that all fit the same design, those can be deleted and also pages can be added. There is also usually a gallery page (or several). My main question: do I physically create one page that brings in content with logic for all those different bits or do I do one for homepage, one for the pages that can be delete and created (all can be updated any time) and one for gallery? Where lies the balance in between avoiding redundancy/creating too many similar web pages and slowing the web page down due to too many logical checks? Any experience and/or help appreciated! As I said I am pretty ok for technical bits, I only need some theoretical backing (or maybe you know how to run tests to measure what would be best?)...Thanks,Son
  20. On a photo gallery site the photos we have issues as it simply takes too long. I am not sure if the issues is too large image size, the Javascript is causing it or the server is too slow (or whatever else the reason might be). What is a sensible way to go along testing and find the "real" cause? Thanks,Son
  21. It complainsdocument type does not allow element "p" hereThe Javascript is embedded in between <div> and </div> Son
  22. I have some trouble validating code that I generated via PHP as: echo "document.write('<p id=\"slidesHint\">Info Text</p>')"; Where is the issue with this? Thanks,Son
  23. son

    Headers From Mail Function

    Thanks. Will do... Son
  24. Sending headers as $headers = 'From: My Website <info@mywebsite.com>' . "\n"; $headers .= 'MIME-Version: 1.0' . "\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; I cannot figure out why the 'From part' arrives in actual email as:mywebsite.com [mywebsite.com@web864.extcp.com; on behalf of; My Website [info@mywebsite.com] Where am I going wrong? Thanks,Son
×
×
  • Create New...