Jeste jednou trasovani
[mirrors/Kyberia-bloodline.git] / scripts / dennikprispevky2node.php
1 <?php
2
3 require('../config/config.inc');
4
5 //connecting to database and creating universal $db object
6 require(SYSTEM_ROOT.'/inc/log.inc');
7 require(SYSTEM_ROOT.'/inc/database.inc');
8 require(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='6'";
13
14 $bigset=$db->query($q);
15
16 while ($bigset->next()) {
17
18 unset($set_array);
19 unset($set_array_item);
20 unset($prispevky);
21 unset($prispevky_array);
22 unset($prispevky_new_array);
23 unset($prispevky_old_array);
24 unset($oldidz);
25
26 $q="select * from nodes where node_type='7'";
27 $userset=$db->query($q);
28 while ($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
38 while ($set->next()) {
39 $set_array[]=$set->getRecord();
40 $prispevky[$set->getString('thread')]=$set->getString('id_prispevku');
41 }
42
43 foreach ($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
49 foreach ($set_array as $set_array_item) {
50
51 $q="insert into nodes set
52 node_name='".addslashes($set_array_item['vlozeno'])."::".addslashes($set_array_item['jmeno'])."',node_type='4'
53 ,old_id='".$set_array_item['id_prispevku']."'
54 ,node_created='".$set_array_item['vlozeno']."'
55 ,old_id_diskuse='".$set_array_item['id_diskuse']."'
56 ,old_type='blog'
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
71 print_r($prispevky_old_array);
72
73 foreach ($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.509431 seconds and 4 git commands to generate.