Jeste jednou trasovani
[mirrors/Kyberia-bloodline.git] / scripts / articleprispevky2node.php
CommitLineData
b42b2bf9
H
1<?php
2
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 * from nodes where old_id_diskuse>0 and node_type='5'";
13
14$bigset=$db->query($q);
15
16while ($bigset->next()) {
17
18unset($set_array);
19unset($set_array_item);
20unset($prispevky);
21unset($prispevky_array);
22unset($prispevky_new_array);
23unset($prispevky_old_array);
24unset($oldidz);
25
26$q="select * from nodes where node_type='7'";
27$userset=$db->query($q);
28while ($userset->next()) {
29 $users[$userset->getString('node_name')]=$userset->getString('node_id');
30}
31
32
33$q="select * from prispevky where id_diskuse='".$bigset->getString('old_id_diskuse')."' order by id_prispevku";
34$set=$db_old->query($q);
35
36
37
38while ($set->next()) {
39 $set_array[]=$set->getRecord();
40 $prispevky[$set->getString('thread')]=$set->getString('id_prispevku');
41}
42
43foreach ($prispevky as $thread_vector => $prispevok_id) {
44 if (strlen($thread_vector)>4) {
45 $prispevky_old_array[$prispevok_id]=$prispevky[substr($thread_vector,0,strlen($thread_vector)-5)];
46 }
47}
48
49foreach ($set_array as $set_array_item) {
50
51$q="insert into nodes set
52node_name='".addslashes($set_array_item['jmeno'])."::".$set_array_item['vlozeno']."',node_type='4'
53,old_id='".$set_array_item['id_prispevku']."'
54,old_type='article'
55,node_created='".$set_array_item['vlozeno']."'
56,old_id_diskuse='".$set_array_item['id_diskuse']."'
57,node_creator='".($users[$set_array_item['jmeno']])."'";
58
59
60 $db->query($q);
61 $lid=$db->getLastInsertId();
62
63 $k="insert into node_content set node_content='".addslashes($set_array_item['telo'])."',node_id='$lid'";
64 $db->query($k);
65 $oldidz[$set_array_item['id_prispevku']]=true;
66 echo $k;
67}
68
69
70
71print_r($prispevky_old_array);
72
73foreach ($oldidz as $key=>$value) {
74 echo "wantin key $key";
75 if ($prispevky_old_array[$key]) {
76 $q23="select node_id from nodes where old_id=".$prispevky_old_array[$key]." and node_type='4'";
77 $lal=$db->query($q23);
78 $lal->next();
79 print_r($lal);
80 $g="update nodes set node_parent='".$lal->getString('node_id')."' where old_id=$key and node_type='4'";
81 }
82 else $g="update nodes set node_parent='".$bigset->getString('node_id')."' where old_id=$key and node_type='4'";
83 $db->query($g);
84 echo "<br>".$g;
85}
86
87}
88
89?>
This page took 0.721124 seconds and 4 git commands to generate.