');
$count=0;
if (module_exist('links')) {
$result = db_query($sql);
while ($row = db_fetch_object($result)) {
if (!db_fetch_object(db_query("SELECT * FROM {links_node} WHERE nid = %d", $row->nid))) { //only upgrade wen the nodes is not yet in links_node table
$n_url = links_normalize_url($row->url);
if (empty($n_url)) {
print("
Node ".$row->nid." was not converted (empty URL)");
continue;
}
$lid = links_put_link($n_url);
if (! $lid) {
print("
Node ".$row->nid." was not converted (failed link insert)");
continue;
}
links_delete_links_for_node($row->nid);
$title = links_suggest_link_title($lid, $row->title);
$clicks = $row->click;
$result2 = db_query($sql2, $lid, $row->nid, $title, $clicks);
$count++;
}
}
}
print("Processed $count weblink records. The script limits the number in one run to $count records to prevent timeouts. If no errors, rerun this script until the count is zero; it may take several iterations.");
print("
WARNING: Monitoring parameters are not yet supported and are currently ignored.");
print('