Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Development
Flashback PHP - A Habbo CMS written in vanilla PHP
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Koala" data-source="post: 465408" data-attributes="member: 75856"><p>Done some work on this. School is taking way too much time atm. However, here are some updates. Feedback is more than welcome.</p><p>[SPOILER="register.tpl"]</p><p><img src="https://i.imgur.com/bHqQ3Ei.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></p><p>Decided to use bootstrap because I am terrible with CSS, well not terrible but I find it hard to be happy with what I do with it.</p><p>[/SPOILER]</p><p></p><p>Created a simple 'template engine' from scratch.</p><p>I am more than happy to take feedback on this. Since I am unsure if using something like this is heavily exploitable.</p><p>[CODE=php]<?php</p><p>//simple template engine for php 7.4</p><p>class Template {</p><p> public $template_data = array();</p><p> public $template;</p><p></p><p> public function __construct($path = '') {</p><p> if(!empty($path)) {</p><p> if(file_exists($path)) {</p><p> $this->template = file_get_contents($path);</p><p> } else {</p><p> echo '<b>Template Error: </b> File not found. If you see this message, please report it to the administrator.';</p><p> }</p><p> }</p><p> }</p><p></p><p> public function pass($search, $replace) {</p><p> if(!empty($search)) {</p><p> $this->template_data[strtoupper($search)] = htmlspecialchars($replace);</p><p> }</p><p> }</p><p></p><p> public function render() {</p><p> if(count($this->template_data) > 0) {</p><p> foreach($this->template_data as $key => $tpl_data) {</p><p> $this->template = str_replace('{'.$key.'}', $tpl_data, $this->template);</p><p> }</p><p> }</p><p> echo $this->template;</p><p> }</p><p>}[/CODE]</p><p></p><p>And here is how I am currently using it. <strong>I would be very, very happy if you guys with more experience with PHP could guide me towards right direction. I am sure that there are lot of bad practices in this file <img src="/styles/default/xenforo/smilies/emojione/biggrin.png" class="smilie" loading="lazy" alt=":D" title="Big Grin :D" data-shortname=":D" /></strong></p><p></p><p>[CODE=php]<?php</p><p>//includes</p><p>require_once 'include/session.php';</p><p>require_once 'include/autoload.php';</p><p>require_once 'include/database.php';</p><p></p><p>//some logc</p><p>$message = "";</p><p>$user = new User($pdo);</p><p></p><p>if(isset($_POST["submit"])) {</p><p> if(!empty($_POST["email"]) && !empty($_POST["username"]) && !empty($_POST["password"]) && !empty($_POST["verify"])) {</p><p> //assign user input to variables</p><p> $email = $_POST["email"];</p><p> $username = $_POST["username"];</p><p> $password = $_POST["password"];</p><p> $verify = $_POST["verify"];</p><p> //creates new user with username, password and email</p><p> if($user->newUser($username, $password, $email)) {</p><p> header("location: index.php");</p><p> }</p><p> } else {</p><p> $message = "Whoops, something went wrong! Please check all of the fields, and try again.";</p><p> }</p><p>}</p><p></p><p>//render template</p><p>$template = new Template(TEMPLATE_PATH.'/register.tpl.html');</p><p>$template->pass('register_message', $message);</p><p>$template->render();[/CODE]</p><p></p><p>Github still not up, I am super lazy.</p></blockquote><p></p>
[QUOTE="Koala, post: 465408, member: 75856"] Done some work on this. School is taking way too much time atm. However, here are some updates. Feedback is more than welcome. [SPOILER="register.tpl"] [IMG]https://i.imgur.com/bHqQ3Ei.png[/IMG] Decided to use bootstrap because I am terrible with CSS, well not terrible but I find it hard to be happy with what I do with it. [/SPOILER] Created a simple 'template engine' from scratch. I am more than happy to take feedback on this. Since I am unsure if using something like this is heavily exploitable. [CODE=php]<?php //simple template engine for php 7.4 class Template { public $template_data = array(); public $template; public function __construct($path = '') { if(!empty($path)) { if(file_exists($path)) { $this->template = file_get_contents($path); } else { echo '<b>Template Error: </b> File not found. If you see this message, please report it to the administrator.'; } } } public function pass($search, $replace) { if(!empty($search)) { $this->template_data[strtoupper($search)] = htmlspecialchars($replace); } } public function render() { if(count($this->template_data) > 0) { foreach($this->template_data as $key => $tpl_data) { $this->template = str_replace('{'.$key.'}', $tpl_data, $this->template); } } echo $this->template; } }[/CODE] And here is how I am currently using it. [B]I would be very, very happy if you guys with more experience with PHP could guide me towards right direction. I am sure that there are lot of bad practices in this file :D[/B] [CODE=php]<?php //includes require_once 'include/session.php'; require_once 'include/autoload.php'; require_once 'include/database.php'; //some logc $message = ""; $user = new User($pdo); if(isset($_POST["submit"])) { if(!empty($_POST["email"]) && !empty($_POST["username"]) && !empty($_POST["password"]) && !empty($_POST["verify"])) { //assign user input to variables $email = $_POST["email"]; $username = $_POST["username"]; $password = $_POST["password"]; $verify = $_POST["verify"]; //creates new user with username, password and email if($user->newUser($username, $password, $email)) { header("location: index.php"); } } else { $message = "Whoops, something went wrong! Please check all of the fields, and try again."; } } //render template $template = new Template(TEMPLATE_PATH.'/register.tpl.html'); $template->pass('register_message', $message); $template->render();[/CODE] Github still not up, I am super lazy. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Development
Flashback PHP - A Habbo CMS written in vanilla PHP
Top