Skip to content

Commit 2112da4

Browse files
committed
rudimentary php file splitting
1 parent e6fe423 commit 2112da4

File tree

126 files changed

+15977
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+15977
-0
lines changed

new/apps/web/src/php/404.html

+71
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
<!doctype html>
2+
<html lang="en">
3+
4+
<head>
5+
<meta charset="utf-8">
6+
<title>Page Not Found</title>
7+
<meta name="viewport" content="width=device-width, initial-scale=1">
8+
<link rel="shortcut icon" href="assets/specify-glass-dynamic.svg" />
9+
<link rel="icon" href="assets/specify-glass-black-256x256.png" media="(prefers-color-scheme light)" />
10+
<link rel="icon" href="assets/specify-glass-black-256x256.png" media="(prefers-color-scheme dark)" />
11+
<style>
12+
13+
* {
14+
line-height: 1.2;
15+
margin: 0;
16+
}
17+
18+
html {
19+
display: table;
20+
font-family: sans-serif;
21+
height: 100%;
22+
text-align: center;
23+
width: 100%;
24+
}
25+
26+
body {
27+
background-color: #3B4252;
28+
display: table-cell;
29+
vertical-align: middle;
30+
margin: 2em auto;
31+
}
32+
33+
h1 {
34+
color: #e0e2e4;
35+
font-size: 2em;
36+
font-weight: 400;
37+
}
38+
39+
p {
40+
color: #e0e2e4;
41+
margin: 0 auto;
42+
width: 280px;
43+
}
44+
45+
@media only screen and (max-width: 280px) {
46+
47+
body,
48+
p {
49+
width: 95%;
50+
}
51+
52+
h1 {
53+
font-size: 1.5em;
54+
margin: 0 0 0.3em;
55+
}
56+
57+
}
58+
</style>
59+
</head>
60+
61+
<body>
62+
63+
<div>
64+
<img src="assets/logo.png">
65+
</div>
66+
67+
<h1>Page Not Found</h1>
68+
<p>Sorry, but the view you were trying to access has expired or is invalid.</p>
69+
</body>
70+
71+
</html>

new/apps/web/src/php/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# specified
2+
An Open Source viewer engine for Specify JSON exports. See [Specify](https://github.com/Spec-ify/specify) for more information.
3+
4+
Written mostly in PHP, visually based (in large) on <a href="https://spark.lucko.me/" target="_blank">Spark</a>
5+
6+
7+
## Style guide
8+
You should prefer to conform to the style of the surrounding code over personal preference.
9+
10+
### Language Conventions
11+
Language specific styling should conform to the [Wordpress Developer Style Guide](https://developer.wordpress.org/coding-standards/wordpress-coding-standards/javascript/), with the following changes:
12+
13+
- Shorthand PHP tags are allowed

new/apps/web/src/php/archive.php

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
<?php
2+
//Shutting out error printing because the two vars will be unset a lot of the time and php will complain
3+
ini_set('display_errors', 0);
4+
include('archive_secret.php');
5+
$login_user = $_POST['user'];
6+
$login_pass = $_POST['pass'];
7+
8+
//Checking if given username and pw are correct
9+
if($login_user == $user
10+
&& $login_pass == $pass)
11+
{
12+
include("rudimentary.php");
13+
die;
14+
}
15+
else
16+
{
17+
//Else, printing out the login page. It's a simple form that just posts back on itself to run the check again.
18+
if(isset($_POST))
19+
{echo '
20+
<meta content="text/html;charset=UTF-8" http-equiv="content-type"/>
21+
<head>
22+
<meta charset="utf-8"/>
23+
<title>Specified</title>
24+
<meta content="width=device-width,initial-scale=1" name="viewport"/>
25+
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/css/bootstrap.min.css"/>
26+
27+
<link href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" rel="stylesheet"/>
28+
<link href="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/5.0.0/mdb.dark.min.css" rel="stylesheet">
29+
<link href="static/css/themes.css" rel="stylesheet" >
30+
<link href="static/css/main.css" rel="stylesheet">
31+
</head>
32+
<div class="textbox metadata-detail tablebox widget json-data" id="login-form">
33+
<h1>Specify Archive Login</h1>
34+
<form method="POST" action="archive">
35+
<div class="form-outline mb-4">
36+
<input type="text" name="user" class="form-control" id="login-form-user"></input><br/>
37+
<label class="form-label" for="login-form-user">Username</label>
38+
</div>
39+
<div class="form-outline mb-4">
40+
<input type="password" name="pass" class="form-control" id="login-form-pass"></input><br/>
41+
<label class="form-label" for="login-form-pass">Password</label>
42+
</div>
43+
<button type="submit" name="submit" class="btn btn-primary btn-block">Login</button>
44+
</form>
45+
</div>
46+
47+
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.2/jquery.min.js" integrity="sha512-tWHlutFnuG0C6nQRlpvrEhE4QpkG1nn2MOUMWmUeRePl4e3Aki0VB6W1v3oLjFtd0hVOtRQ9PHpSfN6u6/QXkQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
48+
<script
49+
src="https://cdnjs.cloudflare.com/ajax/libs/mdb-ui-kit/5.0.0/mdb.min.js"
50+
type="text/javascript"
51+
></script>
52+
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/5.1.3/js/bootstrap.bundle.min.js"></script>
53+
<script type="text/javascript" src="https://cdn.datatables.net/v/bs5/dt-1.13.1/sc-2.0.7/datatables.min.js"></script>
54+
<script defer="defer" src="static/js/main.js"></script>';
55+
}
56+
}
57+
?>

new/apps/web/src/php/assets/brave.png

3.62 KB
Loading
2.31 KB
Loading

new/apps/web/src/php/assets/dl.png

3.49 KB
Loading

new/apps/web/src/php/assets/edge.png

2.79 KB
Loading
8.29 KB
Loading

new/apps/web/src/php/assets/gx.png

3.26 KB
Loading

new/apps/web/src/php/assets/logo.png

8.95 KB
Loading
Loading
Loading
Loading
9.42 KB
Loading

new/apps/web/src/php/common.php

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
// functions that are common to multiple viewer modes
3+
4+
//XDDDDD
5+
function bytesToGigabytes($bytes)
6+
{
7+
// 1073741824 = 1024 * 1024 * 1024
8+
return $bytes / 1073741824;
9+
}
10+
11+
function bytesToMegabytes($bytes)
12+
{
13+
// 1073741824 = 1024 * 1024
14+
return $bytes / 1048576;
15+
}
16+
17+
function getDriveUsed($driveinput)
18+
{
19+
$driveused = 0;
20+
foreach ($driveinput['Partitions'] as $partition) {
21+
$driveused += $partition['PartitionCapacity'] - $partition['PartitionFree'];
22+
}
23+
return $driveused;
24+
}
25+
26+
function getDriveFree($driveinput)
27+
{
28+
$drivefree = $driveinput['DiskCapacity'] - getDriveUsed($driveinput);
29+
return $drivefree;
30+
}
31+
32+
function getDriveCapacity($driveinput)
33+
{
34+
$partitioncap = 0;
35+
foreach ($driveinput['Partitions'] as $partition) {
36+
$partitioncap += $partition['PartitionCapacity'];
37+
}
38+
return $partitioncap;
39+
}
40+
41+
/**
42+
* This is to prevent TypeErrors on malformed jsons where an array is null
43+
*/
44+
function safe_count($arr): int {
45+
if (is_countable($arr)) {
46+
return count($arr);
47+
} else {
48+
$bt = debug_backtrace();
49+
trigger_error("safe_count called on null in {$bt['file']} on line {$bt['line']}", E_USER_NOTICE);
50+
return 0;
51+
}
52+
}
53+
54+
function safe_implode(string $separator, $arr): string {
55+
if (is_array($arr)) {
56+
return implode($separator, $arr);
57+
} else {
58+
$bt = debug_backtrace()[0];
59+
trigger_error("safe_implode called on null in {$bt['file']} on line {$bt['line']}", E_USER_NOTICE);
60+
return '';
61+
}
62+
}
63+
64+
function timeConvert($time)
65+
{
66+
67+
$timeString = "";
68+
69+
$days = floor($time / (60 * 60 * 24));
70+
$hours = floor(($time % (60 * 60 * 24)) / (60 * 60));
71+
$minutes = floor(($time % (60 * 60)) / 60);
72+
$seconds = $time % 60;
73+
74+
// Initialize the string with the number of days
75+
76+
if ($days) {
77+
$timeString = '<span';
78+
if ($days > 3) $timeString .= ' style="color:#BF616A;"';
79+
$timeString .= '>' . $days . ' day';
80+
if ($days != 1) {
81+
$timeString .= 's';
82+
}
83+
$timeString .= ', ';
84+
}
85+
86+
87+
// Add the number of hours to the string
88+
if ($hours) {
89+
$timeString .= $hours . ' hour';
90+
if ($hours != 1) {
91+
$timeString .= 's';
92+
}
93+
$timeString .= ', ';
94+
}
95+
96+
// Add the number of minutes to the string
97+
if ($minutes) {
98+
$timeString .= $minutes . ' minute';
99+
if ($minutes != 1) {
100+
$timeString .= 's';
101+
}
102+
$timeString .= ', ';
103+
}
104+
// Add the number of seconds to the string A3BE8C
105+
if ($seconds) {
106+
if ($days || $hours || $minutes) $timeString .= 'and ';
107+
$timeString .= $seconds . ' second';
108+
if ($seconds != 1) {
109+
$timeString .= 's</span>';
110+
}
111+
}
112+
113+
return $timeString;
114+
}
115+
116+
// https://maxchadwick.xyz/blog/stripping-a-query-parameter-from-a-url-in-php
117+
function http_strip_query_param($url, $param)
118+
{
119+
$pieces = parse_url($url);
120+
$query = [];
121+
if ($pieces['query']) {
122+
parse_str($pieces['query'], $query);
123+
unset($query[$param]);
124+
$pieces['query'] = http_build_query($query);
125+
}
126+
127+
return $pieces['path'] . ($pieces['query'] ? '?' : '') . $pieces['query'];
128+
}

new/apps/web/src/php/composer.json

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"name": "spec-ify/specified",
3+
"description": "A web viewer for Specify",
4+
"type": "project",
5+
"require-dev": {
6+
"phpstan/phpstan": "^1.12",
7+
"phpstan/phpstan-strict-rules": "^1.6"
8+
},
9+
"require": {
10+
"basuke/sveltekit-php-backend": "^1.0"
11+
}
12+
}

0 commit comments

Comments
 (0)