function modif_mdp($newpw) { $login = $_SESSION['login']; $db = db_connection(); $req = $db->prepare('UPDATE db_login SET mdp = ? WHERE login = ?'); $req->execute(array($newpw, $login)); }
/** * clean data */ function clean(&$data) { foreach ($data as $key => $post) { if (is_array($post)) { clean($post); } else { $clean[$key] = strip_tags(mysql_real_escape_string($post, db_connection())); } } $data = $clean; }
function insert_persona($persona) { include_once 'db_connection.php'; if (!($conn = db_connection('localhost', 'root', '', 'academia'))) { return false; } // var_dump($conn); // mysqli_select_db($conn, "academia"); // echo $persona->to_sql(); if ($q = mysqli_query($conn, $persona->to_sql())) { mysqli_close($conn); return true; } return false; }
function i18n_setLanguage($lang) { global $common_language; if ($lang == 'C') { setcookie('synchrotronLanguage', '', 0, $auth_path); unset($GLOBALS['common_language']); unset($common_language); unset($_COOKIE['synchrotronLanguage']); return; } $db = db_connection(); sql_addToWhereClause($where, 'WHERE', 'code', '=', $lang); $query = db_query($db, "select id from languages {$where};"); if (db_numRows($query) > 0) { list($common_language) = db_row($query, 0); $common_language = intval($common_language); } }
function exec_query($query) { $connection = db_connection(); $result = $connection->query($query); if (!$result) { die("The query is invalid.<br/>"); } $result_in_arr = array(); if (explode(" ", $query)[0] == "SELECT") { while ($db_record = $result->fetch_assoc()) { foreach ($db_record as $key => $value) { $result_in_arr[$key] = $value; } } $result->free_result(); } $connection->close(); return $result_in_arr; }
function get_personas() { include_once 'db_connection.php'; $conn = db_connection('localhost', 'root', '', 'academia'); $sql = "SELECT * FROM personas;"; $personas = array(); $errors = array(); if ($query = mysqli_query($conn, $sql)) { while ($row = mysqli_fetch_assoc($query)) { $personas[] = $row; } } else { $errors[] = mysqli_error($conn); } mysqli_close($conn); if (empty($errors)) { return $personas; } return array('errors' => $errors); }
$fdate = htmlspecialchars($_POST['due_date']); /*if(preg_match('/[^\w\s]/i', $fname) || preg_match('/[^\w\s]/i', $lname)) { fail('Invalid name provided.'); } if( empty($fname) || empty($lname) ) { fail('Please enter a first and last name.'); } if( empty($gender) ) { fail('Please select a gender.'); } if( empty($minutes) || empty($seconds) ) { fail('Please enter minutes and seconds.'); }*/ //$time = $minutes.":".$seconds; $query = "INSERT INTO assignments SET course_name='{$fcourse}', course_code='{$fcode}', assignment_name='{$fname}', due_date='{$fdate}'"; $result = db_connection($query); if ($result) { $msg = "Assignment: " . $fcode . " " . $fname . " added successfully"; success($msg); } else { fail('Insert failed.'); } exit; } } function fail($message) { die(json_encode(array('status' => 'fail', 'message' => $message))); } function success($message) {
function processProviderAssets($assets, $packageBasePath, $provider, $providerId, $config) { global $verbose; $metadataPath = $config['metadata']; if (empty($metadataPath)) { $metadataPath = 'metadata.desktop'; } $recreateCategoriesFile = false; $categories = array(); $db = db_connection('write'); foreach ($assets as $asset => $path) { if ($verbose) { print "Processing {$providerId} {$asset} at {$path}\n"; } if (!is_file("{$path}/{$metadataPath}")) { if ($verbose) { print "No such thing as {$path}/{$metadataPath}, perhaps it was deleted?\n"; } deleteAsset($providerId, $asset); continue; } $metadata = new INIFile("{$path}/{$metadataPath}"); $plugin = $metadata->getValue('X-KDE-PluginInfo-Name', 'Desktop Entry'); if (empty($plugin)) { print "No X-KDE-PluginInfo-Name entry in {$path}/{$metadataPath}\n"; continue; } $packageFile = $metadata->getValue('X-Synchrotron-ContentUrl', 'Desktop Entry'); $externalPackage = !empty($packageFile); if (!$externalPackage) { $packageFile = createPackage($plugin, $path, $packageBasePath, $config); } if (!$packageFile) { deleteAsset($providerId, $asset); continue; } $category = $metadata->getValue('X-KDE-PluginInfo-Category', 'Desktop Entry'); if (empty($category)) { $category = 'Miscelaneous'; } if (isset($categories[$category])) { $categoryId = $categories[$category]; } else { unset($where); sql_addToWhereClause($where, '', 'provider', '=', $providerId); global $db_type; if ($db_type == 'postgres') { sql_addToWhereClause($where, 'and', 'name', 'ILIKE', $category); } else { sql_addToWhereClause($where, 'and', 'name', 'LIKE', $category); } $query = db_query($db, "SELECT id FROM categories WHERE {$where}"); if (db_numRows($query) < 1) { unset($fields, $values); sql_addIntToInsert($fields, $values, 'provider', $providerId); sql_addScalarToInsert($fields, $values, 'name', $category); db_insert($db, 'categories', $fields, $values); $query = db_query($db, "SELECT id FROM categories WHERE {$where}"); $recreateCategoriesFile = true; } list($categoryId) = db_row($query, 0); $categories[$category] = $categoryId; } unset($where); sql_addToWhereClause($where, '', 'provider', '=', $providerId); sql_addToWhereClause($where, 'and', 'id', '=', $plugin); $query = db_query($db, "select * from content where {$where};"); if (db_numRows($query) > 0) { // just update the field unset($fields); sql_addScalarToUpdate($fields, 'version', $metadata->getValue('X-KDE-PluginInfo-Version', 'Desktop Entry')); sql_addScalarToUpdate($fields, 'author', $metadata->getValue('X-KDE-PluginInfo-Author', 'Desktop Entry')); sql_addScalarToUpdate($fields, 'homepage', $metadata->getValue('X-KDE-PluginInfo-Website', 'Desktop Entry')); //FIXME: get preview image from asset dir! sql_addScalarToUpdate($fields, 'preview', <image path>); sql_addScalarToUpdate($fields, 'name', $metadata->getValue('Name', 'Desktop Entry')); // FIXME: i18n sql_addScalarToUpdate($fields, 'description', $metadata->getValue('Comment', 'Desktop Entry')); sql_addIntToUpdate($fields, 'category', $categoryId); sql_addRawToUpdate($fields, 'updated', 'current_timestamp'); sql_addScalarToUpdate($fields, 'package', $packageFile); sql_addBoolToUpdate($fields, 'externalPackage', $externalPackage); db_update($db, 'content', $fields, $where); } else { // new asset! unset($fields, $values); sql_addIntToInsert($fields, $values, 'provider', $providerId); sql_addScalarToInsert($fields, $values, 'id', $plugin); sql_addScalarToInsert($fields, $values, 'version', $metadata->getValue('X-KDE-PluginInfo-Version', 'Desktop Entry')); sql_addScalarToInsert($fields, $values, 'author', $metadata->getValue('X-KDE-PluginInfo-Author', 'Desktop Entry')); sql_addScalarToInsert($fields, $values, 'homepage', $metadata->getValue('X-KDE-PluginInfo-Website', 'Desktop Entry')); //FIXME: get preview image from asset dir! sql_addScalarToInsert($fields, $values, 'preview', <image path>); sql_addScalarToInsert($fields, $values, 'name', $metadata->getValue('Name', 'Desktop Entry')); // FIXME: i18n sql_addScalarToInsert($fields, $values, 'description', $metadata->getValue('Comment', 'Desktop Entry')); sql_addIntToInsert($fields, $values, 'category', $categoryId); sql_addScalarToInsert($fields, $values, 'package', $packageFile); sql_addBoolToInsert($fields, $values, 'externalPackage', $externalPackage); db_insert($db, 'content', $fields, $values); } } if ($recreateCategoriesFile) { createCategoriesFile($provider); } }
function install_done() { global $output, $db, $mybb, $errors, $cache, $lang; if (empty($mybb->input['adminuser'])) { $errors[] = $lang->admin_step_error_nouser; } if (empty($mybb->input['adminpass'])) { $errors[] = $lang->admin_step_error_nopassword; } if ($mybb->input['adminpass'] != $mybb->input['adminpass2']) { $errors[] = $lang->admin_step_error_nomatch; } if (empty($mybb->input['adminemail'])) { $errors[] = $lang->admin_step_error_noemail; } if (is_array($errors)) { create_admin_user(); } require MYBB_ROOT . 'inc/config.php'; $db = db_connection($config); require MYBB_ROOT . 'inc/settings.php'; $mybb->settings =& $settings; ob_start(); $output->print_header($lang->finish_setup, 'finish'); echo $lang->done_step_usergroupsinserted; // Insert all of our user groups from the XML file $settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml'); $parser = new XMLParser($settings); $parser->collapse_dups = 0; $tree = $parser->get_tree(); $admin_gid = ''; $group_count = 0; foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) { // usergroup[cancp][0][value] $new_group = array(); foreach ($usergroup as $key => $value) { if ($key == "gid" || !is_array($value)) { continue; } $new_group[$key] = $db->escape_string($value[0]['value']); } $return_gid = $db->insert_query("usergroups", $new_group); // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs) if ($new_group['cancp'] == 1 && !$admin_gid) { $admin_gid = $return_gid; } $group_count++; } echo $lang->done . '</p>'; echo $lang->done_step_admincreated; $now = TIME_NOW; $salt = random_str(); $loginkey = generate_loginkey(); $saltedpw = md5(md5($salt) . md5($mybb->input['adminpass'])); $newuser = array('username' => $db->escape_string($mybb->input['adminuser']), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->input['adminemail']), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'msn' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'remember' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_string(get_ip()), 'longregip' => intval(ip2long(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1); $db->insert_query('users', $newuser); echo $lang->done . '</p>'; echo $lang->done_step_adminoptions; $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml'); $parser = new XMLParser($adminoptions); $parser->collapse_dups = 0; $tree = $parser->get_tree(); $insertmodule = array(); $db->delete_query("adminoptions"); // Insert all the admin permissions foreach ($tree['adminoptions'][0]['user'] as $users) { $uid = $users['attributes']['uid']; foreach ($users['permissions'][0]['module'] as $module) { foreach ($module['permission'] as $permission) { $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value']; } } $defaultviews = array(); foreach ($users['defaultviews'][0]['view'] as $view) { $defaultviews[$view['attributes']['type']] = $view['value']; } $adminoptiondata = array('uid' => intval($uid), 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(serialize($insertmodule)), 'defaultviews' => $db->escape_string(serialize($defaultviews))); $insertmodule = array(); $db->insert_query('adminoptions', $adminoptiondata); } echo $lang->done . '</p>'; // Automatic Login my_unsetcookie("sid"); my_unsetcookie("mybbuser"); my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true); ob_end_flush(); // Make fulltext columns if supported if ($db->supports_fulltext('threads')) { $db->create_fulltext_index('threads', 'subject'); } if ($db->supports_fulltext_boolean('posts')) { $db->create_fulltext_index('posts', 'message'); } // Register a shutdown function which actually tests if this functionality is working add_shutdown('test_shutdown_function'); echo $lang->done_step_cachebuilding; require_once MYBB_ROOT . 'inc/class_datacache.php'; $cache = new datacache(); $cache->update_version(); $cache->update_attachtypes(); $cache->update_smilies(); $cache->update_badwords(); $cache->update_usergroups(); $cache->update_forumpermissions(); $cache->update_stats(); $cache->update_forums(); $cache->update_moderators(); $cache->update_usertitles(); $cache->update_reportedposts(); $cache->update_mycode(); $cache->update_posticons(); $cache->update_update_check(); $cache->update_tasks(); $cache->update_spiders(); $cache->update_bannedips(); $cache->update_banned(); $cache->update_birthdays(); $cache->update("plugins", array()); $cache->update("internal_settings", array('encryption_key' => random_str(32))); echo $lang->done . '</p>'; echo $lang->done_step_success; $written = 0; if (is_writable('./')) { $lock = @fopen('./lock', 'w'); $written = @fwrite($lock, '1'); @fclose($lock); if ($written) { echo $lang->done_step_locked; } } if (!$written) { echo $lang->done_step_dirdelete; } echo $lang->done_subscribe_mailing; $output->print_footer(''); }
function is_validated($email) { $con = db_connection(); $email = mysql_real_escape_string($string); $result = mysql_query("SELECT validated FROM users WHERE email='{$email}'"); if (mysql_num_rows($result) > 0) { $validated = int_to_bool(mysql_result($result, 0)); db_close($con); return $result; } else { return false; } }
<?php require_once "conf/db_connection.php"; require_once "header.php"; require_once "left_nav.php"; ?> <div id="content"> <br /> <center> <?php db_connection(); $query = "SELECT max(id_producto) as 'maximo' FROM producto"; $result = mysql_query($query); $datos = mysql_fetch_array($result); $r1 = rand(14, $datos["maximo"]); $r2 = rand(14, $datos["maximo"]); $r3 = rand(14, $datos["maximo"]); $query = "SELECT * FROM producto WHERE id_producto IN ({$r1},{$r2},{$r3})"; $result = mysql_query($query); while ($datos = mysql_fetch_array($result)) { $id = $datos["id_producto"]; $nombre = $datos["nombre"]; $precio = $datos["precio"]; $img = $datos["imagen"]; //$img = "<img src=\'". $image ."' width=\'100\' height=\'100\' />"; echo " <img src='" . $datos["imagen"] . "' width='100' height='100' /> <br /><br /> <a href='catalogo.php?id=" . $datos["id_producto"] . "&desc=" . $datos["descripcion"] . "&nom=" . $datos["nombre"] . "'>" . $datos["nombre"] . " </a><span class='precio'>RD\$ " . $datos["precio"] . ".00</span><a href='catalogo.php?id=" . $datos["id_producto"] . "&desc=" . $datos["descripcion"] . "&nom=" . $datos["nombre"] . "'> <img src='imagen/ordenar.png' with='30' height='30' /></a> <a id='add' onclick='addcart({$id},\"{$nombre}\",{$precio},1,\"{$img}\");'><img src='imagen/addtocart2.jpg' with='30' height='30' id='icart' /></a><br /><br /><br />"; } ?> </center> </div>
if (!canAccessApi($_SERVER['REMOTE_ADDR'])) { printHeader(0, 0, 0, _("Too many requests from {$_SERVER['REMOTE_ADDR']}"), 200); printFooter(); exit; } $pagesize = intval($_GET['pagesize']); $page = max(0, intval($_GET['page'])); $searchTerm = $_GET['search']; $sortMode = $_GET['sortmode']; $provider = $_GET['provider']; if (empty($provider)) { printHeader(0, $pagesize, 0, _("Invalid provider")); printFooter(); exit; } $db = db_connection(); unset($where); sql_addToWhereClause($where, '', 'p.name', '=', $provider); $updatedSince = intval($_GET['updatedsince']); if ($updatedSince > 0) { sql_addToWhereClause($where, 'and', "extract('epoch' from c.updated)", '>=', $updatedSince); } $createdSince = intval($_GET['createdsince']); if ($createdsince > 0) { sql_addToWhereClause($where, 'and', "extract('epoch' from c.created)", '>=', $createdSince); } list($totalItemCount) = db_row(db_query($db, "SELECT count(c.id) FROM content c LEFT JOIN providers p ON (c.provider = p.id) WHERE {$where};"), 0); if ($totalItemCount < 1) { printHeader(0, $pagesize); printFooter(); exit;
function query_full_day($date, $scope) { // // Used to generate all three of the "current" charts that shows daily activity. // $connection = db_connection(); // should always a date, and should always be formatted YYYY-MM-DD // not always a scope, but always an int if there is one. if ($date == date("Y-m-d")) { // if the date is today... if (isset($scope)) { // ...and it's scoped. $whereClause = "date > DATE_SUB(NOW(), INTERVAL " . $scope . " HOUR)"; } else { // ...with no scope. $whereClause = "date(date) = date(NOW())"; } } else { // It's not today... if (isset($scope)) { // ...but it is scoped. $whereClause = "date > DATE_SUB(DATE_ADD(date('" . $date . "'), INTERVAL 1 DAY), INTERVAL " . $scope . " HOUR) AND\n\t\t\t\t\t\t\tdate < DATE_ADD(date('" . $date . "'), INTERVAL 1 DAY)"; } else { // ...with no scope. $whereClause = "date(date) = date('" . $date . "')"; } } $query_summary = "SELECT *\n\t\t\t\t\t\tFROM monitormate_summary\n\t\t\t\t\t\tWHERE date(date) = date('" . $date . "')\n\t\t\t\t\t\tORDER BY date"; // WHERE ".$whereClause." $query_cc = "SELECT *\n\t\t\t\t\t\tFROM monitormate_cc\n\t\t\t\t\t\tWHERE " . $whereClause . "\n\t\t\t\t\t\tORDER BY date"; // if there's more than one charge controller (fm/mx) we should get the cc totals. $query_cc_totals = "SELECT date, SUM(charge_current) AS total_current, battery_voltage\n\t\t\t\t\t\tFROM `monitormate_cc`\n\t\t\t\t\t\tWHERE " . $whereClause . "\n\t\t\t\t\t\tGROUP BY date\n\t\t\t\t\t\tORDER BY date"; $query_fndc = "SELECT *\n\t\t\t\t\t\tFROM monitormate_fndc\n\t\t\t\t\t\tWHERE " . $whereClause . "\n\t\t\t\t\t\tORDER BY date"; $query_fx = "SELECT *\n\t\t\t\t\t\tFROM monitormate_fx\n\t\t\t\t\t\tWHERE " . $whereClause . "\n\t\t\t\t\t\tORDER BY date"; $query_radian = "SELECT *\n\t\t\t\t\t\tFROM monitormate_radian\n\t\t\t\t\t\tWHERE " . $whereClause . "\n\t\t\t\t\t\tORDER BY date"; $result_summary = mysql_query($query_summary, $connection); $result_cc = mysql_query($query_cc, $connection); $result_fndc = mysql_query($query_fndc, $connection); $result_fx = mysql_query($query_fx, $connection); $result_radian = mysql_query($query_radian, $connection); $full_day_querys = array("cc" => $result_cc, "fndc" => $result_fndc, "fx" => $result_fx, "radian" => $result_radian); // Summary only needs to net values to be computed, then add to full_day_data while ($row = mysql_fetch_assoc($result_summary)) { set_elementTypes($row); // row passed as a reference. $row['kwh_net'] = $row['kwh_in'] - $row['kwh_out']; $row['ah_net'] = $row['ah_in'] - $row['ah_out']; $full_day_data["summary"] = $row; } // All other queries need a proper timestamp added. foreach ($full_day_querys as $i) { while ($row = mysql_fetch_assoc($i)) { set_elementTypes($row); // row passed as a reference. $timestamp = strtotime($row['date']) * 1000; // get timestamp in seconds, convert to milliseconds $stampedRow = array("timestamp" => $timestamp) + $row; // put it in an assoc array and merge them $full_day_data[$row["device_id"]][$row["address"]][] = $stampedRow; } } // there's more than one charge controller, query the totals, timestamp them and add them. if (count($full_day_data[3]) > 1) { $result_cc_totals = mysql_query($query_cc_totals, $connection); while ($row = mysql_fetch_assoc($result_cc_totals)) { set_elementTypes($row); // row passed as a reference. $timestamp = strtotime($row['date']) * 1000; // get timestamp in seconds, convert to milliseconds $stampedRow = array("timestamp" => $timestamp) + $row; // put it in an assoc array and merge them $full_day_data[3]["totals"][] = $stampedRow; } } if (isset($_GET["debug"])) { echo $query_cc . '<br/>'; echo '<pre>'; print_r($full_day_data); echo '</pre>'; } else { $json_full_day = json_encode($full_day_data); echo $json_full_day; } }
function db_delete($id) { $db = db_connection(); return db_backend_delete($db, intval($id)); }
} // Attempt a save of the database connection details $error_message = false; if ($_SESSION['x7chat_install']['type'] == 'install' && (!empty($_POST) && $_SESSION['x7chat_install']['step'] === 1 || $_SESSION['x7chat_install']['step'] === 2 && !$db && !empty($_SESSION['x7chat_install']['config_contents']))) { try { if ($_SESSION['x7chat_install']['step'] === 1) { $check_db = db_connection($_POST); $_SESSION['x7chat_install']['config_contents'] = $contents = '<?php return ' . var_export(array('user' => $_POST['user'], 'pass' => $_POST['pass'], 'dbname' => $_POST['dbname'], 'host' => $_POST['host'], 'prefix' => $_POST['prefix'], 'auth_plugin' => '', 'auth_api_endpoint' => '', 'api_key' => hash('sha256', microtime(TRUE) . print_r($_SERVER, 1) . mt_rand(0, mt_getrandmax()) . crypt(mt_rand(0, mt_getrandmax()) . microtime(TRUE) . print_r($_SERVER, 1))), 'debug' => false), 1) . ';'; } else { $contents = $_SESSION['x7chat_install']['config_contents']; } if (is_writable('../config.php')) { $written = file_put_contents('../config.php', $contents); if ($written) { $config = (require '../config.php'); $db = db_connection($config); } } else { $written = false; } $_SESSION['x7chat_install']['step'] = 2; } catch (Exception $ex) { $error_message = "The connection to the database failed: {$ex->getMessage()}"; } } // Check configuration file for valid values & setup database tables if ($_SESSION['x7chat_install']['step'] === 2 && $_SESSION['x7chat_install']['type'] == 'install') { if ($db) { unset($_SESSION['x7chat_install']['config_contents']); try { patch_sql($db, $config['prefix']);
function transaction(closure $action) { $config = db_config(); $connection = db_connection($config); $began = $connection->beginTransaction(); if (!$began) { throw new Exception('can not start transaction'); } try { $res = $action(); $connection->commit(); return $res; } catch (Exception $ex) { $connection->rollBack(); throw $ex; } }
function db_canAccessApi($addr) { $res = db_query(db_connection(), 'SELECT synchrotron_canAccessApi(\'' . addslashes($addr) . '\');'); list($res) = db_row($res, 0); return db_boolean($res); }
/** * Installation is finished */ function install_done() { global $output, $db, $mybb, $errors, $cache, $lang; if (empty($mybb->input['adminuser'])) { $errors[] = $lang->admin_step_error_nouser; } if (empty($mybb->input['adminpass'])) { $errors[] = $lang->admin_step_error_nopassword; } if ($mybb->get_input('adminpass') != $mybb->get_input('adminpass2')) { $errors[] = $lang->admin_step_error_nomatch; } if (empty($mybb->input['adminemail'])) { $errors[] = $lang->admin_step_error_noemail; } if (is_array($errors)) { create_admin_user(); } require MYBB_ROOT . 'inc/config.php'; $db = db_connection($config); require MYBB_ROOT . 'inc/settings.php'; $mybb->settings =& $settings; ob_start(); $output->print_header($lang->finish_setup, 'finish'); echo $lang->done_step_usergroupsinserted; // Insert all of our user groups from the XML file $usergroup_settings = file_get_contents(INSTALL_ROOT . 'resources/usergroups.xml'); $parser = new XMLParser($usergroup_settings); $parser->collapse_dups = 0; $tree = $parser->get_tree(); $admin_gid = ''; $group_count = 0; foreach ($tree['usergroups'][0]['usergroup'] as $usergroup) { // usergroup[cancp][0][value] $new_group = array(); foreach ($usergroup as $key => $value) { if (!is_array($value)) { continue; } $new_group[$key] = $db->escape_string($value[0]['value']); } $db->insert_query("usergroups", $new_group, false); // If this group can access the admin CP and we haven't established the admin group - set it (just in case we ever change IDs) if ($new_group['cancp'] == 1 && !$admin_gid) { $admin_gid = $usergroup['gid'][0]['value']; } $group_count++; } // Restart usergroup sequence with correct # of groups if ($config['database']['type'] == "pgsql") { $db->query("SELECT setval('{$config['database']['table_prefix']}usergroups_gid_seq', (SELECT max(gid) FROM {$config['database']['table_prefix']}usergroups));"); } echo $lang->done . '</p>'; echo $lang->done_step_admincreated; $now = TIME_NOW; $salt = random_str(); $loginkey = generate_loginkey(); $saltedpw = md5(md5($salt) . md5($mybb->get_input('adminpass'))); $newuser = array('username' => $db->escape_string($mybb->get_input('adminuser')), 'password' => $saltedpw, 'salt' => $salt, 'loginkey' => $loginkey, 'email' => $db->escape_string($mybb->get_input('adminemail')), 'usergroup' => $admin_gid, 'regdate' => $now, 'lastactive' => $now, 'lastvisit' => $now, 'website' => '', 'icq' => '', 'aim' => '', 'yahoo' => '', 'skype' => '', 'google' => '', 'birthday' => '', 'signature' => '', 'allownotices' => 1, 'hideemail' => 0, 'subscriptionmethod' => '0', 'receivepms' => 1, 'pmnotice' => 1, 'pmnotify' => 1, 'buddyrequestspm' => 1, 'buddyrequestsauto' => 0, 'showimages' => 1, 'showvideos' => 1, 'showsigs' => 1, 'showavatars' => 1, 'showquickreply' => 1, 'invisible' => 0, 'style' => '0', 'timezone' => 0, 'dst' => 0, 'threadmode' => '', 'daysprune' => 0, 'regip' => $db->escape_binary(my_inet_pton(get_ip())), 'language' => '', 'showcodebuttons' => 1, 'tpp' => 0, 'ppp' => 0, 'referrer' => 0, 'buddylist' => '', 'ignorelist' => '', 'pmfolders' => '', 'notepad' => '', 'showredirect' => 1, 'usernotes' => ''); $db->insert_query('users', $newuser); echo $lang->done . '</p>'; echo $lang->done_step_adminoptions; $adminoptions = file_get_contents(INSTALL_ROOT . 'resources/adminoptions.xml'); $parser = new XMLParser($adminoptions); $parser->collapse_dups = 0; $tree = $parser->get_tree(); $insertmodule = array(); $db->delete_query("adminoptions"); // Insert all the admin permissions foreach ($tree['adminoptions'][0]['user'] as $users) { $uid = $users['attributes']['uid']; foreach ($users['permissions'][0]['module'] as $module) { foreach ($module['permission'] as $permission) { $insertmodule[$module['attributes']['name']][$permission['attributes']['name']] = $permission['value']; } } $defaultviews = array(); foreach ($users['defaultviews'][0]['view'] as $view) { $defaultviews[$view['attributes']['type']] = $view['value']; } $adminoptiondata = array('uid' => (int) $uid, 'cpstyle' => '', 'notes' => '', 'permissions' => $db->escape_string(my_serialize($insertmodule)), 'defaultviews' => $db->escape_string(my_serialize($defaultviews))); $insertmodule = array(); $db->insert_query('adminoptions', $adminoptiondata); } echo $lang->done . '</p>'; // Automatic Login my_unsetcookie("sid"); my_unsetcookie("mybbuser"); my_setcookie('mybbuser', $uid . '_' . $loginkey, null, true); ob_end_flush(); // Make fulltext columns if supported if ($db->supports_fulltext('threads')) { $db->create_fulltext_index('threads', 'subject'); } if ($db->supports_fulltext_boolean('posts')) { $db->create_fulltext_index('posts', 'message'); } echo $lang->done_step_cachebuilding; require_once MYBB_ROOT . 'inc/class_datacache.php'; $cache = new datacache(); $cache->update_version(); $cache->update_attachtypes(); $cache->update_smilies(); $cache->update_badwords(); $cache->update_usergroups(); $cache->update_forumpermissions(); $cache->update_stats(); $cache->update_statistics(); $cache->update_forums(); $cache->update_moderators(); $cache->update_usertitles(); $cache->update_reportedcontent(); $cache->update_awaitingactivation(); $cache->update_mycode(); $cache->update_profilefields(); $cache->update_posticons(); $cache->update_spiders(); $cache->update_bannedips(); $cache->update_banned(); $cache->update_bannedemails(); $cache->update_birthdays(); $cache->update_groupleaders(); $cache->update_threadprefixes(); $cache->update_forumsdisplay(); $cache->update("plugins", array()); $cache->update("internal_settings", array('encryption_key' => random_str(32))); $cache->update_default_theme(); $version_history = array(); $dh = opendir(INSTALL_ROOT . "resources"); while (($file = readdir($dh)) !== false) { if (preg_match("#upgrade([0-9]+).php\$#i", $file, $match)) { $version_history[$match[1]] = $match[1]; } } sort($version_history, SORT_NUMERIC); $cache->update("version_history", $version_history); // Schedule an update check so it occurs an hour ago. Gotta stay up to date! $update['nextrun'] = TIME_NOW - 3600; $db->update_query("tasks", $update, "tid='12'"); $cache->update_update_check(); $cache->update_tasks(); echo $lang->done . '</p>'; echo $lang->done_step_success; $written = 0; if (is_writable('./')) { $lock = @fopen('./lock', 'w'); $written = @fwrite($lock, '1'); @fclose($lock); if ($written) { echo $lang->done_step_locked; } } if (!$written) { echo $lang->done_step_dirdelete; } echo $lang->done_whats_next; $output->print_footer(''); }
#!/usr/bin/env php <?php /* * Copyright 2011 Aaron Seigo <*****@*****.**> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ include_once 'config.php'; include_once "{$common_includePath}/db.php"; $db = SynchrotronDBConnection::copy('write', $synchrotron_dbs['default']); $db->db_username = $db_writeusername; $db->db_password = $db_writepassword; db_register($db); $old_time = time() - 60 * 15; $db = db_connection('write'); db_query($db, "DELETE FROM accesses WHERE ts < {$old_time};");
$mail_smarty->assign("catalogs_secure", $xcart_catalogs_secure); # # Files directories # $files_dir_name = $xcart_dir . $files_dir; $files_http_location = $http_location . $files_webdir; $smarty->assign("files_location", $files_dir_name); $templates_repository = $xcart_dir . $templates_repository_dir; # # Include functions # include_once $xcart_dir . "/include/bench.php"; # # Connect to database # db_connection($sql_host, $sql_user, $sql_db, $sql_password); $tmp = func_query_first("SHOW VARIABLES LIKE 'max_allowed_packet'"); $sql_max_allowed_packet = intval($tmp['Value']); if (preg_match("/^(\\d+\\.\\d+\\.\\d+)/", mysql_get_server_info(), $match)) { define("X_MYSQL_VERSION", $match[1]); if (func_version_compare(X_MYSQL_VERSION, "5.0.0") >= 0) { db_query("SET sql_mode = 'MYSQL40'"); } if (func_version_compare(X_MYSQL_VERSION, "5.0.17") > 0) { define("X_MYSQL5_COMP_MODE", true); } if (func_version_compare(X_MYSQL_VERSION, "5.0.18") == 0) { define("X_MYSQL5018_COMP_MODE", true); } if (func_version_compare(X_MYSQL_VERSION, "4.1.0") >= 0) { define("X_MYSQL41_COMP_MODE", true);
<?php $status = 'viewStudent'; include './function/db_connection.php'; include './function/crud_function.php'; $conn = db_connection(); $sql = allStudent(); $result = $conn->query($sql); //var_dump($result); ?> <?php include './_include/header.php'; ?> <?php include './_include/menu.php'; ?> <div class="container"> <div class="row"> <div class="col-md-6 col-md-offset-3"> <h3 class="text-center">View Student Info : </h3> </div> </div> <div class="row"> <div class="col-md-8 col-md-offset-2"> <hr> <table class="table table-striped table-bordered table-hover"> <thead> <tr>