get_threaded_children fix
[mirrors/Kyberia-bloodline.git] / scripts / contentregexp.php
CommitLineData
b42b2bf9
H
1<?php
2//requiring main config file with path/database etc. constants
3require('../config/config.inc');
4
5//connecting to database and creating universal $db object
6require(SYSTEM_ROOT.'/inc/log.inc');
7require(SYSTEM_ROOT.'/inc/database.inc');
8require(SYSTEM_ROOT.'/inc/nodes.inc');
9$db=new CLASS_DATABASE();
10$db_old=new CLASS_DATABASE("kyberia","kyberia","cyb3ry","127.0.0.1");
11
12$q="select node_id,node_content from node_content order by node_id";
13$set=$db->query($q);
14
15while ($set->next()) {
16 $node_content=$set->getString('node_content');
17 $new_content=preg_replace_callback("/(http:\/\/www.kyberia.sk\/([a-zA-Z]*).php)?\?(action=([a-zA-Z]*))?\&(node_id=([0-9]*))?(\&alone=([0-9]*))?/i","changeRegExp",$node_content);
18 if ($new_content!=$node_content) {
19 $node_id=$set->getString('node_id');
20 $new_content=AddSlashes($new_content);
21 $db->query("update node_content set node_content='$new_content' where node_id='$node_id'");
22 echo $node_id." updated<br>";
23 }
24}
25
26function changeRegExp($match) {
27global $db;
28
29 if ($match[8]) {
30 $q="select node_id from nodes where node_type='4' and old_id='".$match[8]."'";
31 $s=$db->query($q);
32 $s->next();
33 $id=$s->getString('node_id');
34 return "/id/$id";
35 }
36 else {
37 if ($match[4]=='forum') {
38 $q="select node_id from nodes where node_type='3' and old_id='".$match[6]."'";
39 $s=$db->query($q);
40 $s->next();
41 $id=$s->getString('node_id');
42 return "/id/$id";
43 }
44 }
45}
46
47?>
48
49
This page took 0.288192 seconds and 4 git commands to generate.