Esempio n. 1
0
$im = imagecreatetruecolor(90, 20);
imagesavealpha($im, true);
$trans_colour = imagecolorallocatealpha($im, 0, 0, 0, 127);
imagefill($im, 0, 0, $trans_colour);
//We need now a Text-Color corresponding to our chosen style:
//Idea: get the theme-id, then the theme-style-file, open it and extract the corresponding hex color
//Dies passiert, indem das Theme-file mit einem text-leser geöffnet wird, die richtige zeile gesucht wird
//danach wird die farbe (ein hex-wert) in rgb umgewandelt
$theme = 0;
if (isset($_SESSION['user_id'])) {
    //Das vom Benutzer gewählte Theme abfragen
    $db = new DB();
    $theme = $db->getTheme($_SESSION['user_id'])[0]['theme'];
    $db->closeConnection();
}
$theme_name = getThemeName($theme);
$style_file = fopen("../styles/" . $theme_name . ".css", "r");
if ($style_file) {
    while (($line = fgets($style_file)) !== false) {
        if (strstr($line, '--button-text-color')) {
            //DIe richttige Farbe auslesen
            $text_color = strstr($line, '#');
            $col_array = hex2rgb($text_color);
            $fg = imagecolorallocate($im, $col_array[0], $col_array[1], $col_array[2]);
            //imagestring($im, 5, 7, 0,  $code, $fg);
            imagettftext($im, 15, 0, 2, 20, $fg, "font/captcha.ttf", $code);
            header("Cache-Control: no-cache, must-revalidate");
            header('Content-type: image/png');
            imagepng($im);
            imagedestroy($im);
        }
 /**
  * Add one or several JS files for front, checking if js files are overriden in theme/js/modules/ directory
  *
  * @see Controller::addJS()
  */
 public function addJS($js_uri)
 {
     require_once dirname(__FILE__) . '../../../../modules/designerpreview/defines.inc.php';
     if (!is_array($js_uri)) {
         $js_uri = array($js_uri);
     }
     foreach ($js_uri as $key => &$file) {
         if (!preg_match('/^http(s?):\\/\\//i', $file)) {
             $different = 0;
             $override_path = str_replace(__PS_BASE_URI__ . 'modules/', _PS_ROOT_DIR_ . '/themes/' . getThemeName() . '/js/modules/', $file, $different);
             if ($different && file_exists($override_path)) {
                 $file = str_replace(__PS_BASE_URI__ . 'modules/', __PS_BASE_URI__ . 'themes/' . getThemeName() . '/js/modules/', $file, $different);
             } else {
                 $override_path = str_replace(_THEME_JS_DIR_, _PS_ROOT_DIR_ . '/themes/' . getThemeName() . '/js/', $file, $different);
                 if ($different && file_exists($override_path)) {
                     $file = str_replace(_THEME_JS_DIR_, __PS_BASE_URI__ . 'themes/' . getThemeName() . '/js/', $file, $different);
                 }
             }
         }
     }
     return parent::addJS($js_uri);
 }
 public static function cccCss($css_files)
 {
     require_once dirname(__FILE__) . '../../../modules/designerpreview/defines.inc.php';
     //inits
     $css_files_by_media = array();
     $external_css_files = array();
     $compressed_css_files = array();
     $compressed_css_files_not_found = array();
     $compressed_css_files_infos = array();
     $protocol_link = Tools::getCurrentUrlProtocolPrefix();
     $theme_dir = getThemeDir();
     $theme_name = getThemeName();
     // group css files by media
     foreach ($css_files as $filename => $media) {
         if (!array_key_exists($media, $css_files_by_media)) {
             $css_files_by_media[$media] = array();
         }
         $infos = array();
         $infos['uri'] = $filename;
         $url_data = parse_url($filename);
         if (array_key_exists('host', $url_data)) {
             $external_css_files[$filename] = $media;
             continue;
         }
         $infos['path'] = _PS_ROOT_DIR_ . Tools::str_replace_once(__PS_BASE_URI__, '/', $url_data['path']);
         $css_files_by_media[$media]['files'][] = $infos;
         if (!array_key_exists('date', $css_files_by_media[$media])) {
             $css_files_by_media[$media]['date'] = 0;
         }
         $css_files_by_media[$media]['date'] = max(file_exists($infos['path']) ? filemtime($infos['path']) : 0, $css_files_by_media[$media]['date']);
         if (!array_key_exists($media, $compressed_css_files_infos)) {
             $compressed_css_files_infos[$media] = array('key' => '');
         }
         $compressed_css_files_infos[$media]['key'] .= $filename;
     }
     // get compressed css file infos
     foreach ($compressed_css_files_infos as $media => &$info) {
         $key = md5($info['key'] . $protocol_link);
         $filename = $theme_dir . 'cache/' . $key . '_' . $media . '.css';
         $info = array('key' => $key, 'date' => file_exists($filename) ? filemtime($filename) : 0);
     }
     // aggregate and compress css files content, write new caches files
     $import_url = array();
     foreach ($css_files_by_media as $media => $media_infos) {
         $cache_filename = $theme_dir . 'cache/' . $compressed_css_files_infos[$media]['key'] . '_' . $media . '.css';
         if ($media_infos['date'] > $compressed_css_files_infos[$media]['date']) {
             $compressed_css_files[$media] = '';
             foreach ($media_infos['files'] as $file_infos) {
                 if (file_exists($file_infos['path'])) {
                     $compressed_css_files[$media] .= Media::minifyCSS(file_get_contents($file_infos['path']), $file_infos['uri'], $import_url);
                 } else {
                     $compressed_css_files_not_found[] = $file_infos['path'];
                 }
             }
             if (!empty($compressed_css_files_not_found)) {
                 $content = '/* WARNING ! file(s) not found : "' . implode(',', $compressed_css_files_not_found) . '" */' . "\n" . $compressed_css_files[$media];
             } else {
                 $content = $compressed_css_files[$media];
             }
             $content = implode('', $import_url) . $content;
             file_put_contents($cache_filename, $content);
             chmod($cache_filename, 0777);
         }
         $compressed_css_files[$media] = $cache_filename;
     }
     // rebuild the original css_files array
     $css_files = array();
     foreach ($compressed_css_files as $media => $filename) {
         $url = str_replace($theme_dir, _THEMES_DIR_ . $theme_name . '/', $filename);
         $css_files[$protocol_link . Tools::getMediaServer($url) . $url] = $media;
     }
     return array_merge($external_css_files, $css_files);
 }
 /**
  * Installs new themes, either from a gzip or copy of the default.
  *
  * What it does:
  * - Puts themes in $boardurl/themes.
  * - Assumes the gzip has a root directory in it. (ie default.)
  * - Requires admin_forum.
  * - Accessed with ?action=admin;area=theme;sa=install.
  *
  * @uses ManageThemes template
  */
 public function action_install()
 {
     global $boardurl, $txt, $context, $settings, $modSettings;
     checkSession('request');
     require_once SUBSDIR . '/Themes.subs.php';
     require_once SUBSDIR . '/Package.subs.php';
     loadTemplate('ManageThemes');
     // Passed an ID, then the install is complete, lets redirect and show them
     if (isset($_GET['theme_id'])) {
         $_GET['theme_id'] = (int) $_GET['theme_id'];
         $context['sub_template'] = 'installed';
         $context['page_title'] = $txt['theme_installed'];
         $context['installed_theme'] = array('id' => $_GET['theme_id'], 'name' => getThemeName($_GET['theme_id']));
         return;
     }
     // How are we going to install this theme, from a dir, zip, copy of default?
     if (!empty($_FILES['theme_gz']) && (!isset($_FILES['theme_gz']['error']) || $_FILES['theme_gz']['error'] != 4) || !empty($_REQUEST['theme_gz'])) {
         $method = 'upload';
     } elseif (isset($_REQUEST['theme_dir']) && rtrim(realpath($_REQUEST['theme_dir']), '/\\') != realpath(BOARDDIR . '/themes') && file_exists($_REQUEST['theme_dir'])) {
         $method = 'path';
     } else {
         $method = 'copy';
     }
     // Copy the default theme?
     if (!empty($_REQUEST['copy']) && $method == 'copy') {
         // Hopefully the themes directory is writable, or we might have a problem.
         if (!is_writable(BOARDDIR . '/themes')) {
             fatal_lang_error('theme_install_write_error', 'critical');
         }
         // Make the new directory, standard characters only
         $theme_dir = BOARDDIR . '/themes/' . preg_replace('~[^A-Za-z0-9_\\- ]~', '', $_REQUEST['copy']);
         umask(0);
         mkdir($theme_dir, 0777);
         // Get some more time if we can
         @set_time_limit(600);
         if (function_exists('apache_reset_timeout')) {
             @apache_reset_timeout();
         }
         // Create the subdirectories for css, javascript and font files.
         mkdir($theme_dir . '/css', 0777);
         mkdir($theme_dir . '/scripts', 0777);
         mkdir($theme_dir . '/webfonts', 0777);
         // Copy over the default non-theme files.
         $to_copy = array('/index.php', '/index.template.php', '/scripts/theme.js');
         foreach ($to_copy as $file) {
             copy($settings['default_theme_dir'] . $file, $theme_dir . $file);
             @chmod($theme_dir . $file, 0777);
         }
         // And now the entire css, images and webfonts directories!
         copytree($settings['default_theme_dir'] . '/css', $theme_dir . '/css');
         copytree($settings['default_theme_dir'] . '/images', $theme_dir . '/images');
         copytree($settings['default_theme_dir'] . '/webfonts', $theme_dir . '/webfonts');
         package_flush_cache();
         $theme_name = $_REQUEST['copy'];
         $images_url = $boardurl . '/themes/' . basename($theme_dir) . '/images';
         $theme_dir = realpath($theme_dir);
         // Lets get some data for the new theme (default theme (1), default settings (0)).
         $theme_values = loadThemeOptionsInto(1, 0, array(), array('theme_templates', 'theme_layers'));
         // Lets add a theme_info.xml to this theme.
         write_theme_info($_REQUEST['copy'], $modSettings['elkVersion'], $theme_dir, $theme_values);
     } elseif (isset($_REQUEST['theme_dir']) && $method == 'path') {
         if (!is_dir($_REQUEST['theme_dir']) || !file_exists($_REQUEST['theme_dir'] . '/theme_info.xml')) {
             fatal_lang_error('theme_install_error', false);
         }
         $theme_name = basename($_REQUEST['theme_dir']);
         $theme_dir = $_REQUEST['theme_dir'];
     } elseif ($method == 'upload') {
         // Hopefully the themes directory is writable, or we might have a problem.
         if (!is_writable(BOARDDIR . '/themes')) {
             fatal_lang_error('theme_install_write_error', 'critical');
         }
         // This happens when the admin session is gone and the user has to login again
         if (empty($_FILES['theme_gz']) && empty($_REQUEST['theme_gz'])) {
             redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
         }
         // Set the default settings...
         $theme_name = strtok(basename(isset($_FILES['theme_gz']) ? $_FILES['theme_gz']['name'] : $_REQUEST['theme_gz']), '.');
         $theme_name = preg_replace(array('/\\s/', '/\\.[\\.]+/', '/[^\\w_\\.\\-]/'), array('_', '.', ''), $theme_name);
         $theme_dir = BOARDDIR . '/themes/' . $theme_name;
         if (isset($_FILES['theme_gz']) && is_uploaded_file($_FILES['theme_gz']['tmp_name']) && (ini_get('open_basedir') != '' || file_exists($_FILES['theme_gz']['tmp_name']))) {
             read_tgz_file($_FILES['theme_gz']['tmp_name'], BOARDDIR . '/themes/' . $theme_name, false, true);
         } elseif (isset($_REQUEST['theme_gz'])) {
             if (!isAuthorizedServer($_REQUEST['theme_gz'])) {
                 fatal_lang_error('not_valid_server');
             }
             read_tgz_file($_REQUEST['theme_gz'], BOARDDIR . '/themes/' . $theme_name, false, true);
         } else {
             redirectexit('action=admin;area=theme;sa=admin;' . $context['session_var'] . '=' . $context['session_id']);
         }
     } else {
         fatal_lang_error('theme_install_general', false);
     }
     // Something go wrong?
     if ($theme_dir != '' && basename($theme_dir) != 'themes') {
         // Defaults.
         $install_info = array('theme_url' => $boardurl . '/themes/' . basename($theme_dir), 'images_url' => isset($images_url) ? $images_url : $boardurl . '/themes/' . basename($theme_dir) . '/images', 'theme_dir' => $theme_dir, 'name' => $theme_name);
         $explicit_images = false;
         if (file_exists($theme_dir . '/theme_info.xml')) {
             $theme_info = file_get_contents($theme_dir . '/theme_info.xml');
             // Parse theme-info.xml into an Xml_Array.
             require_once SUBSDIR . '/XmlArray.class.php';
             $theme_info_xml = new Xml_Array($theme_info);
             // @todo Error message of some sort?
             if (!$theme_info_xml->exists('theme-info[0]')) {
                 return 'package_get_error_packageinfo_corrupt';
             }
             $theme_info_xml = $theme_info_xml->path('theme-info[0]');
             $theme_info_xml = $theme_info_xml->to_array();
             $xml_elements = array('name' => 'name', 'theme_layers' => 'layers', 'theme_templates' => 'templates', 'based_on' => 'based-on');
             foreach ($xml_elements as $var => $name) {
                 if (!empty($theme_info_xml[$name])) {
                     $install_info[$var] = $theme_info_xml[$name];
                 }
             }
             if (!empty($theme_info_xml['images'])) {
                 $install_info['images_url'] = $install_info['theme_url'] . '/' . $theme_info_xml['images'];
                 $explicit_images = true;
             }
             if (!empty($theme_info_xml['extra'])) {
                 $install_info += unserialize($theme_info_xml['extra']);
             }
         }
         if (isset($install_info['based_on'])) {
             if ($install_info['based_on'] == 'default') {
                 $install_info['theme_url'] = $settings['default_theme_url'];
                 $install_info['images_url'] = $settings['default_images_url'];
             } elseif ($install_info['based_on'] != '') {
                 $install_info['based_on'] = preg_replace('~[^A-Za-z0-9\\-_ ]~', '', $install_info['based_on']);
                 $temp = loadBasedOnTheme($install_info['based_on'], $explicit_images);
                 // @todo An error otherwise?
                 if (is_array($temp)) {
                     $install_info = $temp + $install_info;
                     if (empty($explicit_images) && !empty($install_info['base_theme_url'])) {
                         $install_info['theme_url'] = $install_info['base_theme_url'];
                     }
                 }
             }
             unset($install_info['based_on']);
         }
         // Find the newest id_theme.
         $id_theme = nextTheme();
         $inserts = array();
         foreach ($install_info as $var => $val) {
             $inserts[] = array($id_theme, $var, $val);
         }
         if (!empty($inserts)) {
             addTheme($inserts);
         }
         updateSettings(array('knownThemes' => strtr($modSettings['knownThemes'] . ',' . $id_theme, array(',,' => ','))));
     }
     redirectexit('action=admin;area=theme;sa=install;theme_id=' . $id_theme . ';' . $context['session_var'] . '=' . $context['session_id']);
 }
Esempio n. 5
0
        <p><b><?php 
echo $username;
?>
</b></p>
        <p>Und deine Darstellung:</p>
        <!-- Erster Buchstabe gross -->
        <p><b><?php 
echo ucfirst($theme);
?>
</b></p>
    </div>
    <div class="double-content-right">
        <h2>Darstellung wählen</h2>
        <?php 
//Den Spinner für das Theme printen
$themes = getThemeName("", true);
echo "<form method='post' name='form' action='content/changeTheme.php'>";
echo "<select name='theme'>";
$counter = 0;
foreach ($themes as $th) {
    echo "<option value=" . $counter;
    $db = new DB();
    if ($db->getTheme($id)[0]['theme'] == $counter) {
        echo " selected";
    }
    $db->closeConnection();
    //Erster Buchstabe des Theme-Namens gross
    echo ">" . ucfirst($th) . "</option>";
    $counter++;
}
echo "</select>";
Esempio n. 6
0
    // Alle Tabellen erzeugen, falls sie noch nicht vorhanden sind.
    $db->generateUserTable();
    $db->generateListTable();
    $db->generateWordTable();
    $db->closeConnection();
    $_SESSION['started'] = '1';
}
$theme = 0;
if (isset($_SESSION['user_id'])) {
    //Das vom Benutzer gewählte Theme abfragen
    $db = new DB();
    $theme = $db->getTheme($_SESSION['user_id'])[0]['theme'];
    $db->closeConnection();
}
//Das korrekte Theme-Style-Sheet und das immer-geltende-Style-sheet laden
echo '<link rel="stylesheet" href="styles/' . getThemeName($theme) . '.css" />';
echo '<link rel="stylesheet" href="styles/style.css" />';
?>
<script src="scripts/jquery.js"></script>
<script src="scripts/customAlert.js"></script>
<script type="text/javascript">
    function getErrorMessage(errorParam) {
        // Gibt eine Fehler-Nachricht zum jeweiligen Parameter zurück
        var errorMessages = [];
        errorMessages[0] = 'Ein Fehler ist aufgetreten.',
                errorMessages[1] = 'Du musst alle Felder ausfüllen.',
                errorMessages[2] = 'Dein Passwort ist falsch.',
                errorMessages[3] = 'Dieser Benutzer existiert nicht.\nDu kannst nun einen neuen Benutzer anlegen.',
                errorMessages[4] = 'Du musst eingeloggt sein, um diese Funktion nützen zu können.',
                errorMessages[5] = 'Dieser Benutzer existiert bereits.',
                errorMessages[6] = 'Du kannst nur XLS- und XLSX-Dateien hochladen.',