本文整理汇总了PHP中gcms::isValidImage方法的典型用法代码示例。如果您正苦于以下问题:PHP gcms::isValidImage方法的具体用法?PHP gcms::isValidImage怎么用?PHP gcms::isValidImage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gcms
的用法示例。
在下文中一共展示了gcms::isValidImage方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: elseif
if (sizeof($index) == 0) {
$ret['error'] = 'ACTION_ERROR';
} elseif ($save['name'] == '') {
$ret['ret_write_name'] = 'FNAME_EMPTY';
$ret['error'] = 'FNAME_EMPTY';
$ret['input'] = 'write_name';
} elseif ($icon['tmp_name'] == '' && $id == 0) {
// ใหม่ ต้องมีรูปภาพเสมอ
$ret['ret_write_picture'] = 'REQUIRE_PICTURE';
$ret['error'] = 'REQUIRE_PICTURE';
$ret['input'] = 'write_picture';
} else {
// อัปโหลดรูปภาw
if ($icon['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage(array('jpg', 'gif', 'png'), $icon);
if (!$info) {
$ret['ret_write_picture'] = 'INVALID_FILE_TYPE';
$input = 'write_picture';
$error = 'INVALID_FILE_TYPE';
} else {
$save['picture'] = $index[0]['id'] . '.jpg';
// อัปโหลด
if (!gcms::cropImage($icon['tmp_name'], DATA_PATH . "personnel/{$save['picture']}", $info, $config['personnel_image_w'], $config['personnel_image_h'])) {
$ret['ret_write_picture'] = 'DO_NOT_UPLOAD';
$input = 'write_picture';
$error = 'DO_NOT_UPLOAD';
} else {
$ret['imgIcon'] = rawurlencode(DATA_URL . "personnel/{$save['picture']}?{$mmktime}");
}
// ลบไฟล์เดิม
示例2: explode
$error = !$error ? 'ALIAS_EXISTS' : $error;
$tab = !$tab ? 'options' : $tab;
} else {
$ret['ret_write_alias'] = '';
}
}
// ไฟล์อัปโหลด
if (!$error && $index['img_typies'] != '') {
$img_typies = explode(',', $index['img_typies']);
// path เก็บรูป
$dir = DATA_PATH . "document";
// อัปโหลด
foreach ($_FILES as $key => $file) {
if (!$error && $file['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage($img_typies, $file);
if (!$info) {
// ชนิดไฟล์อัปโหลด
$ret["ret_{$key}"] = 'INVALID_FILE_TYPE';
$input = !$input ? $key : $input;
$error = !$error ? 'INVALID_FILE_TYPE' : $error;
} else {
$ret["ret_{$key}"] = '';
// อัปโหลด
$k = str_replace('write_', '', $key);
$save[$k] = "{$k}-{$index['module_id']}-{$index['id']}.{$info['ext']}";
if (!gcms::cropImage($file['tmp_name'], "{$dir}/{$save[$k]}", $info, $index['icon_width'], $index['icon_height'])) {
$ret["ret_{$key}"] = 'DO_NOT_UPLOAD';
$input = !$error ? $key : $input;
$error = !$error ? 'DO_NOT_UPLOAD' : $error;
} else {
示例3: str_replace
$save['website'] = str_replace(array('http://', 'https://', 'ftp://'), array('', '', ''), $save['website']);
$patt = '!^(\\.?([a-z0-9-]+))+\\.[a-z]{2,6}(:[0-9]{1,5})?(/[a-zA-Z0-9.,;\\?|\'+&%\\$#=~_-]+)*$!i';
if ($save['website'] != '' && !preg_match($patt, $save['website'])) {
$ret['ret_register_website'] = 'REGISTER_INVALID_WEBSITE';
$input = !$input ? 'register_website' : $input;
$error = !$error ? 'REGISTER_INVALID_WEBSITE' : $error;
} else {
$ret['ret_register_website'] = '';
}
}
}
// ตรวจสอบรูปภาพอัปโหลดสมาชิก
$register_usericon = $_FILES['register_usericon'];
if ($register_usericon['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage($config['user_icon_typies'], $register_usericon);
if (!$info) {
$ret['ret_register_usericon'] = 'INVALID_FILE_TYPE';
$input = !$input ? 'register_usericon' : $input;
$error = !$error ? 'INVALID_FILE_TYPE' : $error;
} else {
if ($user['icon'] != '') {
@unlink(USERICON_FULLPATH . $user['icon']);
}
// สร้างรูป thumbnail
if ($info['width'] == $config['user_icon_w'] && $info['height'] == $config['user_icon_h']) {
$save['icon'] = "{$user['id']}.{$info['ext']}";
if (!@move_uploaded_file($register_usericon['tmp_name'], USERICON_FULLPATH . $save['icon'])) {
$ret['ret_register_usericon'] = 'DO_NOT_UPLOAD';
$input = !$input ? 'register_usericon' : $input;
$error = !$error ? 'DO_NOT_UPLOAD' : $error;
示例4: elseif
$sql = "SELECT 1+COALESCE(MAX(`link_order`),0) FROM `" . DB_TEXTLINK . "`";
$sql = "SELECT ({$sql}) AS `link_order`,(1+COALESCE(MAX(`id`),0)) AS `id` FROM `" . DB_TEXTLINK . "`";
}
$textlink = $db->customQuery($sql);
if (sizeof($textlink) == 0) {
$ret['error'] = 'ACTION_ERROR';
$error = true;
} elseif (!preg_match('/^[a-z0-9]{1,}$/u', $save['name'])) {
$ret['ret_textlink_name'] = 'this';
$ret['input'] = 'textlink_name';
$error = true;
} else {
$textlink = $textlink[0];
if ($logo['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage(array('jpg', 'gif', 'png', 'swf'), $logo);
if (!$info) {
$ret['error'] = 'INVALID_FILE_TYPE';
$error = true;
} else {
$save['width'] = $info['width'];
$save['height'] = $info['height'];
// ชื่อไฟล์ใหม่
$save['logo'] = "{$textlink['id']}.{$info['ext']}";
if (!@copy($logo['tmp_name'], DATA_PATH . 'image/' . $save['logo'])) {
$ret['error'] = 'DO_NOT_UPLOAD';
$error = true;
}
}
}
if (!$error) {
示例5:
$ret['ret_download_file'] = 'FILE_TOO_BIG';
$error = true;
} else {
if (!@copy($file_upload['tmp_name'], DATA_PATH . "download/file-{$last_id}.{$ext}")) {
$ret['error'] = 'DO_NOT_UPLOAD';
$ret['ret_download_file'] = 'DO_NOT_UPLOAD';
$error = true;
} else {
$save['file'] = "file-{$last_id}.{$ext}";
$save['size'] = $file_upload['size'];
}
}
}
if (!$error && $thumbnail['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด (thumbnail)
$info = gcms::isValidImage($config['download_thumb_type'], $thumbnail);
if (!$info) {
$ret['error'] = 'INVALID_FILE_TYPE';
$ret['ret_download_thumbnail'] = 'INVALID_FILE_TYPE';
$error = true;
} else {
$thumb = "thumb-{$last_id}";
if ($info['width'] <= $config['download_thumb_width'] && $info['height'] <= $config['download_thumb_width']) {
// รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
if (!@copy($thumbnail['tmp_name'], DATA_PATH . "download/{$thumb}.{$info['ext']}")) {
$ret['error'] = 'DO_NOT_UPLOAD';
$ret['ret_download_thumbnail'] = 'DO_NOT_UPLOAD';
$error = true;
} else {
$save['thumb'] = "{$thumb}.{$info['ext']}";
$save['thumb_w'] = $info['width'];
示例6: elseif
}
if (!$index) {
// ไม่พบ หรือไม่สามารถแก้ไขได้
$ret['error'] = 'ACTION_ERROR';
} elseif ($img_typies == '') {
$ret['error'] = 'ICON_CATEGORY_TYPE_EMPTY';
$ret['input'] = 'config_img_typies';
$ret['ret_config_img_typies'] = 'ICON_CATEGORY_TYPE_EMPTY';
} else {
$ret['ret_config_img_typies'] = '';
// ไอคอนของหมวด
$cfg = array();
$default_icon = $_FILES['config_default_icon'];
if ($default_icon['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage(explode(',', $img_typies), $default_icon);
if (!$info) {
$ret['error'] = 'INVALID_FILE_TYPE';
$ret['input'] = 'config_default_icon';
$ret['ret_config_default_icon'] = 'INVALID_FILE_TYPE';
} else {
// ชื่อไฟล์ใหม่
$icon = DATA_FOLDER . "document/default-{$index['id']}";
if ($info['width'] <= $icon_width && $info['height'] <= $icon_height) {
// รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
if (!@move_uploaded_file($default_icon['tmp_name'], ROOT_PATH . "{$icon}.{$info['ext']}")) {
$ret['error'] = 'DO_NOT_UPLOAD';
$ret['input'] = 'config_default_icon';
$ret['ret_config_default_icon'] = 'DO_NOT_UPLOAD';
} else {
$cfg[] = "icon_w={$info['width']}";
示例7: array
// icon
if (!$error && !empty($index['img_typies'])) {
// old icon
$icon = gcms::ser2Array($index, 'icon');
if (sizeof($icon) == 1) {
$icon = array();
}
// ชนิดของไฟล์ที่ยอมรับ
$img_typies = explode(',', $index['img_typies']);
foreach ($_FILES as $key => $value) {
if ($value['tmp_name'] != '') {
$ret["ret_{$key}"] = '';
// ภาษา
$k = str_replace('category_icon_', '', $key);
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage($img_typies, $value);
if (!$info) {
$ret["ret_{$key}"] = 'INVALID_FILE_TYPE';
$input = $key;
$error = 'INVALID_FILE_TYPE';
} else {
$icon[$k] = "cat-{$k}-{$index['id']}.{$info['ext']}";
if ($info['width'] <= $index['icon_width'] && $info['height'] <= $index['icon_height']) {
// รูปภาพต้นฉบับ เท่ากับ หรือ เล็กกว่าที่กำหนดให้อัปโหลดเลย
if (!@move_uploaded_file($value['tmp_name'], DATA_PATH . "board/{$icon[$k]}")) {
$ret["ret_{$key}"] = 'DO_NOT_UPLOAD';
$input = $key;
$error = 'DO_NOT_UPLOAD';
} else {
$ret["icon_{$k}"] = rawurlencode(DATA_URL . "board/{$icon[$k]}?{$mmktime}");
}
示例8: elseif
}
// ไอคอน
$icon = $_FILES['lang_icon'];
if (mb_strlen($name) != 2 || !preg_match('/^[a-z]{2,2}$/', $name)) {
// ชื่อภาษาไม่ถูกต้อง
$ret['error'] = 'LANGUAGE_INVALID';
$ret['input'] = 'lang_name';
$ret['ret_lang_name'] = 'LANGUAGE_INVALID';
} elseif ($id == '' && $icon['tmp_name'] == '') {
// ใหม่ ไม่พบไอคอน
$ret['ret_lang_icon'] = 'REQUIRE_PICTURE';
$ret['input'] = 'lang_icon';
$ret['error'] = 'REQUIRE_PICTURE';
} elseif ($icon['tmp_name'] != '') {
// ตรวจสอบชนิดของไฟล์
$info = gcms::isValidImage(array('gif'), $icon);
if (!$info) {
$ret['ret_lang_icon'] = 'INVALID_FILE_TYPE';
$ret['input'] = 'lang_icon';
$ret['error'] = 'INVALID_FILE_TYPE';
}
}
if (!isset($ret['error'])) {
if ($id == '') {
// เพิ่มภาษา
if (isset($install_languages[$name])) {
// ไม่สามารถใช้ชื่อภาษานี้ได้
$ret['error'] = $install_languages[$name] == 1 ? 'LANGUAGE_EXISTS' : 'LANGUAGE_ERROR';
$ret['input'] = 'lang_name';
$ret['ret_lang_name'] = $ret['error'];
} else {
示例9: addslashes
}
if ($id == 0 && sizeof($ret) == 0 && $detail != '') {
// ตอบคำถาม ตรวจสอบโพสต์ซ้ำภายใน 1 วัน
$sql = "SELECT `id` FROM `" . DB_BOARD_R . "`";
$sql .= " WHERE `detail`='" . addslashes($detail) . "' AND `email`='{$post['email']}'";
$sql .= " AND `module_id`='{$index['module_id']}' AND `last_update`>" . ($mmktime - 86400);
$sql .= " LIMIT 1";
$flood = $db->customQuery($sql);
if (sizeof($flood) > 0) {
$ret['error'] = 'FLOOD_COMMENT';
}
}
// รูปภาพอัปโหลด
if (sizeof($ret) == 0 && $index['img_upload_type'] != '' && $picture['tmp_name'] != '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage(explode(',', $index['img_upload_type']), $picture);
if (!$info) {
$ret['error'] = 'INVALID_FILE_TYPE';
$ret['input'] = 'reply_picture';
$ret['ret_reply_picture'] = 'INVALID_FILE_TYPE';
} elseif ($picture['size'] > $index['img_upload_size'] * 1024) {
$ret['error'] = 'FILE_TOO_BIG';
$ret['input'] = 'reply_picture';
$ret['ret_reply_picture'] = 'FILE_TOO_BIG';
} else {
// ชื่อไฟล์
$post['picture'] = "{$mmktime}.{$info['ext']}";
while (is_file(DATA_PATH . "board/{$post['picture']}")) {
$mmktime++;
$post['picture'] = "{$mmktime}.{$info['ext']}";
}
示例10: unset
}
}
}
}
// bg image
if (isset($_POST['delete_bg_image'])) {
$ret['bgImageFile'] = '';
unset($config['bg_image']);
if (is_file(DATA_PATH . "image/{$config['bg_image']}")) {
@unlink(DATA_PATH . "image/{$config['bg_image']}");
}
} elseif (isset($_FILES['bg_image'])) {
$bg_image = $_FILES['bg_image'];
if ($bg_image['tmp_name'] !== '') {
// ตรวจสอบไฟล์อัปโหลด
$info = gcms::isValidImage(array('jpg', 'gif', 'png'), $bg_image);
if (!$info) {
$ret['ret_bg_image'] = 'INVALID_FILE_TYPE';
$error = 'INVALID_FILE_TYPE';
} else {
if (@copy($bg_image['tmp_name'], DATA_PATH . "image/bg_image.{$info['ext']}")) {
$ret['bgImageFile'] = "bg_image.{$info['ext']}";
$ret['ret_bg_image'] = '';
$config['bg_image'] = "bg_image.{$info['ext']}";
} else {
$ret['ret_bg_image'] = 'DO_NOT_UPLOAD';
$error = 'DO_NOT_UPLOAD';
}
}
}
}