|
functional posted:This isn't always working like it should. I have a special link on my pages that will take you to loggingout.php. It uses a token to verify that you actually clicked the link (and didn't have anyone IM you a fake logout link). Stripping away the logic what it really does is this, which should log you out and redirect you to the index: caching probably, browser still you were cached, try adding some no cache headers and it should fix it.
|
# ? Jun 12, 2008 05:05 |
|
|
# ? May 15, 2024 03:31 |
|
mcbuttbutt posted:I'm trying to implement a simple URL hiding script that retrieves a zip file from the server filesystem. It's pretty basic and could surely be much better. Something like this... Don't do silly things like this. Use readfile(). Also, I don't know if that is only a snippet of the code, but please:
gibbed fucked around with this message at 06:49 on Jun 12, 2008 |
# ? Jun 12, 2008 06:47 |
|
I'm teaching myself how to use mySQLi and prepared statements. I'm having difficulty finding out how to insert a varied amount of rows in one statement, and Google isn't helping. I used to do something like this:code:
php:<? $stmt = $mysqli->prepare("INSERT INTO test VALUES (?, ?)"); $stmt->bind_param('ds', $number, $text); $number = 1; $text = 'one'; $stmt->execute(); $stmt->close(); ?>
|
# ? Jun 12, 2008 16:12 |
|
Preface: I'm using WordPress for blogging, an as-of-yet unknown forum system and hand-coding the main site. WP and Forums are on subdomains. How would I go about having a unified user login system across those three unique databases? My thought was to replicate user information between all three by way of a small bit of php at each sites user creation (checking for duplicates and sanitizing). or Something else? Am I on the right track, is there a much easier way to do this?
|
# ? Jun 12, 2008 16:47 |
|
maybe create the variable in the session that each system uses. And have a unified registration form that calls both user creation functions from WP and the forum. That could take a bit, because you'll have to tinker with the innards of the forum and WP to figure out how to do that.
|
# ? Jun 12, 2008 17:02 |
|
I'm at work, so I can't really check out the source at the moment, but it looks as though http://www.wp-united.com/ will handle the unification work between WP and PHPbb. Maybe I could use that and find a way to integate it into the main site. I was trying to shy away from phpbb however. Unless they've changed a good amount of phpbb since I last used it (version 2.something).
|
# ? Jun 12, 2008 17:26 |
|
I hear tell that v2 is gonna be "really awesome" Personally I use https://www.simplemachines.org for all forums for clients or personal.
|
# ? Jun 12, 2008 18:57 |
|
MrEnigma posted:caching probably, browser still you were cached, try adding some no cache headers and it should fix it. Do you mean to add no-caching headers to the page that looks like you're still logged in? There's a lot of different caching stuff you can do. Can you elaborate? Maybe post some source to get me started?
|
# ? Jun 12, 2008 19:26 |
|
gibbed posted:Why? WHY? Easy now, that's just a snippet. And thanks, but readfile() didn't work either... still a partial download. I've increased the memory_limit variable in my php.ini to 80M and that did nothing as well. Stumped! mcbuttbutt fucked around with this message at 20:40 on Jun 12, 2008 |
# ? Jun 12, 2008 20:06 |
|
functional posted:Do you mean to add no-caching headers to the page that looks like you're still logged in? There's a lot of different caching stuff you can do. Can you elaborate? Maybe post some source to get me started? Yeah, to the page that looks like you're still logged in. It's your browser caching that page on you I'm guessing, there are a bunch of them you can find from a google search. But setting the header expiration in php, the meta expire stuff in html, and maybe there are a few more, but that should do it.
|
# ? Jun 12, 2008 20:34 |
|
duz posted:Frameworks They can make life easier Just out of curiousity, what did you find with CakePHP that disgusts you so much? I've used it before, and there's a lot of things that piss me off about it, but there's a few things I really enjoy too. Is it a security risk or just poorly programmed?
|
# ? Jun 12, 2008 20:46 |
|
Stephen posted:Just out of curiousity, what did you find with CakePHP that disgusts you so much? I've used it before, and there's a lot of things that piss me off about it, but there's a few things I really enjoy too. Is it a security risk or just poorly programmed? Stuff like the data sanitization, especially for databases, was effectively non-existent. By being PHP4 compatible it made the source more convoluted and therefore error prone then it had to be. This was a year or so ago so they hopefully have cleaned it up in the latest builds. It was nice to use, and had some nice features, but for the project we were looking to use it for, the code just wasn't up to snuff.
|
# ? Jun 12, 2008 21:37 |
|
mcbuttbutt posted:Easy now, that's just a snippet. And thanks, but readfile() didn't work either... still a partial download. I've increased the memory_limit variable in my php.ini to 80M and that did nothing as well. Stumped! There is no reason why readfile() should fail unless the file is damaged somehow.
|
# ? Jun 13, 2008 01:08 |
|
I saw a thread about this a long time ago but I can't find it anymore so... How do you do the authentication system like they have on AwfulYearbook. If you don't know what I'm talking about, it's where a website checks to see if you have a specific line of text written onto a certain page. I hope that made sense.
|
# ? Jun 13, 2008 06:06 |
|
drcru posted:How do you do the authentication system like they have on AwfulYearbook. Probably include an activation token in the table of users. A random MD5 ought to do the job. Once you have that, compare it to member.php for that particular user by using the DOMDocument object (or some other method for gathering information from HTML/XML) to scour each element's child text for that value. Zorilla fucked around with this message at 06:32 on Jun 13, 2008 |
# ? Jun 13, 2008 06:28 |
|
Zorilla posted:Probably include an activation token in the table of users. A random MD5 ought to do the job. I was wondering more on how they did the actual checking of the website.
|
# ? Jun 13, 2008 06:30 |
|
drcru posted:I was wondering more on how they did the actual checking of the website. Just realized that after I posted. Check the first reply again. DOMDocument is great if you're already familiar with manipulating web pages with DOM in Javascript.
|
# ? Jun 13, 2008 06:33 |
drcru posted:I saw a thread about this a long time ago but I can't find it anymore so... Use something shorter than an MD5 hash, as some of the profile fields don't let you put in 32 chars, causing people problems. Use cURL to fetch the profile page. You will need to use cookies and your own bbuserid and bbpassword (find these by going through your cookies in firefox). Once you have the page loaded, just do a preg_match('/'.$code.'/', $page) and it will return true or false if $code is found in $page or not. Replace &userid=x to &username=x to search for a username. php:<? $ch = curl_init(EXTERNAL_PROFILE_USERID_URL.urlencode($id)); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_COOKIE, EXTERNAL_FORUM_COOKIE); $result = curl_exec($ch); curl_close($ch); return preg_match('/'.$code.'/', $result); ?>
|
|
# ? Jun 13, 2008 08:53 |
|
How do I get dreamweaver to fully preview my PHP files? I followed the setting up process for HostMonster: http://helpdesk.hostmonster.com/kb/index.php?mod_id=2&id=155&kb_rating=no But when I make the PHP page, all that I see is: So How do I make it so the actual, full page will show in the preview pane (it works on the actual web page though)
|
# ? Jun 13, 2008 22:12 |
|
I have just started work on a project which I hope will increase my knowledge of PHP. For reference, I have a lot of programming experience in other languages (I'm a CS major), but only just started really getting into PHP (took a really good web development class at Uni this quarter). Basically I am working on a CMS, and was wondering what the best way to store things like website parameters is? By website parameters I mean, for example, say that the admin doesn't want a certain section to be visible (eg. the top menu). I want to make it so that he/she can just check a box and the content will not show up. However, I want to store the preferences somewhere, and a SQL DB (which I will be using a lot for the backend of the site) doesn't seem appropriate. In fact, it's the type of thing where you would use an .ini file to save an applications preferences, for a normal application. But obviously since it's on the web, I want it to be secure. Any suggestions?
|
# ? Jun 13, 2008 23:38 |
|
cannibustacap posted:How do I get dreamweaver to fully preview my PHP files? Wouldn't it be easier to set up a testing server on your localhost?
|
# ? Jun 14, 2008 00:03 |
|
noonches posted:Wouldn't it be easier to set up a testing server on your localhost? Nah I want to use the servers of HostMonster so that way I know what I am previewing is what will be shown online. Do you know how to set it up?
|
# ? Jun 14, 2008 00:55 |
cannibustacap posted:Nah I want to use the servers of HostMonster so that way I know what I am previewing is what will be shown online. Use Editplus and edit it directly on the server
|
|
# ? Jun 14, 2008 01:00 |
|
fletcher posted:Use Editplus and edit it directly on the server I like the preview feature of dreamweaver. I know there is a way to do it through dreamweaver, does anyone know how?
|
# ? Jun 14, 2008 01:21 |
|
cannibustacap posted:How do I get dreamweaver to fully preview my PHP files? Dreamweaver is not a PHP interpreter. If you want to view a page with the PHP executed, you need to view it through a browser. Dreamweaver will not show any more than that.
|
# ? Jun 14, 2008 01:57 |
|
Munky_Magic posted:Basically I am working on a CMS, and was wondering what the best way to store things like website parameters is? If you don't mind the settings being lost if the user clears their browser cache, use cookies. Otherwise, use the MySQL database. I would use cookies for petty things like which menus get shown on each page.
|
# ? Jun 14, 2008 02:10 |
|
Anveo posted:Dreamweaver is not a PHP interpreter. If you want to view a page with the PHP executed, you need to view it through a browser. Dreamweaver will not show any more than that. Then why would they offer a PHP features?
|
# ? Jun 14, 2008 02:15 |
|
cannibustacap posted:Then why would they offer a PHP features? I think the feature is that it can do code foldering and syntax highlighting for PHP. If you think there is more, hit up your manual.
|
# ? Jun 14, 2008 02:42 |
|
I want to add a feature on my site that outputs that data into a PDF file, so when the user print, it looks consistent and paged correctly. Anyone know of a good library or something that will do this?
|
# ? Jun 14, 2008 02:48 |
|
nbv4 posted:I want to add a feature on my site that outputs that data into a PDF file, so when the user print, it looks consistent and paged correctly. Anyone know of a good library or something that will do this? PDFLib is the one you want, it's not easy at all to do things though...well anything besides just a block of text. http://pecl.php.net/package/pdflib It's free for non-commercial use (or at least there is a free alternative for non-commercial use). Edit: Also check out http://us3.php.net/manual/en/book.pdf.php (and the comments).
|
# ? Jun 14, 2008 02:59 |
|
I just moved my stuff over to new hosting and I came across and issue with some of my previously functional code. I've been using time() in one of my scripts to generate ids for items placed into a database. Then later when they are displayed I used the following to get the month and the day: $day = date("d", $id); $month = date("M", $id); I get anything from February 23 1997 to October 02 2019 What's wrong here? Edit: It appears to be working now, I guess because it was just setup the dates were messed up somehow? clockwork automaton fucked around with this message at 20:26 on Jun 15, 2008 |
# ? Jun 15, 2008 19:40 |
|
MrEnigma posted:PDFLib is the one you want, it's not easy at all to do things though...well anything besides just a block of text. take a look at http://www.digitaljunkies.ca/dompdf/ It will convert html + css2.1 to a pdf document and is a crap load easier than directly using PDFLib.
|
# ? Jun 16, 2008 03:10 |
|
bt_escm posted:take a look at http://www.digitaljunkies.ca/dompdf/ That's awesome, although I don't see a usage license on there...but apparently it's "free" for all.
|
# ? Jun 16, 2008 04:34 |
|
I'm writing a script to validate URLs, and one part of the script validation is a check to see if the document exists (i.e. seeing if there's a response). Is there a faster function to use than get_headers? For me, get_headers is extremely slow and I'm going to be validating thousands of URLs.
|
# ? Jun 16, 2008 18:39 |
|
I am trying to implement a reversible sort a 2d array by an arbitrary key in the second level function. So I used an insertion sort (or it's based on an insertion sort rather): php:<? function sort_list($array,$index="person_id",$direction) { //$array[0] = "person_id"=> 1223523,"class"=>"Shakespeare","type"=>"Final",etc... $max = count($array); if ( $direction == "asc" ) { for($j=1; $j < $max; $j++){ $temp = $array[$j]; $i = $j; while(!empty($array[$i-1]) && ($i >= 0) && ($array[$i-1][$index] > $temp[$index])){ $array[$i] = $array[$i-1]; $i--; } $array[$i] = $temp; } } else if ( $direction == "desc" ) { for($j=1; $j < $max; $j++){ $temp = $array[$j]; $i = $j; while( !empty($array[$i-1]) && ($i >= 0) && ($array[$i-1][$index] < $temp[$index])){ $array[$i] = $array[$i-1]; $i--; } $array[$i] = $temp; } } return $array; } ?>
|
# ? Jun 16, 2008 19:04 |
|
iamstinky posted:I am trying to implement a reversible sort a 2d array by an arbitrary key in the second level function. I have to question where you're getting the data from that you would need to sort it in php?
|
# ? Jun 16, 2008 22:35 |
|
iamstinky posted:I am trying to implement a reversible sort a 2d array by an arbitrary key in the second level function. php:<? /** * sortMultiArray * * Input: a 2-dimensional array, where the all the 2nd-dimension elements have a common field name (e.g. 'name') * It will sort the array based on a specific field name. * E.g. if the array contains many arrays like ('name'=>..., 'address'=>...) * then calling sortMultiArray($arr, 'name') will return the array sorted by name. * The key of the main array is not retained. * * @param array $arr - Array to sort * @param string $field - field name to sort on * @param boolean $reverse - Reverse sort order. false (default) - ascending, true - descending * @param string $function - name of the sorting function. (strnatcasecmp is default). To pass in a static class * method (a non-static class method is not permitted), use the form 'StaticClass::methodname'. * @return array - the sorted array. */ function sortMultiArray($arr, $field, $reverse=false, $function=null) { $rev = ''; if($reverse) { $rev = '-'; } if(!$function) { $function = 'strnatcasecmp'; } $function_def = 'return '.$rev.$function.'($a[\''.$field.'\'],$b[\''.$field.'\']);'; $function = create_function('&$a,&$b',$function_def); usort($arr, $function); return $arr; } ?>
|
# ? Jun 16, 2008 22:40 |
|
Can someone recommend a good library/script for generating captchas? I'm using a comment module for Joomla that I like, but has a really simple captcha generator and I'm starting to get a lot of spam. It would be really easy to just replace the captcha generation script, so that's what I'm gonna do. Any recommendations?
|
# ? Jun 16, 2008 22:44 |
|
I'm having a problem using the php mail() function. I've been googling and experimenting for two days trying to figure it out to no avail. Basically, I'm unable to send an email using the mail() function. The interesting part is that our company website (which we bought from a third party) uses the function and it works just fine. To make matters even more fun, my code works on another webserver. I've checked the php.ini sections on mail, and there dont seem to be any relevant differences. Here is the relevant part of the company website that works: code:
code:
|
# ? Jun 16, 2008 23:37 |
|
|
# ? May 15, 2024 03:31 |
|
dancavallaro posted:Can someone recommend a good library/script for generating captchas? I'm using a comment module for Joomla that I like, but has a really simple captcha generator and I'm starting to get a lot of spam. It would be really easy to just replace the captcha generation script, so that's what I'm gonna do. Any recommendations? Anything you roll on your own will likely be easy to defeat, use reCAPTCHA instead. They provide sample code and libraries to help integrate it.
|
# ? Jun 16, 2008 23:48 |