筛选出来的常用jQuery幻灯片插件

s3Slider(Demo)

本款插件是我在朋友的网站上看到的,当时就感觉十分好用

coin-slider 页面上也有演示

这款幻灯片插件感觉好酷啊,看着很简单,却觉那么得体适当,我一眼就喜欢上了

jQuery Easy Slides

话说使用最简单,一眼看上去,与s3Slider有点像,就收下了,我喜欢这种简单的

 Nivo Slider

号称”the most awesome”,大家可以试试看

其它的总结jquery插件的网址如下:

14个基于jQuery的图片展示和幻灯片插件

15个幻灯片效果的JQuery插件

15款jQuery幻灯片插件

十个jQuery图片画廊插件推荐

2010年十佳jquery插件

 

 

PHP-浏览器参数防注入检测函数

 对浏览器的URL的字段进行过滤,防止进行SQL注入

function inject_check($sql_str) {
   $check=eregi('select|insert|update|delete|\'|\/\*|\*|\.\.\/|\.\/|union|into|load_file|outfile', $sql_str);     // 进行过滤
   if($check){
       echo "你输入了非法内容!";
       exit();
   } else {
       return $sql_str;
   }
}

 

 

 

 



PHP从checkbox取值

在用到checkbox的时候发现php只能取一个值,查了相关资料,原因如下:

Php代码

<input type="checkbox" name="weeks[]" id="weeks" value=1>  
<input type="checkbox" name="weeks[]" id="weeks" value=2>  
<input type="checkbox" name="weeks[]" id="weeks" value=3>

 

weeks后的中括号不可漏,否则用PHP获取的时候只能取到最后一个值。之后PHP就很好处理了,如下:

Php代码
方法一:  
$weeks = $_POST['weeks'];  
for($i=0;$i<count($weeks);$i++)  
echo $weeks[$i]."<br>";   
  
方法二:  
$array = $this->request->getParameter("weeks[]");  
$str =implode(',',$array);  
echo $str;

 

 

毕业设计出现的一个严重错误—-文件不能相互引用

 昨晚大概1点,突然点某几个链接,出现了“你指定的网站不能访问,链接错误”这样的情况,然点击其它的网页却没有错误,一段时间极度郁闷,知道1点半没弄出来

今天下午经过一番删除测试,终于发现了错因:

解决突然不能访问,说指定的网站不存在的问题的解决方法
1、 发现paike表中注释掉xuanke类的引用后,排课正常
2、 由1可以知道,paike表没有问题,xuanke表有问题
3、 猜测原因:两个类文件相互引用,造成了引用的死循环
 
错误原因已经出来了,就是两个文件如果相互引用的话,就会造成引用的死循环,使得程序崩溃

php函数-计算两个日期相差多少天

<?PHP 

/*
*
*函数功能:计算两个以YYYY-MM-DD为格式的日期,相差几天
*
*/
function getChaBetweenTwoDate($date1,$date2){

    $Date_List_a1=explode("-",$date1);
    $Date_List_a2=explode("-",$date2); 

    $d1=mktime(0,0,0,$Date_List_a1[1],$Date_List_a1[2],$Date_List_a1[0]); 

    $d2=mktime(0,0,0,$Date_List_a2[1],$Date_List_a2[2],$Date_List_a2[0]); 

    $Days=round(($d1-$d2)/3600/24); 

    return $Days;
}

echo getChaBetweenTwoDate('2010-08-11','2010-08-16');
echo "<br>";
echo getChaBetweenTwoDate('2010-08-16','2010-08-11');
?>

 

Apache禁止目录访问方法介绍

本文原文出处http://www.leapsoul.cn/?p=453

在 PHP网站开发中,基于WEB服务器和PHP网站程序代码的安全考虑,我们需要对相关的目录或者文件访问权限进行控制,以防止意外情况的发生,那么我们如 何来实现这种功能呢?我们可以通过Apache来实现禁止目录访问(禁止游览列出的目录或文件列表)、禁止或允许IP与域名访问目录的功能。

环境说明

  我使用的是DedeCMS DedeAmpz的PHP运行环境,PHP版本5.2.4,Apache版本2.2.4 继续阅读Apache禁止目录访问方法介绍

PHP操作EXCEL相关

phpExcel,操作excel很方便,尤其是可以方便的加入图片,支持jpg gif png格式。

下载地址:http://www.codeplex.com/PHPExcel

下面是总结的几个使用方法

include ‘PHPExcel.php’;
include ‘PHPExcel/Writer/Excel2007.php’;
//或者include ‘PHPExcel/Writer/Excel5.php’; 用于输出.xls的
创建一个excel
$objPHPExcel = new PHPExcel();
保存excel—2007格式
$objWriter = new PHPExcel_Writer_Excel2007($objPHPExcel);
//或者$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel); 非2007格式
$objWriter->save(”xxx.xlsx”);
直接输出到浏览器
$objWriter = new PHPExcel_Writer_Excel5($objPHPExcel);
header(”Pragma: public”);
header(”Expires: 0″);
header(”Cache-Control:must-revalidate, post-check=0, pre-check=0″);
header(”Content-Type:application/force-download”);
header(”Content-Type:application/vnd.ms-execl”);
header(”Content-Type:application/octet-stream”);
header(”Content-Type:application/download”);;
header(’Content-Disposition:attachment;filename=”resume.xls”‘);
header(”Content-Transfer-Encoding:binary”);
$objWriter->save(’php://output’);
——————————————————————————————————————–
设置excel的属性:
创建人
$objPHPExcel->getProperties()->setCreator(”Maarten Balliauw”);
最后修改人
$objPHPExcel->getProperties()->setLastModifiedBy(”Maarten Balliauw”);
标题
$objPHPExcel->getProperties()->setTitle(”Office 2007 XLSX Test Document”);
题目
$objPHPExcel->getProperties()->setSubject(”Office 2007 XLSX Test Document”);
描述
$objPHPExcel->getProperties()->setDescription(”Test document for Office 2007 XLSX, generated using PHP classes.”);
关键字
$objPHPExcel->getProperties()->setKeywords(”office 2007 openxml php”);
种类
$objPHPExcel->getProperties()->setCategory(”Test result file”);
——————————————————————————————————————–
设置当前的sheet
$objPHPExcel->setActiveSheetIndex(0);
设置sheet的name
$objPHPExcel->getActiveSheet()->setTitle(’Simple’);
设置单元格的值
$objPHPExcel->getActiveSheet()->setCellValue(’A1′, ‘String’);
$objPHPExcel->getActiveSheet()->setCellValue(’A2′, 12);
$objPHPExcel->getActiveSheet()->setCellValue(’A3′, true);
$objPHPExcel->getActiveSheet()->setCellValue(’C5′, ‘=SUM(C2:C4)’);
$objPHPExcel->getActiveSheet()->setCellValue(’B8′, ‘=MIN(B2:C5)’);
合并单元格
$objPHPExcel->getActiveSheet()->mergeCells(’A18:E22′);
分离单元格
$objPHPExcel->getActiveSheet()->unmergeCells(’A28:B28′);
保护cell
$objPHPExcel->getActiveSheet()->getProtection()->setSheet(true); // Needs to be set to true in order to enable any worksheet protection!
$objPHPExcel->getActiveSheet()->protectCells(’A3:E13′, ‘PHPExcel’);
设置格式
// Set cell number formats
echo date(’H:i:s’) . ” Set cell number formats\n”;
$objPHPExcel->getActiveSheet()->getStyle(’E4′)->getNumberFormat()->setFormatCode(PHPExcel_Style_NumberFormat::FORMAT_CURRENCY_EUR_SIMPLE);
$objPHPExcel->getActiveSheet()->duplicateStyle( $objPHPExcel->getActiveSheet()->getStyle(’E4′), ‘E5:E13′ );
设置宽width
// Set column widths
$objPHPExcel->getActiveSheet()->getColumnDimension(’B’)->setAutoSize(true);
$objPHPExcel->getActiveSheet()->getColumnDimension(’D’)->setWidth(12);
设置font
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFont()->setName(’Candara’);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFont()->setSize(20);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFont()->setUnderline(PHPExcel_Style_Font::UNDERLINE_SINGLE);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$objPHPExcel->getActiveSheet()->getStyle(’E1′)->getFont()->getColor()->setARGB(PHPExcel_Style_Color::COLOR_WHITE);
$objPHPExcel->getActiveSheet()->getStyle(’D13′)->getFont()->setBold(true);
$objPHPExcel->getActiveSheet()->getStyle(’E13′)->getFont()->setBold(true);
设置align
$objPHPExcel->getActiveSheet()->getStyle(’D11′)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle(’D12′)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle(’D13′)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_RIGHT);
$objPHPExcel->getActiveSheet()->getStyle(’A18′)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_JUSTIFY);
//垂直居中
$objPHPExcel->getActiveSheet()->getStyle(’A18′)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
设置column的border
$objPHPExcel->getActiveSheet()->getStyle(’A4′)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle(’B4′)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle(’C4′)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle(’D4′)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
$objPHPExcel->getActiveSheet()->getStyle(’E4′)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN);
设置border的color
$objPHPExcel->getActiveSheet()->getStyle(’D13′)->getBorders()->getLeft()->getColor()->setARGB(’FF993300′);
$objPHPExcel->getActiveSheet()->getStyle(’D13′)->getBorders()->getTop()->getColor()->setARGB(’FF993300′);
$objPHPExcel->getActiveSheet()->getStyle(’D13′)->getBorders()->getBottom()->getColor()->setARGB(’FF993300′);
$objPHPExcel->getActiveSheet()->getStyle(’E13′)->getBorders()->getTop()->getColor()->setARGB(’FF993300′);
$objPHPExcel->getActiveSheet()->getStyle(’E13′)->getBorders()->getBottom()->getColor()->setARGB(’FF993300′);
$objPHPExcel->getActiveSheet()->getStyle(’E13′)->getBorders()->getRight()->getColor()->setARGB(’FF993300′);
设置填充颜色
$objPHPExcel->getActiveSheet()->getStyle(’A1′)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle(’A1′)->getFill()->getStartColor()->setARGB(’FF808080′);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_SOLID);
$objPHPExcel->getActiveSheet()->getStyle(’B1′)->getFill()->getStartColor()->setARGB(’FF808080′);
加图片
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName(’Logo’);
$objDrawing->setDescription(’Logo’);
$objDrawing->setPath(’./images/officelogo.jpg’);
$objDrawing->setHeight(36);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
$objDrawing = new PHPExcel_Worksheet_Drawing();
$objDrawing->setName(’Paid’);
$objDrawing->setDescription(’Paid’);
$objDrawing->setPath(’./images/paid.png’);
$objDrawing->setCoordinates(’B15′);
$objDrawing->setOffsetX(110);
$objDrawing->setRotation(25);
$objDrawing->getShadow()->setVisible(true);
$objDrawing->getShadow()->setDirection(45);
$objDrawing->setWorksheet($objPHPExcel->getActiveSheet());
在默认sheet后,创建一个worksheet
echo date(’H:i:s’) . ” Create new Worksheet object\n”;
$objPHPExcel->createSheet();

 

PHPEXCEL是一个国外的站点,地址:http://phpexcel.codeplex.com/

phpexcel-自己写的几个非常好用的函数

 在写一个用到PHPEXCEL的程序时,发现总是得去找相关的PHPEXCEL操作的代码复制过来,下次再找,影响了速度不说,打乱了原来的程序思路,于是干脆把常用操作写成了函数,函数名简单易记,这样就不用考虑PHPEXCEL的相关问题了,更容易回到原来的程序开发思路上,顺风顺雨,一路帆风,其实应该自己整理成一个类的,这样更好用了

$objExcel->setActiveSheetIndex(0);
$objActSheet = $objExcel->getActiveSheet(); 

//函数:设置border
function setBorder($index){
    global $objActSheet;
    $objActSheet->getStyle($index)->getBorders()->getTop()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
    $objActSheet->getStyle($index)->getBorders()->getLeft()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
    $objActSheet->getStyle($index)->getBorders()->getRight()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
    $objActSheet->getStyle($index)->getBorders()->getBottom()->setBorderStyle(PHPExcel_Style_Border::BORDER_THIN );
    $objActSheet->getStyle($index)->getAlignment()->setHorizontal(PHPExcel_Style_Alignment::HORIZONTAL_CENTER);
    $objActSheet->getStyle($index)->getAlignment()->setVertical(PHPExcel_Style_Alignment::VERTICAL_CENTER);
    $objActSheet->getStyle($index)->getAlignment()->setWrapText(true);
}

//设置宽度
function setWidth($index,$width=5){
    global $objActSheet;
    $objActSheet->getColumnDimension(gbkToUtf8($index))->setWidth($width);
}

//设置背景
function setBg($index){
    global $objActSheet;
    $objActSheet->getStyle($index)->getFill()->setFillType(PHPExcel_Style_Fill::FILL_PATTERN_DARKUP);
    $objActSheet->getStyle($index)->getFill()->getStartColor()->setARGB('FFFFFFFF' );
}

//设置值
function setValue($index,$value){
    global $objActSheet;
    $objActSheet->setCellValue($index,gbkToUtf8($value) );
}

//合并单元格
function mergeCell($fc,$lc){
    global $objActSheet;
    $objActSheet->mergeCells($fc.":".$lc);
}

 



 

Fckeditor-动态增减按钮的方法

在使用fckeditor 的过程中,经常需要根据实际需要来设置工具栏,显示或隐藏工具栏上的部分按钮。

在默认情况下,fckeditor显示了全部的工具栏。在fckconfig.js中有两个工具栏的配置方案,一个是Default,一个是Basic。我们可以按照他的格式自定义几个选项。

FCKConfig.ToolbarSets["c1"] = [
 ['Source','DocProps','-','Save','NewPage','Preview','-','Templates'],
 ['Cut','Copy','Paste','PasteText','PasteWord','-','Print','SpellCheck'],
 ['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
 '/',
 ['Bold','Italic','Underline','StrikeThrough','-','Subscript','Superscript'],
 ['JustifyLeft','JustifyCenter','JustifyRight','JustifyFull'],
 ['Link','Unlink','Anchor'],
 '/',
 ['Style','FontFormat','FontName','FontSize'],
 ['TextColor','BGColor'],
 ['FitWindow','ShowBlocks','-','About']  // No comma for the last row.
] ;

 



在页面中使用fckeditor时可以写成这样

var oFCKeditor = new FCKeditor( 'FCKeditor1' ) ;
oFCKeditor.ToolbarSet="c1";

 



 

PHP验证码-类

 原文地址:http://www.windsfly.cn/blog/article.asp?id=1013

1、验证码类文件 CreateImg.class.php

<?php
/**
* @version 1.0
* @author   Ben
* @date 2008-1-30
* @email jinmaodao116@163.com
* @验证码文件类
* int function imagecolorallocate(resource image, int red, int green, int blue) //为一幅图像分配颜色
* bool function imagefilledrectangle(resource image, int x1, int y1, int x2, int y2, int color) //画一矩形并填充
* bool function imagerectangle(resource image, int x1, int y1, int x2, int y2, int col)   //画一个矩形
* bool function imagesetpixel(resource image, int x, int y, int color)   //画一个单一像素
*/
class ValidationCode
{
private $width,$height,$codenum;
public $checkcode;     //产生的验证码
private $checkimage;    //验证码图片
private $disturbColor = ''; //干扰像素
/*
* 参数:(宽度,高度,字符个数)
*/
function __construct($width='80',$height='20',$codenum='4')
{
   $this->width=$width;
   $this->height=$height;
   $this->codenum=$codenum;
}
function outImg()
{
   //输出头
   $this->outFileHeader();
   //产生验证码
   $this->createCode();

   //产生图片
   $this->createImage();
   //设置干扰像素
   $this->setDisturbColor();
   //往图片上写验证码
   $this->writeCheckCodeToImage();
   imagepng($this->checkimage);
   imagedestroy($this->checkimage);
}
/*
   * @brief 输出头
   */
private function outFileHeader()
{
   header ("Content-type: image/png");
}
/**
   * 产生验证码
   */
private function createCode()
{
   $this->checkcode = strtoupper(substr(md5(rand()),0,$this->codenum));
}
/**
   * 产生验证码图片
   */
private function createImage()
{
   $this->checkimage = @imagecreate($this->width,$this->height);
   $back = imagecolorallocate($this->checkimage,255,255,255);
   $border = imagecolorallocate($this->checkimage,0,0,0);
   imagefilledrectangle($this->checkimage,0,0,$this->width - 1,$this->height - 1,$back); // 白色底
   imagerectangle($this->checkimage,0,0,$this->width - 1,$this->height - 1,$border);   // 黑色边框
}
/**
   * 设置图片的干扰像素
   */
private function setDisturbColor()
{
   for ($i=0;$i<=200;$i++)
   {
    $this->disturbColor = imagecolorallocate($this->checkimage, rand(0,255), rand(0,255), rand(0,255));
    imagesetpixel($this->checkimage,rand(2,128),rand(2,38),$this->disturbColor);
   }
}
/**
   *
   * 在验证码图片上逐个画上验证码
   *
   */
private function writeCheckCodeToImage()
{
   for ($i=0;$i<=$this->codenum;$i++)
   {
    $bg_color = imagecolorallocate ($this->checkimage, rand(0,255), rand(0,128), rand(0,255));
    $x = floor($this->width/$this->codenum)*$i;
    $y = rand(0,$this->height-15);
    imagechar ($this->checkimage, rand(5,8), $x, $y, $this->checkcode[$i], $bg_color);
   }
}
function __destruct()
{
   unset($this->width,$this->height,$this->codenum);
}
}
?>