顯示具有 php 標籤的文章。 顯示所有文章
顯示具有 php 標籤的文章。 顯示所有文章

2010年4月14日 星期三

[PHP]Elgg - 功能完整的社交平台(SNS)

Elgg.org is a robust open source social application engine. Elgg provides elegant, flexible and scalable solutions for organisations, groups and individuals. Take advantage of powerful social technology today.

Elgg.org 是一個開放原始碼的社交應用引擎,Elgg 提供優雅、彈性與可擴充的解決方案,適合組織、社群與個人。透過它可以得到社交技術的好處。

功能:個人用戶信息管理。Blog功能。文檔管理。通過各種方式(如Email、內部消息等,允許利用插件擴展通知方式如通過手機短信)瞭解你的朋友當前正在做些什麼。創建圈子,支持圈內討論,文件共享等。







官網:http://elgg.org/
下載:http://elgg.org/download.php
正體中文:Language pack for Traditional Chinese

  1. PHP版本必須5.2以上
  2. Apache server hffpd.conf
    將 AllowOverride None 改為 AllowOverride All
    必須開放 LoadModule rewrite_module modules/mod_rewrite.so
    這個一定要注意,否則安裝完數據庫到第二頁之後,會出現網頁找不到的情況。
  3. 將/engine/settings.example.php改成settings.php開啟修改底下的設定,
    // Database username
    $CONFIG->dbuser = '{{CONFIG_DBUSER}}';
    // Database password
    $CONFIG->dbpass = '{{CONFIG_DBPASS}}';
    // Database name
    $CONFIG->dbname = '{{CONFIG_DBNAME}}';
    // Database server
    // (For most configurations, you can leave this as 'localhost') $CONFIG->dbhost = '{{CONFIG_DBHOST}}';
  4. 在 mySQL 建立您剛設定的資料庫名稱{{CONFIG_DBNAME}}
  5. 即可順利完成安裝。

2010年3月27日 星期六

[PHP]jQuery/PHP Form Builder Sourcecode

jQuery/PHP Form Builder Sourcecode 是個好用的表單快速產生器。


範例影片:


網址:
http://blog.sonuku.com/2009/04/11/php-formbuilder/

DEMO:
http://dontlink.me/formbuilder/

DOWNLOAD:
http://dontlink.me/formbuilder/formbuilder-1.1.rar

2010年3月26日 星期五

[PHP]PHP 結合 ADODB 產生 json 教學

今天在需要運用 PHP 結合 ADODB 產生 json,於是找到了這篇「Handy AJAX data structures using JSON, XML, ADODB, PHP, and Mysql」教學,將 tojson.inc.php 檔放入 adodb/ 目錄下,即可運用了 ^^

tojson.inc.php
CODE:

/**
* Creates JSON ( http://www.json.org/ ) from the ADODB record set
*
* @param object $rs - record set object
* @param bool $moveFirst - determines whether recordset is returned to first record
* @return string $output - resulting json string
* @version V1.0 10 June 2006 (c) 2006 Rich Zygler ( http://www.boringguys.com/ ). All rights reserved.
*
* Released under both BSD license and Lesser GPL library license. You can choose which license
* you prefer.

Example output from query "SELECT Name, Continent From Country LIMIT 10;"

{"rows":[
{"row":{"Name":"Afghanistan","Continent":"Asia"}},
{"row":{"Name":"Netherlands","Continent":"Europe"}},
{"row":{"Name":"Netherlands Antilles","Continent":"North America"}},
{"row":{"Name":"Albania","Continent":"Europe"}},
{"row":{"Name":"Algeria","Continent":"Africa"}},
{"row":{"Name":"American Samoa","Continent":"Oceania"}},
{"row":{"Name":"Andorra","Continent":"Europe"}},
{"row":{"Name":"Angola","Continent":"Africa"}},
{"row":{"Name":"Anguilla","Continent":"North America"}},
{"row":{"Name":"Antigua and Barbuda","Continent":"North America"}}
]}

*/

function rs2json($rs, $moveFirst = false)
{
if (!$rs)
{
printf(ADODB_BAD_RS,'rs2json');
return false;
}

$output = '';
$rowOutput = '';

$output .= '{"rows":';
$totalRows = $rs->numrows();

if($totalRows > 0)
{
$output .= '[';
$rowCounter = 1;
while ($row = $rs->fetchRow())
{
$rowOutput .= '{"row":{';
$cols = count($row);
$colCounter = 1;

foreach ($row as $key => $val)
{
$rowOutput .= '"' . $key . '":';
$rowOutput .= '"' . $val . '"';

if ($colCounter != $cols)
{
$rowOutput .= ',';
}
$colCounter++;
}

$rowOutput .= '}}';

if ($rowCounter != $totalRows)
{
$rowOutput .= ',';
}
$rowCounter++;
}
$output .= $rowOutput . ']';
}
else
{
$output .= '"row"';
}

$output .= '}';

if ($moveFirst)
{
$rs->MoveFirst();
}
return $output;
}



Example

<?php

require_once('Adodb/adodb.inc.php');
require_once('Adodb/tojson.inc.php');

// we're using the mysql "world" database downloadable from http://dev.mysql.com/doc/
$dbType = 'mysql';
$dbHost = 'localhost';
$dbName = 'world';
$dbUser = 'test';
$dbPass = 'test';

$db = ADONewConnection($dbType);
$db->Connect($dbHost, $dbUser, $dbPass, $dbName);
$db->SetFetchMode(ADODB_FETCH_ASSOC);

$sql = "SELECT * FROM Country LIMIT 10";
$result = $db->Execute($sql);

if(!$result)
{
echo $db->ErrorMsg();
}
else
{
echo rs2json($result);

// you may want to utf8_encode the results instead (works better in IE this way)
//echo utf8_encode(rs2json($result));
}

$result->close();
$db->close();

?>


英文網址:http://blog.boringguys.com/2006/08/handy-ajax-data-structures-using-json.html

2010年2月3日 星期三

[PHP]MD5函數加密 解密 ENCODE DECODE

今天在網路上看到有關 PHP 運用 MD5 函數將字符串加密以及解密的函數。

<?php

/**
 * 字符串加密以及解密函數
 *
 * @param string $string 原文或者密文
 * @param string $operation 操作(ENCODE | DECODE), 默認為 DECODE
 * @param string $key 密鑰
 * @param int $expiry 密文有效期, 加密時候有效, 單位 秒,0 為永久有效
 * @return string 處理後的 原文或者 經過 base64_encode 處理後的密文
 *
 * @example
 *
 *     $a = authcode('abc', 'ENCODE', 'key');
 *     $b = authcode($a, 'DECODE', 'key');  // $b(abc)
 *
 *     $a = authcode('abc', 'ENCODE', 'key', 3600);
 *     $b = authcode('abc', 'DECODE', 'key'); // 在一個小時內,$b(abc),否則 $b 為空
 */
    function authcode($string, $operation = 'DECODE', $key = '', $expiry = 0) {

        $ckey_length = 4;    // 隨機密鑰長度 取值 0-32;
                    // 加入隨機密鑰,可以令密文無任何規律,即便是原文和密鑰完全相同,加密結果也會每次不同,增大破解難度。
                    // 取值越大,密文變動規律越大,密文變化 = 16 的 $ckey_length 次方
                    // 當此值為 0 時,則不產生隨機密鑰

        $key = md5($key ? $key : UC_KEY);
        $keya = md5(substr($key, 0, 16));
        $keyb = md5(substr($key, 16, 16));
        $keyc = $ckey_length ? ($operation == 'DECODE' ? substr($string, 0, $ckey_length): substr(md5(microtime()), -$ckey_length)) : '';

        $cryptkey = $keya.md5($keya.$keyc);
        $key_length = strlen($cryptkey);

        $string = $operation == 'DECODE' ? base64_decode(substr($string, $ckey_length)) : sprintf('%010d', $expiry ? $expiry + time() : 0).substr(md5($string.$keyb), 0, 16).$string;
        $string_length = strlen($string);

        $result = '';
        $box = range(0, 255);

        $rndkey = array();
        for($i = 0; $i <= 255; $i++) {
            $rndkey[$i] = ord($cryptkey[$i % $key_length]);
        }

        for($j = $i = 0; $i < 256; $i++) {
            $j = ($j + $box[$i] + $rndkey[$i]) % 256;
            $tmp = $box[$i];
            $box[$i] = $box[$j];
            $box[$j] = $tmp;
        }

        for($a = $j = $i = 0; $i < $string_length; $i++) {
            $a = ($a + 1) % 256;
            $j = ($j + $box[$a]) % 256;
            $tmp = $box[$a];
            $box[$a] = $box[$j];
            $box[$j] = $tmp;
            $result .= chr(ord($string[$i]) ^ ($box[($box[$a] + $box[$j]) % 256]));
        }

        if($operation == 'DECODE') {
            if((substr($result, 0, 10) == 0 || substr($result, 0, 10) - time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26).$keyb), 0, 16)) {
                return substr($result, 26);
            } else {
                return '';
            }
        } else {
            return $keyc.str_replace('=', '', base64_encode($result));
        }

    }
 
?>

網址:http://5ddesign.kingkinmen.com/bbs/redirect.php?tid=44&goto=lastpost

2010年1月30日 星期六

[Dreamweaver]tecnorama.org 提供 Dreamweaver PHP的外掛模組

tecnorama.org 這裡提供了許多 Dreamweaver Extensions,和使用教學。

網址:http://www.tecnorama.org/list.php?id_tipo=5



特別介紹好用的 Dreamweaver 外掛 PHP 圖形驗證(PHP Captcha Image)文中還有教學,不過是英文教學,中文教學的話可以參考 YOGO生活誌 Captcha圖形驗證 - Dreamweaver外掛篇(PHP篇)

2010年1月28日 星期四

[PHP]www.phpjc.cn 讓你從零開始學習

www.phpjc.cn 提供了 PHP、Smarty、Ajax、Css 的教學,讓你從基礎學起。



網址:http://www.phpjc.cn/