-
Posts
94 -
Joined
-
Last visited
Content Type
Profiles
Forums
Events
Everything posted by Karlos94
-
Here is a slight update on your if() statement if(file_exists('ipbans/'.$IP.'.txt')) { echo 'You\'re banned dooood get outa here'; die($this->endpage()); }
-
Well I do agree with you, but some may however. Personally if they can't put in the extra effort to do this, they aren't appealing to everyone! I hope at least someone has a go, even if they fail it's at least the thought they have tried to implant it.
-
Oh I see, but the idea is there now, in case someone wishes to do it the way I said.
-
Lately there has been a lot of discussing about Facebook due to Spudinski and Haunted Dawg and their future Social Bookmarking modification/plug-in. However there was obviously going to be a slight opposition against this, myself being one of them. However recently on Nettuts+ there has been a tutorial released on how to authenticate users and how to connect to the Facebook API. The tutorial shows how to connect to the Facebook API via the OAuth 2.0 protocol, although the tutorial shows how to about the lazy registration it can be very informative. The tutorial link is: How to Authenticate Users With Facebook Connect.
-
Why not do it a nice simple way? Using a regularly updated XML file with the latest exchange rates, they aren't that hard to find. ;)
-
There is one problem, the way you have formatted it your making it looking powers.. I'd recommend having a look and rethinking how to display it.
-
Ahh I see, well if it was 100% personal to myself and no-one else would develop with myself then I would do it almost the same way... This is just so I can limit the amount of digits after the decimal are returned. ## Created by Karl Ballard function area_of_circle($rad, $dec_return = 2) { if (!is_int($dec_return)) { $dec_return = 2; } return $dec_return === false ? pi() * $rad * $rad : number_format(pi() * $rad * $rad, $dec_return); } ## Created By Karl Ballard function circum_of_circle($dia, $dec_return = 2) { if (!is_int($dec_return)) { $dec_return = 2; } return $dec_return === false ? pi() * $dia : number_format(pi() * $dia, $dec_return); }
-
I added more than the base code because I wanted to make the function to be used more easily and more customizable without editing the function source code.
-
Well I got bored this morning as I only have to go into school for exams and I have one today, maths! So I was wondering how I could help myself remember the formula to calculate the area of a circle and the circumference of a circle. So I was browsing this forum and I saw LordDan post a mathematics function to calculate percentage so I thought to myself that I should do this with the formula and create two functions. I ended up writing these functions and I have tested them but I would like to improve them if others are kind enough to give feedback and other ideas. Constructive criticism is welcome, flaming is not. <?php ## Created by Karl Ballard function area_of_circle($val, $radius = true, $dec_return = 3) { if (!is_numeric($val)) { return false; } if (!is_numeric($pi)) { $pi = pi(); } if ($radius === false) { $val = $val / 2; } return $dec_return === false ? $pi * $val * $val : number_format($pi * $val * $val, $dec_return); } ## Created By Karl Ballard function circum_of_circle($val, $radius = false, $dec_return = 3) { if (!is_numeric($val)) { return false; } if (!is_numeric($pi)) { $pi = pi(); } if ($radius === true) { $val = $val * 2; } return $dec_return === false ? $pi * $val : number_format($pi * $val, $dec_return); }
-
I've pretty unique on this forum then, I like being on of a kind... But am I really meant to appreciate it when I have just been called 'weird' by a webpage?
-
I can't be arsed with a lot today, so I'll nick the second idea. Let's go searching! O.o Edit: Turns out Nyna created a search: Search
-
Here is a debate I would like to bring to MakeWebGames, HTML 5. I personally have a few questions about it, which I shall list below, despite my questions I would like to know your opinions about HTML, what you believe the advantages and/or disadvantages of it is. I would love to sit here and write more but I am in a rush no, so sorry for being short, but it is sweet! Why should I develop with HTML 5 when it's not going to be completely ready until 2022? What are the benefits of developing with in now?
-
For example: InnoDb - Records and logs? MyISAM - General users table and tables with updates and inserts? Memory - To be honest, I'm not quite sure.
-
Ahh I see, could it I be an ass and ask what type of tables engine would be most efficient with certian types of data stored in there? Updating alot? Inserting and selecting? Selecting and updating? ect..
-
I read somewhere that only InnoDB currently supports foreign keys? Am I wrong to think MyISAM dosen't support foreign keys? Well some of the foreign keys don't have actions as I am still getting the concept of them, I am getting to understand them better.. CASCASE, RESTRICT, SET NULL and NO ACTION.
-
Admittedly I am no good with designing and creating MySQL database, however I have had a go today and I was wondering if someone could tell me what I am doing wrong/right or how I could do better! this would be much appreciated! P.s I know about the long, tedious insert queries at the bottom, they were generated. Not my fault ;) [mysql]SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0; SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0; SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL'; CREATE SCHEMA IF NOT EXISTS `mydb` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci ; -- ----------------------------------------------------- -- Table `mydb`.`group` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`group` ( `group_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT , `group_title` VARCHAR(20) NOT NULL , `group_role` VARCHAR(45) NOT NULL , PRIMARY KEY (`group_id`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`houses` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`houses` ( `house_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT , `house_name` VARCHAR(20) NOT NULL , `house_desc` VARCHAR(45) NULL DEFAULT NULL , `house_buy_price` INT(10) UNSIGNED NOT NULL DEFAULT 0 , `house_sale_price` INT(10) UNSIGNED NOT NULL , PRIMARY KEY (`house_id`) ) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`users_meta` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`users_meta` ( `user_id` INT(8) UNSIGNED NOT NULL , `house_id` INT(8) UNSIGNED NOT NULL DEFAULT 1 , PRIMARY KEY (`user_id`) , INDEX `fk_users_houses` (`house_id` ASC) , INDEX `fk_users_info` (`user_id` ASC) , CONSTRAINT `fk_users_houses` FOREIGN KEY (`house_id` ) REFERENCES `mydb`.`houses` (`house_id` ) ON DELETE NO ACTION ON UPDATE NO ACTION, CONSTRAINT `fk_users_info` FOREIGN KEY (`user_id` ) REFERENCES `mydb`.`users` (`user_id` ) ON DELETE CASCADE ON UPDATE CASCADE) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`users` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`users` ( `user_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT , `group_id` INT UNSIGNED NOT NULL DEFAULT 2 , `user_name` VARCHAR(20) NOT NULL , `user_pass` CHAR(64) NOT NULL , `user_ip_addr` INT(10) NOT NULL , `user_email` VARCHAR(45) NOT NULL , `user_active` TINYINT(1) UNSIGNED NOT NULL DEFAULT 0 , `user_active_key` CHAR(32) NULL , `user_forgot_pass_key` CHAR(32) NULL , `user_registered` INT(11) UNSIGNED NOT NULL , `user_last_login` INT(11) UNSIGNED NOT NULL , PRIMARY KEY (`user_id`) , INDEX `fk_users_group` (`group_id` ASC) , CONSTRAINT `fk_users_group` FOREIGN KEY (`group_id` ) REFERENCES `mydb`.`group` (`group_id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; -- ----------------------------------------------------- -- Table `mydb`.`intel` -- ----------------------------------------------------- CREATE TABLE IF NOT EXISTS `mydb`.`intel` ( `intel_id` INT(8) UNSIGNED NOT NULL AUTO_INCREMENT , `intel_posted_by` INT(8) UNSIGNED NOT NULL DEFAULT 0 , `intel_title` VARCHAR(25) NOT NULL , `intel_text` TEXT NOT NULL , `intel_severity` ENUM('Low', 'Normal', 'High') NOT NULL DEFAULT 'Normal' , `intel_subject` ENUM('Competition', 'General News', 'Update', 'Warning') NOT NULL DEFAULT 'General News' , PRIMARY KEY (`intel_id`) , INDEX `fk_intel_users` (`intel_posted_by` ASC) , CONSTRAINT `fk_intel_users` FOREIGN KEY (`intel_posted_by` ) REFERENCES `mydb`.`users` (`user_id` ) ON DELETE NO ACTION ON UPDATE NO ACTION) ENGINE = InnoDB; SET SQL_MODE=@OLD_SQL_MODE; SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS; SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS; -- ----------------------------------------------------- -- Data for table `mydb`.`group` -- ----------------------------------------------------- BEGIN; INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'NPC', 'Non-Playing Computer'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'Member', 'General Player'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'Player Enquires', 'Staff (Helpers)'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'Forum Mods', 'Staff (Forum Moderation Team)'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'General Mods', 'Staff (General Moderation Team)'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'Admins', 'Staff (Game Development Team)'); INSERT INTO `mydb`.`group` (`group_id`, `group_title`, `group_role`) VALUES (NULL, 'Game Owner', 'Staff (Game Owner/Founder)'); COMMIT; -- ----------------------------------------------------- -- Data for table `mydb`.`houses` -- ----------------------------------------------------- BEGIN; INSERT INTO `mydb`.`houses` (`house_id`, `house_name`, `house_desc`, `house_buy_price`, `house_sale_price`) VALUES (NULL, 'Cardboard Box', 'Wow, it\'s cardboard', 0, 0); INSERT INTO `mydb`.`houses` (`house_id`, `house_name`, `house_desc`, `house_buy_price`, `house_sale_price`) VALUES (NULL, 'Basher', 'A MoD issued \'tent\'', 100, 25); COMMIT;[/mysql]
-
In this function you have made the last query more complicated that it needs, why do you make the money field to the set to the $money var? You already do it at the start of the query? function gang_take_money($userid, $amount, $field = 'money') { $q_get = sprintf('select `%s` from users where userid = %d', $field, $userid); $q_get = mysql_query($q_get); if (!$q_get or mysql_num_rows($q_get) < 1) { return false; } list($money) = mysql_fetch_row($q_get); if ($money < $amount) { return false; } $q_take = sprintf('update users set `%1$s` = `%1$s` - "%2$.0f" where userid = %3$d and `%1$s` = "%4$.0f"', $field, $amount, $userid, $money); mysql_query($q_take); return mysql_affected_rows() > 0; } Thank you if you can explain.
-
Instead of using a session as Karlos suggested, use a cookie.
-
Why not use some MySQL functions? INET_ATON() INET_NTOA()
-
I've just seen this and I think it shows how a framework should be developed, it's simple and effective from what I've seen. Shame the original poster isn't still here to follow up the post, and create part #2 as they said they planned to do.
-
Or simply investigate CodeIgniter... It should help quite alot.
-
May I suggest that you actually use error_reporting(); in your code for ZAP Engine.. Because the amount of undefined indexes and other problems I find is unbelievable.. And I have I personally don't like how you do it in ZAP...
-
Detect browser language & change page accordingly
Karlos94 replied to Haunted Dawg's topic in Tutorials
You missed a key point.. For example: I Agree - English Acepto - Spanish Ich bin einverstanden - German Je suis d'accord - French All the same phrase, just translated.. So technically your function has a limit on what you can do... Why not keep it simple? Have a file of translations and link them into your actualy file.. I'm using CodeIgniter for a project I am doing, thought it'll be different from what I am use to, but anyway... Here is a snippet I use with CodeIgniter.. class Login extends Controller { private function getLang() { $lang = substr($_SERVER['HTTP_ACCEPT_LANGUAGE'], 0, 2); if (!in_array($lang, array('en', 'es', 'de', 'fr'))) { $lang = 'en'; } //$lang = 'fr'; <-- Testing purposes only.. return $lang; } public function index() { // Blah blah... $this->lang->load('login', $this->getLang()); // Get information needed and pass it to the view. } } -
A few questions I would still like to ask.. 1. Will it use a framework or a templating system CodeIgniter, CakePHP, Smarty, jQuery, ect..2. Procedural or OO? 3. And just out of curisoty, would there be a security file full of functions for the less able web developers?