1 |
rabit |
1.1 |
<?php $ID = substr( |
2 |
|
|
/*------------------------------------------------------------------------------ |
3 |
|
|
--- www.netfrag.org |
4 |
|
|
--- HTML1: user info page. |
5 |
|
|
-------------------------------------------------------------------------------- |
6 |
|
|
--- rabit, 02:29 05.09.2004 |
7 |
|
|
------------------------------------------------------------------------------*/ |
8 |
rabit |
1.5 |
'$Id: userinfo.php,v 1.4 2004/09/06 03:03:28 rabit Exp $' |
9 |
rabit |
1.1 |
//------------------------------------------------------------------------------ |
10 |
|
|
, 5, -2); |
11 |
|
|
//------------------------------------------------------------------------------ |
12 |
|
|
|
13 |
|
|
include('../../inc/common/common.php.inc'); |
14 |
|
|
|
15 |
|
|
include('../../inc/otdef/otd_html1/otd_html1.php.inc'); |
16 |
|
|
|
17 |
|
|
common_benchmark_addstep('OTD_HTML1 included'); |
18 |
|
|
|
19 |
rabit |
1.2 |
//------------------------------------------------------------------------------ |
20 |
|
|
|
21 |
|
|
function variablebox($varname) { |
22 |
|
|
|
23 |
|
|
global $$varname; |
24 |
|
|
|
25 |
|
|
$arraytext = htmlentities(print_r($$varname, true)); |
26 |
|
|
$arraytext = str_replace(' ', ' ', $arraytext); |
27 |
|
|
$arraytext = str_replace("Array\n", 'array ', $arraytext); |
28 |
|
|
$arraytext = str_replace(' )', ')', $arraytext); |
29 |
|
|
$arraytext = str_replace("\n\n", "\n", $arraytext); |
30 |
|
|
|
31 |
|
|
$len = strlen($arraytext); |
32 |
|
|
$oldlen = 0; |
33 |
|
|
|
34 |
|
|
while($len != $oldlen) { |
35 |
|
|
|
36 |
|
|
$oldlen = strlen($arraytext); |
37 |
|
|
$arraytext = str_replace("array ", 'array ', $arraytext); |
38 |
|
|
$len = strlen($arraytext); |
39 |
|
|
|
40 |
|
|
} |
41 |
|
|
|
42 |
rabit |
1.5 |
otd_html1_codeparagraph('<small><b>$' . $varname . '</b> = ' . trim($arraytext) . '</small>'); |
43 |
rabit |
1.2 |
|
44 |
|
|
} |
45 |
|
|
|
46 |
|
|
common_benchmark_addstep('functions'); |
47 |
rabit |
1.1 |
|
48 |
|
|
//------------------------------------------------------------------------------ |
49 |
|
|
|
50 |
rabit |
1.2 |
common_benchmark_addstep('start'); |
51 |
|
|
|
52 |
rabit |
1.1 |
otd_html1_pagehead(); |
53 |
|
|
|
54 |
|
|
common_benchmark_addstep('head'); |
55 |
|
|
|
56 |
|
|
otd_html1_pageheader(); |
57 |
|
|
|
58 |
|
|
common_benchmark_addstep('header'); |
59 |
|
|
|
60 |
|
|
//---------------------------------------------------------- |
61 |
|
|
|
62 |
rabit |
1.3 |
otd_html1_pagetitle('CMS test page'); |
63 |
rabit |
1.2 |
|
64 |
rabit |
1.4 |
otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); |
65 |
rabit |
1.2 |
|
66 |
rabit |
1.5 |
//otd_html1_paragraph('If successful, the result of the query process is shown as a table. If you want to see the complete function response then turn "Debug outputs" on.'); |
67 |
rabit |
1.2 |
|
68 |
|
|
//---------------------------------------------------------- |
69 |
|
|
|
70 |
rabit |
1.4 |
$queries = array( |
71 |
rabit |
1.5 |
'GET COUNT FROM SOURCES', |
72 |
|
|
'GET FIELDNAMES FROM SOURCES', |
73 |
|
|
'GET name FROM SOURCES', |
74 |
|
|
'GET * FROM SOURCES', |
75 |
|
|
'GET COUNT FROM contenttypes', |
76 |
|
|
'GET FIELDNAMES FROM contenttypes', |
77 |
|
|
'GET id, name FROM contenttypes', |
78 |
|
|
'GET COUNT FROM languages', |
79 |
|
|
'GET FIELDNAMES FROM languages', |
80 |
|
|
'GET id, name FROM languages', |
81 |
|
|
'GET * FROM languages', |
82 |
|
|
'GET COUNT FROM contents', |
83 |
|
|
'GET FIELDNAMES FROM contents', |
84 |
|
|
'GET type, language_id, description FROM contents', |
85 |
|
|
/* |
86 |
|
|
'GET content FROM contents WITH id 3', |
87 |
|
|
'GET FROM contents WITH timestamp >1000000000', |
88 |
|
|
'GET description, language_id FROM contents WITH keyname Home', |
89 |
|
|
*/ |
90 |
rabit |
1.4 |
); |
91 |
|
|
|
92 |
|
|
$query = (isset($_POST['q']) ? $_POST['q'] : ''); |
93 |
rabit |
1.2 |
|
94 |
rabit |
1.4 |
otd_html1_headline('Query command:'); |
95 |
rabit |
1.2 |
|
96 |
rabit |
1.5 |
for($q = 0, $options = ''; $q < count($queries); $q++) |
97 |
|
|
$options .= '<option' . ($query == $queries[$q] ? ' selected="selected"' : '') . ' value="' . $queries[$q] . '">' . $queries[$q] . '</option> |
98 |
rabit |
1.4 |
'; |
99 |
rabit |
1.2 |
|
100 |
rabit |
1.4 |
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
101 |
rabit |
1.5 |
<select name="q" size="1"> |
102 |
rabit |
1.4 |
' . $options . '</select> |
103 |
|
|
<input type="submit" value="OK" /> |
104 |
|
|
</form>', 'box1'); |
105 |
|
|
|
106 |
|
|
otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> |
107 |
rabit |
1.5 |
<input name="q" size="50" value="' . $query . '" /> |
108 |
rabit |
1.4 |
<input type="submit" value="OK" /> |
109 |
|
|
</form>', 'box1'); |
110 |
rabit |
1.2 |
|
111 |
rabit |
1.4 |
common_benchmark_addstep('content'); |
112 |
rabit |
1.2 |
|
113 |
rabit |
1.4 |
if($query) { |
114 |
rabit |
1.2 |
|
115 |
rabit |
1.4 |
$response = null; |
116 |
|
|
$success = cms_query($query, $response); |
117 |
rabit |
1.2 |
|
118 |
rabit |
1.4 |
common_benchmark_addstep('CMS query'); |
119 |
rabit |
1.1 |
|
120 |
rabit |
1.5 |
otd_html1_headline('Query execution response:'); |
121 |
rabit |
1.1 |
|
122 |
rabit |
1.5 |
otd_html1_paragraph('Command: "<b>' . $query . '</b>"', 'hl12'); |
123 |
rabit |
1.1 |
|
124 |
rabit |
1.4 |
$resultinfo = $response[0]; |
125 |
rabit |
1.1 |
|
126 |
rabit |
1.5 |
otd_html1_paragraph('Error: "<code>' . $resultinfo['error'] . '</code>" - "<b>' . $resultinfo['errortext'] . '</b>"', ($resultinfo['error'] ? 'hl11' : 'hl12')); |
127 |
rabit |
1.2 |
|
128 |
rabit |
1.5 |
// otd_html1_headline('Result:'); |
129 |
rabit |
1.2 |
|
130 |
rabit |
1.5 |
if($success) { |
131 |
rabit |
1.1 |
|
132 |
rabit |
1.4 |
switch($resultinfo['operation']) { |
133 |
rabit |
1.1 |
|
134 |
rabit |
1.4 |
case 'GET': |
135 |
rabit |
1.2 |
|
136 |
rabit |
1.4 |
$rows = $response[1]; |
137 |
rabit |
1.2 |
|
138 |
rabit |
1.4 |
for($y = 0; $y < count($rows); $y++) { |
139 |
rabit |
1.2 |
|
140 |
rabit |
1.4 |
for($x = 0; $x < count($rows[$y]); $x++) { |
141 |
rabit |
1.2 |
|
142 |
rabit |
1.5 |
if(strlen($rows[$y][$x]) > 97) { |
143 |
rabit |
1.2 |
|
144 |
rabit |
1.5 |
$rows[$y][$x] = substr($rows[$y][$x], 0, 97) . '...'; |
145 |
rabit |
1.2 |
|
146 |
rabit |
1.5 |
} |
147 |
rabit |
1.2 |
|
148 |
rabit |
1.5 |
$rows[$y][$x] = htmlentities($rows[$y][$x]); |
149 |
rabit |
1.1 |
|
150 |
rabit |
1.4 |
} |
151 |
rabit |
1.2 |
|
152 |
rabit |
1.4 |
} |
153 |
rabit |
1.2 |
|
154 |
rabit |
1.4 |
otd_html1_table($response[2], $rows); |
155 |
rabit |
1.2 |
|
156 |
rabit |
1.4 |
break; |
157 |
rabit |
1.2 |
|
158 |
rabit |
1.4 |
} |
159 |
rabit |
1.5 |
|
160 |
|
|
} else { |
161 |
|
|
|
162 |
|
|
otd_html1_paragraph('(No result returned)'); |
163 |
rabit |
1.2 |
|
164 |
rabit |
1.4 |
} |
165 |
rabit |
1.2 |
|
166 |
rabit |
1.4 |
if($common_sessiondata['user_prefs']['debug']) variablebox('response'); |
167 |
rabit |
1.2 |
|
168 |
rabit |
1.4 |
} else { |
169 |
rabit |
1.2 |
|
170 |
rabit |
1.4 |
otd_html1_headline('Query execution'); |
171 |
rabit |
1.2 |
|
172 |
rabit |
1.4 |
otd_html1_paragraph('Select a pre-defined query string from the list or enter a new one into the text input field. Press the "<b>GO</b>" button in both cases to execute the query.'); |
173 |
rabit |
1.2 |
|
174 |
|
|
} |
175 |
|
|
|
176 |
|
|
common_benchmark_addstep('content'); |
177 |
|
|
|
178 |
|
|
//---------------------------------------------------------- |
179 |
|
|
|
180 |
rabit |
1.1 |
$extrapageinfocontents = 'Page created by <b>rabit</b> on <b>2004/09/05, 02:29</b>.'; |
181 |
|
|
|
182 |
|
|
otd_html1_pagefooter($extrapageinfocontents); |
183 |
|
|
|
184 |
|
|
common_benchmark_addstep('footer'); |
185 |
|
|
|
186 |
|
|
otd_html1_pagefoot(); |
187 |
|
|
|
188 |
|
|
//------------------------------------------------------------------------------ |
189 |
|
|
|
190 |
|
|
?> |