KIND 水印集成
1 首先请教个问题(1)我把KIND的上传图片集成到CI了 但是开启CSRF 在不关闭CSRF的情况下 如何像AJAX CSRF 那样解决呢 找了一顿没找到在哪加(2)我想做个获取远程图片 不知道他那个 填入网络地址 提交 经过PHP不也是没找到
代码我就不写了 具体说下我的解决办法
1 首先 你建个控制器
然后 建个UPLOAD把upload_json.phpfunctions alert()上面的代码贴上去
把upload 里面的ALERT 更改为$this->alert;
然后FUNTION ALERT 放入控制器中
再建个MANAGE控制器 把file_manager_json.php里面的代码除了 FUNCTION cmp_func 同上再建个控制器
把usort($file_list, 'cmp_func');更改为usort($file_list, array($this, 'cmp_func'));
水印的话 我首先建立了个配置类
至于这个东西怎么写 自己可以设计
配置文件代码如下
$config['open']='1';
$config['watype']='0';
$config['title']='copyright';
$config['font']='TMBGSTD_.TTF';
$config['fontsize']='15';
$config['yanse']='#f16d7e';
$config['photo']='user_botton.gif';
$config['alpha']='30';
$config['weizhi']='8';
$config['quality']='100';
然后在编辑器上方加个按钮 是否添加水印 判断配置文件OPEN值 如果是1那么默认选中
在上upload$shuiyi=@$_POST['checkbox'];
if($shuiyin==0)
{
$this->load->model('xxx/photos');
$this->photos->add_shuiyin($save_path.$new_file_name);
}
模型
add_shuiyin
require('xxx/upload.php');
if($config['watype']==0)
{
$result=$this->photos->wenzi($photo);//文字水印
}
else
{
$result=$this->photos->tp($photo);//图片水印
}
/*文字水印*/
function wenzi($photo)
{
$this->load->library('image_lib');
$configa['source_image'] = $photo;
require('./settings/upload.php');
$configa['wm_text'] = $config['title'];
$configa['wm_type'] = 'text';
$configa['wm_font_path'] = './images/'.$config['font'];
$configa['wm_font_size'] = $config['fontsize'];
$configa['wm_font_color'] =$config['yanse'];
$weizhi=$this->weizhi($config['weizhi']);
$configa['wm_vrt_alignment'] = $weizhi;
$configa['wm_hor_alignment'] = $weizhi;
$this->image_lib->initialize($configa);
if($this->image_lib->watermark())
{
return true;
}
else
{
return false;
}
}
function tp($photo)
{
$this->load->library('image_lib');
$configa['source_image'] = $photo;
require('./settings/upload.php');
$configa['wm_type'] = 'overlay';
$configa['wm_overlay_path']="./images/".$config['photo'];
$configa['wm_opacity']=$config['alpha'];
$configa['wm_shadow_color']=$config['yanse'];
$weizhi=$this->weizhi($config['weizhi']);
$configa['quality']=$config['quality'];
$configa['wm_vrt_alignment'] = $weizhi;
$configa['wm_hor_alignment'] = $weizhi;
$this->image_lib->initialize($configa);
if($this->image_lib->watermark())
{
return true;
}
else
{
return false;
}
}
function weizhi($config)
{
$arry_x=array('left','center','right');
$arry_y=array('top','middle','bottom');
switch($config)
{
/*随机位置*/
case 0:
$this->load->helper('array');
$x=random_element($arry_x);
$y=random_element($arry_y);
return array($x,$y);break;
/*顶部居左*/
case 1:
return array($arry_x,$arry_y);
break;
/*顶部居中*/
case 2:
return array($arry_x,$arry_y);
break;
/*顶部居右*/
case 3:
return array($arry_x,$arry_y);
break;
/*底部居左*/
case 4:
return array($arry_x,$arry_y);
break;
/*底部居中*/
case 5:
return array($arry_x,$arry_y);
break;
/*底部居右*/
case 6:
return array($arry_x,$arry_y);
break;
/*中部居左*/
case 7:
return array($arry_x,$arry_y);
break;
/*中部居中*/
case 8:
return array($arry_x,$arry_y);
break;
/*中部居右*/
case 9:
return array($arry_x,$arry_y);
break;
}
}
页:
[1]