function adi_menu_admin($event, $step) { $debug = 0; // display debug info // tooltip help information $h['se'] = "The TXP section name, set in Sections tab"; $h['ti'] = "The TXP section title, set in Sections tab"; $h['ex'] = "Tick if the section should be excluded by default from the menu"; $h['pa'] = "The section's parent"; $h['so'] = "The section's sort order number"; $h['ch'] = "Tick if the section should be cloned in its own submenu"; $h['ct'] = "Used as the section's title if it's cloned"; $h['in'] = "Install adi_menu"; $h['un'] = "Uninstall adi_menu"; $h['im'] = "Import parent settings from cnk_section_tree (install adi_menu first)"; $installed = adi_menu_column_found('adi_menu_parent'); $something = ps("something"); $res = FALSE; if ($installed) { if ($something == "uninstall") { require_privs('plugin'); $res = adi_menu_uninstall(); if ($res) { pagetop("adi_menu admin", "adi_menu: uninstall successful"); } else { pagetop("adi_menu admin", "adi_menu: uninstall not successful"); } $installed = adi_menu_column_found('adi_menu_parent'); } else { if ($something == "install") { require_privs('plugin'); pagetop("adi_menu admin", "adi_menu: already installed"); } else { if ($something == "import") { $res = adi_menu_import(); $res ? pagetop("adi_menu admin", "adi_menu: import successful") : pagetop("adi_menu admin", "adi_menu: import failed"); } else { if ($step == "update") { pagetop("adi_menu admin", "adi_menu: updated"); if ($debug) { echo "<br/>Parent: "; print_r(ps('parent')); echo "<br/>Alt title: "; print_r(ps('alt_title')); echo "<br/>Exclude: "; print_r(ps('exclude')); echo "<br/>Clone: "; print_r(ps('clone')); echo "<br/>Sort: "; print_r(ps('sort')); } $parent = ps('parent'); $alt_title = ps('alt_title'); $exclude = ps('exclude'); $clone = ps('clone'); $sort = ps('sort'); $sections = adi_get_sections(); adi_menu_update($sections, $parent, $alt_title, $exclude, $clone, $sort); } else { if ($step == "admin") { pagetop("adi_menu admin", "adi_menu: no admin option selected"); } else { // do nothing pagetop("adi_menu admin", ""); } } } } } } else { // not installed if ($something == "install") { require_privs('plugin'); $res = adi_menu_install(); if ($res) { pagetop("adi_menu admin", "adi_menu: install successful"); } else { pagetop("adi_menu admin", "adi_menu: install not successful"); } $installed = adi_menu_column_found('adi_menu_parent'); } else { if ($something == "uninstall") { require_privs('plugin'); pagetop("adi_menu admin", "adi_menu: not installed"); } else { if ($something == "import") { pagetop("adi_menu admin", "adi_menu: must be installed first"); } } } } if ($installed) { $sections = adi_get_sections(); // perform check for section loops $out = ""; foreach ($sections as $index => $section) { if (adi_menu_loop_check($sections, $index, $index, FALSE)) { $out .= " " . $index; } } if ($out) { echo tag("<strong>** WARNING: Section loops found (check: {$out}) **</strong>", 'div', ' align="center" style="margin:1em"'); } echo form(startTable('list') . tr(hcell(adi_menu_tip("Section", $h['se'])) . hcell(adi_menu_tip("Title", $h['ti'])) . hcell(adi_menu_tip("Exclude?", $h['ex'])) . hcell(adi_menu_tip("Parent", $h['pa'])) . hcell(adi_menu_tip("Sort order", $h['so'])) . hcell(adi_menu_tip("Clone?", $h['ch'])) . hcell(adi_menu_tip("Clone title", $h['ct']))) . adi_menu_display_settings($sections) . endTable() . tag(fInput("submit", "update", "Update", "smallerbox") . eInput("adi_menu_admin") . sInput("update"), 'div', ' align="center" style="margin-top:2em"')); } else { if ($something != "uninstall" && $something != "import") { pagetop("adi_menu admin", "adi_menu: not installed"); } } if ($debug) { echo "Event: " . $event . "<br/>Step: " . $step . "<br/>Something: " . $something; } echo form(tag("Administration", "h3") . graf(" " . adi_menu_tip("Install", $h['in']) . fInput("radio", "something", "install", "edit", "", "", "20", "1") . " " . adi_menu_tip("Uninstall", $h['un']) . fInput("radio", "something", "uninstall", "edit", "", "", "20", "1") . " " . adi_menu_tip("Import", $h['im']) . fInput("radio", "something", "import", "edit", "", "", "20", "1") . " " . fInput("submit", "do_something", "Do admin", "smallerbox", "", 'return verify(\'' . gTxt('are_you_sure') . '\')')) . eInput("adi_menu_admin") . sInput("admin"), "text-align:center;margin-top:3em"); // output hierarchy summary global $sections, $exclude, $sort, $default_first, $default_title, $include_default, $menu_id; $sections = $exclude = ""; $sort = "NULL"; $default_first = $include_default = "1"; $menu_id = "mainmenu"; $section_list = adi_menu_section_list(FALSE); $hierarchy = adi_menu_hierarchy($section_list, '', 0); $out = adi_menu_markup($hierarchy, 0); echo '<div style="margin-left:10em">'; echo tag("Summary", "h3", ' style="margin-top:3em"'); echo tag("The above configuration will generate the following section hierarchy (subject to adi_menu tag attributes):", "p"); foreach ($out as $index => $value) { print $out[$index]; } echo '</div>'; }
function rss_sql_run($event, $step) { pagetop("Run SQL Query"); $text = ""; $rsd[] = ""; $sql_query2 = ""; if (gps("tn")) { $tq = "select * from " . gps("tn"); } if (gps("sql_query") || gps("tn")) { $sql_queries2 = gps("sql_query") ? trim(gps("sql_query")) : trim($tq); $totalquerycount = 0; $successquery = 0; if ($sql_queries2) { $sql_queries = array(); $sql_queries2 = explode("\n", $sql_queries2); foreach ($sql_queries2 as $sql_query2) { $sql_query2 = trim(stripslashes($sql_query2)); $sql_query2 = preg_replace("/[\r\n]+/", '', $sql_query2); if (!empty($sql_query2)) { $sql_queries[] = $sql_query2; } } foreach ($sql_queries as $sql_query) { if (preg_match("/^\\s*(insert|update|replace|delete|create|truncate) /i", $sql_query)) { $run_query = safe_query($sql_query); if (!$run_query) { $text .= graf(mysql_error(), ' style="color:#D10000;"'); $text .= graf($sql_query, ' style="color:#D10000;"'); } else { $successquery++; $text .= graf($sql_query, ' style="color:#4B9F00;"'); } $totalquerycount++; } elseif (preg_match("/^\\s*(select) /i", $sql_query)) { $run_query = safe_query($sql_query); if ($run_query) { $successquery++; } if ($run_query && mysql_num_rows($run_query) > 0) { /* get column metadata */ $i = 0; $headers = ""; while ($i < mysql_num_fields($run_query)) { $meta = mysql_fetch_field($run_query, $i); $headers .= hcell($meta->name); $i++; } $rsd[] = '<div class="scrollWrapper">' . startTable('list', '', 'scrollable') . '<thead>' . tr($headers) . '</thead><tbody>'; while ($a = mysql_fetch_assoc($run_query)) { $out[] = $a; } mysql_free_result($run_query); foreach ($out as $b) { $data = ""; foreach ($b as $f) { $data .= td($f); } $rsd[] = tr($data); } $rsd[] = '</tbody>' . endTable() . '</div>' . br; $out = array(); } else { $text .= graf(mysql_error(), ' style="color:#D10000;"'); } $text .= graf($sql_query, ' style="color:#D10000;"'); $totalquerycount++; } elseif (preg_match("/^\\s*(drop|show|grant) /i", $sql_query)) { $text .= graf($sql_query . " - QUERY TYPE NOT SUPPORTED", ' style="color:#D10000;"'); $totalquerycount++; } } $text .= graf($successquery . "/" . $totalquerycount . " Query(s) Executed Successfully", ' style="color:#0069D1;"'); } } echo startTable('edit') . tr(td(form(graf("Each query must be on a single line. You may run multiple queries at once by starting a new line." . br . "Supported query types include SELECT, INSERT, UPDATE, CREATE, REPLACE, and DELETE.") . graf("WARNING: All SQL run in this window will immediately and permanently change your database.", ' style="font-weight:bold;"') . text_area('sql_query', '200', '550', $sql_query2) . br . fInput('submit', 'run', gTxt('Run'), 'publish') . href("Go to Database Manager", "index.php?event=rss_db_man") . eInput('rss_sql_run'), '', ' verify(\'' . gTxt('are_you_sure') . '\')"'))) . tr(td(graf($text . br . implode('', $rsd)))) . endTable(); }