diff --git a/README.md b/README.md index 3e5f00c..0095c26 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,5 @@ -practise -======== -this repo contains the things that i have practise. \ No newline at end of file +# PHP practise code of @codeanit + +> TODO: +> This will be streamlined for better usage. diff --git a/SandersW-LearningPHPDesignPatterns/proxy/Client.php b/SandersW-LearningPHPDesignPatterns/proxy/Client.php new file mode 100644 index 0000000..b5f3aba --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/Client.php @@ -0,0 +1,30 @@ +tableMaster="proxy_log"; + $this->hookup=UniversalConnect::doConnect(); + $this->un=$this->hookup->real_escape_string(trim($_POST['uname'])); + $this->pw=$this->hookup->real_escape_string(trim($_POST['pw'])); + + $this->getIface($this->proxy=new Proxy()); + } + private function getIface(ISubject $proxy) + { + $proxy->login($this->un,$this->pw); + } +} +$worker=new Client(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/ConnectClient.php b/SandersW-LearningPHPDesignPatterns/proxy/ConnectClient.php new file mode 100644 index 0000000..f50c058 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/ConnectClient.php @@ -0,0 +1,19 @@ +hookup=UniversalConnect::doConnect(); +} +} +$worker=new ConnectClient(); \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/CreateTable.php b/SandersW-LearningPHPDesignPatterns/proxy/CreateTable.php new file mode 100644 index 0000000..85203cb --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/CreateTable.php @@ -0,0 +1,44 @@ +tableMaster="proxyLog"; + $this->hookup=UniversalConnect::doConnect(); + $drop = "DROP TABLE IF EXISTS $this->tableMaster"; + if($this->hookup->query($drop) === true) + { + printf("Old table %s has been dropped.
",$this->tableMaster); + } + echo $sql = "CREATE TABLE $this->tableMaster (uname NVARCHAR(15), + pw NVARCHAR(120)"; die; + print_r($this->hookup->query($sql)); die; + if($this->hookup->query($sql) === true) + { + echo "Table $this->tableMaster has been created successfully.
"; + } + $this->hookup->close(); + } +} + $worker=new CreateTable(); + + + /* + * use proxy_practise; +CREATE TABLE IF NOT EXISTS `proxy_log` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `uname` varchar(11) NOT NULL, + `pw` varchar(11) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1; + */ \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/HashRegister.php b/SandersW-LearningPHPDesignPatterns/proxy/HashRegister.php new file mode 100644 index 0000000..78bfd6c --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/HashRegister.php @@ -0,0 +1,34 @@ +tableMaster="proxy_log"; +$this->hookup=UniversalConnect::doConnect(); +$username=$this->hookup->real_escape_string(trim($_POST['uname'])); +$pwNow=$this->hookup->real_escape_string(trim($_POST['pw'])); +$sql = "INSERT INTO $this->tableMaster (uname,pw) VALUES ('$username', +md5('$pwNow'))"; +if($this->hookup->query($sql)) +{ +echo "Registration completed:"; +} +elseif ( ($result = $this->hookup->query($sql))===false ) +{ +printf("Invalid query: %s
Whole query: %s
", + $this->hookup->error, $sql); +exit(); +} +$this->hookup->close(); +} +} +$worker=new HashRegister(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/IConnectInfo.php b/SandersW-LearningPHPDesignPatterns/proxy/IConnectInfo.php new file mode 100644 index 0000000..fd5145a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/IConnectInfo.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/Proxy.php b/SandersW-LearningPHPDesignPatterns/proxy/Proxy.php new file mode 100644 index 0000000..089af72 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/Proxy.php @@ -0,0 +1,60 @@ +logGood=false; +//Choose table and connect +$this->tableMaster="proxy_log"; +$this->hookup=UniversalConnect::doConnect(); +//Create MySQL statement +$sql = "SELECT pw FROM $this->tableMaster WHERE uname='$uname'"; +if($result=$this->hookup->query($sql)) +{ +$row=$result->fetch_array(MYSQLI_ASSOC); + +if($row['pw']== substr($pw, 0, 11)) +{ +$this->logGood=true; +} +$result->close(); +} +elseif ( ($result = $this->hookup->query($sql))===false ) +{ +printf("Failed: %s
", $this->hookup->error); +exit(); +} +$this->hookup->close(); +if($this->logGood) +{ +$this->request(); +} +else{ +echo "Username and/or Password not on record."; +} +} +public function request() +{ +$this->realSubject=new RealSubject(); +$this->realSubject->request(); +} +} \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/RealSubject.php b/SandersW-LearningPHPDesignPatterns/proxy/RealSubject.php new file mode 100644 index 0000000..efa7d50 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/RealSubject.php @@ -0,0 +1,36 @@ + + + + + + + +
PHP Tip Sheet:
+For OOP Developers
+
    +
  1. Program to the interface and not the implementation.
  2. +
  3. Encapsulate your objects.
  4. +
  5. Favor composition over class inheritance.
  6. +
  7. A class should only have a single responsibility.
  8. +
+ + +REQUEST; +echo $practice; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/UniversalConnect.php b/SandersW-LearningPHPDesignPatterns/proxy/UniversalConnect.php new file mode 100644 index 0000000..3ca9132 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/UniversalConnect.php @@ -0,0 +1,34 @@ +CREATE TABLE proxyLog (uname NVARCHAR(15), + pw NVARCHAR(120) \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/login.html b/SandersW-LearningPHPDesignPatterns/proxy/login.html new file mode 100644 index 0000000..5659a8d --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/login.html @@ -0,0 +1,24 @@ + + + + +Proxy Login + + + +
Login
+
+
+
+Username:
+ +
+Password:
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Client.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Client.php new file mode 100644 index 0000000..b5f3aba --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Client.php @@ -0,0 +1,30 @@ +tableMaster="proxy_log"; + $this->hookup=UniversalConnect::doConnect(); + $this->un=$this->hookup->real_escape_string(trim($_POST['uname'])); + $this->pw=$this->hookup->real_escape_string(trim($_POST['pw'])); + + $this->getIface($this->proxy=new Proxy()); + } + private function getIface(ISubject $proxy) + { + $proxy->login($this->un,$this->pw); + } +} +$worker=new Client(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/ConnectClient.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/ConnectClient.php new file mode 100644 index 0000000..f50c058 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/ConnectClient.php @@ -0,0 +1,19 @@ +hookup=UniversalConnect::doConnect(); +} +} +$worker=new ConnectClient(); \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/CreateTable.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/CreateTable.php new file mode 100644 index 0000000..85203cb --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/CreateTable.php @@ -0,0 +1,44 @@ +tableMaster="proxyLog"; + $this->hookup=UniversalConnect::doConnect(); + $drop = "DROP TABLE IF EXISTS $this->tableMaster"; + if($this->hookup->query($drop) === true) + { + printf("Old table %s has been dropped.
",$this->tableMaster); + } + echo $sql = "CREATE TABLE $this->tableMaster (uname NVARCHAR(15), + pw NVARCHAR(120)"; die; + print_r($this->hookup->query($sql)); die; + if($this->hookup->query($sql) === true) + { + echo "Table $this->tableMaster has been created successfully.
"; + } + $this->hookup->close(); + } +} + $worker=new CreateTable(); + + + /* + * use proxy_practise; +CREATE TABLE IF NOT EXISTS `proxy_log` ( + `id` int(11) UNSIGNED NOT NULL AUTO_INCREMENT, + `uname` varchar(11) NOT NULL, + `pw` varchar(11) NOT NULL, + PRIMARY KEY (`id`) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8 CHECKSUM=1 DELAY_KEY_WRITE=1 ROW_FORMAT=DYNAMIC AUTO_INCREMENT=1; + */ \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/HashRegister.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/HashRegister.php new file mode 100644 index 0000000..78bfd6c --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/HashRegister.php @@ -0,0 +1,34 @@ +tableMaster="proxy_log"; +$this->hookup=UniversalConnect::doConnect(); +$username=$this->hookup->real_escape_string(trim($_POST['uname'])); +$pwNow=$this->hookup->real_escape_string(trim($_POST['pw'])); +$sql = "INSERT INTO $this->tableMaster (uname,pw) VALUES ('$username', +md5('$pwNow'))"; +if($this->hookup->query($sql)) +{ +echo "Registration completed:"; +} +elseif ( ($result = $this->hookup->query($sql))===false ) +{ +printf("Invalid query: %s
Whole query: %s
", + $this->hookup->error, $sql); +exit(); +} +$this->hookup->close(); +} +} +$worker=new HashRegister(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/IConnectInfo.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/IConnectInfo.php new file mode 100644 index 0000000..fd5145a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/IConnectInfo.php @@ -0,0 +1,17 @@ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Proxy.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Proxy.php new file mode 100644 index 0000000..089af72 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/Proxy.php @@ -0,0 +1,60 @@ +logGood=false; +//Choose table and connect +$this->tableMaster="proxy_log"; +$this->hookup=UniversalConnect::doConnect(); +//Create MySQL statement +$sql = "SELECT pw FROM $this->tableMaster WHERE uname='$uname'"; +if($result=$this->hookup->query($sql)) +{ +$row=$result->fetch_array(MYSQLI_ASSOC); + +if($row['pw']== substr($pw, 0, 11)) +{ +$this->logGood=true; +} +$result->close(); +} +elseif ( ($result = $this->hookup->query($sql))===false ) +{ +printf("Failed: %s
", $this->hookup->error); +exit(); +} +$this->hookup->close(); +if($this->logGood) +{ +$this->request(); +} +else{ +echo "Username and/or Password not on record."; +} +} +public function request() +{ +$this->realSubject=new RealSubject(); +$this->realSubject->request(); +} +} \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/RealSubject.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/RealSubject.php new file mode 100644 index 0000000..efa7d50 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/RealSubject.php @@ -0,0 +1,36 @@ + + + + + + + +
PHP Tip Sheet:
+For OOP Developers
+
    +
  1. Program to the interface and not the implementation.
  2. +
  3. Encapsulate your objects.
  4. +
  5. Favor composition over class inheritance.
  6. +
  7. A class should only have a single responsibility.
  8. +
+ + +REQUEST; +echo $practice; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/UniversalConnect.php b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/UniversalConnect.php new file mode 100644 index 0000000..3ca9132 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/UniversalConnect.php @@ -0,0 +1,34 @@ +CREATE TABLE proxyLog (uname NVARCHAR(15), + pw NVARCHAR(120) \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/login.html b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/login.html new file mode 100644 index 0000000..5659a8d --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/login.html @@ -0,0 +1,24 @@ + + + + +Proxy Login + + + +
Login
+
+
+
+Username:
+ +
+Password:
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.css b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.css new file mode 100644 index 0000000..af9bfdd --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.css @@ -0,0 +1,32 @@ +/* +To change this license header, choose License Headers in Project Properties. +To change this template file, choose Tools | Templates +and open the template in the editor. +*/ +/* + Created on : Mar 20, 2014, 4:07:05 PM + Author : Anit Shrestha +*/ + +@charset "UTF-8"; +/* CSS Document */ +/*EFECCA,046380,002F2F */ +body { +margin-left:20px; +font-family:Verdana, Geneva, sans-serif; +background-color:#EFECCA; +} +header { + font-family: "Arial Black", Gadget, sans-serif; +font-size:24px; +color:#002F2F; +} +#entry { +font-size:11; +color:#046380; +} +.subhead +{ +font-size:16px; +font-family:Verdana, Geneva, sans-serif; +} \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.html b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.html new file mode 100644 index 0000000..aed4aff --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy-login/proxy.html @@ -0,0 +1,24 @@ + + + + + +Username/Password Registration + + +
Registration
+
+
+
+Username: (15 Characters Max-No spaces)
+ +
+Password: (10 Characters Max-No spaces)
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy.css b/SandersW-LearningPHPDesignPatterns/proxy/proxy.css new file mode 100644 index 0000000..af9bfdd --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy.css @@ -0,0 +1,32 @@ +/* +To change this license header, choose License Headers in Project Properties. +To change this template file, choose Tools | Templates +and open the template in the editor. +*/ +/* + Created on : Mar 20, 2014, 4:07:05 PM + Author : Anit Shrestha +*/ + +@charset "UTF-8"; +/* CSS Document */ +/*EFECCA,046380,002F2F */ +body { +margin-left:20px; +font-family:Verdana, Geneva, sans-serif; +background-color:#EFECCA; +} +header { + font-family: "Arial Black", Gadget, sans-serif; +font-size:24px; +color:#002F2F; +} +#entry { +font-size:11; +color:#046380; +} +.subhead +{ +font-size:16px; +font-family:Verdana, Geneva, sans-serif; +} \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/proxy/proxy.html b/SandersW-LearningPHPDesignPatterns/proxy/proxy.html new file mode 100644 index 0000000..aed4aff --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/proxy/proxy.html @@ -0,0 +1,24 @@ + + + + + +Username/Password Registration + + +
Registration
+
+
+
+Username: (15 Characters Max-No spaces)
+ +
+Password: (10 Characters Max-No spaces)
+ +
+ +
+
+
+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/Client.php b/SandersW-LearningPHPDesignPatterns/strategy/Client.php new file mode 100644 index 0000000..e57ba1a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/Client.php @@ -0,0 +1,37 @@ +algorithm(); +} +public function findData() +{ +$context=new Context(new SearchData()); +$context->algorithm(); +} +public function showAll() +{ +$context=new Context(new DisplayData()); +$context->algorithm(); +} +public function changeData() +{ +$context=new Context(new UpdateData()); +$context->algorithm(); +} +public function killer() +{ +$context=new Context(new DeleteRecord()); +$context->algorithm(); +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/Context.php b/SandersW-LearningPHPDesignPatterns/strategy/Context.php new file mode 100644 index 0000000..d6fcc1a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/Context.php @@ -0,0 +1,21 @@ +strategy = $strategy; +} +public function algorithm() +{ +$this->strategy->algorithm(); +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/DataEntry.php b/SandersW-LearningPHPDesignPatterns/strategy/DataEntry.php new file mode 100644 index 0000000..48db4a1 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/DataEntry.php @@ -0,0 +1,18 @@ +real_escape_string($_POST['data']); +echo "This data has been entered: " . $test . "
"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/DeleteRecord.php b/SandersW-LearningPHPDesignPatterns/strategy/DeleteRecord.php new file mode 100644 index 0000000..8b94b75 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/DeleteRecord.php @@ -0,0 +1,19 @@ +real_escape_string($_POST['data']); +echo "The record " . $test . "has been deleted.
"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/DisplayData.php b/SandersW-LearningPHPDesignPatterns/strategy/DisplayData.php new file mode 100644 index 0000000..c01f5f7 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/DisplayData.php @@ -0,0 +1,18 @@ +"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/IConnectInfo.php b/SandersW-LearningPHPDesignPatterns/strategy/IConnectInfo.php new file mode 100644 index 0000000..61cd2d8 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/IConnectInfo.php @@ -0,0 +1,18 @@ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/IStrategy.php b/SandersW-LearningPHPDesignPatterns/strategy/IStrategy.php new file mode 100644 index 0000000..7095fc5 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/IStrategy.php @@ -0,0 +1,13 @@ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/SearchData.php b/SandersW-LearningPHPDesignPatterns/strategy/SearchData.php new file mode 100644 index 0000000..5de1682 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/SearchData.php @@ -0,0 +1,19 @@ +real_escape_string($_POST['data']); +echo "Here's what you were looking for " . $test . "
"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/UniversalConnect.php b/SandersW-LearningPHPDesignPatterns/strategy/UniversalConnect.php new file mode 100644 index 0000000..3463d9c --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/UniversalConnect.php @@ -0,0 +1,32 @@ +"; +} +elseif (mysqli_connect_error(self::$hookup)) +{ +echo('Here is why it failed: ' . mysqli_connect_error()); +} +return self::$hookup; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/UpdateData.php b/SandersW-LearningPHPDesignPatterns/strategy/UpdateData.php new file mode 100644 index 0000000..bc62e5a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/UpdateData.php @@ -0,0 +1,18 @@ +real_escape_string($_POST['data']); +echo "Your new data is now " . $test . "
"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/displayTrigger.php b/SandersW-LearningPHPDesignPatterns/strategy/displayTrigger.php new file mode 100644 index 0000000..b15e6da --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/displayTrigger.php @@ -0,0 +1,15 @@ +showAll(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/findTrigger.php b/SandersW-LearningPHPDesignPatterns/strategy/findTrigger.php new file mode 100644 index 0000000..8a568d2 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/findTrigger.php @@ -0,0 +1,15 @@ +findData(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/insertTrigger.php b/SandersW-LearningPHPDesignPatterns/strategy/insertTrigger.php new file mode 100644 index 0000000..e364b33 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/insertTrigger.php @@ -0,0 +1,16 @@ +insertData(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/killTrigger.php b/SandersW-LearningPHPDesignPatterns/strategy/killTrigger.php new file mode 100644 index 0000000..9c1a5ac --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/killTrigger.php @@ -0,0 +1,16 @@ +killer(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/strategy.html b/SandersW-LearningPHPDesignPatterns/strategy/strategy.html new file mode 100644 index 0000000..3ad5462 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/strategy.html @@ -0,0 +1,41 @@ + + + + +Test + + +Insert
+
+ +
+ +
+
+Find Data +
+ +
+ +
+
+Display All Data +
+ +
+
+Update Data +
+ +
+ +
+
+Delete Record +
+ +
+ +
+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/strategy/updateTrigger.php b/SandersW-LearningPHPDesignPatterns/strategy/updateTrigger.php new file mode 100644 index 0000000..424c110 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/strategy/updateTrigger.php @@ -0,0 +1,15 @@ +changeData(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Client.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Client.php new file mode 100644 index 0000000..c47a691 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Client.php @@ -0,0 +1,16 @@ +templateMethod(); + } +} + +$worker=new Client(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Creator.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Creator.php new file mode 100644 index 0000000..105a1d0 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Creator.php @@ -0,0 +1,13 @@ +factoryMethod(); + return $mfg; + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicFactory.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicFactory.php new file mode 100644 index 0000000..3a6f0e8 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicFactory.php @@ -0,0 +1,11 @@ +getProperties()); + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicProduct.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicProduct.php new file mode 100644 index 0000000..1e17f48 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/GraphicProduct.php @@ -0,0 +1,13 @@ +mfgProduct=""; + return $this->mfgProduct; + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Product.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Product.php new file mode 100644 index 0000000..2109708 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/Product.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextFactory.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextFactory.php new file mode 100644 index 0000000..b6155b8 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextFactory.php @@ -0,0 +1,11 @@ +getProperties()); + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextProduct.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextProduct.php new file mode 100644 index 0000000..b99d22d --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TextProduct.php @@ -0,0 +1,17 @@ +mfgProduct ="
+ Caption: Modigliani + painted elongated faces.
"; + + return $this->mfgProduct; + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmAb.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmAb.php new file mode 100644 index 0000000..c2906b7 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmAb.php @@ -0,0 +1,19 @@ +addPix(); + $this->addCaption(); + } + + protected abstract function addPix(); + + protected abstract function addCaption(); +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmFac.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmFac.php new file mode 100644 index 0000000..0cc8e5c --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/TmFac.php @@ -0,0 +1,18 @@ +pix=new GraphicFactory(); + echo $this->pix->doFactory(); + } + + protected function addCaption() { + $this->cap=new TextFactory(); + echo $this->cap->doFactory(); + } + +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/class-diagram.png b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/class-diagram.png new file mode 100644 index 0000000..7bfdd10 Binary files /dev/null and b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hollywood_principle/class-diagram.png differ diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/Client.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/Client.php new file mode 100644 index 0000000..fe968f8 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/Client.php @@ -0,0 +1,42 @@ +setHTML(); + $this->setCost(); + $this->zamCalc=new ZambeziCalc(); + $this->zamCalc->templateMethod($this->buyTotal,$this->special); + } + + private function setHTML() { + $this->gpsNow=$_POST['gps']; + $this->mapNow=$_POST['map']; + $this->boatNow=$_POST['boat']; + } + + private function setCost() { + $this->buyTotal=$this->gpsNow; + + foreach($this->mapNow as $value) { + $this->buyTotal+= $value; + } + //Boolean + $this->special = ($this->buyTotal >= 200); + $this->buyTotal += $this->boatNow; + } +} + +$worker=new Client(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/IHook.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/IHook.php new file mode 100644 index 0000000..990dd6a --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/IHook.php @@ -0,0 +1,21 @@ +purchased=$total; +$this->hookSpecial=$special; +$this->addTax(); +$this->addShippingHook(); +$this->displayCost(); +} +protected abstract function addTax(); +protected abstract function addShippingHook(); +protected abstract function displayCost(); +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/ZambeziCalc.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/ZambeziCalc.php new file mode 100644 index 0000000..2ae7eac --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/ZambeziCalc.php @@ -0,0 +1,21 @@ +fullCost = $this->purchased + ($this->purchased * .07); +} +protected function addShippingHook() +{ +if(! $this->hookSpecial) +{ +$this->fullCost += 12.95; +} +} +protected function displayCost() +{ +echo "Your full cost is $this->fullCost"; +} +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.css b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.css new file mode 100644 index 0000000..73356ac --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.css @@ -0,0 +1,31 @@ +/* +To change this license header, choose License Headers in Project Properties. +To change this template file, choose Tools | Templates +and open the template in the editor. +*/ +/* + Created on : Feb 16, 2014, 11:59:32 AM + Author : Anit Shrestha +*/ + + +@charset "UTF-8"; +/* CSS Document */ +/*zambezi.css */ +/*D9C68F,F2DAC4,A69586,73635A,592D23*/ +body { +background-color: #f2dac4; +color: #73635a; +font-family: Verdana, Geneva, sans-serif; +font-size: 12px; +} +h1 { +font-family:"Trebuchet MS", Arial, Helvetica, sans-serif; +font-size:36px; +} +h2 { +font-family: "Arial Black", Gadget, sans-serif; +font-size: 18px; +background-color: #592d23; +color: #d9c68f; +} \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.html b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.html new file mode 100644 index 0000000..b96a99b --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/hook/zambezi.html @@ -0,0 +1,48 @@ + + + + + +Zambezi Trading Post + +zam +

Adventure Outfitters

+
+

 Equipment

+

Navigation

+

GPS

+ + Curiosity $98  + + Cabot $112  + + Boomer $127  + + Livingston $189  +

Maps

+ + Zambia $20  + + Angola $29  + + Namibia $15  + + Botswana $15  + + Zimbabwe $30  + + Mozambique $27
+

 River Craft (Daily Rental)

+ + White Water Kayak $55
+ + Motorized Canoe $125
+ + Zodiac $250
+ + Steam Launch $495 +

+ +

+ + \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/AbstractClass.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/AbstractClass.php new file mode 100644 index 0000000..fd4ebf9 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/AbstractClass.php @@ -0,0 +1,32 @@ +pix=$pixNow; + $this->cap=$capNow; + $this->addPix($this->pix); + $this->addCaption($this->cap); + } + + abstract protected function addPix($pix); + + abstract protected function addCaption($cap); + + } +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/Client.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/Client.php new file mode 100644 index 0000000..e64172b --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/Client.php @@ -0,0 +1,24 @@ +templateMethod("genious.jpg", $caption); + } +} + +$worker=new Client(); +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/ConcreteClass.php b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/ConcreteClass.php new file mode 100644 index 0000000..85f8cc5 --- /dev/null +++ b/SandersW-LearningPHPDesignPatterns/template_method_pattern/minimal_example/ConcreteClass.php @@ -0,0 +1,30 @@ +pix=$pix; + $this->pix = "pix/" . $this->pix; + $formatter = "pix>
"; + echo $formatter; + } + + protected function addCaption($cap) { + $this->cap=$cap; + echo "Caption:" . $this->cap . "
"; + } +} +?> \ No newline at end of file diff --git a/SandersW-LearningPHPDesignPatterns/template_method_pattern/pix/genious.jpg b/SandersW-LearningPHPDesignPatterns/template_method_pattern/pix/genious.jpg new file mode 100644 index 0000000..6915b0d Binary files /dev/null and b/SandersW-LearningPHPDesignPatterns/template_method_pattern/pix/genious.jpg differ diff --git a/stripe-php b/stripe-php deleted file mode 160000 index 8d618cb..0000000 --- a/stripe-php +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 8d618cb4a090771edd2195c2f27b84746f98cb22