Jump to content

ttmt

Members
  • Posts

    67
  • Joined

  • Last visited

Everything posted by ttmt

  1. Hi all I have simple page here to illustrate my question. http://www.ttmt.org.uk/forum/discount/ It's a function that calculates a percentage of a given number. My problem is if the percentage calculated ends with a zero it isn't displayed as in the second number on the example page. I would like the second example to display £5.50 <!DOCTYPE html> <html> <meta charset="UTF-8"> <title>Title of the document</title> <style type="text/css"> *{margin:0;padding:0;} #wrap{margin:50px;} h3{display:block;font:1.2em Helvetica, sans-serif;color:#555;margin:0 0 15px 0;} .deletePrice{margin:0 20px 0 0;text-decoration:line-through} .discountRed{color:red;} </style> </head> <body> <div id="wrap"> <?php function item($price, $discount){ if($discount > 0){ $normPrice = $price; $normPriceDelete = "<span class='deletePrice discountRed'>£$normPrice</span>"; $price = ($discount/100)*$normPrice; $discountPrice = "<span class='price'>£$price</span>"; global $priceBlock; $priceBlock = "<span class='price deletePrice'>£$normPrice</span><span class='price discountRed'>£$price</span>"; echo "<h3>".$priceBlock."</h3>"; }else{ global $priceBlock; $priceBlock = "<span class='price'>£$price</span>"; echo "<h3>".$priceBlock."</h3>"; } } item(22,26); item(22,25); ?> </div> </body> </html>
  2. Timthumb thumbnails in Wordpress Hi all I'm having real problems here so any help would be really appreciated. I'm using the jQuery cycle menu here to create a slideshow and thumbnails. http://www.ttmt.org.uk/forum/wordpress/ I want to create the same thing in Wordpress http://www.ttmt.org.uk/wordpress/ The slideshow works but thumbnails don't show. I think part of the problem is creating the thumbnails in Wordpress so I'm using timthumb to create the thumbnails - http://www.binarymoon.co.uk/projects/timthumb/ I have downloaded timthumb and named the file thumb.php then put it in the folder thumb I'm using this to try and create the thumbnails from timthumb. <script type="text/javascript"> $(window).load(function() { $('#slideshow').cycle({ fx: 'fade', speed: 800, timeout: 3000, pause: 1, next: '#next', prev: '#prev', pager: '#thumbs', pagerAnchorBuilder: function(idx, slide) { return '<li><a href="#"><img src="<?php bloginfo('template_directory'); ?>thumb/thumb.php?src="' + slide.src + '"&h=50&w=50&zc=1" /></a></li>'; } }); </script> Can anyone see why this isn't working? Will this ever work? Should I stop trying?
  3. Wordpress - List child pages and parent page? Hi all This is the 3rd day on this now, it's driving me mad. I'm trying to create a Wordpress photo gallery theme, I want a gallery with sub sections. http://www.ttmt.org.uk/wordpress/ In the demo I have 'Transport' with the sub sections Boats and Cars. I have 3 pages - Transport, Boats and Cars. Boast and Cars are child pages of Transport. Each page has a NextGen Gallery as it's content. When you click Transport the gallery loads and the child pages are shown in a list above. The child pages are added with this: <?php if($post->post_parent){ $children = wp_list_pages("title_li=&include=".$post->post_parent."&echo=0"); $children .= wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0"); } else { $children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0"); } if ($children) { echo '<ul class="submenu">'; echo $children; echo '</ul>'; } ?> How can I add the actual page 'Transport' to this list? If you click on Boats or Cars 'Transport' is added to the list, this because it is then a parent. How can I have a sub menu of Transport, Boats, Cars when 'Transport' is clicked? ANY help with this would be greatly appreciated.
  4. GD Library Pattern Background ? Hi all I have a simple page here that uses the GD Library to display text in a selected font and size etc. http://www.ttmt.org.uk/forum/ At moment the stripped background goes from the code. Is there a way to have an image as the background instead of the stripped background. PHP code <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(900, 215); $w = imagecolorallocate($im, 255, 255, 255); $c = imagecolorallocate($im, 220, 220, 220); $black = imagecolorallocatealpha($im, 0, 0, 0, 20); $style = array($w,$w,$w,$c,$c,$c); ImageSetStyle($im, $style); ImageLine($image, 100, 0, 50, 50, IMG_COLOR_STYLED); imagefilledrectangle($im, 0, 0, 900, 214, IMG_COLOR_STYLED); $text = $_GET['text']; $textSize = $_GET['size']; $font = $_GET['font']; imagefttext($im, $textSize, 0, 15, 165, $black, $font, $text); imagepng($im); imagedestroy($im); ?>
  5. If I created the link to the fonts folder <?php $fontsPath = "/fonts"; ?> Could then use it in the jquery font = fontsPath + fontVal; // dataString = 'text=' + text + '&size=' + size + '&font=' + font; // $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="robots" content="noindex, nofollow" /> <title></title> <style type="text/css" media="screen"> *{margin:0;padding:0;} #content{margin:20px;} form{margin:0 0 20px 0;} #inputText{width:300px;} #selectText,#inputText{width:200px;} </style> </head> <body> <?php $fontsPath = "/fonts"; ?> <div id="content"> <form method="" action="" id="testerForm"> <select name="text" id="selectText" class="input"> <option value="">Text</option> <option value="0123456789">0123456789</option> <option value="The quick brown fox jumps over the lazy dog">The quick brown fox jumps over the lazy dog</option> <option value="Fjord Nymphs XV beg quick waltz">Fjord Nymphs XV beg quick waltz</option> </select> <select name="size" id="selectWeight" class="input"> <option value="">Weight</option> <option value="CORBEL.TTF">Regular</option> <option value="CORBELI.TTF">Italic</option> <option value="CORBELB.TTF">Bold</option> <option value="CORBELZ.TTF">Bold Italic</option> </select> <select name="size" id="selectSize" class="input"> <option value="">Size</option> <option value="40">40</option> <option value="60">60</option> <option value="84">84</option> <option value="108">108</option> </select> </form> <div class="fontTester"> </div> </div><!-- #content --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> var fontfile = "fonts/corbel/" window.theText = "Test Text"; window.theSize = 50; window.theFont = fontsPath+"CORBELB.TTF"; text = window.theText; size = window.theSize; font = window.theFont; dataString = 'text=' + text + '&size=' + size + '&font=' + font; $(".fontTester").find("img").remove(); $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); $(".fontTesterImg").hide().fadeIn(800); $('.input').change(function(){ if($('#selectText').val() != ''){ text = $('#selectText').val(); }else{ text = window.theText; } if($('#selectSize').val() != ''){ size = $('#selectSize').val(); }else{ size = window.theSize; } if($('#selectWeight').val() != ''){ var fontVal = $('#selectWeight').val(); font = fontsPath + fontVal; }else{ font = window.theFont; } dataString = 'text=' + text + '&size=' + size + '&font=' + font; $(".fontTester").find("img").remove(); $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); $(".fontTesterImg").hide().fadeIn(800); }) </script> </body> </html>
  6. Thanks for replying kicken I realise I can access the file outside the public_html with PHP but can I use that with my code where I am using jQuery to call the sample.php. dataString = 'text=' + text + '&size=' + size + '&font=' + font; $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); Can I use the PHP variable in the jQuery code. Sorry if I being really stupid here but I've been trying to working this out for days now and I'm going round in circles.
  7. Access files outside public_html folder ? Hi all I have this demo here to explain the problem I have http://www.ttmt.org.uk/ This a app to test font by selecting the text, weight and size. The image is created by capturing the values with jQuery and passing them to a PHP script that uses the GD Library. At the moment the fonts are contained in a folder in the public_html folder. My problem is the fonts in the this location could be downloaded by anyone simple by viewing the html and - THE FONTS HAVE TO BE SAFE AND CAN'T BE DOWNLOADABLE. I was thinking I could have the fonts outside the public_html folder so no one could download them but I can't get this to work. Is there anyway I could contain the fonts outside the public_html folder and still use them? Is there any other way I can have the fonts files not downloadable but this useable by the script? I wouldn't mind having the fonts inside the public_html folder in a folder with a long or usual name so it can't be guessed. If I did this is there a way to hide or conceal the name of the folder in the code? Any help would be greatly appreciated. t. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <meta name="robots" content="noindex, nofollow" /> <title></title> <style type="text/css" media="screen"> *{margin:0;padding:0;} #content{margin:20px;} form{margin:0 0 20px 0;} #inputText{width:300px;} #selectText,#inputText{width:200px;} </style> </head> <body> <div id="content"> <form method="" action="" id="testerForm"> <select name="text" id="selectText" class="input"> <option value="">Text</option> <option value="0123456789">0123456789</option> <option value="The quick brown fox jumps over the lazy dog">The quick brown fox jumps over the lazy dog</option> <option value="Fjord Nymphs XV beg quick waltz">Fjord Nymphs XV beg quick waltz</option> </select> <select name="size" id="selectWeight" class="input"> <option value="">Weight</option> <option value="CORBEL.TTF">Regular</option> <option value="CORBELI.TTF">Italic</option> <option value="CORBELB.TTF">Bold</option> <option value="CORBELZ.TTF">Bold Italic</option> </select> <select name="size" id="selectSize" class="input"> <option value="">Size</option> <option value="40">40</option> <option value="60">60</option> <option value="84">84</option> <option value="108">108</option> </select> </form> <div class="fontTester"> </div> </div><!-- #content --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script> <script type="text/javascript" charset="utf-8"> var fontfile = "fonts/corbel/" window.theText = "Test Text"; window.theSize = 50; window.theFont = fontfile+"CORBELB.TTF"; text = window.theText; size = window.theSize; font = window.theFont; dataString = 'text=' + text + '&size=' + size + '&font=' + font; $(".fontTester").find("img").remove(); $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); $(".fontTesterImg").hide().fadeIn(800); $('.input').change(function(){ if($('#selectText').val() != ''){ text = $('#selectText').val(); }else{ text = window.theText; } if($('#selectSize').val() != ''){ size = $('#selectSize').val(); }else{ size = window.theSize; } if($('#selectWeight').val() != ''){ var fontVal = $('#selectWeight').val(); font = fontfile + fontVal; }else{ font = window.theFont; } dataString = 'text=' + text + '&size=' + size + '&font=' + font; $(".fontTester").find("img").remove(); $(".fontTester").html("<img src='sample.php?" + dataString + "' class='fontTesterImg' />"); $(".fontTesterImg").hide().fadeIn(800); }) </script> </body> </html>
  8. Paypal dropdrop menu / Add to Cart Hi all I'm working on linking a type foundry website to paypal so the fonts can be purchased online. The price of the fonts is determined by the number of devices the fonts will be installed on. I have created this page to add the fonts to a cart with a drop menu on each weight to determine the price. http://www.ttmt.org.uk/forum-paypal/1/ Each drop down is created with a function called from the html. <?php item("Basic Family", "Family", "Bas-Fa", "130"); item("Basic Light", "Light", "Bas-Lt", "20"); item("Basic Regular", "Regular", "Bas-Rg", "20"); item("Basic Medium", "Medium", "Bas-Md", "20"); item("Basic Bold", "Bold", "Bas-Bd", "20"); item("Basic Light Italic", "Light Italic", "Bas-LtIt", "20"); item("Basic Italic", "Italic", "Bas-It", "20"); item("Basic Medium Italic", "Medium Italic", "Bas-MdIt", "20"); item("Basic Bold Italic", "Bold Italic", "Bas-BdIt", "20"); ?> <?php function item( $name, $weight, $number, $price){ $to5 = $price; $to25 = ($price*200)/100; $to50 = ($price*300)/100; $to75 = ($price*400)/100; $to100 = ($price*500)/100; $to150 = ($price*600)/100; $to250 = ($price*700)/100; $to400 = ($price*900)/100; $to500 = ($price*1000)/100; $to600 = ($price*1250)/100; $to700 = ($price*1500)/100; $to850 = ($price*1750)/100; $to1000 = ($price*2000)/100; // $img = "../images/".$image; echo " <div class='product'> <div class='productInfo'> <h3>".$weight."<span> - from £".$price."</span></h3> <form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'> <input type='hidden' name='cmd' value='_cart'> <input type='hidden' name='business' value='sales@moretype.co.uk'> <input type='hidden' name='lc' value='GB'> <input type='hidden' name='item_name' value='".$name."'> <input type='hidden' name='item_number' value='".$number."'> <input type='hidden' name='button_subtype' value='products'> <input type='hidden' name='no_note' value='0'> <input type='hidden' name='cn' value='Add special instructions to the seller'> <input type='hidden' name='no_shipping' value='2'> <input type='hidden' name='add' value='1'> <input type='hidden' name='bn' value='PP-ShopCartBF:btn_cart_LG.gif:NonHosted'> <table> <tr><td><input type='hidden' name='on0' value='Number of Users' id='numberOfUsers'></td></tr><tr><td><select name='os0' class='numUserSelect'> <option value='Up to 5'>Number of Users</option> <option value='Up to 5'>Up to 5 - £".$to5."</option> <option value='Up to 25'>Up to 25 - £".$to25."</option> <option value='Up to 50'>Up to 50 - £".$to50."</option> <option value='Up to 75'>Up to 75 - £".$to75."</option> <option value='Up to 100'>Up to 100 - £".$to100."</option> <option value='Up to 150'>Up to 150 - £".$to150."</option> <option value='Up to 250'>Up to 250 - £".$to250."</option> <option value='Up to 400'>Up to 400 - £".$to400."</option> <option value='Up to 500'>Up to 500 - £".$to500."</option> <option value='Up to 600'>Up to 600 - £".$to600."</option> <option value='Up to 700'>Up to 700 - £".$to700."</option> <option value='Up to 850'>Up to 850 - £".$to850."</option> <option value='Up to 1000'>Up to 1000 - £".$to1000."</option> </select> </td></tr> </table> <input type='hidden' name='currency_code' value='GBP'> <input type='hidden' name='option_select0' value='Up to 5'> <input type='hidden' name='option_amount0' value='".$to5."'> <input type='hidden' name='option_select1' value='Up to 5'> <input type='hidden' name='option_amount1' value='".$to5."'> <input type='hidden' name='option_select2' value='Up to 25'> <input type='hidden' name='option_amount2' value='".$to25."'> <input type='hidden' name='option_select3' value='Up to 50'> <input type='hidden' name='option_amount3' value='".$to50."'> <input type='hidden' name='option_select4' value='Up to 75'> <input type='hidden' name='option_amount4' value='".$to75."'> <input type='hidden' name='option_select5' value='Up to 100'> <input type='hidden' name='option_amount5' value='".$to100."'> <input type='hidden' name='option_select6' value='Up to 150'> <input type='hidden' name='option_amount6' value='".$to150."'> <input type='hidden' name='option_select7' value='Up to 250'> <input type='hidden' name='option_amount7' value='".$to250."'> <input type='hidden' name='option_select8' value='Up to 400'> <input type='hidden' name='option_amount8' value='".$to400."'> <input type='hidden' name='option_select9' value='Up to 500'> <input type='hidden' name='option_amount9' value='".$to500."'> <input type='hidden' name='option_select10' value='Up to 600'> <input type='hidden' name='option_amount10' value='".$to600."'> <input type='hidden' name='option_select11' value='Up to 700'> <input type='hidden' name='option_amount11' value='".$to700."'> <input type='hidden' name='option_select12' value='Up to 850'> <input type='hidden' name='option_amount12' value='".$to850."'> <input type='hidden' name='option_select13' value='Up to 1000'> <input type='hidden' name='option_amount13' value='".$to1000."'> <input type='hidden' name='option_index' value='0'> <input class='button' type='image' src='addToCart.png' border='0' name='submit' alt='PayPal — The safer, easier way to pay online.'> <img alt='' border='0' src='https://www.paypalobjects.com/en_GB/i/scr/pixel.gif' width='1' height='1'> </form> </div><!-- #productInfo --> </div>"; } ?> Instead of having a drop down menu I would like to have an input text box to enter the number of devices. http://www.ttmt.org.uk/forum-paypal/2/ My problem is how can I capture the figure in the input textbox and then use if statements to add the value to the cart. Hope this makes sense and someone can help. Any help would be greatly appreciated.
  9. Thanks for the replies I'll go with JKG's suggestion, that works best for me.
  10. Selected navigation on include file. Hi all I can't think how to do this or even if it's possible so I'm hoping someone can help. I have a simple example here to illustrate. http://www.ttmt.org.uk/three.php It's just four linked pages with a heading and a navigation. The navigation has an id="selected" in the <a> tag for that page that changes the color of that link to show you are on that page - very basic. I wanted the put the navigation on the pages with an include file. <?php include("php/includes/nav.php"); ?> and have the code for the nav in nav.php nav.php <ul id="nav"> <li><a href="index.php">Home</a></li> <li><a href="one.php">One</a></li> <li><a href="two.php">Two</a></li> <li><a href="three.php">Three</a></li> </ul> My problem is how can I add the id="selected" to the different links for the different pages if I'm including the navigation code? Hope this makes sense and someone can help. Any help would be greatly appreciated.
  11. jQuery, Ajax, PHP Function Hi all Hope this is the right place to post this and someone can help. I have a simple app that uses the PHP GD library to display text in a set font at a set size. http://www.ttmt.org.uk/ When it's working you can select the text and size and press set and it will be displayed in the grey box. When doing this WITHOUT Ajax I simply used this php to echo the img tag with the php function as the src. echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; imageftt.php - PHP, This is the GD library function that creates the image. <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1000, 200); $gray = imagecolorallocate($im, 240, 240, 240); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 1000, 199, $gray); $theText = $_POST['text']; $theSize = $_POST['size']; $theFont = $_POST['font']; imagefttext($im, $theSize, 0, 15, 160, $black, $theFont, $theText); imagepng($im); imagedestroy($im); ?> = My problem is I want to do this using jQuery and Ajax so the page doesn't have to reload. I have this jQuery that collects the values from the form <script type="text/javascript" > $(function(){ $('.button').click(function(){ var text = $('#text').val(); var size = $('#size').val(); var font = $('corbelb.ttf'); //alert(text); //alert(size); // var dataString = 'text=' + text + 'size=' + size + 'font=' + font; $.ajax({ type: 'POST', url: 'imageftt.php', data: dataString, success: function(){ alert() } }); return false; }); }); </script> My Problem is I can't see how to use my php function with the jQuery function. Hope this makes sense - Any help would be greatly appreciated. HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <link rel="stylesheet" href="style.css" type="text/css" /> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js" type="text/javascript"></script> <script src="../js/jquery.easing.1.3.js" type="text/javascript"></script> <script type="text/javascript" > $(function(){ $('.button').click(function(){ var text = $('#text').val(); var size = $('#size').val(); var font = $('corbelb.ttf'); //alert(text); //alert(size); // var dataString = 'text=' + text + 'size=' + size + 'font=' + font; $.ajax({ type: 'POST', url: 'imageftt.php', data: dataString, success: function(){ alert() } }); return false; }); }); </script> </head> <body> <div id="wrap"> <form action="" method=""> <select name="text" id="text"> <option value="<?php echo $_POST['text'];?>">Text</option> <option value="ABCDEFGHJIKLMNOPQRSTUVWXYZ">ABCDEFGHIJKLMNOPQRSTUVWXYZ</option> <option value="abcdefghijklmnopqrstuvwxyz">abcdefghijklmnopqrstuvwxyz</option> <option value="0123456789">0123456789</option> </select> <select name="size" id="size"> <option value="<?php echo $_POST['size'];?>">Size</option> <option value="72">72</option> <option value="84">84</option> <option value="96">96</option> <option value="108">108</option> </select> <input type="submit" name="submit" class="button" value="Set →" /> </form> <div id="top"> <?php $theFont="corbelb.ttf"; if(!empty($_POST['submit'])){ $myText = $_POST['text']; $mySize = $_POST['size']; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; } ?> </div> </div> </body> </html>
  12. How to input a large block of html code with passed variables? Hi all I have a large block of html code that is part of the paypal add to cart button. I need to add this code a number of times with different variables for each one. I want to have this block of html in a separate function that I can then call and pass in the variables in. PHP <?php function item($name, $number){ echo " <div class='product'> <h2>Product Name</h2> <form target='paypal' action='https://www.paypal.com/cgi-bin/webscr' method='post'> <input type='hidden' name='cmd' value='_cart''> <input type='hidden' name='business' value='emailAddress'> <input type='hidden' name='lc' value='GB'> <input type='hidden' name='item_name' value='".$name."'> <input type='hidden' name='item_number' value='".$number."'> <input type='hidden' name='button_subtype' value='products'> <input type='hidden' name='no_note' value='0'> <input type='hidden' name='cn' value='Add special instructions to the seller'> <input type='hidden' name='no_shipping' value='2'> <input type='hidden' name='add' value='1'> <input type='hidden' name='bn' value='PP-ShopCartBF:btn_cart_LG.gif:NonHosted'> <table> <tr><td><input type='hidden' name='on0' value='Number of Users'>Number of Users</td></tr><tr><td><select name='os0'> <option value='1 - 5'>1 - 5 £0.01</option> <option value='6 - 10'>6 - 10 £0.02</option> <option value='11 - 20'>11 - 20 £0.03</option> <option value='21 - 50'>21 - 50 £0.04</option> <option value='51 - 100'>51 - 100 £0.05</option> <option value='100+'>100+ £0.06</option> </select> </td></tr> </table> <input type='hidden' name='currency_code' value='GBP'> <input type='hidden' name='option_select0' value='1 - 5'> <input type='hidden' name='option_amount0' value='0.01'> <input type='hidden' name='option_select1' value='6 - 10'> <input type='hidden' name='option_amount1' value='0.02'> <input type='hidden' name='option_select2' value='11 - 20'> <input type='hidden' name='option_amount2' value='0.03'> <input type='hidden' name='option_select3' value='21 - 50'> <input type='hidden' name='option_amount3' value='0.04'> <input type='hidden' name='option_select4' value='51 - 100'> <input type='hidden' name='option_amount4' value='0.05'> <input type='hidden' name='option_select5' value='100+'> <input type='hidden' name='option_amount5' value='0.06'> <input type='hidden' name='option_index' value='0'> <input class='button' type='image' src='https://www.paypalobjects.com/en_GB/i/btn/btn_cart_LG.gif' border='0' name='submit' alt='PayPal — The safer, easier way to pay online.'> <img alt='' border='0' src='https://www.paypalobjects.com/en_GB/i/scr/pixel.gif' width='1' height='1'> </form> </div> } " ?> HTML <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <?php require_once("functions.php"); ?> </head> <body> <?php item($car, $deo); ?> </body> </html> How can I output this html code from a function with passed in variables ?
  13. imagefilledrectagle - pattered background ? Hi All Is it possible to have a pattern as the background of image created with imagefilledrectangle. This creates a solid tray block but I want a block with a simple pattered fill. <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1020, 215); $gray = imagecolorallocate($im, 220, 220, 220); imagefilledrectangle($im, 0, 0, 1020, 214, $gray); imagepng($im); imagedestroy($im); ?>
  14. That's sounds like it would work - how would I address the fonts outside the my web root. What would the path be.
  15. Hide PHP variables in the html? Hi all I've started working again on this type testing thing http://www.ttmt.org.uk/forum/index.php The text, size and font to use are past to a php function that uses the GD library to create the image using the font at the set size. My problem is from the source code of the page I can see the location of the fonts which I can't have - I don't want people to be able to download the fonts. <img src="imageftt.php?text=Handgloves&size=24&font=/fonts/corbelb.ttf"> </div> How can I hide the variables in the html code or hide the location of the fonts. Any help would be greatly appreciated. html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <link rel="stylesheet" href="style.css" type="text/css" /> </head> <body> <div id="wrap"> <form action="index.php" method="post"> <select name="text" > <option value="<?php echo $_POST['text'];?>">Text</option> <option value="ABCDEFGHJIKLMNOPQRSTUVWXYZ">ABCDEFGHIJKLMNOPQRSTUVWXYZ</option> <option value="abcdefghijklmnopqrstuvwxyz">abcdefghijklmnopqrstuvwxyz</option> </select> <select name="size"> <option value="<?php echo $_POST['size'];?>">Size</option> <option value="31">30</option> <option value="48">48</option> <option value="72">72</option> <option value="84">84</option> <option value="108">108</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <div id="top"> <?php $theFont="/fonts/corbelb.ttf"; if(!empty($_POST['submit'])){ $myText = $_POST['text']; $mySize = $_POST['size']; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; }else{ $myText = "Handgloves"; $mySize = 24; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; } ?> </div> </div> </body> </html> PHP <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1000, 200); $gray = imagecolorallocate($im, 240, 240, 240); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 1000, 199, $gray); $text = $_GET['text']; $textSize = $_GET['size']; $font = $_GET['font']; imagefttext($im, $textSize, 0, 15, 160, $black, $font, $text); imagepng($im); imagedestroy($im); ?>
  16. Hi all I have this simple gd code to produce a filled rectangle with a solid color. <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1000, 200); $gray = imagecolorallocate($im, 240, 240, 240); imagefilledrectangle($im, 0, 0, 1000, 199, $gray); imagepng($im); imagedestroy($im); ?> Is it possible to create a rectangle with a pattern such as a lined background.
  17. Font size GD Library Hi All I'm trying to create a font tester - http://www.ttmt.org.uk/fonts/index.php (this demo doesn't use the font I'm using.). I'm using the GD library to create images of the text. I'm not happy with the quality of the fonts at small sizes. I've tried everything to fix it but nothing is working. One suggestion I had was to create the fonts larger then reduce the size of the image. Can anyone offer any advise how I might do this? <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(1000, 200); $gray = imagecolorallocate($im, 240, 240, 240); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 1000, 199, $gray); $text = $_GET['text']; $textSize = $_GET['size']; $font = $_GET['font']; imagefttext($im, $textSize, 0, 15, 160, $black, $font, $text); imagepng($im); imagedestroy($im); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <style type="text/css"> *{margin:0;padding:0;} #wrap{margin:20px 0 0 20px;} h1{margin:0px 0 20px 0;clear:both;} h2{font-size:1.1em;margin:15px 0 5px 0;} #top{padding:0 0 20px 0;} form{margin:0 0 20px 0;} </style> </head> <body> <div id="wrap"> <form action="index.php" method="post"> <!--<input type="text" name="text" value="<?php echo $_POST['text'];?>" />--> <select name="text" > <option value="<?php echo $_POST['text'];?>">Text</option> <option value="ABCDEFGHIJKLMNOPQRSTUVWXYZ">ABCDEFGHIJKLMNOPQRSTUVWXYZ</option> <option value="abcdefghijklmnopqrstuvwxyz">abcdefghijklmnopqrstuvwxyz</option> <option value="0123456789">0123456789</option> </select> <select name="size"> <option value="<?php echo $_POST['size'];?>">Size</option> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="18">18</option> <option value="24">24</option> <option value="30">30</option> <option value="38">38</option> <option value="42">42</option> <option value="50">50</option> <option value="60">60</option> <option value="80">80</option> <option value="100">100</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <div id="top"> <?php $theFont="corbelb.ttf"; if(!empty($_POST['submit'])){ $myText = $_POST['text']; $mySize = $_POST['size']; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; }else{ $myText = "Handgloves"; $mySize = 24; echo '<img src="imageftt.php?text='.$myText.'&size='.$mySize.'&font='.$theFont.'">'; } ?> </div> </div> </body> </html>
  18. I'm trying to install ImageMagick to use with PHP, thats why I thought I might get an answer on the PHP forum.
  19. Have I installed ImageMagick ? Hi all I have been trying for days now to install ImageMagick on MAMP in Lion. I think I might have done it. I found this test online. <?php echo "<pre>"; system("type convert"); echo "</pre>"; ?> which echos convert is /opt/local/bin/convert Does this mean I have ImageMagick installed.
  20. Hi all Simple question is Pear installed on MAMP I'm having an absolute nightmare trying to install ImageMagick on MAMP. I have Image Magick installed I think, now I'm trying to install Imagick. In the terminal window I type 'sudo pecl install imagick' which returns 'sudo: pecl: command not found' I'm thinking that means pecl isn't installed. I read on a post that pecl comes installed with pear. Therefore does MAMP cpme with pear. ANY Help with this would be appreciated.
  21. Hi all I'm using MAMP and trying to install ImageMagick. Is there a way to test if it is correctly installed when using MAMP? ttmt
  22. Sorry to pester but can anyone help with this, it's driving me crazy now. This is my latest attempt - I thought I could use an array to store the text then use that value in the array when the input text field was empty. index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <style type="text/css"> *{margin:0;padding:0;} #wrap{margin:20px 0 0 20px;} img{margin:20px 0 0 0px;} </style> </head> <body> <div id="wrap"> <form action="index.php" method="post"> <input type="text" name="text" /> <select name="size"> <option value="24">24</option> <option value="30">30</option> <option value="36">36</option> <option value="50">50</option> <option value="100">100</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <?php $oldText = array(); if(!empty($_POST['submit'])){ if($_POST['text'] != ""){ $myText = $_POST['text']; array_unshift($oldText, $myText); print_r($oldText); $mySize = $_POST['size']; echo '<img src="image.php?text='.$myText.'&size='.$mySize.'">'; }else{ print_r($oldText); $mySize = $_POST['size']; $myText = $oldText[0]; echo '<img src="image.php?text='.$myText.'&size='.$mySize.'">'; } }else{ $myText = "Handgloves"; array_unshift($oldText, $myText); print_r($oldText); $mySize = 50; echo '<img src="image.php?text='.$myText.'&size='.$mySize.'">'; } ?> </div> </body> </html> image.php <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(600, 160); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 600, 199, $red); $text = $_GET['text']; $textSize = $_GET['size']; $font = 'corbelb.ttf'; imagettftext($im, $textSize, 0, 10, 120, $black, $font, $text); $img = imagepng($im); imagedestroy($im); ?>
  23. Thanks premiso, thorpe for your help, thorpe I understand now I think I've got this partly working now but I'm stuck again - http://www.ttmt.org.uk/test/index.php It starts now with a predefined text area (red) and text. I can enter text and select a size that is show in the text area as an image. My problem is I want to be able to change the font size without changing the text. If I try to change the text size with nothing in the text input area nothing is displayed because nothing is in the text box. I want to keep the last thing displayed the red area but just change the font size. I can see why this is happening but can't work out a solution. Any help would be greatly appreciated. index.php <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> <style type="text/css"> *{margin:0;padding:0;} #wrap{margin:20px 0 0 20px;} img{margin:20px 0 0 0px;} </style> </head> <body> <div id="wrap"> <form action="index.php" method="post"> <input type="text" name="text" /> <select name="size"> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="18">18</option> <option value="24">24</option> <option value="30">30</option> <option value="36">36</option> <option value="50">50</option> <option value="100">100</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <?php if(!empty($_POST['submit'])){ if($_POST['text'] != ""){ $myText = $_POST['text']; $mySize = $_POST['size']; echo '<img src="image.php?text='.$myText.'&size='.$mySize.'">'; }else{ $mySize = $_POST['size']; echo '<img src="image.php?size='.$mySize.'">'; } }else{ $myText = "Handgloves"; $mySize = 50; echo '<img src="image.php?text='.$myText.'&size='.$mySize.'">'; } ?> </div> </body> </html> image.php <?php header('Content-Type: image/png'); $im = imagecreatetruecolor(600, 160); $red = imagecolorallocate($im, 255, 0, 0); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 600, 199, $red); if(($_GET['text'] != "")){ $text = $_GET['text']; } $textSize = $_GET['size']; $font = 'corbelb.ttf'; imagettftext($im, $textSize, 0, 10, 120, $black, $font, $text); $img = imagepng($im); imagedestroy($im); ?>
  24. Font tester - I thought I had it. Hi all I'm trying to produce this font tester where you can set a font with inputted text at a selected size. In my demo here http://www.ttmt.org.uk/test/ I can type in text and select the size. The image is set with the correct text and size but everything else is removed from the page. How can I do this so the image of the text appears below the form in the image tag. <?php if(isset($_POST['submit'])){ // Set the content-type header('Content-Type: image/png'); // Create the image $im = imagecreatetruecolor(400, 30); // Create some colors $white = imagecolorallocate($im, 255, 255, 255); $black = imagecolorallocate($im, 0, 0, 0); imagefilledrectangle($im, 0, 0, 399, 29, $white); // The text to draw $text = $_POST['text']; $textSize = $_POST['size']; $font = 'corbelb.ttf'; // Add the text //imagettftext($im, 20, 0, 10, 20, $black, $font, $text); imagettftext($im, $textSize, 0, 10, 20, $black, $font, $text); // Using imagepng() results in clearer text compared with imagejpeg() $img = imagepng($im); imagedestroy($im); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title>untitled</title> </head> <body> <form action="index.php" method="post"> <input type="text" name="text" /> <select name="size"> <option value="10">10</option> <option value="12">12</option> <option value="14">14</option> <option value="18">18</option> <option value="24">24</option> <option value="30">30</option> <option value="36">36</option> </select> <input type="submit" name="submit" value="Set →" /> </form> <img src="<?php echo $img; ?>" /> </body> </html>
×
×
  • 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.