if (!isset($_SESSION['ITCLoggedInAdmin']) || !isset($_SESSION["ITCadminEmail"])) { $json = array("status" => 0, "msg" => "You are not logged in."); header('Content-type: application/json'); echo json_encode($json); } else { if (filter_input(INPUT_POST, "updateThisAdmin") != NULL) { $postVars = array('id', 'name', 'email', 'userName', 'role'); // Form fields names //Validate the POST variables and add up to error message if empty foreach ($postVars as $postVar) { switch ($postVar) { default: $adminObj->{$postVar} = filter_input(INPUT_POST, $postVar) ? mysqli_real_escape_string($dbObj->connection, filter_input(INPUT_POST, $postVar)) : ''; if ($adminObj->{$postVar} === "") { array_push($errorArr, "Please enter {$postVar} "); } break; } } //If validated and not empty submit it to database if (count($errorArr) < 1) { echo $adminObj->update(); } else { $json = array("status" => 0, "msg" => $errorArr); $dbObj->close(); //Close Database Connection header('Content-type: application/json'); echo json_encode($json); } } }
<?php session_start(); require "../includes/checkPermission.php"; require "../../deny/connector.php"; require "class/class.Admin.php"; require "../includes/injection.php"; $fullname = sqlInjection($_POST['Afullname']); $email = sqlInjection($_POST['AEmail']); $phone = sqlInjection($_POST['APhone']); $adm = new Admin(); $adm->update($_SESSION['ADMIN'], $email, $fullname, $phone); echo "<meta http-equiv='refresh' content='0;url=../admincp.php'>"; //header("location: ../admincp.php"); //exit();
function finish_installation() { require_once LIB_PATH . 'osclass/helpers/hSecurity.php'; require_once LIB_PATH . 'osclass/model/Admin.php'; require_once LIB_PATH . 'osclass/model/Preference.php'; require_once LIB_PATH . 'osclass/model/Category.php'; require_once LIB_PATH . 'osclass/model/Item.php'; require_once LIB_PATH . 'osclass/core/Params.php'; require_once LIB_PATH . 'osclass/compatibility.php'; require_once LIB_PATH . 'osclass/utils.php'; $data = array(); $password = osc_genRandomPassword(); $mAdmin = new Admin(); $admin_user = '******'; $admin = $mAdmin->update(array('s_password' => sha1($password)), array('s_username' => $admin_user)); $mPreference = Preference::newInstance(); $mPreference->insert(array('s_section' => 'osclass', 's_name' => 'osclass_installed', 's_value' => '1', 'e_type' => 'BOOLEAN')); // update categories $mCategories = new Category(); if (Params::getParam('submit') != '') { $categories = Params::getParam('categories'); if (is_array($categories)) { foreach ($categories as $category_id) { $mCategories->update(array('b_enabled' => '1'), array('pk_i_id' => $category_id)); } } } $aCategoriesToDelete = $mCategories->listWhere("a.b_enabled = 0"); foreach ($aCategoriesToDelete as $aCategory) { $mCategories->deleteByPrimaryKey($aCategory['pk_i_id']); } $admin = $mAdmin->findByPrimaryKey(1); $data['s_email'] = $admin['s_email']; $data['admin_user'] = $admin_user; $data['password'] = $password; $body = 'Welcome ' . $mPreference->get('pageTitle') . ',<br/><br/>'; $body .= 'Your OSClass installation at ' . WEB_PATH . ' is up and running. You can access to the administration panel with this data access:<br/>'; $body .= '<ul>'; $body .= '<li>username: '******'</li>'; $body .= '<li>password: '******'</li>'; $body .= '</ul>'; $body .= 'Regards,<br/>'; $body .= 'The <a href=\'http://osclass.org/\'>OSClass</a> team'; $sitename = strtolower($_SERVER['SERVER_NAME']); if (substr($sitename, 0, 4) == 'www.') { $sitename = substr($sitename, 4); } require_once LIB_PATH . 'phpmailer/class.phpmailer.php'; $mail = new PHPMailer(); $mail->CharSet = "utf-8"; $mail->Host = "localhost"; $mail->From = 'osclass@' . $sitename; $mail->FromName = 'OSClass'; $mail->Subject = 'OSClass successfully installed!'; $mail->AddAddress($admin['s_email'], 'OSClass administrator'); $mail->Body = $body; $mail->AltBody = $body; if (!$mail->Send()) { echo $mail->ErrorInfo; } return $data; }
<?php include_once $CFG->dirroot . "/lib/classes/application/Admin.Class.php5"; $adminObj = new Admin(); $vFromIP = $_SERVER['REMOTE_ADDR']; $iAdminId = $_POST['iAdminId']; $adminObj->select($iAdminId); $GeneralObj->getRequestVars(); $adminObj->setAllVar(); $redirect_file = "index.php?file=a-adminadd"; $GeneralObj->checkDuplicate('iAdminId', 'admin', array('vUserName'), $redirect_file, USER_ALREADY_EXISTS, $iAdminId); $GeneralObj->checkDuplicate('iAdminId', 'admin', array('vEmail'), $redirect_fshowile, EMAIL_ALLREADY_EXIST, $iAdminId); #print_R($_POST); exit; $iAdminId = $_POST['iAdminId']; $dAddedDate = date('Y-m-d H:i:s'); $adminObj->setdRegDate($dAddedDate); $adminObj->setvFromIP($vFromIP); $adminObj->update($iAdminId); $msg = MSG_UPDATE; $url = 'index.php?file=a-adminadd&var_msg=' . $msg; header("Location:" . $url); exit;
<?php session_name('IDSESSION'); session_start(); $_SESSION['display'] = "displayComs();"; require_once '../../php/connexion.class.php'; require_once 'admin.class.php'; $comments = new Admin(); $comments->update(); ?> <h3> Galleries updated.</h3> <script>setTimeout(function() { location.reload(); }, 2000);</script>
public function testBeforeSaveOnUpdate() { $connection = m::mock('juicyORM\\Database\\DbConnection'); $connection->shouldReceive('query')->with('SELECT * FROM "admin" WHERE "admin_id" = ? LIMIT 0, 1', array('5'))->once()->andReturn(array(array("admin_id" => 5, "username" => "Steve", "email" => "*****@*****.**"))); $connection->shouldReceive('query')->with('UPDATE "admin" SET "username" = ?, "email" = ? WHERE "admin_id" = ?', array('Steve5', '*****@*****.**', 5), false)->once()->andReturn(true); $connection->shouldReceive('query')->with('SELECT * FROM "admin" WHERE "admin_id" = ?', array('5'))->once()->andReturn(array(array("admin_id" => 5, "username" => "Steve5", "email" => "*****@*****.**"))); $db = juicyORM\Database\DB::Instance($this->dbConfig, $connection, true); $admin = new Admin($db); $user_response = $admin->update(5, array("username" => "Derek", "email" => "*****@*****.**")); $this->assertEquals(gettype($user_response), 'object'); $this->assertEquals(get_class($user_response), 'juicyORM\\Database\\ModelRow'); $this->assertEquals($user_response->username, 'Steve5'); }