function UsernameExists($username) { if (selectUser($_POST['username']) == null) { return false; } return true; }
function displayUserForm(&$db, &$editor, $message, $action) { $dbList = $db->getDatabases(); $userList = $editor->getUsersList(); $privilegeNames = Privileges::getNames(); $dbPrivilegeNames = DbPrivileges::getNames(); // current user name is not plaintext in case of 'update' action $userName = ''; if ($action == 'update') { $obj = json_decode(v($_REQUEST['query'])); if (is_object($obj)) { $userName = $obj->username . '@' . $obj->hostname; } } else { $userName = v($_REQUEST['query']); } $currentUser = selectUser($userList, $userName); $privileges = array(); $dbPrivileges = array(); $userInfo = array(); if ($currentUser) { $privileges = $currentUser->getGlobalPrivileges(); foreach ($dbList as $db_name) { $dbPrivileges[$db_name] = $currentUser->getDbPrivileges($db_name); } $userInfo = array('username' => $currentUser->userName, 'host' => $currentUser->host); } $users = userOptions($userList, $currentUser); $replace = array('ID' => v($_REQUEST["id"]) ? htmlspecialchars($_REQUEST["id"]) : '', 'MESSAGE' => $message, 'USERS' => $users, 'USER_INFO' => json_encode($userInfo), 'DATABASES' => json_encode($dbList), 'PRIVILEGES' => json_encode($privileges), 'DB_PRIVILEGES' => json_encode($dbPrivileges), 'PRIVILEGE_NAMES' => json_encode($privilegeNames), 'DB_PRIVILEGE_NAMES' => json_encode($dbPrivilegeNames)); echo view('usermanager', $replace); }
try { $dbh = new PDO($dsn, $dbuser, $dbpass, array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8')); } catch (PDOException $e) { $error = array("error" => 'Error connection'); //$e->getMessage() echo json_encode($error); die; } return $dbh; } $dbh = null; $dbh = resetPDO($dbh); $method = $_GET['r']; switch ($method) { case 'selectUser': echo selectUser(); break; case 'selectMates': echo selectMates(); break; case 'selectTop3': echo selectTop3(); break; case 'addUser': echo addUser(); break; case 'addParticipation': echo addParticipation(); break; case 'updateUser': echo updateUser();
function generatePDF($accountId) { $transactions = selectTransactionsByAccountId($accountId); $userId = selectAccountById($accountId)->USER; $user = selectUser($userId); require 'FPDF/fpdf.php'; $pdf = new FPDF(); // Column headings $header = array("Sender Name", "Sender Account", "Recipient Name", "Recipient Account", "Amount", "Description", "Status", "Created On", "TAN", "Approved By", "Approved On"); // Column widths $w = array(25, 23, 25, 23, 20, 35, 15, 20, 35, 27, 20); $pdf->AddPage("L"); $pdf->SetFont('Arial', 'B', 12); $pdf->Cell(0, 10, "Transaction Summary: " . $user->FIRST_NAME . " " . $user->LAST_NAME); $pdf->Ln(); $pdf->SetFont('Arial', '', 8); for ($i = 0; $i < count($header); $i++) { $pdf->Cell($w[$i], 7, $header[$i], 1, 0, 'C'); } $pdf->Ln(); // Data foreach ($transactions as $row) { $status = "Pending"; if ($row->STATUS === "A") { $status = "Approved"; } else { if ($row->STATUS === "D") { $status = "Declined"; } } $pdf->Cell($w[0], 6, $row->SENDER_NAME, 'LR'); $pdf->Cell($w[1], 6, $row->SENDER_ACCOUNT_NUM, 'LR'); $pdf->Cell($w[2], 6, $row->RECIPIENT_NAME, 'LR'); $pdf->Cell($w[3], 6, $row->RECIPIENT_ACCOUNT_NUM, 'LR'); $pdf->Cell($w[4], 6, number_format($row->AMOUNT), 'LR', 0, 'R'); $pdf->Cell($w[5], 6, $row->DESCRIPTION, 'LR'); $pdf->Cell($w[6], 6, $status, 'LR'); $pdf->Cell($w[7], 6, $row->DATE_CREATED, 'LR'); $pdf->Cell($w[8], 6, $row->TAN_NUMBER, 'LR'); $pdf->Cell($w[9], 6, $row->APPROVED_BY_NAME, 'LR'); $pdf->Cell($w[10], 6, $row->DATE_APPROVED, 'LR'); $pdf->Ln(); } // Closing line $pdf->Cell(array_sum($w), 0, '', 'T'); $doc = $pdf->Output('transactions.pdf', 'D'); //Save the pdf file return $doc; }
$title = "Index"; require_once $_SERVER['DOCUMENT_ROOT'] . '/../includes/init.php'; require_once 'templates/header.php'; require_once 'lib/businessLogic.php'; is_logged_in(); $relationship = null; //other user's index page if (isset($_GET['u_id'])) { $user = selectUser($_GET['u_id']); $mineProfile = false; $relationship = getRelationshipStatus($_SESSION['loggedInUser']['u_id'], $_GET['u_id']); $rr = getRelationship($_SESSION['loggedInUser']['u_id'], $_GET['u_id']); } else { //index of a currently logged in user $user = selectUser($_SESSION['loggedInUser']['u_id']); $mineProfile = true; } ?> <main> <div class="container border"> <div id="profile"> <!--public data--> <div class="public"> <img src="/userpic.php?u_id=<?php echo $user['u_id']; ?> &type=public" width="170" height="235" alt="public-picture"> <div> <p><span class="bold">Nickname:</span> <?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/../includes/init.php'; require_once 'lib/businessLogic.php'; session_start(); function is_user_permitted_to_see_the_file($id1, $id2) { if ($id1 === $id2 || getRelationshipStatus($id1, $id2) === Relationship::FRIENDS) { return true; } return false; } function get_file_and_send($filename) { if (!$filename) { $path = $_SERVER['DOCUMENT_ROOT'] . "/images/anonymous.jpg"; } else { $path = $_SERVER['DOCUMENT_ROOT'] . "/../user_uploads/" . $filename; } $content = file_get_contents($path); header("Content-Type: image/jpeg"); return $content; } if (is_logged_in()) { $user = selectUser($_GET['u_id']); if ($_GET['type'] === 'public') { print get_file_and_send($user['u_picture']); } else { if ($_GET['type'] === 'private' && is_user_permitted_to_see_the_file($_SESSION['loggedInUser']['u_id'], $_GET['u_id'])) { print get_file_and_send($user['u_secret_pic']); } } }
<?php // s'il n'y a pas de connexion on redirige vers la page de connexion if (!isset($_SESSION['user'])) { header('location: index.php?p=connexion'); } else { // l'utilisateur s'est déja connecté // function d'interaction avec la base de donnee include __DIR__ . '/../models/fonctionConnexionBdd.php'; include __DIR__ . '/../models/fonctionUser.php'; // barre de navigation include __DIR__ . '/../vues/navbar-top.php'; ?> <div class="container" style="margin-bottom: 200px"> <?php //recupération des donnees de l'utilisateur dans la database $user = selectUser($_SESSION['user']); // mise en forme des donnees avec la vue correspondante include __DIR__ . '/../vues/userProfil.php'; ?> </div> <?php // footer de la page include __DIR__ . '/../vues/footer.php'; }
function sendRegistrationEmail($userId) { $tans = selectTansByUserId($accountId); $user = selectUser($userId); $email = $user->EMAIL; $name = $user->FIRST_NAME . " " . $user->LAST_NAME; $subject = "Tan Numbers - " . $name; $body = ""; for ($i = 0; $i < count($tans); $i++) { $body .= $i + 1 . ". " . $tans[$i]->TAN_NUMBER . "<br/>"; } return sendEmail($email, $name, $subject, $body); }
function ccc() { $pa = 'http://vk.com/victoria_anne'; preg_match_all('/<div class="cc">(.*)<\\/div>[\\n]*<div class="info">/Us', $page, $content); //print_r($content); $countMsg = count($content[1]); for ($i = 0; $i < $countMsg; $i++) { //echo $content[1][$i]; //$all[1][$i] = iconv('Windows-1251','UTF-8',$all[1][$i]); preg_match_all('/<img src="[^"]+" data-photo="([^|]+)|[0-9|]+" \\/>/', $content[1][$i], $photos); //echo $photos[1][0]; preg_match_all('/<div class="text">(.*)/', $content[1][$i], $all); $all[1][0] = str_replace('<a class="wall_post_more" onclick="hide(this, this.previousSibling);show(this.nextSibling);return false;">', '', $all[1][0]); $all[1][0] = str_replace('Показать полностью..</a>', '', $all[1][0]); $all[1][0] = str_replace('style="display: none"', '', $all[1][0]); $all[1][0] = str_replace('!', '', $all[1][0]); $all[1][0] = str_replace('"', '', $all[1][0]); $all[1][0] = str_replace('$', '', $all[1][0]); $all[1][0] = str_replace('\', '', $all[1][0]); $all[1][0] = str_replace('<br>', ' ', $all[1][0]); //$all[1][$i] = iconv('UTF-8','Windows-1251',$all[1][$i]); $all[1][0] = preg_replace('/[^\\^]+Expand text../', '', $all[1][0]); preg_match_all('/<img src="(.*)" [^>]+>/Us', $all[1][0], $images); $all[1][0] = strip_tags($all[1][0]); //print_r($images); $countImages = count($images[1]); for ($k = 0; $k < $countImages; $k++) { $all[1][0] = '<img src=\\"' . $images[1][$k] . '\\">' . $all[1][0]; } $allText = '<img src=\\"' . $photos[1][0] . '\\"><br>' . $all[1][0]; isset($photos[1][0]) && $photos[1][0] != '' ? $allText = '<img src=\\"' . $photos[1][0] . '\\"><br>' . $all[1][0] : ($allText = $all[1][0]); //echo $allText.'<br>'; $checkContent = checkContent($allText); //print_r($checkContent); if ($checkContent['COUNT(*)'] <= 0) { $user = selectUser(); $date = random_date(); $action = '<a href="' . SITE_ADR . 'members/' . $user['user_nicename'] . '/" title="' . $user['display_name'] . '">' . $user['display_name'] . '</a> добавил(а) запись'; $actionDB = '<a href=\\"' . SITE_ADR . 'members/' . $user['user_nicename'] . '/\\" title=\\"' . $user['display_name'] . '\\">' . $user['display_name'] . '</a> добавил(а) запись'; $primatyLink = SITE_ADR . 'members/' . $user['user_nicename'] . '/'; $sql = mysql_query('INSERT INTO `wp_bp_activity` (`user_id`,`component`,`type`,`action`,`content`,`primary_link`,`date_recorded`) VALUES (' . $user['ID'] . ',"activity","activity_update","' . $actionDB . '","' . $allText . '", "' . $primatyLink . '","' . $date . '") '); //echo mysql_error(); } } //print_r($all[1]); #Выставляем задержку $sec = rand(19000, 21000); usleep($sec * 100); }
while ($item = mysql_fetch_assoc($result)) { $GLOBALS['fname'] = htmlspecialchars($item['firstname']); $GLOBALS['lname'] = htmlspecialchars($item['lastname']); $GLOBALS['company'] = htmlspecialchars($item['company']); $GLOBALS['email'] = htmlspecialchars($item['email']); $GLOBALS['access'] = htmlspecialchars($item['userlevel']); } } } } ?> <?php selectUser(); ?> <div id="company-head" class="head full"> <img src="../img/logo-background2.png" /> <div class="head-container"> <a><img id="logo" src="../img/logo.png" /></a> <ul class="top-nav"> <li><a id="red" href="process.php">Log out</a></li> </ul> </div> </div> <div class="full"> <div class="bottom-nav-bg3"></div>