Jump to content

tryingtolearn

Members
  • Posts

    293
  • Joined

  • Last visited

  • Days Won

    1

Everything posted by tryingtolearn

  1. Hi Thanks for the response. I am looking at building my own for a few reasons It will work the way I want rather than making something fit I can (Might know) how to customize as I go And last - to learn something new. My question for MYSQL would be how to set up the message storage, Would you just do 1 field for messages and keep updating that field for the responses back and forth or A seperate table for the messages so each individual message is stored and linked to the user through an ID of sorts. I dont expect a large amount of traffic as it is for a specialized site but you never know.
  2. Hi all Im trying to figure out the best approach to setting up a contact system that will: Allow a user (Signed in or not) to fill out a contact form With this type of set up - They select a department fill in a message block Send The technician associated with the department selected will have something along the lines of 1 New message in their admin area The technician responds An email is sent to the original poster saying - there is a response to you question Click here yada yada yada They click the link and go to the response They have the ability to respond - close - etc... The main question is What is the best way to handle the messages back and forth so the trail is displayed from original message to final conclusion including everything in between? Database? - Text file? or other ideas an how to go about doing it... Hope it makes sense - Thanks for any input.
  3. Thanks, I appreciate the advice/help.
  4. Think I got it now Is this what you were talking about? The image code (fontgen.php) <?php header("Content-type: image/png"); $im = imagecreate(600, 40); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagettftext($im, 30, 0, 11, 31, $grey, $font, $text); imagettftext($im, 30, 0, 10, 30, $black, $font, $text); imagepng($im); imagedestroy($im); ?> Used to call the images <?php $path = "./font"; $dir_handle = @opendir($path) or die("Unable to open $path"); while($file = readdir($dir_handle)) { if(substr($file, -4) == '.ttf') { $length = strlen($file); $file2 = substr($file, 0, ($length-4)); echo "$file2<br>"; $font = 'font/'.$file2.'.ttf'; echo "<img src=\"fontgen.php?font=$font&text=ABCDEFG abcdefg 1234567890\"><br><br>"; } } closedir($dir_handle); ?>
  5. When you say create only 1 png you are saying I will only get the 1 font? Or is there a different way to get all of them for a preview???
  6. No luck Well maybe I can explain it better this way If I use <?php $path = "./font"; $dir_handle = @opendir($path) or die("Unable to open $path"); while($file = readdir($dir_handle)) { if(substr($file, -4) == '.ttf') { $length = strlen($file); $file2 = substr($file, 0, ($length-4)); echo "$file2<br>"; } } closedir($dir_handle); ?> I get Thats all of them But If I use <?php $path = "./font"; $dir_handle = @opendir($path) or die("Unable to open $path"); while($file = readdir($dir_handle)) { if(substr($file, -4) == '.ttf') { $length = strlen($file); $file2 = substr($file, 0, ($length-4)); $im = imagecreatetruecolor(400, 30); $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); $text = 'Testing...'; $font = 'font/'.$file2.'.ttf'; imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); imagettftext($im, 20, 0, 10, 20, $black, $font, $text); header("Content-type: image/png"); imagepng($im); imagedestroy($im); } } closedir($dir_handle); ?> I only get an image in Arial font and then it stops running the script - wont even echo anything else after that. Any ideas??
  7. This is what I have that gives me an image of the first file only <?php header("Content-type: image/png"); // read all .ttf file in the font directory if ($fd = opendir('./font')) { $files = array(); while (($file = readdir($fd)) !== false) { if (substr($file, strlen($file) - 4) == '.ttf') { array_push($files, $file); } } closedir($fd); } // Sort the files and display sort($files); foreach ($files as $file) { // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = "font/$file"; // Optional add some shadow to the text imagettftext($im, 20, 0, 11, 21, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); $title = Title($file); echo "$title<br>$file<br>\n"; } // Function to get a readable title from the filename function Title($filename) { $title = substr($filename, 0, strlen($filename) - 4); $title = str_replace('-', ' ', $title); $title = ucwords($title); return $title; } ?> Any ideas?
  8. I am trying to get an image of each font listed in a directory If I try to get the list of fonts in the dir it works fine using this <?php // read all .ttf file in the font directory if ($fd = opendir('./font')) { $files = array(); while (($file = readdir($fd)) !== false) { if (substr($file, strlen($file) - 4) == '.ttf') { array_push($files, $file); } } closedir($fd); } // Sort the files and display sort($files); foreach ($files as $file) { $title = Title($file); echo "$title<br>$file<br>\n"; } // Function to get a readable title from the filename function Title($filename) { $title = substr($filename, 0, strlen($filename) - 4); $title = str_replace('-', ' ', $title); $title = ucwords($title); return $title; } ?> Is it possible to create an image preview using something like this: <?php header("Content-type: image/png"); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $grey = imagecolorallocate($im, 128, 128, 128); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = 'Testing...'; // Replace path by your own font path $font = 'font/$file'; // Optional add some shadow to the text imagettftext($im, 20, 0, 15, 25, $grey, $font, $text); // Add the text imagettftext($im, 20, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() imagepng($im); imagedestroy($im); ?> The problem I was getting was that it only creates an image on the first font file. Any help would be appreciated.
  9. Depends on what method you are using from paypal. If you are just using their cart buttons then you can just have them make the buttons from their acct. If you are using web payments pro its a little more involved.
  10. Thanks, That is how I started originally but it was resizing every pic loaded. I dont understand it. maybe I will just start from scratch with it.
  11. Does this mean there is no way to do it or does anyone have an idea of how to change it up to make it work?
  12. Hi again I have an image upload script that is resizing every image that a user uploads. What I would like to do is have a check box added to the upload form that a user can check to resize the image if they want to or leave it unchecked to just upload the image. So if the box is checked the original image gets uploaded and a resized image is created as well If the box is not checked just the original image uploaded. I tried adding a check box but every image still was resized - checked or not - Im assiming because it was in the foreach loop so I dont know what to do. This is what I have right now FORM CODE <b>File [<?php echo $x; ?>]:</b><br> <input type="file" name="upload[]" size="10"/> PROCESS CODE if (!(isset($_POST['folder']))) { echo"<H1><span style=\"color: #ff1111;\">PROCESS ERROR</span></H1><br>We did not receive your information to process.<br>Please go <a href=\"img_manager.php\">back</a> and input your information again."; exit(); // Quit the script. include ('./includes/footer.html'); } foreach ($_POST['folder'] as $p) { $pa = $p; } $query = "SELECT path FROM img_folder WHERE folder_id=$pa"; $result25 = mysql_query ($query); while ($row = mysql_fetch_array($result25, MYSQL_ASSOC)) { $resultpath = $row['path']; } echo"<p>Return to the <a href=\"img_manager.php\">Image Manager</a> </p><br>"; if (!is_dir("images/$user_id/$resultpath")) { $oldumask = umask(0); mkdir("images/$user_id/$resultpath", 0777); umask($oldumask); } $num = $_POST['num']; //start_process // Check if the form has been submitted. if (isset($_POST['submitted'])) { //echo '<pre>' . print_r ($_FILES, 1) . '</pre>'; echo'<fieldset><legend>Upload Results:</legend> <table border="0" CELLSPACING="0" CELLPADDING="10" width="85%" align="center"> <tr>'; $numcols = 2; // how many columns to display $numcolsprinted = 0; // no of columns so far foreach ($_FILES['upload']['tmp_name'] as $key => $upload) {//begin foreach if ($numcolsprinted == $numcols) { print "</tr>\n<tr>\n"; $numcolsprinted = 0; }echo "<td valign=\"top\">"; $file_num = $key+1; $filedir = 'images/' .$user_id.'/'.$resultpath.'/'; // the directory for the original image $mode = '0777'; $userfile_name = $key.$_FILES['upload']['name'][$key]; $userfile_name = ereg_replace(' ', '_', $userfile_name); $userfile_tmp = $_FILES['upload']['tmp_name'][$key]; $userfile_size = $_FILES['upload']['size'][$key]; $userfile_type = $_FILES['upload']['type'][$key]; $size = 400; // Image View $thumb_prefix = 'th_'; // the prefix to be added to the original name $thumbname = $thumb_prefix.$userfile_name; $thumb_img = $filedir.$thumb_prefix.$userfile_name; $add= $filedir.$userfile_name; //Check for an uploaded file. if (isset($_FILES['upload']['name'][$key]) && ($_FILES['upload']['error'][$key] != 4)){ //if there is a file validate it $allowed = array ('image/png', 'image/x-png', 'image/gif', 'image/jpeg', 'image/jpg', 'image/pjpeg'); if (in_array($_FILES['upload']['type'][$key], $allowed)) { $orig_img = $filedir.$userfile_name; if (move_uploaded_file($_FILES['upload']['tmp_name'][$key], $orig_img)) { chmod ($orig_img, octdec($mode)); if ($userfile_type == "image/pjpeg" OR $userfile_type == "image/jpeg" OR $userfile_type == "image/jpg"){ chmod ($add, octdec($mode)); $sizes = getimagesize($add); $aspect_ratio = $sizes[1]/$sizes[0]; if ($sizes[0] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_width = $size; $new_height = ($aspect_ratio*$size); } $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromJPEG($add) or die('Problem In opening Source Image'); imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImageJPEG($destimg,$thumb_img,75) or die('Problem In saving'); imagedestroy($destimg); } if ($userfile_type == "image/gif"){ chmod ($add, octdec($mode)); $sizes = getimagesize($add); $aspect_ratio = $sizes[1]/$sizes[0]; //start resize image if ($sizes[0] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_width = $size; $new_height = ($aspect_ratio*$size); } // $destimg=ImageCreate($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromGIF($add) or die('Problem In opening Source Image'); $colourBlack = imagecolorallocate($destimg, 0, 0, 0); imagecolortransparent($destimg, $colourBlack); imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImageGIF($destimg,$thumb_img) or die('Problem In saving'); imagedestroy($destimg); } if ($userfile_type =="image/png" OR $userfile_type =="image/x-png"){ chmod ($add, octdec($mode)); $sizes = getimagesize($add); $aspect_ratio = $sizes[1]/$sizes[0]; //start resize image if ($sizes[0] <= $size) { $new_width = $sizes[0]; $new_height = $sizes[1]; }else{ $new_width = $size; $new_height = ($aspect_ratio*$size); } //copied $destimg=ImageCreateTrueColor($new_width,$new_height) or die('Problem In Creating image'); $srcimg=ImageCreateFromPNG($add) or die('Problem In opening Source Image'); $colourBlack = imagecolorallocate($destimg, 0, 0, 0); imagecolortransparent($destimg, $colourBlack); imagecopyresampled($destimg,$srcimg,0,0,0,0,$new_width,$new_height,ImageSX($srcimg),ImageSY($srcimg)) or die('Problem In resizing'); ImagePNG($destimg,$thumb_img) or die('Problem In saving'); imagedestroy($destimg); } if (!empty($userfile_name)) { $userfile_name = ereg_replace(' ', '_', $userfile_name); $i = escape_data($userfile_name); $i = escape_data($userfile_name); // Check for terms. if (!empty($userfile_size)) { $s = escape_data($userfile_size); // Make the query. $query = "INSERT INTO img (user_id, img_name, img_size) VALUES ('$user_id', '$i', '$s')"; $result = mysql_query ($query) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); //make assoc $uid = mysql_insert_id(); // Get the url ID. if ($uid > 0) { // New article has been added. $query = 'INSERT INTO img_assoc (id, folder_id, user_id) VALUES '; foreach ($_POST['folder'] as $v) { $query .= "($uid, $v, $user_id), "; } $query = substr ($query, 0, -2); // Chop off the last comma and space. $result = mysql_query ($query); // Run the query. } $t = escape_data($thumbname); $ts = filesize($thumb_img); $query2 = "INSERT INTO img (user_id, img_name, img_size) VALUES ('$user_id', '$t', '$ts')"; $result2 = mysql_query ($query2) or trigger_error("Query: $query\n<br />MySQL Error: " . mysql_error()); $uid2 = mysql_insert_id(); // Get the url ID. if ($uid2 > 0) { // New article has been added. $query3 = 'INSERT INTO img_assoc (id, folder_id, user_id) VALUES '; foreach ($_POST['folder'] as $v) { $query3 .= "($uid2, $v, $user_id), "; } $query3 = substr ($query3, 0, -2); // Chop off the last comma and space. $result3 = mysql_query ($query3); // Run the query. } if (mysql_affected_rows() == 4) mysql_close(); // Close the database connection. } } echo '<span class="ulpass">SUCCESS</span><br>File ['.$file_num.']:<br><span class="ulinfo">Was uploaded!</span><br><a href="'.$filedir.''.$userfile_name.'" target="_blank"><img src="sized.php?image='.$filedir.''.$userfile_name.'&width=100&height=150" border="0"></a>'; } else { // Couldn't move the file over. echo '<span class="error">Upload failed</span><br>File ['.$file_num.'] <br /><span class="ulinfocause">We are experiencing technical difficulties. Please try again later.</span>'; } // End of move... IF. //if its not allowed }else{ echo '<span class="error">Upload failed</span><br> File ['.$file_num.']<br> <span class="ulinfocause">was not uploaded because:<br />'; // Print a message based upon the error. switch ($_FILES['upload']['error'][$key]) { case 1: print 'It exceeded the servers max file size.'; break; continue $key; case 2: print 'It exceeded the acceptable file size.<br />Please edit your original file size and try again.'; break; continue $key; case 3: print 'It was only partially uploaded.<br />Please try again.'; break; continue $key; case 4: print 'It was an empty field on the upload form.'; break; continue $key; case 6: print 'It could not be loaded to a folder.'; break; continue $key; case ($allowed = FALSE): print 'It was the wrong file type.<br />Please try again with an acceptable file type located on the upload page.'; unlink ($_FILES['upload']['tmp_name'][$key]); // Delete the file. break; continue $key; default: print 'This feature is currently unavailable<br />Please check back soon.'; break; } // End of switch. print '</span>'; }//endof not valid echo //end validation } //no uploaded file else{ echo'Form input # ['.$file_num.']<br><span class="ulinfocause"> did not contain any data to upload.<br />If you meant to add a file there you will need to upload it again.</span>'; } //start table code bottom echo"</td>\n"; $numcolsprinted++; }//end foreach // bump up row counter $colstobalance = $numcols - $numcolsprinted; for ($i=1; $i<=$colstobalance; $i++) { print "<TD> </TD>\n"; } //stop table code bottom echo'</tr> </table> </fieldset> '; } // End of the submitted conditional. else{ $selnum .= 'photogal.php'; header("Location: $selnum"); exit(); // Quit the script. } //stop_process Any ideas/ help appreciated. Thanks
  13. rockinaway, I just went through the same confusion yesterday. (Im still confused but until I do it over and over - well....) This link http://www.phpfreaks.com/tutorials/52/0.php posted in the resources sticky helped me alot (Along with effigy many thanks). I read the first page over and over it it breaks it down pretty easy to understand. The best line is on the first page that says I blew right over it the first time through because I didnt understand. But once I read what each symbol meant then it became a little less cloudy. I would start on page 1 Read it over and over learning the meanings of each symbol and then do like the quote says. Then write some things out that you would want to do and come up with the expression to go along with it. I found this to test and it helped alot also http://regexlib.com/RETester.aspx Just an idea, but that seemed to work for me. Like I said, Im still a little confused but not as much. Good luck.
  14. Worked Perfect! THanks I appreciate your time (and the links)
  15. Thanks effigy, I will look at in depth when I get back this evening. I spent a loooong time at those links last night. They are helpful it just takes me a really long time to get this straight. Wow - Thanks for your time.
  16. Well I dont know how but I tried this and it works but there are two issues 1. It seems like a crude way of doing it (Compared to what effigy was saying with the callback) 2. It only seems to work with an image tag I had to replace the <img to get the contents back - an imag in this example. $search2 = array ("'<!-- STARTMARK -->[<]([a-zA-Z]|[0-9])*'"); $replace2 = array ("IfR!-- STARTMARK --IfR XXX "); $strip2 = preg_replace ($search2, $replace2, $strip); $newcode = strip_tags($strip2, '<p>,<br>,<H1>'); $search3 = array ("'IfR!-- STARTMAK --IfR'","'XXX'"); $replace3 = array ("<!-- STARTMARK -->","<img"); $strip3 = preg_replace ($search3, $replace3, $newcode); This is very confusing.
  17. OK I can try that but I cant capture the text inbetween the tags? I guess thats where the confusion begins!
  18. Hello, I started this post over on the help board before I realized this board was even here. I hope someone can help with this or even let me know if its possible. I am totally confused over this preg_replace Basically I am not sure what function I should be using to accomplish something. What I need to do is convert everything between multiple html comment tags so they do not get stripped when using strip tags.( might not be an img tag in there either - so what ever is between the two comment tags I need in a format that wont get touched by the strip_tags) So if I start with this Bunch of html code <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <img src="graphics/pic2.gif" width="40" height="40" alt="mypic2" border="0"> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of html code It will change to something like this Bunch of html code <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <img src="graphics/pic2.gif" width="40" height="40" alt="mypic2" border="0"> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of html code So I can run it through strip tags and end up with this back on the html page. Bunch of text <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of text There can be any # of the STARTMARK and ENDMARK tags from 0-100 it will just depend on the page. I have everything but converting only those marked sections Can this be done? Im this far but am lost when it comes to replacing everything in the middle of the tags. $search = array ("'<!-- STARTMARK --[^>]*?>.*?<!-- ENDMARK -->'si"); $replace = array ("<!-- STARTMARK -->.*<!-- ENDMARK -->"); $new = preg_replace ($search, $replace, $source); Any ideas???
  19. Im this far but am lost when it comes to replacing everything in the middle of the tags. $search = array ("'<!-- STARTMARK --[^>]*?>.*?<!-- ENDMARK -->'si"); $replace = array ("<!-- STARTMARK -->.*<!-- ENDMARK -->"); $new = preg_replace ($search, $replace, $source); Is this at least in the ballpark??
  20. Hi again all, I am totally confused over this preg_replace Basically I am not sure what function I should be using to accomplish something. What I need to do is convert everything between multiple html comment tags so they do not get stripped when using strip tags. So if I start with this Bunch of html code <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <img src="graphics/pic2.gif" width="40" height="40" alt="mypic2" border="0"> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of html code It will change to something like this Bunch of html code <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <img src="graphics/pic2.gif" width="40" height="40" alt="mypic2" border="0"> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of html code So I can run it through strip tags and end up with this Bunch of text <!-- STARTMARK --><img src="graphics/pic1.gif" width="40" height="40" alt="mypic1" border="0"><!-- ENDMARK --> <!-- STARTMARK --><img src="graphics/pic3.gif" width="40" height="40" alt="mypic3" border="0"><!-- ENDMARK --> Bunch of text There can be any # of the STARTMARK and ENDMARK tags from 0-100 it will just depend on the page. I have everything but converting only those marked sections Can this be done?
  21. Thanks for the detailed explanations That really does help me understand it alot better. I must have had something set a little different - I am going to go back through and check it out to find why it didnt work. Thanks again - I do appreciate your time.
  22. Yes, that is how I thought it would work - But, what happens is that if you do not have the largest value as the last # it didnt return the largest value. I guess that in the many tests I did where it did work out I just happened to have the largest # last. Using max() works each time. Thanks again.
  23. Hi and thanks again mjdamato I see that in kenrbnsn's method with using max I guess what Im asking is in the other method - $maxHeight = 0; foreach($array as $key => $add){ if($add == "Yes") { $image_height = round($_SESSION['imgheight'.$key]); if ($image_height>$maxHeight) { $maxHeight = $image_height;} } } if the image heights are 23, 145, 78, 416, 43 What sets img_height to 416 in this case since they are all greater than maxHeight Just trying to understand - THanks
  24. Wow - Thats fantastic and confusing. All the methods work - and I apologize Balmung-San You posted the same method as mjdamato did I wasnt doing something right. With that method - if all the values are greater than 0 what causes the highest # to display? Sorry for being so dense on this, I have tried so many different things I guess Im just not seeing it. Thanks again for all the great help and ideas!
×
×
  • 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.