Forum Moderators: coopster
code:
<?php //this script should rebuild the photobook database //make sure this will continue till the end; don't abort on user ignore_user_abort("true"); include("../config.inc.php"); include($paths['functions']); connect_mysqli(); //data from my config.inc.php file: $paths['pbook'] = $paths['private'] . "pbook/"; $paths['palbums'] = $paths['pbook'] . "albums/"; $paths['pupload'] = $paths['pbook'] . "uploaded/"; $paths['pimages'] = $paths['pbook'] . "images/"; $paths['pthumbs'] = $paths['pbook'] . "thumbs/"; //get dirs $albums = glob($paths['palbums'] . "*"); foreach($albums as $album){ if(is_dir($album)){ //fix dirs $ar = substr($album, strlen($paths['palbums'])); photo_directory_fix($ar); //do the images $images_p = glob($paths['palbums'] . $ar . "/*"); foreach($images_p as $img){ $photos[$ar][] = $img; $i = substr($img , strlen($paths['palbums'] . $ar)); $i = substr($i , 1); photoalbum_photo_fix($ar, $i); }; //get the vars to update the xml file $num_p = count($photos[$ar]); $phs = $photos[$ar]; if(!file_exists($paths[palbums] . $ar . ".xml")){ make_album_xml($ar); }; $xmld = acess_album_xml($ar); $i = "0"; foreach($phs as $phf){ $xmld->photos->photo[$i]->filename = $phf; $i++; }; $xmld->config->amount = $num_p; write_album_xml($ar, $xmld); }; }; $mysqli->close(); exit("Complete"); ?> <?php //part of my used functions: //album xml getter function acess_album_xml($album){ global $paths; $xml = $paths[palbums] . $album . ".xml"; $albumxml = simplexml_load_file($xml); return $albumxml; }; //album xml writer function write_album_xml($album, $xml){ global $paths; $xmlfile = $paths[palbums] . $album . ".xml"; if(is_file($xmlfile)){ unlink($xmlfile); }; $xml->asXML($xmlfile); }; //album xmlgen function make_album_xml($album){ global $templates; global $paths; $xmlfile = $paths[palbums] . $album . ".xml"; $xml = simplexml_load_string($templates['album_xml']); $xml->asXML($xmlfile); }; //repairs all the paths for the supplied album function photo_directory_fix($album){ global $paths; if(!is_dir($paths['palbums'] . $album)){ mkdir($paths['palbums'] . $album); }; if(!is_dir($paths['pthumbs'] . $album)){ mkdir($paths['pthumbs'] . $album); }; if(!is_dir($paths['pthumbs'] . $album . "/small/")){ mkdir($paths['pthumbs'] . $album . "/small/"); }; if(!is_dir($paths['pthumbs'] . $album . "/large/")){ mkdir($paths['pthumbs'] . $album . "/large/"); }; }; function photoalbum_photo_thumb($a, $i){ global $paths; global $photobook; $complete_th_small = $paths['pthumbs'] . $a . "/small/" . $i; $complete_th_large = $paths['pthumbs'] . $a . "/large/" . $i; $complete_ab_img = $paths['palbums'] . $a . "/" . $i; $complete_ab = $paths['palbums'] . $a; $smallthumb = $complete_th_small; $largethumb = $complete_th_large; $sizes = getimagesize($complete_ab_img); $smallthumbdimensions['l'] = get_setting('th_small_x'); $smallthumbdimensions['h'] = get_setting('th_small_y'); $largethumbdimensions['l'] = get_setting('th_large_x'); $largethumbdimensions['h'] = get_setting('th_large_y'); $currentdimensions['l'] = $sizes['0']; $currentdimensions['h'] = $sizes['1']; $x = $largethumbdimensions['l']; $y = $largethumbdimensions['h']; $complete_ab_img = str_replace(" ", "\ ", $complete_ab_img); $largethumb = str_replace(" ", "\ ", $largethumb); $smallthumb = str_replace(" ", "\ ", $smallthumb); if($currentdimensions['l'] > $x && $currentdimensions['h'] > $y){ $thumbcommand = $paths['convert'] . " -resize " . $x . "x" . $y . " " . $complete_ab_img . " " . $largethumb; if(file_exists($largethumb)){ unlink($largethumb); }; echo exec($thumbcommand); }; $x = $smallthumbdimensions['l']; $y = $smallthumbdimensions['h']; if($currentdimensions['l'] > $x && $currentdimensions['h'] > $y){ $thumbcommand = $paths['convert'] . " -resize " . $x . "x" . $y . " " . $complete_ab_img . " " . $smallthumb; if(file_exists($smallthumb)){ unlink($smallthumb); }; echo exec($thumbcommand); }; }; ?> xml:
<?xml version="1.0" encoding="UTF-8"?>
<photoablum>
<description>Some text to describe this album</description>
<config>
<active>yes</active>
<amount>3</amount>
<securitylevel>0</securitylevel>
</config>
<photos>
<photo>
<filename>picture1.jpg</filename>
</photo>
<photo>
<filename>picture2.jpg</filename>
</photo>
<photo>
<filename>picture3.jpg</filename>
</photo>
</photos>
</photoablum>
error:
Fatal error: Objects used as arrays in post/pre increment/decrement must return values by reference in /www/thej/system/pbookrebuilder.php on line 65