123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364 |
- <?php
- /**
- * This file is part of amfPHP
- *
- * LICENSE
- *
- * This source file is subject to the license that is bundled
- * with this package in the file license.txt.
- */
- /**
- * This is a test/example service. Remove it for production use
- *
- * @package Amfphp_Services
- * @author Ariel Sommeria-klein
- */
- class ExampleService {
- public function callmepleaseQ1($id,$name,$text1,$text2,$text3)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q1 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ2($id,$name,$text1,$text2,$text3,$text4)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q2 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '".$text4."', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ3($id,$name,$text1,$text2,$text3)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q3 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ4($id,$name,$text1,$text2,$text3)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q4 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ5($id,$name,$text1,$text2,$text3,$text4)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q5 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '".$text4."', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ6($id,$name,$text1,$text2,$text3,$text4)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q6 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '".$text4."', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ7($id,$name,$text1,$text2,$text3,$text4)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q7 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '".$text4."', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
-
- public function callmepleaseQ8($id,$name,$text1,$text2,$text3,$text4)
- {
-
- $dbhost = 'localhost';
- $dbuser = 'root';
- $dbpass = 'esciedu';
- $dbname = 'NeoSCORM2007data';
- $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die('Error with MySQL connection');
- mysql_query("SET NAMES 'utf8'");
- mysql_select_db($dbname);
- $sql = "INSERT INTO PS_flash_Q8 VALUES ('".$id."','".$name."', '".date('Y-m-d H:i:s')."','".$text1."', '".$text2."', '".$text3."', '".$text4."', '', '', '', '', '', '')";
- $result = mysql_query($sql) or die('MySQL query error');
-
- return $text;
-
- }
- /**
- * return one param
- * @param mixed $param example: {"_explicitType":"myType", "intVal":2, "stringVal":"bla", "arrayVal":[1,2, "ert"]}
- * @return mixed
- */
- public function returnOneParam($param) {
- return $param;
- }
- /**
- * return sum
- * @param int $number1 example: 2
- * @param int $number2 example: 3
- * @return int
- */
- public function returnSum($number1, $number2) {
- return $number1 + $number2;
- }
- /**
- * return null
- * @return null
- */
- public function returnNull() {
- return null;
- }
- /**
- * return bla
- * @return String
- */
- public function returnBla() {
- return 'bla';
- }
- /**
- * throy exception
- * @param string $arg1
- * @throws Exception
- */
- public function throwException($arg1) {
- throw new Exception("test exception $arg1", 123);
- }
- /**
- * return after one second
- * @return String
- */
- public function returnAfterOneSecond() {
- sleep(1);
- return 'slept for 1 second';
- }
- /**
- * return test header
- * @return mixed
- */
- public function returnTestHeader() {
- $header = Amfphp_Core_Amf_Handler::$requestPacket->headers[0];
- return $header->data;
- }
- /**
- * shouldn't appear in the service browser or be available as a service
- */
- public function _reservedMethod() {
-
- }
- /**
- * return array
- * @return array
- */
- public function returnArray() {
- return array(0, 1 => 2, 3 => 4, 5 => array(6 => 7));
- }
- /**
- * return opposite
- * @param boolean $value
- * @return boolean
- */
- public function returnOpposite($value) {
- return!$value;
- }
- /**
- * return bitwise and
- * @param boolean $value1
- * @param boolean $value2
- * @return boolean
- */
- public function returnBitwiseAnd($value1, $value2) {
- return ($value1 && $value2);
- }
- /**
- * static return one param
- * @param mixed $param
- * @return mixed
- */
- public static function staticReturnOneParam($param) {
- return $param;
- }
- /**
- * use to test for serialization performance. Each item contains a random int, float, and string
- * @param int $numItems example: 1000
- * @return array
- */
- public function returnLargeDataSet($numItems) {
- $ret = array();
- for ($i = 0; $i < $numItems; $i++) {
- $item = new stdClass();
- $item->int = rand(-1000, 1000);
- $item->float = rand(-1000, 1000) / 100;
- $item->string = md5(rand(-1000, 1000));
- $ret[] = $item;
-
- }
- return $ret;
- }
- /**
- * use to test Vo conversion performance. Each item contains a random int, float, and string, and is typed
- * @param int $numItems example: 1000
- * @return array
- */
- public function returnLargeTypedDataSet($numItems) {
- $ret = array();
- for ($i = 0; $i < $numItems; $i++) {
- $item = new DummyVo();
- $item->int = rand(-1000, 1000);
- $item->float = rand(-1000, 1000) / 100;
- $item->string = md5(rand(-1000, 1000));
- $ret[] = $item;
- }
- return $ret;
- }
-
- /**
- * dummy function to see how the backoffice tools react when there are many parameters.
- * @param type $a
- * @param type $b
- * @param type $c
- * @param type $d
- * @param type $e
- * @param type $f
- */
- public function manyParams($a, $b, $c, $d, $e, $f){
-
- }
-
- /**
- * simply to see if this doesn't appear in the back office, but is still callable
- * @amfphpHide
- */
- public function testAmfphpHide(){
- return "bla";
- }
-
- /**
- * receives an array(flex array collections are deserialized to arrays), and sends back an array collection.
- */
- public function testArrayCollection(array $data){
- $ret = new stdClass();
- $explicitTypeField = Amfphp_Core_Amf_Constants::FIELD_EXPLICIT_TYPE;
- $ret->$explicitTypeField = "flex.messaging.io.ArrayCollection";
- $ret->source = $data;
- return $ret;
- }
-
- /**
- * useful for testing a messy, nested typed obj
- * @param mixed $param example: {"_explicitType":"UserVo1", "name":"ariel", "status":"bla", "sub1": {"_explicitType":"Sub1", "name":"ariel", "status":"bla", "sub2": {"_explicitType":"Sub2", "name":"ariel", "status":"bla"}, "sub2again": {"_explicitType":"Sub2", "name":"ariel2", "status":"bla2"}}}
- */
- public function testComplicatedTypedObj($param){
- return $param;
- }
-
- /**
- * adds custom markers for monitoring
- */
- public function testCustomMonitorTime(){
- usleep(200000);
- AmfphpMonitor::addTime('operation 1');
- usleep(200000);
- AmfphpMonitor::addTime('operation 2');
- usleep(200000);
- AmfphpMonitor::addTime('operation 3');
- return 'bla';
- }
- }
- /**
- * dummy class
- */
- class DummyVo {}
- ?>
|