Kiwi Dan
Kiwi Server 3.0
I made this code for those that always want to keep up to date with 9.7 items or changing distros...
Having custom items and then having to keep up with all the modifications in the latest svn can be a nightmare!
So you copy over all your custom items into from.log like:
Copy the latest items.xml and name it items.log
Put this code into any directory with php installed (tested on linux), change /dir/path to the path which your items.log etc are in, set the php file to permission 755 and then execute it and viola all your custom items are inserted into the latest items.xml file, rename items.log to items.xml (keep the old one as a backup) enjoy! Easy
Having custom items and then having to keep up with all the modifications in the latest svn can be a nightmare!
So you copy over all your custom items into from.log like:
XML:
<item id="383" article="a" name="really awesome hole">
<attribute key="floorchange" value="down" />
</item>
<item id="384" article="a" name="super cool rope spot">
<attribute key="description" value="There is a hole in the ceiling." />
</item>
Copy the latest items.xml and name it items.log
Put this code into any directory with php installed (tested on linux), change /dir/path to the path which your items.log etc are in, set the php file to permission 755 and then execute it and viola all your custom items are inserted into the latest items.xml file, rename items.log to items.xml (keep the old one as a backup) enjoy! Easy
PHP:
#!/usr/bin/php
<?php
//CONFIG
$fromname = "from.log";
$finishname = "items.log";
function writethis($variable, $filename)
{
//WRITE DIRECTORY HERE
$dir = "/dir/path/";
$filename = "".$dir."".$filename."";
$fh = fopen($filename, "w") or die("Could not open log file.");
fwrite($fh, $variable) or die("Could not write file!");
fclose($fh);
}
//Count how many items to loop through:
preg_match_all("/item id/", file_get_contents("".$fromname.""), $out);
$count = count($out[0]);
for ($i=1; $i<=$count; $i++)
{
preg_match("/<item id=\"(.*)\".*<\/item>/sU", file_get_contents("".$fromname.""), $matches, PREG_OFFSET_CAPTURE);
$bye = preg_replace("/<item id=\"".$matches[1][0]."\".*<\/item>/sU", "used", file_get_contents("".$fromname.""));
writethis($bye,"".$fromname."");
$b = preg_replace("/<item id=\"".$matches[1][0]."\".*<\/item>/sU", "".$matches[0][0]."", file_get_contents("".$finishname.""));
writethis($b,"".$finishname."");
}
echo "Woop.";
?>