PHP二维码添加logo的方法

PHP二维码添加logo的方法

    public function createqcode($text,$id){
        include '/phpqrcode/phpqrcode.php';

        $level = "L";
        //二维码图片每个黑点的像素,默认4
        $size = '10';
        //二维码边框的间距,默认2
        $padding = 2;
        $path=__DIR__.'/../../../Public/images/qcode/'.$id.'.jpg';
        //生成二维码图片
        \QRcode::png($text , $path , $level , $size , $padding , true);


        $logo = __DIR__.'/../../../Public/images/logo.png';//准备好的logo图片
        $QR = $path;//已经生成的原始二维码图
        $QR = imagecreatefromstring(file_get_contents($QR));
        $logo = imagecreatefromstring(file_get_contents($logo));
        $QR_width = imagesx($QR);//二维码图片宽度
        $QR_height = imagesy($QR);//二维码图片高度
        $logo_width = imagesx($logo);//logo图片宽度
        $logo_height = imagesy($logo);//logo图片高度
        $logo_qr_width = $QR_width / 5;
        $scale = $logo_width/$logo_qr_width;
        $logo_qr_height = $logo_height/$scale;
        $from_width = ($QR_width - $logo_qr_width) / 2;
        //重新组合图片并调整大小
        imagecopyresampled($QR, $logo, $from_width, $from_width, 0, 0, $logo_qr_width,
            $logo_qr_height, $logo_width, $logo_height);


        imagepng($QR, $path);
        $weburl='/baiqueyaoqing2/images/qcode/'.$id.'.jpg';
        return $weburl;
    }

简单的说就是利用php GD函数合并

navcat excel数据导入mysql的方法

navcat excel数据导入mysql的方法

先navcat导出 xls格式 然后把数据复制到往这个xls里 (按照这个xls格式) 然后导入mysql就行了

如果导入的过程无法识别excel里的内容 就想办法第一行能识别 自己重新输入下 就行 一般都是格式问题 第一行通过就行了

下面是通过phpexcel读取excel里的内容 然后存入数据库的

    public function daochuexcel()
    {
        set_time_limit(0);
		 ini_set("memory_limit","512M");
        error_reporting(E_ALL);
        ini_set('display_errors', TRUE);
        ini_set('display_startup_errors', TRUE);
        date_default_timezone_set('Asia/Shanghai');

        if (PHP_SAPI == 'cli')
            die('This example should only be run from a Web Browser');

        /** Include PHPExcel */
        require_once dirname(__FILE__) . '/../../../Public/phpexcel/Classes/PHPExcel.php';


// Create new PHPExcel object
        $objPHPExcel = new \PHPExcel();

// Set document properties
        $objPHPExcel->getProperties()->setCreator("Maarten Balliauw")
            ->setLastModifiedBy("Maarten Balliauw")
            ->setTitle("Office 2007 XLSX Test Document")
            ->setSubject("Office 2007 XLSX Test Document")
            ->setDescription("Test document for Office 2007 XLSX, generated using PHP classes.")
            ->setKeywords("office 2007 openxml php")
            ->setCategory("Test result file");


// Add some data
        $objPHPExcel->getActiveSheet()->getColumnDimension('B')->setWidth(20);
        $objPHPExcel->getActiveSheet()->getColumnDimension('C')->setWidth(20);
        $objPHPExcel->getActiveSheet()->getColumnDimension('f')->setWidth(20);
        $objPHPExcel->setActiveSheetIndex(0)
            ->setCellValue('A1', '姓名')
            ->setCellValue('B1', '手机号')
            ->setCellValue('C1', '奖品名字');

        $VModel = new HuanShanVoteModel();
        $sql = "select u.name,u.phone,p.prize_id from guagua_prize as p left join guaguaka_userinfo as u on p.openid=u.openid";
        $list = $VModel->query($sql);
        foreach ($list as $k => $v) {
            $prizeinfo = $this->prize_id($v['prize_id']);
            $list[$k]['prize_shortname'] = $prizeinfo['prize_shortname'];
        }


        $i = 1;
        foreach ($list as $k => $v) {
            $i++;
            $objPHPExcel->setActiveSheetIndex(0)
                ->setCellValue('A' . $i, $v['name'])
                ->setCellValue('B' . $i, $v['phone'])
                ->setCellValue('C' . $i, $v['prize_shortname']);
        }


        $objPHPExcel->getActiveSheet()->setTitle('Simple');


// Set active sheet index to the first sheet, so Excel opens this as the first sheet
        $objPHPExcel->setActiveSheetIndex(0);


// Redirect output to a client’s web browser (Excel5)
        header('Content-Type: application/vnd.ms-excel');
        header('Content-Disposition: attachment;filename="01simple.xls"');
        header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
        header('Cache-Control: max-age=1');

// If you're serving to IE over SSL, then the following may be needed
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
        header('Pragma: public'); // HTTP/1.0

        $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
        $objWriter->save('php://output');
        exit;
    }

jquery实现比较靠谱的手风琴代码

比较靠谱的手风琴代码

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title>自制手风琴</title>
    <script type="text/javascript" src="/index/js/jquery.min.js"></script>
    <style type="text/css">


        .menulist li {
            display: none;
        }


    </style>
</head>
<body>
<div class="menulist">
    <ul>
        <span>AAAAA<b>+</b></span>
        <li>11111</li>
        <li>11111</li>
        <li>11111</li>
        <li>11111</li>
    </ul>
    <ul>
        <span>BBBBB<b>+</b></span>
        <li>22222</li>
        <li>22222</li>
        <li>22222</li>
    </ul>
    <ul>
        <span>CCCCC<b>+</b></span>
        <li>33333</li>
        <li>33333</li>
        <li>33333</li>
        <li>33333</li>
        <li>33333</li>
    </ul>
    <ul>
        <span>DDDDD<b>+</b></span>
        <li>44444</li>
        <li>44444</li>
    </ul>
    <ul>
        <span>EEEEE<b>+</b></span>
        <li>55555</li>
        <li>55555</li>
        <li>55555</li>
    </ul>
</div>
<script type="text/javascript">
    $(function () {
        $('span').click(function () {
            if ($(this).siblings('li').hasClass('on')) {
                $(this).siblings('li').slideUp(500).removeClass('on');
                $(this).children('b').text('+');
            } else {
                $(this).siblings('li').slideDown(500).addClass('on');
                $(this).children('b').text('-');
            }
        });
    });
</script>
</body>
</html>

css3写下雨效果

css3写下雨效果

<div class="xiayuxiaoguo">
</div>
.xiayuxiaoguo{
    width:100%;
    height: 100%;
    position: absolute;
    left:0px;
    top:0px;
    z-index: 2;
}
.xiayu {
    animation: xiayu 2s forwards;
    -webkit-animation: xiayu 2s forwards;
}


@keyframes xiayu /* Firefox */
{

    to {
        top: 130%;
    }
}

@-webkit-keyframes xiayu /* Safari 和 Chrome */
{

    to {
        top: 130%;
    }
}
.yudi{
    width:2px;
    height: 10px;
    position: absolute;
    top:0%;
    background: #000;
}
xiayu();
function xiayu() {
    setTimeout(function () {
        var leftsuiji=RandomNumBoth(0,100);
        var yudi='<div style="left:'+leftsuiji+'%;" class="yudi xiayu"></div>';
        $(".xiayuxiaoguo").append(yudi);
        xiayu();
        if($('.yudi').length>=150){
            $('.yudi').remove();
        }
    },100)
}
function RandomNumBoth(Min,Max){
    var Range = Max - Min;
    var Rand = Math.random();
    var num = Min + Math.round(Rand * Range); //四舍五入
    return num;
}

大致就是利用jquery动态创建雨滴 然后播放css3动画就OK了

nginx配置优化提高并发量

1 nginx配置优化提高并发量

worker_processes 2;
这个按照CPU的核数来决定

2 worker_connections 65535;
这个一般设置65535即可 每个进程允许的最多连接数, 理论上每台nginx 服务器的最大连接数为worker_processes*worker_connections。

3 keepalive_timeout 60;
keepalive 设置超时时间 一般设置60

4. use epoll;
使用epoll 的I/O 模型

在Linux中将php-fpm配置成服务的方法

在Linux中将php-fpm配置成服务的方法
2012-07-20 by Jason
1.配置php-fpm.conf

vi /usr/local/php/etc/php-fpm.conf

php-fpm.pid 目录必须指向:/usr/local/php/var/run/php-fpm.pid

2.拷贝php-fpm脚本至/etc/init.d目录

cp /home/soft/php-5.3.15/sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm

3.设置权限并启动php-fpm:

chmod 755 /etc/init.d/php-fpm

/etc/init.d/php-fpm start

chkconfig –add php-fpm

最后,给出php-fpm以服务的方式启动、停止和重启:


service php-fpm start

service php-fpm stop

service php-fpm reload

linux 把nginx加入到系统服务的方法

linux 把nginx加入到系统服务的方法
一。首先写一个shell脚本,脚本名称:nginx

#! /bin/bash
# chkconfig: 35 85 15  
# description: Nginx is an HTTP(S) server, HTTP(S) reverse
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start(){
    $DAEMON || echo -n " already running"
}
d_stop() {
    $DAEMON -s quit || echo -n " not running"
}
d_reload() {
    $DAEMON -s reload || echo -n " counld not reload"
}
case "$1" in
start)
    echo -n "Starting $DESC:$NAME"
    d_start
    echo "."
;;
stop)
    echo -n "Stopping $DESC:$NAME"
    d_stop
    echo "."
;;
reload)
    echo -n "Reloading $DESC configuration..."
    d_reload
    echo "reloaded."
;;
restart)
    echo -n "Restarting $DESC: $NAME"
    d_stop
    sleep 2
    d_start
    echo "."
;;
*)
    echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
    exit 3
;;
esac
exit 0

二。将shell脚本放入到 /etc/rc.d/init.d/中,并执行下列命令
1:chmod +x /etc/rc.d/init.d/nginx (设置可执行权限)
2:chkconfig –add nginx (添加系统服务)