1
0
Fork 0
Manager/cron/checkInventar.php

42 lines
2.5 KiB
PHP

<?php
$InventarObjektStatement = $RUNTIME['PDO']->prepare("SELECT * FROM inventoryitems ORDER BY avatarID ASC LIMIT 50000");
$InventarObjektStatement->execute();
while($InventarObjektRow = $InventarObjektStatement->fetch())
{
//echo "Check Inventory Item '".$InventarObjektRow['inventoryName']."' from '".$InventarObjektRow['avatarID']."'.\n";
$AssetMetaDataStatement = $RUNTIME['PDO']->prepare("SELECT * FROM fsassets WHERE id = ?");
$AssetMetaDataStatement->execute(array($InventarObjektRow['assetID']));
if($AssetMetaDataStatement->rowCount() == 0)
{
if($InventarObjektRow['assetType'] != '24')
{
if(!(left($InventarObjektRow['inventoryName'], 8) == '[DEFEKT]'))
{
$renameQuery = $RUNTIME['PDO']->prepare("UPDATE inventoryitems SET inventoryName = ? WHERE inventoryID = ? AND assetID = ?");
$renameQuery->execute(array(substr('[DEFEKT] '.$InventarObjektRow['inventoryName'], 0, 64), $InventarObjektRow['inventoryID'], $InventarObjektRow['assetID']));
echo "Found new missing asset for item '".$InventarObjektRow['inventoryName']."' from '".$RUNTIME['OPENSIM']->getUserName($InventarObjektRow['avatarID'])."'.\n";
sendInworldIM("00000000-0000-0000-0000-000000000000", $InventarObjektRow['avatarID'], "Inventory", $RUNTIME['GRID']['HOMEURL'], "WARNUNG: Die Assetdaten von einem deiner Inventarobjekte wurden nicht in der DB gefunden! Item Name: '".$InventarObjektRow['inventoryName']."'.");
}else{
echo "Found missing asset for item '".$InventarObjektRow['inventoryName']."' from '".$RUNTIME['OPENSIM']->getUserName($InventarObjektRow['avatarID'])."'.\n";
}
}else{
if((left($InventarObjektRow['inventoryName'], 8) == '[DEFEKT]'))
{
$newName = str_replace("[DEFEKT] ", "", $InventarObjektRow['inventoryName']);
$renameQuery = $RUNTIME['PDO']->prepare("UPDATE inventoryitems SET inventoryName = ? WHERE inventoryID = ? AND assetID = ?");
$renameQuery->execute(array(substr($newName, 0, 64), $InventarObjektRow['inventoryID'], $InventarObjektRow['assetID']));
echo " ==> Rename '".$InventarObjektRow['inventoryName']."' -> '".$newName."'\n";
}
}
}else{
//echo "Checking asset for item '".$InventarObjektRow['inventoryName']."' from '".$RUNTIME['OPENSIM']->getUserName($InventarObjektRow['avatarID'])."'.\n";
}
}
?>