Hootie Hoo posted:I tried my own cack-handed editing and it just resulted in a php error. I'm stupid and unsure of what to delete and what to leave. Please help. Download Firebug and use the element inspector and you should be on your way in no time!
|
|
# ? May 1, 2010 07:52 |
|
|
# ? May 16, 2024 08:40 |
|
Go check your widgets page in Wordpress admin. I'm pretty sure most of those can be removed from there.
|
# ? May 3, 2010 13:46 |
|
Is this common PHP behaviour or just some wacky configurations by the hosting company: I'm writing a script right now that should handle specific script-created directory removal, but specifying any sort of path value in a variable adds in data that I don't want and fucks up the directory checking/manipulation functions, eg:php:<? // for the sake of reference, I'm passing script.php?mode=del&dir=1234-20100503 $rm_dir = preg_replace("#^[a-zA-Z0-9\-]#", "", $_GET['dir']); // quick & dirty injection protection $my_path_check = "/home/*******/images/{$rm_dir}/"; echo "<xmp>"; echo var_dump(is_dir($my_path_check)); echo $my_path_check; echo "</xmp>"; ?> bool(false) /home/********/images/1234-20100503/.htaccess/ Now because PHP (or whatever modifications were done to the php installation) adds in that .htaccess bit, I can't reliably check if that 1234-20100503 directory is legit or not so I can't get the script to do what I want it to do. I don't work with directory manipulation much, but whenever I did I don't think I ever ran into this problem so I'm thinking it's just a hinky setting or patch on the host machine. Is there a better way of quickly checking directory existence that won't be impeded with random poo poo getting added into my code? FWIW, before I had it set to remove single files and that worked fine, but I have to make the jump to directories because I need to delete collections of files.
|
# ? May 3, 2010 18:17 |
|
The regex "^[a-zA-Z0-9\-]" says "find one lowercase/uppercase/number/dash at the beginning of the string". You probably want to move the caret inside the square brackets, "[^a-zA-Z0-9\-]", which means "find anything that is not a lowercase/uppercase/number/dash" instead. What's var_dump($_GET['dir']) before and after the regex? No idea where the .htaccess is coming from.
|
# ? May 3, 2010 19:01 |
|
Has anyone come up with/found any way to implement a low footprint chat system with PHP? I'm running Apache 2 so probably no Comet. I was thinking of temporarily storing messages in xcache or memcache but not really sure if that's a good way to go.
|
# ? May 3, 2010 23:45 |
|
Ugh yeah, I always get tripped up on that quick regex character strip (but that's neither here nor there). Also as far as my problem goes, I think I've figured out what it was. I'm just a big dummy on Monday mornings. Referencing pre-existing php files in the application I'm adding to gave me the impression that all the get/post vars got processed out of the $_GET/$_POST arrays and sanitized/globalized but apparently that wasn't the case. Instead of using $_GET['dir'] (and previously $_GET['file']) like I should have done as per the pseudo-code posted, I was referencing $dir and $file, both of which inexplicably kept showing up as ".htaccess" strings. I've since fixed my code and all is well with my directory check/delete function and I feel like a giant idiot. Mondays Thanks for the assistance though.
|
# ? May 3, 2010 23:49 |
|
quote:// quick & dirty injection protection php:<? $root_dir = '/home/clap/images/'; $target_dir = realpath("{$root_dir}/{$_POST['dir']}"); if (0 != strncmp ($target_dir, $root_dir, strlen($root_dir))) { ... } ?>
|
# ? May 4, 2010 03:13 |
|
drcru posted:Has anyone come up with/found any way to implement a low footprint chat system with PHP? I'm running Apache 2 so probably no Comet. Very low footprint, Facebook Live Stream: http://developers.facebook.com/docs/reference/plugins/live-stream
|
# ? May 4, 2010 04:19 |
|
MrMoo posted:Very low footprint, Facebook Live Stream: That's kinda cool, don't know how comfortable people would be displaying their real names in a game though. Know of anything that you can run locally?
|
# ? May 4, 2010 04:30 |
|
Try the APE real time chat, http://www.ape-project.org/demos/1/ape-real-time-chat.html
|
# ? May 4, 2010 04:37 |
|
I'm planning on using PHP to parse a HUGE xml file (10 gb or so). It seems PHPs XMLReader will do the job, since it streams the file and doesn't load it all into memory at once. However, I need to store all the xml data in MySQL. I don't have the tables set up yet....I do have an XSD file that the XML must conform to. I was hoping to somehow use this XSD file to automatically create the MySQL tables. XMLSpy sort of did the trick I guess - it created about 40 tables with foreign keys - seems like it may be a pain in the rear end to manage. So anyway, I really don't want to hardcode field names into the script that will be inserting the data into the database....is there some way to get the node name, if it doesn't exist create the table, then create the fields? I'm a bit of an XML noob so I may not be wording this correctly. I guess one of the main issues is some of the nodes have children with the same attribute name (like multiple photos): <photos><url>whatever.com</url><url>whatever2.com</url></photos> <- a bunch of issues like that. In this case there would be a photos table with a url field and then a foreign key field that relates to this record. There is so much data here that I want to try to make this script "automatic" as possible but I'm not really sure where to start. Any suggestions on resources to use or where to even start? I did find a tool called PhRETS that is made for dealing with the type of data I have (real estate data based on RETS) however I am reading it from a file, not connecting to a service and this library seems to be made for connecting to a service.
|
# ? May 4, 2010 18:59 |
|
You might not want to be using PHP / MySQL for this. I'm not saying it can't be done, but there are other tools which are much better suited for your task. For example, eXist is a free document database (as opposed to a relational database) which stores xml. You can then query the data using xquery/xpath to pull out what you want. I'm not sure what freedom you have regarding running non-php-mysql-type software on your host, but I feel like you're in for a world of pain by shredding xml into relational tables.
|
# ? May 4, 2010 19:07 |
|
yeah, originally I was looking at a product called Talend to basically map the xml file to fields in mysql.....it works great with small files - for this huge file it can't load it into memory so it crashes. That is the main reason I'm looking at PHP and XMLReader/SAX. I'll check eXist out to see if it can help...ultimately the data does need to be in MySQL however.
|
# ? May 4, 2010 20:18 |
|
I'm trying to make sure players only hit with their weapons a percentage of the time (70%, 34%, etc) but it doesn't seem that my functions are very accurate. Attempt 1: code:
code:
|
# ? May 6, 2010 04:15 |
|
drcru posted:I'm trying to make sure players only hit with their weapons a percentage of the time (70%, 34%, etc) but it doesn't seem that my functions are very accurate. I have no idea what your functions are supposed to be doing, they seem a bit convoluted with the arrays and all. Instead, imagine you are rolling a 100 sided die to compute this. Lets say your hit percentage is 65%. In that case when you roll the die if the number is 65 or less, thats a hit. If the number is 66 or greater, then that is a miss. So all you need to do is pick a random number between 1 and 100 for each shot, then see how that number compares to your hit percentage.
|
# ? May 6, 2010 04:31 |
|
Begby posted:I have no idea what your functions are supposed to be doing, they seem a bit convoluted with the arrays and all. Thanks, the way I had it was a bit much.
|
# ? May 6, 2010 04:58 |
|
in regards to my php question earlier, I have the tables created but am now running into some issues with XMLReader: I'm trying to parse a HUGE xml file and store the values in MySQL. XMLReader seems to the solution since I won't have to read the entire file into memory - I can stream it in (the file is like 5 gigs). Main problem I'm having is the documentation on XMLReader blows. If my XML file looks something like this code:
Here is code that I have written that just spits all addresses out: code:
|
# ? May 6, 2010 16:57 |
|
Does anyone know of a free RSVP script similar to what facebook has? Found one on my own if anyone needs one this works well http://www.dbscripts.net/poll/ TKE248 fucked around with this message at 19:13 on May 7, 2010 |
# ? May 7, 2010 17:11 |
|
Somethings wrong with this SQL query and i have no idea what. I'm not getting an error message either because its a paypal ipn repsonse that says its going through fine.quote:$sql = "INSERT INTO orders (email, paypal_tx, paypal_status, payer_id, payer_status, name, address_name, address_street, address_city, address_state, address_country, address_postcode, address_status, items,prices, promo, promovalue, gross_value, net_value, shipping, paypal_protection, timestamp) VALUES ($email, $paypal_tx, $paypal_status, $payer_id, $payer_status, $name, $address_name, $address_street, $address_city, $address_state, $address_country, $address_postcode, $address_status, $items, $prices, $promo, $promovalue, $gross_value, $net_value, $shipping, $paypal_protection, $timestamp)"; I assume its some ridiculous formatting error but i'm totally at a loss.
|
# ? May 7, 2010 17:11 |
|
blunt posted:Somethings wrong with this SQL query and i have no idea what. I'm not getting an error message either because its a paypal ipn repsonse that says its going through fine. None of your string values have quotes around them, and if any of your values have a comma, quote of other breaking character, your SQL becomes invalid. Use prepared statements, or add quotes to your query values and escape your variables.
|
# ? May 7, 2010 17:20 |
|
^^^ is correctblunt posted:I assume its some ridiculous formatting error but i'm totally at a loss. In the future to troubleshoot this kind of stuff, its good to use dummy data then echo the sql query, then paste it into a mysql gui and troubleshoot and fix it there.
|
# ? May 7, 2010 17:30 |
|
Alex007 posted:None of your string values have quotes around them, and if any of your values have a comma, quote of other breaking character, your SQL becomes invalid. Found the problem, i was missing quotes ($items is a x,x,x, string) and the while() that was around it was also wrong. PHP e; quote:In the future to troubleshoot this kind of stuff, its good to use dummy data then echo the sql query, then paste it into a mysql gui and troubleshoot and fix it there. Thanks for the headsup
|
# ? May 7, 2010 17:59 |
|
blunt posted:
This 'error' has nothing to do with PHP and everything with the SQL standard. Sorry mate!
|
# ? May 7, 2010 18:54 |
|
I am having trouble getting a simple monthly interest calculator to work. I am entirely new to PHP, and don't understand my problem. calculator.html code:
code:
I can upload it to my host if you need to see it. Anyone that can help, thanks!
|
# ? May 10, 2010 18:04 |
|
At present your script has two syntax errors (that I can see). All statements need to be terminated by a semicolon; you are missing a semicolon after $counter = $counter + 1. Also, your while loop is missing a closing brace.
|
# ? May 10, 2010 18:15 |
|
Also: you don't have to type out a new "echo" command for every little piece of data you want to output. If you have a lot of things to output, you can use string concatenation:code:
code:
|
# ? May 10, 2010 18:19 |
|
Hammerite posted:At present your script has two syntax errors (that I can see). All statements need to be terminated by a semicolon; you are missing a semicolon after $counter = $counter + 1. Also, your while loop is missing a closing brace. Thanks a lot man! The table now works just as it should. Now I just have to add the actual calculations and test it out.
|
# ? May 10, 2010 18:40 |
|
Hammerite posted:Also: you don't have to type out a new "echo" command for every little piece of data you want to output. If you have a lot of things to output, you can use string concatenation: To expand further; you don't even need to do concatenation, you can pass it comma separated arguments, and it'll handle them: code:
code:
|
# ? May 10, 2010 19:44 |
|
I foolishly volunteered to help someone with a project and now I'm suffering for my lack of PHP experience. I'm using Drupal with the Webform and Webform PHP module. It lets you put in a chunk of PHP code to do additional validation and processing after the form is submitted. I've got some code in the processing section that isn't working. code:
|
# ? May 11, 2010 03:55 |
|
I'm currently toying a bit with PHP to make a web-game for my SO (think along the lines of Neopets or Gaia, just... actually don't.) Now, I have never used PHP before and I learn as I go. Having some background with other programming languages (mostly java) everything goes pretty smooth. I've made a registration page, a login page, member profiles, etc. mostly to get a feel for the language (will probably have to drastically change the structure once I actually design the page). The game will revolve around "pets" (think Pokémon. Pokémon is good.) and incorporate many RPG elements, one of which is equipment or accessories. This is where I'm stuck. Looking around google I've found the function "imagecopymerge" which does part of what I want (take the 'pet', take the 'accessory', merge them) but my current script is awfully clunky. Click here to take a look Right now I use two PHP scripts, one which generates the image based on a GET request (php?on = add hat, php?off = don't add hat) and the other which displays the image. The img src in the display-page is a string where the value if determined by the button you press (party.php?on or party.php?off) Now, this is where it gets clunky. GET is far too exploitable when it comes to things like this (only a user that actually HAS the hat should be able to use the hat) and I have no idea how I would add (and remove) more items. I'm sorry if my explanation is terrible, I'll get to the point. What I want is to be able to equip several items, and then be able to unequip them one by one in any possible combination (say, add party hat, add glasses, remove party hat without removing the rest). I also want to get rid of the GET or at least make the resulting image a .png (so when you save it it won't save as "party.php?on.png") Any ideas?
|
# ? May 11, 2010 13:09 |
|
Your Computer posted:The game will revolve around "pets" (think Pokémon. Pokémon is good.) and incorporate many RPG elements, one of which is equipment or accessories. This is where I'm stuck.
|
# ? May 11, 2010 13:26 |
|
Yay posted:Store and validate the data against the session, rather than a querystring? Ultimately, get is not exploitable unless you leave it to exploitation. If you can secure the input in such a way as you always know what to expect (check the string is in an array of valid scalars, etc), then there's much less of a problem. Of course, sessions. I'm still not very good with those. I suppose I would use both cookies and sessions, then? I currently use cookies for user login and sessions for... nothing. Any good resource for using sessions in this manner?
|
# ? May 11, 2010 13:39 |
|
Cpt.Wacky posted:I foolishly volunteered to help someone with a project and now I'm suffering for my lack of PHP experience. I'm using Drupal with the Webform and Webform PHP module. It lets you put in a chunk of PHP code to do additional validation and processing after the form is submitted. Well it looks like Webform wasn't meant to be used this way. I'm building the form as a custom content type with the CCK and Computed Field modules now.
|
# ? May 11, 2010 16:43 |
|
I've recently set up a Drupal site on an Amazon EC2 machine running Fedora 8. On this site I have just activated the "Contact Form" module. For some reason, it doesn't seem to be sending any email. Where should I be looking to fix this? Is this the wrong thread? I'm clueless about email.
spiritual bypass fucked around with this message at 05:31 on May 12, 2010 |
# ? May 11, 2010 18:21 |
|
Edit: Mail() won't work, you'll need to get SMTP support from a drupal module. Or configure sendmail, which I don't feel is worth the hassle.
|
# ? May 12, 2010 00:45 |
|
Let's pretend we have an imaginary message board. The messages are stored in a table with a thread_id and sub_forum_id. Threads and forums are stored in their own tables. The threads have a sub_forum_id, so if you click on sub forum 'games', all the threads that have the sub_forum_id of '5' or whatever games is, will show up. Likewise, when you click on the thread 'Super Mario Brothers', all the messages with the thread_id '50' show up. Here's my question: Which way would be commonly used to keep track of the replies, views, and post counts in each forum? Forum: Threads: Posts Games 57 302 Chat 23 98 Thread: Posts: Views: Hello! 23 299 Anyone play it? 56 23432 Would it be stupid to query the database for all threads, and then posts that belong in each forum, every time someone calls up the forum index page? I guess we're already querying the DB for all the thread titles etc each time, or is that something that shouldn't be done every time either? What about updating the thread counters (and then the sub forum counters) every time a post is made? What about having an automated process just update the numbers every 1 or 5 minutes? Would I do that with just a cron job? Or would I have some custom maintenance script that is running all the time, doing things as I set them up (sounds like re-writing cron)
|
# ? May 12, 2010 21:12 |
|
Bob Morales posted:Let's pretend we have an imaginary message board. The messages are stored in a table with a thread_id and sub_forum_id. Threads and forums are stored in their own tables. Well, Invision Board has a table just for topics and it stores the total number of posts, threads, the last topic id, and last poster name. Take it as you will. Edit: It's probably best to do it this way since you don't want to scan through all your posts every time someone loads the index. If my Invision forum did that it'd probably eat up all the RAM going through 400,000 poo poo posts.
|
# ? May 12, 2010 21:28 |
|
You'll hear arguments from both sides, but mostly people (who can reconcile everything not being normalized to the optimum) just deal with the minor denormalisation and have a separate field to keep a reasonably up-to-date count of various bits like that. (Edit: ultimately, object counts don't need to be accurate (see post below) because once they pass a certain thresh-hold (say, 5-10), they're irrelevant for a while. For example, the difference between 11 and 16 objects is measurable, but not by enough for it to matter. You don't suddenly hit object 14 and declare that due to an inaccurate representation on the previous page, you shan't continue. Page counts matter slightly more, as they're an indication of the overall timesink, but still) Yay fucked around with this message at 22:18 on May 12, 2010 |
# ? May 12, 2010 21:41 |
|
Ah just store the values, you're not writing bank software, it's really, really ok if your post count is off for whatever reason. If you want, write a "regenerate totals" function which does the full aggregate scan and comes up with the true values, and run it once an hour/day, and in the meantime just increment the values as necessary and get on with your life.
|
# ? May 12, 2010 21:53 |
|
|
# ? May 16, 2024 08:40 |
|
revmoo posted:get SMTP support from a drupal module Good suggestion; the day is saved
|
# ? May 12, 2010 23:40 |