PHP 5 SAFE MODE - Some errors…..

Sunday, May 4th, 2008

Safe mode… humm - not the place to do it I think at PHP / application level. If it has got that far then you are a little buggered!

Anywho - you can force it with an ini_set() but not the best idea. - Once again I find PHP a ball ache- get me back to Java or C# please……..

http://uk.php.net/features.safe-mode

Uploading images tiny MCE

Saturday, April 12th, 2008

God I hate php….

http://pascal.vanhecke.info/2005/08/25/image-upload-plugin-for-tinymce/

Then (summarized from readme.txt for a simple setup, have a look at it if you want to know more):

  • download the latest version, unzip and upload the Ibrowser files to tiny_mce\plugins\ibrowser
  • select the one, 2 or more directories you want to be able to insert images from and and upload to and indicate them with easy to understand names (that will show up in the interface) in config/config.inc.php:

    $cfg['ilibs'] = array (
    array (
    ‘value’ => ‘/path/from/webroot/images/’,
    ‘text’ => ‘Sprekers’,
    ),
    array (
    ‘value’ => ‘/path/from/webroot/gallery/’,
    ‘text’ => ‘Sponsors’,
    ),
    );
  • chmod these directories and additionally the directories ibrowser/scripts/phpThumb/cache and ibrowser/temp to 755 or 777 (depending on the privileges your webserver has - try with 755 first if you’re not sure)
  • copy tinyMCE.editor_plugin.js file into the iBrowser plugin directory and rename it to “editor_plugin.js”
  • somewhere in an included or inline javascript, you should have the “tinyMCE.init” statement, configuring your TinyMce setup:

    Example for the latter:

    tinyMCE.init({
    ...
    plugins : "ibrowser",
    ...
    theme : "advanced",
    theme_advanced_buttons3_add : "ibrowser",
    });

JSON for php

Monday, April 7th, 2008

http://pear.php.net/pepr/pepr-proposal-show.php?id=198

another php cms to have a look at

Saturday, April 5th, 2008

http://textpattern.com/

PHP Framework to evaluate (Cake)

Tuesday, December 18th, 2007

More info to follow after I have played with this:

http://cakephp.org/

Symfony PHP framework

Friday, June 22nd, 2007

Not sure if it is any good - might try it - might not

http://www.symfony-project.com/

File uploads using Flash 8 and PHP

Friday, May 18th, 2007

I though this looked like a bit of fun - I had a go. I started at the tutorial below but the PHP is a little wrong - well it is for my PHP setup.

http://livedocs.adobe.com/flash/8/main/wwhelp/wwhimpl/common/html/wwhelp.htm?context=LiveDocs_Parts&file=00001591.html

I added some logging to my PHP so that I could see what it was doing too. This is my PHP (in very TEST mode). I will be making lots of improvements. I will also create a C# one for any .NET apps that might require something like this. I might even port the actionscript up to AS 3.0

<?php
logIt(’Started upload.php’);
function logIt($message = ‘message’) {
$handle = fopen(’log.txt’, ‘a’);
fwrite($handle, “$message\n”);
fclose($handle);
}

$MAXIMUM_FILESIZE = 1024 * 999999;
$MAXIMUM_FILE_COUNT = 100; // keep maximum 10 files on server
logIt(’Max filesize:’ . $MAXIMUM_FILESIZE);
//echo exif_imagetype($_FILES['Filedata']);
if ($_FILES['Filedata']['size'] <= $MAXIMUM_FILESIZE) {
logIt(’Current file size’ . $_FILES['Filedata']['size']);
move_uploaded_file($_FILES['Filedata']['tmp_name'], “./tmp/”.$_FILES['Filedata']['name']);
//$type = exif_imagetype(”./temporary/”.$_FILES['Filedata']['name']);
$type = 1;
if ($type == 1 || $type == 2 || $type == 3) {
@rename(”./tmp/”.$_FILES['Filedata']['name'], “./images/”.$_FILES['Filedata']['name']);
logIt(’Renaming to: ‘ . “./images/”.$_FILES['Filedata']['name']);
} else {
unlink(”./tmp/”.$_FILES['Filedata']['name']);
logIt(’Deleting temp file.’);
}
}

$directory = opendir(’./images/’);
logIt(’Directory handle: ‘ . var_dump($directory));
$files = array();
while ($file = readdir($directory)) {
if(!is_dir($file)){
array_push($files, array(’./images/’.$file, filectime(’./images/’.$file)));
logIt(’Adding to file list array: ‘ . $file);
}
}
usort($files, sorter);
if (count($files) > $MAXIMUM_FILE_COUNT) {
$files_to_delete = array_splice($files, 0, count($files) - $MAXIMUM_FILE_COUNT);
for ($i = 0; $i < count($files_to_delete); $i++) {
unlink($files_to_delete[$i][0]);
}
}
print_r($files);
closedir($directory);

function sorter($a, $b) {
if ($a[1] == $b[1]) {
return 0;
} else {
return ($a[1] < $b[1]) ? -1 : 1;
}
}

logIt(”Ended upload.php\n—————————–\n”);
?>

PHP is great when it comes to if - if’s and strings thats all it is!

Monday, May 14th, 2007

This is really useful for working out what PHP will really return - is_null() - who knows it all depends if it is “0″ 0 etc….

http://www.deformedweb.co.uk/php_variable_tests.php?show=1