| 1 | <?php $ID = substr( | 
| 2 | /*------------------------------------------------------------------------------ | 
| 3 | --- www.netfrag.org | 
| 4 | --- HTML1: user info page. | 
| 5 | -------------------------------------------------------------------------------- | 
| 6 | --- rabit, 02:29 05.09.2004 | 
| 7 | ------------------------------------------------------------------------------*/ | 
| 8 | '$Id: userinfo.php,v 1.4 2004/09/06 03:03:28 rabit Exp $' | 
| 9 | //------------------------------------------------------------------------------ | 
| 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 | //------------------------------------------------------------------------------ | 
| 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 | otd_html1_codeparagraph('<small><b>$' . $varname . '</b> = ' . trim($arraytext) . '</small>'); | 
| 43 |  | 
| 44 | } | 
| 45 |  | 
| 46 | common_benchmark_addstep('functions'); | 
| 47 |  | 
| 48 | //------------------------------------------------------------------------------ | 
| 49 |  | 
| 50 | common_benchmark_addstep('start'); | 
| 51 |  | 
| 52 | otd_html1_pagehead(); | 
| 53 |  | 
| 54 | common_benchmark_addstep('head'); | 
| 55 |  | 
| 56 | otd_html1_pageheader(); | 
| 57 |  | 
| 58 | common_benchmark_addstep('header'); | 
| 59 |  | 
| 60 | //---------------------------------------------------------- | 
| 61 |  | 
| 62 | otd_html1_pagetitle('CMS test page'); | 
| 63 |  | 
| 64 | otd_html1_paragraph('This is the first outstanding page and it was created for testing the CMS query mechanism.'); | 
| 65 |  | 
| 66 | //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 |  | 
| 68 | //---------------------------------------------------------- | 
| 69 |  | 
| 70 | $queries = array( | 
| 71 | '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 | ); | 
| 91 |  | 
| 92 | $query = (isset($_POST['q']) ? $_POST['q'] : ''); | 
| 93 |  | 
| 94 | otd_html1_headline('Query command:'); | 
| 95 |  | 
| 96 | for($q = 0, $options = ''; $q < count($queries); $q++) | 
| 97 | $options .= '<option' . ($query == $queries[$q] ? ' selected="selected"' : '') . ' value="' . $queries[$q] . '">' . $queries[$q] . '</option> | 
| 98 | '; | 
| 99 |  | 
| 100 | otd_html1_paragraph('<form action="' . $common['page']['filename'] . '" method="post" style="margin:0;"> | 
| 101 | <select name="q" size="1"> | 
| 102 | ' . $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 | <input name="q" size="50" value="' . $query . '" /> | 
| 108 | <input type="submit" value="OK" /> | 
| 109 | </form>', 'box1'); | 
| 110 |  | 
| 111 | common_benchmark_addstep('content'); | 
| 112 |  | 
| 113 | if($query) { | 
| 114 |  | 
| 115 | $response = null; | 
| 116 | $success = cms_query($query, $response); | 
| 117 |  | 
| 118 | common_benchmark_addstep('CMS query'); | 
| 119 |  | 
| 120 | otd_html1_headline('Query execution response:'); | 
| 121 |  | 
| 122 | otd_html1_paragraph('Command: "<b>' . $query . '</b>"', 'hl12'); | 
| 123 |  | 
| 124 | $resultinfo = $response[0]; | 
| 125 |  | 
| 126 | otd_html1_paragraph('Error: "<code>' . $resultinfo['error'] . '</code>" - "<b>' . $resultinfo['errortext'] . '</b>"', ($resultinfo['error'] ? 'hl11' : 'hl12')); | 
| 127 |  | 
| 128 | //  otd_html1_headline('Result:'); | 
| 129 |  | 
| 130 | if($success) { | 
| 131 |  | 
| 132 | switch($resultinfo['operation']) { | 
| 133 |  | 
| 134 | case 'GET': | 
| 135 |  | 
| 136 | $rows = $response[1]; | 
| 137 |  | 
| 138 | for($y = 0; $y < count($rows); $y++) { | 
| 139 |  | 
| 140 | for($x = 0; $x < count($rows[$y]); $x++) { | 
| 141 |  | 
| 142 | if(strlen($rows[$y][$x]) > 97) { | 
| 143 |  | 
| 144 | $rows[$y][$x] = substr($rows[$y][$x], 0, 97) . '...'; | 
| 145 |  | 
| 146 | } | 
| 147 |  | 
| 148 | $rows[$y][$x] = htmlentities($rows[$y][$x]); | 
| 149 |  | 
| 150 | } | 
| 151 |  | 
| 152 | } | 
| 153 |  | 
| 154 | otd_html1_table($response[2], $rows); | 
| 155 |  | 
| 156 | break; | 
| 157 |  | 
| 158 | } | 
| 159 |  | 
| 160 | } else { | 
| 161 |  | 
| 162 | otd_html1_paragraph('(No result returned)'); | 
| 163 |  | 
| 164 | } | 
| 165 |  | 
| 166 | if($common_sessiondata['user_prefs']['debug']) variablebox('response'); | 
| 167 |  | 
| 168 | } else { | 
| 169 |  | 
| 170 | otd_html1_headline('Query execution'); | 
| 171 |  | 
| 172 | 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 |  | 
| 174 | } | 
| 175 |  | 
| 176 | common_benchmark_addstep('content'); | 
| 177 |  | 
| 178 | //---------------------------------------------------------- | 
| 179 |  | 
| 180 | $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 | ?> |