php

Trouble with regular expression for comments code

Hey I am currently making a homepage where logged in users can write comments. The comment string is first run through a function that str_replaces emoticons. After that I want it to exchange [url=www.whatever.com]linktext[/url] with: <a href='www.whatever.com'>linktext</a> The reason for this is that I want to strip the text for...

How to write a query in CodeIgniter Active Record

Hi all, I'm having some issues getting codeigniter active record to produce a query like this: SELECT fruits.* FROM fruits WHERE fruits.color = 'red' AND ( fruits.size = 'medium' OR fruits.name = 'kiwi' OR fruits.length = 7 ); Basically I want to have several or clauses but one where clause that is always enforced. $this->db->select(...

Symfony user framework design problem

Hello all, I'm looking for advice on how to tackle a design problem I've came up with. I'm currently using Symfony framework so I'll be using the names of Symfony classes. When a user becomes "authenticated" or their "credentials" change in the Symfony user class, a regenerate() gets called on the currently used storage class. The stor...

php header, internal server error

hi I coded the code bellow my self, and I get a f*ing internal server error every time, I'm getting sick and tired of this, please help: <? function doer($str) { $d = base64_decode($str); $a = explode('<||>',$d); $v =array( 'path' => $a[0], 'size' => $a[1], 'type' =>$a[2] ...

Default value of member variables

What is the default value of class member variables in PHP? Why do I often see: public static $variable = null; Wouldn't it be enough: public static $variable; ...

PHP GD: need to find out an alpha quantity

Imagine this. I have a pixel of color (255,0,0) [red]. No someone painted on it with white color with * alpha. I know the background color, I know with what color it was painted over, I need to get the alpha of the painted over color. How? So far we have: $im = imagecreatefrompng('public/images/bg-tmp.png'); // we need to find a neare...

I need a script to make input field fill the rest of the screen relative to screen size

This below code is what I have donr. I need the third input field "description" to spread into width, according to size of the screen, but I don't know how to get there: echo("<table cellspacing=\"0\" cellpadding=\"4\" width=\"100%\">\n"); echo("<tr class=\"header\" ALIGN=LEFT>\n"); echo("<th>NUmber</th>\n"); echo("<th>Descrtiption</th>...

Javascript Regular Expression to PHP

I have written this JavaScript that calculate words, but I am unable to convert this JavaScript code to PHP regular expression. Can anyone help me with following code? return str.replace(/\&\w+;/ig,"") .replace(/lt;/g, "<") .replace(/gt;/g, ">") .replace(/(<([^>]+)>)/ig,"") .replace(/^[^A-Za-z0-9-\']+/gi,...

Looking for a good example of cleanly doing PHP database sessions

Trying to use database sessions in PHP without re-inventing the wheel so I'm looking for a clean library or example that could send me in the right direction. ...

PHP Create List with Replaced characters.

Hi, I am trying to basically create a list of obscene words for a filter. I wanted to generate the list by creating arrays of characters and their replacements, example. 'A' can be replaced with '4', or "E" with "3". So basically I have a bunch of arrays for every char in the alphabet with the several different ways to replace it. EG. ...

What is the proper way to develop a custom theme/template for Magento 1.4

I have recently started working on an eCommerce site for a company and they have selected Magento 1.4.0 to run their store. I have spent most of my PHP "career" working with various MVC frameworks (even Zend with Magento is supposed to be based on) but the complexity of Magento seems to be on another level with no seemingly good resource...

DNS_GET_RECORD 'www' record?

I am using a PHP script that makes use of dns_get_record to check the A and MX records of domains. The domain is entered via a simple form. However, I'm having some issues adding 'www' to the domain variable. I would like to add an A Record lookup for www.domain.com. How do I add the www? <?php $domain = $_POST["Domain"]; $dns = d...

C# .exe upload of multiple files to PHP server - filename param?

What is the best way for a C# .exe program, to upload to a php server script that accepts file uploads. If using .NET WebClient is the only way, is there a way for WebClient to specify the parameter name, rather than just the file? For example, the C# .exe would do basically what a simple html form would do in this case. <input nam...

Parsing certain info from Yahoo! Weather RSS Feed

Hello, I'm using Yahoo! Weather RSS Feed in order to get the forecast for my town. I can parse the XML and get weather description, but then I get a result like this: <img src="http://l.yimg.com/a/i/us/we/52/11.gif"/&gt;&lt;br /> <b>Current Conditions:</b><br /> Light Rain, 18 C<BR /> <BR /><b>Forecast:</b><BR /> Tue - PM Thundershower...

Session hash does size matter?

Does size matter when choosing the right algorithm to use for a session hash. I recently read this article and it suggested using whirlpool to create a hash for session id. Whirlpool generates a 128 character hash string, is this too large? The plan is to store the session hash in a db. Is there much of a difference between maybe using...

Correct way of using wp_get_attachment_image() in wordpress

I'm looking for the correct way of using wp_get_attachment_image(). The following code: <?php $args = array( 'type' => 'attachment', 'category_name' => 'portfolio' ); $attachments = get_posts($args); print_r($attachments); ?> Generates the following result: Array ( [0] => stdClass Object ...

extjs json decode

function symbol_handler(){ fp.getForm().submit({ url:'/index.php/ajax/test_function', success:function(resp){ //how would i access attributes of the json object? } }); edit: here is the php controller, in case it is relevant. function test_function(){ $array = array( 'success' => 'true', 'msg' =>...

PHP Image Optimization

I need some ways to dynamically optimize images using PHP. Sample codes or a module would be very helpful. Thanks. ...

Php grab file information on upload

Is it possible to write an upload script in php that takes the file information(for example... a music file has the artist, album ect ect within the file information) and writes it into a database? If so how would i go abouts doing so... ...

Can't serve HTML5 video through PHP on Safari/Mac (5.0)

I'm encountering a strange bug in Safari where, when I serve MP4 video through PHP (to obfuscate the file beneath the document root with a token-based authentication system), Safari for some reason fires the <video>'s onerror event, and the video never loads (I can't get any useful information out of the event object sent to onerror — ev...