Everything posted by php_penguin
-
How come there is no PHP script that simply uses images to mimic fonts?
Here is the first example i found. It is actually for creating buttons with custom fonts (for quick UI development). An example url might be: http://localhost/button/button.php?t=Login A full list of options is as follows: t: text to display (required) x: offset from left (optional, aligns center by default) y: offset from top (optional, aligns center by default) c: color of font (optional, goes to #444444 by default), takes RGB and Hex input: rgb(111,111,111), 111,111,111, #08f, #0088ff, 08f, and 0088ff are all valid s: size of font, in pixels or points (dependant on GD version), defaults to a "good" size for the button Hope that all makes sense. You should be able to chop up that script to do what is required. button.zip
-
How come there is no PHP script that simply uses images to mimic fonts?
The easiest way to accomplish this is using the PHP GD libraries compiled with the ttf support (read the man pages for more specifics). That way you can simply specify the font, size, and color in the url for the image (using JS to replace dynamically). Another way I have done this is using a linux command-line tool for image generation, as is this is quicker (but requires ssh access to the server, or friendly tech-support). In both cases, images can automatically be cropped (either by using imagettfbbox() or by passing an arg to the prog), weight is chosen by a specific TTF file (eg "Arial Black" for bolded Arial) as is emphasis/italicisation. Ill have a look for the GD based script in a few minutes...
-
CSS stylesheets with PHP
Hi there! Firstly, it might not be a PHP error - it might be that some files aren't uploaded with teh right permissions, or that they are in the wrong directories, or that they are in the right directory but cant be found because of a mistake in the css file (relative (./) and absolute (/) directory naming for example). If your husband is 100% sure its not something like above (and isn't just blaming PHP for the errors because of its foreignness), could you ask your husband if the server is PHP enabled? If he doesn't know, he can find out by copying and pasting the following: <?php print "PHP works!"; ?> into a file named "test.php", uploading it to the server, and running it in his web browser (eg http://mysite.co.uk/test.php) If PHP is enabled, the problem may well be that his desktop server runs PHP version 5, and the server runs PHP version 4. If this is the case he could either: - try and convince the server tech guys to upgrade it to PHP5 - try and figure out the errors that the php script(s) are giving him and fix them himself - pay (!) someone else to fix it.
-
How does an HTML DOM parser work?
Hi Scaz/Rich (woo namesake win), I've built a HTML and a CSS parser with pure PHP just for kicks before now... The way I went around it was: - strip all tags from the raw html source - create objects containing name, attributes, content (either string or reference), and its type (opener, closer, autocloser), and a reference to its children - assigned a unique numerical ID to every element (this is what I mean by reference) - builds a tree based on the objects attributes (auto-closing tags which are out of sync, not as good as htmltidy though) - also creates a linear list of elements for selection for every attribute (i'll explain in a mo) The CSS parser: - parsed common (but not all) CSS rules, and broke down some other ones into simpler/more verbose rules - looked into the linear list of elements to match by tagname, id, class, other attributes - selected all elements and passed that list to the next selector To do the searching: - create a copy of the full element list as the "Search Region" (SR) - for each selector (parsed using regex) narrow down the SR based on that rule - move onto the next selector, which searches in the SR - when a comma or { (parenthesis?) occurs, move the SR to a "Result Set" (RtS). - when a comma only occurs, go back to the start of this list The advantages of this are that you have a full tree with which you can easily manipulate all attributes, add and remove attributes, move elements around, insert and remove elements, and generally treat it like jQuery if you code it right Not sure if these answer your questions or just ocnfuse you, reply with something more specific and i'll answer more specifically!
-
/n not creating a new line
you are using echo instead of print srsly, thats all their is to it.
-
is there a more efficient way of creating a site?
Hi vxd, What you are asking for is basically a "dynamic site". There are a bunch of ways to do this, and they are: - An ecommerce package, such as Magento, Zencart or Actinic (if you want a cart and payment processing) - A CMS (content managment system) such as ExpressionEngine - A bespoke PHP/MySQL system (for full control and exact feature requirements). I have experience with all three things on that list, and am in a position to either do the work or help you out gratis on MSN. Add me with my username @hotmail.com (cryptic i know, but less spam this way).
-
Access Database to HTML
Or PHP - it CAN do access databases. Take a look at codeigniter framework.
-
How big is your Monitor?
1680x1050 + 1440x900
-
How wide should I go?¿Panowebsite
Jay D : whilst its true that statistics can be bent, those statistics are raw, straight from Google Analytics from the last month on both those sites. If you'd prefer me to list the the stats for all records since they began (approx 400,000 unique visitors) then I can. It's still a small percentage but that sample covers a pretty average user - not technically able, sitting on a dell inspiron laptop. As Headcoat said, 1024x768 is the de-facto standard, my figures are there simply to support that case with facts. Disregarding 800x600 users is an entirely personal choice, and I do it without flinching these days - tracking sales against monitor resolution actually shows a trend whereby "larger resolution = higher sales conversion". 800x600 are usually stingy buggers who refuse to by an up to date monitor.
-
How wide should I go?¿Panowebsite
800x600 is *not* the average resolution by any definition of average. Taken from Sportsaver.co.uk and Robinsons-intl.com in the last month (first num is Sportsaver, second is Robinsons): > 1024 x 768 59.60% 58.67 % => 59.135 % = 1024 x 768 37.67% 38.69 % => 38.18 % < 1024 x 768 2.73% 2.64 % => 2.685 % As you can see, 97.3% of users (approx 30,000 recorded) had a screen resolution greater than or equal to 1024x768, meaning you can safely discard that tiny proportion of users (800 of the 30,000, or 2/75th's). Just as a side note, if either the X or Y value was less than 1024/768 it was classed as under 1024x768. I saw a few exotic screen sizes in the list, included one listed as 800x5000.. mad edit: apparently the 800x5000 is the Opera Mini browser, which spoofs the res to be 800x5000 and then scales+crops to fit
-
Another one bits the dust!
is there something in your house that fuxors them? I have had one from about 3 months after they came out, and apart from occasional (like 3 times a day, if I play for 10 hours solid) disk read errors, I have had no problems. Are you playing on it in a really warm room or something?
-
having two background images
could you use a fixed sized image that contains both sqaures? A little less flexible, I know...
-
Freelancer warning - taxed as employees
This is well known about, but it's pretty difficult to be caught out. The rules stipulate that if you primarily work for (are paid by) only one employer for any given six month (or longer) period, you are counted as an employer rather than a freelancer. For all those worried by this, take on a few small jobs from people within the UK and you will be fine - remember to record invoices and so on!
-
What is CSS File management
any chance of a bit more info? for example, where have you seen this phrase?
-
javascript limit field to integer
there are two options here, one is to use the "typeof" construct like so: if( typeof a == "Int" ) The string might not be "Int" it might be "Integer" but more importantly it *might* not work, because the number might be interpreted as always being a string, regardless of what it is. The other way is to use character code recognition. if( e.keyCode > 91 && e.keyCode < 102 ) The specific numbers might be off, they should be close though - you can alert the keyCode value to figure it out properly. The "e" object is the result of a window.event call
-
How far do you walk every day?
about the same as jamest :s
-
CMS - Can it be done...
jamest makes a good point, although it is unexplained. A CMS allows a user to edit content on the site in an easy way - this involves putting the content in a database and making the database CRUDable by the user. This means that there are two root security holes - the database requires only a username/password and a query entry interface (XSS) and the control panel needs to be secured properly. If you aren't clued up on XSS and user authentication then you are likely to leave some large security holes in your application. If you are going to use this CMS on a commercial project then you are giving yourself huge liabilities. For that reason, you are better off using a CMS of choice such as Expression Engine, Text Pattern, Drupal, Joomla - the list is pretty huge
-
zookeeper
11350 first time i played it... cba doing a screeny
-
Tree-gen
the bare little twigs is due to the random pruning 1/20 times... the chance of one section and then failure is possible, as is 2 or 3 sections and so on... once it gets past the 4th tube its probably diverged and so failure falls to 1/400+ The "cannot be displayed" is probably a division by zero somewhere, but i cba figuring it out right now...
-
Tree-gen
Just mucking about, tell me what you think: http://www.richardlyon.co.uk/tree/tree.php It generates a tree-like structure based on a few rules... lots of random numbers, plugging them into logs with a bit of trig thrown in for good measure... I might add some leaf-spawning shortly.. For the code-junkies out there... <?php // create and fill canvas $width = 800; $height = 1000; $image = imagecreatetruecolor( $width, $height ); $sky = imagecolorallocate( $image, 170, 210, 230 ); imagefill( $image, 0, 0, $sky ); // root color $root = imagecolorallocate( $image, 70, 56, 28 ); $leaf = imagecolorallocate( $image, 75, 135,55 ); // root function function root( $image, $x1, $y1, $width, $step, $limit, $angle = false ) { global $root; // color $step++; if( $step > $limit ) return; // randomly prune if( rand( 0, 20 ) > 19 ) return; // should the branch diverge? $diverge = ( rand( 0, $width * 4 ) / $width > log( $width ) ); // should the width shrink? $shrink_limit = $diverge ? 1: 0; if( $width > 1 && rand( 0, 10 ) > $shrink_limit ) { $width--; } /* make new length */ $length = rand( $width * 2, log($width) * 50 ) / 2; // calculate angle /* width is between 1 and 20... 180 - ( w * 8 ) gives between 172 and 20 */ /* if it is diverging, one branch has forced angle.. */ if( isset( $angle ) || !$angle ) { $angle_dif = 180 - ( $width * 8 ); $angle_mid = 180; $angle_min = $angle_mid - $angle_dif; $angle_max = $angle_mid + $angle_dif; $angle = rand( $angle_min, $angle_max ); } /* calculate new positions from angle, length and x1,x2 */ $mod_x = $length * sin( deg2rad( $angle ) ); $mod_y = $length * cos( deg2rad( $angle ) ); $x2 = $x1 + $mod_x; $y2 = $y1 + $mod_y; if( $width == 1 && rand( 0, 10 ) > 5 ) { spawn_leaf( $image, $x2, $y2 ); } // set thickness imagesetthickness( $image, $width / 2 ); // draw line imageline( $image, $x1, $y1, $x2, $y2, $root ); // draw new branch(es) if( $diverge ) { root( $image, $x2, $y2, $width, $step, $limit ); } $pm = ( rand(0,10) > 5 ) ? 1 : -1; $angle = $angle + ( $pm * 10 ); root( $image, $x2, $y2, $width, $step, $limit, $angle ); return $image; } function spawn_leaf( $image, $cx, $cy ) { global $leaf; // color // random size between 1 and 10 wide * high $width = rand( 1, 10 ); $height = rand( 1, 10 ); return imagefilledellipse ( $image, $cx , $cy , $width , $height , $leaf ); } // make first root $x = $width/2; $y = $height; $image = root( $image, $x, $y, 20, 1, 30 ); // output header('Content-type: image/png'); imagepng( $image ); imagedestroy( $image ); EDIT: LEAFINESS ADDED
-
Get text in javascript
simple! var pagehtml = '<html>' + document.getElementsByTagName('html')[0].innerHTML + '</html>'; pagehtml then contains the contents of the page, assuming the <html> tag doesn't contain any attributes and you don't need the doctype.
-
Design Category For Shopping System
your database design is not good. if you want to have a parent->child relationship with the categories, you need to add a "ParentID" field, which contains the CatID of it's parent, or 0 for a top-level category.
-
GTA4... a couple of months on
but you can also consider that the graphics were just amazingly better and the city was ALOT more detailed (rather than just expansive). The driving controls are more realistic, and with practice its not hard to drive a fast car through the city without hitting a single thing. I think it adds more of a challenge during the driving missions that you have to concentrate on driving rather than just bouncing off buildings to turn... I didn't feel the game missed anything due to the lack of jet planes, tanks, attack helicopters, or jetpacks - they simply were not realistic... GTA4, yes you could take 50 bullets to the face and walk away, yes you could fall 50 feet and only be a bit bruised... but the fights and missions felt alot more realistic - they were on the edge of realism rather than far far beyond it... the rise from the slums through crime was measured and not over the top - you were always the little guy, fighting against mob bosses... And the storyline? Tracking down someone who stabbed you in the back and killed 11 of your friends... seems a pretty good motive and resulting storyline to me...
-
Want an adrenaline rush?
http://www.brightcove.tv/title.jsp?title=1438490562 gotta have some big kahunas to do that voluntarily... I'd love to make a chav walk it and watch him p*** himself in fear
-
$_POST vs. $_COOKIE
I *think* the reason not to use $_REQUEST is because you may be using POST data in order to make it harder (but by no means impossible) to change the values. That reason is so flimsy that in practice, simply using REQUEST or the following would help: $_INPUT = ( count( $_POST ) > 0 ? $_POST : $_GET ); and then using $_INPUT (or any other name for that variable) - no real reason, but you may like the different name, or the REQUEST may be disabled..