Exemplo n.º 1
0
 public function mark($img)
 {
     $options = $this->widget('Widget_Options');
     $cfg = $options->plugin('Watermark');
     $img1 = self::lujin(__TYPECHO_ROOT_DIR__ . base64_decode($img));
     $dir = '.' . __TYPECHO_PLUGIN_DIR__ . '/Watermark/';
     $ck_p = 0;
     $ck_t = 0;
     if (in_array('pic', $cfg->vm_type) && file_exists($dir . $cfg->vm_pic)) {
         $ck_p = 1;
     }
     if (in_array('text', $cfg->vm_type) && file_exists($dir . $cfg->vm_font)) {
         $ck_t = 1;
     }
     $pos_p = $cfg->vm_pos_pic;
     $pos_t = $cfg->vm_pos_text;
     $font = $dir . $cfg->vm_font;
     $text = $cfg->vm_text;
     $size = $cfg->vm_size;
     $color = $cfg->vm_color;
     $mic_x = $cfg->vm_m_x;
     $mic_y = $cfg->vm_m_y;
     $width = $cfg->vm_width;
     $wmpic = $cfg->vm_pic ? $cfg->vm_pic : 'WM.png';
     $alpha = $cfg->vm_alpha;
     $file = false;
     if (file_exists($img1)) {
         require_once $dir . 'class.php';
         $wm = new WaterMark();
         $wm->setImSrc($img1, $width);
         // 设置背景图
         $wm->setImWater($dir . $wmpic);
         // 设置水印图
         $wm->setFont($font, $text, $size, $color);
         // 设置水印文字相关(字体库、文本、字体大小、颜色)
         if (isset($cfg->vm_cache) && 'cache' == $cfg->vm_cache) {
             $file = base64_decode($img);
             $ext = pathinfo($file, PATHINFO_EXTENSION);
             $dir_cache = __TYPECHO_ROOT_DIR__ . '/usr/img';
             if (!is_dir($dir_cache)) {
                 @mkdir($dir_cache, 0777);
             }
             //检测缓存目录是否存在,自动创建
             $file = './usr/img/' . md5($file) . '.' . $ext;
         }
         $wm->mark($ck_p, $pos_p, $ck_t, $pos_t, $mic_x, $mic_y, $alpha, $file);
     } else {
         $this->widget('Widget_Archive@404', 'type=404')->render();
     }
 }
Exemplo n.º 2
0
        @unlink($_FILES[$upload_name]['tmp_name']);
    }
    @copy($filepath . $original_url, $filepath . $shrink_url);
} else {
    HandleError(iconv($_G['charset'], 'utf-8', $php_lang['daxiaoxz']));
    exit(0);
}
$pic = $filepath . $shrink_url;
new myThumbClass($pic, 276, 195, $pic, 0, 0);
$imgwater = $_G["gp_imgwater"];
if ($imgwater) {
    $imgwater_wz = intval($_G["gp_imgwater_wz"]);
    $wm = new WaterMark();
    $wm->setImSrc($filepath . $original_url);
    $wm->setImWater($imgwater);
    $wm->mark(1, $imgwater_wz, 0, 0);
}
$curtime = time();
if ($albums) {
    if (!$albums['img_url'] || !file_exists($albums['img_url'])) {
        DB::update('forum_alliance_albums', array('imgnum' => $albums[imgnum] + 1, 'revisedate' => $curtime, 'img_url' => $pic), "id='{$albums['id']}'");
        DB::insert('forum_alliance_albums_img', array('id' => '', 'title' => $title, 'shrink_url' => $filepath . $shrink_url, 'original_url' => $filepath . $original_url, 'albums_id' => $albums[id], 'createdate' => $curtime, 'status' => 1));
    } else {
        DB::update('forum_alliance_albums', array('imgnum' => $albums[imgnum] + 1, 'revisedate' => $curtime), "id='{$albums['id']}'");
        DB::insert('forum_alliance_albums_img', array('id' => '', 'title' => $title, 'shrink_url' => $filepath . $shrink_url, 'original_url' => $filepath . $original_url, 'albums_id' => $albums[id], 'createdate' => $curtime));
    }
} else {
    DB::insert('forum_alliance_albums', array('id' => '', 'title' => $title, 'img_url' => $pic, 'uid' => $uid, 'uname' => $uname, 'arid' => $aid, 'createdate' => $curtime, 'revisedate' => $curtime, 'imgnum' => 1));
    $abid = DB::insert_id();
    DB::insert('forum_alliance_albums_img', array('id' => '', 'title' => $title, 'shrink_url' => $filepath . $shrink_url, 'original_url' => $filepath . $original_url, 'albums_id' => $abid, 'createdate' => $curtime, 'status' => 1));
}