ztizzlegaming / CSGOWinBig

Open-source Counter-Strike: Global Offensive jackpot betting website.
MIT License
169 stars 104 forks source link

I can login to my site, but the pot wont show up, it just keeps saying loading... #179

Open HansenDansen opened 8 years ago

HansenDansen commented 8 years ago

Hey Everybody.

I can login to my website, but the pot and the chat keeps saying loading. I have hardcoded the passwords and api key into the code.. This is the changes i made when i did hardcode it in.. And this is a picture of the problem. http://imgur.com/KdLVsql

Regards Frederik

andrewda commented 8 years ago

Did you setup the MySQL database and are you getting connections to it?

HansenDansen commented 8 years ago

Yes i did that :) and i have putted in the password :)

HansenDansen commented 8 years ago

Where can i see if i got connection to the Database? In the update.php?

andrewda commented 8 years ago

Try just making a simple PHP script to get data from the MySQL server. My guess is that your site can't connect to your database.

HansenDansen commented 8 years ago

I'll try that, but cant i just see if it have connection through the update.php file?

HansenDansen commented 8 years ago

The website got connection to the database, because i did just deposit an skin to my bot, and then the update.php file updated.. Before the deposit: http://i.imgur.com/dokQRjb.png And after the deposit: http://i.imgur.com/Lq4nikY.png

HansenDansen commented 8 years ago

I have tested it twice now with two different things, and both did connect, but i still doesent show up on the website.. Does the Database needs to have a specific Charset, shouldnt UTF8 be fine?

andrewda commented 8 years ago

Yep that all looks good. What's your website URL?

HansenDansen commented 8 years ago

http://csgobottle.com :)

andrewda commented 8 years ago

http://imgur.com/OSZxAHd Here's your issue. Add a chat message directly to the MySQL database and see if that fixes your issue.

 

To quote the README:

The site assumes that there will always be chat messages, so you have to manually insert one chat message into the chat database table.

HansenDansen commented 8 years ago

I have forgot about that, for sure it might solve the problem.. But it might sound stupid, but how do i add an chat message in there.. http://imgur.com/hww1whD Which one of theese do i need to add something to? :) I do not know that much about MySQL

HansenDansen commented 8 years ago

I did figure it out! But yeah that worked! Thanks alot for your help man!

HansenDansen commented 8 years ago

Are you still in here, because now i got an new problem.. The timer on the website dosent start.. The update.php file does get the items, but the check-items.php and the timer-end.php makes this error message.. http://i.imgur.com/wbRPyLG.png Is it because i dosent have connection to the database? Thanks in advance

andrewda commented 8 years ago

https://github.com/ztizzlegaming/CSGOWinBig/blob/83c2b02383c22926a078e6da8a27097520262ae6/src/php/timer-end.php#L9-L12

You didn't supply a password

HansenDansen commented 8 years ago

so i need to put the database password in that field?

HansenDansen commented 8 years ago

or where should i supply an password?

andrewda commented 8 years ago

No, you need to put the password that is defined as "default-password" in your passwords.txt

(see https://github.com/ztizzlegaming/CSGOWinBig/blob/83c2b02383c22926a078e6da8a27097520262ae6/src/php/timer-end.php#L20)

HansenDansen commented 8 years ago

Okay, but i did code the password in to the .php files because that my host doesnt allow me to put anything outside of the web root... So how can i supply it?

HansenDansen commented 8 years ago

I can send you an Pastebin with my files in, so you can see what i have changed.. if you want me to?

andrewda commented 8 years ago

Change this:

# Get the password from config file and make sure it matches
$fileLoc = $_SERVER['DOCUMENT_ROOT'] . '/../passwords.txt';
if (file_exists($fileLoc)) {
    $fh = fopen($fileLoc, 'r');
    $jsonStr = fgets($fh);
    $arr = json_decode($jsonStr, true);
    $realPassword = $arr['default-password'];
    fclose($fh);
} else {
    die('no file found');
}

to

$realPassword = "XXX";

Then, when making a request, use http://site.com/timer-end.php with a POST field of password equal to XXX. If you don't have a way to make POST requests easily, try Postman, a free Chrome extension. (Or alternatively you can change $_POST to $_GET to make it a get request which you can do from your URL bar - i.e. http://site.com/timer-end.php?password=XXX)

HansenDansen commented 8 years ago

so like this: $password = isset($_POST['password']=xxx) ? $_POST['password'=xxx]

The password = xxx

?

I am really glad for you help dude! It means alot!

andrewda commented 8 years ago

No. So let's just make this easy for now. Change

# Get the password from config file and make sure it matches
$fileLoc = $_SERVER['DOCUMENT_ROOT'] . '/../passwords.txt';
if (file_exists($fileLoc)) {
    $fh = fopen($fileLoc, 'r');
    $jsonStr = fgets($fh);
    $arr = json_decode($jsonStr, true);
    $realPassword = $arr['default-password'];
    fclose($fh);
} else {
    die('no file found');
}

to

$realPassword = "XXX";

AND change

$password = isset($_POST['password']) ? $_POST['password'] : null;

to

$password = isset($_GET['password']) ? $_GET['password'] : null;

Now you can end the timer with http://site.com/timer-end.php?password=XXX.

HansenDansen commented 8 years ago

Arh, okay.. But my problem is that i want the timer to start, it just keeps saying 0, and there is 4 people in the pot and 32 items in it.. can you solve that problem aswell?

Btw, cant i just put my passwords.txt in an folder, and then edit this: # Get the password from config file and make sure it matches $fileLoc = $_SERVER['DOCUMENT_ROOT'] . '/../passwords.txt'; if (file_exists($fileLoc)) { $fh = fopen($fileLoc, 'r'); $jsonStr = fgets($fh); $arr = json_decode($jsonStr, true); $realPassword = $arr['default-password']; fclose($fh); } else { die('no file found'); } So that it find the file passwords.txt in that folder? Wouldnt that fix it all?

andrewda commented 8 years ago

If you put it on your web host, that's an ENOURMOUS security risk, as someone can simply go to http://site.com/passwords.txt or /folder/passwords.txt and get all your passwords. The best way to do it is to put them all in a PHP file, and I'm not sure why that's not what @ztizzlegaming did. I'll fix that in my branch.

HansenDansen commented 8 years ago

Yeah okay, stupid me xD. But i cant be awake 24/7 and type that url in, can i fix it on another way? And how to fix the bug with the timer that doesnt start?

Again i'm really glad for all you help dude!

HansenDansen commented 8 years ago

If i buy my host on an host that allows me to save my files outside of the web root, wouldnt that fix it all aswell?

andrewda commented 8 years ago

It should. If it's a fresh installation of CSGOWinBig, it should work fine.

HansenDansen commented 8 years ago

But, again if the check-items.php and the timer-end.php files cant get the password, and i need to type that url in every time i want it to work, then i'll need to stay awake 24/7, is there anyway that i can fix it another way with that server i got now?

Thanks in Advance

HansenDansen commented 8 years ago

@andrewda I just bought VPS at Bluehost, everything works fine now. Besides one thing.. The timer, i have tried to do everything that all the other suggest, but nothing really helps.. Can you help me with this as well? And again thank you very much for all your help!