Skip to content
Browse files

full source init from svn

  • Loading branch information...
1 parent 40168fe commit d6a60020bdc885b5be66ed2fefd8b9641aa54354 @iwater committed Apr 23, 2009
Showing with 9,573 additions and 0 deletions.
  1. +58 −0 Application.php
  2. +41 −0 ApplicationCache.php
  3. +24 −0 Class.php
  4. +8 −0 Compatible/BasePage.php
  5. +5 −0 Compatible/BaseTableObject.php
  6. +3 −0 Compatible/Chinese.php
  7. +1,074 −0 Compatible/CordaEmbedder.php
  8. +3 −0 Compatible/HessianClient.php
  9. +3 −0 Compatible/HessianService.php
  10. +3 −0 Compatible/Pagination.php
  11. +3 −0 Compatible/Smarty.php
  12. +3 −0 Compatible/SqlCommand.php
  13. +3 −0 Compatible/htmlMimeMail5.php
  14. +83 −0 Controller.php
  15. +35 −0 Controller/Ajax.php
  16. +56 −0 Controller/Brower.php
  17. +37 −0 Controller/Cli.php
  18. +33 −0 Controller/Hessian.php
  19. +86 −0 Controller/JSON.php
  20. +29 −0 Controller/PHP.php
  21. +50 −0 Data/DataSet/Schema/Database.php
  22. +44 −0 Data/DataSet/Schema/XML.php
  23. +124 −0 DataObject.php
  24. +202 −0 DistributedFileSystem.php
  25. +58 −0 Exception.php
  26. +83 −0 Filter.php
  27. +29 −0 Filter/Cache.php
  28. +20 −0 Filter/OB.php
  29. +23 −0 Filter/Session.php
  30. +36 −0 Filter/StorageCookie.php
  31. +19 −0 Filter/StorageSession.php
  32. +17 −0 Filter/User.php
  33. +213 −0 Framework/Config.php
  34. +25 −0 Framework/Context.php
  35. +47 −0 Framework/Registry.php
  36. +16 −0 Framework/Storage.php
  37. +1 −0 Framework/config.xml
  38. +13 −0 Interface/Runnable.php
  39. +13 −0 Interface/User.php
  40. +96 −0 KDO/MsSqlCommand.php
  41. +105 −0 KDO/MySqlCommand.php
  42. +116 −0 KDO/PostgreSqlCommand.php
  43. +228 −0 KDO/SqlCommand.php
  44. +64 −0 KDO/SqlCommandIterator.php
  45. +95 −0 KISS.php
  46. +12 −0 NULLObject.php
  47. +383 −0 ORM/BaseTableAdmin.php
  48. +594 −0 ORM/BaseTableObject.php
  49. +24 −0 ORM/BaseTableObjectProxy.php
  50. +378 −0 ORM/BaseViewObject.php
  51. +60 −0 Object.php
  52. +160 −0 PDOSqlCommand.php
  53. +99 −0 PDO_MySqlCommand.php
  54. +143 −0 Page.php
  55. +90 −0 Parse.php
  56. +32 −0 Proxy.php
  57. +24 −0 ProxyFactory.php
  58. +88 −0 SQLObject.php
  59. +161 −0 Tools/Builder.php
  60. +4 −0 Tools/Builder/template/base/tpl.BaseTableAdmin.htm
  61. +1 −0 Tools/Builder/template/base/tpl.base_delete.htm
  62. +29 −0 Tools/Builder/template/base/tpl.base_insert.htm
  63. +27 −0 Tools/Builder/template/base/tpl.base_list.htm
  64. +29 −0 Tools/Builder/template/base/tpl.base_search.htm
  65. +22 −0 Tools/Builder/template/base/tpl.base_select.htm
  66. +26 −0 Tools/Builder/template/base/tpl.base_update.htm
  67. +13 −0 Tools/Builder/template/base/tpl.class.manager.htm
  68. +42 −0 Tools/Builder/template/base/tpl.class.mapping.htm
  69. +42 −0 Tools/Builder/template/base/tpl.class.view.mapping.htm
  70. +1 −0 Tools/Builder/template/base/tpl.input.date.htm
  71. +1 −0 Tools/Builder/template/base/tpl.input.file.htm
  72. +2 −0 Tools/Builder/template/base/tpl.input.file.insert.htm1
  73. +1 −0 Tools/Builder/template/base/tpl.input.password.htm
  74. +4 −0 Tools/Builder/template/base/tpl.input.select.htm
  75. +1 −0 Tools/Builder/template/base/tpl.input.text.htm
  76. +1 −0 Tools/Builder/template/base/tpl.input.textarea.htm
  77. +51 −0 Tools/Builder/template/tpl.config.htm
  78. +2 −0 Tools/Builder/template/tpl.footer.htm
  79. +15 −0 Tools/Builder/template/tpl.guide.htm
  80. +12 −0 Tools/Builder/template/tpl.header.htm
  81. +51 −0 Tools/Builder/template/tpl.list.htm
  82. +7 −0 Tools/Builder/template/tpl.menu.htm
  83. +28 −0 Tools/Builder/template/tpl.show.htm
  84. +52 −0 Tools/Clean.php
  85. +20 −0 Tools/Compiler.php
  86. +24 −0 Tools/Debug.php
  87. +151 −0 Tools/JS.php
  88. +134 −0 Tools/SVN.php
  89. +7 −0 Tools/Status.php
  90. +784 −0 Tools/WebSvn.php
  91. +811 −0 Tools/WebSvn.php.bak
  92. +5 −0 Tools/config.ini-dist
  93. +39 −0 Util/Cache.php
  94. +204 −0 Util/Chart.php
  95. +67 −0 Util/DBSession.php
  96. +277 −0 Util/Debug.php
  97. +181 −0 Util/Excel.php
  98. +157 −0 Util/File.php
  99. +30 −0 Util/FileCache.php
  100. +42 −0 Util/MEMSession.php
  101. +60 −0 Util/Pagination.php
  102. +62 −0 Util/Permission.php
  103. +57 −0 Util/String.php
  104. +422 −0 Util/Util.php
View
58 Application.php
@@ -0,0 +1,58 @@
+<?php
+/**
+ * 定义全局应用容器
+ *
+ * PHP versions 5
+ *
+ * @category KISS
+ * @package Application
+ * @author iwater <iwater@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @link http://kissphp.cn
+ *
+ */
+
+/**
+ * 定义全局应用容器
+ *
+ * @category KISS
+ * @package Application
+ * @author iwater <iwater@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @link http://kissphp.cn
+ */
+class KISS_Application
+{
+ const ON = 1;
+ const OFF = 0;
+
+ public static $session_status = self::OFF;
+ public static $charset = 'gbk';
+ public static $mode = 'online';
+
+ /**
+ * session 初始化
+ *
+ * @return void
+ */
+ public static function sessionStart()
+ {
+ if (self::OFF == self::$session_status) {
+ session_name(self::getUniqueAppName());
+ session_start();
+ self::$session_status = self::ON;
+ }
+ }
+
+ /**
+ * 取得当前应用的唯一标示串
+ *
+ * @return string
+ */
+ public static function getUniqueAppName()
+ {
+ $root_path = KISS_Framework_Config::getSystemPath('root');
+ return 'A'.strtoupper(substr(md5($root_path), 0, 7));
+ }
+}
+?>
View
41 ApplicationCache.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * $Id: Runnable.php 10 2007-03-09 16:42:11Z matao $
+ * @package KISS
+ */
+/**
+ * 可以直接运行的程序必须实现此接口
+ * @package KISS
+ */
+class KISS_Application {
+ const ON = 1;
+ const OFF = 0;
+
+ public static $session_status = self::OFF;
+
+ public static function session_start() {
+ if (self::OFF == self::$session_status) {
+ session_name(self::getUniqueAppName());
+ session_start ();
+ self::$session_status = self::ON;
+ }
+ }
+
+ public static function getUniqueAppName() {
+ if (xcache_isset('app_name')) {
+ return xcache_get('app_name');
+ }
+ $app_name = 'A'.strtoupper(substr(md5(KISS_Framework_Config::getSystemPath('root')),0,7));
+ if (!xcache_set('app_name', $app_name)) {
+
+ }
+ return $app_name;
+ }
+
+ public static function getSystemPath($pPathName) {
+ if (!xcache_isset('sp_'.$pPathName)) {
+ xcache_set("count", load_count_from_mysql());
+ }
+ }
+}
+?>
View
24 Class.php
@@ -0,0 +1,24 @@
+<?php
+class KISS_Class {
+ public static function getClassStaticMember($pClass, $pMember) {
+ $return = '';
+ $script = "if(isset({$pClass}::\${$pMember})){\$return = {$pClass}::\${$pMember};}";
+ eval($script);
+ return $return;
+ }
+
+ public static function getClassConstant($pClass, $pMember) {
+ $u_name = APP_NAME.'cc:'.$pClass.':'.$pMember;
+ if (xcache_isset($u_name)) {
+ return xcache_get($u_name);
+ }
+ $const = "{$pClass}::{$pMember}";
+ if (defined($const)) {
+ xcache_set($u_name, constant($const));
+ return constant($const);
+ }
+ xcache_set($u_name, '');
+ return '';
+ }
+}
+?>
View
8 Compatible/BasePage.php
@@ -0,0 +1,8 @@
+<?php
+class BasePage extends KISS_Page {
+ public function __construct(){
+ trigger_error('BasePage ÒѾ­¸üÃûΪ KISS_Page');
+ parent::__construct();
+ }
+}
+?>
View
5 Compatible/BaseTableObject.php
@@ -0,0 +1,5 @@
+<?php
+class BaseTableObject extends KISS_ORM_BaseTableObject {
+
+}
+?>
View
3 Compatible/Chinese.php
@@ -0,0 +1,3 @@
+<?php
+require_once("Chinese/class.Chinese.php");
+?>
View
1,074 Compatible/CordaEmbedder.php
@@ -0,0 +1,1074 @@
+<?php
+
+function indexOf($haystack, $needle)
+{
+ $pos = strpos($haystack, $needle);
+ $strFound = true;
+ if($pos === false) // note: three equal signs
+ {
+ // not found...
+ $strFound = false;
+ }
+
+ if($strFound == false)
+ {
+ return -1;
+ }
+ return $pos;
+}
+
+// CordaEmbedder Constants
+define("DEFAULT_HEIGHT", "330");
+define("DEFAULT_WIDTH", "540");
+
+define("SVG", "SVG");
+define("FLASH", "FLASH");
+define("GIF", "GIF");
+define("PNG", "PNG");
+define("PDF", "PDF");
+define("EPS", "EPS");
+define("WBMP", "WBMP");
+define("URL", "URL");
+define("TIFF", "TIFF");
+define("JPEG", "JPEG");
+
+define("STRICT", "STRICT");
+define("LOOSE", "LOOSE");
+define("NONE", "NONE");
+
+define("EN", "EN");
+
+class CordaEmbedder
+{
+ var $encodeURLAB = array(); // 1-dimensional array
+ var $encodeURLBAA = array(); // 2-dimensional array
+ var $encodeURLdone = false; // boolean
+
+ var $CordaEmbedderVersion = "5.1.2"; // string
+ var $EmbedderType = "PHP"; // string
+ var $attributeErrors = null; // string
+
+ var $debugOn = false; // boolean
+
+ var $externalServerAddress = null; // string
+ var $resultSetPCScript = null; // string
+ var $pcScript = null; // string
+ var $loadDataPCScript = null; // string
+ var $internalCommPortAddress = null; // string
+ var $isPostRequest = false; // boolean
+ var $clusterMonitorAddress = null; // string
+ var $requestPath = ""; // string
+
+ var $error = false; // boolean
+ var $errorString = null; // string
+
+ var $commportHost = null; // string
+ var $useLogData = false; // boolean return graphical log
+ var $password = null; // string for graphical log, save, & flush
+ var $appearanceFile = null; // string
+ var $cmdVector = array(); // array
+ var $objectParamTag = null; // string
+ var $retrieveImageSS = false; // boolean
+ var $serverSideImageName = null; // string
+ var $imageType = null; // string
+ var $useCache = true; // boolean cacheImage
+ var $width = 0; // int
+ var $height = 0; // int
+ var $htmlWidth = "0"; // string
+ var $htmlHeight = "0"; // string
+ var $extraHTMLAttributes = " "; // string
+ var $bgColor = null; // string
+ var $svgTemplate = null; // string
+ var $extraCTSCommands = null; // string
+ var $genericData = null; // string
+ var $userAgent = null; // string
+ var $fallback = null; // string
+ var $returnDescriptiveLink = false; // boolean
+ var $language = null; // string dLink Language
+ var $tableObject = null; // string
+ var $appendServerInfoSlash = true; // boolean
+ var $autoSwitchToPNG = true; // boolean
+ var $makeFullRequest = false; // boolean
+ var $maxRequestLength = 0; // int
+
+ //_________________________________________________________________________
+ //
+ // CordaEmbedder constructor
+ //_________________________________________________________________________
+ function CordaEmbedder()
+ {
+ // if we haven't filled in these encoding arrays yet, do it now.
+ if (!$this->encodeURLdone)
+ $this->buildURLEncodingArray();
+
+ // debug encoding array data
+ /*
+ echo "<pre>";
+ $i = 0;
+ foreach($this->encodeURLBAA as $key => $value)
+ {
+ $i++;
+ echo "$i\t$key => ";
+ for($j=0; $j < 3; $j++)
+ {
+ echo chr($value[$j]);
+ }
+ echo "\n";
+ }
+ echo "</pre>";
+ */
+ // end debug code
+ }
+
+ //_________________________________________________________________________
+ //
+ // buildURLEncodingArray
+ //_________________________________________________________________________
+ function buildURLEncodingArray()
+ {
+ $this->encodeURLdone = true;
+
+ // 1-dimensional array
+ $this->encodeURLAB = array();
+
+ // 2-dimensional array
+ $this->encodeURLBAA = array();
+
+ $badCharacters = " #%<>?[]^`{|}~";
+
+ $len = strlen($badCharacters);
+ for ($i = 0; $i < $len; $i++)
+ {
+ $c = ord($badCharacters[$i]);
+ $hexChars = dechex("$c");
+
+ $this->encodeURLAB[$c] = true;
+ $this->encodeURLBAA[$c][0] = ord('%'); // (byte)'%';
+ $this->encodeURLBAA[$c][1] = ord($hexChars[0]); //(byte)hexChars.charAt(0);
+ $this->encodeURLBAA[$c][2] = ord($hexChars[1]); //(byte)hexChars.charAt(1);
+ }
+
+ // encode linefeeds && newlines as spaces
+ $badCharacters = "\r\n";
+ $hexChars = dechex(ord(' ')); //Integer.toHexString(' ');
+ $len = strlen($badCharacters);
+ for ($i = 0; $i < $len; $i++)
+ {
+ $c = ord($badCharacters[$i]);
+ $this->encodeURLAB[$c] = true;
+ $this->encodeURLBAA[$c][0] = ord('%'); // (byte)'%';
+ $this->encodeURLBAA[$c][1] = ord($hexChars[0]); //(byte)hexChars.charAt(0);
+ $this->encodeURLBAA[$c][2] = ord($hexChars[1]); //(byte)hexChars.charAt(1);
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // getEmbeddingHTML()
+ // returns string
+ //_________________________________________________________________________
+
+ function getEmbeddingHTML()
+ {
+ if($this->debugOn)
+ {
+ return $this->getCommportResponse("@_RTNHTML@_EMBVER".$this->CordaEmbedderVersion."@_EMBTYPE".$this->EmbedderType) . $this->attributeErrors;
+ }
+ return $this->getCommportResponse("@_RTNHTML@_EMBVER".$this->CordaEmbedderVersion."@_EMBTYPE".$this->EmbedderType);
+ }
+
+ //_________________________________________________________________________
+ //
+ // getExternalServerAddress
+ //_________________________________________________________________________
+
+ function getExternalServerAddress($sa)
+ {
+ $host = "";
+ $port = 80;
+
+ $i = indexOf($sa, "://");
+ if($i >= 0)
+ $sa = substr($sa, $i+3);
+
+ // remove query string
+ $i = indexOf($sa, '?');
+ if($i >= 0)
+ {
+ $sa = substr($sa, 0, $i);
+ }
+
+ // remove path
+ $i = indexOf($sa, '/');
+ if($i >= 0)
+ {
+ $sa = substr($sa, 0, $i);
+ }
+
+ // peal off the port number
+ $i = indexOf($sa, ':');
+ if ($i >= 0)
+ {
+ $host = substr($sa, 0, $i);
+ $port = substr($sa, $i+1);
+ }
+ else
+ {
+ $host = $sa;
+ }
+ return array('host' => $host, 'port' => (int)$port);
+ }
+
+ //_________________________________________________________________________
+ //
+ // setCommportAddress
+ //_________________________________________________________________________
+
+ function setCommportAddress($cpa)
+ {
+ $port = 80;
+
+ $i = indexOf($cpa, "://");
+ if($i >= 0)
+ $cpa = substr($cpa, $i+3);
+ // peal off the port number
+ $i = indexOf($cpa, ':');
+ if ($i >= 0)
+ {
+ $this->commportHost = substr($cpa, 0, $i);
+ $this->commportPort = (int)substr($cpa, $i+1);
+ }
+ else
+ {
+ $this->commportHost = $cpa;
+ $this->commportPort = $port;
+ }
+
+ $i = indexOf($cpa, "/");
+ if ($i >= 0)
+ {
+ $this->requestPath = substr($cpa, $i);
+ }
+
+ $this->error = false;
+ }
+
+ //_________________________________________________________________________
+ //
+ // validateHeightWidth
+ //
+ // if height or width <= 0 set to them default width
+ //_________________________________________________________________________
+
+ function validateHeightWidth()
+ {
+ if($this->height <= 0)
+ $this->height = DEFAULT_HEIGHT;
+
+ if($this->width <= 0)
+ $this->width = DEFAULT_WIDTH;
+ }
+
+ //_________________________________________________________________________
+ //
+ // validateReturnDescriptiveLink()
+ //
+ // set language if it's null and returnDescriptiveLink is true.
+ //_________________________________________________________________________
+
+ function validateReturnDescriptiveLink()
+ {
+ if($this->returnDescriptiveLink)
+ {
+ if(empty($this->language))
+ {
+ $this->language = "EN";
+ }
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // encodeString(String str)
+ //
+ // return the encoded string (for server)
+ //_________________________________________________________________________
+
+ function encodeString($str)
+ {
+ $encodedStr = "";
+ $encodeIndex = 0;
+
+ $encodeBuffer = array();
+
+ if(strlen($str) > 0)
+ {
+ $len = strlen($str);
+ $c = 0;
+ $wrote = false;
+
+ for($i=0; $i < $len; $i++)
+ {
+ $c = ord($str[$i]);
+ $wrote = false;
+ // urlencode bad chars below 0x07F inclusive
+ if($c <= 0x07F)
+ {
+ // encode the bad character
+ if(isset($this->encodeURLAB[$c]))
+ {
+ $encodeBuffer[$encodeIndex++] = chr($this->encodeURLBAA[$c][0]);
+ $encodeBuffer[$encodeIndex++] = chr($this->encodeURLBAA[$c][1]);
+ $encodeBuffer[$encodeIndex++] = chr($this->encodeURLBAA[$c][2]);
+ }
+ // write the character w/o encoding it
+ else
+ {
+ $encodeBuffer[$encodeIndex++] = $str[$i];
+ }
+ }
+ // %uxxxx encode chars with ord val greater than 0x07F
+ else
+ {
+ $encodeBuffer[$encodeIndex++] = '%';
+ $encodeBuffer[$encodeIndex++] = 'u';
+ if($c <= 0x0FF)
+ {
+ $encodeBuffer[$encodeIndex++] = '0';
+ }
+ if($c <= 0x0FFF)
+ {
+ $encodeBuffer[$encodeIndex++] = '0';
+ }
+
+ $hexChars = dechex("$c");
+ for($hidx=0; $hidx < strlen($hexChars); $hidx++)
+ {
+ $encodeBuffer[$encodeIndex++] = $hexChars[$hidx];
+ }
+ }
+ }
+ }
+
+ // append last part to string
+ if($encodeIndex > 0)
+ {
+ $encodedStr = implode("", $encodeBuffer);
+ }
+
+ // delete the temp buffer
+ $encodeBuffer = null;
+
+ return $encodedStr;
+ }
+
+ //_________________________________________________________________________
+ //
+ // setServerInfoFromClusterMonitor()
+ //
+ // returns a workingServerAddress (String)
+ //_________________________________________________________________________
+
+ function setServerInfoFromClusterMonitor()
+ {
+ $workingServerAddress = $this->externalServerAddress;
+
+ $request = $this->clusterMonitorAddress;
+ if($this->lastUsedCommPort != null)
+ $request = $this->clusterMonitorAddress . "?noresponse^^" . $this->lastUsedCommPort;
+
+ // create a URL to contact the Cluster Monitor
+ $serverInfo = $this->getExternalServerAddress($request);
+ $query = "GET $request HTTP/1.0\r\n" .
+ "Host: ".$serverInfo['host'].":".$serverInfo['port']."\r\n" .
+ "\r\n";
+
+ // open server connection
+ $fp = fsockopen($serverInfo['host'], $serverInfo['port']);
+
+ if(!$fp)
+ {
+ echo "<b>Error Contacting Corda Cluster Monitor - Connection Failed</b>";
+ }
+ else
+ {
+ fputs($fp, $query);
+
+ // discard HTTP header
+ while(trim(fgets($fp, 1024)) != "");
+
+ // assign the rest of the file to response
+ while(!feof ($fp))
+ {
+ $buffer = fgets($fp, 1024);
+ $response .= $buffer;
+ }
+
+ // close server connection
+ fclose($fp);
+
+ $address = $response;
+
+ $cpIndex = indexOf($address, ',');
+ $this->lastUsedCommPort = substr($address, $cpIndex + 1);
+ $this->setCommportAddress($this->lastUsedCommPort);
+ if($this->externalServerAddress == null)
+ $workingServerAddress = "http://" . substr($address, 0, $cpIndex);
+// echo "Results from clusterMonitor : " . $address . "<br />";
+ }
+
+ return $workingServerAddress;
+ }
+
+ //_________________________________________________________________________
+ //
+ // validateExtraHTMLAttributes
+ //_________________________________________________________________________
+
+ function validateExtraHTMLAttributes()
+ {
+ if($this->extraHTMLAttributes != null)
+ {
+ if($this->extraHTMLAttributes[0] != ' ')
+ $this->extraHTMLAttributes = " " . $this->extraHTMLAttributes;
+
+ if($this->extraHTMLAttributes[strlen($this->extraHTMLAttributes)-1] != ' ')
+ $this->extraHTMLAttributes .= " ";
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // validateUseLogData()
+ //
+ // Make sure password property is not null
+ //_________________________________________________________________________
+ function validateUseLogData()
+ {
+ if($this->useLogData)
+ {
+ if($this->password == null)
+ {
+ $this->addAttributeError("Graphical Log requests require a password to be set.");
+ }
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // getCommportResponse()
+ // returns string
+ // takes a string
+ //_________________________________________________________________________
+
+ function getCommportResponse($type)
+ {
+ $response = ""; // string
+ $notDone = true; // boolean
+ $workingServerAddress = $this->externalServerAddress; // string
+
+ if($this->resultSetPCScript != null)
+ {
+ if($this->pcScript != null)
+ $this->pcScript = $this->resultSetPCScript . $this->pcScript;
+ else
+ $this->pcScript = $this->resultSetPCScript;
+ }
+
+ // add objectName.loadfile(filename,append,name/number) command to pcscript
+ if($this->loadDataPCScript != null)
+ {
+ if($this->pcScript != null)
+ $this->pcScript = $this->loadDataPCScript . $this->pcScript;
+ else
+ $this->pcScript = $this->loadDataPCScript;
+ }
+
+ if($this->internalCommPortAddress != null)
+ {
+ $this->setCommportAddress($this->internalCommPortAddress);
+ }
+
+ while($notDone)
+ {
+ if($this->clusterMonitorAddress != null)
+ $workingServerAddress = $this->setServerInfoFromClusterMonitor();
+ else
+ $notDone = false;
+
+ if($this->error)
+ return $this->errorString;
+ if($workingServerAddress == null)
+ return "<b>ERROR: No server address specified</b>";
+ if($this->commportHost == null)
+ return "<b>ERROR: No commport address specified</b>";
+
+ $request = null; // string
+ $request = $type . "@_SVRADDRESS".$workingServerAddress;
+
+ // add the log graph if necessary
+ if($this->useLogData)
+ {
+ $this->validateUseLogData();
+ if($this->password != null)
+ {
+ // graphical log requires an appearance file
+ // log data pcscript commands must be supplied also
+ $request .= "@_LOGgraph@_PW" . $this->password;
+ if($this->appearanceFile == null && ($this->cmdVector == null || count($this->cmdVector) > 0))
+ {
+ // if no apfile or data provided, use a default
+ // timeline chart & display default log data
+ $this->addPCXML("<?xml version='1.0' encoding='ISO-8859-1' ?> <Chart Version='4.0'> <Textbox Name='textbox' Top='20' Left='0' Width='540' Height='22' Anchor='TopCenter'> <Text>Add Text Here</Text> </Textbox> <Graph Name='timelinegraph' Top='62' Left='20' Width='500' Height='248' Type='TimeLine'> <Properties Effect='2D' NoGap='No'/> <DataLabels ValueString='%_YVALUE' /> <DateInputFormat>%Y/%m/%d:%H</DateInputFormat> <ValueScale Position='Bottom' MinorFont='Size:9;'/> </Graph> </Chart>");
+ if($this->pcScript == null)
+ {
+ // if no pcscript, provide something
+ $this->pcScript = "textbox.settext(So far there have been PCIS.totalHits hits) timelinegraph.series(hits, PCIS.hitsByDaySeries)";
+ }
+ }
+ }
+ }
+
+ if($this->retrieveImageSS)
+ {
+ $request .= "@_LOAD" . $this->serverSideImageName;
+
+ // clear serverSideImageName & retrieveImageSS (so object can be used again)
+ $this->serverSideImageName = null;
+ $this->retrieveImageSS = false;
+ }
+
+ if($this->appearanceFile != null)
+ $request .= "@_FILE".$this->appearanceFile;
+
+ if($this->imageType != null && strlen(trim($this->imageType)) > 0)
+ $request .= "@_IMGTYPE".$this->imageType;
+
+ if(!$this->useCache)
+ {
+ $request .= "@_DONTCACHE";
+ }
+
+ // width and height set explicitly?
+ $this->validateHeightWidth();
+ $request .= "@_WIDTH".$this->width;
+ $request .= "@_HEIGHT".$this->height;
+
+ if($this->htmlWidth != "0")
+ $request .= "@_HTMLWIDTH".$this->encodeString($this->htmlWidth);
+ if($this->htmlHeight != "0")
+ $request .= "@_HTMLHEIGHT".$this->encodeString($this->htmlHeight);
+ if($this->extraHTMLAttributes != null && $this->extraHTMLAttributes != " ")
+ {
+ $this->validateExtraHTMLAttributes();
+ $request .= "@_HTMLATTRIBUTES".$this->encodeString($this->extraHTMLAttributes);
+ }
+
+ if($this->bgColor != null)
+ $request .= "@_BGCOLOR".$this->bgColor;
+ if($this->svgTemplate != null)
+ $request .= "@_USESVGTEMPLATE".$this->svgTemplate;
+ if($this->extraCTSCommands != null)
+ $request .= $this->extraCTSCommands;
+ if($this->pcScript != null)
+ $request .= "@_PCSCRIPT" . $this->encodeString($this->pcScript);
+ // add commands in cmdVector to request
+ if($this->cmdVector != null && count($this->cmdVector) > 0)
+ {
+ for($i=0; $i < count($this->cmdVector); $i++)
+ {
+ $request .= $this->cmdVector[$i];
+ }
+ }
+ if($this->objectParamTag != null)
+ $request .= "@_OPTAG" . $this->encodeString($this->objectParamTag);
+ if($this->genericData != null)
+ $request .= "@_OBJCMD" . $this->encodeString($this->genericData);
+ if($this->userAgent != null)
+ $request .= "@_USRAGENT" . $this->encodeString($this->userAgent);
+ if($this->fallback != null && (strcasecmp($this->fallback, "none") != 0))
+ {
+ // valid options: "strict", and "loose"
+ if((strcasecmp($this->fallback, "strict") == 0) || (strcasecmp($this->fallback, "loose") == 0))
+ $request .= "@_FALLBACK".$this->fallback;
+ }
+ if($this->returnDescriptiveLink)
+ {
+ $this->validateReturnDescriptiveLink();
+ $request .= "@_TDREQUIRED".$this->language;
+ }
+ //if($this->tableObject != null)
+ if(isset($this->tableObject))
+ $request .= "@_TABLEOBJECT" . $this->encodeString($this->tableObject);
+
+ // appendServerInfoSlash boolean value instructs Corda Server to either
+ // add a slash to the server info upon return or not
+ // this is a work around for WebLogic using the Corda Servlet Redirector
+ if(!$this->appendServerInfoSlash)
+ $request .= "@_NOSINFOSLASH";
+
+ // suppress server-side auto switch from gif to png
+ if(!$this->autoSwitchToPNG)
+ $request .= "@_NOPNGAUTOSWITCH";
+
+ // return full url request(s) within the embedding html
+ if($this->makeFullRequest)
+ {
+ // maxRequestLength is zero when not set
+ // must be (greater than zero) and (less than/equal to request len)
+ if(($this->maxRequestLength == 0) || ($this->maxRequestLength > 0 && strlen($request) <= $this->maxRequestLength))
+ {
+ $request .= "@_MAKEFULLREQUEST";
+ }
+ }
+
+ // replace carriage return and line feeds from the request
+ $request = strtr($request, chr(10), ' ');
+ $request = strtr($request, chr(13), ' ');
+
+ // build query
+ if($this->isPostRequest)
+ {
+ $query = "POST " . $this->requestPath . " HTTP/1.0\r\n" .
+ "Host: $this->commportHost:$this->commportPort\r\n" .
+ "Content-Length: " . strlen($request) . "\r\n" .
+ "Content-Type: text/html\r\n" .
+ "\r\n" .
+ $request;
+ }
+ else
+ {
+ if(isset($this->requestPath))
+ {
+ $requestPath = $this->requestPath;
+ }
+ else
+ {
+ $requestPath = "/";
+ }
+ $query = "GET $requestPath?$request HTTP/1.0\r\n" .
+ "Host: $this->commportHost:$this->commportPort\r\n" .
+ "\r\n";
+ }
+
+ // open server connection
+ $fp = fsockopen($this->commportHost, $this->commportPort);
+
+ // if connection failed return false;
+ if(!$fp)
+ {
+ if((empty($clusterMonitorAddress)) ||
+ ((!empty($clusterMonitorAddress)) && (indexOf($commportHost, "127.0.0.1") == 0) && ($commportPort == 2002)))
+ {
+ $response = "<b>ERROR: Can't connect to the commport of Corda Server - Connection Failed</b>";
+ $notDone = false;
+ }
+ }
+ else
+ {
+ // send query
+ fputs($fp, $query);
+
+ // discard HTTP header
+ while(trim(fgets($fp, 1024)) != "");
+
+ // assign the rest of the file to response
+ while(!feof ($fp))
+ {
+ $buffer = fgets($fp, 1024);
+ $response .= $buffer;
+ }
+
+ // close server connection
+ fclose($fp);
+
+ $notDone = false;
+ }
+ }
+
+ return $response;
+ }
+
+ //_________________________________________________________________________
+ //
+ // addHTMLTable(String obj, String title)
+ //
+ // no parameters: use "graph" element and title if there is one
+ // parameters: obj, title (for an appearance file graph object and title)
+ // title parameter is optional
+ //
+ // this function can be called multiple times and the parameters will
+ // be appended to the previous ones.
+ //
+ // calling it with no parameters clears the list
+ //_________________________________________________________________________
+
+ function addHTMLTable($obj=null, $title=null)
+ {
+ $delim = "PCDELIM";
+ $bTag = "<".$delim.">";
+ $eTag = "</".$delim.">";
+
+ if(empty($obj))
+ {
+ $this->tableObject = "";
+ }
+ else
+ {
+ // replace empty or null tableObject string
+ if(!$this->tableObject)
+ {
+ $this->tableObject = $bTag . $obj . $eTag;
+ }
+ else // append to tableObject string
+ {
+ $this->tableObject .= $bTag . $obj . $eTag;
+ }
+
+ // add title to tableObject string
+ if(!empty($title))
+ {
+ $this->tableObject .= $bTag . $title . $eTag;
+ }
+ else
+ {
+ $this->tableObject .= $bTag . $eTag;
+ }
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // loadCommandFile(String ldRQ, String encoding=null)
+ //
+ // takes a url or filename
+ // add ldRQ string with @_LOADREQUEST to cmdVector
+ //_________________________________________________________________________
+
+ function loadCommandFile($ldRQ, $encoding=null)
+ {
+ if(!empty($encoding))
+ {
+ $this->cmdVector[] = "@_ENCLOADREQUEST" . $encoding . "," . $this->encodeString($ldRQ);
+ }
+ else
+ {
+ $this->cmdVector[] = "@_LOADREQUEST" . $this->encodeString($ldRQ);
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // saveImageToCordaServer(String fileName)
+ //_________________________________________________________________________
+
+ function saveImageToCordaServer($fileName, $pw=null)
+ {
+ // use class password variable if pw not passed
+ if($pw != null)
+ {
+ $passwd = $pw;
+ }
+ else
+ {
+ $passwd = $this->password;
+ }
+
+ // save imageType
+ $saveImageAs = "";
+ if($this->imageType != null && strlen(trim($this->imageType)) > 0)
+ {
+ $saveImageAs = $this->imageType;
+ }
+
+ // change image type to URL so we get a url back from the comm port
+ $this->imageType = "URL";
+
+ // request a url from the comm port
+ $requestStr = $this->getCommportResponse("@_RTNHTML@_EMBVER".$this->CordaEmbedderVersion."@_EMBTYPE".$this->EmbedderType);
+
+ // add the saved image type to the new request, the @_SAVE command and the @_PW command
+ $requestStr .= "@_" . strtoupper($saveImageAs) . "@_SAVE" . $fileName;
+
+ // restore saved imageType
+ $this->imageType = $saveImageAs;
+
+ if( ($passwd != null) && (strlen($passwd) > 0) )
+ {
+ $requestStr .= "@_PW" . $passwd;
+ }
+
+ $serverInfo = $this->getExternalServerAddress($requestStr);
+ $query = "GET $requestStr HTTP/1.0\r\n" .
+ "Host: ".$serverInfo['host'].":".$serverInfo['port']."\r\n" .
+ "\r\n";
+
+ // open server connection
+ $fp = fsockopen($serverInfo['host'], $serverInfo['port']);
+
+ if(!$fp)
+ {
+ echo "<b>Error Contacting Corda Server - Connection Failed</b>";
+ }
+ else
+ {
+ fputs($fp, $query);
+
+ // assign the rest of the file to response
+ while(!feof ($fp))
+ {
+ $buffer = fgets($fp, 1024);
+ $response .= $buffer;
+ }
+
+ // close server connection
+ fclose($fp);
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // resetPCXML -- clear cmdVector
+ //_________________________________________________________________________
+
+ function resetPCXML()
+ {
+ $this->cmdVector = array();
+ }
+
+ //_________________________________________________________________________
+ //
+ // loadPCXML -- load a file or http url
+ //
+ // add path-filename or url with @_LOADPCXML to cmdVector
+ //_________________________________________________________________________
+
+ function loadPCXML($pcxmlFile)
+ {
+ $this->cmdVector[] = "@_LOADPCXML" . $this->encodeString($pcxmlFile);
+ }
+
+ //_________________________________________________________________________
+ //
+ // addObjectParamTag -- Add name="value" to <object><param /></object> tag
+ //
+ // Can be called multiple times.
+ //_________________________________________________________________________
+
+ function addObjectParamTag($name, $value)
+ {
+ $delim = "PCDELIM";
+ $bTag = "<".$delim.">";
+ $eTag = "</".$delim.">";
+
+ if($this->objectParamTag != null && strlen($this->objectParamTag) > 0)
+ {
+ $this->objectParamTag .= $bTag . $name . $eTag . $bTag . $value . $eTag;
+ }
+ else
+ {
+ $this->objectParamTag = $bTag . $name . $eTag . $bTag . $value . $eTag;
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // addPCXML -- add or set xml data tailored to Corda Server
+ //
+ // add pcXml string with @_PCXML to cmdVector
+ //_________________________________________________________________________
+
+ function addPCXML($pcxml)
+ {
+ $this->cmdVector[] = "@_PCXML" . $this->encodeString($pcxml);
+ }
+
+ //_________________________________________________________________________
+ //
+ // getCordaEmbedderVersion()
+ //_________________________________________________________________________
+
+ function getCorda5EmbedderVersion()
+ {
+ return "CordaEmbedder Version " . $this->CordaEmbedderVersion;
+ }
+
+ //_________________________________________________________________________
+ //
+ // getCordaEmbedderVersion()
+ //
+ // Always point this function to the current embedder version
+ //_________________________________________________________________________
+
+ function getCordaEmbedderVersion()
+ {
+ return $this->getCorda5EmbedderVersion();
+ }
+
+ //_________________________________________________________________________
+ //
+ // loadServerSideImage(String fileName)
+ //_________________________________________________________________________
+
+ function loadServerSideImage($fileName)
+ {
+ $this->retrieveImageSS = true;
+ $this->serverSideImageName = $fileName;
+ }
+
+ //_________________________________________________________________________
+ //
+ // loadData(objectName, path/url, append, id, encoding)
+ //
+ // 1) objectName must be an existing graph object name in the current apFile
+ // 2) path/url is a filename or url with the data we want to load
+ // 3) append is a boolean value which signifies whether you want to override
+ // existing data or add to it
+ // 4) id is the number of the table in the file or a named id of some type
+ // 5) encoding is the character encoding string for the file/url
+ //_________________________________________________________________________
+
+ function loadData($objName, $path, $append_replace="replace", $id=null, $encoding=null)
+ {
+ // pcscript loadfile command will be modified
+ // on server-side to accept filenames or urls
+ $ldPCS = $objName . ".loadfile(" . $path . "," . $append_replace;
+
+ if(!empty($id))
+ {
+ $ldPCS .= "," . $id;
+ }
+
+ if(!empty($encoding))
+ {
+ if(empty($id))
+ {
+ $ldPCS .= ",";
+ }
+ $ldPCS .= "," . $encoding;
+ }
+
+ $ldPCS .= ")";
+
+ if($this->loadDataPCScript != null)
+ $this->loadDataPCScript .= $ldPCS;
+ else
+ $this->loadDataPCScript = $ldPCS;
+
+ }
+
+ //_________________________________________________________________________
+ //
+ // loadMapData(objectName, layerName, path/url, id, encoding)
+ //
+ // 1) objectName must be an existing graph object name in the current apFile
+ // 2) layerName is the layer to apply the data to
+ // 3) path/url is a filename or url with the data we want to load
+ // 4) id is the number of the table in the file or a named id of some type
+ // 5) encoding is the character encoding string for the file/url
+ //_________________________________________________________________________
+
+ function loadMapData($objName, $layerName, $path, $id=null, $encoding=null)
+ {
+ // pcscript loadfile command will be modified
+ // on server-side to accept filenames or urls
+ $ldPCS = $objName . ".loadmapfile(" . $layerName . "," . $path;
+
+ if(!empty($id))
+ {
+ $ldPCS .= "," . $id;
+ }
+
+ if(!empty($encoding))
+ {
+ if(empty($id))
+ {
+ $ldPCS .= ",";
+ }
+ $ldPCS .= "," . $encoding;
+ }
+
+ $ldPCS .= ")";
+
+ if($this->loadDataPCScript != null)
+ $this->loadDataPCScript .= $ldPCS;
+ else
+ $this->loadDataPCScript = $ldPCS;
+
+ }
+
+ //_________________________________________________________________________
+ //
+ // setData(objName, dataString)
+ //
+ // send one or many generic xml data sets to Corda Server
+ // targeted at specific objects
+ //_________________________________________________________________________
+
+ function setData($objName, $dataString)
+ {
+ $delim = "PCDELIM";
+ $bTag = "<".$delim.">";
+ $eTag = "</".$delim.">";
+
+ // replace all occurances of \n with <PCNL> in dataString
+ $dataString = preg_replace("/\n/", "<PCNL>", $dataString);
+
+ $tmpData = $bTag . "setdata" . $eTag . $bTag . $objName . $eTag . $bTag . $dataString . $eTag;
+
+ if($this->genericData != null && strlen(trim($this->genericData)) > 0)
+ {
+ $this->genericData .= $tmpData;
+ }
+ else //genericData empty or null
+ {
+ $this->genericData = $tmpData;
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // setMapData(objName, dataString)
+ //
+ // send one or many generic xml data sets to Corda Server
+ // targeted at specific objects
+ //_________________________________________________________________________
+
+ function setMapData($objName, $layerName, $dataString)
+ {
+ $delim = "PCDELIM";
+ $bTag = "<".$delim.">";
+ $eTag = "</".$delim.">";
+
+ // replace all occurances of \n with <PCNL> in dataString
+ $dataString = preg_replace("/\n/", "<PCNL>", $dataString);
+
+ $tmpData = $bTag . "setmapdata" . $eTag . $bTag . $objName . $eTag . $bTag . $layerName . $eTag . $bTag . $dataString . $eTag;
+
+ if($this->genericData != null && strlen(trim($this->genericData)) > 0)
+ {
+ $this->genericData .= $tmpData;
+ }
+ else //genericData empty or null
+ {
+ $this->genericData = $tmpData;
+ }
+ }
+
+ //_________________________________________________________________________
+ //
+ // addAttributeError(String)
+ //_________________________________________________________________________
+
+ function addAttributeError($attrError)
+ {
+ if($this->attributeErrors == null)
+ {
+ $this->attributeErrors = "";
+ }
+ $this->attributeErrors .= "<p>" . attrError . "</p>\n";
+ }
+
+} // end of class definition
+
+?>
View
3 Compatible/HessianClient.php
@@ -0,0 +1,3 @@
+<?php
+include_once 'HessianPHP/HessianClient.php';
+?>
View
3 Compatible/HessianService.php
@@ -0,0 +1,3 @@
+<?php
+include_once 'HessianPHP/HessianService.php';
+?>
View
3 Compatible/Pagination.php
@@ -0,0 +1,3 @@
+<?php
+class Pagination extends KISS_Util_Pagination {}
+?>
View
3 Compatible/Smarty.php
@@ -0,0 +1,3 @@
+<?php
+require_once("Smarty/Smarty.class.php");
+?>
View
3 Compatible/SqlCommand.php
@@ -0,0 +1,3 @@
+<?php
+abstract class SqlCommand extends KISS_KDO_SqlCommand {}
+?>
View
3 Compatible/htmlMimeMail5.php
@@ -0,0 +1,3 @@
+<?php
+require_once("htmlMimeMail5/htmlMimeMail5.php");
+?>
View
83 Controller.php
@@ -0,0 +1,83 @@
+<?php
+/**
+ * 分发器,根据不同的客户端调用不同的 Controller
+ *
+ * PHP versions 5
+ *
+ * @category KISS
+ * @package Controller
+ * @author iwater <iwater@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @link http://kissphp.cn
+ *
+ */
+
+/**
+ * 分发器,根据不同的客户端调用不同的 Controller
+ *
+ * @category KISS
+ * @package Controller
+ * @author iwater <iwater@gmail.com>
+ * @license http://www.opensource.org/licenses/bsd-license.php BSD
+ * @link http://kissphp.cn
+ */
+class KISS_Controller
+{
+ private $_innerController;
+ /**
+ * 构造函数
+ *
+ */
+ function __construct()
+ {
+ if ('cli' == php_sapi_name()) {
+ $this->_innerController = new KISS_Controller_Cli();
+ } else {
+ $application = KISS_Framework_Config::getValue('//application');
+ session_name(strtoupper(substr(MD5(KISS_Framework_Config::getSystemPath('root')), 0, 8)));
+ if (isset($application['session'])) {
+ switch ($application['session']) {
+ case 'disable':
+ break;
+
+ case 'memcache':
+ $memcache = KISS_Framework_Config::getValue('/application/memcache');
+ if (!isset($memcache['host']) || !isset($memcache['port'])) {
+ die('没有配置 memcache 参数!');
+ }
+ session_save_path("tcp://{$memcache['host']}:{$memcache['port']}");
+ session_module_name('memcache');
+ KISS_Application::sessionStart();
+ break;
+
+ default:
+ KISS_Application::sessionStart();
+ break;
+ }
+ } else {
+ KISS_Application::sessionStart();
+ }
+ if (isset($_SERVER['HTTP_KISS_RPC']) && in_array($_SERVER['HTTP_KISS_RPC'], array('JSON')) && class_exists('KISS_Controller_'.$_SERVER['HTTP_KISS_RPC'])) {
+ $Controller = 'KISS_Controller_'.$_SERVER['HTTP_KISS_RPC'];
+ }
+ if (strtolower(substr($_SERVER['SERVER_SOFTWARE'], 0, 6)) == 'apache') {
+ preg_match("/^(_([^_]+)_){0,1}([^\/]*?)(\.|$)/i",
+ basename($_SERVER['PHP_SELF']), $matches);
+ } else {
+ preg_match("/^(_([^_]+)_){0,1}([^\/]*?)(\.|\?|$)/i",
+ basename($_SERVER['REQUEST_URI']), $matches);
+ }
+ if (!isset($Controller)) {
+ $Controller = "KISS_Controller_{$matches[2]}";
+ }
+ if ($Controller == 'KISS_Controller_' || !class_exists($Controller)) {
+ $Controller = "KISS_Controller_Brower";
+ }
+ $class_name = implode('_',
+ array_map('ucfirst', explode('_', $matches[3])));
+ $this->_innerController = new $Controller($class_name);
+ }
+ $this->_innerController->run();
+ }
+}
+?>
View
35 Controller/Ajax.php
@@ -0,0 +1,35 @@
+<?php
+class KISS_Controller_Ajax {
+ private $ins;
+ public function __construct($class_name){
+ header('Content-Type: application/x-javascript');
+ if (class_exists($class_name)) {
+ try {
+ $this->ins = new $class_name();
+ } catch (Exception $error) {
+ $this->showMessage($error->getMessage());
+ }
+ } else {
+ $this->showMessage("Îļþ²»´æÔÚ£¡\\r".$_SERVER['SCRIPT_URI']);
+ }
+ }
+
+ public function run() {
+ $S = & new JPSpan_Server_PostOffice();
+ $S->addHandler($this->ins);
+
+ if ($_SERVER['REQUEST_METHOD'] == 'GET') {
+ define('JPSPAN_INCLUDE_COMPRESS',TRUE);
+ $S->displayClient();
+ } else {
+ require_once JPSPAN . 'ErrorHandler.php';
+ $S->serve();
+ }
+ }
+
+ public function showMessage($pMessage) {
+ echo "alert('{$pMessage}');";
+ die();
+ }
+}
+?>
View
56 Controller/Brower.php
@@ -0,0 +1,56 @@
+<?php
+class KISS_Controller_Brower extends KISS_Object {
+ public function __construct($class_name) {
+ parent::__construct();
+ try {
+ $context = KISS_Framework_Context::getInstance();
+ $context->mClassName = $this->checkClass($class_name);
+ $filter = KISS_Class::getClassConstant($context->mClassName, 'FILTERS');
+ $this->mFilters = ($filter=='')?array():explode(',',$filter);
+
+ $context->mFilters = $this->mFilters;
+ $context->mCacheTime = intval(KISS_Class::getClassConstant($context->mClassName, 'CACHE_TIME'));
+ }
+ catch (Exception $error) {
+ $page = new KISS_Page();
+ $page->showMessage($error->getMessage());
+ }
+ }
+
+ function __destruct() {
+ parent::__destruct();
+ if (KISS_Framework_Config::getMode()=='debug') {
+ KISS_Util_Debug::dumpinfo();
+ }
+ }
+
+ private function checkClass($class_name) {
+ $u_name = APP_NAME.'class_'.$class_name;
+ if (xcache_isset($u_name)) {
+ return xcache_get($u_name);
+ }
+ $class_names = array('Page_User_'.$class_name, 'Page_'.$class_name, $class_name);
+ foreach ($class_names as $class_name) {
+ $interfaces = @class_implements($class_name);
+ if (is_array($interfaces) && in_array('KISS_Interface_Runnable', $interfaces)) {
+ xcache_set($u_name, $class_name);
+ return $class_name;
+ }
+ }
+ KISS_Util_Util::directGoToUrl("/");
+ }
+
+ public function run() {
+ $context = KISS_Framework_Context::getInstance();
+ if (count($this->mFilters) > 0) {
+ $filter = array_shift($this->mFilters);
+ $filter = new $filter();
+ $filter->doFilter($context, $this);
+ }
+ else {
+ $page = new $context->mClassName();
+ $page->run();
+ }
+ }
+}
+?>
View
37 Controller/Cli.php
@@ -0,0 +1,37 @@
+<?php
+class KISS_Controller_Cli {
+ private $ins;
+ public function __construct(){
+ set_time_limit(0);
+ array_shift($_SERVER['argv']);
+ if (count($_SERVER['argv']) > 0) {
+ $class_name = array_shift($_SERVER['argv']);
+ $class_name = implode('_' ,array_map('ucfirst', explode('_', $class_name)));
+ if (class_exists($class_name)) {
+ try {
+ parse_str(implode('&',$_SERVER['argv']), $parameters);
+ $_GET = $parameters;
+ $_REQUEST = $parameters;
+ $this->ins = new $class_name($parameters);
+ } catch (Exception $error) {
+ $this->showMessage($error->getMessage());
+ }
+ } else {
+ $this->showMessage('ȱÉÙÀ࣡'.$class_name);
+ }
+ } else {
+ $this->showMessage('ȱÉÙ²ÎÊý£¡');
+ }
+ }
+
+ public function run() {
+ if ($this->ins) {
+ return $this->ins->run();
+ }
+ }
+
+ public function showMessage($pMessage) {
+ echo $pMessage."\n";
+ }
+}
+?>
View
33 Controller/Hessian.php
@@ -0,0 +1,33 @@
+<?php
+class KISS_Controller_Hessian {
+ private $ins;
+ public function __construct($class_name){
+ if (class_exists($class_name)) {
+ try {
+ $parameters = array();
+ if(isset($_SERVER['argv'])) {
+ parse_str(implode('&',$_SERVER['argv']), $parameters);
+ }
+ $this->ins = new $class_name($parameters);
+ } catch (Exception $error) {
+ $this->showMessage($error->getMessage());
+ }
+ } else {
+ $this->showMessage('ȱÉÙÀ࣡'.$class_name);
+ }
+ }
+
+ public function run() {
+ if ($this->ins) {
+ $wrapper = &new HessianService();
+ $wrapper->registerObject($this->ins);
+ $wrapper->displayInfo = true;
+ $wrapper->service();
+ }
+ }
+
+ public function showMessage($pMessage) {
+ echo $pMessage."\n";
+ }
+}
+?>
View
86 Controller/JSON.php
@@ -0,0 +1,86 @@
+<?php
+class KISS_Controller_JSON extends KISS_Object{
+ private $ins;
+ public function __construct($class_name) {
+ parent::__construct();
+ try {
+ $context = KISS_Framework_Context::getInstance();
+ $context->mClassName = $class_name;
+ $filter = KISS_Class::getClassConstant($context->mClassName, 'FILTERS');
+ $filters = ($filter=='')?array():explode(',',$filter);
+ } catch (Exception $error) {
+ $page = new KISS_Page();
+ $page->showMessage($error->getMessage());
+ }
+ while (count($filters) > 0) {
+ $filter = array_shift($filters);
+ $filter = new $filter();
+ $filter->doPreProcessing($context, $this);
+ }
+ }
+
+ public function run() {
+ $context = KISS_Framework_Context::getInstance();
+ $class_name = $context->mClassName;
+ if (class_exists($class_name)) {
+ if (!isset($_REQUEST['method'])) {
+ $this->gen_js();
+ die();
+ } else {
+ try {
+ $old_error_handler = set_error_handler(array('KISS_Controller_JSON',"myErrorHandler"));
+ $this->ins = new $class_name();
+ } catch (Exception $error) {
+ $this->showMessage($error->getMessage());
+ }
+ }
+
+ } else {
+ $this->showMessage("文件不存在!\\r".$_SERVER['SCRIPT_URI']);
+ }
+ if (isset($_REQUEST['method'])) {
+ $return = array();
+ try {
+ $old_error_handler = set_error_handler(array('KISS_Controller_JSON',"myErrorHandler"));
+ if(get_magic_quotes_gpc()===1){
+ $_REQUEST['parameters'] = stripslashes($_REQUEST['parameters']);
+ }
+ $return = array('data'=>call_user_func_array(array(&$this->ins,$_REQUEST['method']),json_decode($_REQUEST['parameters'])));
+ } catch (Exception $error) {
+ $return = array('message'=>$error->getMessage());
+ }
+ echo json_encode($return);
+ }
+ }
+
+ public static function myErrorHandler($errno, $errstr, $errfile, $errline, $errcontext){
+ return true;
+ $trace_array = debug_backtrace();
+ array_shift($trace_array);
+ $file = '';
+ for ($i=0;$i<count($trace_array);$i++) {
+ $file.=(isset($trace_array[$i]['file'])?$trace_array[$i]['file']:serialize($trace_array[$i])).'('.(isset($trace_array[$i]['line'])?$trace_array[$i]['line']:0).")\n";
+ }
+ $return = array('Exception'=>"{$errfile}({$errline}):{$errstr}",'option_msg'=>$file);
+ die(json_encode($return));
+ return true;
+ }
+
+ public function showMessage($pMessage) {
+ echo "alert('{$pMessage}');";
+ die();
+ }
+
+ public function gen_js() {
+ $json_array = KISS_Framework_Config::$annotation['class_function'];
+ foreach ($json_array as $class => $value) {
+ echo "\n{$class} = {\n URL : '_JSON_{$class}.php'";
+ echo ",\n name : '{$class}'";
+ foreach ($value as $function => $item) {
+ echo ",\n {$function} : function(){KISS.rpc.apply(this, new Array('{$function}',arguments));}";
+ }
+ echo "\n}";
+ }
+ }
+}
+?>
View
29 Controller/PHP.php
@@ -0,0 +1,29 @@
+<?php
+class KISS_Controller_PHP {
+ private $ins;
+ public function __construct($class_name){
+ if (class_exists($class_name)) {
+ try {
+ $this->ins = new $class_name();
+ } catch (Exception $error) {
+ $this->showMessage($error->getMessage());
+ }
+ } else {
+ $this->showMessage("Îļþ²»´æÔÚ£¡\\r".$_SERVER['SCRIPT_URI']);
+ }
+ }
+
+ public function run() {
+ $parameters = array();
+ if (array_key_exists('parameters', $_REQUEST)) {
+ $parameters = unserialize(stripslashes($_REQUEST['parameters']));
+ }
+ echo serialize(call_user_func_array(array(&$this->ins,$_REQUEST['method']), is_array($parameters)?$parameters:array()));
+ }
+
+ public function showMessage($pMessage) {
+ echo "alert('{$pMessage}');";
+ die();
+ }
+}
+?>
View
50 Data/DataSet/Schema/Database.php
@@ -0,0 +1,50 @@
+<?php
+class KISS_Data_DataSet_Schema_Database {
+ static $schema;
+ private $link;
+ function init() {
+ if (is_null(self::$schema)) {
+ self::$schema = self::readTables();
+ }
+ return self::$schema;
+ }
+
+ function readTables() {
+ $link = mysql_connect('localhost', 'root', 'M2oNa3D9');
+ $result = mysql_list_tables('test', $link);
+ $tables = array();
+ while ($row = mysql_fetch_row($result)) {
+ $name = $row[0];
+ $columns = self::readColumns(mysql_list_fields('album', $name, $link));
+ $keys = self::readKeys(mysql_list_fields('album', $name, $link));
+ $tables[$name] = array('columns'=>$columns, 'keys'=>$keys);
+ }
+ return $tables;
+ }
+
+ function readColumns($result) {
+ $columns = array();
+ $column_num = mysql_num_fields($result);
+ for ($i = 0; $i < $column_num; $i++) {
+ $name = mysql_field_name($result, $i);
+ $type = mysql_field_type($result, $i);
+ $conums[$name] = array('type' => $type);
+ }
+ return $conums;
+ }
+
+ function readKeys($result) {
+ $keys = array('primary'=>array(), 'foreign'=>array());
+ $column_num = mysql_num_fields($result);
+ for ($i = 0; $i < $column_num; $i++) {
+ $column = mysql_field_name($result, $i);
+ $table = mysql_field_table($result, $i);
+ if(strpos(mysql_field_flags($result, $i), 'primary_key') > 0) {
+ $type = 'primary';
+ $keys[$type][$table] = array('type' => $type, 'table' => $table, 'column' => $column);
+ }
+ }
+ return $keys;
+ }
+}
+?>
View
44 Data/DataSet/Schema/XML.php
@@ -0,0 +1,44 @@
+<?php
+class KISS_Data_DataSet_Schema_XML {
+ static $schema;
+ function init() {
+ if (is_null(self::$schema)) {
+ $schema = simplexml_load_file('database.xml');
+ self::$schema = self::readTables($schema->table);
+ }
+ return self::$schema;
+ }
+
+ function readTables($config) {
+ $tables = array();
+ foreach ($config as $table){
+ $name = (string)$table['name'];
+ $columns = self::readColumns($table->column);
+ $keys = self::readKeys($table->key);
+ $tables[$name] = array('columns'=>$columns, 'keys'=>$keys);
+ }
+ return $tables;
+ }
+
+ function readColumns($config) {
+ $conums = array();
+ foreach ($config as $column) {
+ $name = (string)$column['name'];
+ $type = (string)$column['type'];
+ $conums[$name] = array('type' => $type);
+ }
+ return $conums;
+ }
+
+ function readKeys($config) {
+ $keys = array('primary'=>array(), 'foreign'=>array());
+ foreach ($config as $key) {
+ $column = (string)$key['column'];
+ $table = (string)$key['table'];
+ $type = (string)$key['type'];
+ $keys[$type][$table] = array('type' => $type, 'table' => $table, 'column' => $column);
+ }
+ return $keys;
+ }
+}
+?>
View
124 DataObject.php
@@ -0,0 +1,124 @@
+<?php
+class KISS_DataObject {
+ private $table;
+ private $data = array();
+ //public $property = array();
+ public static $objects = array();
+ public $object_id = 0;
+ function __construct($table, $keys =array()) {
+ $this->object_id = uniqid();
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ $this->table = $table;
+ if (count($keys) > 0) {
+ $this->_select($keys);
+ }
+ $values = array_values($keys);
+ KISS_DataObject::$objects[$table][$values[0]] = $this;
+ }
+
+ function __get($pKey) {
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ //¼ì²éÍâ¼ü
+ $table = $this->table;
+ $foreign_keys = &$schema[$this->table]['keys']['foreign'];
+ if (array_key_exists($pKey,$schema) && array_key_exists($pKey, $foreign_keys)) {
+ if (!isset($this->data[$pKey]) || is_null($this->data[$pKey])) {
+ $code = "\$this->data['{$pKey}'] = $pKey::find(\$this->get_column('{$foreign_keys[$pKey]['column']}'));";
+ eval($code);
+ }
+ return $this->data[$pKey];
+ }
+ elseif (array_key_exists($pKey,$schema) && array_key_exists($this->table, $schema[$pKey]['keys']['foreign'])) {
+ if (!isset($this->data[$pKey]) || is_null($this->data[$pKey])) {
+ $results = KISS_SQLObject::getFetchQuery($pKey,array($schema[$pKey]['keys']['foreign'][$this->table]['column'] => $this->get_column($schema[$pKey]['keys']['foreign'][$this->table]['column'])));
+ foreach ($results as $result) {
+ $code = "\$this->data['{$pKey}'][] = {$pKey}::find('{$result['student_id']}');";
+ eval($code);
+ }
+ }
+ return $this->data[$pKey];
+ } elseif (array_key_exists($pKey, $this->data)) {
+ return $this->data[$pKey];
+ }
+ }
+
+ private function has_column($pKey) {
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ return array_key_exists($pKey, $schema[$this->table]['columns']);
+ }
+
+ private function set_column($pKey, $pValue) {
+ if ($this->has_column($pKey)) {
+ $this->data[$pKey] = $pValue;
+ }
+ }
+
+ public function get_columns() {
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ return $schema[$this->table]['columns'];
+ }
+
+ public function get_keys() {
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ return $schema[$this->table]['keys'];
+ }
+
+ private function get_column($pKey) {
+ if ($this->has_column($pKey)) {
+ return $this->data[$pKey];
+ }
+ }
+
+ private function _select($keys) {
+ $result = KISS_SQLObject::getFetchQuery($this->table, $keys);
+ $this->_fill($result[0]);
+ }
+
+ public function _save() {
+ return KISS_SQLObject::_save($this);
+ }
+
+ public function _delete() {
+ if (KISS_SQLObject::_delete($this)) {
+ $this->_reset();
+ return true;
+ }
+ return false;
+ }
+
+ public function _reset() {
+ }
+
+ private function _fill($pData) {
+ foreach ($pData as $key=>$value){
+ $this->set_column($key, $value);
+ }
+ }
+
+ function __sleep() {
+ $this->property = array();
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ foreach ($schema[$this->table]['columns'] as $key => $value) {
+ $this->property[$key] = $this->data[$key];
+ }
+ $this->property['_table'] = $this->table;
+ return array('property');
+ }
+
+ function __wakeup() {
+ $schema = KISS_Data_DataSet_Schema_XML::init();
+ foreach ($schema[$this->property['_table']]['columns'] as $key => $value) {
+ $this->data[$key] = $this->property[$key];
+ }
+ $this->table = $this->property['_table'];
+ $this->property = array();
+ }
+
+ static function find($pTable, $pPrimaryKey) {
+ if (isset(KISS_DataObject::$objects[$pTable][$pPrimaryKey]))
+ return KISS_DataObject::$objects[$pTable][$pPrimaryKey];
+ else
+ return new $pTable($pPrimaryKey);
+ }
+}
+?>
View
202 DistributedFileSystem.php
@@ -0,0 +1,202 @@
+<?php
+class KISS_DistributedFileSystem {
+ private $_Root;
+ public function __construct() {
+ $this->_Root = dirname($_SERVER['SCRIPT_FILENAME']);
+ }
+ public function Delete($pFilename) {
+ $filename = $this->_Root.$pFilename;
+ @unlink($filename);
+ return !file_exists($filename);
+ }
+ public function freeSpace() {
+ return disk_free_space($this->_Root)/1024;
+ }
+ public function uploadByURL($pUrl, $pCheckSize=0, $pCheckMD5='') {
+ $url_info = parse_url($pUrl);
+ $return = pathinfo($url_info['path']);
+
+ $path_relatively = date("/Y/m/d", time());
+ $path_absolute = "{$this->_Root}{$path_relatively}";
+
+ do {
+ $file = uniqid();
+ $file_absolute = "{$path_absolute}/{$file}";
+ }
+ while (file_exists($file_absolute));
+
+ $this->_exec("mkdir -p {$path_absolute}");
+ $this->_exec("wget -q -O '{$file_absolute}' '{$pUrl}'");
+ if (file_exists($file_absolute) && ((0 == $pCheckSize) || (filesize($file_absolute) == $pCheckSize)) && (('' == $pCheckMD5) || (md5_file($file_absolute) == $pCheckMD5))) {
+ $return['size'] = filesize($file_absolute);
+ $return['system_path'] = $path_relatively;
+ $return['system_file'] = $file;
+ return $return;
+ }
+ @unlink($file_absolute);