Install Apache and PHP from the installer.
Activate apache with PHP:
1. Edit /etc/profile and update the line setting PATH to read as follows:
Code:
PATH="/bin:/sbin:/usr/bin:/usr/local/bin:/usr/sbin:/opt/iphone/bin"
2a. Edit /etc/httpd/httpd.conf and modify "DirectoryIndex":
Code:
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
2b. Edit /etc/httpd/httpd.conf and add the following to the end of the file:
Code:
ScriptAlias /php /opt/iphone/bin
AddType application/x-httpd-php .php
Action application/x-httpd-php "/php/php-cgi"
3. Restart Apache by SSH’ing to the iPhone and running the following command:
Your you build your own iPhone apache/php server.
You can visit the server on your iphone at: http://127.0.0.1
REPLACE /Library/WebServer/Documents/index.html with /Library/WebServer/Documents/index.php
Make sure that this is the content of index.php:
PHP Code:
<?php
//variables
// ADD FOLDERS HERE TO VIEW HERE
// DONT FORGET TO SYMLINK THEM! (ln -s fromfolder tofolder)
$folders = array (
'/Documents/'
);
// ONLY THERE EXTENSIONS ARE SHOWED
// DONT FORGET TO ADD YOUR EXTENSIONS HERE!
$file_types = array(
'mp3',
'aac',
'pdf',
'ppt',
'png',
'txt',
'emlx',
'doc',
'jpg',
);
// Returns a human readable size
function size($fileadres){
$size = filesize($fileadres);
$i=0;
$iec = array("B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB");
while (($size/1024)>1) {
$size=$size/1024;
$i++;
}
return substr($size,0,strpos($size,'.')+2)." ".$iec[$i];
}
// vind de bestands extensie van de NAAM
function file_type($file){
$path_chunks = explode("/", $file);
$thefile = $path_chunks[count($path_chunks) - 1];
$dotpos = strrpos($thefile, ".");
return strtolower(substr($thefile, $dotpos + 1));
}
//echo files to page
foreach($folders as $folderadres){
if (is_readable($folderadres)) {
if ($handle = opendir($folderadres)) {
while (false !== ( $file = readdir($handle))) {
$extension = file_type($file);
if ($file != '.' && $file != '..' && array_search($extension, $file_types)){
$fileadres = $folderadres.$file;
$folder_content[] = $fileadres ;
};
};
closedir($handle);
};
}else{
//given folder can't be read.
};
};
$folder_content_count = (count($folder_content));
echo("<div>");
echo("<table>");
echo("<tr><th>Total file count: ".$folder_content_count."\n</th></tr>");
if(!empty($folder_content)){
foreach($folder_content as $fileadres){
$file_adres = explode("/", $fileadres);
$file_location = array_reverse($file_adres);
$file = $file_location[0];
$folder = $file_location[1];
echo("<tr>");
if( $folder != $lastfolder){
echo("\t<th>");
echo($folder);
echo("</th>");
echo("</tr>");
echo("<tr>");
}
$lastfolder = $folder;
echo("\t<td>");
echo("<a href=\"".$fileadres."\" target=\"_blank\">".$file."</a>");
echo("</td>");
echo("\t</tr>\n");
}
}
echo("</table>");
echo("</div>");
?>
Now you only need to make a 'Documents' folder in your root directory of your iPhone:
link this directory to the apache webserver directory (This must be done else apache will not give you acces because of the security it provides).
Code:
ln -s /Documents /Library/WebServer/Documents/
Your done! To see your files in /Documents just type: http://127.0.0.1 in mobile safari.
Questions? Ask them.
Bookmarks