Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Recently, ESET add my domain name to the black-list of their database. You can’t open my site and been warned my site is not safe if your PC is running the ESS or EAV. Why Eset block my site?The answer is obvious. That is reason that you come here. I promise that my site is pure, no virus, no spyware, no Trojan, no pop ads. You can test my word through intalling Kaspersky or other Antivirus Software. If you want open my site and take latest escalation ID & Activation Code, close your ESET software(disable antivirus and antispyware protection function temporarily) or by proxy or virtual machinor. You can also feed the RSS source http://feed.loserblog.cn.
Archive
The path way paging category – Pager:: Pathing ()
A recent project, the path way with the performance of pages url:
http://www.foo.com/index.php/p/user:photo
http://www.foo.com/index.php/p/user:photo/page/1
http://www.foo.com/index.php/p/user:photo/page/2
Normal pages url:
http://www.foo.com/index.php?p=user:photo
http://www.foo.com/index.php?p=user:photo&page=1
http://www.foo.com/index.php?p=user:photo&page=2
Before the use of paging is the Pear: Pager, at this time on the Wan Buzhuan, no matter how to adjust the parameters page link is always wrong, then wrote a Pathing.php, devoted to the path way paging, call methods :
PLAIN TEXT
PHP:
1.
$ pager = Pager:: factory (array ( 'mode' => 'Pathing'));
Pager / Pathing.php
PLAIN TEXT
PHP:
1.
require_once ( 'Pager / Jumping.php');
2.
3.
class Pager_Pathing extends Pager_Jumping (
4.
5.
/ **
6.
* @ See Pager_Common:: _setOptions ()
7.
* /
8.
function _setOptions ($ options) (
9.
$ allowed_options = array (
10.
'totalItems',
11.
'perPage',
12.
'delta',
13.
'linkClass',
14.
'path',
15.
'fileName',
16.
'append',
17.
'httpMethod',
18.
'importQuery',
19.
'urlVar',
20.
'altPrev',
21.
'altNext',
22.
'altPage',
23.
'prevImg',
24.
'nextImg',
25.
'expanded',
26.
'separator',
27.
'spacesBeforeSeparator',
28.
'spacesAfterSeparator',
29.
'curPageLinkClassName',
30.
'curPageSpanPre',
31.
'curPageSpanPost',
32.
'firstPagePre',
33.
'firstPageText',
34.
'firstPagePost',
35.
'lastPagePre',
36.
'lastPageText',
37.
'lastPagePost',
38.
'firstLinkTitle',
39.
'nextLinkTitle',
40.
'prevLinkTitle',
41.
'lastLinkTitle',
42.
'showAllText',
43.
&n
bsp; 'itemData',
44.
'clearIfVoid',
45.
'useSessions',
46.
'closeSession',
47.
'sessionVar',
48.
'pearErrorMode',
49.
'extraVars',
50.
'excludeVars',
51.
'currentPage',
52.
);
53.
54.
foreach ($ options as $ key => $ value) (
55.
if (in_array ($ key, $ allowed_options) & & (! is_null ($ value))) (
56.
$ this->{'_'. $ key) = $ value;
57.
)
58.
)
59.
60.
$ this-> _fileName = ltrim ($ this-> _fileName,'/'); / / strip leading slash
61.
$ this-> _path = rtrim ($ this-> _path,'/'); / / strip trailing slash
62.
63.
if ($ this-> _append) (
64.
$ this-> _fileName = CURRENT_FILENAME; / / avoid possible user error;
65.
$ this-> _url = $ this-> _path .'/'.$ this-> _fileName;
66.
) Else (/ / hacked for pathing pager
67.
$ this-> _url = $ this-> _path;
68.
if (strncasecmp ($ this-> _fileName, 'javascript', 10)! = 0)
69.
$ this-> _url .= '/';
70.
71.
$ len = strlen ($ this-> _urlVar);
72.
if ((substr ($ this-> _path, – $ len, $ len) == $ this-> _urlVar) and
73.
is_numeric (CURRENT_FILENAME))
74.
$ this-> _url = substr ($ this-> _path, 0, – $ len);
75.
else
76.
$ this-> _url .= CURRENT_FILENAME. '/';
77.
78.
if (! strstr ($ this-> _fileName, '% d'))
79.
trigger_error ($ this-> errorMessage (ERROR_PAGER_INVALID_USAGE), E_USER_WARNING);
80.
)
81.
82.
$ this-> _classString ='';
83.
if (strlen ($ this-> _linkClass)) (
84.
$ this-> _classString = 'class ="'.$ this-> _linkClass .'"';
85.
)
86.
87.
if (strlen ($ this-> _curPageLinkClassName)) (
88.
$ this-> _curPageSpanPre = '<span class="'.$this-> _curPageLinkClassName .'">';
89.
$ this-> _curPageSpanPost = '</ span>';
90.
)
91.
92.
$ this-> _perPage = max ($ this-> _perPage, 1); / / avoid possible user errors
93.
94.
if ($ this-> _useSessions & &! isset ($ _SESSION)) (
95.
session_start ();
96.
)
97.
if (! empty ($ _REQUEST [$ this-> _sessionVar])) (
98.
$ this-> _perPage = max (1, (int) $ _REQUEST [$ this-> _sessionVar]);
99.
 
; if ($ this-> _useSessions) (
100.
$ _SESSION [$ This-> _sessionVar] = $ this-> _perPage;
101.
)
102.
)
103.
104.
if (! empty ($ _SESSION [$ this-> _sessionVar])) (
105.
$ this-> _perPage = $ _SESSION [$ this-> _sessionVar];
106.
)
107.
108.
if ($ this-> _closeSession) (
109.
session_write_close ();
110.
)
111.
112.
$ this-> _spacesBefore = str_repeat ( '', $ this-> _spacesBeforeSeparator);
113.
$ this-> _spacesAfter = str_repeat ( '', $ this-> _spacesAfterSeparator);
114.
115.
$ request = ($ this-> _httpMethod == 'POST')? $ _POST: $ _GET;
116.
if (isset ($ request [$ this-> _urlVar]) & & empty ($ options [ 'currentPage'])) (
117.
$ this-> _currentPage = (int) $ request [$ this-> _urlVar];
118.
)
119.
$ this-> _currentPage = max ($ this-> _currentPage, 1);
120.
$ this-> _linkData = $ this-> _getLinksData ();
121.
122.
return PAGER_OK;
123.
)
124.
125.
)
Calling examples:
PLAIN TEXT
PHP:
1.
require 'Pager / Pager.php';
2.
$ opt = array (
3.
'mode' => 'Pathing',
4.
'totalItems' => $ totalItems,
5.
'perPage' => $ perPage,
6.
'append' => false,
7.
'fileName' => 'page /% d',
8.
'urlVar' => 'page',
9.
);
10.
11.
$ pager = Pager:: factory ($ opt);
12.
$ links = $ pager-> getLinks ();
php + ajax file upload progress bar
Find an article PHP AJAX File Upload Progress Meter Updates, on how to use php Pear: HTML_AJAX produced with the progress of the file upload, Below are the upload when I test the diagram
ajax with the progress of the upload
Code is divided into the following sections:
demo.php – dealing with the upload process
PLAIN TEXT
PHP:
1.
<? php
2.
3.
include 'UploadProgressMeter.class.php';
4.
5.
$ fileWidget = new UploadProgressMeter ();
6.
7.
if ($ fileWidget-> uploadComplete ()) (
8.
/ / Upload the end of the time, send a js from the iframe to the main window that all ok
9.
echo $ fileWidget-> finalStatus ();
10.
11.
/ / Handling upload the file …
12.
13.
exit;
14.
)
15.
«>
demoserver.php – ajax service-js, the use of Pear: HTML_AJAX, direct call UploadProgressMeterStatus category
PLAIN TEXT
HTML:
1.
<script src="http://www.ooso.net/demoserver.php?client=main,request,httpclient,dispatcher,json,util" type="text/javascript"> </ script>
2.
<script src="http://www.ooso.net/demoserver.php?stub=UploadProgressMeterStatus" type="text/javascript"> </ script>
3.
<? php echo $ fileWidget-> renderIncludeJs ();?>
The progress of the style sheet
PLAIN TEXT
CSS:
1.
. progressBar (
2.
position: relative;
3.
padding: 2px;
4.
width: 300px;
5.
height: 40px;
6.
font-size: 14px;
7.
)
8.
. progressBar. background (
9.
border: solid 1px black;
10.
width: 270px;
11.
height: 20px;
12.
)
13.
. progressBar. bar (
14.
position: relative;
15.
background-color: blue;
16.
width: 0px;
17.
height: 20px;
18.
)
Form part of
PLAIN TEXT
HTML:
1.
<form action="demo.php" method="post" enctype="multipart/form-data"> renderFormExtra ();?>>
2.
<? php echo $ fileWidget-> renderHidden ();?> </ form> <form action="demo.php" method="post" enctype="multipart/form-data"> <label> Select File: </ label>
3.
<div> <? php echo $ fileWidget-> render ();?>
4.
<? php echo $ fileWidget-> renderProgressBar ();?> </ div>
5.
</ form>
demo downloads – the password is www.ooso.net
The author's visit svn
Other similar projects:
http://pdoru.from.ro/ – to the form and to patch together compile php
http://www.ugia.cn/?p=54 – socket to upload files and show the progress of the
Upload files using http_request
Sometimes we had hope that with their feet to the remote automatic automatically added in the form of a file upload, using curl module may be a way, but the direct use of pear http_request may be a more convenient way, the simple example:
PLAIN TEXT
PHP:
1.
require_once "HTTP / Request.php";
2.
3.
$ req = & new HTTP_Request ( "http://upload.example.com/upload.php");
4.
$ req-> setBasicAuth ( "johndoe", "foo");
5.
$ req-> setMethod (HTTP_REQUEST_METHOD_POST);
6.
7.
$ result = $ req-> addFile ( "foo.jpg", "/ home / foo / foo.jpg");
8.
if (PEAR:: isError ($ result)) (
9.
echo $ result-> getMessage ();
10.
) Else (
11.
12.
$ response = $ req-> sendRequest ();
13.
14.
if (PEAR:: isError ($ response)) (
15.
echo $ response-> getMessage ();
16.
) Else (
17.
echo $ req-> getResponseBody ();
18.
)
19.
)
Php will use rss format into json
Php should be converted into rss json, the conversion idea is simple:
rss -> php array -> json
We do not have to carry out such work from scratch, pear has already provided some of the available class libraries, to use the command line below pear install these packages
pear install channel: / / pear.php.net/XML_RSS-0.9.9
pear install channel: / / pear.php.net/HTML_AJAX-0.4.0
Below is a simple test code:
PLAIN TEXT
PHP:
1.
<? php
2.
require_once 'XML / RSS.php';
3.
require 'HTML / AJAX / JSON.PHP';
4.
5.
$ rss = new XML_RSS ( 'http://www.ooso.net/index.php/feed/');
6.
$ rss-> parse ();
7.
/ / var_dump ($ rss-> getItems ());
8.
9.
$ json = new HTML_AJAX_JSON ();
10.
$ js = $ json-> encode ($ rss-> getItems ());
11.
12.
echo $ js;
13.
«>
Pear:: DB_Table Profile
What is DB_Table »
DB_Table is a visit to the database Table OO interface, it provides a number of automatically create, insert, update and the method of choice. Construction is often automatically mean the loss of some flexibility, DB_Table is no exception.
Installation
pear procedures for the installation of no concern
pear install DB_Table
DB_Table fly
Official recommendation not to introduce the direct use of DB_Table Class, but it was extended, on top of the definition in this field, index, view, etc. other custom content. Below to see how the DB_Table expansion.
For example:
PLAIN TEXT
PHP:
1.
<? php
2.
class Guestbook extends DB_Table (
3.
/ / Later added We'll add more here later in the tutorial,
4.
/ / Note that no structural function but for now this is all we need.
5.
)
6.
«>
Then, an instance of Guestbook
PLAIN TEXT
PHP:
1.
<? php
2.
/ / Must be the class
3.
require_once 'DB.php';
4.
require_once 'DB / Table.php';
5.
require_once 'Guestbook.php';
6.
7.
/ / Create a PEAR DB object
8.
$ dsn = "phptype: / / username: password @ localhost / database";
9.
$ db = DB:: connect ($ dsn);
10.
11.
/ / Set up for the Guestbook and create it, connecting
12.
/ / To a table called 'guestbook' (which does not exist
13.
/ / Yet, we'll get to that in the next section)
14.
$ book = & new Guestbook ($ db, 'guestbook'); / / note the "= &" (very important!)
15.
«>
PEAR_Error can use to see if there is any fault
PLAIN TEXT
PHP:
1.
<? php
2.
if ($ book-> error) (
3.
/ / Error handling code goes here; for example …
4.
5.
print_r ($ book-> error);
6.
7.
/ / … Although that's probably a bad idea as it will print
8.
/ / Your database username and password.
9.
)
10.
«>
Below see how detailed definition Guestbook category, this example of the definition of the various fields guestbook table type:
PLAIN TEXT
PHP:
1.
<? php
2.
class Guestbook extends DB_Table (
3.
var $ col = array (
4.
5.
/ / Unique row ID
6.
'id' => array (
7.
'type' => 'integer',
8.
'require' => true
9.
),
10.
11.
/ / First name
12.
'fname' => array (
13.
'type' => 'varchar',
14.
'size' => 32
15.
),
16.
17.
/ / Last name
18.
'lname' => array (
19.
'type' => 'varchar',
20.
'size' => 64
21.
),
22.
23.
/ / Email address
24.
'email' => array (
25.
'type' => 'varchar',
26.
'size' => 128,
27.
'require' => true
28.
),
29.
30.
/ / Date-time signed
31.
'signdate' => array (
32.
'type' => 'date',
33.
'require' => true
34.
)
35.
);
36.
«>
To further define guestbook table index, this can be:
PLAIN TEXT
PHP:
1.
<? php
2.
class Guestbook extends DB_Table (
3.
4.
/ / Snip: var $ col = array (…); this part of the contents of that period and above, omitting
5.
6.
var $ idx = array (
7.
'id' => array (
8.
'type' => 'unique',
9.
'cols' =>' id '
10.
),
11.
'signdate' => array (
12.
'type' => 'normal',
13.
'cols' =>' signdate '
14.
)
15.
);
16.
)
17.
«>
If the index and field names are the same, but not many fields index, the above definition can be simplified as follows:
PLAIN TEXT
PHP:
1.
<? php
2.
var $ idx = array (
3.
/ / Unique index called 'id' based on the 'id' column
4.
'id' => 'unique',
5.
6.
/ / Normal index called 'signdate' based on the 'signdate' column
7.
'signdate' => 'normal'
8.
);
9.
«>
Definition of a good table structure, we look at how to carry out enquiries, looks very simple, no traces of sql statement:
PLAIN TEXT
PHP:
1.
<? php
2.
/ / [Snip] create the $ book Guestbook object
3.
4.
/ / Get the 'list' view as an array
5.
$ rows = $ book-> select ( 'list');
6.
print_r ($ rows);
7.
8.
/ / Get the 'emails' view as a DB_Result object
9.
$ result = $ book-> selectResult ( 'emails');
10.
print_r ($ result);
11.
12.
«>
The conditions for:
PLAIN TEXT
PHP:
1.
<? php
2.
3.
/ / [Snip] create the $ book Guestbook object
4.
5.
/ / Get 'list' view rows signed on August 14, 2003, ordered ascending by
6.
/ / Last name and first name, starting at row 7 and getting 12 rows total.
7.
8.
$ view = 'list';
9.
$ filter = "signdate ='2003-08-14 '";
10.
$ order = 'lname, fname';
11.
$ start = 7;
12.
$ count = 12;
13.
14.
/ / As an array
15.
$ rows = $ book-> select ($ view, $ filter, $ order, $ start, $ count);
16.
print_r ($ rows);
17.
18.
/ / As a DB_Result object
19.
$ rows = $ book-> selectResult ($ view, $ filter, $ order, $ start, $ count);
20.
print_r ($ result);
21.
22.
«>
Insert data
PLAIN TEXT
PHP:
1.
<? php
2.
3.
/
/ [Snip] create the Guestbook object ($ book)
4.
5.
/ / Assign the fields and values
6.
$ cols_vals = array (
7.
'id' => 1,
8.
'fname' => 'Thomas',
9.
'lname' => 'Anderson',
10.
'signdate' =>'2003-10-12 ',
11.
'email' => 'neo@matrix.net'
12.
);
13.
14.
/ / Insert into the table and print results
15.
$ result = $ book-> insert ($ cols_vals);
16.
print_r ($ result);
17.
18.
«>
Data Update
PLAIN TEXT
PHP:
1.
<? php
2.
3.
/ / [Snip] create the Guestbook object ($ book)
4.
5.
/ / Assign the updated fields and values
6.
$ cols_vals = array (
7.
'lname' => 'Jones'
8.
);
9.
10.
/ / Assign the Where clause
11.
$ where = "lname = 'Smith'";
12.
13.
/ / Attempt the update and print the results
14.
$ result = $ book-> update ($ cols_vals, $ where);
15.
print_r ($ result);
16.
17.
«>
Data
PLAIN TEXT
PHP:
1.
<? php
2.
3.
/ / [Snip] create the Guestbook object ($ book)
4.
5.
/ / A where clause
6.
$ today = date ( 'Ym-d'); / / formatted as yyyy-mm-dd
7.
$ where = "signdate < '$ today'";
8.
9.
/ / Attempt the delete and print the results
10.
$ result = $ book-> delete ($ where);
11.
print_r ($ result);
12.
13.
«>
In the above example has not too many traces of the sql statements, which can be simplified to a certain extent, in the process of developing the sql statements prepared, but still sentence, automation to reduce the flexibility in the use of DB_Table need to weigh before .
Reference
http://wiki.ciaweb.net/yawiki/index.php?area=DB_Table&page=HomePage
Download source
http://pear.php.net/package/DB_Table
Pear from the command line
Pear PHP is the expansion and application of the ( "PHP Extension and Application Repository") stands for, it is not a Pear attention, even though the pronunciation and the same fruit. Php in installed, a default under the pear will automatically install the part of the process, let us look at such cases on their own how to install more applications library.
Automatic installation
Very simple, just his party.
PLAIN TEXT
CODE:
1.
pear install <package>
<package> should you want to install the library, you may be able to stand on the Pear here, quite rich. Can also use the command line directly see:
pear remote-list
Tip: Use "- o" parameter can automatically install the necessary dependence on the application.
Manually install
If you stand directly in the pear download the gzip the installation package, you can use this form of installation. pear will automatically install the application library, no longer link to the Internet to download.
PLAIN TEXT
CODE:
1.
pear install <file>. tgz
order list
Command Description
build Build the extension
from source
bundle Download and unpack
a PECL extension
channel-add Add a Channel (PEAR
1.4 +)
channel-alias Specify an alias to
a channel name (PEAR 1.4 +)
channel-delete Remove a channel
from the list (PEAR 1.4 +)
channel-discover Initialize a channel
from its server name (PEAR 1.4 +)
channel-info Retrieve information
on a channel (PEAR 1.4 +)
channel-update Update an existing
channel (PEAR 1.4 +)
clear-cache Clear the XML-RPC
cache
config-create Create a default
configuration file (PEAR 1.4 +)
config-get Echo a specific
configuration setting
config-help Show information
about a setting
config-set Set a specific
configuration setting value
config-show Show all
configuration setting values
convert Convert a
package.xml 1.0 format to package.xml 2.0 format
(PEAR 1.4 +)
cvsdiff Execute and display
a "cvs diff-u" on all files
within the package
cvstag Set a CVS release
tag
download Download a package
but not install it
download-all Downloads every
available package
info Display information
about a package
install Install a package,
will report with success or failure
list List installed
packages
list-all List all packages,
packaged and / or available
list-channels List available
channels (PEAR 1.4 +)
list-files List files in an
installed package (PEAR 1.4 +)
list-upgrades List available
upgrades for the installed packages
login Connects and
authenticates to the remote PEAR server
logout Logs out from the
remote PEAR server
makerpm Builds a RPM spec
file from a PEAR package
package Build a package
package-dependencies Show package
dependencies
package-validate Validate package
consistency
remote-info Information about
remote packages
remote-list List remote
packages
run-scripts Run post-install
scripts bundled with a package (PEAR 1.4 +)
run-tests Run regression
tests
search Search the remote
package database
shell-test Do a shell script
test
sign Sign a package
distribution file
uninstall Uninstall and remove
a package
update-channels Update the channel
list (PEAR 1.4 +)
upgrade Upgrade a package to
the current version (see also: preferred_state)
upgrade-all Upgrade all packages
(see also: list-upgrades)
No handlers for package.xml version 2.0
Try to install in a host of DB_Table Pear
pear install-o DB_Table
Download………………………… such as the Banshang, downloaded after the success of this should be installed, lost by one:
No handlers for package.xml version 2.0
This is a very strange thing, php the xml extension with no less, dependent on the package nor the shortage of it, how it can be like that »search of the one in the Faq Pear above to find the answer.
Why do I get "No handlers for package.xml version 2.0" when I try to install a package?
You are using a PEAR version lower than 1.4.0.
To install the package, you have to update PEAR via:
$ Pear upgrade PEAR
This will install the latest available version of PEAR which is capable of installing packages that have only a package.xml version 2.0.
1.4.11 Pear for the upgrade, the issue is resolved.
Pear:: Pager and the integration of AJAX applicat
As a PHP developers, probably very people the benefit of a Dongdong Pear is a class library. We know that, Pear:: Pager is dedicated to paging, and the Pear:: HTML_AJAX is Ajax application of some class library. But Pager also is not just only for the html page links, than it has for the Super Girls also red Ajax prepared for, the following look at how to integrate these two packages application.
Pager and Javascript
Now take the first step, Pager has been able to build a javascript links, and the integration of Ajax, in theory, should also be realized, and Pager Below is an example of javascript page:
PLAIN TEXT
PHP:
1.
require_once 'Pager / Pager.php';
2.
$ data = range (1, 100); / / an array of data to paginate
3.
$ pager_params = array (
4.
'mode' => 'Sliding',
5.
'append' => false, / / don't append the GET parameters to the url
6.
'path' =>'',
7.
'fileName' => 'javascript: revealDiv (% d)', / / Pager replaces "% d" with the page number …
8.
'perPage' => 10, / / show 10 items per page
9.
'delta' => 5,
10.
'itemData' => $ data,
11.
);
12.
$ pager = & Pager:: factory ($ pager_params);
13.
$ n_pages = $ pager-> numPages ();
14.
$ links = $ pager-> getLinks ();
15.
«>
16.
<html>
17.
<head>
18.
<script type="text/javascript" language="javascript">
19.
var n_pages = <? php echo $ n_pages?>;
20.
function revealDiv (n)
21.
(
22.
for (var count = 1; count <= n_pages; count + +) (
23.
document.getElementById ( "page" + count). style.display = 'none';
24.
)
25.
document.getElementById ( "page" + n). style.display = 'block';
26.
)
27.
</ script>
28.
<style type="text/css">
29.
div.page (
30.
background: # FFFF99;
31.
border-top: 1px solid # FFBF99;
32.
border-bottom: 1px solid # FFBF99;
33.
)
34.
</ style>
35.
</ head>
36.
<body>
37.
<h1> PEAR:: Pager example with JavaScript </ h1>
38.
<? php echo $ links [ 'pages'];?>
39.
<hr />
40.
<? php
41.
for ($ i = 1; $ i <= $ n_pages; + + $ i) (
42.
echo '<div class="page" id="page'.$i.'">';
43.
echo '<h2> Page'. $ i. '</ h2>';
44.
foreach ($ pager-> getPageData ($ i) as $ item) (
45.
echo 'Item'. $ item. '<br />';
46.
)
47.
echo '</ div>';
48.
)
49.
«>
50.
<hr />
51.
<script type="text/javascript" language="javascript">
52.
revealDiv (1);
53.
</ script>
54.
</ body>
55.
</ html>
In the example of all the data page into a div tag, the definition of the two parameters is more important path (empty) and fileName, fileName should be a link to the original file name, but here to replace the javascript.
Ajax battle
The examples include three documents page.html, server.php, testdata.php
# Page.html
Dynamic javascript – server.php to deal with data, call HTML_AJAX.replace ( 'target', 'testdata.php') to replace div id for the content of this target.
PLAIN TEXT
PHP:
1.
<html>
2.
<body>
3.
<h1> PEAR:: Pager example with AJAX </ h1>
4.
5.
<script type="text/javascript" src="server.php?client=all"> </ script>
6.
7.
<div id="target
4;> I'm the target </ div>
8.
9.
<script type="text/javascript">
10.
HTML_AJAX.replace ( 'target', 'testdata.php');
11.
</ script>
12.
13.
</ body>
14.
</ html>
# Testdata.php
This is a very simple php procedures, to take data and paging output html
PLAIN TEXT
PHP:
1.
<? php
2.
require_once 'Pager / Pager.php';
3.
$ data = range (1, 100); / / an array of data to paginate
4.
$ pager_params = array (
5.
'mode' => 'Sliding',
6.
'append' => false, / / don't append the GET parameters to the url
7.
'path' =>'',
8.
'fileName' => 'javascript: HTML_AJAX.replace (\' target \ ', \' testdata.php? pageID =% d \');', / / Pager replaces "% d" with the page number …
9.
'perPage' => 10, / / show 10 items per page
10.
'delta' => 1,
11.
'itemData' => $ data,
12.
);
13.
$ pager = & Pager:: factory ($ pager_params);
14.
$ n_pages = $ pager-> numPages ();
15.
$ links = $ pager-> getLinks ();
16.
echo '<p> This container is loaded with an AJAX call </ p>';
17.
echo '<p> <span class="datetime"> DateTime:'. date ( 'Ymd H: i: s').' </ span> </ p> ';
18.
echo '<h3> Page'. $ pager-> getCurrentPageId (). '</ h3>';
19.
foreach ($ pager-> getPageData () as $ item) (
20.
echo 'Item'. $ item. '<br />';
21.
)
22.
echo '<hr />'. $ pager-> links;
23.
«>
# Finally, paste the code behind the scenes workers server.php
HTML_AJAX_Server used to deal with these Fan Xinshi it ajax
PLAIN TEXT
PHP:
1.
<? php
2.
include 'HTML / AJAX / Server.php';
3.
4.
$ server = new HTML_AJAX_Server ();
5.
$ server-> handleRequest ();
6.
«>
web 2.0, Ajax of the trends
The current concept of web 2.0 and Ajax is in full swing, and whether this Dongdong Ajax in the end is not the product of speculation, for the practical application, Ajax on certain occasions is indeed the top looks very cool and useful.
Blue is the web 2.0, Ajax is the redhttp://www.google.com/trends/viz?q=web +2.0, ajax & date = all & geo = all & graph = weekly_img & sa = N ” border=”0″ alt=”"/>
Pear package of PHP_Compat
Pear's PHP_Compat is a relatively interesting package, it provided some php4 under php5 can also use the proprietary function, such as file_put_contents, array_combine, str_split ………. so even in php4 the host, In advance can enjoy the convenience of one point php5 function.
Usage
PLAIN TEXT
PHP:
1.
<? php
2.
require_once 'PHP / Compat.php';
3.
4.
/ / Load file_put_contents
5.
PHP_Compat:: loadFunction ( 'file_put_contents');
6.
7.
/ / Load str_split, array_chunk and file_get_contents
August.
PHP_Compat:: loadFunction (array ( 'str_split', 'array_chunk', 'file_get_contents'));
9.
«>
The above examples illustrate, you can load a specific function of n php5
Package Information: PHP_Compat
http://pear.php.net/package/PHP_Compat
Create a local pear
In some host, you may not modify the system's default installation of pear competence, but also want to install their own pear packages. Under such circumstances there are simple ways to achieve:
First of all in their own home under a pear create a profile. Pearrc:
$ Pear config-create $ HOME. Pearrc
If all goes well, the next step directly, or else run the following order:
$ Pear config-set download_dir / home / (username) / tmp / pear / cache
$ Pear config-set cache_dir / home / (username) / tmp / pear / cache
$ Pear config-set temp_dir / home / (username) / tmp / pear / temp
Then you can start the installation of pear, pear will be linked to the installation of a reliance on paper:
$ Pear install-o PEAR
After this step, pear installation is complete, if you want to install other package, then:
$ Pear install pear / PackageName
So you have a pear own customized package, in order to call in the proceedings of these pear, thank you need to write some additional code, after all, the code is not in your include_path.
php4
PLAIN TEXT
CODE:
1.
ini_set (
2.
'include_path',
3.
ini_get ( 'include_path'). PATH_SEPARATOR. "/ home / (youruser) / pear / php"
4.
);
php5
PLAIN TEXT
CODE:
1.
set_include_path (
2.
get_include_path ().
3.
PATH_SEPARATOR. '/ Home / (youruser) / pear / php'
4.
);