Location: PHPKode > projects > WorkOrder TS > workorder-ts/setup_files/validate.php
<?PHP error_reporting(E_ALL);$inc_dir='../include/';require_once $inc_dir.'magic_quotes.php';require_once 'MySQLErr.php';require_once 'php_to_javascript.php';require_once 'defaults.php';$_IlJtQ=Null;$_IlJIl=Null;$_j6O6l=0;$_jffIt=False;$_jljij=False;$_jIiOQ=False;$_jIilQ=False;$_jQfL8=False;$_jILt8=False;$_jlJQQ=False;$_jlJf0=False;if( count($_GET) < 2 ) { die("You can not run this script directly.");} if( isset($_GET['wodb']) ) { $wodb=addslashes($_GET['wodb']);} else { $wodb=Null;} if( isset($_GET['woip']) ) { $woip=addslashes($_GET['woip']);} else { $woip=Null;} if( isset($_GET['wologip']) ) { $wologip=addslashes($_GET['wologip']);} else { $wologip=Null;} if( isset($_GET['worootu']) ) { $worootu=addslashes($_GET['worootu']);} else { $worootu=Null;} if( isset($_GET['worootp']) ) { $worootp=html_entity_decode($_GET['worootp']);} else { $worootp=Null;} if( isset($_GET['wogu']) ) { $wogu=addslashes($_GET['wogu']);} else { $wogu=Null;} if( isset($_GET['wogp']) ) { $wogp=html_entity_decode($_GET['wogp']);} else { $wogp=Null;} if( isset($_GET['wouu']) ) { $wouu=addslashes($_GET['wouu']);} else { $wouu=Null;} if( isset($_GET['woup']) ) { $woup=html_entity_decode($_GET['woup']);} else { $woup=Null;} if( isset($_GET['wotp']) ) { $wotp=addslashes($_GET['wotp']);} else { $wotp=Null;} if( isset($_GET['wouap']) ) { $wouap=html_entity_decode($_GET['wouap']);} else { $wouap=Null;} if( isset($_GET['woutp']) ) { $woutp=html_entity_decode($_GET['woutp']);} else { $woutp=Null;} if( isset($_GET['wolk']) ) { $wolk=addslashes($_GET['wolk']);} else { $wolk=Null;} function _OELJA($_jlJOO) { $_jl600=FALSE;$_jl6lL=explode("-",$_jlJOO);if( is_numeric($_jl6lL[0])==True && is_numeric($_jl6lL[1])==True && is_numeric($_jl6lL[2])==True && is_numeric($_jl6lL[3])==True ) { $_jlfOJ=( (($_jl6lL[0]-$_jl6lL[3])+($_jl6lL[1]-$_jl6lL[2])) /-1 );if( $_jl6lL[4]==$_jlfOJ ) { $_jl600=TRUE;} } return $_jl600;} if( !ereg("^[A-Za-z0-9_]{1,30}$",$wodb)) { die('Invalid database name. valid input contains [A-Za-z0-9_] is between 1 and 30 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9:_.-]{1,61}$",$woip)) { die('Invalid IP Address or hostname for "Server Address". valid input contains [A-Za-z0-9:.-_] <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9:%_.-]{1,61}$",$wologip)) { die('Invalid IP Address or hostname for "Dedicated Server Login From". valid input contains [A-Za-z0-9:%.-_] <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9_]{0,16}$",$worootu)) { die('Invalid root user name. valid input contains [A-Za-z0-9_] is between 1 and 30 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9_]{1,16}$",$wogu)) { die('Invalid guest user name. valid input contains [A-Za-z0-9_] is between 1 and 16 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9_]{1,16}$",$wouu)) { die('Invalid user name. valid input contains [A-Za-z0-9_] is between 1 and 16 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9_]{1,10}$",$wotp)) { die('Invalid table prefix. valid input contains [A-Za-z0-9_] is between 1 and 10 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} if( !ereg("^[A-Za-z0-9-]{25,29}$",$wolk)) { die('Invalid license key. valid input contains [A-Za-z0-9-] is 29 characters long. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n<br />");} $_jl8Ii=MIN_PHP_VERSION;$_jl8Jf=True;$_jlt18=False;$_jlt8o=explode(".",$_jl8Ii);$_jltLI=count($_jlt8o);$_jlOOO=phpversion();$_jlOOO=explode(".",$_jlOOO);$_jlOoi=count($_jlOOO);if( $_jlOoi==$_jltLI ) { $_jlOiL=$_jltLI;} else { if( $_jlOoi < $_jltLI ) { $_jlOiL=$_jlOoi;$_jl8Jf=False;} else { $_jlOiL=$_jltLI;$_jl8Jf=False;} } for( $x=0;$x < $_jlOiL;$x++) { if( $_jlt8o[$x] > $_jlOOO[$x] && $_jlt18==False ) { $_IlJtQ.="Your PHP Version is ".phpversion()." the program requires at least $_jl8Ii".' <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} $_jlt18=True;} else { if( $_jlt8o[$x] !=$_jlOOO[$x] && $_jlt18==False ) { $_IlJtQ.="Your PHP Version is compatible. ".phpversion().' <img src="'.OK_IMG.'" width="22" height="11" />'."\n";$_jlt18=True;break;} } } if( $_jl8Jf==False && $_jlt18==False ) { if( $_jltLI > $_jlOoi ) { $_IlJtQ.="Your PHP Version is ".phpversion()." the program requires at least $_jl8Ii".' <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} $_jlt18=True;} } if( $_jlt18==False ) { $_IlJtQ.="Your PHP Version is compatible. ".phpversion().' <img src="'.OK_IMG.'" width="22" height="11" />'."\n";$_jlt18=True;} if( get_magic_quotes_gpc() ) { if( $_j6O6l < 1 ) { $_j6O6l=1;} $_IlJtQ.='Warning PHP magic_quotes are enabled. <a href="javascript: popuphelpmagic()" style="text-decoration: none">Click here for more info.</a> <img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";} if( ini_get('register_globals') ) { if( $_j6O6l < 1 ) { $_j6O6l=1;} $_IlJtQ.='Warning PHP register_globals are enabled, this is very dangerous. <a href="javascript: popuphelpregglob()" style="text-decoration: none">More Info</a> <img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";} else { $_IlJtQ.='Excellent, register_globals are turned Off. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} if( !function_exists('mysql_connect') ) { die("You MySQL extension is properly installed. Please check your installation or contact tech support.".' <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n");} if( $worootu !="" ) { $_jf6jO=$worootu;$_jff11=$worootp;$_jffIt=True;} else { $_jf6jO=$wouu;$_jff11=$woup;$_jffIt=False;} $_IlJIl=Null;$conn=mysql_connect( "$woip","$_jf6jO","$_jff11");if (!$conn) { $_IlJIl=mysql_errno();die("MySQL Error "._ODBDA($_IlJIl));} $_jloj0=MIN_MYSQL_VERSION;$_jl8Jf=True;$_jlof0=False;$_jloot=explode(".",$_jloj0);$_jlC0C=False;$_jlCfl=count($_jloot);$_jCQOl=mysql_get_server_info();$_jCQOl=explode(".",$_jCQOl);$_jCI86=count($_jCQOl);if( $_jCI86==$_jlCfl ) { $_jlOiL=$_jlCfl;} else { if( $_jCI86 < $_jlCfl ) { $_jlOiL=$_jCI86;$_jl8Jf=False;} else { $_jlOiL=$_jlCfl;$_jl8Jf=False;} } for( $x=0;$x < $_jlOiL;$x++) { if( $_jloot[$x] > $_jCQOl[$x] && $_jlof0==False ) { $_IlJtQ.="Your MySQL Version is ".mysql_get_server_info()." the program requires at least $_jloj0".' <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";$_jlC0C=True;if( $_j6O6l < 2 ) { $_j6O6l=2;} $_jlof0=True;} else { if( $_jloot[$x] !=$_jCQOl[$x] && $_jlof0==False ) { $_IlJtQ.="Your MySQL Version is compatible. ".mysql_get_server_info().' <img src="'.OK_IMG.'" width="22" height="11" />'."\n";$_jlof0=True;break;} } } if( $_jl8Jf==False && $_jlof0==False ) { if( $_jlCfl > $_jCI86 ) { $_IlJtQ.="Your MySQL Version is ".mysql_get_server_info()." the program requires at least $_jloj0".' <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";$_jlC0C=True;if( $_j6O6l < 2 ) { $_j6O6l=2;} $_jlof0=True;} } if( $_jlof0==False ) { $_IlJtQ.="Your MySQL Version is compatible. ".mysql_get_server_info().' <img src="'.OK_IMG.'" width="22" height="11" />'."\n";$_jlof0=True;} if( $_jlC0C==False ) { if( $_jffIt==True ) { $sql="SELECT CURRENT_USER() AS CurrentUser";$res=mysql_query( $sql,$conn ) or die("Unable to get current user name");$row=mysql_fetch_array($res);$_jliQ8=explode('@',$row['CurrentUser'] );$_jlL10=$_jliQ8[0];$_jlLt8=$_jliQ8[1];$_jlLot=Null;$_jllQl=Null;$_J000Q=Null;$_J00ii=Null;$_J01I6=Null;$_J0Q0f=Null;$_J0QCj=Null;$_J0I1C=@mysql_select_db("mysql",$conn);if (!$_J0I1C) { } $sql="SELECT * FROM user WHERE User = '$_jlL10' AND Host = '$_jlLt8'";$res=mysql_query( $sql,$conn );$_J0QCj=@mysql_num_rows($res);if( $_J0QCj=="" ) { $_IlJtQ.="Unable to get current user name rights but I was able to login. Is the administrative information correct?";if( $_j6O6l < 1 ) { $_j6O6l=1;} } else { $row=mysql_fetch_array($res);$_jllQl=$row['Grant_priv'];$_J000Q=$row['Create_priv'];$_J00ii=$row['Insert_priv'];$_J01I6=$row['Update_priv'];$_J0Q0f=$row['Alter_priv'];} if( $_jllQl !='Y' ) { $_jlLot.="Permission Error, current user does not have GRANT privileges. FATAL, fix this or the installation will fail!\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $_J000Q !='Y' ) { $_jlLot.="Permission Error, current user does not have CREATE privileges. FATAL, fix this or the installation will fail!\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $_J00ii !='Y' ) { $_jlLot.="Permission Error, current user does not have INSERT privileges. FATAL, fix this or the installation will fail!\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $_J01I6 !='Y' ) { $_jlLot.="Permission Error, current user does not have UPDATE privileges. FATAL, fix this or the installation will fail!\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $_J0Q0f !='Y' ) { $_jlLot.="Permission Error, current user does not have ALTER privileges. FATAL, fix this or the installation will fail!\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $_jlLot==Null ) { $_jlLot='Database privileges for administrative user verified <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} $_IlJtQ.=$_jlLot;} $_IlJIl=Null;$db_selected=mysql_select_db( $wodb,$conn);if( !$db_selected ) { $_J0IL1=mysql_errno();$_IlJIl=Null;mysql_close();$_J0jtj=mysql_connect( "$woip","$_jf6jO","$_jff11");$_IlJIl=mysql_errno($_J0jtj);if( $_IlJIl=="1044" ) { $_IlJtQ.=_ODBDA($_IlJIl,'For User: '.$_jf6jO.' with Password: '.$_jff11.' To Server: '.$woip);} if( $_J0IL1 !="1049" ) { $_IlJtQ.=_ODBDA($_J0IL1);} } else { $_jljij=True;$_IlJtQ.='Database already exists. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} if( $_jljij==False ) { $_IlJIl=Null;$_J0J0I=TEST_CREATE_DATABASES;$sql="Create database $_J0J0I";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);} else { $_IlJIl=Null;$_jIiOQ=True;$_IlJtQ.='<input type="hidden" name="CanCreateDatabases" value="True" id="CanCreateDatabases" />';$sql="Drop database $_J0J0I";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);} else { $_jIilQ=True;$_IlJtQ.='<input type="hidden" name="CanDeleteDatabases" value="True" id="CanDeleteDatabases" />';$_IlJtQ.='Successfully Created and Dropped test Database  <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} } } if( $_jljij==True || ( $_jIilQ==True && $_jIiOQ==True ) ) { if( $_jljij==False ) { if( $_jIilQ==True && $_jIiOQ==True ) { $_IlJIl=Null;$_J0J0I=TEST_CREATE_DATABASES;$sql="Create database $_J0J0I";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);} } } $_IlJIl=Null;$_J0Jl0=TEST_CREATE_TABLE;$db_selected=mysql_select_db( $wodb,$conn);$sql="Create table $_J0Jl0(ID int unsigned auto_increment PRIMARY KEY) ENGINE=MyISAM DEFAULT CHARSET=latin1";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);}else { $_IlJIl=Null;$_jQfL8=True;$_IlJtQ.='<input type="hidden" name="CanCreateTables" value="True" id="CanCreateTables" />';$sql="Drop table $_J0Jl0";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);} else { $_jILt8=True;$_IlJtQ.='<input type="hidden" name="CanDeleteTables" value="True" id="CanDeleteTables" />';$_IlJtQ.='Successfully Created and Dropped test Table  <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} } } if( $_jljij==False ) { if( $_jIilQ==True && $_jIiOQ==True ) { $_IlJIl=Null;$_J0Jl0=TEST_CREATE_TABLE;$_jIiOQ=True;$sql="Drop database $_J0J0I";mysql_query( $sql,$conn );$_IlJIl=mysql_errno($conn);if( $_IlJIl ) { $_IlJtQ.=_ODBDA($_IlJIl);} } } if( $wogu !=Null ) { $_IlJIl=Null;$_jftlj=@mysql_connect( "$woip","$wogu","$wogp");if ($_jftlj) { $_jlJQQ=True;$_IlJtQ.='Guest Account exists, login successful. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} else { if( $_jffIt==False ) { $_IlJtQ.='Error, invalid Guest Username or Password. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } else { if( strlen($wogp) < MIN_PASSWORD_LENGTH ) { $_IlJtQ.='Warning, Guest Password too short. <img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 1 ) { $_J0686=1;} } else { $_IlJtQ.='Guest does not exist. New account will be created. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} } } } else { $_IlJtQ.='Error, Guest Username too short. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( $wouu !=Null ) { $_IlJIl=Null;$_jfOQ8=@mysql_connect( "$woip","$wouu","$woup");if ($_jfOQ8) { $_jlJf0=True;$_IlJtQ.='User Account exists, login successful. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} else { if( $_jffIt==False ) { $_IlJtQ.='Error, invalid User Username or Password. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } else { if( strlen($woup) < MIN_PASSWORD_LENGTH ) { $_IlJtQ.='Warning, User\'s Password too short.<img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";      if( $_j6O6l < 1 ) { $_j6O6l = 1; }      } else {       $_IlJtQ .= 'User does not exist.New account will be created.<img src="'.OK_IMG.'" width="22" height="11" />'."\n";     }     }    }   } else {    $_IlJtQ .= 'Error,User\'s Username too short. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } if( strlen($wotp) < 1 || strlen($wotp) > 10 ) { $_IlJtQ.='Error, invalid table prefix. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } else { $_IlJtQ.='Table Prefix OK. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} if( strlen($wouap) >=MIN_PASSWORD_LENGTH ) { $_IlJtQ.='Specified Admin Password OK. <img src="'.OK_IMG.'" width="22" height="11" />' .'<input type="hidden" name="wouap_hash" id="wouap_hash" value="'.htmlentities($wouap).'">'."\n";} else { $_IlJtQ.='Warning, Admin password too short. <img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 1 ) { $_j6O6l=1;} } if( file_exists("../include/pro/calendar.php")==False ) { if( strlen($woutp) >=MIN_PASSWORD_LENGTH ) { $_IlJtQ.='Specified Tech Password OK. <img src="'.OK_IMG.'" width="22" height="11" />' .'<input type="hidden" name="woutp_hash" id="woutp_hash" value="'.htmlentities($woutp).'">'."\n";} else { $_IlJtQ.='Warning, Tech password too short. <img src="'.WARNING_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 1 ) { $_j6O6l=1;} } } if( empty($wolk)==FALSE ) { if( file_exists("$inc_dir/pro/calendar.php")==False ) { $res=Null;$res=_OELJA($wolk);if( $res==False ) { $wolk=NULL;$_IlJtQ.='Error, Invalid License Key. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } else { $StoreNum=1;$_IlJtQ.='<input type="hidden" name="StoreNum" id="StoreNum" value="'.$StoreNum.'">';$_IlJtQ.='Free License Key OK. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} } else { $res=Null;require_once "../include/workorder_function_general.inc.php";require_once "../include/pro/workorder_functions_pro.inc.php";$res=ValidateKey4($wolk);if( $res==0 ) { $wolk=NULL;$_IlJtQ.='Error, Invalid Professional License Key. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } else { $res=CheckKey4($wolk);$res=substr("$res",strlen($res)-6);$StoreNum=$res{0}.$res{1};$_jtCtj=1;$_IlJtQ.='<input type="hidden" name="StoreNum" id="StoreNum" value="'.$StoreNum.'">';$_IlJtQ.='<input type="hidden" name="ProInstall" id="ProInstall" value="'.$_jtCtj.'">';$_IlJtQ.='Professional License Key OK. <img src="'.OK_IMG.'" width="22" height="11" />'."\n";} } } else { $_IlJtQ.='Error, Invalid License Key. <img src="'.ERROR_IMG.'" width="22" height="11" />'."\n";if( $_j6O6l < 2 ) { $_j6O6l=2;} } } switch ($_j6O6l) { case 0:$_IlJtQ='<span style="background-color: #33CC00;">' .'All Tests OK, please proceed with the installation. </span><img src="'.OK_IMG.'" width="22" height="11" />'."\n" .'<input type="submit" name="btnSubmit" id="btnSubmit" value="Download Configuration Files" />'."\n".$_IlJtQ;break;case 1:$_IlJtQ='<span style="background-color: #FF9900;">' .'At least one Warning issued, please check the test warning below. </span><img src="'.WARNING_IMG.'" width="22" height="11" />'."\n" .'<input type="submit" name="btnSubmit" id="btnSubmit" value="Start Installation" /></span>'."\n".$_IlJtQ;break;case 2:$_IlJtQ='<span style="background-color: #FF0000;">' .'FATAL ERROR, installation will fail! Please correct the problem and retest. </span><img src="'.ERROR_IMG.'" width="22" height="11" />'."\n\n" .$_IlJtQ;break;} $_IlJtQ=nl2br($_IlJtQ);print_r($_IlJtQ);?>
Return current item: WorkOrder TS