Skip to content

Commit 45d3aec

Browse files
committed
the site which is online today
0 parents  commit 45d3aec

File tree

1,525 files changed

+160589
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,525 files changed

+160589
-0
lines changed

cgi/LICENSE

+340
Large diffs are not rendered by default.

cgi/advancedsettings.php

+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<?php
2+
/**
3+
* This file defines settings regarding custom class mappings
4+
* Custom class mapping is an advanced feature that enables mapping instances of
5+
* custom Flash objects to PHP objects and vice-versa. If you want to implement
6+
* VOs (value objects) this is the perfect feature for this
7+
*
8+
* If you have no idea what a VO is chances are you don't really care about these
9+
* settings
10+
*
11+
* Most of the time you will probably want to change the outgoing settings only
12+
* since incoming mappings are done for you automatically
13+
*/
14+
15+
//One may choose to put mapped classes (incoming) outside of the services folder also
16+
$gateway->setBaseCustomMappingsPath('services/vo/');
17+
18+
//Set incoming mappings
19+
$incoming = array(
20+
//For incoming mappings to work, you need to use
21+
//Object.registerClass('com.myClass', com.myClass) in Flash
22+
//To map an instance of com.myclass to com/myclass.php, you don't have to
23+
//actually do anything, this is done automatically. To map an instance of
24+
//com.myClass to org/myOtherClass.php, uncomment the following line:
25+
//'com.myClass' => 'org.myOtherClass'
26+
//AMFPHP will call the init function (if it exists) in your class right after
27+
//instanciating it
28+
);
29+
30+
$gateway->setCustomIncomingClassMappings($incoming);
31+
32+
//Set outgoing mappings
33+
$outgoing = array(
34+
//To map an instance of a PHP class named 'MyPhpClass' (located in any folder or file)
35+
//to an ActionScript class named 'com.myproject.MyFlashClass', uncomment this line:
36+
//'myphpclass' => 'com.myproject.MyFlashClass'
37+
//Note that the left hand side is *lowercase*. This is because of the issue
38+
//in PHP4 that get_class returns the *lowercase* name of the class only.
39+
//Also note that this may be overriden if your class has a member called '_explicitType',
40+
//in which case _explicitType will be used
41+
);
42+
43+
$gateway->setCustomOutgoingClassMappings($outgoing);
44+
45+
?>
+141
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
<?php
2+
/**
3+
* RecordSetAdapter is the superclass of all database adapter implementations.
4+
*
5+
* To keep the apadters encapsulated, the getter methods have been added to
6+
* this superclass instead of direct property access. This superclass is really "abstract"
7+
* even though abstraction isn't supported until PHP5. This class must be extended
8+
* and an implementation to set the 3 properties needs to be defined.
9+
*
10+
* The implementation for setting the 3 properties can be defined either in the constructor
11+
* or by overwriting the getter methods.
12+
*
13+
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
14+
* @copyright (c) 2003 amfphp.org
15+
* @package flashservices
16+
* @subpackage adapters
17+
* @version $Id: RecordSetAdapter.php,v 1.1 2005/07/05 07:56:29 pmineault Exp $
18+
*/
19+
20+
class RecordSetAdapter {
21+
/**
22+
* The 2 dimensional array representing the recordset data
23+
*
24+
* @access private
25+
* @var array
26+
*/
27+
var $initialData = array();
28+
29+
/**
30+
* An array with the column names in the same order they appear in
31+
* the initialData object
32+
*
33+
* @access private
34+
* @var array
35+
*/
36+
var $columnNames = array();
37+
38+
/**
39+
* The number of rows in this recordset
40+
*
41+
* @access private
42+
* @var int
43+
*/
44+
var $numRows;
45+
46+
/**
47+
* The session id of the saved recordset
48+
*
49+
* @access private
50+
* @var int
51+
*/
52+
var $id;
53+
/**
54+
* Dummy constructor function.
55+
*
56+
* @param resource $d The result resource
57+
*/
58+
59+
function RecordSetAdapter ($d) {
60+
$this->_resultResource = $d;
61+
$this->_charsetHandler = new CharsetHandler('sqltophp');
62+
$this->_directCharsetHandler = new CharsetHandler('sqltoflash');
63+
$this->isBigEndian = AMFPHP_BIG_ENDIAN;
64+
}
65+
/**
66+
* Saves the full recordset into the session.
67+
*
68+
* The session is started normally to let php negotiate the automatic generation of
69+
* session id's. An array within the session is stored to make getting
70+
* multiple recordsets on the same request possible. The key of the array is
71+
* appended to the end of the session key seperated by an = sign to make
72+
* exploding simple on the return trip.
73+
*/
74+
function _saveRecordSet($paging)
75+
{
76+
if (!isset($_SESSION['amfphp_recordsets']))
77+
{ // has the session been started
78+
$_SESSION['amfphp_recordsets'] = array(); // create the recordsets array
79+
}
80+
$_SESSION['amfphp_recordsets'][] = array(
81+
"numconsumed" => min($paging['ps'], $paging['count']),
82+
"mode" => 'dynamic',
83+
"args" => $paging['args'],
84+
"method" => $paging['method'],
85+
"class" => $paging['class']
86+
);
87+
$this->id = session_id(); // start with the session id
88+
$this->id .= "=" . (count($_SESSION['amfphp_recordsets'])-1); // add the position of this recordset
89+
}
90+
/**
91+
* getter for the recordset data
92+
* If the pagesize value is set in the method table it saves the recordset
93+
* and returns a paged recordset of the stated size, otherwise it just
94+
* returns the whole recordset.
95+
*
96+
* ::TODO:: add error handling for if a session could not be created.
97+
* if no sessions are available then just dump the entire payload.
98+
*
99+
* @param int $ps The pagesize
100+
* @return array The recordset data
101+
*/
102+
function getRecordSet($paging = -1)
103+
{
104+
if ($paging != -1) {
105+
$this->_saveRecordSet($paging);
106+
return array_slice($this->initialData, 0, $paging['ps']);
107+
} else {
108+
return $this->initialData;
109+
}
110+
}
111+
112+
/**
113+
* getter for the number of rows
114+
*
115+
* @return int The number of rows
116+
*/
117+
function getRowCount () {
118+
return $this->numRows;
119+
}
120+
121+
122+
/**
123+
* getter for the column names array
124+
*
125+
* @return array The column names
126+
*/
127+
function getColumnNames () {
128+
return $this->columnNames;
129+
}
130+
131+
/**
132+
* getter for the id
133+
*
134+
* @return string The id to this result set
135+
*/
136+
function getID() {
137+
return $this->id;
138+
}
139+
}
140+
141+
?>
+111
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
/**
3+
* This Adapter translates the specific Database type links to the data and pulls the data into very
4+
* specific local variables to later be retrieved by the gateway and returned to the client.
5+
*
6+
* Correct typing for MySQL databases contributed by Patrick Gutlich
7+
*
8+
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
9+
* @copyright (c) 2003 amfphp.org
10+
* @package flashservices
11+
* @subpackage adapters
12+
* @version $Id: adodbAdapter.php,v 1.2 2005/07/22 10:58:09 pmineault Exp $
13+
*/
14+
15+
require_once(AMFPHP_BASE . "adapters/RecordSetAdapter.php");
16+
17+
class adodbAdapter extends RecordSetAdapter {
18+
/**
19+
* Constructor method for the adapter. This constructor implements the setting of the
20+
* 3 required properties for the object.
21+
*
22+
* @param resource $d The datasource resource
23+
*/
24+
25+
function adodbAdapter($d) {
26+
parent::RecordSetAdapter($d);
27+
$fieldcount = $d->FieldCount(); // grab the number of fields
28+
29+
$ob = "";
30+
$be = $this->isBigEndian;
31+
$fc = pack('N', $fieldcount);
32+
33+
if($d->RecordCount() > 0)
34+
{
35+
$d->MoveFirst();
36+
while ($line = $d->FetchRow()) {
37+
// write all of the array elements
38+
$ob .= "\12" . $fc;
39+
40+
for ($n=0; $n < $d->Fieldcount(); $n++)
41+
{
42+
$value = $line[$n];
43+
$fieldObj = $d->FetchField($n);
44+
$fieldtype = $d->MetaType($fieldObj->type);
45+
switch($fieldtype){
46+
case "C":
47+
case "X":
48+
case "D":
49+
case "T":
50+
case "B":
51+
$type = "string";
52+
break;
53+
case "N":
54+
case "I":
55+
case "R":
56+
$type = "number";
57+
break;
58+
case "L":
59+
$type = "boolean";
60+
break;
61+
}
62+
// write all of the array elements
63+
64+
if ($type=="string")
65+
{ // type as string
66+
$os = $this->_directCharsetHandler->transliterate($value);
67+
//string flag, string length, and string
68+
$len = strlen($os);
69+
if($len < 65536)
70+
{
71+
$ob .= "\2" . pack('n', $len) . $os ;
72+
}
73+
else
74+
{
75+
$ob .= "\14" . pack('N', $len) . $os;
76+
}
77+
}
78+
79+
elseif ($type=="number")
80+
{ // type as double
81+
$b = pack('d', $value); // pack the bytes
82+
if ($be) { // if we are a big-endian processor
83+
$r = strrev($b);
84+
} else { // add the bytes to the output
85+
$r = $b;
86+
}
87+
$ob .= "\0" . $r;
88+
}
89+
elseif ($type=="boolean")
90+
{ //type as bool
91+
$ob .= "\1";
92+
$ob .= pack('c', $value);
93+
}
94+
elseif (is_null($value))
95+
{ // null
96+
$ob .= "\5";
97+
}
98+
}
99+
}
100+
}
101+
$this->serializedData = $ob;
102+
103+
for($i = 0; $i < $fieldcount; $i++) { // loop over all of the fields
104+
$fld = $d->FetchField($i);
105+
$this->columnNames[] = $this->_directCharsetHandler->transliterate($fld->name);
106+
}
107+
$this->numRows = $d->RecordCount();
108+
}
109+
}
110+
111+
?>
+95
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
<?php
2+
/**
3+
* The arrayf adapter is a filtered mySQL adapter riggged
4+
* to only transmit certain column names. Must be typed manually.
5+
*
6+
* @license http://opensource.org/licenses/gpl-license.php GNU Public License
7+
* @copyright (c) 2003 amfphp.org
8+
* @package flashservices
9+
* @subpackage adapters
10+
* @version $Id: mysqlfAdapter.php,v 1.1 2005/07/05 07:56:29 pmineault Exp $
11+
*/
12+
13+
require_once(AMFPHP_BASE . "adapters/RecordSetAdapter.php");
14+
15+
class arrayfAdapter extends RecordSetAdapter {
16+
/**
17+
* Constructor method for the adapter. This constructor implements the setting of the
18+
* 3 required properties for the object.
19+
*
20+
* @param resource $d The datasource resource
21+
*/
22+
23+
function arrayfAdapter($d) {
24+
25+
$f = $d->filter;
26+
$d = $d->data;
27+
28+
parent::RecordSetAdapter($d);
29+
30+
$fieldcount = count($f);
31+
$be = $this->isBigEndian;
32+
33+
$this->columnNames = $f;
34+
35+
//Start fast serializing
36+
$ob = "";
37+
$fc = pack('N', $fieldcount);
38+
39+
if(count($d) > 0)
40+
{
41+
$line = $d[0];
42+
do {
43+
//Write array flag + length
44+
$ob .= "\12" . $fc;
45+
46+
$i = 0;
47+
foreach($f as $key)
48+
{
49+
$value = $line[$key];
50+
51+
if (is_string($value))
52+
{ // type as string
53+
$os = $this->_directCharsetHandler->transliterate($value);
54+
//string flag, string length, and string
55+
$len = strlen($os);
56+
if($len < 65536)
57+
{
58+
$ob .= "\2" . pack('n', $len) . $os;
59+
}
60+
else
61+
{
62+
$ob .= "\14" . pack('N', $len) . $os;
63+
}
64+
}
65+
elseif (is_double($value) || is_int($value))
66+
{ // type as double
67+
$b = pack('d', $value); // pack the bytes
68+
if ($be) { // if we are a big-endian processor
69+
$r = strrev($b);
70+
} else { // add the bytes to the output
71+
$r = $b;
72+
}
73+
$ob .= "\0" . $r;
74+
}
75+
elseif (is_bool($value))
76+
{ //type as bool
77+
$ob .= "\1";
78+
$ob .= pack('c', $value);
79+
}
80+
elseif (is_null($value))
81+
{ // null
82+
$ob .= "\5";
83+
}
84+
85+
$i++;
86+
}
87+
} while($line = next($d));
88+
}
89+
90+
$this->numRows = count($d);
91+
$this->serializedData = $ob;
92+
}
93+
}
94+
95+
?>

0 commit comments

Comments
 (0)