php

returning to php after 4 years; looking for Current Best Thing

I'm getting back into web dev after a four/five year hiatus. I was wondering what you folks think the Current Big Thing™ is in PHP dev; i.e., if I'm going to try to put myself back in the game after a break, what should I brush up on? I heard that the model/view/controller method of development is getting popular in php, using Zend Frame...

PHP function to get the date format?

I know how to use date format strings, to turn date('Y/m/d H:i:s'); into 2009/12/18 11:37:45. I would like a function that can do the opposite - look at a formatted date then return the format. Is there one in PHP? The reason is we have timestamps saved in our database in a variety of formats and I am writing a tool processing all of ...

how to create a secure php login system, allowing for "keep me logged in" functionality?

hello, I use a simple login system based on SESSION vars. Once the user logs in, a session var is set that tells my script the user is to be accepted in. I don't use any custom clientside cookie var. I would like to offer the option on the login screen that says "keep me loggued in the whole day". How does one do that in a secure way? ...

Getting row data of inserted row (Mysql, PHP, mysqli)

I need to get back the postid (auto-incrementing PK) of a row when i insert it. I am currently using this to get it //get postid to return if($result = $db -> query('SELECT postid FROM posts WHERE title = \''.$title.'\' LIMIT 1')){ $row = $result->fetch_assoc(); $json['postid'] = $row['postid']; $result->free(); where $title ...

Zend Framework (Twitter Search) JSON problem since_id

I'm using Zend_Service_Twitter to run a Twitter search and return json. I'm having a problem with the since_id values I'm getting back. When I print_r() the search results, I get back the following: ... [since_id] => -2017847207 [refresh_url] => ?since_id=6801825835&q=myTwitterSearchQuery ... The [since_id] value is different to the...

Codeigniter first time user

I need a way to tell if it's a user's first time to log in--so I can display relevant information to that user about what they need to do. How can this be achieved? I'm at a loss here and examples would be appreciated! :) ...

Why doesn't DOMXPath work?

I've been trying to write a PHP script to parse an XML document using DOMXPath; however it seems I'm missing something because none of my XPath queries are returning anything. So I've tried to water down my script to try and parse a very rudimentary XML document, and that's not working either. I've based this script off of this XPath exa...

mail server log - is this possible?

Hello, We have a main email account where I work (info@) that at least 4 people receive. Occasionally, someone screws with the outlook settings and makes it start pulling the emails off the server instead of downloading a copy. However, this time, a few emails came through on a couple computers, but didn't come through on one. Then I ch...

Injecting Criteria into an sfPropelRoute object

I have a Page object whose uniqueness comes from its PageDomain. The schema is configured such that the page table contains a page_domain_id field to create the relationship. To show a page, I have an executeShow action and a custom handler. My route looks like this: page_show: url: /:domain_slug/:slug class: sfPropelRoute o...

problem with facebook api - Keeps redirecting

I created an application with a name and connect URL on facebook. I put below code in test.php here (test.php): include_once 'facebook.php'; $fb = new Facebook('api_key', 'secret'); $user = $fb->require_login(); echo $fb->api_client->user; echo $fb->api_client->session_key; when I go to that page, it takes me to facebook login,...

iPhone pushNotification DeviceToken - How to "decrypt"

I've already managed to get the devicetoken from APNs. It's type of NSData. So i want to write this deviectoken into my mysql db. I've already tried to convert it to a string without luck. That was my way: NSString *tokenTMP = [[NSString alloc] initWithData:devToken encoding:NSASCIIStringEncoding]; If i have the deviceToken in a rea...

How to strip unicode chars (LEFT_TO_RIGHT_MARK) from a string in php

I'm trying to remove LEFT-TO-RIGHT-MARK (\u200e) and RIGHT-TO-LEFT-MARK (\u200f) from a string before encoding it as JSON. Neither of the following seems to work: $s = mb_ereg_replace("\u200e", '', $s); $s = preg_replace("#\u200e#u", '', $s); $s = preg_replace("#\u200e#", '', $s); Any help is appreciated! ...

[PHP] How to sort arrays inside an array?

Hello there, I need to sort arrays inside an array of array based on one of the array's array value. For example: $data = array( array( 1, "Article One", 132, 12402773, 3 ), array( 2, "Article Two", 251, 12519283, 5 ), array( 3, "Article Three", 107, 12411321, 3 ), array( 4, "Article Four",...

Why does fsockopen have performance problems and not fopen when sending a POST request in PHP?

I have tried two different implementations for simulating POSTing a form. One uses fsockopen (example here: http://www.faqts.com/knowledge_base/view.phtml/aid/7962) and the other uses fopen (example here: http://netevil.org/blog/2006/nov/http-post-from-php-without-curl). I ran into some serious performance problems with fsockopen - whe...

[PHP] Mystery, variable path name

This works: function upload($directory) { App::import('Vendor', 'UploadedFiles', array('file' => 'UploadedFiles.php')); echo $directory; $this->_saveUploadedFiles('C:/xampp/htdocs/freetickets/app/webroot/img/gallery/zantje_11042/'); } function _saveUploadedFiles($galleryPath) { $absGalleryPath = $galle...

Variable Content Streaming in PHP

I wrote a toPdf class in PHP that has the ability to stream it to the browser. If the file is not marked as savable, I need to perform clean up after I stream it. Since that is not possible, I'm wondering if there is a way to read the file into a variable, perform my clean up, send the headers, then start the file steam? Thanks! ...

Convert a complicated string into an array in php

I have a php variable that comes from a form that needs tidying up. I hope you can help. The variable contains a list of items (possibly two or three word items with a space in between words). I want to convert it to a comma separated list with no superfluous white space. I want the divisions to fall only at commas, semi-colons or new-l...

HTML to plain text (for email)

Do you know any good HTML to plain text conversion class written in PHP? I need it for converting HTML mail body to plain text mail body. I wrote simple function, but I need more features like converting tables, adding links at the end, converting nested lists… -- regards takeshin ...

regex: converting php code from eregi to preg_match

Hi. I'm trying to find the proper regular expression to convert eregi($1,$2) to preg_match("/$1/i",$2) i need to consider if there will be functions with () in it, and they may appear more then once. can anyone please provide the proper regular expression to do so ? thanks ...

Will [a-z] ever match accented characters in PREG/PCRE?

I'm already aware that \w in PCRE (particularly PHP's implementation) can sometimes match some non-ASCII characters depending on the locale of the system, but what about [a-z]? I wouldn't think so, but I noticed these lines in one of Drupal's core files (includes/theme.inc, simplified): // To avoid illegal characters in the class, // w...