Jump to content

dennismonsewicz

Members
  • Posts

    1,136
  • Joined

  • Last visited

Everything posted by dennismonsewicz

  1. hmmm I will have to check that out! I appreciate ALL of your help buddy!
  2. I am working on a PHP script that will take a generated barcode and then place the image inside of a PDF using the FPDF script. require_once('fpdf.php'); require_once('fpdi.php'); $pdf =& new FPDF(); $pdf->Image("images/o-png24.png"); $pdf->Output("pdf.pdf", "F"); The PDF creates but the image does not place inside the PDF... any ideas?
  3. Hmmm alright... I will keep looking then... I appreciate it buddy!
  4. ah gotcha... I follow you now... sorry for the newb question... so I changed my code just a little bit: function processPDF($img) { $imgFile = "images/" . $img . ".jpg"; $pdfdoc = pdf_new(); pdf_open_file($pdfdoc, "test.pdf"); $image = pdf_load_image($pdfdoc, "jpeg", $imgFile, ""); pdf_fit_image($pdfdoc, $image, 0, 50, ""); pdf_close($image); } but now I am getting the following error: Fatal error: Uncaught exception 'PDFlibException' with message 'Function must not be called in 'document' scope' in /var/www/barcode/index.php:31 Stack trace: #0 /var/www/barcode/index.php(31): pdf_fit_image(Resource id #4, 1, 0, 50, '') #1 /var/www/barcode/index.php(36): processPDF('hello') #2 {main} thrown in /var/www/barcode/index.php on line 31 And thanks for ALL of your help thus far!
  5. hmmm I think I am confused... what is meant by resource?
  6. I am trying to create script that I can open a PDF file and write an image to this file. Here is my code so far function processPDF($img) { $imgFile = "images/" . $img . ".jpg"; $fd = fopen("test.pdf", "w"); $pdfdoc = pdf_new(); pdf_open_file($pdfdoc, "test.pdf"); $image = pdf_load_image($pdfdoc, "jpeg", $imgFile, ""); pdf_fit_image('test.pdf', $image, 0, 50, ""); pdf_close_image($image); fclose($fd); } I have found several tutorials on how to create brand new PDF document, I already have a PDF doc I want to use. The error I am getting with the above is this: Fatal error: Uncaught exception 'PDFlibException' with message 'pdf_fit_image() expects parameter 1 to be resource, string given' in /var/www/barcode/index.php:23 Stack trace: #0 /var/www/barcode/index.php(23): pdf_fit_image('test.pdf', 1, 0, 50, '') #1 /var/www/barcode/index.php(28): processPDF('hello') #2 {main} thrown in /var/www/barcode/index.php on line 23 Any ideas?
  7. Thanks everyone! I will check out that website mentioned
  8. I have been trying to better understand error checking but was wondering what are the best practices for using isset() vs empty()? Thanks! Dennis
  9. <?php header( "Content-type: image/png" ); session_start(); function createImg() { $num_chars=6;//number of characters for captcha image $characters=array_merge(range(0,9),range('A','Z'),range('a','z'));//creating combination of numbers & alphabets shuffle($characters);//shuffling the characters $captcha_text=""; for($i=0;$i<$num_chars;$i++) { $captcha_text.=$characters[rand(0,count($characters)-1)]; } $_SESSION['captcha'] =$captcha_text;// assigning the text into session $captcha_image=imagecreatetruecolor(140,30); $captcha_background=imagecolorallocate($captcha_image,225,238,221);//setting captcha background colour $captcha_text_colour=imagecolorallocate($captcha_image,58,94,47);//setting cpatcha text colour imagefilledrectangle($captcha_image,0,0,140,29,$captcha_background);//creating the rectangle imagettftext($captcha_image,20,0,11,21,$captcha_text_colour,$captcha_text); imagepng($captcha_image); imagedestroy($captcha_image); } echo '<img src="' . createImg() . '" alt="Captcha" />'; ?> The above just outputs weird characters the screen, such as: �PNG ��� IHDR����������qa!���gIDATh���A � ���1�y`� H�s4�SФc��p������`R�I&�`R�I&�`R�I&�`R�I&�`R�I&�`R�I&�`R�I&���l{\����IEND�B`� Any ideas why this is happening? Thanks!
  10. I would check out using jQuery to handle your AJAX requests. Much easier to use and much cleaner to look at
  11. I am trying to do a find and replace of a spanish word in a string but can't get it to work... $tele_array = array('teléfonos', 'teléfono'); $apar_array = array('aparatos', 'aparato'); if($culture == 'es-US' && $id == 1) { if(strstr($answer, 'teléfonos')) { echo 'Found it!'; $answer = str_replace($tele_array, $apar_array, $answer); } } the echo statement does not display and the rest of the script continues. Any thoughts?
  12. so this is what I came up with: function maskStr($str = '') { $characters = "1234567890abcdefghjkmnopqrstuvwxyz"; $explode = strtok($str, ""); $string_one = ''; $string_two = ''; $string_three = ''; $string_four = ''; for($a = 0; $a < 3; $a++) { $string_one .= $characters[mt_rand(0, strlen($characters) - 1)]; $first = $string_one . $explode[0]; } for($b = 0; $b < 1; $b++) { $string_two .= $characters[mt_rand(0, strlen($characters) - 1)]; $second = $first . $string_two . $explode[1] . $explode[2]; } for($c = 0; $c < 4; $c++) { $string_three .= $characters[mt_rand(0, strlen($characters) - 1)]; $third = $second . $string_three . $explode[3]; } for($d = 0; $d < 2; $d++) { $string_four .= $characters[mt_rand(0, strlen($characters) - 1)]; $final = $third . $string_four; } return $final; } echo maskStr('1234'); Is there anyway to make the above condensed or easier to look at it?
  13. I am trying to write a script that masks a users input when they submit a form and takes a field and is manipulated and then dumped into a database after being manipulated. The mask will look like this: nnn1n23nnnn4nn Where n is a random number or letter and the '1234' will be the input from the user... Any idea on how to achieve this?
  14. ok so I got this working... SELECT * FROM tbl_name WHERE DATE_SUB(NOW(), INTERVAL 24 HOUR) <= date_col but it only selects the entries from today... I need it to pull entries from the past 24 hours... I pull a report every morning around 10am and need to be able to pull results from then and the past twenty four hours
  15. SELECT * FROM tbl_name WHERE DATE_SUB(CURDATE(), INTERVAL -1 DAY) <= date the above sql statement is supposed to select all of the results from the past 24 hours, but when I pull the query I get nothing... any ideas?
  16. if(file_exists($file)) { $cmd = "uuencode " . escapeshellarg($file) . " " . escapeshellarg($attachment_name) . " | mail -s 'Test' dennismonsewicz@gmail.com"; if(passthru($cmd)) { echo '<p>File Sent Sucessfully!</p>'; } else { echo '<p>File Could Not Be Sent! </p>'; } } else { echo '<p>File does not exist!</p>'; } So I have the above command to encode a file and send it to me with the attachment... but when I run the script I get the error message of File Could Not Be Sent! ... but I still receive the test email with the attachment... Any ideas on why this is?
  17. header('Content-Description: File Transfer'); header('Content-Type: application/octet-stream'); header('Content-Disposition: attachment; filename='.basename("/tmp/mytest.xls")); header('Content-Transfer-Encoding: binary'); header('Expires: 0'); header('Cache-Control: must-revalidate, post-check=0, pre-check=0'); header('Pragma: public'); header('Content-Length: ' . filesize("/tmp/mytest.xls")); readfile("/tmp/mytest.xls"); The code above does not force download the file, rather it displays the results on the screen... is this a problem of the headers not sending?
  18. ok so now I am getting the following error: Fatal Error: 'send' is an unknown method of 0 updated code: require 'Mail.php'; $recipients = 'dennismonsewicz@gmail.com'; $headers['From'] = 'dennismonsewicz@gmail.com'; $headers['To'] = 'dennismonsewicz@gmail.com'; $headers['Subject'] = 'Test message'; $body = 'Test message'; $params['sendmail_path'] = '/usr/lib/sendmail'; // Create the mail object using the Mail::factory method $mail_object &= Mail::factory('sendmail', $params); $mail_object->send($recipients, $headers, $body);
  19. So I am trying to explore the avenue known as PEAR and I am getting nowhere Here is my code: require '/usr/share/php/Mail.php'; $recipients = 'dennismonsewicz@gmail.com'; $headers['From'] = 'me@me.com'; $headers['To'] = 'dennismonsewicz@gmail.com'; $headers['Subject'] = 'Test message'; $body = 'Test message'; $params['sendmail_path'] = '/usr/lib/sendmail'; // Create the mail object using the Mail::factory method $mail_object =& Mail::factory('sendmail', $params); $mail_object->send($recipients, $headers, $body); If I do not include the file using an absolute path I get the following error message: Fatal Error: 'PEAR.php' is not a valid path But if I include the file with the absolute path I then get a blank page.... Any ideas?
  20. here is the code I am using: $fileatt = $file; // Path to the file $fileatt_type = "application/octet-stream"; // File Type $fileatt_name = "filename.xls"; // Filename that will be used for the file as the attachment $email_from = "me@me.com"; // Who the email is from $email_subject = "subject here"; // The Subject of the email $email_message = "This is a test"; // Message that the email has in it $email_to = "me@me.com"; // Who the email is too $headers = "From: ".$email_from; $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; $email_message .= "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type:text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $email_message . "\n\n"; $attached_file = fopen($fileatt,'rb'); $data = fread($attached_file,filesize($fileatt)); fclose($attached_file); $data = chunk_split(base64_encode($data)); $email_message .= "--{$mime_boundary}\n" . "Content-Type: {$fileatt_type};\n" . " name=\"{$fileatt_name}\"\n" . //"Content-Disposition: attachment;\n" . //" filename=\"{$fileatt_name}\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n" . "--{$mime_boundary}\n"; unset($data); unset($attached_file); unset($fileatt); unset($fileatt_type); unset($fileatt_name); $ok = @mail($email_to, $email_subject, $email_message, $headers); if($ok) { echo "The file was successfully sent!"; } else { die("Sorry but the email could not be sent. Please go back and try again!"); } The email I receive has a bunch of coded jumbly goop with no attachment... Email attachment: This is a testThis is a multi-part message in MIME format. --==Multipart_Boundary_x4db218f24afded124fee220fcb9d6110x Content-Type:text/html; charset="iso-8859-1" Content-Transfer-Encoding: 7bit This is a test --==Multipart_Boundary_x4db218f24afded124fee220fcb9d6110x Content-Type: application/octet-stream; name="filename.xls" Content-Transfer-Encoding: base64 PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz4NCjxXb3JrYm9vayB4bWxucz0i dXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6c3ByZWFkc2hlZXQiDQogeG1sbnM6eD0i dXJuOnNjaGVtYXMtbWljcm9zb2Z0LWNvbTpvZmZpY2U6ZXhjZWwiDQogeG1sbnM6c3M9InVybjpz Y2hlbWFzLW1pY3Jvc29mdC1jb206b2ZmaWNlOnNwcmVhZHNoZWV0Ig0KIHhtbG5zOmh0bWw9Imh0 dHA6Ly93d3cudzMub3JnL1RSL1JFQy1odG1sNDAiPgo8V29ya3NoZWV0IHNzOk5hbWU9IlRhYmxl MSI+CjxUYWJsZT4KPENvbHVtbiBzczpJbmRleD0iMSIgc3M6QXV0b0ZpdFdpZHRoPSIwIiBzczpX aWR0aD0iMTEwIi8+CjxSb3c+CjxDZWxsPjxEYXRhIHNzOlR5cGU9IlN0cmluZyI+Um93aWQ8L0Rh dGE+PC9DZWxsPgo8Q2VsbD48RGF0YSBzczpUeXBlPSJTdHJpbmciPkN1c3RvbWVyIEFjY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Ij4yMDA5LTEyLTEwIDE2OjI1OjQyLjA8L0RhdGE+PC9DZWxsPgo8 Q2VsbD48RGF0YSBzczpUeXBlPSJTdHJpbmciPlRFQyBmb3IgUGhvbmVzPC9EYXRhPjwvQ2VsbD4K PENlbGw+PERhdGEgc3M6VHlwZT0iU3RyaW5nIj48L0RhdGE+PC9DZWxsPgo8Q2VsbD48RGF0YSBz czpUeXBlPSJTdHJpbmciPjwvRGF0YT48L0NlbGw+CjxDZWxsPjxEYXRhIHNzOlR5cGU9IlN0cmlu ZyI+Tm9ydGggRWFzdCBFbWFpbCBDYW1wYWlnbjwvRGF0YT48L0NlbGw+CjwvUm93Pgo8L1RhYmxl Pgo8L1dvcmtzaGVldD4KPC9Xb3JrYm9vaz4= --==Multipart_Boundary_x4db218f24afded124fee220fcb9d6110x ------- I have no idea what could be wrong
×
×
  • 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.