<?php

if (isset($_POST['full_name']) && !empty($_POST['full_name']) && isset($_POST['username']) && !empty($_POST['username']) && isset($_POST['email']) && !empty($_POST['email']) && isset($_POST['password'])) {
    $_POST['code'] = sha1($_SERVER['REMOTE_ADDR'] . microtime() . mt_rand(1, 100000)) . _Function::randomString(40, TRUE, TRUE, TRUE);
    $_POST['email'] = trim($_POST['email']);
    $_POST['full_name'] = _Function::spaces(trim($_POST['full_name']));
    $_POST['username'] = _Function::spaces(trim($_POST['username']));
    $_POST['password'] = _Function::spaces(trim($_POST['password']));
    $admin = $obj->getSettings();
    $emailAddress = $_POST['email'];
    $_POST['email_verify'] = $settings->email_verification;
    if ($_POST['full_name'] == '' || mb_strlen($_POST['full_name'], 'utf8') < 2 || mb_strlen($_POST['full_name'], 'utf8') > 20) {
        echo json_encode(array('res' => $_SESSION['LANG']['full_name_error'], 'focus' => 'full_name'));
    } else {
        if (preg_match('/[^a-z0-9\\_]/i', $_POST['username'])) {
            echo json_encode(array('res' => $_SESSION['LANG']['username_not_valid'], 'focus' => 'username'));
        } else {
            if (strlen($_POST['username']) < 1 || strlen($_POST['username']) > 15) {
                echo json_encode(array('res' => $_SESSION['LANG']['username_not_valid'], 'focus' => 'username'));
            } else {
                if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
                    echo json_encode(array('res' => $_SESSION['LANG']['email_not_valid'], 'focus' => 'email'));
                } else {
                    if (mb_strlen($_POST['password'], 'utf8') < 5 || mb_strlen($_POST['password'], 'utf8') > 20) {
                        echo json_encode(array('res' => $_SESSION['LANG']['password'], 'focus' => 'username'));
                    } else {
                        if ($_POST['terms'] == '') {
                            echo json_encode(array('res' => $_SESSION['LANG']['can_not_register']));
                        } else {
                            /* INSERT DATABASE */
                            $res = $obj->signUp();
$path = "../../tmp/";
$path_bg = "../backgrounds/";
$obj = new AjaxRequest();
$infoUser = $obj->infoUserLive($_SESSION['authenticated']);
$bg_old = $path_bg . $infoUser->bg;
$defaults = array('0.jpg', '1.jpg', '2.jpg', '3.jpg', '4.jpg', '5.jpg', '6.jpg', '7.jpg', '8.jpg', '9.jpg', '10.jpg', '11.jpg', '12.jpg', '13.jpg', '14.jpg', '15.jpg');
if (isset($session_id)) {
    $valid_formats = array("jpg", "JPG", "jpeg", "png", "x-png", "gif", "pjpeg");
    if (isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST") {
        $name = $_FILES['photo']['name'];
        $size = $_FILES['photo']['size'];
        if (strlen($name)) {
            $ext = pathinfo($name);
            if (in_array($ext['extension'], $valid_formats)) {
                if ($size < 1500 * 1500) {
                    $photo_post = 'bg_' . strtolower($infoUser->username) . "_" . $session_id . "" . _Function::randomString(5, FALSE, TRUE, FALSE) . "." . strtolower($ext['extension']);
                    $tmp = $_FILES['photo']['tmp_name'];
                    if (move_uploaded_file($tmp, $path . $photo_post)) {
                        //=============== 440 px =================//
                        $width = _Function::getWidth($path . $photo_post);
                        $height = _Function::getHeight($path . $photo_post);
                        $scale = 1;
                        $uploaded = _Function::resizeImage($path . $photo_post, $width, $height, $scale, $path . $photo_post);
                        //<=//   PHOTO LARGE     =//>
                        $photo_post_id = $photo_post;
                        //==================================================//
                        //=            * COPY FOLDER AVATAR /         *    =//
                        //==================================================//
                        if (file_exists($path . $photo_post) && isset($photo_post_id)) {
                            copy($path . $photo_post, $path_bg . $photo_post);
                            unlink($path . $photo_post);
" type="button" class="btn btn-border btn-xs btn-default followBtn" data-original-title="Request send"><i class="icon-user3 myicon-right"></i> <?php 
                        echo $_SESSION['LANG']['follow'];
                        ?>
</button>
	                       	   <?php 
                    }
                    ?>
	                       	   
	                       	   <?php 
                    if (isset($_SESSION['authenticated']) && $_SESSION['authenticated'] != $key['id'] && $key['followActive'] == 1) {
                        ?>
	                       	   <button data-username="******" data-id="<?php 
                        echo _Function::randomString(10, FALSE, TRUE, FALSE) . '-' . $key['id'];
                        ?>
" data-follow="<?php 
                        echo $_SESSION['LANG']['follow'];
                        ?>
" data-unfollow="<?php 
                        echo $_SESSION['LANG']['unfollow'];
                        ?>
" data-following="<?php 
                        echo $_SESSION['LANG']['following'];
                        ?>
" type="button" class="btn btn-border btn-xs btn-info follow_active followBtn" data-original-title="Request send"><i class="icon-user3 myicon-right"></i> <?php 
                        echo $_SESSION['LANG']['following'];
                        ?>
</button>
	                       	   <?php 
Ejemplo n.º 4
0
//$session id
$path = "../../tmp/";
$path_upload = "../../upload/";
if (isset($session_id)) {
    $valid_formats = array("jpg", "JPG", "jpeg", "png", "x-png", "gif", "pjpeg");
    $_valid_formats = array("image/pjpeg", "image/jpeg", "image/jpg", "image/png", "image/x-png", "image/gif");
    if (isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST") {
        $name = $_FILES['photo_upload']['name'];
        $size = $_FILES['photo_upload']['size'];
        $typeMime = $_FILES['photo_upload']['type'];
        $imgInfo = getimagesize($_FILES['photo_upload']['tmp_name']);
        if (strlen($name)) {
            $ext = pathinfo($name);
            if (in_array($ext['extension'], $valid_formats) && in_array($typeMime, $_valid_formats) && in_array($imgInfo['mime'], $_valid_formats)) {
                if ($size < 3000 * 3000) {
                    $photo_post = $session_id . "" . _Function::randomString(14, FALSE, TRUE, FALSE) . "." . strtolower($ext['extension']);
                    $tmp = $_FILES['photo_upload']['tmp_name'];
                    if (move_uploaded_file($tmp, $path . $photo_post)) {
                        //=============== px =================//
                        $width = _Function::getWidth($path . $photo_post);
                        $height = _Function::getHeight($path . $photo_post);
                        $max_width = '900';
                        if ($width < $height) {
                            $max_width = '600';
                        }
                        if ($width > $max_width) {
                            $scale = $max_width / $width;
                            $uploaded = _Function::resizeImage($path . $photo_post, $width, $height, $scale, $path . $photo_post);
                        } else {
                            $scale = 1;
                            $uploaded = _Function::resizeImage($path . $photo_post, $width, $height, $scale, $path . $photo_post);
$path = "../../tmp/";
$path_cover = "../cover/";
$obj = new AjaxRequest();
$infoUser = $obj->infoUserLive($_SESSION['authenticated']);
$coverOld = $path_cover . $infoUser->cover_image;
$imgOldLarge = $path_cover . 'large_' . $infoUser->cover_image;
if (isset($session_id)) {
    $valid_formats = array("jpg", "JPG", "jpeg", "png", "x-png", "gif", "pjpeg");
    if (isset($_POST) && $_SERVER['REQUEST_METHOD'] == "POST") {
        $name = $_FILES['photo']['name'];
        $size = $_FILES['photo']['size'];
        if (strlen($name)) {
            $ext = pathinfo($name);
            if (in_array($ext['extension'], $valid_formats)) {
                if ($size < 2250 * 2250) {
                    $randomHash = _Function::randomString(5, FALSE, TRUE, FALSE);
                    $photo_post = 'cover_' . strtolower($infoUser->username) . "_" . $session_id . "" . $randomHash . "." . strtolower($ext['extension']);
                    $photo_large = 'large_cover_' . strtolower($infoUser->username) . "_" . $session_id . "" . $randomHash . "." . strtolower($ext['extension']);
                    $tmp = $_FILES['photo']['tmp_name'];
                    $dimensionsImage = getimagesize($tmp);
                    $widthImage = $dimensionsImage[0];
                    $heightImage = $dimensionsImage[1];
                    if ($widthImage >= 400 && $heightImage >= 200) {
                        if (move_uploaded_file($tmp, $path . $photo_large)) {
                            //=============== Image Large =================//
                            $width = _Function::getWidth($path . $photo_large);
                            $height = _Function::getHeight($path . $photo_large);
                            $max_width = '1500';
                            if ($width < $height) {
                                $max_width = '800';
                            }
         *   Require/Include Files
         * -------------------------
         */
        require_once '../../class_ajax_request/classAjax.php';
        include_once '../../application/functions.php';
        include_once '../../application/DataConfig.php';
        require_once '../../phpmailer/PHPMailerAutoload.php';
        /*
         * --------------------------
         *   Instance Class
         * -------------------------
         */
        $obj = new AjaxRequest();
        $admin = $obj->getSettings();
        $linkHash = sha1($_SERVER['REMOTE_ADDR'] . microtime() . mt_rand(1, 100000) . '%(asqWas8*)');
        $link = _Function::idHash($linkHash) . _Function::randomString(40, TRUE, TRUE, TRUE);
        $linkRecover = '' . URL_BASE . 'recover/?c=' . $link . '';
        // <------------------ DATA ----------->
        $_POST['email_recover'] = trim($_POST['email_recover']);
        $_POST['id_hash'] = $link;
        $emailAddress = $_POST['email_recover'];
        //================ * EMAIL * =================//
        if (!filter_var($emailAddress, FILTER_VALIDATE_EMAIL)) {
            echo json_encode(array('status' => 'false', 'html' => $_SESSION['LANG']['email_not_valid']));
        } else {
            //<<<--- DATABASE
            $res = $obj->recoverPass();
            /* EMAIL TEMPLATE */
            $messageEmail = '
			<table width="550" cellpadding="0" cellspacing="0" style="font-family:Arial,Helvetica,sans-serif; font-size: 14px; color: #666;" align="center">
	<tbody>