?? functions.php1
字號:
<?php //functions.phpfunction add_points($resources,$userid){ return false;}function remove_points($resources,$userid){ return false;}//// Comprueba si un usario existe//function check_user(){ //obtenemos las cookies y o userdata $row = checkcookies(); if($row != false){ global $user; $user = $row; return true; } return false;}//// Obtiene una array de los datos de un jugador.//function get_userdata(){ echo "pendiente";}//// Comprueba si es una direccion de email valida//function is_email($email){ return(preg_match("/^[-_.[:alnum:]]+@((([[:alnum:]]|[[:alnum:]][[:alnum:]-]*[[:alnum:]])\.)+(ad|ae|aero|af|ag|ai|al|am|an|ao|aq|ar|arpa|as|at|au|aw|az|ba|bb|bd|be|bf|bg|bh|bi|biz|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|com|coop|cr|cs|cu|cv|cx|cy|cz|de|dj|dk|dm|do|dz|ec|edu|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gh|gi|gl|gm|gn|gov|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|in|info|int|io|iq|ir|is|it|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|mg|mh|mil|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|museum|mv|mw|mx|my|mz|na|name|nc|ne|net|nf|ng|ni|nl|no|np|nr|nt|nu|nz|om|org|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|pro|ps|pt|pw|py|qa|re|ro|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|st|su|sv|sy|sz|tc|td|tf|tg|th|tj|tk|tm|tn|to|tp|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|yu|za|zm|zw)$|(([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5])\.){3}([0-9][0-9]?|[0-1][0-9][0-9]|[2][0-4][0-9]|[2][5][0-5]))$/i",$email)); }//// Sirve para leer las cookies.//function checkcookies(){ global $lang,$game_config,$ugamela_root_path,$phpEx; //mas adelante esta variable formara parte de la $game_config includeLang('cookies'); include($ugamela_root_path.'config.'.$phpEx); $row = false; if (isset($_COOKIE[$game_config['COOKIE_NAME']])) { // Formato de la cookie: // {ID} {USERNAME} {PASSWORDHASH} {REMEMBERME} $theuser = explode(" ",$_COOKIE[$game_config['COOKIE_NAME']]); $query = doquery("SELECT * FROM {{table}} WHERE username='{$theuser[1]}'", "users"); if (mysql_num_rows($query) != 1) { message($lang['cookies']['Error1']); } $row = mysql_fetch_array($query); if ($row["id"] != $theuser[0]) { message($lang['cookies']['Error2']); } if (md5($row["password"]."--".$dbsettings["secretword"]) !== $theuser[2]) { message($lang['cookies']['Error3']); } // Si llegamos hasta aca... quiere decir que la cookie es valida, // entonces escribimos una nueva. $newcookie = implode(" ",$theuser); if($theuser[3] == 1){ $expiretime = time()+31536000;}else{ $expiretime = 0;} setcookie ($game_config['COOKIE_NAME'], $newcookie, $expiretime, "/", "", 0); doquery("UPDATE {{table}} SET onlinetime=".time().", user_lastip='{$_SERVER['REMOTE_ADDR']}' WHERE id='{$theuser[0]}' LIMIT 1", "users"); } unset($dbsettings); return $row;}//// Funcion de parce//function parsetemplate($template, $array){ foreach($array as $a => $b) { $template = str_replace("{{$a}}", $b, $template); } return $template;}//////function gettemplate($templatename){ //OpenGame .. $skinname = 'FinalWars' global $ugamela_root_path; $filename = $ugamela_root_path . TEMPLATE_DIR . TEMPLATE_NAME . '/' . $templatename . ".tpl"; return ReadFromFile($filename); }// to get the language textsfunction includeLang($filename,$ext='.mo'){ global $ugamela_root_path,$lang; include($ugamela_root_path."language/".DEFAULT_LANG.'/'.$filename.$ext);}//// Leer y Guardar archivos//function ReadFromFile($filename){ $f = @fopen($filename,"r"); $content = @fread($f,filesize($filename)); @fclose($f); return $content;}function SaveToFile($filename,$content){ $f = fopen($filename,"w"); fputs($f,"$content"); fclose($f);}//**************************************************************************//// FUNCIONES PARA REVISAR!!!!!!!!!!////**************************************************************************function message($mes,$title='Error',$dest = "",$time = "3"){ $parse['color'] = $color; $parse['title'] = $title; $parse['mes'] = $mes; $page .= parsetemplate(gettemplate('message_body'), $parse); display($page,$title,false,(($dest!='')?"<meta http-equiv=\"refresh\" content=\"$time;URL=javascript:self.location='$dest';\">":''));}function display($page,$title = '',$topnav = true,$metatags=''){ global $link,$game_config,$debug,$user; echo_head($title,$metatags); if($topnav){ echo_topnav();} echo "<center>\n$page\n</center>\n"; //Muestra los datos del debuger. if($user['authlevel']==1||$user['authlevel']==3){ if($game_config['debug']==1) $debug->echo_log(); } echo echo_foot(); if(isset($link)) mysql_close(); die();}function echo_foot(){ global $game_config,$lang; $parse['copyright'] = $game_config['copyright']; $parse['TranslationBy'] = $lang['TranslationBy']; echo parsetemplate(gettemplate('overall_footer'), $parse);}function CheckUserExist($user){ global $lang,$link; if(!$user){ if(isset($link)) mysql_close(); error($lang['Please_Login'],$lang['Error']); }}function pretty_time($seconds){ //Divisiones, y resto. Gracias Prody $day = floor($seconds / (24*3600)); $hs = floor($seconds / 3600 % 24); $min = floor($seconds / 60 % 60); $seg = floor($seconds / 1 % 60); $time = '';//la entrada del $time if($day != 0){ $time .= $day.'d ';} if($hs != 0){ $time .= $hs.'h ';} if($min != 0){ $time .= $min.'m ';} $time .= $seg.'s'; return $time;//regresa algo como "[[[0d] 0h] 0m] 0s"}function pretty_time_hour($seconds){ //Divisiones, y resto. Gracias Prody $min = floor($seconds / 60 % 60); $time = '';//la entrada del $time if($min != 0){ $time .= $min.'min ';} return $time;//regresa algo como "[[[0d] 0h] 0m] 0s"}function echo_topnav(){ global $user, $planetrow, $galaxyrow,$mode,$messageziel,$gid,$lang; if(!$user){return;} if(!$planetrow){ $planetrow = doquery("SELECT * FROM {{table}} WHERE id ={$user['current_planet']}","planets",true);} calculate_resources_planet($planetrow);//Actualizacion de rutina //if(!$galaxyrow){ $galaxyrow = doquery("SELECT * FROM {{table}} WHERE id_planet = '".$planetrow["id"]."'","galaxy",true);} $dpath = (!$user["dpath"]) ? DEFAULT_SKINPATH : $user["dpath"]; //-[Arrays]------------------------------------------------ $parse = $lang; $parse['dpath'] = $dpath; $parse['image'] = $planetrow['image']; /* peque帽o loop para agregar todos los planetas disponibles del mismo jugador... */ ?><script language="JavaScript" src="scripts/flotten.js"></script><script language="JavaScript" src="scripts/ocnt.js"></script><script type="text/javascript" src="scripts/jquery.js"></script><script type="text/javascript" src="scripts/thickbox.js"></script><link rel="stylesheet" href="scripts/thickbox.css" type="text/css" media="screen" /><? $parse['planetlist'] = ''; //pedimos todos los planetas que coincidan con el id del due錕
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -