代码片段
分页: 1/4 第一页 1 2 3 4 下页 最后页 [ 显示模式: 摘要 | 列表 ]
Nov 17

[置顶] 收藏PHP常用函数 不指定

shuguang , 10:13 , 代码片段 , 评论(13) , 引用(0) , 阅读(189842) , Via 本站原创

<?
function GetIP() { //获取IP
    
if ($_SERVER["HTTP_X_FORWARDED_FOR"])
        
$ip $_SERVER["HTTP_X_FORWARDED_FOR"];
    else if (
$_SERVER["HTTP_CLIENT_IP"]) //开源代码OSPHP.COM.Cn
        
$ip $_SERVER["HTTP_CLIENT_IP"];
    else if (
$_SERVER["REMOTE_ADDR"])
        
$ip $_SERVER["REMOTE_ADDR"];
    else if (
getenv("HTTP_X_FORWARDED_FOR"))
//OSPHP.COM.Cn开源

        
$ip getenv("HTTP_X_FORWARDED_FOR");
    else if (
getenv("HTTP_CLIENT_IP"))
        
$ip getenv("HTTP_CLIENT_IP");
    else if (
getenv("REMOTE_ADDR"))
//OSPHP.COm.CN

        
$ip getenv("REMOTE_ADDR");
    else
        
$ip "Unknown";
    return 
$ip;
}
?>

Tags: , , ,
Mar 13
程序名称:代码高亮 KindSyntax
开发者/组织名称:Kindsoft
运行环境:php+文本
官方网站:http://www.kindsoft.net
演示地址:http://www.kindsoft.net/syntax/demo.php
下载地址:http://www.kindsoft.net/download/kindsyntax-1.0.zip
请下载附件中的源码,不要直接复制 (已下载 1880 次)

文章来源:http://www.OSphp.com.cn
程序介绍:
KindSyntax是用PHP做的程序语法加亮类,支持HTML、 JavaScript、 PHP、 Perl等语言的高亮显示,可以替代PHP自带的highlight函数。
版权:免费(LGPL)
使用语言:PHP //OsPHP.COM.CN
最新版本:1.0
使用方法:请参考压缩包里的README.txt文件。

引用

win和bsd主机下可能会出错
Error 内容是:
Warning: in_array(): Wrong datatype for second argument in h:akil_board estclass.stx.php on line 203
Warning: in_array(): Wrong datatype for second argument in h:akil_board estclass.stx.php on line 237
Warning: in_array(): Wrong datatype for second argument in h:akil_board estclass.stx.php on line 239


引用

打开class.stx.php
查找:
$root_path = preg_replace("/^(.*/)(.*)$/","",__FILE__);
替换为:
$root_path = (substr(PHP_OS,0,3) =='WIN') ? dirname(__FILE__).'\\' : dirname(__FILE__).'/';
修改后测试 WIN 和 BSD 正常。

Feb 23
程序名称:ajax Database Table
开发/组织:Sean Dempsey
官方网站:http://seandempsey.com/php
文章来源:http://w ww.OS php.com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 1952 次)

程序介绍:
点击在新窗口中浏览此图片

This package can be used to manipulate MySQL database table records using HTML forms with AJAX.
//开源代码OSPHP.COM.Cn
It takes a given database table name and displays its records in an HTML table that can be edited using AJAX to save the record changes without reloading the page. New database table records may also be added or deleted.

The class supports defining relationships to other tables from which the values of foreign key fields are retrieved and displayed as form select inputs for editing.

Long tables are presented split in multiple pages with links to browse other pages where other table records are displayed.
Jan 16
程序名称:SWF to JPG
开发/组织:Gurdeep Singh
文章来源:http://www.OSphp. com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 2934 次)

程序介绍:
点击在新窗口中浏览此图片
This class can be used to render an image drawn on a Flash canvas movie.

A Flash canvas movie displays a drawing area on which the user can draw a picture with brushes of different colors and and thicknesses.//w ww.O Sphp. com.cn //oSPHP.COM.CN

When the user wants the save the drawing, the Flash movie sends the list of the brush strokes to the server.

The class receives the list brush strokes and generates a JPEG image file that represents a copy of the user drawing.
Tags: , , , , ,
Dec 12
程序名称:PHP5 Calendar
开发/组织:galen
官方网站:http://www.galengrover.com/
文章来源:http://www.OSphp.com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 2549 次)

程序介绍:
This class can be used to display month calendars in HTML tables.

It takes a given month and year and generates an HTML table with the days of that month. The calendar start week day may be set to Sunday or Monday.

Special event days may exhibit the title of the event in the respective calendar table cell.

The class also shows links to pages that display the next and previous months. //OsPHP.COM.CN

The calendar presentation details can be configured with CSS styles.

The class generates XHTML compliant HTML.
Tags: , ,
Dec 12
程序名称:PHP Tree Graph
开发/组织:Mathias
官方网站:http://mazeh.ath.cx/
文章来源:http://www.OSphp.com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 2396 次)

程序介绍:
点击在新窗口中浏览此图片
点击在新窗口中浏览此图片
//OsPHP.COM.CN

This package can be used to render graphical diagrams of hierarchical trees of nodes.

There is a base tree class that manages an hierarchy of node objects.

A renderer sub-class takes care of traversing the tree and rendering a representation of each node in an image.

Each node may have associate a text, an image and desired width and height that it will occupy in the tree graphical diagram.

The colors of the image background, node, node links and node text are configurable. The node link style, node text font and node border width can also be configured.
Tags: , , , , ,
Dec 5
程序名称:Calendar Form
开发/组织:Alexander Russkih
官方网站:http://olden.ks.ua/
文章来源:http://www.OSphp.com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 3459 次)

程序介绍:
This class can be used to display months of calendars in Web pages.

It takes as parameters the year and the month to be displayed.

The class generates an HTML table that displays the days of the given month. The week days appear at the top with names in Ukrainian.
Tags: , , ,
Dec 5
程序名称:Feed Finder
开发/组织:Manel Zaera
官方网站:http://manelzaera.blogspot.com/
文章来源:http://www.OSphp.com.cn
下载地址:
请下载附件中的源码,不要直接复制 (已下载 1534 次)

程序介绍:
This class can be used to check whether an URL is of an RSS or Atom feed.

It retrieves the contents of a Web resource given its URL.

The class tries to parse the retrieved content assuming it is a XML document.

It checks whether certain XML elements are present to determine whether it is a feed in RSS 1, RSS 2 or Atom formats.
Tags: , ,
Dec 3
程序名称:FormatMail
开发者/组织名称:Senk Jozsef
运行环境:php+文本
下载地址:
请下载附件中的源码,不要直接复制 (已下载 1003 次)

文章来源:http://www.OSphp.com.cn
程序介绍:
This package can be used to compose and send HTML e-mail messages.

It reads a template file and replace variable place-holders by the values of global variables with the same name.

The processed template is sent as body of an HTML message. Any images and CSS files are automatically processed and included in the message as attachements.

//PHP开源代码
<?php
    
require_once ("class.phpmailer.php");
    require_once (
"class.smtp.php");

    class 
FormatMail {
        var 
$TemplateFile;
        var 
$Mailer;
        var 
$Message;
        var 
$ReplacedArr=array('/<img[^<>]*src="[^<>]*"[^<>]*>/i' => '/src="[^<>"]*"/i',

//OsPHP.COM.CN


                                
'/<img[^<>]*src='[^<>]*'[^<>]*>/i' => '/src='[^<>']*'/i',
                                '
/<script[^<>]*src="[^<>]*"[^<>]*>/i' => '/src="[^<>"]*"/i', //开源OSPhP.COM.CN
                                '/<script[^<>]*src='[^<>]*'[^<>]*>/i' => '/src='[^<>']*'/i',
                                '/<link[^<>]*href="
[^<>]*"[^<>]*>/i' => '/href="[^<>"]*"/i',
                                '
/<link[^<>]*href='[^<>]*'[^<>]*>/i' => '/href='[^<>']*'/i', //PHP开源代码
                                
'/<[^<>]*background="[^<>]*"[^<>]*>/i' => '/background="[^<>"]*"/i',
                                
'/<[^<>]*background='[^<>]*'[^<>]*>/i' => '/background='[^<>']*'/i');
//PHP开源代码

                                
        
        
        function FormatMail($TemplateFile) {
            $this->TemplateFile=$TemplateFile;
            $this->Mailer=new PHPMailer();
            $this->Mailer->IsHTML(true);
            $this->Message=$this->GetTemplate();
        }

    
        function Send() {

//开源代码OSPHP.COM.Cn


            $this->Mailer->Body=$this->Message;
            return $this->Mailer->Send();
        }
        
        function GetTemplate() {
            $tfile=fopen($this->TemplateFile,'
r');
            $tcontent=fread($tfile,filesize($this->TemplateFile));
            fclose($tfile);
            while (!(strpos($tcontent, '
{$')===false)) {

//OSPHP.com.CN


                $start=strpos($tcontent, '
{$');
                $end=strpos($tcontent, '
}', $start);
                $name=substr($tcontent,$start+2,$end-$start-2);
                $thalf1=substr($tcontent,0,$start);
                $thalf2=substr($tcontent,$end+1);
                if (isset($GLOBALS[$name]))
                  $tcontent=$thalf1.$GLOBALS[$name].$thalf2;

//OSPHP.COm.CN


                else 
                  $tcontent=$thalf1.$thalf2;
            }
            $tcontent=preg_replace("/r/","",$tcontent);
            $tcontent=preg_replace("/n/","",$tcontent);
            $TagArr=array();
            $Idx=0;
            foreach ($this->ReplacedArr as $ReplacedTag => $ReplacedAttribute) {
                if (preg_match_all($ReplacedTag,$tcontent,$TagArr)) { //OSPHP.COM.Cn开源
                    foreach ($TagArr as $ValArr) {
                        foreach ($ValArr as $Found) {
                            $AttributeArr=array();
                            if (preg_match($ReplacedAttribute,$Found,$AttributeArr)) {
                                $CID=md5("ATTACH_".$Idx++); //OSPHP.COm.CN
                                $Subject=substr($AttributeArr[0],strpos($AttributeArr[0],'
=')+2,-1);
                                $this->Mailer->AddEmbeddedImage($Subject,$CID, "");
                                $Pattern="'
$Subject'i";
                                $tcontent=preg_replace($Pattern,"cid:".$CID,$tcontent);

//开源代码OSPhP.COm.CN


                            }
                        }
                    }
                }
            }    
            return $tcontent;
        }
    }  
?>

Dec 3
程序名称:Recursive array to XML
开发者/组织名称:Mikael Göransson
运行环境:php+mysql,php+文本
官方网站:http://www.strangeways.se/
下载地址:
请下载附件中的源码,不要直接复制 (已下载 1453 次)

文章来源:http://www.OSphp.com.cn
程序介绍:
This class can be used to generate XML documents from nested arrays.

It takes an associative array and traverse it to generate a XML document on which the array keys are turned into XML tags and array entry values are nodes of the XML tags.

The XML document encoding, version, line indenting and line endings are configurable parameters.
Tags: , , ,
分页: 1/4 第一页 1 2 3 4 下页 最后页 [ 显示模式: 摘要 | 列表 ]