Jump to content

kahodges

Members
  • Posts

    42
  • Joined

  • Last visited

Everything posted by kahodges

  1. This script adds a text watermark to an image. No matter what number I put into this script under $fontsize = ? for changing the font size, it does not change when viewing the image. I've tried adding px and em to the number to see if that would help, but it made the images not show up altogether. Can anyone please help me? Here is the code: <?php function watermark_text($src_image,$watermarkstring,$watermark_location,$watermark_margin=0) { $file = $src_image; $size = getimagesize($file); $w = $size[0]; $h = $size[1]; $fontsize = 30; if(stristr($file,".jpg") || stristr($file,".jpeg")) { $image=@imagecreatefromjpeg($file); } else if(stristr($file,".png")) { $image = @imagecreatefrompng($file); } else { exit("Sorry, only *.jpg/*jpeg and *.png images are supported"); } $color = imagecolorallocate($image, 200, 200, 200); $xi = 0; $yi = 0; $strlen_watermark = strlen($watermarkstring); switch($watermark_location) { case "topleft": $x = $watermark_margin; $y = $watermark_margin; break; case "topright": $x = $size[0] - $fontsize * strlen($watermarkstring); $y = $watermark_margin; break; case "center": $x = $size[0]/2 - $fontsize * strlen($watermarkstring)/2; $y = $size[1]/2 - $fontsize ; break; case "bottomleft": $x = $watermark_margin; $y = $size[1] - $fontsize - $watermark_margin; break; case "bottomright": $x = $size[0] - $fontsize * strlen($watermarkstring); $y = $size[1] - $fontsize - $watermark_margin; break; default: $x = 0; $y = 0; break; } imagestring($image, $fontsize, $x, $y, "$watermarkstring", $color); if(stristr($file,".jpg") || stristr($file,".jpeg")) { header("Content-type: image/jpeg"); imagejpeg($image,NULL,100); } else if(stristr($file,".png")) { header("Content-type: image/png"); imagepng($image); } else { exit("Sorry, only *.jpg/*jpeg and *.png images supported"); } ImageDestroy($image); }//function ////////////////////////////////////////////////////////////////////////////////// function watermark_image($image_path_src,$image_path_watermark,$watermark_location,$watermark_margin=0) { if(stristr($image_path_src,".jpg") || stristr($image_path_src,".jpeg")) { $image=@imagecreatefromjpeg($image_path_src); } else if(stristr($image_path_src,".png")) { $image = @imagecreatefrompng($image_path_src); } else { exit("Sorry, only *.jpg/*jpeg and *.png images are supported"); } $size = getimagesize($image_path_src); $w = $size[0]; $h = $size[1]; $src_x = 0; $src_y = 0; if(preg_match("#\.png$#i",$image_path_watermark)) $watermark_image = imagecreatefrompng($image_path_watermark); else if(preg_match("#\.gif$#i",$image_path_watermark)) $watermark_image = imagecreatefromgif($image_path_watermark); else if(preg_match("#\.jpe*g$#i",$image_path_watermark)) $watermark_image = imagecreatefromjpeg($image_path_watermark); else exit("Sorry, only *.gif, *.jpg and *.png watermarks are supported"); $size_watermark = getimagesize($image_path_watermark); $dst_w = $src_w = $size_watermark[0]; $dst_h = $src_h = $size_watermark[1]; switch($watermark_location) { case "topleft": $x = $watermark_margin; $y = $watermark_margin; break; case "topright": $x = $size[0] - $size_watermark[0] - $config["watermark_margin"]; $y = $watermark_margin; break; case "center": $x = $size[0]/2 - $size_watermark[0]/2; $y = $size[1]/2 - $size_watermark[1]/2; break; case "bottomleft": $x = $watermark_margin; $y = $size[1] - $size_watermark[1] - $watermark_margin; break; case "bottomright": $x = $size[0] - $size_watermark[0] - $watermark_margin; $y = $size[1] - $size_watermark[1] - $watermark_margin; break; default: $x = 0; $y = 0; break; } $dst_x = $x; $dst_y = $y; imagecopymerge($image,$watermark_image,$dst_x,$dst_y,$src_x,$src_y,$src_w,$src_h,25); if(stristr($image_path_src,".jpg") || stristr($image_path_src,".jpeg")) { header("Content-type: image/jpeg"); imagejpeg($image,NULL,100); } else if(stristr($image_path_src,".png")) { header("Content-type: image/png"); imagepng($image); } else { exit("Sorry, only *.jpg/*jpeg and *.png images supported"); } ImageDestroy($image); } ///////////////////////////////////////////// include(dirname(__FILE__)."/../common.ini.php"); $item = $catalog->items->get("WHERE id=".(int)$_GET["id"]); switch($config["watermark_type"]) { case "text":watermark_text("../rwx/".$item["file"],$config["watermark_text"],$config["watermark_location"],$config["watermark_margin"]);break; case "image":watermark_image("../rwx/".$item["file"],"../rwx/".$config["watermark_image"],$config["watermark_location"],$config["watermark_margin"]);break; } ?>
  2. I'm trying to set up a host to connect to a remote MySQL database. I can connect to a database on localhost, but not on the remote system. I have added the IP address that will be connecting to the database on the remote server through CPanel giving it permission to connect. The hosting company for the remote server claims to have added the IP address to the white list on the firewall for the domain that is connecting to the mysql server. When I access the php script trying to connect to the remote database, I get the following: Lost connection to MySQL server at 'reading initial communication packet', system error: 110 Anything else might cause this besides the IP being blocked on the firewall? I know it's not the script itself, as I can connect to a local database with no problem. Thanks.
  3. That's what it was. It was including more than the one column in the index. I dropped the relation, dropped the index. added the index back, added the relation back, and codegen. It's not giving the notice any longer. Thanks for your help.
  4. I just started using Qcodo framework, and ran the codegen. It produced the following error regarding my mysql database: I'm not exactly sure what this means? Do I add another column to the table, and name it am_startup_ibfk_1? I already have that column , am_startup.employee indexed. I'm using phpMyAdmin to set up the relations between the tables. I'm just barely grasping foreign keys, so your help would be most appreciated.
  5. O.K., got it working like I want. Have a cron job set up, and now my reminder script is spitting out reminder e-mails. In case this will help anyone, here it is: <?php include('database.inc.php'); // Our database connectivity file $sql = <<<EOL SELECT t1.reminder_id AS reminder_id, t1.reminder_name AS reminder_name, t1.reminder_desc AS reminder_desc, t1.reminder_date AS reminder_date, t1.reminder_email AS reminder_email, lp4.email AS lp_reminder_email FROM reminder_events AS t1 LEFT OUTER JOIN authorize AS lp4 ON ( t1.reminder_email = lp4.email ) WHERE DAY(reminder_date) = DAY(DATE_ADD(CURDATE(),INTERVAL 1 DAY)) ORDER BY reminder_date ASC LIMIT 0 , 900000000000000000; EOL; $result = mysql_query($sql) or die(mysql_error()); while( $row = mysql_fetch_array($result)) { $to = $row["reminder_email"]; $from = "reminder@mydomain.com"; $headers = "From:$from"; $headers = preg_replace('#(?<!\r)\n#si', "\r\n", $headers); $subject = $row["reminder_name"]; $message = preg_replace("#(?<!\r)\n#si", "\r\n", $message); $body = $row["reminder_desc"]; mail($to, $subject, $body, $headers); } { mysql_query("DELETE FROM reminder_events WHERE DAY(reminder_date) = DAY(DATE_ADD(CURDATE(),INTERVAL 1 DAY))"); } ?>
  6. You could use a .htacess file to redirect your domain to any script located on the same domain, or a different domain.
  7. O.K., I enabled error reporting, and now it's not throwing any errors. However, it does not seem to be sending out the e-mail. Here is what I have now: <?php ini_set('display_errors',1); error_reporting(E_ALL); include('database.inc.php'); // Our database connectivity file ?> <?php $reminder_date = 't1.`reminder_date`'; $email = 'lp4.`email`'; $reminder_name = 't1.`reminder_name`'; $reminder_details = 't1.`reminder_desc`'; $sql = "SELECT t1.`reminder_id` , t1.`reminder_name` , t1.`reminder_desc` , t1.`reminder_date` , t1.`reminder_email` , lp4.`email` AS `lp_reminder_email` FROM `reminder_events` AS t1 LEFT OUTER JOIN `authorize` AS lp4 ON ( t1.`reminder_email` = lp4.`email` ) WHERE reminder_date <= NOW( ) ORDER BY `reminder_date` ASC"; $result = mysql_query($sql) or die(mysql_error()); while( $row = mysql_fetch_array( $result ) ) ?> <?php $to = $row[$email]; $from = $row[$email]; $headers = $from; $subject = $row[$reminder_name]; $body = $row[$reminder_details]; { $send = @mail($to, $subject, $body, $headers); } ?>
  8. Here is the code I have so far: <?php include('database.inc.php'); // Our database connectivity file ?> <?php $reminder_date = 't1.reminder_date'; $email = 'lp_reminder_email'; $reminder_name = 't1.reminder_name'; $reminder_details = 't1.reminder_desc'; $result = mysql_query($sql) or die(mysql_error()); $sql = "SELECT t1.`reminder_id` , t1.`reminder_name` , t1.`reminder_desc` , t1.`reminder_date` , t1.`reminder_email` , lp4.`email` AS `lp_reminder_email` FROM `reminder_events` AS t1 LEFT OUTER JOIN `authorize` AS lp4 ON ( t1.`reminder_email` = lp4.`email` ) WHERE reminder_date <= NOW() ORDER BY `reminder_date` ASC"; $result = 'mysql_num_rows'; while( $row = mysql_fetch_array( $result ) ) if( !empty( $nr ) ) ?> <?php $to = $row[$email]; $from = $row[$email]; $headers = $from; $subject = $row[$reminder_name]; $body = $row[$reminder_details]; { $send = @mail($to, $subject, $body, $headers); } ?> The sql query when run through phpMyAdmin returns a result. When I open this in the browser, it says "Query is empty". Anyone want to help a newb out and show me what I'm doing wrong? I'd like for it to pull the data out of these fields and send it via e-mail. What would be even better is if I could get it to do this the day before the `reminder_date`. I can set it up so cron runs the script, I just need to get the script to work first. Thanks in advance for your help.
  9. Nevermind. I had an extra comma in there. Thanks anyway.
  10. I have the following query: It processes through fine until I get to the WHERE clause. This is what I get on the above: Can someone please point out what I am doing wrong? I'm running MySQL 5.1.48 Thanks.
  11. I'm trying to build a small php script to help automate adding vacation time to keep track of employees available vacation. I can run the sql below, and it executes fine: I'm trying to build this into a php function. This is what I have so far: <?php function sql_addition() { global $conn; global $_POST; $sql = "update `vacation` set `avail_vacation`= `avail_vacation` + `added` where employee = .sqlvalue(@$_POST["employee"])"; mysql_query($sql, $conn) or die(mysql_error()); } <html> <tr> <td class="hr"><?php echo htmlspecialchars("Add Hours")." " ?></td> <td class="dr"><input type="text" name="added" value="<?php echo sql_addition('"', '"', trim($row["added"])) ?>"></td> </tr> ?> </html> It's showing the error below where the field should be for submitting hours to add: Help would be greatly appreciated.
  12. Update `vacation` set avail_vacation = `avail_vacation` + 30 where employee = "employee1"; That worked. Thank you.
  13. MySQL version 5.1.30. I have a field that I'm trying to update and add a number to, and then have it update to the new total and display the sum in that same field. Is this possible? Tried: SELECT avail_vacation FROM vacation WHERE employee = employee1 + 30; UPDATE vacation.avail_vacation WHERE employee = "employee1" + 30; Table: CREATE TABLE IF NOT EXISTS `vacation` ( `id` int(6) NOT NULL AUTO_INCREMENT, `employee` varchar(75) COLLATE utf8_unicode_ci NOT NULL, `avail_vacation` smallint(6) NOT NULL, `added` int(4) NOT NULL, `used` int(4) NOT NULL, PRIMARY KEY (`id`), KEY `employee` (`employee`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=2 ; Thanks.
  14. I took the brackets out, and it's working fine now: <td><font face="Arial, Helvetica, sans-serif"><?php echo "<a href=https://www.mysite.com/maps/$f5>Map</a>"?></font></td> Thanks for everyone's help.
  15. Here's the entire script: <html> <body> <?php $username="username"; $password="password"; $database="database_name"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM `jobs` WHERE ( `url` is not NULL and trim(`url`) <> '' )"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">job #</font></th> <th><font face="Arial, Helvetica, sans-serif">company</font></th> <th><font face="Arial, Helvetica, sans-serif">location</font></th> <th><font face="Arial, Helvetica, sans-serif">map</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"job"); $f3=mysql_result($result,$i,"company"); $f4=mysql_result($result,$i,"location"); $f5=mysql_result($result,$i,"url"); ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo ("<a href=https://www.mysite.com/maps/$f5>Map</a>)"?></font></td> </tr> <?php $i++; } ?> </body> </html> This is line 39: <td><font face="Arial, Helvetica, sans-serif"><?php echo ("<a href=https://www.teamcrr.com/maps/$f5>Map</a>)"?></font></td>
  16. I figured out what was I was doing wrong on where I tried your code, and I see the difference now, and think I understand. I have the code as: <td><font face="Arial, Helvetica, sans-serif"> <?php echo ("<a href=https://www.teamcrr.com/maps$f5>Map</a>)"?></font></td> That code shows as valid in my editor. Now, my problem is that it's throwing the following error: Parse error: syntax error, unexpected ';' in /home/directory/public_html/map.php on line 39 Line 39 is the code I have displayed above, and I know I'm getting old and half blind, but I don't see where there's a ; anywhere in that line. Anyone know what I need to do?
  17. I'm getting the following error on that script: Parse error: syntax error, unexpected T_VARIABLE I do appreciate your trying to help me understand. Thanks.
  18. I read it, but I'm not understanding. Are you saying there should be single quotes instead of the double quotes around the url in this line?: <?php echo( '<a href="https://www.mysite.com/maps/.$f5">Map</a>'); ?> If that is what you mean, I've tried it, and I get a Parse error: syntax error, unexpected T_STRING. If you can point out where I'm messing up, and be a little clearer on what you mean, I'd appreciate it. Thanks.
  19. I'm trying to get it to display as so: https://www.mysite.com/maps/file_name.pdf Instead, I'm getting: $site.$f5 displaying as the url. I went through as did the following change: Removed the line containing: $site="https://www.mysite.com/maps/"; and changed the line below: <?php echo( '<a href="https://www.mysite.com/maps/.$f5">Map</a>'); ?> Now, I'm getting it to display as: https://www.mysite.com/maps/.$f5 as the url. I need $f5 to display the file name out of MySQL. Thanks.
  20. I'm trying to pull a url from a database table and display it as a html hyperlink in php. I'm getting the link to display, but I'm having trouble getting it to pull the MySQL data into the field. Thanks in advance if you can steer me in the right direction. Here is my code: <html> <body> <?php $username="username"; $password="password"; $database="database_name"; mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query="SELECT * FROM `jobs` WHERE ( `url` is not NULL and trim(`url`) <> '' )"; $result=mysql_query($query); $num=mysql_numrows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th><font face="Arial, Helvetica, sans-serif">Job #</font></th> <th><font face="Arial, Helvetica, sans-serif">Company</font></th> <th><font face="Arial, Helvetica, sans-serif">Location</font></th> <th><font face="Arial, Helvetica, sans-serif">Map</font></th> </tr> <?php $i=0; while ($i < $num) { $f1=mysql_result($result,$i,"id"); $f2=mysql_result($result,$i,"job"); $f3=mysql_result($result,$i,"company"); $f4=mysql_result($result,$i,"location"); $f5=mysql_result($result,$i,"url"); $site="https://www.mysite.com/maps/"; ?> <tr> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f2; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f3; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo $f4; ?></font></td> <td><font face="Arial, Helvetica, sans-serif"><?php echo( '<a href="$site.$f5">$f5</a>'); ?></font></td> </tr> <?php $i++; } ?> </body> </html>
  21. I have the following code: $sql .=" where ( `date` is null or trim(`date`) = '' ) "; I'm using MySQL date format, which is 0000-00-00. When the field is left blank, it leaves 0000-00-00 instead of null. Is there another way around this? If there's an entry in that field instead of null, it causes my php script to not display an entry on the screen. Thanks.
  22. It's not producing an error, but at the same time, it's not sending out the e-mail with the results from the table.
  23. Can anyone tell me what I'm doing wrong? Thanks in advance. Here's the code: #!/usr/bin/php -q -c /etc/php.ini <? $dbhost = "localhost"; $dbuser = "username"; $dbpass = "password"; $dbname = "database"; mysql_connect($dbhost,$dbuser,$dbpass); @mysql_select_db($dbname) or die("Unable to select database"); return $conn; $query = "SELECT id, vehicle, last_date, due_date FROM inspection WHERE DATE_ADD(CURDATE(),INTERVAL 30 DAY) = due_date;"; $row = mysql_query($query) or die(mysql_error()); $sendto = "Me <me@mydomain.com>"; $sendfrom = "System Backup <admin@mydomain.com>"; $sendsubject = "Maintenance Reminder"; $bodyofemail = $row['vehicle']." ".$row['last_date']." ".$row['due_date']; // Mail the file include('Mail.php'); include('Mail/mime.php'); $message = new Mail_mime(); $text = "$bodyofemail"; $message->setTXTBody($text); $message->AddAttachment($backupfile); $body = $message->get(); $extraheaders = array("From"=>"$sendfrom", "Subject"=>"$sendsubject"); $headers = $message->headers($extraheaders); $mail = Mail::factory("mail"); $mail->send("$sendto", $headers, $body); ?>
  24. That helped me so much. Thanks.
×
×
  • 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.