php图片加水印,切头像图和自动缩放
代码如下 | 复制代码 |
<html> http://code.google.com/p/queryphp/downloads/list frameworklibimg.class.php中的img类 <? */ class uploadrouter extends controller{
|
代码如下 | 复制代码 |
<?php session_start(); header("content-type:text/html;charset=utf-8"); require("stole_config.php"); require("conn.php"); require("keyword.php"); if(!empty($_post['ask'])) { $ask=urlencode(trim($_post['ask']));//获取表单提交的问题 $sp="s".$ask; }else { $sp=urlencode($_get['sp']); } if(empty($_get['jl'])) { $_get['jl']=1; } $jl=$_get['jl']; $pg=intval($_get['pg']);//获取页数 $rs=intval($_get['rs']);//获得 记录的参数 if($rs>9) { $rs=0; $pg++; } if($pg>51) { echo "采集完毕! 总共采集 ".urldecode($sp)." ".$jl."条记录"; exit(); } if($sp)//有设定答案才开始 { $str=@file_get_contents("http://wenwen.soso.com/z/search.e?sp={$sp}&pg={$pg}"); @preg_match("/<ol class="result_list">(.*)</ol>/ius",$str,$asklist);//获取问答列表 //echo $asklist[1]; $url="/<a target="_blank" href="/z/(q.*.htm)/ius"; @preg_match_all($url,$asklist[1],$urllist);//获取 所有的问题 $t=$urllist[1][$rs]; $uid=$t; $suid="ww{$uid}"; $sct=mysql教程_query("select count(*) from {$table_prefix}c_article where suid='$suid' "); $sct=mysql_fetch_array($sct); $sct=$sct[0]; if($sct==0) { $html=@file_get_contents("http://wenwen.soso.com/z/${t}"); $html=str_replace("<pre>","",str_replace("</pre>","",$html)); $html=str_replace("<br/><br/><br/>","<br/><br/>",$html); //echo $html; @preg_match("/<div class="question_main">.*<h3>(.*)</h3>/ius",$html,$ask_title); $art_title=$ask_title[1]; @preg_match("/<div class="answer_con">(.*)</div>/ius",$html,$answer); $j=count($answer)-1; $art_content="";//商品详细 for($i=$j;$i>=1;$i--) { if(strlen($answer[$i])>$min_t1) { $art_content .= $answer[$i]; } } $art_content=trim($art_content); $s1="/(<a .*>)(.*)</a>/ius"; $art_content=preg_replace($s1,${2},trim($art_content)); $word_arr=explode(",",iconv("gbk","utf-8",$cj_word)); $word_allow=false;//初始化是否允许采集 $word_count=count($word_arr);//总数 for($i=0;$i<$word_count;$i++) { if(substr_count($art_title,$word_arr[$i])>0) { $word_allow=1; $i=$word_count; } } if($word_allow)//如果合法 { //开始处理数据库教程 if(strlen($art_content)>$min_t2) { echo "<font color=red>添加中............................</font><br>"; echo $art_title."<br>"; $art_title=iconv('utf-8','gbk', $art_title); $title_ct=mysql_query("select count(*) from {$table_prefix}c_article where art_title ='$art_title' ");//查看标题是否重复 $title_ct=@mysql_fetch_array($title_ct); $title_ct=$title_ct[0]; if($title_ct>0) { $art_title .="{$same_title}{$title_ct}"; } $art_content=iconv('utf-8','gbk',str_replace(" ","<br>",$art_content)); $art_content=strtr($art_content,$keyword); $art_time=date("y-m-d"); $sql="insert into {$table_prefix}c_article(art_title,art_content,art_time,art_author,suid) values('$art_title','$art_content','$art_time','$art_author','$suid')";//插入采集表 mysql_query($sql); if(empty($t_catx_id))//如果无分类 { $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author}) values('$art_title','$art_content','$art_time','$art_author')"; }else { $sql2="insert into {$t_table}({$t_art_title},{$t_art_content},{$t_art_time},{$t_artx_author},{$t_catx_id}) values('$art_title','$art_content','$art_time','$art_author','$cat_id')"; } mysql_query($sql2);//插入文章表 $jl++;//如果存放数据库中 则记录加1 //处理数据库结束 }else { echo "长度不够"; } }else { echo "主题不符合要求"; } }else { echo "已经存在"; } $rs++; //记录下本次采集 的状况 $f_tt= urldecode($sp)."--页数".$pg." 记录数 ".$jl ; file_put_contents("ss.txt",$f_tt); echo "<script>location.href='wenwen.php?jl=".$jl."&sp=".$sp."&pg=".$pg."&rs=".$rs." ';</script>"; exit(); } ?> <link href="style.css教程" rel="stylesheet" type="text/css" /> <table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc"> <tr> <td height="50" align="center" bgcolor="#00cc00"><h1><a href="http://www.111cn.net">荐礼啦</a>知道问问采集插件</h1></td> </tr> </table> <table width="700" border="0" align="center" cellspacing="1" bgcolor="#cccccc" style="margin-top:6px; margin-bottom:6px;"> <tr> <td height="30" align="center" bgcolor="#ffffff"><a href="cj_config.php">采集设置</a> <a href="uninstall.php" onclick="return confirm('您确定要卸载采集插件吗');">卸载采集</a> <a href="cj_view.php">查看采集记录</a> <a href="cj_help.php">采集帮助</a> <a href="baidu.php" target="_blank">知道采集</a> <a href="wenwen.php" target="_blank">问问采集</a></td> </tr> </table> <form action="wenwen.php" method="post"> <table width="628" height="49" border="0" align="center"> <tr> <td width="413" align="right"><input name="ask" type="text" id="ask" size="50"></td> <td width="205"><input type="submit" name="button" id="button" value="问问采集" style=" padding-left:15px; padding-right:15px; height:25px; line-height:25px;"></td> </tr> </table> </form> |
if(!isset($_session))session_start();
/**2010-6-22
* $data 数组类型 包含以下变量
-------------------------------
* $sub_type submit类型(upload:上传按钮 delete:删除按钮),默认upload
* $file 通过表单获取的$_files['filename']数组
* $img_tag_id 预览图片的<img>的id值
* $img_dir 上传图片的目录
* $max_file_size 单位m(兆),默认:1m
* $type_array 允许的上传的图片类型(默认:image/pjpeg、image/jpeg、image/gif)
**/
function upload($data){
if(!$data['file']){
echo '<script>alert("file不能为空!");</script>';exit;
}
if(!$data['img_tag_id']){
echo '<script>alert("预览图片标签id不能为空!");</script>';exit;
}
if(!$data['img_dir']){
echo '<script>alert("图片上传目录不能为空!");</script>';exit;
}
if(!isset($data['max_file_size'])){
$data['max_file_size'] = 1024 * 1024;
}else{
$data['max_file_size'] = $data['max_file_size'] * 1024 * 1024;
}
if(!isset($data['type_array'])){
$data['type_array'] = array('image/pjpeg', 'image/jpeg', 'image/gif');
}
if(!isset($data['sub_type'])){
$data['sub_type'] = 'upload';
}
$imgpath = '';
if(isset($data['sub_type']) && $data['sub_type'] == 'delete'){
if(isset($_session['name']) && $_session['name']){
if(is_file($_session['imgpath'])){
$b = unlink($_session['imgpath']);
}
unset($_session['name'], $_session['imgpath']);
if(!isset($_session['name'])){
echo '<script>alert("删除成功!");</script>';
echo '<script>parent.document.getelementbyid("'.$data['img_tag_id'].'").style.display = "none";</script>';
}else{
echo '<script>alert("删除失败!");</script>';
}
}else{
echo '<script>alert("没有稿件!");</script>';
}exit;
}
if(isset($_session['imgpath']) && $_session['imgpath']){
echo '<script>alert("稿件已经存在,要想重新上传请删除原来的稿件!");</script>';exit;
}
if(!in_array($data['file']['type'], $data['type_array'])){
echo '<script>alert("稿件类型不匹配,请上传.jpg、.gif和.png格式的图片!");</script>';exit;
}
if($data['file']['size'] > $data['max_file_size']){
echo '<script>alert("您上传的稿件过大,请选择2m以下的图片上传!");</script>';exit;
}
if(!is_dir($data['img_dir'])){
@mkdir($data['img_dir'], 0777, true);
}
$imgpath = $data['img_dir'].'/'.date('his', time()).rand(100, 999).$data['file']['name'];
$isupload = move_uploaded_file($data['file']['tmp_name'], $imgpath);
if(!$isupload){
echo '<script>alert("稿件上传失败,请尝试重新上传!");</script>';exit;
}else{
echo '<script>alert("稿件上传成功!");</script>';
}
$_session['name'] = $data['file']['name'];
$_session['imgpath'] = $imgpath;
return $imgpath;
}
/*test_start*/
$sub_type = '';
if(isset($_post['submit_upload']))$sub_type = 'upload';
if(isset($_post['submit_delete']))$sub_type = 'delete';
if($sub_type){//echo '<script>alert("'.$sub_type.'");</script>';exit;
$data = array( 'sub_type' => $sub_type,
'file' => $_files['file'],
'img_tag_id' => 'picview',
'img_dir' => 'upload_img',
);
$imgpath = upload($data);
}else{
$imgpath = isset($_session['imgpath'])? $_session['imgpath']: '';
}
?>
<form action="ad.php" method="post" enctype="multipart/form-data" target="frame">
<input type="file" name="file" class="input">
<input type="submit" name="submit_upload" value="上 传">
<input type="submit" name="submit_delete" value="删 除">
<iframe id="frame" name="frame" width="0" height="0" marginwidth="0" frameborder="0" src="about:blank"></iframe>
</form>
<img id="picview" height="100" style="display:none;">
<script>
if("<?php echo $imgpath; ?>"){
parent.document.getelementbyid("picview").src = "<?php echo $imgpath; ?>";
parent.document.getelementbyid("picview").style.display = "block";
}
</script>
代码如下 | 复制代码 |
*/ //alipay.php代码 $url = $s22.$s14."?"; } pay.php页面 <?
$geturl = new alipay; <body> |
php 购物车是在电子商务网站会用到的,一种像超市购物车一样的,选好商品了,先放到自己的购物车里面等好了再到柜台结算,本款php购物车完全按照这个原理来实例的,下面我们来看看吧,利用了cookie来实现。
代码如下 | 复制代码 |
<?php |
相关文章
使用PHP+JavaScript将HTML页面转换为图片的实例分享
这篇文章主要介绍了使用PHP+JavaScript将HTML元素转换为图片的实例分享,文后结果的截图只能体现出替换的字体,也不能说将静态页面转为图片可以加快加载,只是这种做法比较interesting XD需要的朋友可以参考下...2016-04-19- php如何实现抓取网页图片,相较于手动的粘贴复制,使用小程序要方便快捷多了,喜欢编程的人总会喜欢制作一些简单有用的小软件,最近就参考了网上一个php抓取图片代码,封装了一个php远程抓取图片的类,测试了一下,效果还不错分享...2015-10-30
- 这篇文章主要介绍了C#从数据库读取图片并保存的方法,帮助大家更好的理解和使用c#,感兴趣的朋友可以了解下...2021-01-16
- 今天小编在这里就来给各位Photoshop的这一款软件的使用者们来说说把古装美女图片转为细腻的工笔画效果的制作教程,各位想知道方法的使用者们,那么下面就快来跟着小编一...2016-09-14
- 这篇文章主要介绍了Python 图片转数组,二进制互转操作,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧...2021-03-09
- 下面小编就为大家带来一篇利用JS实现点击按钮后图片自动切换的简单方法。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-10-25
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮
jquery左右滚动焦点图banner图片鼠标经过显示上下页按钮...2013-10-13- 这篇文章主要为大家详细介绍了js实现上传图片及时预览的相关资料,具有一定的参考价值,感兴趣的朋友可以参考一下...2016-05-09
- Photoshop的这一款软件小编相信很多的人都已经是使用过了吧,那么今天小编在这里就给大家带来了用Photoshop软件制作枪战电影海报的教程,想知道制作步骤的玩家们,那么下面...2016-09-14
- 图片剪裁是常用的方法,那么如何通过4坐标剪裁图片,本文就详细的来介绍一下,感兴趣的小伙伴们可以参考一下...2021-06-04
- 共享一段使用PHP下载CSS文件中的图片的代码 复制代码 代码如下: <?php //note 设置PHP超时时间 set_time_limit(0); //note 取得样式文件内容 $styleFileContent = file_get_contents('images/style.css'); //not...2013-10-04
- 这篇文章主要给大家介绍了关于微信小程序如何获取图片宽度与高度的相关资料,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-10
- PHP代码如下:复制代码 代码如下:if (isset($_FILES["Filedata"]) || !is_uploaded_file($_FILES["Filedata"]["tmp_name"]) || $_FILES["Filedata"]["error"] != 0) { $upload_file = $_FILES['Filedata']; $fil...2013-10-04
C#中图片旋转和翻转(RotateFlipType)用法分析
这篇文章主要介绍了C#中图片旋转和翻转(RotateFlipType)用法,实例分析了C#图片旋转及翻转Image.RotateFlip方法属性的常用设置技巧,需要的朋友可以参考下...2020-06-25- ps软件是现在很多人比较喜欢的,有着非常不错的使用效果,这次文章就给大家介绍下ps怎么制作图片阴影效果,还不知道制作方法的赶紧来看看。 ps图片阴影效果怎么做方法/...2017-07-06
- 这篇文章主要介绍了OpenCV如何去除图片中的阴影的实现,文中通过示例代码介绍的非常详细,对大家的学习或者工作具有一定的参考学习价值,需要的朋友们下面随着小编来一起学习学习吧...2021-03-29
- 这篇文章主要介绍了JavaScript 如何禁止用户保存图片,帮助大家完成需求,更好的理解和使用JavaScript,感兴趣的朋友可以了解下...2020-11-19
- 本文主要介绍用C#实现图片转换成字节流,字节流转换成图片,并根据图片路径返回图片的字节流,有需要的朋友可以参考下...2020-06-25
- 我们在php中上传文件就必须使用#_FILE变量了,这个自动全局变量 $_FILES 从 PHP 4.1.0 版本开始被支持。在这之前,从 4.0.0 版本开始,PHP 支持 $HTTP_POST_FILES 数组。这...2016-11-25
- 下面小编就为大家带来一篇JS实现图片的不间断连续滚动的简单实例。小编觉得挺不错的,现在就分享给大家,也给大家做个参考。一起跟随小编过来看看吧...2016-06-12