diff --git a/opt/base.php b/opt/base.php index e8442a5..4499edf 100644 --- a/opt/base.php +++ b/opt/base.php @@ -599,7 +599,7 @@ function reset_org_id($db, $sub, $post_id) } // Set the css that we use -function set_css($mode, $settings) +function set_css($db, $mode, $sub, $settings) { $admin_css = array( @@ -619,6 +619,21 @@ function set_css($mode, $settings) return 'admin'; } elseif (in_array($mode, $mod_css)) { return 'mod'; + } + + $statement = $db->prepare("SELECT css + FROM subs + WHERE name = ?"); + $statement->bindParam(1, $sub); + $result = $statement->execute(); + + while ($row = $result->fetchArray(SQLITE3_NUM)) { + $css_sub = "{$row[0]}"; + } + + if ( (!empty($css_sub)) ) { + $css = filter($css_sub, 'alnum', 20); + // 20 chars should be enough to name a css } elseif ( (!empty($_POST['css'])) ) { $css = filter($_POST['css'], 'alnum', 20); // 20 chars should be enough to name a css