Example #1
0
        }
    }
} else {
    if (isset($_POST['file-url']) && !empty($_POST['file-url']) && !!filter_var($_POST['file-url'], FILTER_VALIDATE_URL)) {
        $url = $_POST['file-url'];
        $fullname = basename($url);
        list($filename, $extension) = explode(".", $fullname);
        $uploadfile = $uploadDir . $fullname;
        $f = fopen($url, 'rb');
        if ($f) {
            $content = "";
            while ($data = fread($f, 1024)) {
                $content .= $data;
            }
            fclose($f);
            file_put_contents($uploadfile, $content);
            try {
                updateUserImage($_SESSION['id'], $filename, $path, $extension);
            } catch (Exception $e) {
                ecvdphp\addFlashMessage('error', $e->getMessage());
                header('Location:profile.php', true, 301);
                exit;
            }
        } else {
            ecvdphp\addFlashMessage('error', 'The URL couldn\'t not be found');
        }
    } else {
        ecvdphp\addFlashMessage('error', 'The uploaded file couldn\'t be found');
    }
}
ecvdphp\redirect("profile.php");
Example #2
0
        addQuestion();
        break;
    case 'addAnswer':
        addAnswer();
        break;
    case 'addShop':
        addShop();
        break;
    case 'idUpload':
        idUpload();
        break;
    case 'updateForm':
        updateForm();
        break;
    case 'updateUserImage':
        updateUserImage();
        break;
    default:
        login();
}
function login()
{
    // login.. checks if session already set..
    $results = array();
    $results['pageTitle'] = "Home | Dating website";
    if (!isset($_SESSION['email'])) {
        if (isset($_POST['email'])) {
            $email = $_POST['email'];
            $password = $_POST['password'];
            $passwordHash = Password::hash($password);
            //echo $passwordHash;
Example #3
0
<?php

require_once 'session.php';
require_once 'pdo.php';
require_once 'functions.php';
if ($_FILES['userfile'] || $_POST['userfileurl']) {
    // if($_POST['userfileurl'] && urlExists($_POST['userfileurl'])) {
    //     $fileName = end(explode('/', $_POST['userfileurl']));
    //     $source = $_POST['userfileurl'];
    //     file_put_contents($uploadsDir . $fileName, file_get_contents($source));
    //     setProfilePicture($fileName);
    // };
    $fileName = $_FILES['userfile']['name'];
    $fileTmpName = $_FILES['userfile']['tmp_name'];
    $uploadsDir = 'uploads/';
    if (checkUpload($fileName, $fileTmpName)) {
        $uplodaded = uploadFile($fileName, $fileTmpName);
        if ($uplodaded != null) {
            updateUserImage($_SESSION["id"], $uplodaded['filename'], $uploadsDir, $uplodaded['extension']);
        }
    }
}
<?php

session_start();
include "dbconnection.php";
$user_id = $_SESSION['user_id'];
$smallimage = $_FILES['user_image'];
$user_image = $smallimage['name'];
if (!$smallimage['error']) {
    if (!@move_uploaded_file($smallimage['tmp_name'], "userimages/" . $smallimage['name'])) {
        header("location:addrhyme.php?err=Unknown Error Occured please try again");
        exit;
    } else {
        $work = new ImgResizer("userimages/" . $smallimage['name']);
    }
}
updateUserImage($user_id, $user_image);
unset($_SESSION['user_image']);
$users = getUserById($user_id);
$user = mysql_fetch_array($users);
$_SESSION['user_image'] = $user['userimages'];
header("location:mom-forum-user-profile");
class ImgResizer
{
    var $originalFile = '';
    function ImgResizer($originalFile = '')
    {
        $this->originalFile = $originalFile;
    }
    function resize($newWidth, $targetFile)
    {
        if (empty($newWidth) || empty($targetFile)) {
Example #5
0
require_once INCLUDES_PATH . 'cm_authorize.inc.php';
require_once INCLUDES_PATH . 'common_function.inc.php';
require_once INCLUDES_PATH . 'profile_function.inc.php';
// Edit upload location here
$destination_path = "/tmp/";
$result = 0;
$newfilename = "img" . md5(time() . 'image') . basename($_FILES['myfile']['name']);
$target_path = $destination_path . $newfilename;
//$target_path = $destination_path . basename( $_FILES['myfile']['name']);
if (@move_uploaded_file($_FILES['myfile']['tmp_name'], $target_path)) {
    $result = 1;
    try {
        $contents = addslashes(file_get_contents($target_path));
        //	$thumbnail = createThumbnail($target_path , "/tmp/thumb/", 32 , 32);
        //	print "here".$thumbnail;
        $res = updateUserImage($strCK_user_id, $contents, $objDataHelper);
        if (!$res) {
            $result = 3;
        }
    } catch (Exception $e) {
        print_r($e);
        $result = 2;
    }
}
sleep(1);
?>
<script language="javascript" type="text/javascript">window.top.window.stopUpload(<?php 
echo $result;
?>
);</script>   
Example #6
0
        header("Location: upload_photo.php?id={$pid}&error=Image field empty.");
    } elseif ($res == 2) {
        header("Location: upload_photo.php?id={$pid}&error=Your image has exceeded the 300mb size limit required. Please select a smaller image file.");
    } elseif ($res == 3) {
        header("Location: upload_photo.php?id={$pid}&error=Unknown image extension. Images must be in jpg, jpeg, gif or png formats.");
    } elseif ($res == 4) {
        header("Location: upload_photo.php?id={$pid}&error=Unable to save image file. Please try again or contact site admin.");
    } elseif ($res == 5) {
        header("Location: upload_photo.php?id={$pid}&error=Unable to save image file. Please try again or contact site admin.");
    } else {
        header("Location: upload_photo.php?id={$pid}&error=There was an error uploading your image. Please try again.");
    }
}
if (array_key_exists('updatephoto', $_POST)) {
    $id = $_POST['id'];
    $imgpth = "pics/";
    $res = updateUserImage($imgpth, $_FILES["picture"]["name"], $_FILES["picture"]["tmp_name"], $_POST["max"], $_POST['id']);
    if ($res == 99) {
        header("Location: update_photo.php?id={$pid}&message=Photo updated successfully.");
    } elseif ($res == 1) {
        header("Location: update_photo.php?id={$pid}&error=Image field empty.");
    } elseif ($res == 2) {
        header("Location: update_photo.php?id={$pid}&error=Unknown image extension. Images must be in jpg, jpeg, gif or png formats.");
    } elseif ($res == 3) {
        header("Location: update_photo.php?id={$pid}&error=Your image has exceeded the 300mb size limit required. Please select a smaller image file.");
    } elseif ($res == 4) {
        header("Location: update_photo.php?id={$pid}&error=Unable to update image. Please try again, or contact the site administrator.");
    } else {
        header("Location: update_photo.php?id={$pid}&error=There was an error uploading your image. Please try again.");
    }
}