php

How to extract Twitter username from Search API via PHP

The Twitter Search api returns results in ATOM/XML format which look like this: <author> <name>username (Friendly Name)</name> <uri>http://twitter.com/username&lt;/uri&gt; </author> In my PHP I can get the name field as a variable, so it would look like this: $names = "username (Friendly Name)" But I want to use PHP to extract ...

Simple file upload/download manager for distributing files

I am looking for a simple, standalone file download solution in PHP for a company located in a rural area (slow internet connection) to distribute files to be downloaded by customers, press contacts, the printers', and so on, through their website which is hosted in a data center elsewhere. The perfect workflow would be: Admin users ...

Every pages needs a HEAD with lots of stuff: Is my framework design good?

I came to a point where I realized that I need an intelligent solution for this problem. In my framework, there are: Views (actually just HTML files with little PHP to output data) View Controllers (create views, do some logic) So for every page like http://stackoverflow.com/questions/ask for example, I have an ViewController which ...

How to set current user in View?

I am using Zend Framework. I want the current user (if logged in) to always be available to the view. In my Bootstrap.php file I currently have: function _initViewHelpers() { $this->bootstrap('layout'); $layout = $this->getResource('layout'); $view = $layout->getView(); // <snip> $view-> set some stuff $v...

date() and strftime() not same on windows and Linux. Why?

Why are some options to date() and strftime() not supported on windows? I though anything related to date is something that every system should support. Is it because of the way the date is internally stored? ...

PHP form tokens

I'm a learner working on a login script. This is the form token statement that I have so far: $_SESSION [ "form_token" ] = md5 ( rand ( time (), true ) ) ; The statement is issued just after the user indicates that he/she wants to login. My limited understanding is that its purpose is to identify a unique user at a unique point in t...

domdocument load errors. How to test for.

I'm using domdocument load to fetch some data. On occasion, this data is not available and when the script runs, I will get errors or warnings. I noticed that I can test for a return value if the data is not there. Is it best to use a while loop or an if statement? ...

Ads in a PHP based webpage

Hi.. We all have come across web pages which take some time to show the content the user is waiting for and in the mean time display ads on the page. I'm not talking about the pages that show full-page ad with 'skip this ad' button. A typical example of what I'm referring to is: I visit a free plugin site. Click on the plugin I want t...

looking for a db abstraction/substitute that actually works

i am looking for a form of data storage that will answer a few requirements. i realize these requirements are non-standard, and for now i'm using activerecord and ORM solutions like everyone else, but this is my "holy grail" - if you know of anything like this, i would be eternally grateful: pure PHP multiple repositories, preferably f...

How does PHP Work?

We have all seen many question on StackOverflow that are founded upon the idea that PHP works like Javascript. Where the person clearly does not understand that PHP is a Preproccessor and only works before the page is sent out. A clear example of this is in the following code, where runCommand() will not run when the user presses the b...

Call URL with wget and return an ERRORLEVEL depending on URL's contents

A client has a Windows based in-house server, on which they edit the contents of a CMS. The data are synchronized nightly with the live web server. This is a workaround for a slow Internet connection. There are two things to be synchronized: New files (already sorted) and a mySQL database. To do this, I am writing a script that exports ...

MySQL database orginization and PHP select

I am setting up a MySQL database and will be querying it with PHP. Is is better to break the information up into multiple tables and do select queries on each of the tables; or is it better to put all the items in one table and do a single select query? For example: It will hold information on upto 7 cars; which would mean that their ...

Zend PHP Class Variable retention for mysql queries

I have a flash application which uses a single php file to retrieve records from a database (using the Zend framework). When the application first begins, I make a call to the php to set a class variable, so that all future requests to the database will use this variable to select records based on its value. So here is how the class begi...

Regex, get string value between two characters

Howdy, I'd like to return string between two characters, @ and dot (.). I tried to use regex but cannot find it working. (@(.*?).) Anybody? ...

Which of these OOP options should I use?

I have two classes ClassA and ClassB. ClassA always needs an template file name, and ClassB extends ClassA. In usual cases when a ClassB instance is created, the user has to specify the template file name. Like: $classB = new ClassB('index'); But now I created a ClassX which extends ClassA, and when the user uses ClassX, he must not ...

pg_connect takes longer than 5 seconds!?

Hello, I have just setup a OpenBSD little personal development server running PHP with an almost-default(enabled debugging messages) php.ini and installed PostgreSQL with the default configuration. Well, running this very simple code $starttimer=time()+microtime(); $dbconn = pg_connect("host=localhost port=5432 dbname=earlzblog_001 us...

Streaming local file from PHP while it's been written to by a CURL process

I am creating a simple Proxy server for my website. Why I am not using mod_proxy and mod_cache is a different discussion. Here's the code: shell_exec("nohup curl --create-dirs -o {$write_path} {$source_url} > /dev/null 2> /dev/null & echo $!"); sleep(1); $read_speed = 65.5; # 65.5 kb/s download rate $handle = fopen($wri...

stat() and ampersand operator

I've been studying WordPress source code that operates on the filesystem, when I hit these few lines and I'm really not quite sure what they do? $stat = stat( dirname( $new_file )); $perms = $stat['mode'] & 0000666; @ chmod( $new_file, $perms ); ...

Drawing in Flash using PHP

Hi, Is it possible to draw shapes in a flash animation at runtime through PHP? If so, how can this be achieved? ...

Control SVN users with PHP Subversion API?

Is it possible to create/delete/modify SVN users with the SVN PHP API? Thank you. ...