Jump to content
MakeWebGames

bluegman991

Members
  • Posts

    394
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by bluegman991

  1. When you sell your house yes it is natural to drop to 0. When you train, the better the house you have the higher each train is suppose to be.
  2. By default it boosts your training.
  3. Well I do not know if it has been created yet nor have I checked if this has been done yet. I probably should have though because if it has I could have saved myself some time.   <?php function contains_array(array $array) { foreach($array as $k => $v) { if(is_array($v)) { return true; } } return false; } class Database { protected $host; protected $database; protected $user; protected $pass; protected $persistent; public $connection_id; public $last_query; public $last_result; public $num_queries; public $start_time; function __construct(array $settings) { $this->host=@$settings['host'] or 'localhost'; $this->user=@$settings['user'] or 'root'; $this->pass=@$settings['pass'] or ''; $this->database=@$settings['database'] or die('Database not defined!'); $this->persistent=!empty($settings['persistent']) ? true : false; return true; } protected function Reset() //resets variables no longer required for after disconnection { $this->connection_id=NULL; $this->last_query=NULL; $this->last_result=NULL; $this->num_queries=NULL; $this->start_time=NULL; return true; } function Escape($data) //escape strings going into database { return mysql_real_escape_string($data); } function Connect() { if($this->persistent) { $this->connection_id=mysql_pconnect($this->host,$this->user,$this->pass) or die('Persistent database connection failed on '.$this->host.' ('.mysql_error().')'); } else { $this->connection_id=mysql_connect($this->host,$this->user,$this->pass,true) or die('Database connection failed on '.$this->host.' ('.mysql_error().')'); } $this->Change_db($this->database); $time=explode(' ',microtime()); $this->start_time=((float)$time[0]+(float)$time[1]); //Timestamp of when database was connected to return $this->connection_id; } function Disconnect() { if($this->connection_id) { mysql_close($this->connection_id); //disconnects from database $this->Reset(); //see function for description return true; } else { return false; } } protected function Query_error($text='') //throws mysql query error (if detected) or ends page outputting $text { return die("<pre>Database Query Error:\n".(empty($text) ? mysql_error($this->connection_id) : $text)."\nQuery: ".$this->last_query.'</pre>');; } protected static function Escape_callback($matches) //used with $this->Auto_escape function for preg_replaces_callback { return $matches[1].mysql_real_escape_string($matches[2]).$matches[1]; } protected function Auto_escape($data) //regexp finds any text that is in beginning and end quotes (ignores and captures escaped characters) { return preg_replace_callback("/([\"'])((?:\\\\?+.)*?)\\1/",'self::Escape_callback',$data); } function Query($query) { $this->num_queries++; //increments query count (logs number of queries executed) $this->last_query=$query; //logs last query in text form (after compiled) $this->last_result=mysql_query($this->last_query,$this->connection_id) or $this->Query_error(); //executes query or throws error on fail $return=array(); if(@mysql_affected_rows($this->connection_id))//if rows are affected puts how many in $return array { $return['affected_rows']=mysql_affected_rows($this->connection_id); } if(is_numeric(@mysql_num_rows($this->last_result)))//if any rows are returned from select statement puts how many into $return array { $return['num_rows']=mysql_num_rows($this->last_result); } if(@mysql_insert_id($this->connection_id))//if insert id is detected puts it in $return array { $return['insert_id']=mysql_insert_id($this->connection_id); } $return['result']=$this->last_result; return $return; } function fetch_row($result)//fetch all rows returned from query { return mysql_fetch_assoc($result); } private function dowhere1(array $where)//recusively loops through array to finalize where statement { $where2=array(); foreach($where as $k => $v)//loop through array { if(is_string($v) && ($v=='||' || strtolower($v)=='or')) //detects OR marker { $where2[]='OR';//inserts or marker into final where statement } elseif(is_array($v)) { $where2[]=dowhere1($v);//runs this function on child array (for recusrsiveness) } else { if(!strpos($k,' '))//operator is found after space so check for space { return $this->Query_error('Error in where clause: Operator was not found!');//no space found = no operator found = throw error } elseif(substr_count($k,' ')>1)//check for: multiple spaces = multiple operators = throw error { return $this->Query_error('Error in where clause: Multiple operators found (Only 1 needed)'); } else { $rop=array('=','!=','<','>','<=','>=','LIKE','LIKE%%','NOT-LIKE','NOT-LIKE%%','IS-NULL','IS-NOT-NULL','REGEXP','NOT-REGEXP'); //^^operator list (Not all operators included) (add any more you need but replace spaces with dashes) $k=explode(' ',$k);//seperate by space $op=$k[1];//operator is after space $k=$k[0];//table name is before space if(!in_array($op,$rop))//validate operator { return $this->Query_error('Error in where clause:Invalid operator.');//throw error if operator is not found in operator list } if($op=='IS-NULL' || $op=='IS-NOT-NULL')//operator special treatment { $v=''; //empty $v because nothing is needed to match against when checking for null $op=' '.str_replace('-',' ',$op);//change "-" to space } elseif($op=='REGEXP' || $op=='NOT-REGEXP')//operator special treatment { $op=' '.str_replace('-',' ',$op).' ';//change "-" to space } else { $symb=$op=='LIKE%%' || $op=='NOT-LIKE%%' ? '%' : '';//operator special treatment $v=$symb.$this->Auto_escape($v).$symb;//run auto escape on value $op=' '.$op.' ';//surround operator with space } $op=str_replace(array('-','%'),array(' ',''),$op);//change "-" to space for remaining operators if($v[0]=='%' && $v[1]=="'")//check for %'string'% { $v[0]="'"; $v[1]='%'; $v[strlen($v)-1]="'"; $v[strlen($v)-2]='%';//replace %'string'% with '%string%' } if($v[0]=='%' && $v[1]=='"')//check for %"string"% { $v[0]='"'; $v[1]='%'; $v[strlen($v)-1]='"'; $v[strlen($v)-2]='%';//replace %"string"% with "%string%" } $v='`'.$k.'`'.$op.$v;//compiles where statement (`field` = value) 'field' is field selected, '=' is operator, 'value' is value being checked against $where2[]=$v;//put final where statement into final array } } } return $where2;//return final array } private function dowhere2(array $where)//convert final array into mysql where statement { while(contains_array($where)) { foreach($where as $k => $v)//loop through array { if(is_array($v)) { $where[$k]=$this->dowhere2($v);//execute this function on child arrays (for recursiveness) } } } $return='(';//beginning of string $first=true;//true because first loop has not yet been executed $nextop=' AND ';//default operator foreach($where as $k => $v) { if(is_string($v) && ($v=='||' || strtolower($v)=='or'))//check for or marker { $nextop=' OR ';//set next operator to be 'or' } if($v !='OR')//check if this loop is not 'or' marker { $return.=($first==false ? $nextop : '').$v; $nextop=' AND ';//append where statement to final where string } $first=false;//set to false because first loop has already been executed } $return.=')';//end parenthesis return 'WHERE '.$return;//return WHERE plus <where statement> } private function dowhere(array $where)//make dowhere1 and dowhere2 1 function { return $this->dowhere2($this->dowhere1($where)); } function Update($tbl,array $set,array $where=array()) { $query='UPDATE `'.$tbl.'` SET '; $first=true; foreach($set as $k => $v) { $v=$this->Auto_escape($v); $query.=($first==true ? '' : ',').'`'.$k.'`='.$v; $first=false; } $where=$this->dowhere($where); $query.=' '.$where; return $this->Query($query); } function Select($tbl,$sel,array $where,array $order=array(),$limit='') { $query='SELECT '; if(empty($sel)) { $this->Query_error('No fields selected.'); }//make sure you are selecting something elseif(is_string($sel)) { $query.=$sel=='*'? '*' : '`'.$sel.'`'; }//if selecting * ouput only * otherwise output `field` elseif(is_array($sel))//if selecting multiple fields { $first=true; foreach($sel as $k => $v) { $query.=($first==true ? '' : ',').'`'.$v.'`';//seperate fields selected by commas $first=false; } } $query.=' FROM `'.$tbl.'`'; $where=$this->dowhere($where); $query.=' '.$where; if(!empty($order)) { $first=true; foreach($order as $k => $v)//$k is field ordering by, $v is order (ASC or DESC) { $query.=($first==true ? ' ORDER BY ' : ',').'`'.$k.'`'.(empty($v) ? '' : ' '.$v);//appends order by if defined $first=false; } } if(!empty($limit)) { $query.=' LIMIT '.$limit; }//appends limit if defined return $this->Query($query);//executes query } function Insert($tbl,array $fields,array $values) { $query=''; $query.='INSERT INTO `'.$tbl.'`'; if(!empty($fields)) { $query.=' ('; $first=true; foreach($fields as $k => $v)//loop and append each field intended to be inserted on { $query.=($first==true ? '' : ',').'`'.$v.'`'; $first=false; } $query.=') '; } $query.='VALUES'; $efirst=true; foreach($values as $ek => $ev)//loop through each insert { $first=true; $query.=($efirst==true ? '(' : ',(');//add parenthesis around each insert foreach($ev as $k => $v)//loop through each field value { $query.=($first==true ? '' : ',').$this->Auto_escape($v);//seperate each field value $first=false; } $efirst=false; $query.=')';//end insert parenthesis } return $this->Query($query); } function Delete($tbl,array $where) { $query='DELETE FROM `'.$tbl.'`'; $where=$this->dowhere($where); $query.=' '.$where; return $this->Query($query); } function Change_db($db) { if(mysql_select_db($db,$this->connection_id)) { $this->database=$db; return true; } else { return die('Failed to connect to database: '.$db); } } function __destruct() { return $this->Disconnect(); } } ?>   Sorry i'm not all that good at explaining things so if you don't understand what something truly does just ask here and i'll elaborate a bit more on it. Usage       ^^ This function may be changed up a bit.   IDK how readable i'm going to be able to make the usage look.
  4. Chrome, because of how light weight it is, and how much support it has for html5 and css3.
  5. It doesn't always mean he has 2 session starts. It could also mean that he has in echo, print, header, or another function that outputs something to the page written somewhere after the session start. put ob_start(); before everything on the main page which has the includes, and that should fix it. If not tell us what you have on line 10 in publichtml/login/index.php. And what you have on line 2 of login/globals.php.
  6. This could be useful. I remember when I was going out of town for a month thinking I was going to be without internet the whole time. So before I left I wrote up a script to download all of the function pages that my php version supported. Then wrote up a search script to search through them.
  7. All the statistics seem about right except mysql being so far behind sql server. I didn't know it was that far behind the top databases.
  8. Exactly it would require less research to make the game. (Which most people aren't willing to do) Most are just going to do as i said above.
  9. First and only mod. http://makewebgames.io/showthread.php/34842-User-Settings-mod Bewtween then and now i have switched to doing php all around as a hobby until a later date. Still using it every day though and learning to use the parts of it which people rarely use or didn't know it could do.
  10. Its not gonna be easy to find much market research on text based rpg games though. There going to type "text based rpg's" into a search engine. See a whole bunch of mafia styled rpg's. See that each one has hundreds to millions of active people each day, then think thats what they want to have.
  11. Well some create mafia games for the money and some create them as a hobby. For those who do it for the money: Owning an online game is just like owning a business, and creating a business is a risk. Making 1 wrong decisions for this business is (deciding the genre of the game) is where it could all go wrong. Why do people mainly make mafia games? Because it is the genre where the most consumer interest is shown. Because it is a genre in life which most people are familiar with (Every country has them though they may be under a different name. Yakuza, Triad, etc...). Because less research would be required to make the game. (In a different genre you will need different stats,vitals,weapons,events,themes,terms,etc...) Because it would to less time and you would spend less to just do something you already know. So asking someone who does it for the money is like asking them " Why don't you spend all your time and money creating something that might fail". If they are truly dedicated to it... If the do it themselves there going to spend a lot of time on it. If they pay to have it done they are going to spend a lot of money on it. So either way if they loose they're loosing time or money. Both of which are valuable.   For the ones who do it as a hobby. They are usually doing it for fun. Why should they spend all their time researching terms and etc to make something that will probably not be used by themselves? By the time they're finished with this one (probably before) they're going to be started on another one. This one probably won't even get finished. I've never even heard of a bushido. Until a poll/survey is given to the consumers about which style rpg they like to play and it out numbers the mafia style. No one really is going to change up their style.
  12. No problemo! ;)
  13. I wouldn't consdider this stealing either since the code to do this would be so simple and have seen similar things on many sites. Here is the code you are looking for to achieve what they are doing. I am going to only do the javascript part and hopefully you know enough php to incorporate what you are trying to do.   <form method="get" action=""> <select onchange="submit();" name="color"> <option>red</option> <option>blue</option> <option>green</option> </select> <select onchange="submit();" name="size"> <option>small</option> <option>medium</option> <option>large</option> </select> </form>   Code is tabbed for readability. This is not tested but i'm pretty sure it should work. In your onchange attribute if "submit();" doesn't work, then one of the following should. form.submit(); this.form.submit();
  14. I watched paranormal activity 1 & 2 with my surround sound up high. I really liked them but the only thing that made it slightly scary was the sudden loud sounds. However it is one of those movies that you can watch 1 time only. I have scrolled past paranormal entity a few times on netflix not bothering to watch it because of the company that made it (although they do make pretty good remakes), but since people say it was better than paranormal activity I will check it out.
  15. North America would fight them off so they wouldn't make it to the south. What if everything were free?
  16. We'd all drown. What if we couldn't see, feel, hear, smell, or taste?
  17. Didn't google a way to do it but I did search for a way through properties, settings and stuff and didn't see a way so didn't think there was a way. Syntax highlighting is the only reason i tried the next top used ide. And so i'm kind of glad i didn't know how to at that time otherwise i wouldn't have even tried netbeans. :p I'll look now for how to change these settings.
  18. Have tried both komodo and netbeans now. I must say both of their auto tabbing/complete is better than dreamweaver. However I would not use komodo over dreamweaver because the syntax highlighting is not good enough. And good syntax highlighting is a must for me. Now netbeans is way better than the both of them. It just has so much more to offer. So much that im not even going to say what it has that the other 2 don't. Im just gonna say the 3 things I don't like about it. You have to open a new project to create new file that's not associated with the old project. You could easily just open a project called misc or something so it's not that big of a deal really. Although it has come in handy for organizing the actual projects I am working on. The startup time and the time it takes for function assist to load functions in the scope from included files. Doesn't really matter since I created the function and know how to use it. Plus could be due to my crappy 1.9 ghz processor. Last but definitely not least. This is the thing that I dislike the most about netbeans. Well auto complete tabbing uses 4 spaces instead of 1 tab which means 4x more space is being used. I probably will just make a php function to loop through all the files in the directory and replace 4 spaces with 1 tab.
  19. It would probably be easier to do it in css [CSS]table > tbody > td:odd { background-color:#0f0; } table > tbody > td:even { background-color:#f00; }[/CSS]
  20. bluegman991

    Php Exam

    I'll take it.
  21. Again in whe editing html in dreamweaver I only use auto complete. Example: I Type "<blockquote></". Dreamweaver auto completes it making it "<blockquote></blockquote>". It can come in handy. Especially because I hate repeat myself 100's of times. Anyway I am going to try out komodo. Reason why I'm looking for a new program is because I know dreamweaver is a bit heavy for what I do and because I have recently done a factory reset on my computer and don't want to fill it up with things I don't efficiently use. (like last time)
  22. O.k. wasn't thinking from a team point of view. And since scripts are distributed I guess readability would matter. Again was thinking in terms of code meant only to be read by the coder. I didn't mean by code similarity. I meant by how similar the script you made is to the target script. Since white space can be trimmed in between code. By filesize I was thinking in terms of excluding space tabs and new lines and using the right methods in the right place to make your code efficient. To make knowing your api matter. Like choosing between using the built in methods which may be faster or building your own methods making it securer and faster and use less resources (using up more file memory) or build your own method using the built in method adding a few things to make it more secure (using more resources).
  23. I like dreamweaver because I can do all my web programming in one program. For PHP and JS it has function hinting (reminding me what order to insert variables into arrays). And it has auto complete for css and html. Making things go by a bit quicker. It also can switch between files easily. I have yet to find a program that can do this but like I said i have not done much searching and am open for suggestions. And yea i'd rather not use the wysiwyg for html when I have to check for cross-browser compatibility anyway.
  24. The coding style wouldn't really matter. I would guess the code would be rated on speed, security, similarity, file size, memory resources used, etc... depending on the language used and script type. Not rated directly on how the code looked.
  25. Just uploaded it to tinypic it may not show for you for a couple of minutes (if at all) :eek:
×
×
  • Create New...