Exemple #1
0
function newticket($msg, $params = null)
{
    global $ticketRestParams;
    // handle the upload itself
    $DATA = $validated = false;
    if (isset($_FILES["file"]) && is_uploaded_file($_FILES["file"]["tmp_name"]) && $_FILES["file"]["error"] == UPLOAD_ERR_OK && ($validated = validateParams($ticketRestParams, $msg))) {
        $DATA = handleUpload($_FILES["file"], $msg);
    }
    if ($DATA === false) {
        // ticket creation unsucessfull
        if ($validated && !empty($_FILES["file"]) && !empty($_FILES["file"]["name"])) {
            $err = uploadErrorStr($_FILES["file"]);
            logError("ticket upload failure: {$err}");
            return array('httpInternalError', $err);
        } elseif (!$validated) {
            logError('invalid ticket parameters');
            return array('httpBadRequest', 'bad parameters');
        } else {
            // errors already generated in handleUpload
            return array('httpInternalError', 'internal error');
        }
    }
    // return ticket instance
    return array(false, array("id" => $DATA['id'], "url" => ticketUrl($DATA)));
}
Exemple #2
0
      and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
require_once 'WebDFS/Client.php';
require_once 'WebDFS/Helper.php';
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    handleUpload();
} else {
    if (isset($_GET['delete'])) {
        deleteFile($_GET['delete']);
    } else {
        if (isset($_GET['get'])) {
            getFile($_GET['get']);
        } else {
            showForm();
        }
    }
}
function showForm()
{
    echo '
        <html>
Exemple #3
0
<?php

$error = handleUpload($_FILES, $_POST);
/**
 * Handle and read uploaded file
 * @param array - fileArray from form
 * @param array - postArray from form
 */
function handleUpload($_FILES, $_POST)
{
    require_once "JotForm.php";
    $path = mktime() . '_' . $_FILES['file']['name'];
    $key = $_POST['APIkey'];
    $form = $_POST['formID'];
    $jot = new JotForm($key);
    $error = "";
    if (move_uploaded_file($_FILES['file']['tmp_name'], $path)) {
        $fileType = getFileType($path);
        $columns = array();
        if ($fileType == 'csv') {
            if (($handle = fopen($path, "r")) !== FALSE) {
                if (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    foreach ($data as $title) {
                        array_push($columns, $title);
                    }
                }
                $error = 'File must contain at least two rows - the first represents the field titles';
                while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
                    $error = '';
                    $result = $jot->createFormSubmissions($form, writeData($data, $columns));
                }
    $uploadStatus['thumb_path'] = $resizeStatus['output'];
    $uploadStatus["wrote_thumb"] = str_replace("uploaded/","",$resizeStatus["output"]);
    $uploadStatus['mime_provided'] = $passed_mime;
    return $uploadStatus;
}

/***************
 * Actual script
 ***************/

if (isset($_SERVER['QUERY_STRING'])) {
    parse_str($_SERVER['QUERY_STRING'], $_REQUEST);
}
$do = isset($_REQUEST['do']) ? strtolower($_REQUEST['do']) : null;

# Check the cases ....

switch ($do) {
# Extend other switches in here as cases ...
case 'upload_file':
    returnAjax(handleUpload());
    break;
case 'upload_image':
    returnAjax(doUploadImage());
    break;
default:
    $default_answer = array('status' => false, 'error' => 'Invalid action', 'human_error' => 'No valid action was supplied.');
    # doUploadImage()
    returnAjax($default_answer);
}
Exemple #5
0
    $act = $_GET['act'];
}
if ($act == "upload") {
    $uid = form_input($_GET["uid"]);
    if ($uid == "" || $uid == nul) {
        throwJSON(array("status" => "error", "code" => 301, "msg" => "uid can not be null"));
        exit;
    }
    if (!isUserExist($uid)) {
        throwJSON(array("status" => "error", "code" => 302, "msg" => "user not exist"));
        exit;
    }
    $sql = "select regdate from disc_common_user where uid='{$uid}'";
    $res = $db->Execute($sql);
    $regdate = $res->fields["regdate"] ? $res->fields["regdate"] : time();
    handleUpload("avatar", $uid, $regdate);
    //处理头像上传
    $y = date("Y", $regdate);
    $m = date("m", $regdate);
    $d = date("d", $regdate);
    $server = $_SERVER["SERVER_NAME"];
    $uid2 = $uid;
    if ($uid < 10) {
        $uid2 = "0" . $uid;
    }
    $url = "http://{$server}/uc_server/data/avatar/{$y}/{$m}/{$d}/{$uid2}_avatar_small.jpg";
    //头像上传奖励信用,威望,贡献
    $credit = array("xinyong" => 0, "weiwang" => 0, "gongxian" => 0);
    $data = array("status" => "ok", "code" => 200, "msg" => "avatar upload success", "avatar" => $url, "credit" => $credit);
} else {
    $data = array("status" => "error", "code" => 303, "msg" => "no module to handle this.");
Exemple #6
0
    $size = $file->getSize();
    if ($size == 0) {
        return array(success => false, error => "File is empty.");
    }
    if ($size > $maxFileSize) {
        return array(success => false, error => "File is too large.");
    }
    $pathinfo = pathinfo($file->getName());
    $filename = $pathinfo['filename'];
    $ext = $pathinfo['extension'];
    $filename = $filename ? $filename : rand(10, 99);
    // if you limit file extensions on the client side,
    // you should check file extension here too
    while (file_exists($uploaddir . $filename . '.' . $ext)) {
        $filename .= rand(10, 99);
    }
    $file->save($uploaddir . $filename . '.' . $ext);
    $imtypes = array(IMG_PNG => 'png', IMG_GIF => 'gif', IMG_JPG => 'jpg', IMG_WBMP => 'wbmp');
    if (!$ext) {
        $gis = exif_imagetype($uploaddir . $filename . '.' . $ext);
        if (in_array($gis, $imtypes)) {
            $ext_new = $imtypes[$gis];
            rename($uploaddir . $filename . '.' . $ext, $uploaddir . $filename . '.' . $ext_new);
            $ext = $ext_new;
        }
    }
    return array(success => true, 'filename' => $filename . '.' . $ext);
}
$result = handleUpload();
// to pass data through iframe you will need to encode all html tags
echo htmlspecialchars(json_encode($result), ENT_NOQUOTES);
Exemple #7
0
        return failUpload($tmpFile);
    }
    // fetch defaults
    $sql = "SELECT * FROM ticket WHERE id = " . $db->quote($id);
    $DATA = $db->query($sql)->fetch();
    if (!empty($GRANT['pass'])) {
        $DATA['pass'] = $GRANT['pass'];
    }
    // trigger use hooks
    onGrantUse($GRANT, $DATA);
    return $DATA;
}
// handle the request
$DATA = false;
if (isset($_FILES["file"]) && is_uploaded_file($_FILES["file"]["tmp_name"]) && $_FILES["file"]["error"] == UPLOAD_ERR_OK) {
    if (!empty($_SESSION['g'][$id]['pass'])) {
        $GRANT['pass'] = $_SESSION['g'][$id]['pass'];
    }
    $DATA = handleUpload($GRANT, $_FILES["file"]);
}
// resulting page
if ($DATA === false) {
    include "grants.php";
} else {
    unset($ref);
    includeTemplate("{$style}/include/grantr.php");
    // kill the session ASAP
    if ($auth === false) {
        session_destroy();
    }
}
Exemple #8
0
<?php

// process a file submission
require_once "ticketfuncs.php";
// handle the request
$DATA = false;
if (isset($_FILES["file"]) && is_uploaded_file($_FILES["file"]["tmp_name"]) && $_FILES["file"]["error"] == UPLOAD_ERR_OK && validateParams($ticketNewParams, $_POST)) {
    // uniform the request parameters to the REST api
    if (isset($_POST['ticket_totaldays'])) {
        $_POST['ticket_total'] = (int) ($_POST['ticket_totaldays'] * 3600 * 24);
    }
    if (isset($_POST['ticket_lastdldays'])) {
        $_POST['ticket_lastdl'] = (int) ($_POST['ticket_lastdldays'] * 3600 * 24);
    }
    if (isset($_POST['ticket_permanent'])) {
        $_POST['permanent'] = !empty($_POST['ticket_permanent']);
    }
    $DATA = handleUpload($_FILES["file"], $_POST);
}
// resulting page
if ($DATA !== false) {
    include "newticketr.php";
} else {
    include "newtickets.php";
}
Exemple #9
0
<?php 
	require_once('util.php');
	require_once 'db_helper.php';
	
	if ($_FILES['file_01']['tmp_name']) {
		$f = handleUpload('file_01');
		if(!$f){
				message('Error occur when uploading the image!');
				return redirect('upload.php');		
			}
	}else{
		$f = '';
	}
	
	
	$db = getDBInstance();
	$name = $_REQUEST['name'];
	$desc = $_REQUEST['description'];
	$short_desc = $_REQUEST['short_description'];
	$point = 1;
	$create_by = $_SESSION['user']->id;

	addBook($db, $name, $desc, $short_desc, $f, $point, $create_by);
	
	// add the point once the user upload the book
	updateUserPoints($db, $_SESSION['user']->id, $point);
	$new_points = $_SESSION['user']->points + $point;	
	$_SESSION['use']->points = $new_points;

	
	$db->debug();
function printFileUploadBox()
{
    global $isLoggedIn;
    echo "<div class='box uploadBox header'>";
    if ($isLoggedIn) {
        handleUpload();
        echo "<form method='POST' enctype='multipart/form-data'>";
        echo "Upload a schematic<br>";
        echo "<input type='file' name='schemaToUpload'><br>";
        echo "<textarea name='desc' rows=5 cols=50 placeholder='Enter a description for the schematic'></textarea><br>";
        echo "<input type='submit' value='Upload Schema' name='submit'>";
        echo "</form>";
    } else {
        echo "You must be logged in to upload schematics!";
    }
    echo "</div>";
}
Exemple #11
0
<?php

function handleUpload($file)
{
    if ($file['error']) {
        return 'Ooops!  Your upload triggered the following error:  ' . $file['error'];
    }
    $ok = move_uploaded_file($file['tmp_name'], 'tracks/' . $file['name']);
    return "ok!";
}
echo handleUpload($_FILES['photo']);