在朋友哪里能到的很简单的qq天气预报小偷程序,呵呵其实很简单啊!
<center>
<?php
$no = $_REQUEST['no'];
if ($no == '') $no = 125;
$f=file('http://weather.news.qq.com/inc/ss'.$no.'.htm');//改一下这网址
foreach ($f as $line_num => $line) {
//echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br />n";
}
$fee = strip_tags("$f[13] $f[14] $f[18] $f[24] $f[30] $f[35]");
$fe = explode(" ","$fee");
//echo str_replace("n",'',$fee);
?>
<style type="text/css">
body,table{font-size:12px;line-height:150%;}
A.color4:link {COLOR: #DD7D02;TEXT-DECORATION: none}
A.color4:visited { COLOR: #DD7D02;TEXT-DECORATION: none}
A.color4:active { COLOR: #DD7D02;TEXT-DECORATION: underline}
A.color4:hover { COLOR: #DD7D02;TEXT-DECORATION: underline}
</style>
<?=$fe[0];?> <?=$fe[1];?> <?=$fe[2];?>
<script>
function getredirects(v) {
if (v=='') v=123;
window.location.href='/index/weather.php?no='+v;
}
</script>
<select name="select" id="obSelect" onChange="getredirects(this.value)">
<option <? if($no==125){ print 'selected="selected"';} ?> value="125">北京</option>
<option <? if($no==292){ print 'selected="selected"';} ?> value="292">广州</option>
<option <? if($no==252){ print 'selected="selected"';} ?> value="252">上海</option>
<option <? if($no==127){ print 'selected="selected"';} ?> value="127">天津</option>
<option <? if($no==212){ print 'selected="selected"';} ?> value="212">重庆</option>
<option <? if($no==115){ print 'selected="selected"';} ?> value="115">沈阳</option>
<option <? if($no==244){ print 'selected="selected"';} ?> value="244">南京</option>
<option <? if($no==211){ print 'selected="selected"';} ?> value="211">武汉</option>
<option <? if($no==166){ print 'selected="selected"';} ?> value="166">成都</option>
<option <? if($no==186){ print 'selected="selected"';} ?> value="186">西安</option>
<option <? if($no==82){ print 'selected="selected"';} ?> value="82">石家庄</option>
<option <? if($no==84){ print 'selected="selected"';} ?> value="84">太原</option>
<option <? if($no==189){ print 'selected="selected"';} ?> value="189">郑州</option>
<option <? if($no==103){ print 'selected="selected"';} ?> value="103">长春</option>
<option <? if($no==17){ print 'selected="selected"';} ?> value="17">哈尔滨</option>
<option <? if($no==69){ print 'selected="selected"';} ?> value="69">呼和浩特</option>
<option <? if($no==140){ print 'selected="selected"';} ?> value="140">济南</option>
<option <? if($no==248){ print 'selected="selected"';} ?> value="248">合肥</option>
<option <? if($no==255){ print 'selected="selected"';} ?> value="255">杭州</option>
<option <? if($no==276){ print 'selected="selected"';} ?> value="276">福州</option>
<option <? if($no==287){ print 'selected="selected"';} ?> value="287">厦门</option>
<option <? if($no==218){ print 'selected="selected"';} ?> value="218">长沙</option>
<option <? if($no==296){ print 'selected="selected"';} ?> value="296">深圳</option>
<option <? if($no==295){ print 'selected="selected"';} ?> value="295">南宁</option>
<option <? if($no==232){ print 'selected="selected"';} ?> value="232">桂林</option>
<option <? if($no==264){ print 'selected="selected"';} ?> value="264">南昌</option>
<option <? if($no==227){ print 'selected="selected"';} ?> value="227">贵阳</option>
<option <? if($no==1){ print 'selected="selected"';} ?> value="1">香港</option>
<option <? if($no==2){ print 'selected="selected"';} ?> value="2">澳门</option>
<option <? if($no==179){ print 'selected="selected"';} ?> value="179">昆明</option>
<option <? if($no==280){ print 'selected="selected"';} ?> value="280">台北</option>
<option <? if($no==150){ print 'selected="selected"';} ?> value="150">拉萨</option>
<option <? if($no==303){ print 'selected="selected"';} ?> value="303">海口</option>
<option <? if($no==57){ print 'selected="selected"';} ?> value="57">兰州</option>
<option <? if($no==78){ print 'selected="selected"';} ?> value="78">银川</option>
<option <? if($no==56){ print 'selected="selected"';} ?> value="56">西宁</option>
<option <? if($no==28){ print 'selected="selected"';} ?> value="28">乌鲁木齐</option>
</select>
<script>
var o=document.getElementById('obSelect');
if (v!= '') o.value=v;
</script>
市
</center>
php读取文件夹里面内容的简单源代码,上篇文章(http://www.viatop.cn/blog/show-166-1.htm)里面的那些文件名都是用这个读出来的.不过可能有些慢吧.
PHP代码
- <?php
-
-
- if ($handle = opendir('./regedit')) {
- echo "Directory handle: $handle\n";
- echo "Files:\n";
-
-
- while (false !== ($file = readdir($handle))) {
- echo "$file"."<br>";
- }
-
- closedir($handle);
- }
- ?>
要轮换的图片的位置先插入图片,文中的"$img1"等是我自己用的php变量,就是图片的网址.
XML/HTML代码
- <a id="javascript.a" href="#"><img id="javascript.img" style="FILTER: blendTrans(duration=2)" height="348" src="upfiles/<?=$img1?>" width="592" border="0" /></a>
然后在下面插入以下javascript代码.
JavaScript代码
- <script>
- <!--
- var ImgSrc = new Array();
- ImgSrc[0] = "upfiles/<?=$img1?>"
- ImgSrc[1] = "upfiles/<?=$img2?>"
- ImgSrc[2] = "upfiles/<?=$img3?>"
- ImgSrc[3] = "upfiles/<?=$img4?>"
-
-
- for (var i=0;i<ImgSrc.length;i++){(new Image()).src = ImgSrc[i];}
-
- var ImgAlt = new Array();
- ImgAlt[0] = "main photo"
- ImgAlt[1] = "main photo"
- ImgAlt[2] = "main photo"
- ImgAlt[3] = "main photo"
-
- var ImgHerf = new Array();
- ImgHerf[0] = "#"
- ImgHerf[1] = "#"
- ImgHerf[2] = "#"
- ImgHerf[3] = "#"
-
- var step=0;
- function slideit(){
- var oImg = document.getElementById("javascript.img");
- if (document.all){oImg.filters.blendTrans.apply();}
- oImg.src=ImgSrc[step];
- document.getElementById("javascript.a").href=ImgHerf[step];
- oImg.title=ImgAlt[step];
- if (document.all){oImg.filters.blendTrans.play();}
- step = (step<(ImgSrc.length-1))?(step+1):0;
- (new Image()).src = ImgSrc[step];
- }
- setInterval("slideit()",3000);
-
- </script>
经测试,在IE7和firefox下都可以显示效果,不过两者的效果有些区别.
之前有发过一篇文章,那是写的三个小函数,今天见到极其简单的.
PHP代码
-
- $extendname = array_pop(explode ( ".",$filename));
-
-
- $extendname = end(explode(".", $filename));
-
-
- $file_part = pathinfo($filename);
- $extendname = $file_part["extension"];
效果不错的图片轮换滚动,平滑滚动,可以自己设置图片大小,给图片加链接,说明.
效果见http://www.thefurniturespot.ca/.
XML/HTML代码
- <div id="top_pic" style="width:592px; height:348px; padding:0px; margin:0px; border:0px;" >
- <script>
- var NowFrame = 1;
- var MaxFrame = 4;
- var bStart = 0;
- function fnToggle() {
- var next = NowFrame + 1;
- if(next == MaxFrame+1)
- {
-
- NowFrame = MaxFrame;
- next = 1;
- }
- if(bStart == 0)
-
- {
- bStart = 1;
-
- setTimeout('fnToggle()', 1000);
- return;
- }
- else
- {
- oTransContainer.filters[0].Apply();
- document.images['oDIV'+next].style.display = "";
- document.images['oDIV'+NowFrame].style.display = "none";
- oTransContainer.filters[0].Play(duration=2);
- if(NowFrame == MaxFrame)
- NowFrame = 1;
- else
- NowFrame++;
- } setTimeout('fnToggle()', 4000);
- }
- fnToggle();
- </script>
- <div id=oTransContainer style="FILTER: progid:DXImageTransform.Microsoft.Wipe(GradientSize=1.0, wipeStyle=0, motion='forward');HEIGHT: 348px; WIDTH: 592px ">
- <a href="javascript:;"><IMG id=oDIV1 style="DISPLAY: none;" src="upfiles/<?=$row['img1']?>" height=348 width=592 border=0 alt="main photo"></A>
- <a href="javascript:;"><img id=oDIV2 style="DISPLAY: none;" src="upfiles/<?=$row['img2']?>" height=348 width=592 border=0 alt="main photo"></a>
- <a href="javascript:;"><img id=oDIV3 style="DISPLAY: none;" src="upfiles/<?=$row['img3']?>" height=348 width=592 border=0 alt="main photo"></a>
- <a href="javascript:;"><img id=oDIV4 style="DISPLAY: none;" src="upfiles/<?=$row['img4']?>" height=348 width=592 border=0 alt="main photo"></a>
-
- </div>
- </div>
刚用的时候因为php自带的函数大小写错误,所以不能使用,后来修改一下,可以使用.经测试在php5,apache下可以正常使用.
$srcFile,$toW,$toH,$toFile 四个参数就是,源文件,宽,高,输出文件.
PHP代码
- function ImageResize($srcFile,$toW,$toH,$toFile="")
- {
- if($toFile==""){ $toFile = $srcFile; }
- $info = "";
- $data = getimagesize($srcFile,$info);
- switch ($data[2])
- {
- case 1:
- if(!function_exists("imagecreatefromgif")){
- echo "你的GD库不能使用GIF格式的图片,请使用Jpeg或PNG格式!<a href='java script:go(-1);'>返回</a>";
- exit();
- }
- $im = imagecreatefromgif($srcFile);
- break;
- case 2:
- if(!function_exists("imagecreatefromjpeg")){
- echo "你的GD库不能使用jpeg格式的图片,请使用其它格式的图片!<a href='java script:go(-1);'>返回</a>";
- exit();
- }
- $im = imagecreatefromjpeg($srcFile);
- break;
- case 3:
- $im = imagecreatefrompng($srcFile);
- break;
- }
- $srcW=imagesx($im);
- $srcH=imagesy($im);
- $toWH=$toW/$toH;
- $srcWH=$srcW/$srcH;
- if($toWH<=$srcWH){
- $ftoW=$toW;
- $ftoH=$ftoW*($srcH/$srcW);
- }
- else{
- $ftoH=$toH;
- $ftoW=$ftoH*($srcW/$srcH);
- }
- if($srcW>$toW||$srcH>$toH)
- {
- if(function_exists("imagecreatetruecolor")){
- $ni = imagecreatetruecolor($ftoW,$ftoH);
- if($ni) {
- imagecopyresampled($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
- }
- else{
- $ni=imagecreate($ftoW,$ftoH);
- imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
- }
- }else{
- $ni=imagecreate($ftoW,$ftoH);
- imagecopyresized($ni,$im,0,0,0,0,$ftoW,$ftoH,$srcW,$srcH);
- }
- if(function_exists('imagejpeg')) imagejpeg($ni,$toFile);
- else imagepng($ni,$toFile);
- imagedestroy($ni);
- }
- imagedestroy($im);
- }
看到有人用的php上传处理代码,我主要用来处理上传图片了.使用的时候很简单,比如有一个name=“thumb”的文件域,上传的时候这样处理就可以了。
$image1 = get_fileform("thumb", $image1_name, $image1_type, $image1_size);
if($image1) $thumb=upfile1($code,$image1,$image1_name);
$thumb就是上传之后的相对url地址。比较简单。
upfile1()函数是上传文件的,里面可以设定文件命名的规则和要上传到的目录,可以很好的修改.
PHP代码
-
- function upload_file_name_ck($uploadfilename){
- if(eregi("\.php|\.php3|\.html|\.htm|\.phtml|\.com|\.bat|\.exe|\.inc|\.js|\.ph|\.asp|\.jsp|\.cgi|\.pl",$uploadfilename)){
- msg_back('上传文件格式不正确.');
- }
- else $check='2';
- return($check);
- }
- function samefile_chk($file_name, $updir) {
- while($file_name and file_exists("$updir/$file_name")) {
- $temp = explode(".", $file_name);
- $temp[0] = $temp[0] . "1";
- $file_name = implode(".", $temp) ;
- }
- return $file_name;
- }
- function get_fileform($image, $image_name, $image_type, $image_size, $arr = "default")
- {
- if($arr != "default"){
- if(isset($_FILES[$image]['name'][$arr])){
- $image_name = $_FILES[$image]['name'][$arr];
- }else{$image_name = NULL;}
-
- if(isset($_FILES[$image]['size'][$arr])){
- $image_size = $_FILES[$image]['size'][$arr];
- }else{$image_size = 0;}
-
- if(isset($_FILES[$image]['type'][$arr])){
- $image_type = $_FILES[$image]['type'][$arr];
- }else{$image_type = NULL;}
-
- if(isset($_FILES[$image]['tmp_name'][$arr])){
- return $_FILES[$image]['tmp_name'][$arr];
- }
- return NULL;
- }
- else{
- if(isset($_FILES[$image]['name'])){
- $image_name = $_FILES[$image]['name'];
- }else{$image_name = NULL;}
-
- if(isset($_FILES[$image]['size'])){
- $image_size = $_FILES[$image]['size'];
- }else{$image_size = 0;}
-
- if(isset($_FILES[$image]['type'])){
- $image_type = $_FILES[$image]['type'];
- }else{$image_type = NULL;}
-
- if(isset($_FILES[$image]['tmp_name'])){
- return $_FILES[$image]['tmp_name'];
- }
- return NULL;
- }
- }
-
- function upfile1 ($code,$myfile,$myfile_name)
- {
- $new_id = date("ymdhi",time());
- $check=upload_file_name_ck($myfile_name);
- if($check!='2')exit;
- $datadir='../upfiles/';
- $t=explode(".", $myfile_name);
- $t[0]=$new_id."_".$t[0];
- $filename = implode(".", $t) ;
- $filename=samefile_chk($filename,$datadir);
- $filename=$code.'/'.$filename;
-
- $dest = $datadir.$filename;
- if(!move_uploaded_file($myfile,$dest)) {
- msg_back("Upload Error");
- exit;
- }
- return ($filename);
- }
分页程序,用的时候很简单,用一下的代码,然后在要显示分页的地方用<?=$pagerstring?>就可以了.三种页码显示样式.
循环输出$result就可以了.使用时:
<?
-
- $page = isset($_REQUEST['page'])?$_REQUEST['page']:1;
- $numperpage=10;
- $start = ($page-1)*$numperpage;
- $where = ...;
- $query = "SELECT id FROM bh_articles WHERE $where ";
- $query_result = mysql_query($query);
- $total_records = @mysql_num_rows($query_result);
- $pagerstring = pager($total_records, $numperpage, '?', $page);
- $limit=$start.",".$numperpage;
- $query = "SELECT id, title, summary, timestamp FROM bh_articles WHERE $where ORDER BY timestamp DESC limit $limit";
- $result = $db->query($query);
?>
PHP代码
-
-
- function pager($numrecord, $pagesize, $pagename='?', $page){
-
- $querystring = $pagename;
- if (isset($_GET)) {
- foreach ($_GET as $key=>$val) {
- $val = urlencode($val);
- if ($key != 'page') {
- $querystring .= $key."=$val&";
- }
- }
- }
-
- $numpage = ceil($numrecord/$pagesize);
- $pagerstring = "总计 <b>$numrecord</b> 条 分 <b>$numpage</b> 页显示 当前第<b>$page</b>页";
-
- if ($page>1)
- $pagerstring .= " <a href={$querystring}page=1 class=pager>首页</a> ";
- else
- $pagerstring .= " 首页 ";
-
- if ($page>1)
- $pagerstring .= " <a href={$querystring}page=".($page-1)." class=pager>上一页</a> ";
- else
- $pagerstring .= " 上一页 ";
-
- if ($page<$numpage)
- $pagerstring .= " <a href={$querystring}page=".($page+1)." class=pager>下一页</a> ";
- else
- $pagerstring .= " 下一页 ";
-
- if ($page<$numpage)
- $pagerstring .= " <a href={$querystring}page=$numpage class=pager>末页</a> ";
- else
- $pagerstring .= " 末页 ";
-
- $pagerstring .= "跳转至第<select name\"=page\" onchange=\"window.location.href='{$querystring}page='+this.value\">";
- for ($i=1; $i<=$numpage; $i++){
- $pagerstring .= "<option value=$i ";
- if ($page == $i)
- $pagerstring .= "selected";
- $pagerstring .= ">$i</option>\n";
- }
- $pagerstring .= "</select>页";
-
- return $pagerstring;
- }
输出结果为:
总计 7 条 分 1 页显示 当前第1页 | [首页] [上一页] [下一页] [末页] 跳转至第
页
PHP代码
- function pager2($numrecord, $pagesize, $pagename='?', $page){
-
- $querystring = $pagename;
- if (isset($_GET)) {
- foreach ($_GET as $key=>$val) {
- $val = urlencode($val);
- if ($key != 'page') {
- $querystring .= $key."=$val&";
- }
- }
- }
-
- $numpage = ceil($numrecord/$pagesize);
-
- $pagerstring = '';
- if ($page>1)
- $pagerstring .= " <span class=\"pager2\" style=\"background-color:#FF6500\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=1\"><span class=\"f8black2\"><<</span>第一页</a></span> ";
-
- if ($page>1)
- $pagerstring .= " <span class=\"pager2\" style=\"background-color:#FF6500\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=".($page-1)."\"><span class=\"f8black2\"><<</span>上一页</a></span> ";
- if ($page<4){
- $first = 1;
- }else{
- $first = $page-3;
- }
- if ($first+4>$numpage)
- $last = $numpage;
- else
- $last = $first+4;
-
- for ($i=$first; $i<=$last; $i++){
- if ($i==$page){
- $color='#F7AE08';
- $style='color:#000000';
- }else{
- $color='#FF6500';
- $style='';
- }
- $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='$color'\"><a href=\"{$querystring}page=$i\" style=\"$style\">$i</a></span> ";
- }
- if ($page<$numpage)
- $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=".($page+1)."\">下一页<span class=\"f8black2\">>></span></a></span> ";
-
- if ($page<$numpage)
- $pagerstring .= " <span class=\"pager2\" style=\"background-color:$color\" onmouseover=\"this.style.background='#F7AE08'\" onmouseout=\"this.style.background='#FF6500'\"><a href=\"{$querystring}page=$numpage\">末页<span class=\"f8black2\">>></span></a></span> ";
- return $pagerstring;
- }
输出结果为: 第一页 上一页 下一页 末页
PHP代码
- function pager3($numrecord, $pagesize, $pagename='?', $page){
-
- $querystring = $pagename;
- if (isset($_GET)) {
- foreach ($_GET as $key=>$val) {
- $val = urlencode($val);
- if ($key != 'page') {
- $querystring .= $key."=$val&";
- }
- }
- }
-
- $numpage = ceil($numrecord/$pagesize);
-
- $pagerstring = '';
-
- if ($page>1)
- $pagerstring .= " <span class=\"pager3\"><a href=\"{$querystring}page=".($page-1)."\">前一页</a></span> ";
-
- $first = max((floor($page/5)-1)*5+1, 1);
- $last = min($first+5, $numpage);
-
- for ($i=$first; $i<=$last; $i++){
- if ($i==$page){
- $pagerstring .= " <b>$i</b></a> ";
- }else{
- $pagerstring .= " <span class=\"page3\"><a href=\"{$querystring}page=$i\">$i</a></span> ";
- }
- }
-
- if ($page<$numpage)
- $pagerstring .= " <span class=\"pager3\"><a href=\"{$querystring}page=".($page+1)."\">后一页</a></span> ";
-
- return $pagerstring;
- }
输出结果为: 前一页 后一页.