-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbase.php
More file actions
65 lines (50 loc) · 1.93 KB
/
base.php
File metadata and controls
65 lines (50 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* Created by PhpStorm.
* User: adm_gcs
* Date: 10/19/2016
* Time: 4:50 PM
*/
//error_reporting(-1);
//ini_set('display_errors', 'On');
session_start();
//Comment out this secion and replace the connection info with your local stuff.
//This connection is for a live mysql database that you have to have IP access to,
//So it won't work for you.
//########################################
$this_file = str_replace('drum_it_down', '', $_SERVER['DOCUMENT_ROOT']);
$sql_file = $this_file.'/drums_config.txt';
$json = "";
if (file_exists($sql_file))
{
// Note: You should probably do some more checks
// on the filetype, size, etc.
$contents = file_get_contents($sql_file);
// Note: You should probably implement some kind
// of check on filetype
$json = $contents;
}
if($json == ""){
echo "No file contents";
}
$json = json_decode($json);
$dbhost = $json->{'host'};
$dbname = $json->{'database'}; // the name of the database that you are going to use for this project
$dbuser = $json->{'username'}; // the username that you created, or were given, to access your database
$dbpass = $json->{'password'}; // the password that you created, or were given, to access your database
$port = $json->{'port'};
//#############################################
//Uncomment this section for your local database.
//#############################################
//$dbhost = 'localhost';
//$dbname = 'YOUR MYSQL DATABASE NAME'; // the name of the database that you are going to use for this project
//
//$dbuser = "YOUR MYSQL USERNAME"; // the username that you created, or were given, to access your database
//$dbpass = 'YOUR MYSQL PASSWORD'; // the password that you created, or were given, to access your database
//$port = 3306;
//#############################################
$conn = mysqli_connect($dbhost,$dbuser,$dbpass,$dbname,$port);
if (mysqli_connect_errno())
{
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}