function setup_hooks() { global $context, $hooks, $smcFunc; $integration_function = empty($context['uninstalling']) ? 'add_integration_function' : 'remove_integration_function'; $class = $hooks['class']; $file = $hooks['file']; foreach ($hooks['hooks'] as $hook) { $integration_function($hook, $class . '::' . $hook, $file); } if (empty($context['uninstalling'])) { $db_table = db_table(); $db_table->db_create_table('{db_prefix}notices', array(array('name' => 'id_notice', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'autoincrement' => true), array('name' => 'body', 'type' => 'text'), array('name' => 'class', 'type' => 'varchar', 'size' => 50, 'default' => ''), array('name' => 'expire', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'added', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'show_to', 'type' => 'varchar', 'size' => 150, 'default' => ''), array('name' => 'positioning', 'type' => 'varchar', 'size' => 255, 'default' => '')), array(array('name' => 'id_notice', 'type' => 'primary', 'columns' => array('id_notice')), array('name' => 'expire', 'type' => 'key', 'columns' => array('expire')))); $db_table->db_create_table('{db_prefix}log_notices', array(array('name' => 'id_notice', 'type' => 'int', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'id_member', 'type' => 'mediumint', 'unsigned' => true, 'size' => 10, 'default' => 0), array('name' => 'dismissed', 'type' => 'tinyint', 'size' => 10, 'default' => 0)), array(array('name' => 'dismissed_notices', 'type' => 'key', 'columns' => array('id_member', 'dismissed')))); } $context['installation_done'] = true; }
/** * Resizes the body column from the messages table * * @package Maintenance * @param string $type */ function resizeMessageTableBody($type) { $table = db_table(); $table->db_change_column('{db_prefix}messages', 'body', array('type' => $type)); }
db_delete('organizations', $_GET['delete_id']); url_drop('delete_id,action'); } echo drawTop(); if (url_id()) { //form $f = new form('organizations', @$_GET['id']); $f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title'))); langUnsetFields($f, 'title'); langTranslateCheckbox($f); echo $f->draw(); } else { //modules list $t = new table('organizations', drawHeader()); $t->set_column('draggy', 'd', ' '); $t->set_column('title', 'l', getString('title')); $t->set_column('delete', 'd', ' '); $result = db_table('SELECT id, title' . langExt() . ' title FROM organizations WHERE is_active = 1 ORDER BY precedence'); foreach ($result as &$r) { $r['draggy'] = draw_img('/images/icons/move.png'); $r['title'] = draw_link('organizations.php?id=' . $r['id'], $r['title']); $r['delete'] = drawColumnDelete($r['id']); } echo $t->draw($result, 'No organizations'); //add new $f = new form('organizations'); $f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title'))); langUnsetFields($f, 'title'); echo $f->draw(false, false); } echo drawBottom();
function getStruct($collection) { $table =& db_table($collection); if ($table->getInfo()) { return $table->columns; } $this->error = $table->error; return false; }
<?php include "../../include.php"; if (url_id('module_id')) { $result = db_table('SELECT p.id, p.title, p.url, p.is_hidden FROM pages p WHERE module_id = ' . $_GET['module_id'] . ' ORDER BY p.precedence'); } elseif (url_id('modulette_id')) { $result = db_table('SELECT p.id, p.title, p.url, p.is_hidden FROM pages p WHERE modulette_id = ' . $_GET['modulette_id'] . ' ORDER BY p.precedence'); } else { url_change('./'); } echo drawTop(); //pages list $t = new table('pages', drawHeader()); $t->set_column('is_hidden', 'd', ' '); $t->set_column('draggy', 'd', ' '); $t->set_column('title', 'l', getString('title')); $t->set_column('url'); $t->set_draggable('draggy'); foreach ($result as &$r) { $r['is_hidden'] = draw_form_checkbox('foo', !$r['is_hidden'], false, 'ajax_set(\'pages\', \'is_hidden\', ' . $r['id'] . ', ' . abs($r['is_hidden'] - 1) . ');'); $r['draggy'] = draw_img('/images/icons/move.png'); $r['title'] = draw_link('page.php?id=' . $r['id'], $r['title']); if (empty($r['url'])) { $r['url'] = 'index.php'; } } echo $t->draw($result, 'No pages'); echo drawBottom();
/** * Apply another type of (avatar, language, etc.) package. */ public function action_install2() { global $txt, $context, $boardurl, $scripturl, $modSettings; // Make sure we don't install this mod twice. checkSubmitOnce('check'); checkSession(); // If there's no file, what are we installing? if (!isset($_REQUEST['package']) || $_REQUEST['package'] == '') { redirectexit('action=admin;area=packages'); } $context['filename'] = $_REQUEST['package']; // If this is an uninstall, we'll have an id. $context['install_id'] = isset($_REQUEST['pid']) ? (int) $_REQUEST['pid'] : 0; require_once SUBSDIR . '/Package.subs.php'; require_once SUBSDIR . '/Themes.subs.php'; // @todo Perhaps do it in steps, if necessary? $context['uninstalling'] = $_REQUEST['sa'] == 'uninstall2'; // Set up the linktree for other. $context['linktree'][count($context['linktree']) - 1] = array('url' => $scripturl . '?action=admin;area=packages;sa=browse', 'name' => $context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['page_title'] .= ' - ' . ($context['uninstalling'] ? $txt['uninstall'] : $txt['extracting']); $context['sub_template'] = 'extract_package'; if (!file_exists(BOARDDIR . '/packages/' . $context['filename'])) { fatal_lang_error('package_no_file', false); } // Load up the package FTP information? create_chmod_control(array(), array('destination_url' => $scripturl . '?action=admin;area=packages;sa=' . $_REQUEST['sa'] . ';package=' . $_REQUEST['package'])); // Make sure temp directory exists and is empty! if (file_exists(BOARDDIR . '/packages/temp')) { deltree(BOARDDIR . '/packages/temp', false); } else { mktree(BOARDDIR . '/packages/temp', 0777); } // Let the unpacker do the work. if (is_file(BOARDDIR . '/packages/' . $context['filename'])) { $context['extracted_files'] = read_tgz_file(BOARDDIR . '/packages/' . $context['filename'], BOARDDIR . '/packages/temp'); if (!file_exists(BOARDDIR . '/packages/temp/package-info.xml')) { foreach ($context['extracted_files'] as $file) { if (basename($file['filename']) == 'package-info.xml') { $context['base_path'] = dirname($file['filename']) . '/'; break; } } } if (!isset($context['base_path'])) { $context['base_path'] = ''; } } elseif (is_dir(BOARDDIR . '/packages/' . $context['filename'])) { copytree(BOARDDIR . '/packages/' . $context['filename'], BOARDDIR . '/packages/temp'); $context['extracted_files'] = listtree(BOARDDIR . '/packages/temp'); $context['base_path'] = ''; } else { fatal_lang_error('no_access', false); } // Are we installing this into any custom themes? $custom_themes = array(1); $known_themes = explode(',', $modSettings['knownThemes']); if (!empty($_POST['custom_theme'])) { foreach ($_POST['custom_theme'] as $tid) { if (in_array($tid, $known_themes)) { $custom_themes[] = (int) $tid; } } } // Now load up the paths of the themes that we need to know about. $theme_paths = getThemesPathbyID($custom_themes); $themes_installed = array(1); // Are there any theme copying that we want to take place? $context['theme_copies'] = array('require-file' => array(), 'require-dir' => array()); if (!empty($_POST['theme_changes'])) { foreach ($_POST['theme_changes'] as $change) { if (empty($change)) { continue; } $theme_data = unserialize(base64_decode($change)); if (empty($theme_data['type'])) { continue; } $themes_installed[] = $theme_data['id']; $context['theme_copies'][$theme_data['type']][$theme_data['orig']][] = $theme_data['future']; } } // Get the package info... $packageInfo = getPackageInfo($context['filename']); if (!is_array($packageInfo)) { fatal_lang_error($packageInfo); } $packageInfo['filename'] = $context['filename']; // Set the type of extraction... $context['extract_type'] = isset($packageInfo['type']) ? $packageInfo['type'] : 'modification'; // Create a backup file to roll back to! (but if they do this more than once, don't run it a zillion times.) if (!empty($modSettings['package_make_full_backups']) && (!isset($_SESSION['last_backup_for']) || $_SESSION['last_backup_for'] != $context['filename'] . ($context['uninstalling'] ? '$$' : '$'))) { $_SESSION['last_backup_for'] = $context['filename'] . ($context['uninstalling'] ? '$$' : '$'); // @todo Internationalize this? package_create_backup(($context['uninstalling'] ? 'backup_' : 'before_') . strtok($context['filename'], '.')); } // The mod isn't installed.... unless proven otherwise. $context['is_installed'] = false; // Is it actually installed? $package_installed = isPackageInstalled($packageInfo['id']); // Wait, it's not installed yet! // @todo Replace with a better error message! if (!isset($package_installed['old_version']) && $context['uninstalling']) { deltree(BOARDDIR . '/packages/temp'); fatal_error('Hacker?', false); } elseif ($context['uninstalling']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'uninstall'); // Gadzooks! There's no uninstaller at all!? if (empty($install_log)) { fatal_lang_error('package_uninstall_cannot', false); } // They can only uninstall from what it was originally installed into. foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $package_installed['old_themes'])) { unset($theme_paths[$id]); } } } elseif (isset($package_installed['old_version']) && $package_installed['old_version'] != $packageInfo['version']) { // Look for an upgrade... $install_log = parsePackageInfo($packageInfo['xml'], false, 'upgrade', $package_installed['old_version']); // There was no upgrade.... if (empty($install_log)) { $context['is_installed'] = true; } else { // Upgrade previous themes only! foreach ($theme_paths as $id => $data) { if ($id != 1 && !in_array($id, $package_installed['old_themes'])) { unset($theme_paths[$id]); } } } } elseif (isset($package_installed['old_version']) && $package_installed['old_version'] == $packageInfo['version']) { $context['is_installed'] = true; } if (!isset($package_installed['old_version']) || $context['is_installed']) { $install_log = parsePackageInfo($packageInfo['xml'], false, 'install'); } $context['install_finished'] = false; // We're gonna be needing the table db functions! ...Sometimes. $table_installer = db_table(); // @todo Make a log of any errors that occurred and output them? if (!empty($install_log)) { $failed_steps = array(); $failed_count = 0; foreach ($install_log as $action) { $failed_count++; if ($action['type'] == 'modification' && !empty($action['filename'])) { if ($action['boardmod']) { $mod_actions = parseBoardMod(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } else { $mod_actions = parseModification(file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']), false, $action['reverse'], $theme_paths); } // Any errors worth noting? foreach ($mod_actions as $key => $action) { if ($action['type'] == 'failure') { $failed_steps[] = array('file' => $action['filename'], 'large_step' => $failed_count, 'sub_step' => $key, 'theme' => 1); } // Gather the themes we installed into. if (!empty($action['is_custom'])) { $themes_installed[] = $action['is_custom']; } } } elseif ($action['type'] == 'code' && !empty($action['filename'])) { // This is just here as reference for what is available. global $txt, $modSettings, $context; // Now include the file and be done with it ;). if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) { require BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'credits') { // Time to build the billboard $credits_tag = array('url' => $action['url'], 'license' => $action['license'], 'copyright' => $action['copyright'], 'title' => $action['title']); } elseif ($action['type'] == 'hook' && isset($action['hook'], $action['function'])) { if ($action['reverse']) { remove_integration_function($action['hook'], $action['function'], $action['include_file']); } else { add_integration_function($action['hook'], $action['function'], $action['include_file']); } } elseif ($action['type'] == 'database' && !empty($action['filename']) && (!$context['uninstalling'] || !empty($_POST['do_db_changes']))) { // These can also be there for database changes. global $txt, $modSettings, $context; // Let the file work its magic ;) if (file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename'])) { require BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']; } } elseif ($action['type'] == 'redirect' && !empty($action['redirect_url'])) { $context['redirect_url'] = $action['redirect_url']; $context['redirect_text'] = !empty($action['filename']) && file_exists(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']) ? file_get_contents(BOARDDIR . '/packages/temp/' . $context['base_path'] . $action['filename']) : ($context['uninstalling'] ? $txt['package_uninstall_done'] : $txt['package_installed_done']); $context['redirect_timeout'] = $action['redirect_timeout']; // Parse out a couple of common urls. $urls = array('$boardurl' => $boardurl, '$scripturl' => $scripturl, '$session_var' => $context['session_var'], '$session_id' => $context['session_id']); $context['redirect_url'] = strtr($context['redirect_url'], $urls); } } package_flush_cache(); // First, ensure this change doesn't get removed by putting a stake in the ground (So to speak). package_put_contents(BOARDDIR . '/packages/installed.list', time()); // See if this is already installed $is_upgrade = false; $old_db_changes = array(); $package_check = isPackageInstalled($packageInfo['id']); // Change the installed state as required. if (!empty($package_check['install_state'])) { if ($context['uninstalling']) { setPackageState($package_check['package_id']); } else { // not uninstalling so must be an upgrade $is_upgrade = true; $old_db_changes = empty($package_check['db_changes']) ? array() : $package_check['db_changes']; } } // Assuming we're not uninstalling, add the entry. if (!$context['uninstalling']) { // Any db changes from older version? $table_log = $table_installer->package_log(); if (!empty($old_db_changes)) { $db_package_log = empty($table_log) ? $old_db_changes : array_merge($old_db_changes, $table_log); } else { $db_package_log = $table_log; } // If there are some database changes we might want to remove then filter them out. if (!empty($db_package_log)) { // We're really just checking for entries which are create table AND add columns (etc). $tables = array(); usort($db_package_log, array($this, '_sort_table_first')); foreach ($db_package_log as $k => $log) { if ($log[0] == 'remove_table') { $tables[] = $log[1]; } elseif (in_array($log[1], $tables)) { unset($db_package_log[$k]); } } $package_installed['db_changes'] = serialize($db_package_log); } else { $package_installed['db_changes'] = ''; } // What themes did we actually install? $themes_installed = array_unique($themes_installed); $themes_installed = implode(',', $themes_installed); // What failed steps? $failed_step_insert = serialize($failed_steps); // Credits tag? $credits_tag = empty($credits_tag) ? '' : serialize($credits_tag); // Add to the log packages addPackageLog($packageInfo, $failed_step_insert, $themes_installed, $package_installed['db_changes'], $is_upgrade, $credits_tag); } $context['install_finished'] = true; } // If there's database changes - and they want them removed - let's do it last! if (!empty($package_installed['db_changes']) && !empty($_POST['do_db_changes'])) { foreach ($package_installed['db_changes'] as $change) { if ($change[0] == 'remove_table' && isset($change[1])) { $table_installer->db_drop_table($change[1]); } elseif ($change[0] == 'remove_column' && isset($change[2])) { $table_installer->db_remove_column($change[1], $change[2]); } elseif ($change[0] == 'remove_index' && isset($change[2])) { $table_installer->db_remove_index($change[1], $change[2]); } } } // Clean house... get rid of the evidence ;). if (file_exists(BOARDDIR . '/packages/temp')) { deltree(BOARDDIR . '/packages/temp'); } // Log what we just did. logAction($context['uninstalling'] ? 'uninstall_package' : (!empty($is_upgrade) ? 'upgrade_package' : 'install_package'), array('package' => Util::htmlspecialchars($packageInfo['name']), 'version' => Util::htmlspecialchars($packageInfo['version'])), 'admin'); // Just in case, let's clear the whole cache to avoid anything going up the swanny. clean_cache(); // Restore file permissions? create_chmod_control(array(), array(), true); }
FROM {db_prefix}membergroups WHERE min_posts != {int:min_posts}', array('min_posts' => -1)); $post_groups = array(); while ($row = $db->fetch_assoc($request)) { $post_groups[] = $row['id_group']; } $db->free_result($request); $db->insert('replace', '{db_prefix}sp_profiles', array('id_profile' => 'int', 'type' => 'int', 'name' => 'text', 'value' => 'text'), array(array(1, 1, '$_guests', '-1|'), array(2, 1, '$_members', implode(',', $post_groups) . ',0|'), array(3, 1, '$_everyone', implode(',', $post_groups) . ',0,-1|')), array('id_profile')); } $db_package_log = array(); foreach ($sp_tables as $sp_table_name => $null) { $db_package_log[] = array('remove_table', $db_prefix . $sp_table_name); } // Update the page table to accept more data if (empty($modSettings['sp_version']) || $modSettings['sp_version'] < '2.4.1') { $dbtbl = db_table(); $page_cols = $dbtbl->db_list_columns('{db_prefix}sp_pages', true); if (isset($page_cols['body']) && $page_cols['body']['type'] == 'text') { $dbtbl->db_change_column('{db_prefix}sp_pages', 'body', array('type' => 'mediumtext')); } } // Update the block table to include the mobile column if needed $request = $db->query('', 'SHOW FIELDS FROM {db_prefix}sp_blocks'); $fields = array(); while ($row = $db->fetch_assoc($request)) { $fields[] = $row['Field']; } $db->free_result($request); if (!in_array('mobile_view', $fields)) { $db->query('', 'ALTER TABLE {db_prefix}sp_blocks ADD mobile_view TINYINT NOT NULL DEFAULT "0"'); }
<?php global $cgi; if (empty($cgi->_table)) { header('Location: ' . site_prefix() . '/index/myadm-app'); exit; } $tbl = db_table($cgi->_table); $data = $tbl->fetch($cgi->_key); $trans = get_html_translation_table(HTML_ENTITIES); foreach ($trans as $k => $v) { $v = rawurlencode($v); $v = preg_replace('/[^A-F0-9]+/', '', $v); $v = '&#x' . $v . ';'; $trans[$k] = $v; } function xml_encode($data, $trans) { $data = str_replace(array_keys($trans), array_values($trans), $data); return stripslashes($data); } header("content-type: application/x-octet-stream"); header("content-disposition: attachment; filename=" . $cgi->_table . '.' . $cgi->_key . '.xml'); echo '<?xml version="1.0"?' . '>' . NEWLINEx2; echo '<table name="' . $cgi->_table . '">' . NEWLINE; echo TAB . '<row>' . NEWLINE; foreach (get_object_vars($data) as $key => $value) { $value = xml_encode($value, $trans); echo TABx2 . '<col name="' . $key . '">' . $value . '</col>' . NEWLINE; } echo TAB . '</row>' . NEWLINE;
<?php $return .= '<tr><td colspan="2">' . drawSelectUser('staff', false, true, 0, true, true, "Jump to Staff Member") . '</td></tr>'; $pages = db_table('SELECT url, title' . langExt() . ' title FROM pages WHERE module_id = ' . $m['id'] . ' AND is_active = 1 AND is_hidden <> 1 AND is_admin <> 1 ORDER by precedence'); foreach ($pages as &$p) { $p = draw_link('/staff/' . $p['url'], $p['title']); } $return .= draw_table_rows($pages);
<?php include '../../include.php'; if ($posting) { langTranslatePost('title'); $id = db_save('modulettes'); url_drop('id'); } echo drawTop(); if (url_id()) { //form $f = new form('modulettes', @$_GET['id']); langUnsetFields($f, 'title'); langTranslateCheckbox($f); echo $f->draw(); } else { //modulettes list $t = new table('modulettes', drawHeader()); $t->set_column('is_active', 'd', ' '); $t->set_column('title', 'l', getString('title')); $t->set_column('pages', 'r'); $result = db_table('SELECT m.id, m.title' . langExt() . ' title, m.is_active, (SELECT COUNT(*) FROM pages p WHERE p.modulette_id = m.id) pages FROM modulettes m ORDER BY m.title' . langExt()); foreach ($result as &$r) { $r['is_active'] = draw_form_checkbox('is_active', $r['is_active'], false, 'ajax_set(\'modulettes\', \'is_active\', ' . $r['id'] . ', ' . abs($r['is_active'] - 1) . ');'); $r['title'] = draw_link('modulettes.php?id=' . $r['id'], $r['title']); $r['pages'] = draw_link('pages.php?modulette_id=' . $r['id'], format_quantitize($r['pages'], 'page')); } echo $t->draw($result, 'No modulettes'); } echo drawBottom();
function drawBBPosts($count = 15, $error = '') { if ($topics = db_table("SELECT \n\t\t\tt.id,\n\t\t\tt.title,\n\t\t\tt.isAdmin,\n\t\t\tt.threadDate,\n\t\t\t(SELECT COUNT(*) FROM bulletin_board_followups f WHERE t.id = f.topicID AND f.isActive = 1) replies,\n\t\t\tISNULL(u.nickname, u.firstname) firstname,\n\t\t\tu.lastname\n\t\tFROM bulletin_board_topics t\n\t\tJOIN intranet_users u ON u.userID = t.createdBy\n\t\tWHERE t.isActive = 1 AND (t.temporary IS NULL OR t.temporary = 0 OR \n\t\t\t(t.temporary = 1 AND DATEDIFF(NOW(), t.createdOn) < 31))\n\t\tORDER BY t.threadDate DESC", $count)) { foreach ($topics as &$topic) { if ($topic["isAdmin"]) { $topic["replies"] = "-"; } $topic = ' <tr class="thread' . ($topic["isAdmin"] ? ' admin' : '') . '"> <td class="input"><a href="topic.php?id=' . $topic["id"] . '">' . $topic["title"] . '</a></td> <td>' . $topic["firstname"] . ' ' . $topic["lastname"] . '</td> <td align="center">' . $topic["replies"] . '</td> <td align="right">' . format_date($topic["threadDate"]) . '</td> </tr>'; } return implode($topics); } else { return $error; } }
function do_register() { $network = get_network(); switch ($_GET['status']) { case 'check': $user_or_code = get_user(); if (!$user_or_code) { $user_or_code = get_code(); } if (!$user_or_code) { echo 'available'; } else { echo 'taken'; } return; case 'new_code': $sql = 'INSERT INTO ' . db_table('codes') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defcode') . ')'; $resource = 'codes'; break; case 'new_user': $sql = 'INSERT INTO ' . db_table('users') . ' (network_id, username, password, valid_from, created, ' . access_control_fields() . ') ' . 'VALUES (' . $network['id'] . ',\'' . $_GET['user'] . '\',\'' . $_GET['pass'] . '\', now(), now(), ' . access_control_values($network, 'defuser') . ')'; $resource = 'users'; break; } db_query($sql, false); $id = db_lastid(); if ($id) { $input = $_POST; if (!$input) { $input = file_get_contents("php://input"); } $lines = preg_split("/\n+/", $input); $attrs = array(); foreach ($lines as $line) { $p = preg_split('/[=: ]+/', $line, 2); if ($p[0] && $p[1]) { $attrs[$p[0]] = $p[1]; } } save_attributes($id, $resource, $attrs); } }
<?php include '../include.php'; $result = db_table('SELECT u.id link, u.firstname, u.lastname, u.title, d.departmentName department, o.title organization, u.email, (SELECT CASE WHEN u.rankID = 9 THEN "No" ELSE "Yes" END) is_staff FROM users u LEFT JOIN departments d ON u.departmentID = d.departmentID JOIN organizations o ON u.organization_id = o.id WHERE u.is_active = 1 ORDER BY u.lastname, u.firstname'); foreach ($result as &$r) { $r['link'] = draw_link(url_base() . '/staff/view.php?id=' . $r['link'], $r['link']); } file_array($result, 'employees');
<?php include "../include.php"; echo drawTop(); $result = db_table('SELECT c.id, c.title' . langExt() . ' title, c.pub_date, t.title' . langExt() . ' "group", c.publication' . langExt() . ' publication, ' . db_updated('c') . ' FROM press_clips c JOIN press_clips_types t ON c.type_id = t.id ' . getChannelsWhere('press_clips', 'c', 'clip_id') . ' ORDER BY t.title, pub_date DESC', 20); $t = new table('press-clips', drawHeader(array('edit.php' => getString('add_new')))); $t->set_column('title', 'l', getString('title')); foreach ($result as &$r) { $r['title'] = draw_link("clip.php?id=" . $r["id"], format_string($r["title"], 80)) . '<br>' . $r["publication"] . ' <span class="light">' . format_date($r["pub_date"]) . '</span>'; } echo $t->draw($result, getString('pressclips_recent_empty')); include "edit.php"; echo drawBottom();
/** * This performs a table alter, but does it unbuffered so the script can time out professionally. * * @param string $change * @param int $substep * @param boolean $is_test */ function protected_alter($change, $substep, $is_test = false) { global $db_prefix; $table = db_table(); $db = database(); // Firstly, check whether the current index/column exists. $found = false; if ($change['type'] === 'column') { $columns = $table->db_list_columns('{db_prefix}' . $change['table'], true); foreach ($columns as $column) { // Found it? if ($column['name'] === $change['name']) { $found |= 1; // Do some checks on the data if we have it set. if (isset($change['col_type'])) { $found &= $change['col_type'] === $column['type']; } if (isset($change['null_allowed'])) { $found &= $column['null'] == $change['null_allowed']; } if (isset($change['default'])) { $found &= $change['default'] === $column['default']; } } } } elseif ($change['type'] === 'index') { $request = upgrade_query(' SHOW INDEX FROM ' . $db_prefix . $change['table']); if ($request !== false) { $cur_index = array(); while ($row = $db->fetch_assoc($request)) { if ($row['Key_name'] === $change['name']) { $cur_index[(int) $row['Seq_in_index']] = $row['Column_name']; } } ksort($cur_index, SORT_NUMERIC); $found = array_values($cur_index) === $change['target_columns']; $db->free_result($request); } } // If we're trying to add and it's added, we're done. if ($found && in_array($change['method'], array('add', 'change'))) { return true; } elseif (!$found && in_array($change['method'], array('remove', 'change_remove'))) { return true; } elseif ($is_test) { return false; } // Not found it yet? Bummer! How about we see if we're currently doing it? $running = false; $found = false; while (1 == 1) { $request = upgrade_query(' SHOW FULL PROCESSLIST'); while ($row = $db->fetch_assoc($request)) { if (strpos($row['Info'], 'ALTER TABLE ' . $db_prefix . $change['table']) !== false && strpos($row['Info'], $change['text']) !== false) { $found = true; } } // Can't find it? Then we need to run it fools! if (!$found && !$running) { $db->free_result($request); $success = upgrade_query(' ALTER TABLE ' . $db_prefix . $change['table'] . ' ' . $change['text'], true) !== false; if (!$success) { return false; } // Return $running = true; } elseif (!$found) { $db->free_result($request); return true; } // Pause execution for a sec or three. sleep(3); // Can never be too well protected. nextSubstep($substep); } // Protect it. nextSubstep($substep); }
<?php include "../include.php"; echo drawTop(); $t = new table('bb_topics', drawHeader()); $t->set_column('contact', 'l', 'Contact Record'); $t->set_column('action'); //$t->set_column('contact', 'l', 'Done By'); $t->set_column('when', 'r'); $result = db_table('SELECT c.id, c.firstname, c.lastname, c.updated_date, ' . db_updated('c') . ' FROM contacts c ORDER BY updated DESC', 40); foreach ($result as &$r) { $r['contact'] = draw_link('contact.php?id=' . $r['id'], $r['lastname'] . ', ' . $r['firstname']); $r['action'] = $r['updated_date'] ? 'Update' : 'New Contact'; $r['when'] = format_date($r['updated']); } echo $t->draw($result); echo drawBottom();
<?php include "include.php"; if (url_action('delete')) { db_delete('bb_topics_types'); url_drop('action,id'); } echo drawTop(); $t = new table('bb_topics_types', drawHeader($page['is_admin'] ? array('category_edit.php' => getString('category_new')) : false)); $t->set_column('category', 'l', getString('category')); $t->set_column('topics', 'r', getString('topics')); if ($page['is_admin']) { $t->set_column('delete', 'd', ' '); } $result = db_table('SELECT y.id, y.title' . langExt() . ' category, (SELECT COUNT(*) FROM bb_topics t WHERE t.type_id = y.id AND t.is_active = 1) topics FROM bb_topics_types y WHERE y.is_active = 1 ORDER BY y.title'); foreach ($result as &$r) { $r['category'] = draw_link('category.php?id=' . $r['id'], $r['category']); if ($page['is_admin']) { $r['delete'] = draw_img('/images/icons/delete.png', url_query_add(array('action' => 'delete', 'id' => $r['id']), false)); } } echo $t->draw($result, 'No categories added yet'); echo drawBottom();
c.address_2, RIGHT("00000" + RTRIM(c.zip), 5) zip, c.phone, c.fax, c.mobile_phone, c.email, z.city, z.state, c.notes FROM contacts c LEFT JOIN zip_codes z ON c.zip = z.zip WHERE c.id = ' . $_GET['id']); $d = new display(); $d->row('Name', $r['salutation'] . ' ' . $r['firstname'] . ' ' . $r['lastname'] . ($r['suffix'] ? ', ' . $r['suffix'] : '')); $d->row('Company', $r['organization']); $d->row('Job Title', $r['title']); $d->row('Address', $r['address_1'] . ($r['address_2'] ? BR . $r['address_2'] : false) . BR . $r['city'] . ', ' . $r['state'] . ' ' . $r['zip']); $d->row('Phone', $r['phone']); $d->row('Fax', $r['fax']); $d->row('Mobile', $r['mobile_phone']); $d->row('Email', draw_link('mailto:' . $r['email'])); $d->row('Notes', nl2br($r['notes'])); echo $d->draw(); $result = db_table('SELECT t.id, t.tag, y.title "group" FROM contacts_to_tags c2t JOIN contacts_tags t ON c2t.tag_id = t.id JOIN contacts_tags_types y ON t.type_id = y.id WHERE c2t.contact_id = ' . $_GET['id']); $t = new table('contacts_tags'); $t->set_column('tag'); foreach ($result as &$r) { $r['tag'] = draw_link('value.php?id=' . $r['id'], $r['tag']); } echo $t->draw($result); echo drawBottom();
include 'include.php'; url_query_require('skills.php'); if (!($skill = db_grab('SELECT title FROM skills where isActive = 1 AND id = ' . url_id()))) { url_chagne('skills.php'); } echo drawTop(); echo drawTableStart(); if ($isAdmin) { echo drawHeaderRow($skill, 1, 'Edit', 'skill_add_edit.php?id=' . url_id()); } else { echo drawHeaderRow($skill, 1); } if ($users = db_table('SELECT u.userID, u.firstName, u.lastName FROM users_to_skills u2s JOIN intranet_users u ON u2s.user_id = u.userID WHERE u2s.skill_id = ' . url_id() . ' AND u.isActive = 1 ORDER BY u.lastName, u.firstName')) { ?> <tr> <th>User</th> </tr> <?php foreach ($users as $u) { echo '<tr> <td><a href="view.php?id=' . $u['userID'] . '">' . $u['firstName'] . ' ' . $u['lastName'] . '</a></td> </tr>'; } } else { echo drawEmptyResult('No users are tagged with this skill.');
<?php include "../../include.php"; if (url_id() && url_action('delete')) { db_delete('web_news_blurbs', $_GET['delete_id']); url_drop('action,delete_id'); } echo drawTop(); $blurbs = db_table("SELECT b.id, b.title, b.publish_date FROM web_news_blurbs b WHERE b.is_active = 1 ORDER BY b.publish_date DESC"); $t = new table("web_news_blurbs"); $t->set_column("title"); $t->set_column("publish_date", "r"); $t->set_column('delete', 'c', ' '); $t->set_title(drawHeader(array("add new" => "edit/"))); foreach ($blurbs as &$b) { $b["title"] = draw_link("edit/?id=" . $b["id"], $b["title"]); $b["publish_date"] = format_date($b["publish_date"]); $b['delete'] = draw_img('/images/icons/delete.gif', url_query_add(array('action' => 'delete', 'id' => $b['id']), false)); } echo $t->draw($blurbs); echo drawBottom();
<?php include '../include.php'; echo drawTop(); $t = new table('staff', drawHeader()); $t->set_column('picture', 'l', ' ', '50'); $t->set_column('name'); $t->set_column('organization'); $t->set_column('last_login', 'r'); $result = db_table('SELECT u.id, u.firstname, u.lastname, u.title, o.title organization, u.organization_id, u.lastLogin last_login FROM users u LEFT JOIN organizations o ON u.organization_id = o.id JOIN users_to_modules u2m ON u.id = u2m.user_id WHERE u.is_active = 1 AND u2m.module_id = ' . $page['module_id'] . ' ORDER BY u.lastname, u.firstname'); foreach ($result as &$r) { $link = '/staff/view.php?id=' . $r['id']; $r['picture'] = draw_img(file_dynamic('users', 'image_small', $r['id'], 'jpg'), $link); $r['name'] = draw_link($link, $r['firstname'] . ' ' . $r['lastname']); if ($r['organization']) { $r['organization'] = draw_link('/staff/organizations.php?id=' . $r['organization_id'], $r['organization']) . '<br>'; } $r['organization'] .= $r['title']; $r['last_login'] = format_date($r['last_login']); } echo $t->draw($result, 'No administrators for this module yet!'); echo drawBottom();
langTranslatePost('description'); $_POST["topic_id"] = $_GET["id"]; $id = db_save("bb_followups", false); db_query('UPDATE bb_topics SET thread_date = GETDATE(), replies = (SELECT COUNT(*) FROM bb_followups WHERE topic_id = ' . $_POST['topic_id'] . ') WHERE id = ' . $_POST['topic_id']); //send followup email to all topic contributors if (getOption("bb_notifyfollowup")) { $addresses = array(); $languages = db_array('SELECT code FROM languages'); foreach ($languages as $l) { $addresses[$l] = array(); } //get topic poster email, put in correct bucket $poster = db_grab("SELECT \n\t\t\t\tu.email, \n\t\t\t\tl.code \n\t\t\tFROM bb_topics t \n\t\t\tJOIN users u ON t.created_user = u.id \n\t\t\tJOIN languages l ON u.language_id = l.id\n\t\t\tWHERE u.is_active = 1 AND t.id = " . $_POST["topic_id"]); $addresses[$poster['code']][] = $poster['email']; //get followup poster emails $repliers = db_table("SELECT \n\t\t\t\tu.email,\n\t\t\t\tl.code\n\t\t\tFROM bb_followups f \n\t\t\tJOIN users u ON u.id = f.created_user \n\t\t\tJOIN languages l ON u.language_id = l.id\n\t\t\tWHERE u.is_active = 1 AND f.is_active = 1 AND f.topic_id = " . $_POST["topic_id"]); foreach ($repliers as $r) { $addresses[$r['code']][] = $r['email']; } foreach ($addresses as $lang => $emails) { $topic = db_grab('SELECT t.title' . langExt($lang) . ' title, y.title' . langExt($lang) . ' type, t.created_date FROM bb_topics t LEFT JOIN bb_topics_types y ON t.type_id = y.id WHERE t.id = ' . $_POST['topic_id']); $reply = db_grab('SELECT f.description' . langExt($lang) . ' description, ISNULL(u.nickname, u.firstname) firstname, u.lastname
if ($posting) { langTranslatePost('title'); $id = db_save('modules'); url_drop('id'); } echo drawTop(); if (url_id()) { //form $f = new form('modules', @$_GET['id']); $f->set_field(array('type' => 'text', 'name' => 'title' . langExt(), 'label' => getString('title'))); langUnsetFields($f, 'title'); langTranslateCheckbox($f); echo $f->draw(); } else { //modules list $t = new table('modules', drawHeader()); $t->set_column('is_selected', 'd', ' '); $t->set_column('draggy', 'd', ' '); $t->set_column('title', 'l', getString('title')); $t->set_column('pages', 'r'); $result = db_table('SELECT m.id, m.title' . langExt() . ' title, m.is_active, (SELECT COUNT(*) FROM pages p WHERE p.module_id = m.id AND p.modulette_id IS NULL) pages FROM modules m ORDER BY m.precedence'); $t->set_draggable('draggy'); foreach ($result as &$r) { $r['is_selected'] = draw_form_checkbox('foo', $r['is_active'], false, 'ajax_set(\'modules\', \'is_active\', ' . $r['id'] . ', ' . abs($r['is_active'] - 1) . ');'); $r['draggy'] = draw_img('/images/icons/move.png'); $r['title'] = draw_link('./?id=' . $r['id'], $r['title']); $r['pages'] = draw_link('pages.php?module_id=' . $r['id'], format_quantitize($r['pages'], 'page')); } echo $t->draw($result, 'No modules'); } echo drawBottom();
<?php include "../include.php"; echo drawTop(); if (url_id()) { $title = db_grab('SELECT title' . langExt() . ' title FROM press_clips_types WHERE id = ' . $_GET["id"]); $result = db_table('SELECT c.id, c.title' . langExt() . ' title, c.pub_date, c.publication' . langExt() . ' publication, ISNULL(c.created_date, c.updated_date) updated FROM press_clips c ' . getChannelsWhere('press_clips', 'c', 'clip_id') . ' AND c.type_id = ' . $_GET["id"] . ' ORDER BY updated DESC'); $t = new table('press_clips', drawHeader(false, $title)); $t->set_column('title', 'l', getString('title')); $t->set_column('publication', 'l', getString('publication')); $t->set_column('pub_date', 'r', getString('published')); foreach ($result as &$r) { $r['title'] = draw_link('clip.php?id=' . $r['id'], format_string($r['title'], 50)); $r['pub_date'] = format_date($r['pub_date']); } echo $t->draw($result, 'There are no clips tagged <i>' . $title . '</i>.'); } else { $t = new table('press_clips', drawHeader()); $t->set_column('category', 'l', getString('category')); $t->set_column('clips', 'r', getString('clips')); $result = db_table('SELECT t.id, t.title' . langExt() . ' category, (SELECT COUNT(*) FROM press_clips c WHERE c.type_id = t.id) clips FROM press_clips_types t ORDER BY t.precedence'); foreach ($result as &$r) { $r['category'] = draw_link(url_query_add(array('id' => $r['id']), false), $r['category']); } echo $t->draw($result); } echo drawBottom();
function drawBottom() { global $_josh, $modules, $helpdeskOptions, $helpdeskStatus, $modulettes, $page; $return = ' </div> <div id="right"> <div id="tools"> <a class="right button" href="/index.php?action=logout">' . getString('log_out') . '</a> ' . getString('hello') . ' <a href="/staff/view.php?id=' . $_SESSION['user_id'] . '"><b>' . $_SESSION['full_name'] . '</b></a>'; //search $return .= '<form name="search" accept-charset="utf-8" method="get" action="/staff/search.php" onsubmit="javascript:return doSearch(this);"> <input type="text" name="q" placeholder="' . getString('staff_search') . '"/> </form>'; //channel or language selectors if (getOption('channels')) { //$return .= draw_form_select('channel_id', 'SELECT id, title' . langExt() . ' title FROM channels WHERE is_active = 1 AND is_private = 0 ORDER BY precedence', $_SESSION['channel_id'], false, 'channels', 'url_query_set(\'channel_id\', this.value)', getString('networks_view_all')); $return .= draw_form_select('channel_id', 'SELECT c.id, c.title' . langExt() . ' title FROM channels c WHERE c.is_active = 1 AND (c.is_private = 0 OR (SELECT COUNT(*) FROM users_to_channels u2c WHERE u2c.channel_id = c.id AND u2c.user_id = ' . user() . ') > 0) ORDER BY precedence', $_SESSION['channel_id'], false, 'channels', 'url_query_set(\'channel_id\', this.value)', getString('networks_view_all')); } if (getOption('languages')) { $return .= draw_form_select('language_id', 'SELECT id, title FROM languages ORDER BY title', $_SESSION['language_id'], true, 'languages', 'url_query_set(\'language_id\', this.value)'); } //links $links = db_table('SELECT title' . langExt() . ' title, url FROM links WHERE is_active = 1 ORDER BY precedence'); foreach ($links as &$l) { $l = draw_link($l['url'], $l['title'], true); } $return .= draw_div('#links', draw_container('h3', getString('links')) . (admin() ? draw_link('/a/admin/links.php', getString('edit'), false, array('class' => 'right button')) : false) . draw_list($links)); $return .= '</div>'; foreach ($modules as $m) { $return .= ' <table class="right ' . $m['folder'] . '" cellspacing="1"> <tr> <td colspan="2" class="head" style="background-color:#' . $m['color'] . ';"> <a href="/' . $m['folder'] . '/" class="left">' . $m['title'] . '</a> ' . draw_img('/images/arrows-new/' . format_boolean($m['is_closed'], 'up|down') . '.png', url_query_add(array('module' => $m['id']), false)) . ' </td> </tr>'; if (!$m['is_closed']) { include DIRECTORY_ROOT . DIRECTORY_SEPARATOR . $m['folder'] . DIRECTORY_SEPARATOR . 'pallet.php'; } $return .= '</table>'; } $return .= '</div> <div id="footer">'; //if (admin()) $return .= 'page rendered in ' . format_time_exec() . '<br/>'; $return .= getString('copyright') . '<br/>'; if (getOption('legal')) { $return .= draw_link('/login/legal.php', getString('legal_title')); } $return .= '</div></div> <div id="subfooter"></div> </body> </html>'; //record pageview if ($page['id'] && user()) { db_query('INSERT INTO pages_views ( page_id, user_id, timestamp ) VALUES ( ' . $page['id'] . ', ' . user('NULL') . ', GETDATE() )'); } return $return; }
<?php } ?> </td> </tr> <?php } ?> </table> <?php } else { //main table $result = db_table('SELECT e.id, e.title' . langExt() . ' title, t.title' . langExt() . ' "group", e2t.type_id FROM external_orgs e JOIN external_orgs_to_types e2t ON e.id = e2t.org_id JOIN external_orgs_types t ON e2t.type_id = t.id WHERE e.is_active = 1 ORDER BY t.title, e.title '); $t = new table('external_orgs_types', drawHeader(array('#bottom' => getString('add_new')))); $t->set_column('title', 'l', getString('title')); foreach ($result as &$r) { $r['group'] = draw_link('./type.php?id=' . $r['type_id'], $r['group']); $r['title'] = draw_link('./?id=' . $r['id'], $r['title']); } echo $t->draw($result, 'There are no external orgs added yet.'); //add new include 'edit.php'; } echo drawBottom();
<?php include "../../include.php"; echo drawTop(); $blurbs = db_table("SELECT \n\t\tr.id,\n\t\tr.title,\n\t\tt.icon,\n\t\tISNULL(r.updated_date, r.created_date) updated\n\t\tFROM employer_strategy_resources r\n\t\tJOIN docs_types t ON r.type_id = t.id\n\t\tWHERE r.is_active = 1\n\t\tORDER BY updated DESC", 20); $t = new table("web_news_blurbs"); $t->set_column("icon"); $t->set_column("title"); $t->set_column("updated", "r"); $t->set_title(drawHeader(array("add new" => "edit/"))); foreach ($blurbs as &$b) { $b["icon"] = draw_img($b["icon"]); $b["title"] = draw_link("edit/?id=" . $b["id"], $b["title"]); $b["updated"] = format_date($b["updated"]); } echo $t->draw($blurbs); echo drawBottom();
if ($_GET['doc_id'] == 'new') { $_GET['doc_id'] = false; } $f = new form('dl_docs', @$_GET['doc_id'], ($_GET['doc_id'] ? 'Edit' : 'Add') . ' Document'); $f->set_title_prefix($page['breadcrumbs']); $f->set_field(array('name' => 'title', 'label' => getString('title'), 'type' => 'text')); $f->unset_fields('extension'); $f->set_field(array('name' => 'content', 'label' => getString('file'), 'type' => 'file', 'additional' => getString('upload_max') . file_get_max())); $f->set_field(array('name' => 'categories', 'label' => getString('categories'), 'type' => 'checkboxes', 'options_table' => 'dl_categories', 'option_title' => 'title', 'linking_table' => 'dl_docs_to_categories', 'object_id' => 'doc_id', 'option_id' => 'category_id')); echo $f->draw(); } else { $result = db_table('SELECT d.id, d.title, ' . db_updated('d') . ', d.extension, c.title "group" FROM dl_docs d JOIN dl_docs_to_categories d2c ON d.id = d2c.doc_id JOIN dl_categories c ON d2c.category_id = c.id ORDER BY c.precedence, d.title;'); $links = $page['is_admin'] ? array(url_query_add(array('doc_id' => 'new'), false) => getString('add_new')) : false; $t = new table('dl_docs', drawHeader($links)); $t->set_column('icon', 'd', ' '); $t->set_column('title', 'l', getString('title')); $t->set_column('updated', 'r', getString('updated')); foreach ($result as &$r) { $link = 'info.php?id=' . $r['id']; $r['icon'] = file_icon($r['extension'], $link); $r['title'] = draw_link($link, $r['title']); if (getOption('languages')) { $r['title'] .= ' (' . $r['language'] . ')';
<?php if (!defined('ELK') && file_exists(dirname(__FILE__) . '/SSI.php')) { require_once dirname(__FILE__) . '/SSI.php'; } elseif (!defined('ELK')) { die('<b>Error:</b> Cannot install - please verify you put this in the same place as ELK\'s index.php.'); } $db_table = db_table(); $db_table->db_add_column('{db_prefix}message_likes', array('name' => 'like_timestamp', 'type' => 'int', 'size' => 10, 'unsigned' => true, 'default' => 0)); $db_table->db_change_column('{db_prefix}postby_emails_filters', 'filter_style', array('type' => 'char', 'size' => '6')); $db_table->db_change_column('{db_prefix}mail_queue', 'message_id', array('type' => 'varchar', 'size' => '12')); updateSettings(array('elkVersion' => '1.0.1')); if (ELK == 'SSI') { echo 'Database changes were carried out successfully.'; }
</tr> <?php } if ($r["attachments"]) { ?> <tr height="30"> <td class="left"><?php echo format_quantitize($r['attachments'], 'Attachment'); ?> </td> <td> <table class="nospacing"> <?php $attachments = db_table('SELECT id, title, extension FROM helpdesk_tickets_attachments WHERE ticketID = ' . $_GET["id"]); foreach ($attachments as $a) { ?> <tr height="21"> <td width="18"><?php echo file_icon($a['extension'], 'download.php?id=' . $a["id"]); ?> </td> <td><a href="download.php?id=<?php echo $a["id"]; ?> "><?php echo $a["title"]; ?>