<html>
<head>
<title>Set Item Names</title>
</head>
<body>
<a href="list_pods.php">Zur Liste</a>
<?php
require_once("../config.php");
require_once("lib/db_utils.php");
require_once("lib/path_utils.php");
if (!empty($argv[1])) {
$_REQUEST["really"] = $argv[1];
}
$sql = "select * from item where item_url != '' and item_name = ''";
$rs = db_query($sql);
$rows = array();
while ($row = db_next_row($rs)) {
$rows[] = $row;
}
echo "found ".count($rows)." items to handle ...<br/>\n";
foreach ($rows as $row) {
$name = get_filename($row["item_url"]);
$sql = "update item set item_name='".mysql_escape_string($name)."' where id = '".$row["id"]."'";
echo $sql."<br/>\n";
if (!empty($_REQUEST["really"])) {
db_query($sql);
}
}
echo "handled ".count($rows)." items <br/>\n";
?>
<a href="set_item_names.php?really=true">Wirklich names setzen ?</a>
</body>
</html>