php

How can I sanitize my include statements?

How do I clean this so users can't pull pages outside of the local domain? <?php if(!empty($_GET['page'])) { include($_GET['page']); } else { include('home.php'); } ?> ...

pattern matching an array, not their elements per se

Hi I'm looking for a way of pattern matching the "geometry" of an array, the order in which the elements appear, not the contents of each element directly. Let me outline what I mean by some examples. Given the target array: array('T_STRING','T_VARIABLE','ASSIGN','T_STRING','LPAREN','T_VARIABLE','COMMA','T_VARIABLE','RPAREN'); //as a ...

Error Suppression @ Not Working

I've been happily using the error suppression operator on my PHP dev setup. But recently have gotten hit with Notices like so: Notice: Uninitialized string offset: 0 in C:\websites\xxx\htdocs\includes\myscript.php on line 35 Line 35: $file_name = @$File['file_name']; I have display_errors on, and error_reporting set to 6143 (E_AL...

Is there a solid BB code parser for php that doesn't have any dependancies?

I've got a situation where the client is using php4 and doesn't look like they heave PEAR. Is there an established php bb code parser that will work with vbulletin's bb code system? I just need to convert the bb code to html. This is a data migration from vbulletin to a new platform, so I can't use vbulletin's bb code parser. Docs: ht...

MySQL merge tables with different structure

I have two databases with different structure. Table 1: ch_code ch_def ch_weight Table 2: address ch_code I need to merge this two tables, so the structure would look like: ch_code ch_def ch_weight address The number or rows in two tables are different (table 1 has more data). Should I use merge, union.. some...

PHP File Exists Always False

I have a case where file_exists() is always returning false. My latest attempt was to just test to see if it would return true for $_SERVER["SCRIPT_FILENAME"] and then return the value of the path if it couldn't find the file which it does. The path while not necessarily relevant to solving the problem is: /Users/joe/Workspace/720/ap...

PHP Comment Code Help

Hi guys! I'm in the process of coding my very first blog. With the help of various tutorials, and other forums I have managed to gather a semi-working code. Right now I have a code that takes and displays the comment, but the problem is coordinating which comments go on which post. My current set up is all my post are HTML files, and t...

Creating html templates using PHP

Im learning a lot about how MVC frameworks work by looking around and studying existing ones. It seems that every framework I see has a layout where each method in each controller has its own template file. So there will be a login template, a logout template, register, so on and so on. My question is, how and why would you create a tem...

What's limiting my PHP resources?

I'm having a problem getting more memory out of PHP. This is the error message: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to allocate 82 bytes) in ... Yet: I've set memory_limit in the php.ini file to 32M: memory_limit = 32M; I've also tried to override it manually in the actual script: ini_set('memory_...

Get position of all matches in group

Hi Consider the following example: $target = 'Xa,a,aX'; $pattern = '/X((a),?)*X/'; $matches = array(); preg_match_all($pattern,$target,$matches,PREG_OFFSET_CAPTURE|PREG_PATTERN_ORDER); var_dump($matches); What it does is returning only the last 'a' in the series, but what I need is all the 'a's. Particularly, I need the position of ...

php only get the first occurrence of a word from an array.

Hello, I have an array of tags that I'm pulling from a database, I am exporting the tags out into a tag cloud. I'm stuck on getting only the first instance of the word. For example: $string = "test,test,tag,tag2,tag3"; $getTags = explode("," , $string); foreach ($getTags as $tag ){ echo($tag); } This would output the test...

Issue in Kohana 2.3.4 (2.4) with routing and 'Index' controller

I have: brand new clean copy of Kohana 2.3.4 (tried 2.4 RC1 also), a controller named 'index' on a Debian with Apache 2.2.9. When i type address like http://localhost/kohana/index/index i expect controller 'index', action 'index' to be executed. It works on Windows localhost, works on shared hosting. But does not on my Debian server. ...

PHP6 and its future: How to best handle Unicode in a future proof way?

A week ago there was an interesting post on the PHP-Internals list: http://marc.info/?l=php-internals&amp;m=125842046913842&amp;w=2 I've been thinking for a while what we should do about PHP6 and its future, because right now it seems like there isn't much future in it. I started getting worried about the future of PHP6 quite...

Zend Framework call view helper from a Zend_View_Helper

I have a helper called Zend_View_Helper_FormVars that's used by one of my modules. I also have a common helper in application/common/helpers/GeneralFunctions.php I'm trying to call a function from Zend_View_Helper_FormVars that's in GeneralFunctions.php Here is the sort version of Zend_View_Helper_FormVars class Zend_View_Helper_Form...

PHP/MySQL mailing list, mailer and subscription classes

I am working on a project that needs a emailable mailing list built into it with a very complex list structure. Originally I thought I could just use PHPList to do the job with some minor alterations because of its list management. But now I'm finding that I'm going to need to build this from scratch. PHPList is way to complex to make tw...

MySql PHP results.

Hi i'm working on some code with mysql and need to display the mysql results with php.. MySQL select distinct(year(Cataloged_Date)) from records; +------------------------+ | (year(Cataloged_Date)) | +------------------------+ | 2009 | +------------------------+ 1 row in set (0.00 sec) PHP foreach($query->result() ...

Calculate driving directions using PHP?

For my application I need a server to calculate driving directions. The Google Maps API was designed for clientside use only, with a Javascript and Flash API. Is there any way I can run their API's server-side? ...

Static properties in PHP

Hello everyone. When are static properties initialized, as I know other member properties are initialized when object is created. Thanks ...

Default web browser character encoding in php

Does anyone know how can I default web browser character encoding in php, which I hope all user drop in to the page with using character encoding western (ISO-8859-1) ...

Write CSV To File Without Enclosures In PHP

Is there a native function or solid class/library for writing an array as a line in a CSV file without enclosures? fputcsv will default to " if nothing is passed in for the enclosure param. Google is failing me (returning results for a whole bunch of pages about fputcsv), and PEAR's libraries do more or less the same things as fputcsv. ...