From a84a475008d5a86ee0aa278b4efcdfd224755b36 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Schw=C3=B6rer?= Date: Sat, 27 Jan 2018 14:21:34 +0100 Subject: [PATCH] smaller prog previews + self test --- www/data/binaries/.gitignore | 1 + www/data/css/styles.css | 19 +++ www/data/css/styles.min.css | 6 + www/data/css/styles_admin.scss | 14 +- www/data/css/styles_config.scss | 1 + www/data/css/styles_header.scss | 1 + www/data/dynamic/.gitignore | 4 + www/data/dynamic/.gitkeep | 0 www/data/dynamic/.htaccess | 1 + .../AlephNote.png | Bin .../All_in_One.png | Bin .../Beepster.png | Bin .../BefunUtils.png | Bin .../BefunZ.png | Bin .../Blitzer.png | Bin .../BorderlineDefense.png | Bin .../CannonConquest.png | Bin .../CrystalGrid.png | Bin .../DLF.png | Bin .../Deal_or_no_Deal.png | Bin .../ExtendedGitGraph.png | Bin .../Graveyard_of_Numbers.png | Bin .../H2O.png | Bin .../HexSolver.png | Bin .../InfinityTournament.png | Bin .../KeygenDancer.png | Bin .../LanControl.png | Bin .../LightShow.png | Bin .../Logistixx.png | Bin .../NedSchend.png | Bin .../Passpad.png | Bin .../QuickHiddenFolderToggle.png | Bin .../SDL.png | Bin .../Serpilicum.png | Bin .../SharkSim.png | Bin .../Sieb_des_Eratosthenes.png | Bin .../SuperBitBros.png | Bin .../TicTacToe.png | Bin .../Ziegenproblem.png | Bin .../absCanvas.png | Bin .../exeExtract.png | Bin .../jCircuits.png | Bin .../jClipCorn.png | Bin .../jQCCounter.png | Bin www/fragments/header.php | 2 +- www/fragments/panel_programs.php | 2 +- www/index.php | 6 +- www/internals/base.php | 107 ++++++++++++ www/internals/blog.php | 37 ++++- www/internals/euler.php | 24 +++ www/internals/mikeschergitgraph.php | 22 +++ www/internals/programs.php | 157 +++++++++++++++++- www/pages/about.php | 3 +- www/pages/admin.php | 48 +++++- www/pages/admin_cmd.php | 43 +++++ www/pages/programs_list.php | 2 +- www/pages/programs_view.php | 22 +-- www/statics/programs/__all.php | 53 +++--- 58 files changed, 521 insertions(+), 54 deletions(-) create mode 100644 www/data/binaries/.gitignore create mode 100644 www/data/dynamic/.gitignore create mode 100644 www/data/dynamic/.gitkeep create mode 100644 www/data/dynamic/.htaccess rename www/data/images/{program_thumbnails => program_img}/AlephNote.png (100%) rename www/data/images/{program_thumbnails => program_img}/All_in_One.png (100%) rename www/data/images/{program_thumbnails => program_img}/Beepster.png (100%) rename www/data/images/{program_thumbnails => program_img}/BefunUtils.png (100%) rename www/data/images/{program_thumbnails => program_img}/BefunZ.png (100%) rename www/data/images/{program_thumbnails => program_img}/Blitzer.png (100%) rename www/data/images/{program_thumbnails => program_img}/BorderlineDefense.png (100%) rename www/data/images/{program_thumbnails => program_img}/CannonConquest.png (100%) rename www/data/images/{program_thumbnails => program_img}/CrystalGrid.png (100%) rename www/data/images/{program_thumbnails => program_img}/DLF.png (100%) rename www/data/images/{program_thumbnails => program_img}/Deal_or_no_Deal.png (100%) rename www/data/images/{program_thumbnails => program_img}/ExtendedGitGraph.png (100%) rename www/data/images/{program_thumbnails => program_img}/Graveyard_of_Numbers.png (100%) rename www/data/images/{program_thumbnails => program_img}/H2O.png (100%) rename www/data/images/{program_thumbnails => program_img}/HexSolver.png (100%) rename www/data/images/{program_thumbnails => program_img}/InfinityTournament.png (100%) rename www/data/images/{program_thumbnails => program_img}/KeygenDancer.png (100%) rename www/data/images/{program_thumbnails => program_img}/LanControl.png (100%) rename www/data/images/{program_thumbnails => program_img}/LightShow.png (100%) rename www/data/images/{program_thumbnails => program_img}/Logistixx.png (100%) rename www/data/images/{program_thumbnails => program_img}/NedSchend.png (100%) rename www/data/images/{program_thumbnails => program_img}/Passpad.png (100%) rename www/data/images/{program_thumbnails => program_img}/QuickHiddenFolderToggle.png (100%) rename www/data/images/{program_thumbnails => program_img}/SDL.png (100%) rename www/data/images/{program_thumbnails => program_img}/Serpilicum.png (100%) rename www/data/images/{program_thumbnails => program_img}/SharkSim.png (100%) rename www/data/images/{program_thumbnails => program_img}/Sieb_des_Eratosthenes.png (100%) rename www/data/images/{program_thumbnails => program_img}/SuperBitBros.png (100%) rename www/data/images/{program_thumbnails => program_img}/TicTacToe.png (100%) rename www/data/images/{program_thumbnails => program_img}/Ziegenproblem.png (100%) rename www/data/images/{program_thumbnails => program_img}/absCanvas.png (100%) rename www/data/images/{program_thumbnails => program_img}/exeExtract.png (100%) rename www/data/images/{program_thumbnails => program_img}/jCircuits.png (100%) rename www/data/images/{program_thumbnails => program_img}/jClipCorn.png (100%) rename www/data/images/{program_thumbnails => program_img}/jQCCounter.png (100%) create mode 100644 www/pages/admin_cmd.php diff --git a/www/data/binaries/.gitignore b/www/data/binaries/.gitignore new file mode 100644 index 0000000..6f66c74 --- /dev/null +++ b/www/data/binaries/.gitignore @@ -0,0 +1 @@ +*.zip \ No newline at end of file diff --git a/www/data/css/styles.css b/www/data/css/styles.css index 2f93cbf..3267014 100644 --- a/www/data/css/styles.css +++ b/www/data/css/styles.css @@ -230,6 +230,8 @@ body { background-color: #555; } #headerdiv .tabrow .tab_active { background-color: #442222; } + #headerdiv .tabrow .tab_admin { + background-color: #222244; } #headerdiv .tabrow .tab_split { flex: auto; } #headerdiv .tabrow .tab_github { @@ -1051,6 +1053,8 @@ html, body { .keyvaluelist div { display: flex; flex-direction: row; } + .keyvaluelist div span { + align-self: center; } .keyvaluelist div span:first-child { font-weight: bold; min-width: 500px; } @@ -1064,6 +1068,21 @@ html, body { .kvl_300 div span:first-child { min-width: 300px; } +.consistency_result_ok, .consistency_result_warn, .consistency_result_err { + min-width: 400px; + border: 1px solid #888; + padding: 0 5px; + margin: 1px 0; } + +.consistency_result_ok { + background: #0F0; } + +.consistency_result_warn { + background: #FF0; } + +.consistency_result_err { + background: #F00; } + /* 400px */ #loginform div { display: flex; diff --git a/www/data/css/styles.min.css b/www/data/css/styles.min.css index fa341ae..64b5a7c 100644 --- a/www/data/css/styles.min.css +++ b/www/data/css/styles.min.css @@ -48,6 +48,7 @@ body{background-color:#EEE;color:#CCC;font-family:serif} #headerdiv .tabrow .tab{display:flex;justify-content:center;align-items:center;background-color:#222;color:#CCC;border-left:1px solid #000;border-right:1px solid #000;font-weight:bold;text-decoration:none;margin:0 0 0 20px;padding:2px 5px;min-width:64px;text-align:center;flex:initial} #headerdiv .tabrow .tab:hover{cursor:pointer;background-color:#555} #headerdiv .tabrow .tab_active{background-color:#422} +#headerdiv .tabrow .tab_admin{background-color:#224} #headerdiv .tabrow .tab_split{flex:auto} #headerdiv .tabrow .tab_github{background-color:#4078c0;border-left:1px solid #111;border-right:0;color:black} #headerdiv .tabrow .tab_github:hover{background-color:#c9510c;color:black} @@ -260,10 +261,15 @@ html,body{margin:0;padding:0;height:100%} .egh_ajaxOutput{display:flex;box-sizing:border-box;width:100%;align-self:center;justify-self:center;margin-left:auto;margin-right:auto;resize:none;height:300px} .keyvaluelist{display:flex;flex-direction:column} .keyvaluelist div{display:flex;flex-direction:row} +.keyvaluelist div span{align-self:center} .keyvaluelist div span:first-child{font-weight:bold;min-width:500px} .kvl_100 div span:first-child{min-width:100px} .kvl_200 div span:first-child{min-width:200px} .kvl_300 div span:first-child{min-width:300px} +.consistency_result_ok,.consistency_result_warn,.consistency_result_err{min-width:400px;border:1px solid #888;padding:0 5px;margin:1px 0} +.consistency_result_ok{background:#0F0} +.consistency_result_warn{background:#FF0} +.consistency_result_err{background:#F00} #loginform div{display:flex;flex-direction:column} #loginform div button{margin:10px 0;padding:0} .loginerror{display:flex;background:#f44;font-weight:bold;padding:0 5px;margin:5px 0 20px 0} diff --git a/www/data/css/styles_admin.scss b/www/data/css/styles_admin.scss index a14f7a2..795b099 100644 --- a/www/data/css/styles_admin.scss +++ b/www/data/css/styles_admin.scss @@ -29,7 +29,7 @@ div { display: flex; flex-direction: row; - + span {align-self: center;} span:first-child { font-weight: bold; min-width: 500px; @@ -44,4 +44,14 @@ .kvl_100 div span:first-child { min-width: 100px; } .kvl_200 div span:first-child { min-width: 200px; } -.kvl_300 div span:first-child { min-width: 300px; } \ No newline at end of file +.kvl_300 div span:first-child { min-width: 300px; } + +.consistency_result_ok, .consistency_result_warn, .consistency_result_err { + min-width: 400px; + border: 1px solid #888; + padding: 0 5px; + margin: 1px 0; +} +.consistency_result_ok { background: #0F0; } +.consistency_result_warn { background: #FF0; } +.consistency_result_err { background: #F00; } \ No newline at end of file diff --git a/www/data/css/styles_config.scss b/www/data/css/styles_config.scss index f93c590..05c581f 100644 --- a/www/data/css/styles_config.scss +++ b/www/data/css/styles_config.scss @@ -13,6 +13,7 @@ $COL_COMPLEXHOVER_BRD: black; $COL_GITHUB: #4078C0; $COL_HIGHLIGHT_RED: #442222; +$COL_HIGHLIGHT_BLUE: #222244; $FONT_HEADER: Lato, "Helvetica Neue", Helvetica, Arial, sans-serif; $FONT_CODE: Consolas, Monaco, "Courier New", Menlo, monospace; diff --git a/www/data/css/styles_header.scss b/www/data/css/styles_header.scss index e5e8d48..929b354 100644 --- a/www/data/css/styles_header.scss +++ b/www/data/css/styles_header.scss @@ -53,6 +53,7 @@ } .tab_active { background-color: $COL_HIGHLIGHT_RED; } + .tab_admin { background-color: $COL_HIGHLIGHT_BLUE; } .tab_split { flex: auto; diff --git a/www/data/dynamic/.gitignore b/www/data/dynamic/.gitignore new file mode 100644 index 0000000..d32047b --- /dev/null +++ b/www/data/dynamic/.gitignore @@ -0,0 +1,4 @@ +* +!.gitignore +!.gitkeep +!.htaccess \ No newline at end of file diff --git a/www/data/dynamic/.gitkeep b/www/data/dynamic/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/www/data/dynamic/.htaccess b/www/data/dynamic/.htaccess new file mode 100644 index 0000000..14249c5 --- /dev/null +++ b/www/data/dynamic/.htaccess @@ -0,0 +1 @@ +Deny from all \ No newline at end of file diff --git a/www/data/images/program_thumbnails/AlephNote.png b/www/data/images/program_img/AlephNote.png similarity index 100% rename from www/data/images/program_thumbnails/AlephNote.png rename to www/data/images/program_img/AlephNote.png diff --git a/www/data/images/program_thumbnails/All_in_One.png b/www/data/images/program_img/All_in_One.png similarity index 100% rename from www/data/images/program_thumbnails/All_in_One.png rename to www/data/images/program_img/All_in_One.png diff --git a/www/data/images/program_thumbnails/Beepster.png b/www/data/images/program_img/Beepster.png similarity index 100% rename from www/data/images/program_thumbnails/Beepster.png rename to www/data/images/program_img/Beepster.png diff --git a/www/data/images/program_thumbnails/BefunUtils.png b/www/data/images/program_img/BefunUtils.png similarity index 100% rename from www/data/images/program_thumbnails/BefunUtils.png rename to www/data/images/program_img/BefunUtils.png diff --git a/www/data/images/program_thumbnails/BefunZ.png b/www/data/images/program_img/BefunZ.png similarity index 100% rename from www/data/images/program_thumbnails/BefunZ.png rename to www/data/images/program_img/BefunZ.png diff --git a/www/data/images/program_thumbnails/Blitzer.png b/www/data/images/program_img/Blitzer.png similarity index 100% rename from www/data/images/program_thumbnails/Blitzer.png rename to www/data/images/program_img/Blitzer.png diff --git a/www/data/images/program_thumbnails/BorderlineDefense.png b/www/data/images/program_img/BorderlineDefense.png similarity index 100% rename from www/data/images/program_thumbnails/BorderlineDefense.png rename to www/data/images/program_img/BorderlineDefense.png diff --git a/www/data/images/program_thumbnails/CannonConquest.png b/www/data/images/program_img/CannonConquest.png similarity index 100% rename from www/data/images/program_thumbnails/CannonConquest.png rename to www/data/images/program_img/CannonConquest.png diff --git a/www/data/images/program_thumbnails/CrystalGrid.png b/www/data/images/program_img/CrystalGrid.png similarity index 100% rename from www/data/images/program_thumbnails/CrystalGrid.png rename to www/data/images/program_img/CrystalGrid.png diff --git a/www/data/images/program_thumbnails/DLF.png b/www/data/images/program_img/DLF.png similarity index 100% rename from www/data/images/program_thumbnails/DLF.png rename to www/data/images/program_img/DLF.png diff --git a/www/data/images/program_thumbnails/Deal_or_no_Deal.png b/www/data/images/program_img/Deal_or_no_Deal.png similarity index 100% rename from www/data/images/program_thumbnails/Deal_or_no_Deal.png rename to www/data/images/program_img/Deal_or_no_Deal.png diff --git a/www/data/images/program_thumbnails/ExtendedGitGraph.png b/www/data/images/program_img/ExtendedGitGraph.png similarity index 100% rename from www/data/images/program_thumbnails/ExtendedGitGraph.png rename to www/data/images/program_img/ExtendedGitGraph.png diff --git a/www/data/images/program_thumbnails/Graveyard_of_Numbers.png b/www/data/images/program_img/Graveyard_of_Numbers.png similarity index 100% rename from www/data/images/program_thumbnails/Graveyard_of_Numbers.png rename to www/data/images/program_img/Graveyard_of_Numbers.png diff --git a/www/data/images/program_thumbnails/H2O.png b/www/data/images/program_img/H2O.png similarity index 100% rename from www/data/images/program_thumbnails/H2O.png rename to www/data/images/program_img/H2O.png diff --git a/www/data/images/program_thumbnails/HexSolver.png b/www/data/images/program_img/HexSolver.png similarity index 100% rename from www/data/images/program_thumbnails/HexSolver.png rename to www/data/images/program_img/HexSolver.png diff --git a/www/data/images/program_thumbnails/InfinityTournament.png b/www/data/images/program_img/InfinityTournament.png similarity index 100% rename from www/data/images/program_thumbnails/InfinityTournament.png rename to www/data/images/program_img/InfinityTournament.png diff --git a/www/data/images/program_thumbnails/KeygenDancer.png b/www/data/images/program_img/KeygenDancer.png similarity index 100% rename from www/data/images/program_thumbnails/KeygenDancer.png rename to www/data/images/program_img/KeygenDancer.png diff --git a/www/data/images/program_thumbnails/LanControl.png b/www/data/images/program_img/LanControl.png similarity index 100% rename from www/data/images/program_thumbnails/LanControl.png rename to www/data/images/program_img/LanControl.png diff --git a/www/data/images/program_thumbnails/LightShow.png b/www/data/images/program_img/LightShow.png similarity index 100% rename from www/data/images/program_thumbnails/LightShow.png rename to www/data/images/program_img/LightShow.png diff --git a/www/data/images/program_thumbnails/Logistixx.png b/www/data/images/program_img/Logistixx.png similarity index 100% rename from www/data/images/program_thumbnails/Logistixx.png rename to www/data/images/program_img/Logistixx.png diff --git a/www/data/images/program_thumbnails/NedSchend.png b/www/data/images/program_img/NedSchend.png similarity index 100% rename from www/data/images/program_thumbnails/NedSchend.png rename to www/data/images/program_img/NedSchend.png diff --git a/www/data/images/program_thumbnails/Passpad.png b/www/data/images/program_img/Passpad.png similarity index 100% rename from www/data/images/program_thumbnails/Passpad.png rename to www/data/images/program_img/Passpad.png diff --git a/www/data/images/program_thumbnails/QuickHiddenFolderToggle.png b/www/data/images/program_img/QuickHiddenFolderToggle.png similarity index 100% rename from www/data/images/program_thumbnails/QuickHiddenFolderToggle.png rename to www/data/images/program_img/QuickHiddenFolderToggle.png diff --git a/www/data/images/program_thumbnails/SDL.png b/www/data/images/program_img/SDL.png similarity index 100% rename from www/data/images/program_thumbnails/SDL.png rename to www/data/images/program_img/SDL.png diff --git a/www/data/images/program_thumbnails/Serpilicum.png b/www/data/images/program_img/Serpilicum.png similarity index 100% rename from www/data/images/program_thumbnails/Serpilicum.png rename to www/data/images/program_img/Serpilicum.png diff --git a/www/data/images/program_thumbnails/SharkSim.png b/www/data/images/program_img/SharkSim.png similarity index 100% rename from www/data/images/program_thumbnails/SharkSim.png rename to www/data/images/program_img/SharkSim.png diff --git a/www/data/images/program_thumbnails/Sieb_des_Eratosthenes.png b/www/data/images/program_img/Sieb_des_Eratosthenes.png similarity index 100% rename from www/data/images/program_thumbnails/Sieb_des_Eratosthenes.png rename to www/data/images/program_img/Sieb_des_Eratosthenes.png diff --git a/www/data/images/program_thumbnails/SuperBitBros.png b/www/data/images/program_img/SuperBitBros.png similarity index 100% rename from www/data/images/program_thumbnails/SuperBitBros.png rename to www/data/images/program_img/SuperBitBros.png diff --git a/www/data/images/program_thumbnails/TicTacToe.png b/www/data/images/program_img/TicTacToe.png similarity index 100% rename from www/data/images/program_thumbnails/TicTacToe.png rename to www/data/images/program_img/TicTacToe.png diff --git a/www/data/images/program_thumbnails/Ziegenproblem.png b/www/data/images/program_img/Ziegenproblem.png similarity index 100% rename from www/data/images/program_thumbnails/Ziegenproblem.png rename to www/data/images/program_img/Ziegenproblem.png diff --git a/www/data/images/program_thumbnails/absCanvas.png b/www/data/images/program_img/absCanvas.png similarity index 100% rename from www/data/images/program_thumbnails/absCanvas.png rename to www/data/images/program_img/absCanvas.png diff --git a/www/data/images/program_thumbnails/exeExtract.png b/www/data/images/program_img/exeExtract.png similarity index 100% rename from www/data/images/program_thumbnails/exeExtract.png rename to www/data/images/program_img/exeExtract.png diff --git a/www/data/images/program_thumbnails/jCircuits.png b/www/data/images/program_img/jCircuits.png similarity index 100% rename from www/data/images/program_thumbnails/jCircuits.png rename to www/data/images/program_img/jCircuits.png diff --git a/www/data/images/program_thumbnails/jClipCorn.png b/www/data/images/program_img/jClipCorn.png similarity index 100% rename from www/data/images/program_thumbnails/jClipCorn.png rename to www/data/images/program_img/jClipCorn.png diff --git a/www/data/images/program_thumbnails/jQCCounter.png b/www/data/images/program_img/jQCCounter.png similarity index 100% rename from www/data/images/program_thumbnails/jQCCounter.png rename to www/data/images/program_img/jQCCounter.png diff --git a/www/fragments/header.php b/www/fragments/header.php index 29f6b6a..14de5cf 100644 --- a/www/fragments/header.php +++ b/www/fragments/header.php @@ -8,7 +8,7 @@ Project Euler Blog Programs - Admin + Admin About
{Logout} diff --git a/www/fragments/panel_programs.php b/www/fragments/panel_programs.php index 0806088..c0b15ce 100644 --- a/www/fragments/panel_programs.php +++ b/www/fragments/panel_programs.php @@ -19,7 +19,7 @@ echo '' . "\n"; echo '
' . "\n"; - echo ' Thumbnail '  . $prog['name'] . ' ' . "\n"; + echo ' Thumbnail '  . $prog['name'] . ' ' . "\n"; echo '
' . "\n"; echo '
' . "\n"; echo htmlspecialchars($prog['name']) . "\n"; diff --git a/www/index.php b/www/index.php index c2078c0..6e86fa1 100644 --- a/www/index.php +++ b/www/index.php @@ -37,8 +37,9 @@ $URL_RULES = [ 'url' => ['api', 'statsping'], 'target' => 'pages/api_stats.php', 'options' => [ 'Name' => '%GET%', 'ClientID' => '%GET%', 'Version' => '%GET%', 'ProviderStr' => '%GET%', 'ProviderID' => '%GET%', 'NoteCount' => '%GET%', ], ], [ 'url' => ['admin'], 'target' => 'pages/admin.php', 'options' => [ '_opt' => 'password'], ], - + [ 'url' => ['admin', 'cmd', '?{cmd}'], 'target' => 'pages/admin_cmd.php', 'options' => [ '_opt' => 'password', 'cmd' => '%URL%'], ], [ 'url' => ['admin', 'egh', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => 'egh', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], + [ 'url' => ['su_ajax', '?{cmd}'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%URL%', 'secret' => '%GET%' ], ], [ 'url' => ['su_ajax'], 'target' => 'pages/su_ajax.php', 'options' => [ 'suffix' => '', 'cmd' => '%GET%', 'secret' => '%GET%' ], ], @@ -85,7 +86,7 @@ try { $parse = parse_url($requri); - $path = strtolower(isset($parse['path']) ? $parse['path'] : ''); + $path = isset($parse['path']) ? $parse['path'] : ''; $pathparts = preg_split('@/@', $path, NULL, PREG_SPLIT_NO_EMPTY); $partcount = count($pathparts); @@ -187,6 +188,5 @@ try { //TODO better gh widget //TODO remove db table prefixes //TODO euler insert+show 32bit | 64bit mode -//TODO optimize image sizes for display/download (? - auto?) //TODO send cache header (?) //TODO global uncached error logger -> send by mail diff --git a/www/internals/base.php b/www/internals/base.php index 97da76f..7b39e32 100644 --- a/www/internals/base.php +++ b/www/internals/base.php @@ -181,4 +181,111 @@ function isLoggedInByCookie() function clearLoginCookie() { setcookie("mikescher_auth", "", time()+30); +} + +/** + * easy image resize function + * @author http://www.nimrodstech.com/php-image-resize/ + * @param $file - file name to resize + * @param $string - The image data, as a string + * @param $width - new image width + * @param $height - new image height + * @param $proportional - keep image proportional, default is no + * @param $output - name of the new file (include path if needed) + * @param $quality - enter 1-100 (100 is best quality) default is 100 + * @return boolean|resource + */ +function smart_resize_image($file, $string = null, $width = 0, $height = 0, $proportional = false, $output = 'file', $quality = 100 +) { + + if ( $height <= 0 && $width <= 0 ) return false; + if ( $file === null && $string === null ) return false; + + # Setting defaults and meta + $info = $file !== null ? getimagesize($file) : getimagesizefromstring($string); + $image = ''; + $final_width = 0; + $final_height = 0; + list($width_old, $height_old) = $info; + $cropHeight = $cropWidth = 0; + + # Calculating proportionality + if ($proportional) { + if ($width == 0) $factor = $height/$height_old; + elseif ($height == 0) $factor = $width/$width_old; + else $factor = min( $width / $width_old, $height / $height_old ); + + $final_width = round( $width_old * $factor ); + $final_height = round( $height_old * $factor ); + } + else { + $final_width = ( $width <= 0 ) ? $width_old : $width; + $final_height = ( $height <= 0 ) ? $height_old : $height; + $widthX = $width_old / $width; + $heightX = $height_old / $height; + + $x = min($widthX, $heightX); + $cropWidth = ($width_old - $width * $x) / 2; + $cropHeight = ($height_old - $height * $x) / 2; + } + + # Loading image to memory according to type + switch ( $info[2] ) { + case IMAGETYPE_JPEG: $file !== null ? $image = imagecreatefromjpeg($file) : $image = imagecreatefromstring($string); break; + case IMAGETYPE_GIF: $file !== null ? $image = imagecreatefromgif($file) : $image = imagecreatefromstring($string); break; + case IMAGETYPE_PNG: $file !== null ? $image = imagecreatefrompng($file) : $image = imagecreatefromstring($string); break; + default: return false; + } + + + # This is the resizing/resampling/transparency-preserving magic + $image_resized = imagecreatetruecolor( $final_width, $final_height ); + if ( ($info[2] == IMAGETYPE_GIF) || ($info[2] == IMAGETYPE_PNG) ) { + $transparency = imagecolortransparent($image); + $palletsize = imagecolorstotal($image); + + if ($transparency >= 0 && $transparency < $palletsize) { + $transparent_color = imagecolorsforindex($image, $transparency); + $transparency = imagecolorallocate($image_resized, $transparent_color['red'], $transparent_color['green'], $transparent_color['blue']); + imagefill($image_resized, 0, 0, $transparency); + imagecolortransparent($image_resized, $transparency); + } + elseif ($info[2] == IMAGETYPE_PNG) { + imagealphablending($image_resized, false); + $color = imagecolorallocatealpha($image_resized, 0, 0, 0, 127); + imagefill($image_resized, 0, 0, $color); + imagesavealpha($image_resized, true); + } + } + imagecopyresampled($image_resized, $image, 0, 0, $cropWidth, $cropHeight, $final_width, $final_height, $width_old - 2 * $cropWidth, $height_old - 2 * $cropHeight); + + # Preparing a method of providing result + switch ( strtolower($output) ) { + case 'browser': + $mime = image_type_to_mime_type($info[2]); + header("Content-type: $mime"); + $output = NULL; + break; + case 'file': + $output = $file; + break; + case 'return': + return $image_resized; + break; + default: + break; + } + + # Writing image according to type to the output destination and image quality + switch ( $info[2] ) { + case IMAGETYPE_GIF: imagegif($image_resized, $output); break; + case IMAGETYPE_JPEG: imagejpeg($image_resized, $output, $quality); break; + case IMAGETYPE_PNG: + $quality = 9 - (int)((0.9*$quality)/10.0); + imagepng($image_resized, $output, $quality); + break; + default: return false; + } + + return true; } \ No newline at end of file diff --git a/www/internals/blog.php b/www/internals/blog.php index 6c8ea6c..1dbcca4 100644 --- a/www/internals/blog.php +++ b/www/internals/blog.php @@ -18,6 +18,8 @@ class Blog $d['canonical'] = "https://www.mikescher.com" . $d['url']; + $d['file_fragment'] = __DIR__ . '/../statics/blog/' . $d['fragment']; + return $d; } @@ -38,7 +40,40 @@ class Blog public static function getPostFragment($post) { - return file_get_contents( __DIR__ . '/../statics/blog/' . $post['fragment']); + return file_get_contents($post['file_fragment']); + } + + public static function checkConsistency() + { + $keys = []; + + foreach (self::listAll() as $post) + { + if (in_array($post['id'], $keys)) return ['result'=>'err', 'message' => 'Duplicate key ' . $post['id']]; + $keys []= $post['id']; + + if ($post['cat'] !== 'log' && $post['cat'] !== 'blog') return ['result'=>'err', 'message' => 'Unknown cat ' . $post['cat']]; + + if ($post['type'] === 'markdown') { + + if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']]; + + } else if ($post['type'] === 'plain') { + + if (!file_exists($post['file_fragment'])) return ['result'=>'err', 'message' => 'Fragment not found ' . $post['fragment']]; + + } else if ($post['type'] === 'euler') { + + // aok + + } else { + + return ['result'=>'err', 'message' => 'Unknown type ' . $post['type']]; + + } + } + + return ['result'=>'ok', 'message' => '']; } } diff --git a/www/internals/euler.php b/www/internals/euler.php index 38379f1..181b85d 100644 --- a/www/internals/euler.php +++ b/www/internals/euler.php @@ -67,5 +67,29 @@ class Euler return 4; } + + public static function checkConsistency() + { + $warn = null; + + $numbers = []; + $realname = []; + + foreach (self::listAll() as $ep) + { + if (in_array($ep['number'], $numbers)) return ['result'=>'err', 'message' => 'Duplicate number ' . $ep['number']]; + $numbers []= $ep['number']; + + if (in_array($ep['title'], $realname)) return ['result'=>'err', 'message' => 'Duplicate title ' . $ep['title']]; + $realname []= $ep['title']; + + if (!file_exists($ep['file_description'])) return ['result'=>'err', 'message' => 'file_description not found ' . $ep['file_description']]; + if (!file_exists($ep['file_code'])) return ['result'=>'err', 'message' => 'file_code not found ' . $ep['file_code']]; + if (!file_exists($ep['file_explanation'])) return ['result'=>'err', 'message' => 'file_explanation not found ' . $ep['file_explanation']]; + } + + if ($warn != null) return $warn; + return ['result'=>'ok', 'message' => '']; + } } diff --git a/www/internals/mikeschergitgraph.php b/www/internals/mikeschergitgraph.php index 02e74c5..35992e7 100644 --- a/www/internals/mikeschergitgraph.php +++ b/www/internals/mikeschergitgraph.php @@ -26,4 +26,26 @@ class MikescherGitGraph return $v; } + + public static function getPathRenderedData() + { + return __DIR__ . '/../dynamic/egh.html'; + } + + public static function includeRender() + { + if (file_exists(__DIR__ . '/../dynamic/egh.html')) + include __DIR__ . '/../dynamic/egh.html'; + } + + public static function checkConsistency() + { + $p = self::getPathRenderedData(); + + if (!file($p)) return ['result'=>'err', 'message' => 'Rendered data not found']; + + if (filemtime($p) < time()-(3*7*24*60*60)) return ['result'=>'warn', 'message' => 'Rendered data is older than 3 weeks']; + + return ['result'=>'ok', 'message' => '']; + } } \ No newline at end of file diff --git a/www/internals/programs.php b/www/internals/programs.php index 9454ade..92fe7f4 100644 --- a/www/internals/programs.php +++ b/www/internals/programs.php @@ -1,7 +1,11 @@ $urldata) + { + $type = $fulltype; + if (strpos($fulltype, '#') !== FALSE) $type=explode('#', $fulltype)[0]; + + $caption = '?'; + $css = '?'; + $svg = '?'; + $direct = false; + + if ($type === 'download') { $caption = 'Download'; $css = 'prgv_dl_download'; $svg = 'download'; } + if ($type === 'github') { $caption = 'Github'; $css = 'prgv_dl_github'; $svg = 'github'; } + if ($type === 'homepage') { $caption = 'Homepage'; $css = 'prgv_dl_homepage'; $svg = 'home'; } + if ($type === 'wiki') { $caption = 'Wiki'; $css = 'prgv_dl_wiki'; $svg = 'wiki'; } + if ($type === 'playstore') { $caption = 'Google Playstore'; $css = 'prgv_dl_playstore'; $svg = 'playstore'; } + if ($type === 'amazonappstore') { $caption = 'Amazon Appstore'; $css = 'prgv_dl_amznstore'; $svg = 'amazon'; } + if ($type === 'windowsstore') { $caption = 'Microsoft Store'; $css = 'prgv_dl_winstore'; $svg = 'windows'; } + if ($type === 'itunesstore') { $caption = 'App Store'; $css = 'prgv_dl_appstore'; $svg = 'apple'; } + if ($type === 'sourceforge') { $caption = 'Sourceforge'; $css = 'prgv_dl_sourceforge'; $svg = 'sourceforge'; } + if ($type === 'alternativeto') { $caption = 'AlternativeTo'; $css = 'prgv_dl_alternativeto'; $svg = 'alternativeto'; } + + if (is_array($urldata)) + { + $url = $urldata['url']; + if (isset($urldata['caption'])) $caption = $urldata['caption']; + if (isset($urldata['css'])) $css = $urldata['css']; + if (isset($urldata['svg'])) $svg = $urldata['svg']; + } + else + { + $url = $urldata; + } + + if ($url === 'direct') + { + $direct = true; + $url = Programs::getDirectDownloadURL($prog); + } + + $result []= + [ + 'type' => $type, + 'caption' => $caption, + 'svg' => $svg, + 'href' => $url, + 'css' => $css, + 'isdirect' => $direct, + ]; + } + + return $result; } public static function getLicenseUrl($license) { return self::LICENSES[$license]; } + + public static function getDirectDownloadURL($prog) + { + return '/data/binaries/'.$prog['internal_name'].'.zip'; + } + + public static function getDirectDownloadPath($prog) + { + return (__DIR__ . '/../data/binaries/'.$prog['internal_name'].'.zip'); + } + + public static function checkConsistency() + { + $warn = null; + + $intname = []; + $realname = []; + + foreach (self::listAll() as $prog) + { + if (in_array($prog['internal_name'], $intname)) return ['result'=>'err', 'message' => 'Duplicate internal_name ' . $prog['name']]; + $intname []= $prog['internal_name']; + + if ($prog['internal_name_alt'] !== null) + { + if (in_array($prog['internal_name_alt'], $intname)) return ['result'=>'err', 'message' => 'Duplicate internal_name ' . $prog['name']]; + $intname []= $prog['internal_name_alt']; + } + + if (in_array($prog['name'], $realname)) return ['result'=>'err', 'message' => 'Duplicate name ' . $prog['name']]; + $realname []= $prog['name']; + + if (strpos($prog['internal_name'], ' ') !== FALSE) return ['result'=>'err', 'message' => 'Internal name contains spaces ' . $prog['name']]; + + foreach (explode('|', $prog['ui_language']) as $lang) if (convertLanguageToFlag($lang) === null) return ['result'=>'err', 'message' => 'Unknown ui-lang ' . $prog['name']];; + + if (!in_array($prog['prog_language'], self::PROG_LANGS)) return ['result'=>'err', 'message' => 'Unknown prog-lang ' . $prog['name']]; + + if (strlen($prog['short_description'])> 128) $warn = ['result'=>'warn', 'message' => 'short_description too long ' . $prog['name']]; + + if ($prog['license'] !== null && !array_key_exists($prog['license'], self::LICENSES)) return ['result'=>'err', 'message' => 'Unknown license ' . $prog['name']]; + + $isdl = false; + foreach (self::getURLs($prog) as $xurl) + { + if (!in_array($xurl['type'], self::URL_ORDER)) return ['result'=>'err', 'message' => 'Unknown url ' . $xurl['type']]; + + if ($xurl['type']==='download' && $xurl['isdirect'] && !file_exists(self::getDirectDownloadPath($prog))) return ['result'=>'err', 'message' => 'Direct download not found ' . $prog['name']]; + + if ($xurl['type']==='download' || $xurl['type']==='playstore' || $xurl['type']==='itunesstore') $isdl = true; + } + + if (!$isdl) return ['result'=>'err', 'message' => 'No download link ' . $prog['name']]; + + if (!file_exists($prog['mainimage_path'])) return ['result'=>'err', 'message' => 'Image not found ' . $prog['name']]; + + if (!file_exists($prog['file_longdescription'])) return ['result'=>'err', 'message' => 'Description not found ' . $prog['name']]; + } + + if ($warn != null) return $warn; + return ['result'=>'ok', 'message' => '']; + } + + public static function checkThumbnails() + { + foreach (self::listAll() as $prog) + { + if (!file_exists($prog['preview_path'])) return ['result'=>'err', 'message' => 'Preview not found ' . $prog['name']]; + } + + return ['result'=>'ok', 'message' => '']; + } + + public static function createPreview($prog) + { + $src = $prog['mainimage_path']; + $dst = $prog['preview_path']; + + smart_resize_image($src , null, 250, 0, true, $dst, 100); + } } \ No newline at end of file diff --git a/www/pages/about.php b/www/pages/about.php index fbbe052..1973437 100644 --- a/www/pages/about.php +++ b/www/pages/about.php @@ -2,6 +2,7 @@ @@ -46,7 +47,7 @@ global $OPTIONS;
- +
diff --git a/www/pages/admin.php b/www/pages/admin.php index 3399339..1592472 100644 --- a/www/pages/admin.php +++ b/www/pages/admin.php @@ -4,13 +4,33 @@ require_once (__DIR__ . '/../internals/base.php'); require_once (__DIR__ . '/../internals/highscores.php'); require_once (__DIR__ . '/../internals/alephnoteStatistics.php'); +require_once (__DIR__ . '/../internals/blog.php'); +require_once (__DIR__ . '/../internals/euler.php'); +require_once (__DIR__ . '/../internals/highscores.php'); +require_once (__DIR__ . '/../internals/mikeschergitgraph.php'); +require_once (__DIR__ . '/../internals/programs.php'); Database::connect(); +$consistency_blog = Blog::checkConsistency(); +$consistency_prog = Programs::checkConsistency(); +$consistency_euler = Euler::checkConsistency(); +$consistency_egh = MikescherGitGraph::checkConsistency(); +$consistency_progimg = Programs::checkThumbnails(); + +?> +OK"; + else if ($c['result']==='warn') echo "".$c['message'].""; + else echo "".$c['message'].""; +} + ?> - Mikescher.com - About + Mikescher.com - Admin @@ -30,8 +50,8 @@ Database::connect(); -
-
Version
+
+
Version
Branch:
@@ -39,8 +59,28 @@ Database::connect();
Date:
Message:
+
-
+ + +
diff --git a/www/pages/admin_cmd.php b/www/pages/admin_cmd.php new file mode 100644 index 0000000..1a3c13a --- /dev/null +++ b/www/pages/admin_cmd.php @@ -0,0 +1,43 @@ +'; + echo ''; + echo ''; + echo ''; + echo 'Mikescher.com - AdminExec'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''; + + foreach (Programs::listAll() as $prog) + { + echo 'Create preview for ' . $prog['name'] . '
' . "\n"; + Programs::createPreview($prog); + } + echo 'Finished.' . '
' . "\n"; + + echo ''; + echo ''; + echo ''; + exit; +} + +if ($cmd === 'createBookThumbnails') +{ + //TODO + exit; +} + + +die('Wrong command.'); \ No newline at end of file diff --git a/www/pages/programs_list.php b/www/pages/programs_list.php index d38ac86..45d33d8 100644 --- a/www/pages/programs_list.php +++ b/www/pages/programs_list.php @@ -38,7 +38,7 @@ $allprograms = Programs::listAllNewestFirst($filter); echo ''; echo '
'; - echo ' Thumbnail '  . $prog['name'] . ''; + echo ' Thumbnail '  . $prog['name'] . ''; echo '
'; echo '
'; echo '
' . htmlspecialchars($prog['name']) . '
'; diff --git a/www/pages/programs_view.php b/www/pages/programs_view.php index 884fbb6..24c73c8 100644 --- a/www/pages/programs_view.php +++ b/www/pages/programs_view.php @@ -34,7 +34,7 @@ if ($prog === NULL) httpError(404, 'Program not found');


-
Thumbnail (<?php echo $prog['name'] ?>)
+
Thumbnail (<?php echo $prog['name'] ?>)
Name:
@@ -55,20 +55,14 @@ if ($prog === NULL) httpError(404, 'Program not found');
$url) + foreach (Programs::getURLs($prog) as $xurl) { - if ($type === 'download' && $url === 'direkt') $url = '/data/binaries/'.$prog['internal_name'].'.zip'; - - if ($type === 'download') echo 'Download'; - if ($type === 'github') echo 'Github'; - if ($type === 'homepage') echo 'Homepage'; - if ($type === 'wiki') echo 'Wiki'; - if ($type === 'playstore') echo 'Google Playstore'; - if ($type === 'amazonappstore') echo 'Amazon Appstore'; - if ($type === 'windowsstore') echo 'Microsoft Store'; - if ($type === 'itunesstore') echo 'App Store'; - if ($type === 'sourceforge') echo 'Sourceforge'; - if ($type === 'alternativeto') echo 'AlternativeTo'; + echo ''; + echo ''; + echo ''; + echo ''; + echo ''.$xurl['caption'].''; + echo ''; } ?>
diff --git a/www/statics/programs/__all.php b/www/statics/programs/__all.php index 4e16ae2..95eec4e 100644 --- a/www/statics/programs/__all.php +++ b/www/statics/programs/__all.php @@ -15,7 +15,7 @@ return 'license' => 'GPL-3.0', 'urls' => [ - 'download' => 'direkt', + 'download' => 'https://github.com/Mikescher/AbsCanvas/releases', 'github' => 'https://github.com/Mikescher/AbsCanvas', ], ], @@ -34,7 +34,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -52,7 +52,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -72,6 +72,12 @@ return [ 'github' => 'https://github.com/Mikescher/BefunUtils', 'wiki' => 'https://github.com/Mikescher/BefunUtils/wiki', + 'download#1' => ['caption'=>'BefunExec', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunExec/build/artifacts' ], + 'download#2' => ['caption'=>'BefunGen', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunGen/build/artifacts' ], + 'download#3' => ['caption'=>'BefunWrite', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunWrite/build/artifacts'], + 'download#4' => ['caption'=>'BefunRep', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunRep/build/artifacts' ], + 'download#5' => ['caption'=>'BefunRun', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunRun/build/artifacts' ], + 'download#6' => ['caption'=>'BefunDebug', 'url'=>'https://ci.appveyor.com/project/Mikescher/BefunDebug/build/artifacts'], ], ], @@ -89,7 +95,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -107,7 +113,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', 'homepage' => 'http://borderlinedefense.99k.org/', ], ], @@ -126,7 +132,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -144,7 +150,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -162,7 +168,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -198,7 +204,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -216,7 +222,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -253,7 +259,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -271,7 +277,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', 'sourceforge' => 'http://sourceforge.net/projects/jcircuits/', ], ], @@ -329,7 +335,7 @@ return 'license' => null, 'urls' => [ - //TODO url + 'download' => 'direct', ], ], @@ -347,7 +353,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -365,7 +371,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -383,7 +389,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -420,7 +426,7 @@ return 'license' => 'Unlicense', 'urls' => [ - 'download' => 'direkt', + 'download' => 'https://github.com/Mikescher/Serpilicum/releases', 'github' => 'https://github.com/Mikescher/Serpilicum', ], ], @@ -439,7 +445,8 @@ return 'license' => 'Unlicense', 'urls' => [ - 'github' => 'https://github.com/Mikescher/SharkSim', + 'github' => 'https://github.com/Mikescher/SharkSim', + 'download' => 'https://github.com/Mikescher/SharkSim/releases', ], ], @@ -457,7 +464,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -475,7 +482,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -493,7 +500,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'https://github.com/Mikescher/SuperBitBros/releases', 'github' => 'https://github.com/Mikescher/SuperBitBros', ], ], @@ -512,7 +519,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ], @@ -530,7 +537,7 @@ return 'license' => null, 'urls' => [ - 'download' => 'direkt', + 'download' => 'direct', ], ],