forked from Chocobozzz/OpenVPN-Admin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix database date: 0000-00-00 -> NULL
- Loading branch information
Chocobozzz
committed
Feb 5, 2017
1 parent
1aac22b
commit ab7f85b
Showing
14 changed files
with
125 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
.phpintel | ||
vendor/ | ||
*.komodoproject |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
<div class="col-md-6 col-md-offset-3"> | ||
<nav class="navbar navbar-default"> | ||
|
||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> | ||
<ul class="nav navbar-nav"> | ||
<li <?php if(!isset($_GET['admin'])) echo 'class="active"'; ?>><a href="index.php">Configurations</a></li> | ||
<li <?php if(isset($_GET['admin'])) echo 'class="active"'; ?>><a href="index.php?admin">Administrator</a></li> | ||
</ul> | ||
</div> | ||
|
||
</nav> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
if (count($argv) !== 2) { | ||
echo "Need the www base path as argument"; | ||
exit(0); | ||
} | ||
|
||
$www = $argv[1]; | ||
|
||
require("$www/include/config.php"); | ||
require("$www/include/connect.php"); | ||
require("$www/include/functions.php"); | ||
|
||
$migrations = getMigrationSchemas(); | ||
|
||
try { | ||
$req = $bdd->prepare('SELECT `sql_schema` FROM `application` LIMIT 1'); | ||
$req->execute(); | ||
$data = $req->fetch(); | ||
|
||
$sql_schema = 0; | ||
if ($data['sql_schema']) { | ||
$sql_schema = $data['sql_schema']; | ||
} | ||
} | ||
// Table does not exist | ||
catch (Exception $e) { | ||
$sql_schema = 0; | ||
} | ||
|
||
// For each migrations | ||
foreach ($migrations as $migration_value) { | ||
|
||
// Do the migration, we are behind the last schema | ||
if ($sql_schema < $migration_value) { | ||
|
||
// Create the tables or die | ||
$sql_file = dirname(__FILE__) . "/sql/schema-$migration_value.sql"; | ||
try { | ||
$sql = file_get_contents($sql_file); | ||
$bdd->exec($sql); | ||
} | ||
catch (PDOException $e) { | ||
printError($e->getMessage()); | ||
exit(1); | ||
} | ||
|
||
// Update schema to the new value | ||
updateSchema($bdd, $migration_value); | ||
|
||
echo "Moved to schema $migration_value"; | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
CREATE TABLE IF NOT EXISTS `application` ( `id` INT(11) AUTO_INCREMENT, `sql_schema` INT(11) NOT NULL, PRIMARY KEY (id) ); | ||
|
||
ALTER TABLE `user` CHANGE `user_start_date` `user_start_date` DATE NULL DEFAULT NULL; | ||
ALTER TABLE `user` CHANGE `user_end_date` `user_end_date` DATE NULL DEFAULT NULL; | ||
ALTER TABLE `log` CHANGE `log_end_time` `log_end_time` TIMESTAMP NULL DEFAULT NULL; | ||
|
||
UPDATE `user` SET `user_start_date` = NULL WHERE `user_start_date` = '0000-00-00'; | ||
UPDATE `user` SET `user_end_date` = NULL WHERE `user_end_date` = '0000-00-00'; | ||
UPDATE `log` SET `log_end_time` = NULL WHERE `log_end_time` = '0000-00-00'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters