$faksimil = $form->input('faksimil');
 $email = $form->input('email');
 $action = $form->input('action');
 $user = $_SESSION['nama'];
 $date = date('Y-m-d H:i:s');
 // START INSERT DATA ==============================>
 if ($action == "insert") {
     $foto = $_FILES['foto']['name'];
     $id = $number->id('anggota', 5);
     $kta_baru = $number->kta($desa_id, $tgl_lahir, $id);
     if (empty($foto)) {
         $foto = "user.png";
     } else {
         $source = $_FILES['foto']['tmp_name'];
         $image->upload($foto, $source);
         $image->thumbnail($foto);
     }
     $sql = "INSERT INTO anggota\n                        (id,nama, id_tipe, id_no, jabatan, tempat, tgl_lahir, jns_kelamin, agama,\n                         pernikahan, pekerjaan_id, pendidikan, alamat, rt, rw, propinsi_id, kota_id, kecamatan_id,\n                         desa_id, hp, telp_rumah, telp_kantor, faksimil, email, foto, kta_baru, aktif, crt, crt_date) \n                    VALUES \n                        ('{$id}','{$nama}','{$id_tipe}','{$id_no}','{$jabatan}','{$tempat}','{$tgl_lahir}','{$jns_kelamin}','{$agama}',\n                         '{$pernikahan}','{$pekerjaan_id}','{$pendidikan}','{$alamat}','{$rt}','{$rw}','{$propinsi_id}','{$kota_id}','{$kecamatan_id}',\n                         '{$desa_id}','{$hp}','{$telp_rumah}','{$telp_kantor}','{$faksimil}','{$email}','{$foto}','{$kta_baru}','{$aktif}','{$user}','{$date}')";
     if (!$database->query($sql)) {
         die($sql);
     } else {
         $_SESSION['success'] = "<b>Berhasil!</b> Anda telah menambahkan data baru";
         header("Location: create.php");
         exit;
     }
 }
 // END INSERT DATA ==============================>
 // START UPDATE DATA ==============================>
 if ($action == "update") {
     $id = $form->input('id');
     $kta_baru = $number->kta($desa_id, $tgl_lahir, $id);
示例#2
0
文件: common.php 项目: laiello/xiv
 public function crop_image($file, $size = '200')
 {
     $this->using('image');
     $img = new image();
     if ($img->load($file)) {
         $img->thumbnail($size);
         $img->save();
     }
 }
示例#3
0
            if ($ext == "png") {
                return true;
            } else {
                if ($ext == "bmp") {
                    return true;
                } else {
                    return false;
                }
            }
        }
    }
}
$dir_contents = scandir($dir);
foreach ($dir_contents as $item) {
    if (is_dir($dir . $item) && $item != '.' && $item != '..') {
        $dirs[] = $item;
    }
}
foreach ($dirs as $current) {
    $dir_contents = scandir("./images/" . $current . "/");
    foreach ($dir_contents as $item) {
        if ($item != '.' && $item != '..' && !is_dir($dir . $item) && is_valid_extension($item) && !file_exists("./thumbnails/{$current}/thumbnail_{$item}")) {
            $image = new image();
            if (!is_dir("./thumbnails/" . $current . "/")) {
                $image->makethumbnailfolder($current);
            }
            $image->thumbnail($current . "/" . $item);
            print "./thumbnails/" . $current . "/thumbnail_" . $item . "<br>\n";
        }
    }
}
示例#4
0
include '../common.php';
require_once ROOT_PATH . '/include/FileUploader.class.php';
require_once ROOT_PATH . 'include/Image.class.php';
if ($action == 'save' && !empty($title) && !empty($url)) {
    $title = m_addslashes($title);
    $intro = m_addslashes($content);
    $url = trim($url);
    $file = $_FILES['uploadpic'];
    //文件上传时注意enctype="multipart/form-data"
    //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 )
    if (!empty($file['name'])) {
        $uf = new FileUploader($_FILE['uploadpic']);
        $pic = $uf->move(ROOT_PATH . '/video-upimg', 2);
        $uppic = $pic[0] ? get_basename($pic[0]) : 'NULL';
        $img = new image(ROOT_PATH . 'video-upimg/' . $uppic);
        $img->thumbnail(128, 72, ROOT_PATH . 'video-upimg/' . $uppic);
    }
    $db->query("INSERT INTO `video` VALUES (NULL,'{$title}','{$intro}','{$uppic}','{$url}',now())") or error('Unable to add advertising', __FILE__, __LINE__, $db->error());
    refer('添加视频成功');
}
if ($action == 'del' && isset($id)) {
    $query_id = $db->query("SELECT img FROM `video` WHERE id = {$id}");
    $result = $db->fetch_array($query_id);
    $img = $result['img'];
    if ($img) {
        @unlink(ROOT_PATH . '/video-upimg/' . $img);
    }
    $db->query("DELETE FROM `video` WHERE id = {$id}") or error('Unable to delete advertising', __FILE__, __LINE__, $db->error());
    refer('删除视频成功!');
}
?>
示例#5
0
     } else {
         $rating = "Safe";
     }
 }
 if ($userc->check_log()) {
     $user = $checked_username;
 } else {
     $user = "******";
 }
 $ip = $db->real_escape_string($_SERVER['REMOTE_ADDR']);
 $isinfo = getimagesize("./images/" . $iinfo[0] . "/" . $iinfo[1]);
 $query = "INSERT INTO {$post_table}(creation_date, hash, image, title, owner, height, width, ext, rating, tags, directory, source, active_date, ip) VALUES(NOW(), '" . md5_file("./images/" . $iinfo[0] . "/" . $iinfo[1]) . "', '" . $iinfo[1] . "', '{$title}', '{$user}', '" . $isinfo[1] . "', '" . $isinfo[0] . "', '{$ext}', '{$rating}', '{$tags}', '" . $iinfo[0] . "', '{$source}', '" . date("Ymd") . "', '{$ip}')";
 if (!is_dir("./thumbnails/" . $iinfo[0] . "/")) {
     $image->makethumbnailfolder($iinfo[0]);
 }
 if (!$image->thumbnail($iinfo[0] . "/" . $iinfo[1])) {
     print "Thumbnail generation failed! A serious error occured and the image could not be resized.<br /><br />";
 }
 if (!$db->query($query)) {
     print "failed to upload image.";
     print $query;
     unlink("./images/" . $iinfo[0] . "/" . $iinfo[1]);
     $image->folder_index_decrement($iinfo[0]);
     $ttags = explode(" ", $tags);
     foreach ($ttags as $current) {
         $tclass->deleteindextag($current);
     }
 } else {
     $query = "SELECT id, tags FROM {$post_table} WHERE hash='" . md5_file('./images/' . $iinfo[0] . "/" . $iinfo[1]) . "' AND image='" . $iinfo[1] . "' AND directory='" . $iinfo[0] . "'  LIMIT 1";
     $result = $db->query($query);
     $row = $result->fetch_assoc();
示例#6
0
 if ($rating == "e") {
     $rating = "Explicit";
 } else {
     if ($rating == "q") {
         $rating = "Questionable";
     } else {
         $rating = "Safe";
     }
 }
 if ($userc->check_log()) {
     $user = $checked_username;
 } else {
     $user = "******";
 }
 $ip = $db->real_escape_string($_SERVER['REMOTE_ADDR']);
 $thumb = $image->thumbnail($iinfo[0] . "/" . $iinfo[1]);
 $isinfo = $image->getInfo();
 $query = "INSERT INTO {$post_table}(creation_date, hash, image, title, owner, height, width, ext, rating, tags, directory, source, active_date, ip) VALUES(NOW(), '" . md5_file("./images/" . $iinfo[0] . "/" . $iinfo[1]) . "', '" . $iinfo[1] . "', '{$title}', '{$user}', '" . $isinfo[1] . "', '" . $isinfo[0] . "', '{$ext}', '{$rating}', '{$tags}', '" . $iinfo[0] . "', '{$source}', '" . date("Ymd") . "', '{$ip}')";
 if (!is_dir("./thumbnails/" . $iinfo[0] . "/")) {
     $image->makethumbnailfolder($iinfo[0]);
 }
 if (!$thumb) {
     print "Thumbnail generation failed! A serious error occurred and the image could not be resized.<br /><br />";
 }
 if (!$db->query($query)) {
     print "failed to upload image.";
     print $query;
     unlink("./images/" . $iinfo[0] . "/" . $iinfo[1]);
     $image->folder_index_decrement($iinfo[0]);
     $ttags = explode(" ", $tags);
     foreach ($ttags as $current) {
示例#7
0
}
require_once '../common.php';
require_once ROOT_PATH . '/include/FileUploader.class.php';
require_once ROOT_PATH . '/include/Image.class.php';
if ($action == 'save' && !empty($name) && !empty($site)) {
    $name = m_addslashes($name);
    $intro = m_addslashes($intro);
    $file = $_FILES['img'];
    //文件上传时注意enctype="multipart/form-data"
    //Array ( [name] => a002d.gif [type] => image/gif [tmp_name] => d:/webserver/Server/TEMP\php8E.tmp [error] => 0 [size] => 19675 )
    if (!empty($file['name'])) {
        $uf = new FileUploader($_FILE['img']);
        $pic = $uf->move(ROOT_PATH . 'logos', 2);
        $uppic = $pic[0] ? get_basename($pic[0]) : 'NULL';
        $img = new image(ROOT_PATH . 'logos/' . $uppic);
        $img->thumbnail(88, 31, ROOT_PATH . 'logos/' . $uppic);
        //$img->watermark(ROOT_PATH . 'include/watermark.png','','',ROOT_PATH . 'images/'.$uppic);
    } elseif ($isimg) {
        refer('您未选择图片上传!');
    }
    $db->query("INSERT INTO `links` VALUES (NULL,'{$name}','{$site}','{$intro}','{$isimg}','{$uppic}','1',now())") or error('Unable to add link', __FILE__, __LINE__);
    updateLinkCache();
    refer('添加成功');
}
if ($action == 'invisable' && isset($v) && isset($id)) {
    $v = $v ? 0 : 1;
    $db->query("UPDATE `links` SET invisable = '{$v}' WHERE id = {$id}") or error('Unable to set link\'s invisable', __FILE__, __LINE__, $db->error());
    updateLinkCache();
    refer('操作成功!');
}
if ($action == 'del' && isset($id)) {