当前位置: 首页>>代码示例>>PHP>>正文


PHP HandleError函数代码示例

本文整理汇总了PHP中HandleError函数的典型用法代码示例。如果您正苦于以下问题:PHP HandleError函数的具体用法?PHP HandleError怎么用?PHP HandleError使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了HandleError函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: Insert

 public function Insert()
 {
     $conn = parent::GetConnection();
     //Use the query defined in the Query object.
     $query = $this->SetupQuery(Query::INSERT_USER);
     if (!odbc_exec($conn, $query)) {
         return HandleError($conn);
     }
     if (!($result = odbc_exec($conn, Query::LAST_INSERT_ID))) {
         return HandleError($conn);
     }
     $row = array();
     if (!odbc_fetch_into($result, $row)) {
         return $this->HandleError($conn);
     }
     $this->idNumber = $row[0];
     return true;
 }
开发者ID:hadleymj,项目名称:Senior-Design-Fall-2009,代码行数:18,代码来源:UserDAO.php

示例2: exit

    exit(0);
}
// Validate file extension
$path_info = pathinfo($_FILES[$upload_name]['name']);
$file_extension = $path_info["extension"];
if ($file_extension == 'txt') {
    $file_name = $file_name1 . ".txt";
}
$is_valid_extension = false;
foreach ($extension_whitelist as $extension) {
    if (strcasecmp($file_extension, $extension) == 0) {
        $is_valid_extension = true;
        break;
    }
}
if (!$is_valid_extension) {
    HandleError("Invalid file extension");
    exit(0);
}
if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path . $file_name)) {
    HandleError("文件无法保存.");
    exit(0);
} else {
}
echo "File Received";
exit(0);
function HandleError($message)
{
    header("HTTP/1.1 500 Internal Server Error");
    echo $message;
}
开发者ID:pytonylau,项目名称:vp,代码行数:31,代码来源:upload.php

示例3: HandleError

if (file_exists($save_path . $file_name)) {
    HandleError("File with this name already exists");
    exit(0);
}
// Validate file extension
$path_info = pathinfo($_FILES[$upload_name]['name']);
$file_extension = $path_info["extension"];
$is_valid_extension = false;
foreach ($extension_whitelist as $extension) {
    if (strcasecmp($file_extension, $extension) == 0) {
        $is_valid_extension = true;
        break;
    }
}
if (!$is_valid_extension) {
    HandleError("Invalid file extension");
    exit(0);
}
//	if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path.$file_name)) {
//		HandleError("文件无法保存.");
//		exit(0);
//	}else{
//
//	}
/***
 * 上传到七牛begin
 */
if (!empty($_SESSION['uid'])) {
    $uid = $_SESSION['uid'];
    $time = time();
    require_once '../qiniu/io.php';
开发者ID:returncn,项目名称:chen-xia-cms,代码行数:31,代码来源:upload.php

示例4: strtolower

            $photo_ext = strtolower(strrchr($photo_pic['name'], "."));
            $photo_dest = INFUSIONS . "the_kroax/uploads/thumbs/";
            if (!preg_match("/^[-0-9A-Z_\\.\\[\\]]+\$/i", $photo_pic['name'])) {
                HandleError("" . $locale['KROAX434'] . "");
                echo '<hr width="90%">' . $locale['KROAX435'] . '<br>
<a href="index.php">' . $locale['KROAX431'] . ' </a>';
                closetable();
                exit(0);
            } elseif ($photo_pic['size'] > $imagebytes) {
                HandleError("" . $locale['KROAX436'] . "");
                echo '<hr width="90%">' . $locale['KROAX437'] . '<br>
<a href="index.php">' . $locale['KROAX431'] . ' </a>';
                closetable();
                exit(0);
            } elseif (!in_array($photo_ext, $photo_types)) {
                HandleError("" . $locale['KROAX438'] . "");
                echo '<hr width="90%">' . $locale['KROAX439'] . '<br>
<a href="index.php">' . $locale['KROAX431'] . ' </a>';
                closetable();
                exit(0);
            } else {
                $photo_file = image_exists($photo_dest, $photo_name . $photo_ext);
                move_uploaded_file($photo_pic['tmp_name'], $photo_dest . $photo_file);
                chmod($photo_dest . $photo_file, 0644);
                $imagefile = @getimagesize($photo_dest . $photo_file);
                if ($imagefile[0] > $imagewidth || $imagefile[1] > $imageheight) {
                    $error = 4;
                    unlink($photo_dest . $photo_file);
                } else {
                    $photo_thumb1 = image_exists($photo_dest, $photo_name . "_t1" . $photo_ext);
                    createthumbnail($imagefile[2], $photo_dest . $photo_file, $photo_dest . $photo_thumb1, $settings['thumb_w'], $settings['thumb_h']);
开发者ID:simplyianm,项目名称:clububer,代码行数:31,代码来源:proccess.php

示例5: session_start

<?php

session_start();
if (isset($_SESSION['loginUsername']) && $_SESSION['userLevel'] == "0") {
    $max_size = 2000000;
    $file_mimes = array('image/jpeg', 'image/jpg', 'image/gif', 'image/png');
    // Allowable file Mime Types.
    $file_exts = array('.jpg', '.png', '.gif');
    // Allowable file extension names.
    $ds = DIRECTORY_SEPARATOR;
    $storeFolder = 'user_images';
    if (!empty($_FILES['file']) && $_FILES['file']['error'] == 0) {
        $file_type = $_FILES['file']['type'];
        $file_name = $_FILES['file']['name'];
        $file_ext = strtolower(substr($file_name, strrpos($file_name, ".")));
        if ($_FILES['file']['size'] <= $max_size && in_array($file_type, $file_mimes) && in_array($file_ext, $file_exts)) {
            $tempFile = $_FILES['file']['tmp_name'];
            $targetPath = dirname(__FILE__) . $ds . $storeFolder . $ds;
            $targetFile = $targetPath . $_FILES['file']['name'];
            move_uploaded_file($tempFile, $targetFile);
        }
    }
} else {
    HandleError('No Session was found.');
}
?>
 
开发者ID:anigeluk,项目名称:brewcompetitiononlineentry,代码行数:26,代码来源:upload.inc.php

示例6: HandleError

}
// Validate file contents (extension and mime-type can't be trusted)
/*
	Validating the file contents is OS and web server configuration dependant.  Also, it may not be reliable.
	See the comments on this page: http://us2.php.net/fileinfo
	
	Also see http://72.14.253.104/search?q=cache:3YGZfcnKDrYJ:www.scanit.be/uploads/php-file-upload.pdf+php+file+command&hl=en&ct=clnk&cd=8&gl=us&client=firefox-a
	 which describes how a PHP script can be embedded within a GIF image file.
	
	Therefore, no sample code will be provided here.  Research the issue, decide how much security is
	 needed, and implement a solution that meets the need.
*/
// Process the file
/*
	At this point we are ready to process the valid file. This sample code shows how to save the file. Other tasks
	 could be done such as creating an entry in a database or generating a thumbnail.
	 
	Depending on your server OS and needs you may need to set the Security Permissions on the file after it has
	been saved.
*/
if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path . $file_name)) {
    HandleError("File could not be saved.");
    exit(0);
}
exit(0);
/* Handles the error output. This error message will be sent to the uploadSuccess event handler.  The event handler
will have to check for any error messages and react as needed. */
function HandleError($message)
{
    echo $message;
}
开发者ID:Gninety,项目名称:Microweber,代码行数:31,代码来源:upload.php

示例7: array

}
if (isset($_FILES['UpFile']['error']) && $_FILES['UpFile']['error'] != 0) {
    $uploadErrors = array(0 => '文件上传成功', 1 => '上传的文件超过了 php.ini 文件中的 upload_max_filesize directive 里的设置', 2 => '上传的文件超过了 HTML form 文件中的 MAX_FILE_SIZE directive 里的设置', 3 => '上传的文件仅为部分文件', 4 => '没有文件上传', 6 => '缺少临时文件夹');
    HandleError($uploadErrors[$_FILES['UpFile']['error']]);
}
if (!isset($_FILES['UpFile']['tmp_name']) || !@is_uploaded_file($_FILES['UpFile']['tmp_name'])) {
    HandleError('无法找到上传的文件,上传失败');
}
if (!isset($_FILES['UpFile']['name'])) {
    HandleError('上传空名字文件名');
}
$POST_MAX_SIZE = ini_get('post_max_size');
$unit = strtoupper(substr($POST_MAX_SIZE, -1));
$multiplier = $unit == 'M' ? 1048576 : ($unit == 'K' ? 1024 : ($unit == 'G' ? 1073741824 : 1));
if ((int) $_SERVER['CONTENT_LENGTH'] > $multiplier * (int) $POST_MAX_SIZE && $POST_MAX_SIZE) {
    HandleError('超过POST_MAX_SIZE的设置值,请查看PHP.ini的设置');
}
$file_size = @filesize($_FILES['UpFile']['tmp_name']);
if (!$file_size || $file_size > $ini_set['max_size']) {
    HandleError('零字节文件 或 上传的文件已经超过所设置最大值');
}
$UpFile = array();
$int_type = getimagesize($_FILES['UpFile']['tmp_name']);
$str_type = image_type_to_extension($int_type[2]);
if (!in_array(strtolower($str_type), $ini_set['whitelist'])) {
    HandleError('不允许上传此类型文件');
}
$str_type == ".jpeg" && ($str_type = ".jpg");
$UpFile['filename'] = uniqid("temp_") . "_" . mt_rand(100, 999) . $str_type;
$UpFile['file_url'] = $ini_set['list'] . $UpFile['filename'];
file_exists($ini_set['list']) or @mkdir($ini_set['list'], 511, true);
开发者ID:460611929,项目名称:jdshop,代码行数:31,代码来源:shearphoto.up.php

示例8: foreach

                $is_valid_extension = false;
                foreach ($arrExtensions as $extension) {
                    if (strcasecmp($file_extension, $extension) == 0) {
                        $is_valid_extension = true;
                        break;
                    }
                }
                if (!$is_valid_extension) {
                    HandleError("Invalid file extension");
                    exit(0);
                }
                if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $_PATHS['upload'] . $file_name)) {
                    HandleError("File could not be saved.");
                    exit(0);
                }
                LogError($_FILES[$upload_name]["tmp_name"] . " -> " . $_PATHS['upload'] . $file_name);
                echo "Done.";
                exit(0);
            } else {
                HandleError("Posted file is missing information.");
                exit(0);
            }
        } else {
            HandleError("Posted file is missing information.");
            exit(0);
        }
    } else {
        HandleError("Posted file is missing information.");
        exit(0);
    }
}
开发者ID:laiello,项目名称:punchcms,代码行数:31,代码来源:upload.php

示例9: ImageCreateTrueColor

if ($new_height > $thumbnail_target_height) {
    $new_height = $thumbnail_target_height;
}
if ($new_width > $thumbnail_target_width) {
    $new_height = $thumbnail_target_width;
}
$new_img = ImageCreateTrueColor(100, 100);
//$background_color = imagecolorallocate($new_img, 0, 0, 0);
$background_color = imagecolorallocate($new_img, 200, 200, 200);
if (!@imagefilledrectangle($new_img, 0, 0, $thumbnail_target_width - 1, $thumbnail_target_height - 1, $background_color)) {
    // Fill the image black
    HandleError("ERROR:Could not fill new image");
    exit(0);
}
if (!@imagecopyresampled($new_img, $img, ($thumbnail_target_width - $new_width) / 2, ($thumbnail_target_height - $new_height) / 2, 0, 0, $new_width, $new_height, $width, $height)) {
    HandleError("ERROR:Could not resize image");
    exit(0);
}
if (!isset($_SESSION["file_info"])) {
    $_SESSION["file_info"] = array();
}
imagejpeg($new_img, $save_path . "th/" . $file_name);
chmod($save_path . "th/" . $file_name, 0777);
imagedestroy($new_img);
imagedestroy($img);
imagedestroy($image_p);
exit(0);
/* Handles the error output. This error message will be sent to the uploadSuccess event handler.  The event handler
will have to check for any error messages and react as needed. */
function HandleError($message)
{
开发者ID:erwincornelis,项目名称:Acanthuskattenpension.be,代码行数:31,代码来源:upload.php

示例10: HandleError

}
if (file_exists($save_path . $file_name)) {
    HandleError("File with this name already exists");
    exit(0);
}
// Validate file extension
$path_info = pathinfo($_FILES[$upload_name]['name']);
$file_extension = $path_info["extension"];
$is_valid_extension = false;
foreach ($extension_whitelist as $extension) {
    if (strcasecmp($file_extension, $extension) == 0) {
        $is_valid_extension = true;
        break;
    }
}
if (!$is_valid_extension) {
    HandleError("Invalid file extension");
    exit(0);
}
if (!@move_uploaded_file($_FILES[$upload_name]["tmp_name"], $save_path . $file_name)) {
    HandleError("ÎļþÎÞ·¨±£´æ.");
    exit(0);
} else {
}
echo "File Received";
exit(0);
function HandleError($message)
{
    header("HTTP/1.1 500 Internal Server Error");
    echo $message;
}
开发者ID:xuyi5918,项目名称:ThinkPHPDistribution,代码行数:31,代码来源:upload.php

示例11: PictureOrder

            $car = $blCar->getCar($_POST["CARID"]);
            //default
            if ($car->getDefaultPictureId() == null) {
                $car->setDefaultPictureId($carpicture->getId());
                $blCar->updateCar($car);
            }
            //pictureorder
            $max = $blPictureOrder->getMaxPictureOrderByCar($car->getId()) + 1;
            $pictureorder = new PictureOrder(0, $max, $car->getId(), $carpicture->getId());
            $blPictureOrder->insertPictureOrder($pictureorder);
            //success
            //HandleError('<span style="color:green">' . $file . ' saved!</span><br />');
            $carpicturelist[] = $carpicture;
        } else {
            HandleError('Error: ' . $errorim[2] . ' (' . $file . ')');
        }
    } else {
        HandleError('Error: No Image File. (' . $_FILES[$upload_name]['name'] . ')');
    }
} else {
    HandleError("No file selected.");
}
function HandleError($message)
{
    header("HTTP/1.1 500 Internal Server Error");
    echo $message;
    exit(0);
}
?>
 			
开发者ID:janb87,项目名称:media-cars,代码行数:29,代码来源:uploadimage.php

示例12: upload

 function upload($categoryID)
 {
     $fileName = $_FILES["Filedata"]["name"];
     //$file_name = $fileName;
     $fileName = substr($fileName, 0, strlen($fileName) - 4);
     $MAX_FILENAME_LENGTH = 260;
     $valid_chars_regex = '.A-Z0-9_!@#$%^&()+={}\\[\\]\',~`-';
     //$file_name = preg_replace('/[^'.$valid_chars_regex.']|\.+$/i', "", basename($_FILES[$upload_name]['name']));
     $file_name = preg_replace('/[^' . $valid_chars_regex . ']|\\.+$/i', "", $fileName);
     if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) {
         HandleError("Invalid file name");
         exit(0);
     }
     //$fn = substr($fileName, 0, strlen($fileName)-4);
     if (is_file(self::$photoPath . 'normal/' . $file_name)) {
         echo $file_name;
         return;
     }
     if (!isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) {
         exit(0);
     }
     //move_uploaded_file($_FILES["Filedata"]["tmp_name"], "./files/images/gallery/" . $fn);
     move_uploaded_file($_FILES["Filedata"]["tmp_name"], self::$photoPath . "normal/" . $file_name);
     ////////////////////////////////////////
     //MINIATURA DO PANELU
     ////////////////////////////////////////
     // Get the image and create a thumbnail
     $img = imagecreatefromjpeg(self::$photoPath . 'normal/' . $file_name);
     if (!$img) {
         exit(0);
     }
     $width = imageSX($img);
     $height = imageSY($img);
     if (!$width || !$height) {
         exit(0);
     }
     // Build the thumbnail
     $target_width = 40;
     $target_height = 40;
     $target_ratio = $target_width / $target_height;
     $img_ratio = $width / $height;
     if ($target_ratio > $img_ratio) {
         $new_height = $target_height;
         $new_width = $img_ratio * $target_height;
     } else {
         $new_height = $target_width / $img_ratio;
         $new_width = $target_width;
     }
     if ($new_height > $target_height) {
         $new_height = $target_height;
     }
     if ($new_width > $target_width) {
         $new_height = $target_width;
     }
     $new_img = ImageCreateTrueColor(40, 40);
     if (!@imagefilledrectangle($new_img, 0, 0, $target_width - 1, $target_height - 1, 0)) {
         // Fill the image black
         exit(0);
     }
     if (!@imagecopyresampled($new_img, $img, ($target_width - $new_width) / 2, ($target_height - $new_height) / 2, 0, 0, $new_width, $new_height, $width, $height)) {
         exit(0);
     }
     imagejpeg($new_img, self::$photoPath . 'mini/' . $file_name, 100);
     /*
             ////////////////////////////////////////
             //MINIATURA NA STRONE
             ////////////////////////////////////////
             // Get the image and create a thumbnail
     	$img = imagecreatefromjpeg('./files/images/works/'.$file_name);
     	if (!$img){exit(0);}
     
     	$width = imageSX($img);
     	$height = imageSY($img);
     
     	if (!$width || !$height){exit(0);}
     
     	// Build the thumbnail
     	$target_width = 100;
     	$target_height = 100;
     	$target_ratio = $target_width / $target_height;
     
     	$img_ratio = $width / $height;
     
     	if ($target_ratio > $img_ratio) {
     		$new_height = $target_height;
     		$new_width = $img_ratio * $target_height;
     	} else {
     		$new_height = $target_width / $img_ratio;
     		$new_width = $target_width;
     	}
     
     	if ($new_height > $target_height) {
     		$new_height = $target_height;
     	}
     	if ($new_width > $target_width) {
     		$new_height = $target_width;
     	}
     
     	$new_img = ImageCreateTrueColor(100, 100);
             $background = imagecolorallocate($new_img, 204, 204, 204);
//.........这里部分代码省略.........
开发者ID:rafkol35,项目名称:filipgabrielpudlo.com.pl,代码行数:101,代码来源:files.php

示例13: HandleError

*/
$save_path = $_SERVER['DOCUMENT_ROOT'] . '/uploads/';
$valid_chars_regex = '.A-Z0-9_ !@#$%^&()+={}\\[\\]\',~`-';
// Characters allowed in the file name (in a Regular Expression format)
//$extension_whitelist = array('csv', 'gif', 'png','tif');	// Allowed file extensions
$MAX_FILENAME_LENGTH = 260;
//Header 'X-File-Name' has the dashes converted to underscores by PHP:
if (!isset($_SERVER['HTTP_X_FILE_NAME'])) {
    HandleError('Missing file name!');
}
$file_name = preg_replace('/[^' . $valid_chars_regex . ']|\\.+$/i', '', $_SERVER['HTTP_X_FILE_NAME']);
if (strlen($file_name) == 0 || strlen($file_name) > $MAX_FILENAME_LENGTH) {
    HandleError('Invalid file name');
}
if (file_exists($save_path . $file_name)) {
    HandleError('A file with this name already exists');
}
//echo 'Reading php://input stream...<BR>Writing to file: '.$uploadPath.$fileName.'<BR>';
/*
// Validate file extension
	$path_info = pathinfo($file_name);
	$file_extension = $path_info["extension"];
	$is_valid_extension = false;
	foreach ($extension_whitelist as $extension) {
		if (strcasecmp($file_extension, $extension) == 0) {
			$is_valid_extension = true;
			break;
		}
	}
	if (!$is_valid_extension) {
		HandleError("Invalid file extension");
开发者ID:raidery,项目名称:ridex,代码行数:31,代码来源:xhrupload.php

示例14: header

兼容IE 6 及以上的所有浏览器

后端支持:
支持PHP5.X 至 PHP7.0或以上
支持JAVA后端(shearphoto1.3开发)

系统支持:
支持linux WINDOW服务器
shearphoto采用原生JS面向对象 + 原生PHP面向对象开发,绝对不含JQ插件,对JQ情有独忠的,这个插件不合适你                                                     

                                                                                                         2015  年  9月  5 日  
                                                                                                         shearphoto作者:明哥先生
                                                                                                         版本号:shearphoto2.0
                                                                                                         shearphoto官网:www.shearphoto.com
                                                                                                         shearphoto官方QQ群:461550716                                                                                                             

****************ShearPhoto2.0 免费,开源,兼容目前所有浏览器,纯原生JS和PHP编写,完美兼容linux和WINDOW服务器*******/
/*.......................注意.............非HTML浏览器上传,拍照上传都会用到该文件哦,加入逻辑代码后。所有功能都要确保正确!............................注意..........................*/
header('Content-type:text/html;charset=utf-8');
//error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); //关闭错误提示
require "shearphoto.config.php";
require "shearphoto.up.php";
if (!move_uploaded_file($_FILES['UpFile']['tmp_name'], $UpFile['file_url'])) {
    HandleError('后端获取不到文件写入权限。原因:move_uploaded_file()函数-无法写入文件');
}
$UpFile['file_url'] = str_replace(array(ShearURL, "\\"), array("", "/"), $UpFile['file_url']);
/*
来到这里时,已经代表上传成功,你可以在这里尽情写的你逻辑
$UpFile['file_url']就是那张临时待截图片的路径!
*/
echo '{"success":"' . $UpFile['file_url'] . '"}';
开发者ID:xfei6868,项目名称:shearphoto,代码行数:31,代码来源:upload.php

示例15: ExecuteBatchQuery

function ExecuteBatchQuery($mysql, $query)
{
    WriteLog("Enter ExecuteBatchQuery");
    $found = FALSE;
    $token = NULL;
    $prev = NULL;
    $token = my_strtok($query, $found);
    while (!empty($token)) {
        $prev = $token;
        $token = my_strtok($query, $found);
        if (empty($token)) {
            return ExecuteSingleQuery($mysql, $prev);
        }
        $result = mysql_query($prev, $mysql);
        if (!$result) {
            return HandleError(mysql_errno(), mysql_error());
        }
        mysql_free_result($result);
    }
    WriteLog("Exit ExecuteBatchQuery");
    return;
}
开发者ID:juliogallardo1326,项目名称:proc,代码行数:22,代码来源:sqly.php


注:本文中的HandleError函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。