php

Matching UTF Characters with preg_match in PHP: (*UTF8) Works on Windows but not Linux

I have a simple regular expression to check a username: preg_match('/(*UTF8)^[[:alnum:]]([[:alnum:]]|[ _.-])+$/i', $username); In local testing (Windows 7 using WAMP), this will allow for usernames using UTF characters (such as é or ñ). However, when I move to test this on the server where the site will actually be hosted, I get the f...

How to include javascript from a CDN source using smarty

How do you include Javascript from a CDN source using Smarty? We have code such as the following for including it from a file on the web server, but I want to include it from a CDN instead. {javascript file="prototype.js" priority=20} When I access the Smarty documentation at http://www.smarty.net/manual/en/ "javascript" cannot be ...

Trouble setting up the Zend_Loader_Autoloader. Pretty easy question, but I'm new to Zend Framework

Read the comments in the code for a description: <?php class Bootstrap extends Zend_Application_Bootstrap_Bootstrap { public function __construct($configSection){ $rootDir = dirname(dirname(__FILE__)); define('ROOT_DIR',$rootDir); set_include_path(get_include_path() . PATH_SEPARATOR . ROOT_DIR . '/libra...

Password protect an entire directory with PHP authentication

I want to password protect an entire directory and authenticate users though a MySQL database using PHP. I know you can password protect directories using .htaccess but I can't seem to find out how to use PHP and MySQL along with that. ...

PHP & SELECT how to?

I want to show what the user($pusername) have been posted, in member_film, member_meetups, member_tutorials.. And then if e.g the user have 2 columns with his username, i want to display the "navn" from the same column. Same with title on member_tutorials, and meetup on member_meetups. An example on how i want it to look like: Your pos...

Where in my .phtml file do I tell it to 'use' the layout.phtml file I made?

I'm kind of lost. I made a sort of 'master page' that I want a page to use. Where do I declare it? MainLayout.phtml <html> <head> </head> <body> <?php echo $this->layout()->content; ?> <div> <ul> <li><a href="#">Navigation</a></li> <li><a href="#">Naviga...

How does youtube have URL's like these?

YouTube has URL's like these: http://www.youtube.com/watch?v=zKqeCtjFGFc When I create a PHP page mine would be like these: watch.php?v=zKqeCtjFGFc How does YT hide the PHP extension, and I know YT is probably written in Python or something other than PHP but I have seen this done in WordPress and other PHP written apps. Can this be...

Search for text with php

How would I scan a directory for a specific line of text and list all matching files with php? Thanks. ...

MySQL delete from 3 tables

Hi There, I have the following tables, with these keys in my database: bookings session_id sessions session_id course_id courses course_id I want to create a query to delete all date relating to a single course (course_id). For example if I wanted delete course_id=10, I would want any sessions with course_id=10 to be deleted, in add...

How to redirect users based on browser language

I want to redirect users based on browser language, I figured out how to do this here, it works fine, here is the code(PHP): if(preg_match('/en-US/', $_SERVER['HTTP_USER_AGENT'])) header("location:index.php"); else header("location:http://cn.gearor.com"); The problem is I only want to redirect users from other websites or at t...

Need to Base64 Decode This String

I tried decoding this base64 string so many times but every time i get some parts that decode fine but other parts are all gibberish, can anyone help me ? PD94bWwgdmVyc2lvbj0iMS4wIj8_DQo8cm9vdD4NCgk8YTQ2Nzg2NT4NCgkJPHQ_DQoJCQk2DQoJCTwvdD4NCgkJPHU_DQoJCQlodHRwOi8vbWlsbGVkcml2ZS5jb20vdmlkZW9zLzQxODQxL1NodXR0ZXJfSXNsYW5kXzJfMi5odG1sDQoJCT...

Redirect with a variable

I re-did my portfolio site recently, and I'm trying to make it so that when someone clicks a link to my and old project (ie /philosophy.php) that it takes the name of that file (philosophy) and then adds it to an id indicator # and loads to my new page with that ID selected so it automatically scrolls to that project. Click link > http...

MySQL Syntax Error; "check the manual that corresponds to your MySQL server version.."

I've been looking all over the internet for a solution to the following error; "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'primary, username, password, password2) VALUES (null, 'hello', 'hello', 'hello')' at line 1" I have no idea what is going...

best method to stop users posting urls

I am looking to implement a system to strip out url's from text posted by a user. I know there is no perfect solution and users will still attempt things like: www dot google dot com so I know that ultimately any solution will be flawed in some way... all I am looking to do really is reduce the number of people doing it. Any suggesti...

"Admin module" taking over [Yii framework]

Hi I have an "admin" module and I want it to serve "dynamic controllers", i.e. to provide a default behaviour for controllers which don't really exist ("virtual controllers"). I've invented a lightweight messaging mechanism for loose communication between modules. I'd like to use it such that when e.g. ?r=admin/users/index is reques...

PHP tree implementation: Accessing parent node

I have an own Tree object implemented in PHP. Say we have a tree like: Root |_ Folder 1 |_ Folder 2 |_ Subfolder 1 I can access Subfolder 1 like this: $sf1 = $Tree->NavigateTo("Folder 2/Subfolder 1") And $sf1 will hold the Subfolder 1 node. I want to implement a GetParentNode() method, so that $parent = $sf1->GetParent...

PHP preg_match_all returns nothing

I am trying to extract all img tags from an HTML string. See the code $d1 = file_get_contents("http://itcapsule.blogspot.com/feeds/posts/default?alt=rss"); preg_match_all('/<img[^>]+>/i',$d1,$result); print_r($result); And the result is Array ( [0] => Array ( ) ) But the same regex gives correct result in an online regex test...

Allow hotlinking but redirect when I am my own referrer!

Hey I want to, using htaccess, allow hotlinking BUT if someone views an image on my site I want to redirect them to a "hosted" version of the image where I display my navigation etc. So essentially anyone hotlinking from an external site will not be affected but if someone views the image on my server directly i.e. www.domain.com/image...

Implementing Recursive Comments in PHP/MySQL

I'm trying to write a commenting system, where people can comment on other comments, and these are displayed as recursive threads on the page. (Reddit's Commenting system is an example of what I'm trying to achieve), however I am confused on how to implement such a system that would not be very slow and computationally expensive. I imag...

Email validation in PHP

Possible Duplicate: Is there a php library for email address validation? Hi there, I was just wondering if any of you use a particular public script or set of functions for dealing with email validation in PHP. The built-in PHP function isn't really anything to brag about. Thanks for your time. ...