| 1 |
<?php
|
| 2 |
// $Id: update-webstory.php,v 1.1 2005/06/10 04:29:09 syscrusher Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* @file
|
| 6 |
* PHP page for updating legacy "webstory" nodes. "webstory.module" was never
|
| 7 |
* released into production, but is used on Syscrusher's personal sites. This
|
| 8 |
* script is released in hopes that it might be useful to someone as an
|
| 9 |
* example, since I had to write it for myself anyway.
|
| 10 |
*
|
| 11 |
* THIS CODE IS EXPERIMENTAL -- NOT FOR PRODUCTION USE
|
| 12 |
*/
|
| 13 |
|
| 14 |
include_once 'includes/bootstrap.inc';
|
| 15 |
drupal_bootstrap(DRUPAL_BOOTSTRAP_FULL);
|
| 16 |
|
| 17 |
$sql = "SELECT n.nid, n.title, ws.* FROM {node} n INNER JOIN {webstory} ws ON n.nid=ws.nid WHERE n.type='webstory' ORDER BY n.nid DESC LIMIT 1000";
|
| 18 |
$sql2 = "INSERT INTO {links_node} (lid,nid,link_title,weight,clicks,module) values (%d,%d,'%s',-5,%d,'links_related')";
|
| 19 |
|
| 20 |
print('<html><body>');
|
| 21 |
$count=0;
|
| 22 |
$result = db_query($sql);
|
| 23 |
while ($row = db_fetch_object($result)) {
|
| 24 |
$n_url = links_normalize_url($row->url);
|
| 25 |
$lid = links_put_link($n_url);
|
| 26 |
links_delete_links_for_node($row->nid);
|
| 27 |
$title = links_suggest_link_title($lid, '');
|
| 28 |
$clicks = $row->click;
|
| 29 |
$result2 = db_query($sql2, $lid, $row->nid, $title, $clicks);
|
| 30 |
$result3 = db_query("UPDATE {node} SET TYPE='story' WHERE nid=%d", $row->nid);
|
| 31 |
$count++;
|
| 32 |
}
|
| 33 |
print("<P>Processed $count webstory records. The script limits the number in one run to prevent timeouts. If no errors, rerun this script until the count is zero; it may take several iterations.");
|
| 34 |
print('</body></html>');
|
| 35 |
?>
|