Jump to content

fastsol

Moderators
  • Posts

    827
  • Joined

  • Last visited

  • Days Won

    9

Everything posted by fastsol

  1. Are you doing this on localhost or a web host? If on a webhost, the time will depend on what the server time is set to and where the server is actually located in the world.
  2. Ahh, good eye. I got those backwards when I gave you the code. This line watermarkImage($filePath, $stamp, $margin, $destination); Should be this watermarkImage($stamp, $filePath, $margin, $destination);
  3. I would imagine there is a direct corellation of bandwidth to the size of the zip file being downloaded, so only you would know those stats. Based on those stats you would have to figure out if your host can handle it or if you are allowed that much bandwidth in your plan.
  4. Just put the query stuff right before these lines /* * PHP GD * adding watermark to an image with GD library */
  5. Not sure where my last post went but, you don't have anything in your code to save to a db or even connect to one.
  6. I resorted to wget cause of the path issue i described above. So I guess because of that the cli thing may have not worked either then huh.
  7. Oh yes I can concur that GoCrappy is worthless and their servers are not worth the money. I got rid of them about 4 years ago and have been so glad I did. Yes the email thing can be so frustrating and no one really seems to understand that most of it relates back to the server it self and how things are setup.
  8. The destination can be whatever you want it to be for the final image name and where you want it stored. If you simply want the uploaded file replaced with the new watermarked image then do $destination = $filePath; If it doesn't store it then you'll need to verify the path to the folder you're trying to store it in, but since it seems to work for the upload, in theory it should work for the watermark too.
  9. Sorry that was rude, I remember when I struggled with functions too.
  10. Seriously!, you don't know how to use a standard function? I reworked your code to handle my function. I can't say it's perfect cause I'm not going to make a html form to fully test it. <?php //Creates a water marked image // $wm is the watermark image you want to use // $img is the image to watermark // $xy should be an array of x and y coordinates - $xy['x'] = 150 $xy['y'] = 40 // placement defaults to center if $xy is not supplied // $dest woudl be a place to save the file if you are not displaying the new image directly to the browser. function watermarkImage($wm, $img, $xy = NULL, $dest = NULL) { $watermark = imagecreatefrompng($wm); $wm_src = getimagesize($wm); $source = getimagesize($img); $mime = $source['mime']; if($mime === 'image/jpg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/jpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/pjpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/png') {$src = imagecreatefrompng($img);} elseif($mime === 'image/gif') {$src = imagecreatefromgif($img);} $x = ($xy !== NULL) ? $xy['x'] : floor(($source[0] / 2) - ($wm_src[0] / 2)); $y = ($xy !== NULL) ? $xy['y'] : floor(($source[1] / 2) - ($wm_src[1] / 2)); imagecopy($src, $watermark, $x, $y, 0, 0, imagesx($watermark), imagesy($watermark)); imagealphablending($src, false); imagesavealpha($src, true); if($mime === 'image/jpg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/jpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/pjpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/png') { if($dest !== NULL) { imagepng($src, $dest); } else { header('Content-Type: image/png'); imagepng($src); } } elseif($mime === 'image/gif') { if($dest !== NULL) { imagegif($src, $dest); } else { header('Content-Type: image/gif'); imagegif($src); } } imagedestroy($src); } $uploadDir = '../uploads/'; if(isset($_POST['upload'])) { foreach ($_FILES as $file) { $fileName = $file['name']; $tmpName = $file['tmp_name']; $fileSize = $file['size']; $fileType = $file['type']; if($fileName==""){ $filePath = '../img/none.jpg'; } else{ $filePath = $uploadDir . $fileName; } ////generate random name //// get the file extension first $ext = substr(strrchr($fileName, "."), 1); // //// make the random file name $randName = md5(rand() * time()); // //// and now we have the unique file name for the upload file $filePath = $uploadDir . $randName . '.' . $ext; // Replace spaces with a '_' $filePath = str_replace(" ", "_", $filePath); $result = move_uploaded_file($tmpName, $filePath); //if (!$result) { //echo "Error uploading file"; //exit; //} if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } $fileinsert[]=$filePath; } /* * PHP GD * adding watermark to an image with GD library */ // Load the watermark and the photo to apply the watermark to $stamp = '../img/watermark_fotos.png'; // Set the margins for the stamp and get the height/width of the stamp image $margin['x'] = 10; $margin['y'] = 10; $destination = 'path_where_you_want_the_image_stored'; watermarkImage($filePath, $stamp, $margin, $destination); } ?> You have some other badly written code in there but I didn't focus on any of that. This in particular is pretty bad. if(!get_magic_quotes_gpc()) { $fileName = addslashes($fileName); $filePath = addslashes($filePath); } Magic quotes should be disabled by default on any server at this point, it's a very bad function that php used in the past and has since been removed. Towards the end of the code you will need to edit the $destination var value to an actual path and file name you want the watermarked images stored to.
  11. Try this function that I have in my code base. //Creates a water marked image // $wm is the watermark image you want to use // $img is the image to watermark // $xy should be an array of x and y coordinates - $xy['x'] = 150 $xy['y'] = 40 // placement defaults to center if $xy is not supplied // $dest woudl be a place to save the file if you are not displaying the new image directly to the browser. function watermarkImage($wm, $img, $xy = NULL, $dest = NULL) { $watermark = imagecreatefrompng($wm); $wm_src = getimagesize($wm); $source = getimagesize($img); $mime = $source['mime']; if($mime === 'image/jpg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/jpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/pjpeg') {$src = imagecreatefromjpeg($img);} elseif($mime === 'image/png') {$src = imagecreatefrompng($img);} elseif($mime === 'image/gif') {$src = imagecreatefromgif($img);} $x = ($xy !== NULL) ? $xy['x'] : floor(($source[0] / 2) - ($wm_src[0] / 2)); $y = ($xy !== NULL) ? $xy['y'] : floor(($source[1] / 2) - ($wm_src[1] / 2)); imagecopy($src, $watermark, $x, $y, 0, 0, imagesx($watermark), imagesy($watermark)); imagealphablending($src, false); imagesavealpha($src, true); if($mime === 'image/jpg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/jpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/pjpeg') { if($dest !== NULL) { imagejpeg($src, $dest, 95); } else { header('Content-Type: image/jpeg'); imagejpeg($src); } } elseif($mime === 'image/png') { if($dest !== NULL) { imagepng($src, $dest); } else { header('Content-Type: image/png'); imagepng($src); } } elseif($mime === 'image/gif') { if($dest !== NULL) { imagegif($src, $dest); } else { header('Content-Type: image/gif'); imagegif($src); } } imagedestroy($src); }
  12. I tried this and variations of it while trying to setup things in the past and was not able to ever make it work.
  13. That was awesome, thank you. There were a couple things it didn't like when I first ran it but I figured them out. There was an extra , before the first SUM and the GROUP BY didn't like the `products`.`id` AS `pid` being declared again, so it worked with just `pid` instead. I checked results before and after running on a couple dates to make sure the result was the same and it was!
  14. I just tried it in Firefox and Chrome and neither let you do anything. The only thing that happens is the icons get a white box around them on hover, but that's it for me. Plus it looks very unprofessional.
  15. Oops, forgot one thing in the query when I was making it more readable for the forum. Here is the updated version. SELECT `products`.`id` AS `pid`, `products`.`prod_name`, (SELECT COUNT(*) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 0 AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `committed`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 1 AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_per_item`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` INNER JOIN `schedule` ON `schedule`.`deposit_id` = `quote_deposits`.`id` WHERE `quote_responses`.`purchased` = 0 AND `schedule`.`cancelled` != '' AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_cancelled` FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` WHERE `quote_deposits`.`dep_date` >= $committed_start GROUP BY `products`.`prod_name` ORDER BY `products`.`prod_name` ASC
  16. I have this query that fully works the way it is, but I am wondering if I am overdoing some things in it. I know this may be hard to tell without knowing the full relationship between all the tables in the query. I'm basically running 3 subqueries mostly based on a timestamp value and other specific clauses per subquery. Where the main query is only gathering based on the timestamp. Like I said it works perfect from what I can verify by cross referencing the tables manually and checking the results the query returned. I just want to know if there is a better way to do all this. SELECT `products`.`id` AS `pid`, `products`.`prod_name`, (SELECT COUNT(*) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 0 AND `quote_deposits`.`dep_date` >= $committed_start ) AS `committed`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` WHERE `quote_responses`.`purchased` = 1 AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_per_item`, (SELECT COUNT(`products`.`id`) FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` INNER JOIN `quote_responses` ON `quote_responses`.`id` = `quote_deposits`.`q_id` INNER JOIN `schedule` ON `schedule`.`deposit_id` = `quote_deposits`.`id` WHERE `quote_responses`.`purchased` = 0 AND `schedule`.`cancelled` != '' AND `products`.`id` = `pid` AND `quote_deposits`.`dep_date` >= $committed_start ) AS `total_cancelled` FROM `products` INNER JOIN `quote_deposits` ON `quote_deposits`.`product_id` = `products`.`id` WHERE `quote_deposits`.`dep_date` >= $committed_start GROUP BY `products`.`prod_name` ORDER BY `products`.`prod_name` ASC
  17. https://www.youtube.com/user/betterphp/search?query=watermark
  18. It's not your host that is the problem. One big problem is that you are missing the basic important headers for the mail function. Here is a article I wrote on this subject http://amecms.com/article/Sending-email-in-PHP-and-reaching-the-inbox
  19. Why not? It all depends on the content of the site I guess and if you think yo need personal info on the commenter. I have a setting on mine to allow comments if not logged in, or change it at any time to disallow.
  20. I understand the concern you have with PDO, but honestly it's pretty easy to use. I learned on mysql too and decided to switch a while back when I was still learning a lot of php, so I too didn't really know what I was getting in to. But I converted my whole cms in a matter of hours, so it was actually pretty easy to learn. If you decide to change, the pagination tool can do PDO also.
  21. None of this is being output by php, so of course it's not going to change. <td> Total price: </td> <td> 1.2€ </td> <td style="font-size:12px;color:#e07b14"> 1.2€ Each </td> Are you processing the quantity above that code with php when the form is submitted? You should be. So then you could do something like this <td> Total price: </td> <td> <?php echo number_format(($quantity * $price), 2); ?>€ </td> <td style="font-size:12px;color:#e07b14"> 1.2€ Each </td> But honestly there is more to it than that cause $quantity will only have a value AFTER you submit the form. You need to have a base value $price for the product coming from somewhere, then you *(times) that value by the quantity posted to get the new price. Without knowing how or where you are gathering this info for the product and the quantity update, it's really impossible to say how to help you.
  22. It's been so long since I have used the old mysql extensions, I forgot that you are totally open to sql injection in your query. Add this line after the $searchTerm line I provided above. $searchTerm = mysql_real_escape_string($searchTerm); That will prevent sql injection in the query. You really should consider updating your code to PDO or mysqli. The mysql extensions have been deprecated and will likely be removed from php in the future.
  23. You would also need to change this line in the code to pickup the GET instead $searchTerm = trim($_POST['term']); // Now needs to be this $searchTerm = htmlentities(trim($_GET['term'])); // I would add the htmlentities just incase you are displaying the search term anywhere on the page. This will prevent XSS attack. Then change the paginate call to this paginate($total_rows, $pp, $page, $display_links, 'term='.$searchTerm);
  24. I don't see the paginate() being called in the code you posted. It also sounds like you didn't put the additional $_GET vars in the paginate parameters for the search term which is why it all the sudden grows to 240 pages. As it's already been suggested, you need to change your search form to GET instead of POST. This makes it much easier to paginate and that way when someone hits the back button in the browser the search term is reatined and the form doesn't have to be submitted again.
  25. I have a pagination page generator here http://amecms.com/article/Pagination-Page-Generator . The function that outputs the links will also take a parameter for the extra $_GET vars you need in the links, you just need to make a string to feed the function for those added vars.
×
×
  • 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.