php

JavaScript (or JS+PHP) Terminal Client

Does anyone know of a JS-based terminal client? Either something that initiates an SSH connection with a remote host or even something that simply communicates with a remote PHP script to execute commands and retrieve output. Does such a thing exist? ...

How do I gzip my web files

As prescribed by Yahoo!, gzip'ng files would make your websites load faster. The problem? I don't know how :p ...

Is it possible to pass parameters by reference using call_user_func_array()?

When using call_user_func_array() I want to pass a parameter by reference. How would I do this. For example function toBeCalled( &$parameter ) { //...Do Something... } $changingVar = 'passThis'; $parameters = array( $changingVar ); call_user_func_array( 'toBeCalled', $parameters ); ...

PHP SimpleXML. How to get the last item?

How would I get the last item (or any specific item for that matter) in a simplexml object? Assume you don't know how many nodes there will be. ex. <?xml version="1.0" encoding="UTF-8"?> <?xml-stylesheet type="text/xsl" href="/xsl.xml"?> <obj href="http://xml.foo.com/" display="com.foo.bar" xmlns:xsi="http://www.w3.org/2001/XM...

A PHP hash function with a long output length?

Inside my code I'm generating hashes of URLs, (which are practically of unbounded length). I'm currently using sha1(), which I know has a tiny chance of a collision, but I have up to 255 bytes to store the hash in so feel that I might as well use that available space to lower the chance of collision even further. Is there either: Ano...

Why is PHP Doctine's free() not working?

This is one is for any of you Doctrine users out there. I have a PHP CLI daemon process that checks a table every n seconds to find entries that haven't been processed. It's basically a FIFO. Anyways, I always exceed the memory allocated to PHP becuase Doctrine does not free it's resources. To combat this problem it provides free for...

what does this preg_replace_callback do in PHP? and how do I stop it leaking memory?

I've got a section of code on a b2evo PHP site that does the following: $content = preg_replace_callback( '/[\x80-\xff]/', create_function( '$j', 'return "&#".ord($j[0]).";";' ), $content); What does this section of code do? My guess is that it strips out ascii characters between 128 and 256, but I can't be sure. Also, ...

Help with XML-RPC server

Hello, I'm now trying to create a xml-rpc server with the CodeIgniter Framework. <?php $this->load->library('xmlrpc'); $this->load->library('xmlrpcs'); $config['functions']['weblogUpdates.ping'] = array('function' => 'weblogUpdates.ping'); $config['functions']['ping'] = array('function' => 'weblogUpdates.ping'); $config['functions']['...

ajax displaying code instead of result

Hello, I have a basic ajax application, which will not work, instead the php code is displayed in the browser. The javascript and html seem fine. I have copied the code verbatim from here: http://arief.aeroven.com/2008/07/30/first-ajax-script-tutorial-connecting-ajax-contain-pure-htmlphpand-javascript-to-mysql-database/ and this is th...

Stateful PHP Web Service Using SOAP

I'm trying to implement a stateful web service in PHP using the SOAP extension. (Yes I know that web services are supposed to be stateless; all I really care to persist is some form of a session ID so I don't need to authenticate with every call to the service). PHP.net's API documentation is somewhat lacking on this, and there isn't mu...

Can you generate a migration from an existing table with Doctrine?

Is it possible have a migration script automatically generate from a table schema in Doctrine? For example, during heavy development of new features, I will oftern build out my tables first while writing the initial code. I usually don't create a migration to start because the definition of the table may change as the feature is still ...

PHP $_GET parameter is not populated, even though URL has appropriate form

I'm working on a new Wordpress site that is exhibiting some strange behavior. I pass it a URL with GET parameters in it, and the $_GET parameter is not populated. I see in the $_SERVER parameter that the REQUEST_URI has the full URL there, completed with the ?var=value part, but no love in the $_GET variable. The URL is being redirect...

How do RESTful and SOAP Web Services differ in practice?

I am implementing web services for a PHP application and am trying to understand what both standard web services and RESTful web services have to offer. My intent is to write wrapper code to abstract away the web service details so that developers can just "instantiate remote objects" and use them. Here are my thoughts, perhaps some of ...

Getting the name of file in PHP

How can I get the name of a file in in PHP? What I want to do is have a function take a string of a filename and then do some stuff if it's actually on the page. function onThisPageFunction(fileNameFromFunction) { if(onThisPage == fileNameFromFunction) { do stuff } } ...

backing up a huge mysql table using php and a cronjob

I'm working on developing a regular dump of our database. I'm using this script to create the backup and then feeding it through a regular cron job. In the end we end up with a text file as well as an email archive of everything. The problem we've encountered is the size of two of our tables. They each have 60k fields and grow daily. ...

Simplest way to detect client locale in PHP

I would like to be able to detect what country a visitor is from on my website, using PHP. Please note that I'm not trying to use this as a security measure or for anything important, just changing the spelling of some words (Americans seems to believe that the word "enrolment" has 2 Ls.... crazy yanks), and perhaps to give a default o...

How do you output contents of an array as a comma separated string?

I would like to convert an array if IDs, into a string of comma separated values, to use in a MySQL UPDATE query. How would I do this? ...

Is it really not possible to write a php cli password prompt that hides the password in windows?

I have spent several hours trying to find a means of writing a cross platform password prompt in php that hides the password that is input by the user. While this is easily accomplished in Unix environments through the use of stty -echo, I have tried various means of passthru() and system() calls to make windows do the same thing to no ...

Can FPDF/FPDI use a PDF in landscape format as a template?

I am trying to import an existing PDF as a template with FPDI. The template is in landscape format. If I import the template into a new document the template page is inserted in portrait form with the content rotated 90 degrees. If my new document is in portrait the full content appears, but if the new document is also landscape, the ...

Simulating a cookie-enabled browser in PHP

How can I open a web-page and receive its cookies using PHP? The motivation: I am trying to use feed43 to create an RSS feed from the non-RSS-enabled HighLearn website (remote learning website). I found the web-page that contains the feed contents I need to parse, however, it requires to login first. Luckily, logging in can be done via ...