近期工作摘记(0 位领导批示)

因为最近比较忙,很久没更新博客了,草草几行,记录近期工作

公司

1. 年终晚会抽奖程序 AS3编写 基本完成
2. 内部系统(保密) PHP编写

个人

1. 歪藕 目前还是构思阶段,有部分数据供搜索引擎抓取.
2. 某地区人才网站, 代码编写中,计划用PHP开发, 前期准备工作基本完成, 预期用时为三个月.

[备忘]Mysql中explain的使用详解(1 位领导批示)

explain显示了mysql如何使用索引来处理select语句以及连接表.可以帮助选择更好的索引和写出更优化的查询语句.
使用方法:在select语句前加上explain. 如 EXPLAIN SELECT * FROM `users`

Explain 列的解释:
table 显示这一行的数据是关于哪张表的
type 这是重要的列,显示连接使用了何种类型。从最好到最差的连接类型为const、eq_reg、ref、range、indexhe和ALL
possible_keys 显示可能应用在这张表中的索引。如果为空,没有可能的索引。可以为相关的域从WHERE语句中选择一个合适的语句
key 实际使用的索引。如果为NULL,则没有使用索引。很少的情况下,MYSQL会选择优化不足的索引。这种情况下,可以在SELECT语句中使用USE INDEX(indexname)来强制使用一个索引或者用IGNORE INDEX(indexname)来强制MYSQL忽略索引
key_len 使用的索引的长度。在不损失精确性的情况下,长度越短越好
ref 显示索引的哪一列被使用了,如果可能的话,是一个常数
rows MYSQL认为必须检查的用来返回请求数据的行数
Extra 关于MYSQL如何解析查询的额外信息。这里可以看到的坏的例子是Using temporary和Using filesort,意思MYSQL根本不能使用索引,结果是检索会很慢

全文阅读 »

[备忘]PHP简单调试(1 位领导批示)

还是很方便的调试方式..记录一下备忘

1
2
ini_set("error_log", "E:\php_error.log");  
error_log($output,0);

php生成渐变图片(0 位领导批示)

问题链接:http://bbs.blueidea.com/thread-2957105-1-1.html

我是使用GD的 imagefilledrectangle 函数来实现的. 不知是否有更好的解法

1
2
3
4
5
6
7
8
9
10
11
12
<?php
$im = imagecreate(255, 255);
$bg = imagecolorallocate($im, 0, 0, 0);
for($i=255; $i>=0; $i--)
{
    $color = imagecolorallocate($im, $i, $i, $i);
    imagefilledrectangle($im, 0, $i, 255, 1, $color);
}
header("Content-type: image/png");
imagepng($im);
imagedestroy($im);
?>
Tags : , , ,

Sina App Engine 试用小记(2 位领导批示)

首先扫扫盲

Sina App Engine 是由新浪在近期低调发布了基于PHP的Web应用开发和运行平台(Alpha),致力于为广大SAE开发者提供简单高效的分布式应用环境。

据说是sina内部测试的.只有200个名额. 实在是好奇. 弄到了个账号测试测试. http://bbs.blueidea.com/thread-2956594-1-1.html (^_^)

用过之后有点失望.限制N多(phpinfo都被禁止.更不要谈别的系统函数).不过一个免费的玩意不可能太多功能.HOHO.

11M的memcached. mysql支持. 管理起来还算相当方便. 本想放一个punbb进行测试.无奈几次上传后都不能安装.遂放弃.上传一个N久前写的小代码(访问: http://1.silver.sinaapp.com/). 速度还可以.当虚拟主机用了..HOHO

后台载图

Tags : , ,

PHP处理简单图片的颜色填充(0 位领导批示)

原问题地址: http://bbs.blueidea.com/viewthread.php?tid=2956421


现在有一张背景色为纯蓝色(或者红色等) 并且与照片里人物有很明显的反差色彩 的一寸单人照照片,现想把,该图片中的蓝色背景用PHP处理为白色。即类似于PS中,用白色填充蓝色的效果。

使用GD库的imagecolorset函数可以修改简单的索引色. 不过只能对gif与png图片有效

1
2
3
4
5
6
7
8
<?php
$img = file_get_contents('http://home.blueidea.com/attachment/200911/9/207382_1257738485WdvH.gif');
$im = imagecreatefromstring($img);
$bg = imagecolorat($im, 0, 0);
imagecolorset($im, $bg, 0, 0, 255);
imagepng($im);
imagedestroy($im);
?>

[备忘]安装PHP扩展时需要同时安装的扩展列表(0 位领导批示)

仅备忘

php_curl.dll CURL, Client URL library functions Requires: libeay32.dll, ssleay32.dll (bundled)
php_domxml.dll DOM XML functions PHP <= 4.2.0 requires: libxml2.dll
(bundled) PHP >= 4.3.0 requires: iconv.dll (bundled)
php_fdf.dll FDF: Forms Data Format functions. Requires: fdftk.dll
gnu_gettext.dll (bundled), PHP >= 4.2.3 requires libintl-1.dll,
php_iconv.dll ICONV characterset conversion Requires: iconv-1.3.dll
php_ingres.dll Ingres II functions Requires: Ingres II libraries
php_interbase.dll InterBase functions Requires: gds32.dll (bundled)
php_java.dll Java functions PHP <= 4.0.6 requires: jvm.dll (bundled)
php_ldap.dll LDAP functions PHP <= 4.2.0 requires libsasl.dll(bundled),
PHP >= 4.3.0 requires libeay32.dll,ssleay32.dll (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll (bundled)
php_mcrypt.dll Mcrypt Encryption functions Requires: libmcrypt.dll
php_mhash.dll Mhash functions PHP >= 4.3.0 requires: libmhash.dll (bundled)
php_msql.dll mSQL functions Requires: msql.dll (bundled)
php_mssql.dll MSSQL functions Requires: ntwdblib.dll (bundled)
php_mysql.dll MySQL functions PHP >= 5.0.0, requires libmysql.dll (bundled)
php_mysqli.dll MySQLi functions PHP >= 5.0.0, requires libmysqli.dll (bundled)
php_oci8.dll Oracle 8 functions Requires: Oracle 8.1+ client libraries
php_openssl.dll OpenSSL functions Requires: libeay32.dll (bundled)
php_oracle.dll Oracle functions Requires: Oracle 7 client libraries
php_sybase_ct.dll Sybase functions Requires: Sybase client libraries
php_xmlrpc.dll XML-RPC functions PHP >= 4.2.1 requires: iconv.dll (bundled)
php_xslt.dll XSLT functions PHP <= 4.2.0 requires sablot.dll, expat.dll (bundled).
PHP >= 4.2.1 requires sablot.dll, expat.dll, iconv.dll (bundled).

转换avatar头像函数(0 位领导批示)

仅备忘

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/**
 * 获取 avatar 头像
 *
 * @param string $email
 * @param integer $size
 * @return string
 */
function getAvatar($email, $size = '24')
{
	if (!is_numeric($size))
	{
		$size = '24';
	}
	if (!empty($email))
	{
		$out = 'http://www.gravatar.com/avatar/' . md5(strtolower($email)) . '?s=' . $size;
		$avatar = "<img src='{$out}' class='avatar avatar-{$size} photo' height='{$size}' width='{$size}' alt='{$email}' /> " . $email;
	}
	else
	{
		$avatar = $email;
	}
 
	return $avatar;
}

[备忘]几个不错的Flash Chart (图表)(0 位领导批示)

  • amCharts
  • AnyChart Flash Chart Component
  • Aurigma FlashChart
  • B-Line Charting Component
  • Corda’s PopChart
  • FusionCharts
  • Graph ZX
  • Open Flash Chart
  • PHP/SWF Charts
  • Rich Chart Builder
  • Swiff Chart
  • WA Dynamic Flash Charts
  • Tags : , ,

    [备忘]PHP无法加载LDAP扩展的解决方法(2 位领导批示)

    最近的项目中需要使用域账号访问域控服务器. 要开启PHP的LDAP扩展.

    打开php.ini后去掉 ;extension=php_ldap.dll 的分页.重启APACHE.
    刷新页面..显示 Call to undefined function ldap_connect()

    0_o 咋回事捏? 打开PHPINFO发现没有 LDAP.. 说明木有加载上..

    最终找到解决方法:


    将PHP目录下的libeay32.dll和ssleay32.dll拷贝到system32目录下.重启APACHE

    搞电.. (^_^)

    随机显示的10篇日志

    评论最多的10篇日志

    浏览最多的10篇日志