Kyberia v2.0
[mirrors/Kyberia-bloodline.git] / inc / nodesnew.inc
1 <?php
2 /* This program is free software. It comes without any warranty, to
3 * the extent permitted by applicable law. You can redistribute it
4 * and/or modify it under the terms of the Do What The Fuck You Want
5 * To Public License, Version 2, as published by Sam Hocevar. See
6 * http://sam.zoy.org/wtfpl/COPYING for more details. */
7
8
9 {{
10 class nodes {
11
12 function processRegexp($matches) {
13 print_r($matches);
14 }
15
16 function processContent($node_content) {
17 require(SYSTEM_ROOT.'/inc/htmlparse.inc');
18 if ($_POST['no_html']) {
19 $node_content=htmlspecialchars($node_content);
20 }
21
22 else {
23 global $db,$htmlparse,$error;
24 /*
25 if (!htmlparse::htmlparse($node_content)) {
26 $error=$htmlparse;
27 return false;
28 }
29 */
30 $node_content = EregI_Replace("((( )|(\n)|(^))+)(http://|ftp://|https://)([[:alnum:]][^,[:space:]]*)","\\2<a target='_blank'href=\"\\6\\7\">\\6\\7</a>",$node_content);
31 $node_content=preg_replace_callback("/#(.*)#(.*)#/i","processRegexp",$node_content);
32 // $node_content=strip_tags($node_content,'<center><a><b><i><u><img><br><p><font><pre>');
33 }
34 $node_content=addslashes($node_content);
35 return $node_content;
36 }
37
38
39 function getNodeById($node_handle,$user_id) {
40 global $db, $error;
41 $q="select length(concat(nodes.node_vector,';',nodes.node_id)) as vector_depth,node_content.node_content,nodes.*,nodes.node_creator as node_owner_id,creator.node_name as owner,node_access.*,nodes.node_id as node_id,node_parent.node_name as node_parent_name from nodes left join nodes as creator on creator.node_id=nodes.node_creator left join nodes as node_parent on nodes.node_parent=node_parent.node_id left join node_content on nodes.node_id=node_content.node_id left join node_access on (node_access.node_id='$node_handle' and node_access.user_id='$user_id') where nodes.node_id='$node_handle'";
42
43 $result=$db->query($q);
44 if (!$result->next()) {
45 $error="no such node_id $node_handle exists";
46 return false;
47 }
48 else {
49 $node=$result->getRecord();
50 if (($node['node_system_access']=='crypto') && isset($_SESSION['crypto'])) {
51 require(SYSTEM_ROOT.'/inc/crypto.inc');
52 $node['node_content']=crypto::decrypto($node['node_content'],$_SESSION['crypto'][$node['node_id']]);
53 }
54 return $node;
55 }
56 }
57
58
59 function getNodeByOldId($node_handle,$user_id) {
60 global $db, $error;
61 $q="select nodes.* from nodes where nodes.old_id='$node_handle'";
62
63 $result=$db->query($q);
64 if (!$result->next()) {
65 $error="no such old_id $node_handle exists";
66 return false;
67 }
68 else {
69 return $result->getRecord();
70 }
71
72 }
73
74 function redirByName($node_handle) {
75 global $db, $error;
76 $set=$db->query("select node_id from nodes where node_name='$node_handle'");
77 $set->next();
78 $node_id=$set->getString('node_id');
79 if ($node_id) {
80 Header("Location: /id/$node_id");
81 }
82
83 }
84
85 function getNodesByName($node_handle) {
86 global $db, $error;
87 $q="select nodes.* from nodes where node_name='$node_handle%'";
88
89 $result=$db->query($q);
90
91 while ($result->next()){
92 $record[]=$result->getRecord();
93 }
94 return $record;
95
96 }
97
98
99
100 function getChildrenNodes($orderby="desc",$offset=0,$limit=DEFAULT_LISTING_AMOUNT) {
101 global $db, $error, $node;
102 $node_handle=$node['node_id'];
103
104 $q="select users.*,nodes.*,node_content.* from nodes
105 left join node_content on (node_content.node_id=nodes.node_id)
106 left join users on users.user_id=nodes.node_creator where
107 node_parent='$node_handle' order by node_created $orderby LIMIT $offset,$limit";
108 echo $q;
109 $result=$db->query($q);
110
111 while ($result->next()) {
112 $array[]=$result->getRecord();
113 }
114
115 return $array;
116
117 }
118
119
120 function getThreadedChildrenNodes($orderby="desc",$offset=0,$limit=DEFAULT_LISTING_AMOUNT) {
121 global $db, $error, $node;
122 $node_handle=$node['node_id'];
123
124 $q="select length(node_vector) as depth,users.login,nodes.*,node_content.* from nodes left join node_content on (node_content.node_id=nodes.node_id) left join users on users.user_id=nodes.node_creator where node_vector like '".$node['node_vector'].";".$node['node_id']."%' and node_type=3 order by concat(node_vector,';',nodes.node_id,';z') desc,depth LIMIT $offset,$limit";
125
126 $result=$db->query($q);
127
128 while ($result->next()) {
129 $children_array[]=$result->getRecord();
130 }
131
132 return $children_array;
133
134 }
135
136
137
138 function getNodeAccessData() {
139 global $node,$db;
140 $q="select users.login,node_access.* from node_access left join users on users.user_id=node_access.user_id where node_id='".$node['node_id']."' and node_permission!=''";
141 $result=$db->query($q);
142
143 while ($result->next()) {
144 $access_data[]=$result->getRecord();
145 }
146
147 return $access_data;
148
149 }
150 }
151
152 ?>
This page took 0.317426 seconds and 4 git commands to generate.