php

PHP How To Send Raw HTTP Packet

I want to send a raw http packet to a webserver and recieve its response but i cant find out a way to do it. im inexperianced with sockets and every link i find uses sockets to send udp packets. any help would be great. ...

Figuring out which page is calling a piece of JavaScript, in PHP.

I have a PHP file that generates a JS file, that is being included on a number of sites. I'd like to be able to check which site the file is being included from on each request. I tried using $_SERVER['HTTP_REFERER'] in PHP, but that just returns the domain that the JS file is hosted on. Any ideas would be greatly appreciated. ...

Session hijacking or attack?

Lately I have seen this in my error log (1 per day, and I have 40k visitors per day): [22-Sep-2009 21:13:52] PHP Warning: session_start() [function.session-start]: The session id contains illegal characters, valid characters are a-z, A-Z, 0-9 and '-,' in /var/my_files/class.session.php on line 67 [22-Sep-2009 21:13:52] PHP Warning: Unk...

PHP best way to search a string for values in an array?

Hello,, I have a string and an array, the array contains all kinds of parts of a string I want to find in the original string (this is for basically reading a error log and identifying what line there is a "Could not find", or "Error", etc.) Is the foreach preg_match the best method? ...

PHP Class Scope issues

Below is a very basic example of the trouble I am having. Now why must I use $session = new Session(); in the database.class.php file when in my system the files are included in a way that it would be visible already. In other words I cannot call $session = new Session(); outside of any other classes, to make it work in other classes...

Add exception to recurring event using google calendar api in PHP

Using the Zend Gdata Calendar classes, how can I add an exception to a recurring event? $orig = $evtFeed[0]; //the original recurrence $ex = $gc->newEventEntry(); //gc is a Zend_Gdata_Calendar object $ex->originalEvent = $gc->newOriginalEvent($orig->getId(), $orig->getLink('self')->href, $gc->newWhen('2009-09-23T15:00:00.000Z')); $ex->...

Merging multiple PHP script into a single file

I have a PHP script which includes one or two other libraries it depends on using the 'include' statement. To make it more easily portable, I would like to somehow 'compile' the script and the included libraries it into a single PHP script (in the same way that ack includes all its Perl dependencies in one file). Is there an easy way to ...

Is it better to implement a FORM and its ACTION with a single PHP file or two files?

I'm creating a FORM with PHP for an intranet webpage. Another PHP script is called by submitting the form. Before anyone asks, the form does not allow any uploads, and although the values entered in the form find their way into an SQL query, I strip out everything but numbers. I'm wondering if there would be a advantage in using the s...

CakePHP pagination with HABTM models

I'm having some problems with creating pagination with a HABTM relationship. First, the tables and relationships: requests (id, to_location_id, from_location_id) locations (id, name) items_locations (id, item_id, location_id) items (id, name) So, a Request has a Location the request is coming from and a Location the Request is going t...

isolating a match with regular expressions and PHP

Hi all still struggling with regex :) i have this code: $link = '/\bhttp:\/\/.+\..+[\/\w]?\b/i'; $match = array(); if (preg_match($link, 'http://bit.ly/hghjK6 bla bla',&$match)) { echo 'match'.'</br>'; print_r($match); } as i'm trying to extract only the URL from the string i cant isolate it and the value inserted into $match ...

How to password protect a directory but still give users access

I am creating a PHP script for my website that would allow my clients to login to their client account and view a list of files I've uploaded for them. Then they can download them without having to relogin or re enter a password. I want to keep it secure so anyone cant come in and download the files if they know the clients name. I've ...

How can I initiate a PHP class and use it in several files?

I am stumped right now. In my last post about this question the answer was to use a singleton to make sure an object is only initiated 1 time but I am having the opposite problem. If I have a file called index.php and then I include these files into it, class1.php, class2.php, class3.php, class4.php. In index.php I will have, <?PH...

interfacing erlang application with php

Hi, I have a website built with PHP. I have an Erlang application running as a daemon on the same server. I need to call functions on the Erlang application from PHP and get back the result. I've found PHP/Erlang and over PHP modules but I can't install a PHP module on this server, I can only use PHP code. The only way I know to solve...

How can I use PHP to dynamically publish an ical file to be read by Google Calendar?

Any Google search on PHP ical just brings up phpicalendar and how to parse or read IN ical files. I just want to write a PHP file that pulls events from my database and writes them out in ical format. My problem is I can't find anywhere that will answer two questions: What is the exact ical format, including headers, file format, foot...

wordpress how to add another page?

hi im using the newest version of wordpress version 2.8.4 im wondering how i would add an additional page. i have a navigation that looks something like this. home | about us | contact us | ... etc. i read somewhere to go to pages -> addnew but it forces me to put the content within wordpress rather than edit a php file itself. how ...

Merging php arrays if "clientid" is identical?

Hi all, I have a query which gives back an array, I'd like to be able to merge the array values which have the same "clientid" Here's my query: SELECT * FROM #__db_clients_trip WHERE clientid IN (1999, 2984, 1681) AND companyid IN (1,2) Here's my array: stdClass Object ( [id] => 61 [trip_code] => EUR0600 [clientid] => 19...

$_get/htaccess question (php)

I'm trying to make it so that $_session['kw']=$_GET['kw']. If I use the url index.php?kw=example, then when i echo $_GET['kw'] i get a blank. Is there anything that would cause $_GET to not work? I figured out that it must be caused by the .htaccess file there are rewrite rules in there that go like this: RewriteRUle ([-a-z0-9_]+)_re...

singleton inside of a construct method in PHP?

Is it ok to use a singleton method inside of a __constructor to initiate the class if it wasn't already? ...

Unit Testing With SimpleTest in PHP keeping getting file directory errors from relative paths?

I am using Zend Framework MVC and unit-testing with SimpleTest library. I have a specific model that keeps failing because it uses Zend Cache and the cache directory is a relative path I was wondering if anyone has seen a problem like this b4. Thanks. ...

Non-blocking HTTP requests in object-oriented PHP?

I have a PHP client application that is interfacing with a RESTful server. Each PHP Goat instance on the client needs to initialize itself based on information in a /goat request on the server (e.g. /goat/35, /goat/36, etc.). It does this by sending an HTTP request to its corresponding URL via cURL. Working with 30+ goat objects per page...