glob function problems

How come it seems php glob can only work with relative path in my site built with Yii?

I got a javascript calling a php code to return a list of image files in a directory in json format.

Javascript code (a code snippet deep in /themes/default/js folder):

		$.get('photostack.php', {album_name:album_name} , function(data) {

			var items_count	= data.length;

			for(var i = 0; i < items_count; ++i){

				var item_source = data[i];

				var cnt 		= 0;

				$('<img />').load(function(){

					var $image = $(this);




					var r		= Math.floor(Math.random()*41)-20;

					if(cnt < items_count){


							'-moz-transform'	:'rotate('+r+'deg)',

							'-webkit-transform'	:'rotate('+r+'deg)',

							'transform'			:'rotate('+r+'deg)'



					if(cnt == items_count){









PHP code (photostack.php under root):


$album_name = $_GET['album_name'];

$files = glob('images/celebrities/albums/'.$album_name.'/*.{jpg,gif,png}', GLOB_BRACE);

$encode = json_encode($files);

echo $encode;


This code works fine, but when I add multi-language to the mix, it screws up.

I have my site setup with routing rules so that is actually

In the case of, it works fine.

In the case of, the glob would try to fetch images from…, which does not exists. ( tested this by actually duplicated the image folder under a tw director, and it worked…)

I tried to use absolute path in the glob function:

$files = glob('/images/celebrities/albums/'.$album_name.'/*.{jpg,gif,png}', GLOB_BRACE);

but that breaks everything… It fetches nothing at all in all cases (not sure where it’s trying to fetch from).

Can someone shed a light on what I can do? I tried also play around with the routing rules but failed. Any help would be appreciated.

Not sure why when using absolute paths it wont fetch anything. Doesn’t really make sense.

I know. I’m a bit confused too. I’m looking to see if I can add a routing rule to make sure all tw/images/ entries can go without triggering controller/event, but really am lost on that. All example I see are how to trigger and reroute for controller/event…

I’m not very clear on how routing rules have effect on calls like glob.

or could it be something to do with the javascript calling php?

dont think it has to do with js calling php

A few observations:

On the page, a simple image tag would not work when using (but works with ?lang=tw)

$thumb = CHtml::image("images/celebrities/albums/$star->folder_name/thumb/thumb.jpg","$star->name", array());

adding the / to make image absolute works though.

and if I change the javascript from:

$.get('photostack.php', {album_name:album_name} , function(data) {


$.get('/photostack.php', {album_name:album_name} , function(data) {

then the first one of the six entries would work (it’s a loop that injects a function to onclick event into each of the six divs to fetch images from a folder using ajax).

The pages are:

I really have no clue how to go on… Anyone?