Discuz的install文件核心函数(2 位领导批示)

可以将自己写的程序做一个install.php.
Discuz的install文件中的核心函数,相当精简..

  1. <?php
  2. require("connect.inc.php");
  3. $sqlfile = 'test.sql';//sql文件
  4.  
  5. $fp = fopen($sqlfile, 'rb');
  6. $filesize=filesize($sqlfile);
  7. $sql = fread($fp, $filesize);
  8. fclose($fp);
  9. runquery($sql);
  10.  
  11. function runquery($sql) {
  12.     global $lang, $dbcharset, $tablepre, $db;
  13.  
  14.     $sql = str_replace("\r", "\n", str_replace(' cdb_', ' '.$tablepre, $sql));
  15.     $ret = array();
  16.     $num = 0;
  17.     foreach(explode(";\n", trim($sql)) as $query) {
  18.         $queries = explode("\n", trim($query));
  19.         foreach($queries as $query) {
  20.             $ret[$num] .= $query[0] == '#' || $query[0].$query[1] == '--' ? '' : $query;
  21.         }
  22.         $num++;
  23.     }
  24.     unset($sql);
  25.  
  26.     foreach($ret as $query) {
  27.         $query = trim($query);
  28.         if($query) {
  29.             if(substr($query, 0, 12) == 'CREATE TABLE') {
  30.                 $name = preg_replace("/CREATE TABLE ([a-z0-9_]+) .*/is", "\\1", $query);
  31.                 echo $lang['create_table'].' '.$name.' ... <font color="#0000EE">'.$lang['succeed'].'</font><br>';
  32.                 mysql_query(createtable($query, $dbcharset));
  33.             } else {
  34.                 mysql_query($query);
  35.             }
  36.         }
  37.     }
  38. }
  39. ?>

(备忘)MySQL字段类型(2 位领导批示)

MySQL支持大量的列类型,它可以被分为3类:数字类型、日期和时间类型以及字符串(字符)类型。本节首先给出可用类型的一个概述,并且总结每个列类型的存储需求,然后提供每个类中的类型性质的更详细的描述。概述有意简化,更详细的说明应该考虑到有关特定列类型的附加信息,例如你能为其指定值的允许格式。

由MySQL支持的列类型列在下面。下列代码字母用于描述中:

 

M
指出最大的显示尺寸。最大的合法的显示尺寸是 255 。
D
适用于浮点类型并且指出跟随在十进制小数点后的数码的数量。最大可能的值是30,但是应该不大于M-2。
方括号(“[”和“]”)指出可选的类型修饰符的部分。

注意,如果你指定一个了为ZEROFILL,MySQL将为该列自动地增加UNSIGNED属性。

全文阅读 »

Internet Explorer 8 Beta 1 发布(1 位领导批示)

Internet Explorer 8 can be installed on Microsoft Windows Vista® Service Pack 1 (SP1), Windows Vista, Windows XP® Service Pack 2 (SP2), Windows Server® 2008 and Windows Server 2003 Service Pack 2 (SP2).

能安装在vista,2008server,winXP SP2与2003 SP2上

不敢安装..怕折腾系统..^_^

M$总算知耻而后勇..

P.S.标准化的同学们..又要头大了吧.

Internet Explorer 8 Beta 1 下载页面 http://www.microsoft.com/windows/products/winfamily/ie/ie8/readiness/Install.htm

仿WINODWS警告提示Firefox广告(2 位领导批示)

不知道效果如何,先挂在自己的表情站上试试,毕竟google广告里最有价值的还是Firefox的广告推荐了

实现代码如下:

先在 < body > 后加上这么一段

  1. <div id="firefox">
  2. <a href="/firefox/" target="_new">还在用过时的IE浏览器?远离网络病毒,木马,恶意软件的入侵攻击,强烈建议下载安装【最快.最安全】的浏览器:火狐Firefox2.0</a>
  3. <img src="close.gif" id="foxclose" />
  4. </div>
  5. <script type="text/javascript" src="firefox.js"></script>

CSS部分:

  1. #firefox {
  2.     height:25px;
  3.     width:100%;
  4.     background:url(warning.gif) no-repeat 8px 3px #ffb;
  5.     border-bottom:1px solid #ffdb4d;
  6.     line-height:25px;
  7.     display:none;
  8. }
  9.  
  10. #firefox a {
  11.     color:#52271d;
  12.     float:left;
  13.     margin-left:170px;
  14. }
  15.  
  16. #firefox img {
  17.     dispaly:block;
  18.     float:right;
  19.     margin:7px 6px 0 0;
  20.     cursor:pointer;
  21. }

全文阅读 »

JS存档:insertAfter()函数(0 位领导批示)

insertAfter(newElement, targetElement)
newElement 创建的新元素
targetElement 插入到这个元素之后

JS没有内置这个函数真是不方便呐.存档方便今后查找

  1. function insertAfter(newElement, targetElement)
  2. {
  3.     var parent = targetElement.parentNode;
  4.     if(parent.lastChild == targetElement) 
  5.     {
  6.         parent.appendChild(newElement);
  7.     } 
  8.     else
  9.     {
  10.         parent.insertBefore(newElement, targetElement.nextSibling);
  11.     }
  12. }

JS中文字符串转换unicode编码函数(0 位领导批示)

AJAX传递中文字符串时必须把中文字符串编码成unicode,一般会用到JS的自带函数escape().不过找到了更好的函数来确决中文字符转换成unicode编码的函数

  1. function uniencode(text)
  2. {
  3.     text = escape(text.toString()).replace(/\+/g, "%2B");
  4.     var matches = text.match(/(%([0-9A-F]{2}))/gi);
  5.     if (matches)
  6.     {
  7.         for (var matchid = 0; matchid < matches.length; matchid++)
  8.         {
  9.             var code = matches[matchid].substring(1,3);
  10.             if (parseInt(code, 16) >= 128)
  11.             {
  12.                 text = text.replace(matches[matchid], '%u00' + code);
  13.             }
  14.         }
  15.     }
  16.     text = text.replace('%25', '%u0025');
  17.  
  18.     return text;
  19. }

当然服务器端要对编码过的字符串进行第二次转码.把字符串转换成UTF-8编码.

全文阅读 »

版本控制工具 TortoiseSVN(6 位领导批示)

关于TortoiseSVN

TortoiseSVN

TortoiseSVN是一个真正的易于使用的版本控制/源控制系统。

TortoiseSVN就像是一个windows的扩展外壳,用户可以像使用“我的电脑”那样使用这个软件。

TortoiseSVN是自由软件,你不需要花钱就可以使用它,并且可以随意使用。它的开发遵循GPL协议。

以上是从TortoiseSVN的帮助文档摘录出来的。简单的说,TortoiseSVN可以看作一个代码版本控制工具,方便多人合作编写代码。现在有不少开源的作品是使用SVN作为源码管理工具的,学会了TortoiseSVN就可以很方便的拿到这些代码。

TortoiseSVN功能丰富,但是我们只需要学会2个简单的操作即可,第一就是下载代码,第二是上传。

 

下载页面:http://tortoisesvn.net/downloads

新年新气象,博客换新装(5 位领导批示)

原来用的underone’s G7 v1(basic) 风格使用的人实在是太多了

终下决心要重新做套风格

原来的博客模板现提供下载

下载:http://www.qqdang.net/download/yinzi_skin.rar 大小:122K

Tags : , , ,

Navicat for MySql(4 位领导批示)

Navicat 头儿推荐给我的MySql可视化开发管理工具

Navicat最大的好处就是数据同步与数据的转移..相比来说phpmyadmin就太过不专业了.

主要功能:
-表单检视
-虚拟群组
-自动完码
-排程工作结果自动传送电子邮件
-查询、 检视及事件自动完码
-报告可汇出成各种格式,PDF, Excel, HTML 等
-超时自动重新连接到SQL服务器
-数据和结构同步
-导出注册文件以传送到另外的计算机
-新查询创建器–为不同的数据库创建查询
-查询参数
-SQL控制台
-建立查看
-SSH密钥
-支持所有MySQL版本
-SSH及HTTP隧道
-汇入/汇出数据
-报表设计及建立

软件界面
Navicat for MySql

下载地址: http://www.navicat.com.cn

不过推荐使用英文版,汉化的台湾国语化比较重,用英文还是原汁原味点

JS获取页面实际大小函数(0 位领导批示)

Lightbox里面的一个函数,能把页面实际的高宽与浏览器可视面积的高宽保存在一个数组中..非常好用.记录一下

  1. function getPageSize(){
  2.    
  3.     var xScroll, yScroll;
  4.    
  5.     if (window.innerHeight && window.scrollMaxY) {   
  6.         xScroll = document.body.scrollWidth;
  7.         yScroll = window.innerHeight + window.scrollMaxY;
  8.     } else if (document.body.scrollHeight > document.body.offsetHeight){ // all but Explorer Mac
  9.         xScroll = document.body.scrollWidth;
  10.         yScroll = document.body.scrollHeight;
  11.     } else { // Explorer Mac...would also work in Explorer 6 Strict, Mozilla and Safari
  12.         xScroll = document.body.offsetWidth;
  13.         yScroll = document.body.offsetHeight;
  14.     }
  15.    
  16.     var windowWidth, windowHeight;
  17.     if (self.innerHeight) {    // all except Explorer
  18.         windowWidth = self.innerWidth;
  19.         windowHeight = self.innerHeight;
  20.     } else if (document.documentElement && document.documentElement.clientHeight) { // Explorer 6 Strict Mode
  21.         windowWidth = document.documentElement.clientWidth;
  22.         windowHeight = document.documentElement.clientHeight;
  23.     } else if (document.body) { // other Explorers
  24.         windowWidth = document.body.clientWidth;
  25.         windowHeight = document.body.clientHeight;
  26.     }   
  27.    
  28.     // for small pages with total height less then height of the viewport
  29.     if(yScroll < windowHeight){
  30.         pageHeight = windowHeight;
  31.     } else { 
  32.         pageHeight = yScroll;
  33.     }
  34.  
  35.     // for small pages with total width less then width of the viewport
  36.     if(xScroll < windowWidth){   
  37.         pageWidth = windowWidth;
  38.     } else {
  39.         pageWidth = xScroll;
  40.     }
  41.  
  42.     arrayPageSize = new Array(pageWidth,pageHeight,windowWidth,windowHeight) 
  43.     return arrayPageSize;
  44. }

调用:

  1. var getPageSize = getPageSize();
  2. alert(getPageSize[0] + getPageSize[1] + getPageSize[2] + getPageSize[3]);

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志