diff --git a/exam156/generate.php b/exam156/generate.php new file mode 100644 index 0000000..2019d93 --- /dev/null +++ b/exam156/generate.php @@ -0,0 +1,37 @@ += 1) { + $query_result = mysqli_fetch_assoc($query); + $email = $query_result['email']; + } else { + $email = 'ID not found'; + } +} else { + $email = 'No id specified.'; +} +$email_length = strlen($email); + +$font_size = 4; + +$image_height = imagefontheight($font_size); +$image_width = imagefontwidth($font_size) * $email_length; + +$image = imagecreate($image_width, $image_height); // Stvaranje prazne slike + +imagecolorallocate($image, 255, 255, 255); // boja pozadine podesena na belo +$font_color = imagecolorallocate($image, 0, 0, 0); // boja fonta podesena na belo + +imagestring($image, $font_size, 0, 0, $email, $font_color); +imagejpeg($image); diff --git a/exam156/index.php b/exam156/index.php new file mode 100644 index 0000000..1b200e7 --- /dev/null +++ b/exam156/index.php @@ -0,0 +1,4 @@ +Name:
+Alex

+Email:
+ \ No newline at end of file diff --git a/exam161/generate.php b/exam161/generate.php new file mode 100755 index 0000000..79b56bf --- /dev/null +++ b/exam161/generate.php @@ -0,0 +1,29 @@ + \ No newline at end of file diff --git a/exam161/index.php b/exam161/index.php new file mode 100755 index 0000000..9b90129 --- /dev/null +++ b/exam161/index.php @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/exam161/phone2.jpg b/exam161/phone2.jpg new file mode 100755 index 0000000..65076a5 Binary files /dev/null and b/exam161/phone2.jpg differ diff --git a/exam161/phone2.jpg.watermark.jpg b/exam161/phone2.jpg.watermark.jpg new file mode 100644 index 0000000..8dc6c0f Binary files /dev/null and b/exam161/phone2.jpg.watermark.jpg differ diff --git a/exam161/php.png b/exam161/php.png new file mode 100644 index 0000000..e99e319 Binary files /dev/null and b/exam161/php.png differ diff --git a/exam164/HappySwirly-KVB7l.ttf b/exam164/HappySwirly-KVB7l.ttf new file mode 100644 index 0000000..c315bc9 Binary files /dev/null and b/exam164/HappySwirly-KVB7l.ttf differ diff --git a/exam164/generate.php b/exam164/generate.php new file mode 100755 index 0000000..3e7ee2d --- /dev/null +++ b/exam164/generate.php @@ -0,0 +1,31 @@ + \ No newline at end of file diff --git a/exam164/index.php b/exam164/index.php new file mode 100755 index 0000000..e8bb7b7 --- /dev/null +++ b/exam164/index.php @@ -0,0 +1,27 @@ + +
+
+ +
+ Write a number from picture: + + +
\ No newline at end of file diff --git a/exam168/index.php b/exam168/index.php new file mode 100644 index 0000000..851a2c8 --- /dev/null +++ b/exam168/index.php @@ -0,0 +1,25 @@ + diff --git a/exam168/phone2.jpg b/exam168/phone2.jpg new file mode 100755 index 0000000..65076a5 Binary files /dev/null and b/exam168/phone2.jpg differ diff --git a/exam172/include.inc.php b/exam172/include.inc.php new file mode 100644 index 0000000..05a682b --- /dev/null +++ b/exam172/include.inc.php @@ -0,0 +1 @@ +Hello! \ No newline at end of file diff --git a/exam172/index.php b/exam172/index.php new file mode 100644 index 0000000..2274b9b --- /dev/null +++ b/exam172/index.php @@ -0,0 +1,45 @@ + + + + + + + + + + +
+ + + \ No newline at end of file diff --git a/exam175/index.php b/exam175/index.php new file mode 100644 index 0000000..7b60297 --- /dev/null +++ b/exam175/index.php @@ -0,0 +1,38 @@ + + + + + + + + + + +
+ + \ No newline at end of file diff --git a/exam175/search.inc.php b/exam175/search.inc.php new file mode 100644 index 0000000..3710dc7 --- /dev/null +++ b/exam175/search.inc.php @@ -0,0 +1,26 @@ +'; + } + } + +} + +?> \ No newline at end of file diff --git a/exam180/index.php b/exam180/index.php new file mode 100644 index 0000000..1f92008 --- /dev/null +++ b/exam180/index.php @@ -0,0 +1,41 @@ + + + + + + + + + + +Insert data: + +
+ + + \ No newline at end of file diff --git a/exam180/update.inc.php b/exam180/update.inc.php new file mode 100644 index 0000000..0e4bf4f --- /dev/null +++ b/exam180/update.inc.php @@ -0,0 +1,25 @@ + \ No newline at end of file diff --git a/exam185/trycatch.php b/exam185/trycatch.php new file mode 100644 index 0000000..523d130 --- /dev/null +++ b/exam185/trycatch.php @@ -0,0 +1,17 @@ + 18){ + echo 'Old enough.'; + } else { + throw new Exception('Not old enough'); + } +} catch(Exception $ex){ + echo 'Error: '. $ex -> getMessage(); +} + + +?> \ No newline at end of file diff --git a/exam187/customErrorMessage.php b/exam187/customErrorMessage.php new file mode 100644 index 0000000..a6f9aff --- /dev/null +++ b/exam187/customErrorMessage.php @@ -0,0 +1,35 @@ +getLine() . ' in ' . $this->getFile(); + } +} +class ServerException extends Exception +{ + public function showSpecific() + { + return 'Error thrown on line' . $this->getLine() . ' in ' . $this->getFile(); + } +} + +try { + if (!@$con = mysqli_connect($mysql_host, $mysql_user, $mysql_pass)) { + throw new ServerException(); + } else if (!@mysqli_select_db($con, $mysql_db)) { + throw new DatabaseException(); + } else { + echo 'Connected'; + } +} catch (ServerException $ex) { + echo $ex->showSpecific(); +} catch (DatabaseException $ex) { + echo $ex->showSpecific(); +} diff --git a/exam187/customEx.php b/exam187/customEx.php new file mode 100644 index 0000000..e98d4b1 --- /dev/null +++ b/exam187/customEx.php @@ -0,0 +1,27 @@ +getMessage(); +} catch (DatabaseException $ex) { + echo 'Error: ' . $ex->getMessage(); +} + + +?> \ No newline at end of file diff --git a/exam190/index.php b/exam190/index.php new file mode 100644 index 0000000..6e16eb5 --- /dev/null +++ b/exam190/index.php @@ -0,0 +1,31 @@ +balance . '
'; // Ovako pristupamo vrednosti balance 'pravimo referencu' + } + + public function Withdraw($amount) + { + if ($this->balance < $amount) { + echo 'Not enough money
'; + } else { + $this->balance = $this->balance - $amount; + } + } +} + +//nova instanca klase +$ba = new BankAccount; + + +echo $ba->DisplayBalance(); + +$ba->Withdraw(50); + +echo $ba->DisplayBalance(); diff --git a/exam193/index.php b/exam193/index.php new file mode 100644 index 0000000..ee30468 --- /dev/null +++ b/exam193/index.php @@ -0,0 +1,22 @@ +balance; + + } +} + +$alex = new BankAcount; + +echo $alex->DisplayBalance(); + + + +?> \ No newline at end of file diff --git a/exam194/constants.php b/exam194/constants.php new file mode 100644 index 0000000..abf5d32 --- /dev/null +++ b/exam194/constants.php @@ -0,0 +1,22 @@ +'; + + + +echo 'Area of circle is ' . $area->CircleArea(3); + +?> \ No newline at end of file diff --git a/exam194/constructor.php b/exam194/constructor.php new file mode 100644 index 0000000..df69d68 --- /dev/null +++ b/exam194/constructor.php @@ -0,0 +1,19 @@ + SaySomething($something); + } + + public function SaySomething($something){ + echo $something; + } +} + +$example = new Example('Some text'); + + + +?> \ No newline at end of file diff --git a/exam196/index.php b/exam196/index.php new file mode 100644 index 0000000..2c1d038 --- /dev/null +++ b/exam196/index.php @@ -0,0 +1,43 @@ +balance . '
'; // Ovako pristupamo vrednosti balance 'pravimo referencu' + } + + public function Withdraw($amount) + { + if ($this->balance < $amount) { + echo 'Not enough money
'; + } else { + $this->balance = $this->balance - $amount; + } + } + + public function Deposit($amount){ + $this->balance = $this->balance + $amount; + } +} + +//Multiple instances of class : +$alex = new BankAccount; +$billy = new BankAccount; + +$alex -> Deposit(100); +$billy -> Deposit(50); + +$alex -> Withdraw(98); +$billy -> Withdraw(12.5); + +echo $alex -> DisplayBalance(); +echo $billy -> DisplayBalance(); + + + + +?> \ No newline at end of file diff --git a/exam197/index.php b/exam197/index.php new file mode 100644 index 0000000..0dc33ba --- /dev/null +++ b/exam197/index.php @@ -0,0 +1,49 @@ +type = $input; + } + + public function DisplayBalance() + { + return 'Balance: ' . $this->balance . '
'; + } + + public function Withdraw($amount) + { + if ($this->balance < $amount) { + echo 'Not enough money
'; + } else { + $this->balance = $this->balance - $amount; + } + } + + public function Deposit($amount){ + $this->balance = $this->balance + $amount; + } +} + +class SavingsAccount extends BankAccount { +} + +$alex = new BankAccount; +$alex->SetType('18-25 Current'); +$alex->Deposit(100); +$alex->Withdraw(20); + +$alex_savings = new SavingsAccount; +$alex_savings -> Deposit(40); +$alex_savings->SetType('Super Saver'); + + +echo $alex-> type .' has ' .$alex->DisplayBalance(); +echo $alex_savings->type .' has ' .$alex_savings->DisplayBalance(); + + +?> \ No newline at end of file diff --git a/exam199/index.php b/exam199/index.php new file mode 100644 index 0000000..3b73963 --- /dev/null +++ b/exam199/index.php @@ -0,0 +1,28 @@ +Connect($db_host,$db_user,$db_pass)){ + echo 'Connection failed'; + } else { + echo 'Connected to '. $db_host; + } + } + + public function Connect($db_host, $db_user, $db_pass){ + if(!mysqli_connect($db_host,$db_user,$db_pass)){ + return false; + } else { + return true ; + } + + } +} + +$conn = new DatabaseConnect('localhost','example_user','Kolosnjaj4321!'); + +?>