diff options
-rw-r--r-- | class/class.w.aff.php | 81 | ||||
-rw-r--r-- | class/class.w.app.php | 24 | ||||
-rw-r--r-- | class/class.w.config.php | 13 | ||||
-rw-r--r-- | fn/fn.php | 46 | ||||
-rw-r--r-- | public/w/index.php | 18 | ||||
-rw-r--r-- | public/w/menu.php | 1 |
6 files changed, 132 insertions, 51 deletions
diff --git a/class/class.w.aff.php b/class/class.w.aff.php index d47ca7a..0c7aa24 100644 --- a/class/class.w.aff.php +++ b/class/class.w.aff.php @@ -207,7 +207,7 @@ public function copy(Art $art, $list) } -public function head($title, $tool) +public function head($title, $tool, $color4) { ?> <head> @@ -216,6 +216,11 @@ public function head($title, $tool) <link rel="shortcut icon" href="../media/logo.png" type="image/x-icon"> <link href="/css/stylebase.css" rel="stylesheet" /> <link href="/css/style<?= $tool ?>.css" rel="stylesheet" /> + <style> + :root { + --color4: <?= $color4 ?>; + } + </style> <title><?= $title ?></title> <script src="../rsc/js/app.js"></script> </head> @@ -240,6 +245,23 @@ public function arthead(Art $art, $cssdir, $cssread = '', $edit = 0) } +public function noarthead($id, $cssdir, $cssread = '') +{ + ?> + <head> + <meta charset="utf8" /> + <meta name="description" content="This article does not exist yet." /> + <meta name="viewport" content="width=device-width" /> + <link rel="shortcut icon" href="../media/logo.png" type="image/x-icon"> + <link href="/css/stylebase.css" rel="stylesheet" /> + <link href="<?= $cssdir . $cssread ?>" rel="stylesheet" /> + <title>❓ <?= $id ?></title> + <script src="../rsc/js/app.js"></script> + </head> + <?php + +} + @@ -755,8 +777,9 @@ public function nav($app) $cssread = file_get_contents($cssfile); echo '<details>'; echo '<summary>Edit current CSS</summary>'; - echo '<form>'; - echo '<textarea id="cssarea">' . $cssread . '</textarea>'; + echo '<form action="./" method="post">'; + echo '<textarea name="editcss" id="cssarea">' . $cssread . '</textarea>'; + echo '<input type="hidden" name="action" value="editcss">'; echo '<input type="submit" value="edit">'; echo '</form>'; echo '</details>'; @@ -910,12 +933,64 @@ public function nav($app) </details> + <details> + <summary>Duplicate Table</summary> + <p>If you want to save versions of your work.</p> + + <form action="./" method="post"> + <label for="arttable">Select the table you want to copy.</label> + <select name="arttable" id="arttable" required> + + <?php + foreach ($arttables as $arttable) { + if ($arttable == $config->arttable()) { + echo '<option value="' . $arttable . '" " selected >' . $arttable . '</option>'; + } else { + echo '<option value="' . $arttable . '">' . $arttable . '</option>'; + } + } + ?> + </select> + <label for="tablename">Choose a name for the copy</label> + <input type="text" name="tablename" id="tablename" required> + <input type="hidden" name="actiondb" value="duplicatetable"> + <input type="submit" value="Duplicate"> + </form> + + </details> + </article> <?php } + public function admindisplay($color4) + { + ?> + <article> + <h2>Display</h2> + <details> + <summary>Update favicon</summary> + <form action="./" method="post" enctype="multipart/form-data"> + <input type="file" name="favicon" id="favicon"> + <input type="submit" value="update"> + </form> + </details> + <details> + <summary>Change desktop background color</summary> + <form action="./" method="post"> + <label for="color4">Background color</label> + <input type="color" name="color4" id="color4" value="<?= $color4 ?>"> + <input type="hidden" name="action" value="editconfig"> + <input type="submit" value="color my life"> + </form> + </details> + </article> + <?php + + } + diff --git a/class/class.w.app.php b/class/class.w.app.php index 29d3fef..82e2bef 100644 --- a/class/class.w.app.php +++ b/class/class.w.app.php @@ -409,11 +409,11 @@ class App `template` varchar(255) DEFAULT NULL )"; - $alter = "ALTER TABLE `'.$tablename.'` + $alter = "ALTER TABLE `$tablename` ADD PRIMARY KEY (`id`)"; $req = $this->bdd->query($table); - $req->closeCursor(); + $req = $this->bdd->query($alter); return 'tablecreated'; } else { @@ -423,6 +423,26 @@ class App + public function tableduplicate($dbname, $arttable, $tablename) + { + $arttable = strip_tags($arttable); + $tablename = str_clean($tablename); + if($this->tableexist($dbname, $arttable) && !$this->tableexist($dbname, $tablename)) { + $duplicate = " CREATE TABLE `$tablename` LIKE `$arttable`;"; + $alter = "ALTER TABLE `$tablename` ADD PRIMARY KEY (`id`);"; + $insert = "INSERT `$tablename` SELECT * FROM `$arttable`;"; + + + $req = $this->bdd->query($duplicate . $alter . $insert); + + return 'tableduplicated'; + } else { + return 'tablealreadyexist'; + } + } + + + // __________________________________________ M E D ________________________________________________________ diff --git a/class/class.w.config.php b/class/class.w.config.php index 839bf77..1d5f7b5 100644 --- a/class/class.w.config.php +++ b/class/class.w.config.php @@ -15,6 +15,7 @@ class Config private $invite; private $read; private $cssread; + private $color4; // _______________________________________ F U N _______________________________________ @@ -99,6 +100,11 @@ class Config return $this->cssread; } + public function color4() + { + return $this->color4; + } + // __________________________________________ S E T ______________________________________ @@ -158,6 +164,13 @@ class Config $this->cssread = strip_tags($cssread); } + public function setcolor4($color4) + { + if(strlen($color4) <= 8) { + $this->color4 = $color4; + } + } + } @@ -133,49 +133,11 @@ function contains($needle, $haystack) return strpos($haystack, $needle) !== false; } -// Retrieve JPEG width and height without downloading/reading entire image. -function getjpegsize($img_loc) { - $handle = fopen($img_loc, "rb") or die("Invalid file stream."); - $new_block = NULL; - if(!feof($handle)) { - $new_block = fread($handle, 32); - $i = 0; - if($new_block[$i]=="\xFF" && $new_block[$i+1]=="\xD8" && $new_block[$i+2]=="\xFF" && $new_block[$i+3]=="\xE0") { - $i += 4; - if($new_block[$i+2]=="\x4A" && $new_block[$i+3]=="\x46" && $new_block[$i+4]=="\x49" && $new_block[$i+5]=="\x46" && $new_block[$i+6]=="\x00") { - // Read block size and skip ahead to begin cycling through blocks in search of SOF marker - $block_size = unpack("H*", $new_block[$i] . $new_block[$i+1]); - $block_size = hexdec($block_size[1]); - while(!feof($handle)) { - $i += $block_size; - $new_block .= fread($handle, $block_size); - if($new_block[$i]=="\xFF") { - // New block detected, check for SOF marker - $sof_marker = array("\xC0", "\xC1", "\xC2", "\xC3", "\xC5", "\xC6", "\xC7", "\xC8", "\xC9", "\xCA", "\xCB", "\xCD", "\xCE", "\xCF"); - if(in_array($new_block[$i+1], $sof_marker)) { - // SOF marker detected. Width and height information is contained in bytes 4-7 after this byte. - $size_data = $new_block[$i+2] . $new_block[$i+3] . $new_block[$i+4] . $new_block[$i+5] . $new_block[$i+6] . $new_block[$i+7] . $new_block[$i+8]; - $unpacked = unpack("H*", $size_data); - $unpacked = $unpacked[1]; - $height = hexdec($unpacked[6] . $unpacked[7] . $unpacked[8] . $unpacked[9]); - $width = hexdec($unpacked[10] . $unpacked[11] . $unpacked[12] . $unpacked[13]); - return array($width, $height); - } else { - // Skip block marker and read block size - $i += 2; - $block_size = unpack("H*", $new_block[$i] . $new_block[$i+1]); - $block_size = hexdec($block_size[1]); - } - } else { - return FALSE; - } - } - } - } - } - return FALSE; -} +function str_clean(string $string) +{ + return str_replace(' ', '_', strtolower(strip_tags($string))); +} ?>
\ No newline at end of file diff --git a/public/w/index.php b/public/w/index.php index 5a3fe4e..1f3e967 100644 --- a/public/w/index.php +++ b/public/w/index.php @@ -82,11 +82,15 @@ if (isset($_POST['action'])) { header('Location: ./?aff=admin&message=' . $message); break; + case 'editcss': + file_put_contents($app::CSS_READ_DIR . $config->cssread(), $_POST['editcss']); + header('Location: ./?aff=admin'); + break; + case 'editconfig': $config->hydrate($_POST); $app->savejson($config->tojson()); header('Location: ./?aff=admin'); - break; @@ -244,6 +248,11 @@ if (isset($_POST['actiondb'])) { } break; + case 'duplicatetable': + $message = $app->tableduplicate($config->dbname(), $_POST['arttable'], $_POST['tablename']); + header('Location: ./?aff=admin&message=' . $message); + break; + } } @@ -261,13 +270,14 @@ if (isset($_GET['id'])) { } $aff->arthead($art, $app::CSS_READ_DIR, $config->cssread(), $_GET['edit']); } else { - $aff->head($_GET['id'], ''); + // $aff->head($_GET['id'], '', 'white'); + $aff->noarthead($_GET['id'], $app::CSS_READ_DIR, $config->cssread()); } } elseif (isset($_GET['aff'])) { - $aff->head($_GET['aff'], $_GET['aff']); + $aff->head($_GET['aff'], $_GET['aff'], $config->color4()); } else { - $aff->head('home', 'home'); + $aff->head('home', 'home', $config->color4()); } diff --git a/public/w/menu.php b/public/w/menu.php index 58cc93e..423ef08 100644 --- a/public/w/menu.php +++ b/public/w/menu.php @@ -16,6 +16,7 @@ if ($app->session() >= $app::EDITOR) { $status = "Not Connected"; } $aff->admintable($config, $status, $app->tablelist($config->dbname())); + $aff->admindisplay($config->color4()); echo '</section>'; } elseif ($_GET['aff'] == 'media') { |