Re: [PHP] Re: GD - dynamic PNG generation
I managed to fix my problem, it seems that it was taking so long because of the consturction of a for loop of mine. I was calling the ImagePNG function too early, menaing it seemed to take forever to execute. it's now running at a fraction of it's original time. Conor On Mon, Feb 25, 2002 at 06:30:35PM +, Conor McTernan wrote: hmm, sounds like a good idea, i'll give it a try. it seems too, that if i dont break up my text, i.e. print all of it in one long line, it runs a lot faster i'm running this under Win2k, i got a PIII i dunno how many mhz(it's a college PC, and everything is locked down on me) but i'd guess at 800mhz or something like that. i think i'm also running about 256mb or ram. so my specs are pretty good, i would imagine. i'll look into the multiple images soloution. cheers i'll get back to y'all with my results. Conor On Mon, Feb 25, 2002 at 01:21:42PM -0500, Michael Kimsal wrote: Holy cow that's a big graphic. 20 seconds does sound a tad long, but might not be depending on the server and memory - what are the specs? What might possibly speed it up a bit is to create multiple small versions first (20 one line graphics, for example) and build them all together at the end by loading and copying into the final large area - this MIGHT cut down time a bit, because all the drawing operations would take place against a smaller memory area. Just a hunch though. Conor McTernan wrote: I'm currently using the GD extension to generate dynamic PNG's containing text, that should eventually be coming from a database. the deal is, it seems to take a long time, which is probably my own fault, seeing that I'm generating so much text. I am generating an image containing approx 160 lines of text, and it takes about 20seconds to create, this unfortunatley is too long for me. I was wondering if this is a common time with GD or if I am doing something wrong. Coding wise, I currently read the text in from a file, then put the text into an array, each line being a seperate entry in the array. I then create a PNG image approx 490*1848(i change the image size depending on the amount of text). I dont do anything really strange in my image function, apart from performing a wordwrap on the text before i start displaying it, just to make the image readable. ideally I would like this to come in considerably quicker. that said, if this is going to be used, it will probably done as a cron job, so if need be I will have toaccept it being super slow. any help is appreciated bros Conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] another GD question
two in two days, i must look like a real retard. anyway, i'm having another problem with GD now, it seems that when i create my image, if i specify too many pixels i.e. imagecreate(600, 2290) it will not create the image, just a blank file it's sort of hard to explain, but i'll try. i am currently reading in a html file, which i want to display as an image. I read in my HTML and strip it of all HTML tags, this is stored as a varaible. i now explode this string using every occurence of a new line (\n), into an array, this gives me an array of lines. I now want to format the text a little bit, because I dont want my lines to be too long, so i word wrap it to 40 cols, followed by a rtrim, just to remove any chars that will appear in the image that i dont want. i then pass this array into my imageMake method. i create my image, using imagecreate, now, for my x value, i set it to be 500, and i set my y value to be 1963(i'll explain why in a minute). i then execute a for loop, which runs through each of the elements of the array(each line of text) and runs the GD ImageString function, this will take an incrementing value, making sure that each new line is below each other. when the for loop is completed, i call ImagePNG and then ImageDestroy. I suppose I should mention that I am creating a seperate image, and not displaying it imediattly. anyway, so long as I keep the Y value of the imagecreate function below 1963 the image will be created, but not all of the text is dispayed, since there seems to be more lines of text than area displayed.. if it is larger than that, all i get is a blank image, and if i try opening it in an image viewer i get an error. i have a feeling that it is someway related to the size of my text set, i.e. it is currently 216 lines long(after i perform the word wrap on it). also, if I run the exact same code on the same text formatted differntly (HTML removed, wordwrapped all done in pre-processing) it seems that I am able to increase the Y value in the imagecreate function, but, I still cannot raise it so far as to be able to include all of the text. this seems very strange, and I was wondering if anyone else has encountered this problem before. i'm not sure if i've made myself too clear here, if you have any questions, fire away. sorry for the long post Conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] GD - dynamic PNG generation
I'm currently using the GD extension to generate dynamic PNG's containing text, that should eventually be coming from a database. the deal is, it seems to take a long time, which is probably my own fault, seeing that I'm generating so much text. I am generating an image containing approx 160 lines of text, and it takes about 20seconds to create, this unfortunatley is too long for me. I was wondering if this is a common time with GD or if I am doing something wrong. Coding wise, I currently read the text in from a file, then put the text into an array, each line being a seperate entry in the array. I then create a PNG image approx 490*1848(i change the image size depending on the amount of text). I dont do anything really strange in my image function, apart from performing a wordwrap on the text before i start displaying it, just to make the image readable. ideally I would like this to come in considerably quicker. that said, if this is going to be used, it will probably done as a cron job, so if need be I will have toaccept it being super slow. any help is appreciated bros Conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Re: GD - dynamic PNG generation
hmm, sounds like a good idea, i'll give it a try. it seems too, that if i dont break up my text, i.e. print all of it in one long line, it runs a lot faster i'm running this under Win2k, i got a PIII i dunno how many mhz(it's a college PC, and everything is locked down on me) but i'd guess at 800mhz or something like that. i think i'm also running about 256mb or ram. so my specs are pretty good, i would imagine. i'll look into the multiple images soloution. cheers i'll get back to y'all with my results. Conor On Mon, Feb 25, 2002 at 01:21:42PM -0500, Michael Kimsal wrote: Holy cow that's a big graphic. 20 seconds does sound a tad long, but might not be depending on the server and memory - what are the specs? What might possibly speed it up a bit is to create multiple small versions first (20 one line graphics, for example) and build them all together at the end by loading and copying into the final large area - this MIGHT cut down time a bit, because all the drawing operations would take place against a smaller memory area. Just a hunch though. Conor McTernan wrote: I'm currently using the GD extension to generate dynamic PNG's containing text, that should eventually be coming from a database. the deal is, it seems to take a long time, which is probably my own fault, seeing that I'm generating so much text. I am generating an image containing approx 160 lines of text, and it takes about 20seconds to create, this unfortunatley is too long for me. I was wondering if this is a common time with GD or if I am doing something wrong. Coding wise, I currently read the text in from a file, then put the text into an array, each line being a seperate entry in the array. I then create a PNG image approx 490*1848(i change the image size depending on the amount of text). I dont do anything really strange in my image function, apart from performing a wordwrap on the text before i start displaying it, just to make the image readable. ideally I would like this to come in considerably quicker. that said, if this is going to be used, it will probably done as a cron job, so if need be I will have toaccept it being super slow. any help is appreciated bros Conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Very interesting and challenging question
I had something like this to do a couple of months back, unfortunately, my code was deleted by someone smart in my office. But i can pretty much remember the algorithim behind it. What I done was read in my file into a buffer, then use the explode function, i think, or something like it, basicially there is a function that allows you to parse a string using a set number of char as the delimiters, e.g. first item = first 10 chars etc, i think i was able to differentiate the number of chars, e.g. 10 for the first item, maybe 15 for the second and so on. I then read them all into an arry. once in the array it's a piece of cake, I know which item in the array corresponds to which field from the original file, e.g. item 1 = row 1 col 1, item 2 = row 1 col 2, item 5 = row 2 col 1 (assuming there are 4 cols). At this point you can just loop through the array inserting the fields into the database, or whatever you want to do. I cant remember what happens when I had empty fields. I think I may have had to fill in all blank fields for some reason. I'm not sure if this makes any sense. But I hope it's been a help. Conor On Wed, Nov 28, 2001 at 09:01:26AM -0800, Dan McCullough wrote: I need to take a file, similar to this and strip it of everything but this, and write it to a database. Are there any thoughts on how to get the information out, all the files are consistent. !-- start strip -- Race Final Watkins Glen International 2.450 miles31 laps Fin Str Driver Laps Led Pts Qual Reason Out !-- end strip -- !-- start output -- 1 2 18 Dynamike18 31 24 185 118.007 Running 2 7 68 jcordeiro310 170 116.078 Running 3 5 80 MattyJ140310 165 116.881 Running 4 1 28 RUDD#28 316 165 118.219 Running 5 13 57 1SpeedDemon 310 155 Running 6 9 84 legends3 311 155 115.131 Running 7 3 56 RobertFx3D 310 146 117.854 Running 8 12 55 24skids 310 142 98.644 Running 9 4 53 Mark_O_10310 138 117.323 Running 10 8 91 JJinsane 310 134 116.061 Running 11 108 beertipper 310 130 114.154 Running 12 11 44 WisOutLaw 100 127 111.022 DNF 13 6 51 BdgrOtlw 30 124 116.702 DNF !-- End 1st output -- !-- Start second output -- Race time - 72:52.030 Average speed - 62.538mph Margin of victory - 1.944sec Caution flags - 7 # of lead changes - 3 Weather - Clear 70^ E 0mph !-- End second output -- thanks for any help = Dan McCullough --- Theres no such thing as a problem unless the servers are on fire! h: 603.444.9808 w: McCullough Family w: At Work __ Do You Yahoo!? Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month. http://geocities.yahoo.com/ps/info1 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] (another, not entirely)sessions question
Hey there, I'm currently writing a web app using php. I was just looking for some advice on one aspect. On this site, users will be able to log in and post messages, or articles, or replies etc, you get the idea. Anyway, I am storing some info about the users, the usual stuff, name, email, password, all in mysql. I am also storing other info, such as when they last posted, and how many times they have posted. When a user posts a new message, the message is sent to mysql and stored in a table, at the same time, i also have to increment their total number of posts. The way this is done is by selecting the posts field on their userid, which i have to find using their username, which is set as a session var, when the user logs in. This all results in a good few queries to mysql. I was wondering would it be better to load all the user info, e.g. number of posts, last post date, into session vars, or should i set a cookie on the client side, or should i just continue with the queries. Any help is appreciated. conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] (another, not entirely)sessions question
cheers for the advice, I think what i'm going to do is, put the user name and their id in session vars. then i dont have to select on their id all the time. there wouldnt be any security issues with that would there? On Fri, Jul 20, 2001 at 07:49:56AM -0400, py wrote: Hello, I would continue with the queries. That's what a database is made for. Optimize them and make shure the fields you search often ( the ones in the WHERE clause ) are index. Keep the sesion vars as small as possible. Cookies are quite a pain to program and if the user has disable them, nothing works. Maybe an object (OOP) of all user info, serialized in an session var, would be a solution... just my advice... py - Original Message - From: Conor McTernan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Friday, July 20, 2001 7:31 AM Subject: [PHP] (another, not entirely)sessions question Hey there, I'm currently writing a web app using php. I was just looking for some advice on one aspect. On this site, users will be able to log in and post messages, or articles, or replies etc, you get the idea. Anyway, I am storing some info about the users, the usual stuff, name, email, password, all in mysql. I am also storing other info, such as when they last posted, and how many times they have posted. When a user posts a new message, the message is sent to mysql and stored in a table, at the same time, i also have to increment their total number of posts. The way this is done is by selecting the posts field on their userid, which i have to find using their username, which is set as a session var, when the user logs in. This all results in a good few queries to mysql. I was wondering would it be better to load all the user info, e.g. number of posts, last post date, into session vars, or should i set a cookie on the client side, or should i just continue with the queries. Any help is appreciated. conor -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: (another, not entirely)sessions question
On Fri, Jul 20, 2001 at 11:52:36AM +, Er Galvão Abbott wrote: Just a sugestion here, that may sound strange, but I'd do it like this: Why don't you keep a simle text-counter file for each user? Why this HAVE to go trough SQL? i suppose i want it to go through SQL because I am storing all my documents and the guts of the site in a database. Just creat a text file with 0 on it. When the user posts, retrieve the number from the file, increment it and then write it back... hmmm, interesting idea, but what happens when there are multiple users, each one will then have their own file, i know it wont take up too much disk space, but i really have a thing for tidy directorys:) and this sounds like a nightmare to me ;) This way you don't overload SQL and keep the post counter running... could it in fact create more work for the CPU, if it has to keep reading and writing to files on the disk, as well, would that be any quicker? Tell me what you think, even if you think it's stupid :) haha, i wouldnt say it's stupid anyway, but i wouldnt be attracted to that approach, i'm usually drawn to databases, hehe. On Fri, 20 Jul 2001 12:31:15 +0100, [EMAIL PROTECTED] (Conor McTernan) wrote: Hey there, I'm currently writing a web app using php. I was just looking for some advice on one aspect. On this site, users will be able to log in and post messages, or articles, or replies etc, you get the idea. Anyway, I am storing some info about the users, the usual stuff, name, email, password, all in mysql. I am also storing other info, such as when they last posted, and how many times they have posted. When a user posts a new message, the message is sent to mysql and stored in a table, at the same time, i also have to increment their total number of posts. The way this is done is by selecting the posts field on their userid, which i have to find using their username, which is set as a session var, when the user logs in. This all results in a good few queries to mysql. I was wondering would it be better to load all the user info, e.g. number of posts, last post date, into session vars, or should i set a cookie on the client side, or should i just continue with the queries. Any help is appreciated. conor Er Galvão Abbott Webdeveloper [EMAIL PROTECTED] - To send me an e-mail just remove the CAPITAL TEXT. - -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
Re: [PHP] Re: php/apache question(probably stupid)
Peter I think I have tohse lines i nmy httpd.conf. although they might read: AddType application/x-httpd-php4 .php AddType application/x-httpd-php-source .phps or something like that, i'll make sure to check it when I get back from work. I was going to install it as a DSO, but it said i need Apache configured with mod_so.c (or something like that) unfortunately i dont have that configured when i check my httpd. On Fri, Jul 13, 2001 at 03:40:34PM +0100, Peter Clarke wrote: Conor McTernan [EMAIL PROTECTED] wrote in message [EMAIL PROTECTED]">news:[EMAIL PROTECTED]... hey all, I've been using apache, php and mysql on win32 for a while now, and I have recently decided to move over to linux *yay*, so i got myself a copy of Suse 7.1 personal edition. snip Do you have the following in httpd.conf: # And for PHP 4.x, use: # AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps NB .php NOT .php4 Otherwise consider have php as a DSO then you can rebuild PHP without rebuilding Apache. Peter -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]
[PHP] xml and php question
Hey all I'm not so sure if this is the correct place to ask this question, but I'm hoping some of you will be able to give me some feedback. I am currently toying around with php and mysql developing a website for myself, the current one is partly php powered, but I am trying to move it over to a complete php and mysql system, I would also like to use XML. i have previously used Xml on another web project, and i really liked the way you could reformat you content, and it's ease of use. What i was wondering is, if any of you use XML to store your content, in what way do you go about it. At the moment i see 2 sepeerate ways of going about it. a)Mark up your documents in xml and store the xml documents in a database, your database can be pretty simple, witha couple of fields that represent some of the meta data in the xml file, e.g. Author, Date-created, then a large blob which is the doc. when you wish to view the document, you search on the criteria that is available, and then retrieve your xml doc. Some down sides to this could be the explosion in the size of the db, if you are storing a large amount of documents etc and also the redundancy in some of hte fields, e.g you have an author field, but this info is contained in the xml doc. It is good, because it is an essentialy simple application, in both php code to pull the data and in the database design. b)have the database act as a sort of XML holder, e.g. break the document down to it's base components, and store all the meta data in the database, when a doc is needed, the xml doc can be created on the fly, by pulling the data out of the appropriate fields. some problems with this can be the database design, it can become extremly complicated(i would imagine, i have not tried it yet), as you are effiectively modelling the DTD in the database. but at the same time, we are reducing redundancy, hopefully, so long as it is well normalised. the reason i am asking this is becaue of the amount i read about xml, how good it is extensible etc, there is not much out there inregards to the practical application of it, aside form the odd tutorial on how to construct a DTD or how to parse XMl with Java/PHP etc. once again, i'm not sure if this post is appropriate to this mailing list, perhaps i should send it to a MySql list or something, but if anyone has any ideas or thoughts on the topic i would really appreciate it. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] To contact the list administrators, e-mail: [EMAIL PROTECTED]