Skip to content

Commit

Permalink
2.0 update
Browse files Browse the repository at this point in the history
  • Loading branch information
lera2od committed May 11, 2023
1 parent e872d73 commit 505bbfb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
src/app/settings.json
README.md
src/leravel/leravel.json
src/leravel/admin/statRenders/lastUpdated.json
src/leravel/admin/statRenders/mostVisitedPages.json
src/leravel/admin/statRenders/weeklyVisits.json
src/app/stats.json
src/leravel/admin/statRenders
.gitignore
3 changes: 2 additions & 1 deletion src/leravel/admin/views/stats.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
if ($render == "true") {
$weeklyVisits = array();


foreach ($stats as $stat) {
$date = $stat["date"];
$visits = 0;
Expand Down Expand Up @@ -60,7 +61,7 @@
if (in_array($ip, array_column($visitors, "ip"))) {
continue;
}
if ($ip == "127.0.0.1") {
if ($ip == "127.0.0.1" || $ip == "::1") {
continue;
}
$country = json_decode(file_get_contents("http://ip-api.com/json/" . $ip), true)["country"];
Expand Down
5 changes: 5 additions & 0 deletions src/leravel/commonErrors.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,10 @@
"error" : "parse_ini_file(",
"file" : "\\admin\\admin.php",
"solution" : "<b>account.ini</b> moved into <b>/app/adminAccount.ini</b><br>For more info : <a href='https://github.com/lera2od/leravel/releases/tag/1.3'>leravel v1.3 changelog</a>"
},
{
"error" : "Uncaught mysqli_sql_exception",
"file" : "leravelVar.php",
"solution" : "The default MySQLI connection having trouble connecting to the MySQL server<br>Check if your MySQL server is on. Or disable the database entirely from settings.json"
}
]
39 changes: 28 additions & 11 deletions src/leravel/error.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,23 @@ function customError($errno, $errstr, $errfile, $errline)
}


echo "<style>h1,h2{margin:0}.centerbox,.row,fieldset{display:flex}table{border-collapse:collapse;background-color:red}table,td,th{border:1px solid #000;padding:5px}body{background-image:linear-gradient(40deg,#744d4d,#fff);font-size:1.2rem;line-height:1.5;color:#000;background-position:center;background-repeat:no-repeat;background-size:cover;min-height:100vh;font-family:Roboto,sans-serif}h1{font-size:2rem;font-weight:400;padding:0}h2,legend{font-size:1.2rem;font-weight:400;padding:0}.container{width:100%;max-width:1200px;margin:0 auto;padding:0 1rem}.row{flex-wrap:wrap;margin:0 -1rem}.col{flex:1 1 100%;padding:0 1rem}.center{text-align:center}.centerbox{justify-content:center;align-items:center;flex-direction:column}.btn{display:inline-block;padding:.5rem 1rem;border-radius:.25rem;background-color:#333;color:#fff;text-decoration:none;transition:.2s ease-in-out;display:flex;align-items:center}.btn:hover{background-color:#444}.btn img{width:2.5rem}.logo{width:100%;max-width:300px}::-webkit-scrollbar{width:.4rem}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888;border-radius:5px}fieldset{border:1px solid #000;border-radius:5px;padding:20px;justify-content:center;align-items:center;flex-direction:column}legend{margin:0 10px}</style>";
echo "<style>h1,h2{margin:0}.centerbox,.row,fieldset{display:flex}table{border-collapse:collapse;background-color:red}table,td,th{border:1px solid #000;padding:5px}body{background-image:linear-gradient(40deg,#744d4d,#fff);font-size:1.2rem;line-height:1.5;color:#000;background-position:center;background-repeat:no-repeat;background-size:cover;min-height:100vh;font-family:Roboto,sans-serif}h1{font-size:2rem;font-weight:400;padding:0}h2,legend{font-size:1.2rem;font-weight:400;padding:0}.container{width:100%;max-width:1200px;margin:0 auto;padding:0 1rem}.row{flex-wrap:wrap;margin:0 -1rem}.col{flex:1 1 100%;padding:0 1rem}.center{text-align:center}.centerbox{justify-content:center;align-items:center;flex-direction:column}.btn{display:inline-block;padding:.5rem 1rem;border-radius:.25rem;background-color:#333;color:#fff;text-decoration:none;transition:.2s ease-in-out;display:flex;align-items:center}.btn:hover{background-color:#444}.btn img{width:2.5rem}.logo{width:100%;max-width:300px}::-webkit-scrollbar{width:.4rem}::-webkit-scrollbar-track{background:#f1f1f1}::-webkit-scrollbar-thumb{background:#888;border-radius:5px}fieldset{border:1px solid #000;border-radius:5px;padding:20px;justify-content:center;align-items:center;flex-direction:column}legend{margin:0 10px}
.solution {
background-color: #33e361;
padding: 10px;
border-radius: 10px;
box-shadow: 0px 0px 15px 4px black;
font-family: monospace;
}
.solution table {
background-color: #fffdfd5e;
color: black;
}
.solution h2 {
font-size: 26px;
color: #000000c7;
}
</style>";
echo '<div class="container">';
echo "<div class='centerbox'>";
echo "<h1 style='color: red;'>ERROR</h1>";
Expand All @@ -26,15 +42,6 @@ function customError($errno, $errstr, $errfile, $errline)
echo "<div class='centerbox'>";
$extra = "";
if (strpos($errfile, "leravel") !== false) {
if($solution != null) {
echo "<br>";
echo "<h2>There is a solution for this error</h2>";
echo "<table>";
echo "<tr><td>Solution</td><td>" . $solution . "</td></tr>";
echo "</table>";
echo "<br>";
$extra = "If the solution didn't help.";
}
echo "<table>";
echo "<tr><td>Error Type</td><td>Leravel Error</td></tr>";
echo "<tr><td>Error</td><td>" . $errno . "</td></tr>";
Expand All @@ -43,9 +50,19 @@ function customError($errno, $errstr, $errfile, $errline)
echo "<tr><td>Line</td><td>" . $errline . "</td></tr>";
echo "</table>";
echo "<br>";
if($solution != null) {
echo "<br>";
echo "<div class='solution'>";
echo "<h2>There is a solution for this error</h2>";
echo "<table>";
echo "<tr><td>Solution</td><td>" . $solution . "</td></tr>";
echo "</table>";
echo "</div>";
echo "<br>";
}
echo "<fieldset>";
echo "<legend>Report The Error</legend>";
echo '<a href="https://github.com/lera2od/leravel" class="btn" style="width: fit-content"><img src="https://img.icons8.com/fluency/256/github.png">'. $extra . 'Report the error using Github</a>';
echo '<a href="https://github.com/lera2od/leravel" class="btn" style="width: fit-content"><img src="https://img.icons8.com/fluency/256/github.png"> Report the error using Github</a>';
echo "</fieldset>";
} else {
echo "<table>";
Expand Down
1 change: 1 addition & 0 deletions src/leravel/index.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
session_start();
error_reporting(0);

$files = glob(__DIR__ . "/*.php");
foreach ($files as $file) {
Expand Down
5 changes: 1 addition & 4 deletions src/leravel/leravel.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
{
"version": "1.6",
"statWeek": 20,
"lastUpdateCheck": 1683738433,
"latestVersion": "1.5"
"version": "2.0"
}
4 changes: 2 additions & 2 deletions src/leravel/leravelVar.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
if ($Leravel["settings"]["database"]["enabled"] == "true" || $Leravel["settings"]["database"]["enabled"] == "1") {
$Leravel["conn"] = new Mysqli($Leravel["settings"]["database"]["host"], $Leravel["settings"]["database"]["username"], $Leravel["settings"]["database"]["password"], $Leravel["settings"]["database"]["database"]);

if ($Leravel["conn"]->connect_error) {
die("Connection failed: " . $Leravel["conn"]->connect_error);
if ( $Leravel["conn"]->connect_errno ) {
die('Connect Error: ' . $db->connect_errno);
}
}

0 comments on commit 505bbfb

Please sign in to comment.