<html> 
    <head> 
        <title>Vote 4 US</title> 
        <style> 
           body { background-color: #202020;  
                  color: yellow; 
                }     
        </style> 
    </head> 
    <body> 
        <?php 
        // Report all PHP errors (see changelog) 
        error_reporting(E_ALL); 
         
         
        //----------------------------------------------------------  
        // Give X coins 
        $coins = 200; 
	
	// Homepage 
	// Add http:// in your list
	$webpage1 = "http://elysiumgaming.de:8080/";
         
        // Yout website after vote was successfull 
        // Add http:// in your list 
        $webpage = "http://topofgames.com/index.php?do=votes&id=50459"; 
         
        // Time needed to vote again 
        // You need to remove 1 minut from the time 
        // 720 should be 12hours 
        $time_needed = "719"; // in mintutes 
         
         
        // Insert your MSSQL info here  
            $mssql = array(  
            'host' => "CYBER951-PC\SQLEXPRESS",  
            'user' => "sa",  
            'pass' => "12345"  
            );  
             
        // Insert your MYSQL info here  
            $mysql = array(  
            'host' => "localhost",  
            'user' => "root",  
            'pass' => "",  
            'db'   => "test" // Do not change it the DB is vote 
            );  
             
        //---DO NOT EDIT ANYTHING BELOW HERE UNLESS YOU KNOW WHAT YOU ARE DOING!! --- 
         
        function clean($str){ 
            return is_array($str) ? array_map('clean', $str) : str_replace("\\", "\\\\", htmlspecialchars((get_magic_quotes_gpc() ? stripslashes($str) : $str), ENT_QUOTES)); 
        } 
           
        $mslink = mssql_connect($mssql['host'],$mssql['user'],$mssql['pass']); 
        $mylink = mysql_Connect($mysql['host'], $mysql['user'], $mysql['pass']); 
        mysql_select_db($mysql['db'],$mylink);  
        $ip = getenv("REMOTE_ADDR"); 
        $httpref = getenv ("HTTP_REFERER"); 
        $httpagent = getenv ("HTTP_USER_AGENT"); 
        $account = clean($_POST['account']); 
        $date = date("Y-m-d G:i"); 
         
        if (empty($account)){ 
         
            echo '<SCRIPT LANGUAGE="JavaScript">alert("Du hast kein Account name eingegeben! \n Bitte nochmal versuchen.")</script>'; 
            echo "<script type='text/javascript'>window.location='Index.php';</script>"; 

             
        } elseif(!preg_match("/[0-9a-zA-Z]?/", $account)) { 
         
            echo '<SCRIPT LANGUAGE="JavaScript">alert("Nicht korrekter Accountname. \n Bitte nochmal versuchen.")</script>'; 
            echo "<script type='text/javascript'>window.location='Index.php';</script>"; 

             
        } else { 
             
            $result1 = mssql_query("SELECT * FROM account.dbo.tUser WHERE sUserID = '".$account."'",$mslink); 
            $count1 = mssql_num_rows($result1); 
            $row1 = mssql_fetch_row($result1); 
             
            if($count1 == '0') { 
             
                echo '<SCRIPT LANGUAGE="JavaScript">alert("Account wurde nicht gefunden. \n Bitte nochmal versuchen.")</script>'; 
                echo "<script type='text/javascript'>window.location='Index.php';</script>"; 

                 
            } else {  

                $result2 = mssql_query("SELECT * FROM account.dbo.tCash WHERE userNo = '".$row1[0]."'",$mslink); 
                $count_coins = mssql_num_rows($result2); 
             
                if($count_coins == '0') { 
                 
                    echo '<SCRIPT LANGUAGE="JavaScript">alert("This account didnt visit the D-shop yet. \n You cannot recive your coins. \n Please login into the server, and visit the D-shop.")</script>'; 
                    echo "<script type='text/javascript'>window.location='votenow.php';</script>"; 

                } else { 

         
                    $result2 = mysql_query("SELECT * FROM users WHERE account = '".$account."' "); 
                    $row2 = mysql_fetch_row($result2); 
                    $count2 = mysql_num_rows($result2); 
                     
                    if($count2 == 1){ 
                             
                        $voted_ip = $row2[2]; 
                        $voted_date = $row2[3]; 
                        $voted_id = $row2[0]; 
                        $voted_account = $row2[1]; 
                        $to_time = strtotime($voted_date); 
                        $from_time = strtotime($date); 
                     
                        if (round(abs($to_time - $from_time) / 60,2) > $time_needed) { 
                             
                            $cash = $coins;     
                            mysql_query("UPDATE users SET date = '".$date."' WHERE account = '".$account."' ");         
                            mssql_query("UPDATE account.dbo.tCash SET cash = cash+".$cash." WHERE userNo = '".$row1[0]."'",$mslink);     
                            echo '<SCRIPT LANGUAGE="JavaScript">alert("Danke fürs Voten!")</script>'; 
                            echo "<script type='text/javascript'>window.location='$webpage';</script>"; 
                                         
                        } else { 
                         
                            echo '<SCRIPT LANGUAGE="JavaScript">alert("Du hast in den letzten 12 Stunden schonmal gevotet! \n Bitte später erneu versuchen.")</script>'; 
                            echo "<script type='text/javascript'>window.location='$webpage1';</script>"; 

                        } 
                         
                    } else { 
                        $cash = $coins;     
                        $sql4 = mysql_query("INSERT INTO users (account,ip,date) VALUES ('".$account."','".$ip."','".$date."' ) "); 
                        mssql_query("UPDATE account.dbo.tCash SET cash = cash+".$cash." WHERE userNo = '".$row1[0]."'",$mslink);                 
                        echo '<SCRIPT LANGUAGE="JavaScript">alert("Thank you for you vote!")</script>'; 
                        echo "<script type='text/javascript'>window.location='$webpage';</script>"; 
     
                    } 
                }     
            } 
        } 
        mysql_close($mylink); 
        mssql_close($mslink); 
        ?> 
    </body> 
</html>