Esempio n. 1
0
$username = '';
$password = '';
$errors = [];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];
    if ($username == '' || $password == '') {
        $errors[] = "Поля не можуть бути порожніми.";
    }
    if (strlen($username) < 3 || strlen($username) > 20) {
        $errors[] = "Ім'я має бути від 3 до 20 символів.";
    }
    if (!ctype_alnum($username)) {
        $errors[] = "Ім'я може містити тількі латинські літери і цифри.";
    }
    if (get_user_id_by_username($username)) {
        $errors[] = "Таке ім'я вже існує.";
    }
    if (strlen($password) < 3 || strlen($password) > 255) {
        $errors[] = "Пароль має бути від 3 до 255 символів";
    }
    if (!$errors) {
        $user_id = create_user($username, $password);
        login_user($user_id);
        redirect(APP_URL);
    }
}
?>

<!DOCTYPE html>
<head>
Esempio n. 2
0
function get_cdr_by_username($username, $created_from, $created_to)
{
    global $ch;
    global $auth_token;
    global $api_request_url_accounts;
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');
    $userid = get_user_id_by_username($username);
    $api_request_url_users_cdr = $api_request_url_accounts . 'users/' . $userid . '/cdrs?' . 'created_from=' . $created_from . '&created_to=' . $created_to;
    echo $api_request_url_users_cdr;
    curl_setopt($ch, CURLOPT_URL, $api_request_url_users_cdr);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-Auth-Token: ' . $auth_token));
    $api_response = curl_exec($ch);
    $api_response_info = curl_getinfo($ch);
    $api_response_body = substr($api_response, $api_response_info['header_size']);
    $response_body_obj = json_decode($api_response_body, TRUE);
    var_dump($response_body_obj);
}
Esempio n. 3
0
<?php

require 'init.php';
$username = '';
$password = '';
$errors = [];
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $username = $_POST['username'];
    $password = $_POST['password'];
    if (check_user_password($username, $password)) {
        login_user(get_user_id_by_username($username));
        redirect(APP_URL);
    } else {
        $errors[] = "�е �півпадає ім'�-пароль 😞";
    }
}
?>

<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>Tubogram</title>
    <?php 
echo js_and_css();
?>
</head>

<?php 
page_header('login', 'login');
?>
<div class="container">
Esempio n. 4
0
<?php

require 'init.php';
$username = $_GET['search'];
$user_id = get_user_id_by_username($username);
if ($user_id) {
    redirect(APP_URL . '/user.php?id=' . $user_id);
}
?>
<!DOCTYPE html>
<head>
    <meta charset="utf-8">
    <title>Tubogram</title>
    <?php 
echo js_and_css();
?>
</head>

<?php 
if (get_current_user_id()) {
    page_header('logged');
} else {
    page_header('not_logged');
}
?>
<div class="container">
    <div class="jumbotron not-found">
        <h1><?php 
echo escape_html($username);
?>
</h1>