00001 <?php
00017 class STransaction extends SObject {
00019 private $transId = null;
00021 private $previousTransId = null;
00023 private $transLog = array();
00024
00033 public function getTransaction() {
00034
00035 if ($this->transId != null)
00036 return ($this->transId);
00037
00038 $date = time();
00039 $ip = $_SERVER['REMOTE_ADDR'];
00040 $rand = rand(0, 100000);
00041 $page = $_SERVER['REQUEST_URI'];
00042 $this->transId = MD5($date . $ip . $rand . $page);
00043
00044 return ($this->transId);
00045 }
00046
00055 public function setTransaction($a) {
00056 array_push($this->transLog, $this->previousTransId);
00057 $this->previousTransId = $a;
00058 $this->transId = null;
00059 }
00060
00070 public function getValidTransaction($a) {
00071 $prevTrans = $this->getPreviousTransactionId();
00072
00073 # if it was the previous transaction, return false quickly
00074 if ($a == $prevTrans) return (false);
00075
00076 # if not, check through the entire history of transactions
00077 for ($i = 0; $i < count($this->transLog); $i++) {
00078 if ($a == $this->transLog[$i]) return (false);
00079 }
00080 return (true);
00081 }
00082
00090 public function getTransactionId() {
00091 return ($this->transId);
00092 }
00093
00099 public function getPreviousTransactionId() {
00100 return ($this->previousTransId);
00101 }
00102
00109 public function __sleep() {
00110 return array_keys(get_object_vars($this));
00111 }
00112
00119 public function __wakeup() {
00120 return array_keys(get_object_vars($this));
00121 }
00122 }
00123 ?>