php

Using new languages in an Apache/PHP/JavaScript world

I am stuck in a MySQL/Apache/PHP/JavaScript world. Is it possible to stay inside that stack yet incorporate other languages and technologies to advantage and increase interest? The idea is to still serve pages with PHP, but they might have been made with another technology or the JavaScript might have been built with a tool rather th...

How can a while() loop not stall when using fsockopen() and fgets() in PHP?

This is the basic connection code for a small PHP IRC bot. The problem is that it seems that the while() loop does not progress beyond fgets() until it receives data from the IRC server. I want the while() loop to iterate regardless if the IRC server has not yet sent data. Is this possible? $socket = fsockopen($config['irc_server'], $co...

YouTube Gdata API retrieving favorites using $yt->newVideoQuery

Maybe that's a somewhat uncommon question but here we go. Here's the code $userName=("Google"); $yt = new Zend_Gdata_YouTube(); $query = $yt->newVideoQuery(); $query->setAuthor($userName); $query->setMaxResults(3); $query->setStartIndex(2); printVideoFeed($yt->getVideoFeed($query)); And it works fine. But my client want to include hi...

Change Module Name in Zend Framework

ZF 1.9.6 Trying to change the module based on the user agent of the request. When I try to get the request object from the Front, I get NULL. Currently I'm trying to set the module name from the Bootstrap _initModule method I created. $front = Zend_Controller_Front::getInstance(); $request = $front->getRequest(); // This is NULL $reque...

How is HttpSession implemented?

I just finished taking a final exam on web applications. Capping off what had been a rather easy (albeit lengthy - 12 pages) exam was a question asking us to code an implementation of sessions, similar to that done by javax.http.HttpSession. I hate to admit, it stumped me. I cranked out a rather BS implemetation using a HashMap and did...

PHP: How to turn an array into a StdClass object?

Is there a PHP function that will do this automatically? if (is_array($array)) { $obj = new StdClass(); foreach ($array as $key => $val){ $obj->$key = $val; } $array = $obj; } ...

Drupal External Authentication

I have a cURL PHP script which is able to validate a username/password against the external source. What is the best way to integrate this as a login requirement for (select) users in Drupal? ...

PHP: What does this error mean? Abstract method must be compatible?

I have an abstract class. I'm extending that class. I'm getting this error: Fatal error: Declaration of Default_Model_FoobarMapper::_setClassVarsFromRow() must be compatible with that of Default_Model_AbstractMapper::_setClassVarsFromRow() in /location/to/models/FoobarMapper.php on line 3 What does this usually mean? Update: Found ou...

Database "validation" PHP

Hi everyone, I'm trying to validate the password entered by the user with the password in the database. I've worked out that it checks the username fine (if the username doesn't exist it displays an error), however when it tries to validate the password with the mysql password it never works. The working 'example' is at http://scaperscle...

Convert an image color/hue using PHP GD library. The Catch? It has rounded corners

I'm writing code this week to dynamically change the color of images. As long as the image is square or rectangle, the code below works perfectly. However, I have an image that has rounded corners (filled with a spot color and the background outside the corners is white.) Can someone tell me if there's a simple way to color an image tha...

Drupal Custom Login by Role

I have a cURL PHP script which is able to validate a username/password against the external source. What is the best way to integrate this as a login requirement for (select) users in Drupal? The idea would be to add the external authentication as a login requirement for a role. ...

Mark the top N elements of an unsorted array.

I have an unsorted array (of generated die rolls), and I want to select the top N elements of it (which is trivial with sort-and-snip), but mark them while keeping them in order. E.g.: mark([1,2,3,4], 3) ==> [[1, false], [2, true], [3, true], [4, true]] mark([3,5,2,6,2], 3) ==> [[3, true], [5, true], [2, false], [6, true], [2, false]]...

Naming form fields in a web page

How do you name your field names in a web page without revealing the structure of your database tables? ...

Can a PHP app run when email is sent?

Is there a way to configure a server or a script to execute a php script when an email is received? In theory this could be extended to other protocols, such as XMPP or SMS, etc. What I have in mind is a user could send a message to [email protected] and this would trigger a script which would then do whatever needed to be done, ...

Using JQuery and PHP Session to remember users' array

I'm a designer who dabbles in scripting using JQuery and PHP. I have a pretty good understanding of functionality in both but using sessions is new to me. I have an app with a search feature. The search results may stretch over several pages and each result has a checkbox. The idea is the user goes through the results and checks off ite...

save user actions?

i want to save logged in users actions so when they visit the page again they don't have to do the same thing again eg. what list values they chose or what page they were on before they logged out. i dont want to save it as cookies because i want them to be unchanged even if he switch computer. should i save these kind of information in...

Getting data is fast, but Flash displaying php data is slow, why?

In my database(mysql), I have a table which has 50k data(rows/records). I do a test using firebug, after playing the game, the call to load_score.php and save_score.php is around 380ms (millisecond). The save_score.php just a normal inserting, nothing much. The load_score.php, I use this query: SELECT name, score FROM `highscores` WH...

phpunit xml file (phpunit.xml)

i am picking up phpunit. i am at the phpunit.xml file. i want to understand what does each element do. <testsuite name="application"> <directory>application</directory> </testsuite> the directory refers to the dir containing all the *Test.php files? <filter> <whitelist> <directory suffix=".php">../application</dir...

create session with jquery?

is it possible to create session variables with jquery or javascript or do i have to use ajax to call a php that does that? ...

PHP GET variable array injection

I've recently learned that it's possible to inject arrays into PHP GET variables to perform code execution? .php?a[]=asd&a[]=asdasd&b[]=$a That was the example I was given. I have no idea how it works and was wondering if this is even possible? ...