/**
  * Main constructor, executes login  check.
  */
 public function __construct()
 {
     parent::__construct();
     forceDisableRewriteEngine();
     $this->load->model('Admins');
     $this->parser->assign('Admins_model', $this->Admins);
     $this->_validateLogin();
     $this->_adminMenu();
 }
 public function __construct()
 {
     parent::__construct();
 }
Exemple #3
0
 private function sendTestEmail($email)
 {
     $this->load->library('email');
     $config = Abstract_common_controller::getConfigItem('application', 'email');
     $this->email->initialize($config);
     $from = Abstract_common_controller::getConfigItem('application', 'email_from');
     $from_name = Abstract_common_controller::getConfigItem('application', 'email_from_name');
     $this->email->from($from, $from_name);
     $this->email->to($email);
     $this->email->subject('Pokusný e-mail');
     $msg = '<div style="color: blue; background-color: white; padding: 4px; border: 1px solid black; border-radius: 4px">';
     $msg .= 'Toto je pokusná správa z konfigurátora nastavení.<br />Ak Vám prišla, znamená to, že máte v aplikácii nastavený e-mail správne.</div>';
     $this->email->message($msg);
     return $this->email->send();
 }
/**
 * Creates slider background image.
 * 
 * @param string $texture_file path to file with image placed in background.
 * @param integer $min_year minimum year in slider.
 * @param integer $max_year maximum year in slider.
 * @param string $bg_color background color value in hex notation.
 * @param string $number_color color value for number segments in hex notation.
 * @param integer $width image width.
 * @param integer $height image height.
 * @return string path to background image.
 */
function createSlidebBackgroundImage($texture_file, $min_year = 0, $max_year = 1000, $bg_color = '000000', $number_color = 'ffffff', $width = 20, $height = 400)
{
    $sha_hash = sha1($texture_file . '-' . $min_year . '-' . $max_year . '-' . $bg_color . '-' . $number_color . '-' . $width . '-' . $height);
    $path_to_cache = 'public/timeline/' . $sha_hash . '.png';
    $cache_valid = FALSE;
    if (file_exists($path_to_cache)) {
        $cache_valid = TRUE;
    }
    $image_bg = NULL;
    if ($texture_file !== '' || $texture_file !== NULL) {
        if (file_exists($texture_file)) {
            $my_cache_file_time = file_exists($path_to_cache) ? filemtime($path_to_cache) : 0;
            $texture_file_time = filemtime($texture_file);
            if ($texture_file_time > $my_cache_file_time) {
                $image_bg = getGD2ImageFromFile($texture_file);
                $cache_valid = FALSE;
            }
        } else {
            $cache_valid = FALSE;
        }
    }
    $base_url = trim(Abstract_common_controller::getBaseUrl(), '/\\');
    if ($cache_valid) {
        return $base_url . '/' . $path_to_cache;
    }
    $image = imagecreatetruecolor($width, $height);
    getRGBFromHexColor($bg_color, $bg_red, $bg_green, $bg_blue);
    $color_background = imagecolorallocate($image, $bg_red, $bg_green, $bg_blue);
    getRGBFromHexColor($number_color, $nm_red, $nm_green, $nm_blue);
    $color_number = imagecolorallocate($image, $nm_red, $nm_green, $nm_blue);
    if ($image_bg !== NULL) {
        $image_info = getimagesize($texture_file);
        $dest_x = $width / 2 - $image_info[0] / 2;
        $dest_y = $height / 2 - $image_info[1] / 2;
        imagecopy($image, $image_bg, $dest_x, $dest_y, 0, 0, $image_info[0], $image_info[1]);
    }
    $range = $max_year - $min_year;
    for ($i = $min_year; $i <= $max_year; $i++) {
        imagesetthickness($image, 3);
        if ($i % 1000 == 0) {
            $y_coord = getYCoordinate($i, $min_year, $max_year, $height);
            imageline($image, $width, $y_coord, 0, $y_coord, $color_number);
        } elseif ($i % 100 == 0) {
            $y_coord = getYCoordinate($i, $min_year, $max_year, $height);
            imageline($image, $width, $y_coord, $width / 3, $y_coord, $color_number);
        } elseif ($i % 50 == 0 && $range <= 1000) {
            $y_coord = getYCoordinate($i, $min_year, $max_year, $height);
            imageline($image, $width, $y_coord, $width / 2, $y_coord, $color_number);
        } elseif ($i % 10 == 0 && $range <= 500) {
            imagesetthickness($image, 2);
            $y_coord = getYCoordinate($i, $min_year, $max_year, $height);
            imageline($image, $width, $y_coord, $width / 5 * 3, $y_coord, $color_number);
        } elseif ($i % 2 == 0 && $range <= 50) {
            imagesetthickness($image, 2);
            $y_coord = getYCoordinate($i, $min_year, $max_year, $height);
            imageline($image, $width, $y_coord, $width / 5 * 4, $y_coord, $color_number);
        }
    }
    imagepng($image, $path_to_cache, 9);
    return $base_url . '/' . $path_to_cache;
}
/**
 * Creates thumbnail of image.
 * It does not create thumbnail if max width and height are NULL.
 * 
 * @param string $image path to image.
 * @param integer @max_width maximum width of thumbnail or NULL.
 * @param integer $max_height maximum height of thumbnail or NULL.
 * @return string path to thumbnail.
 */
function imageThumb($image, $max_width = NULL, $max_height = NULL)
{
    if (trim($image) == '') {
        return '';
    }
    $path_to_image = $image[0] == '/' || $image[0] == '\\' ? substr($image, 1) : $image;
    if (!file_exists($path_to_image)) {
        return '';
    }
    $CI =& get_instance();
    $base_url = Abstract_common_controller::getBaseUrl();
    $original_full_path = $base_url . ($path_to_image[0] == '/' ? substr($path_to_image, 1) : $path_to_image);
    if (is_null($max_width) && is_null($max_height)) {
        return $original_full_path;
    }
    $path_info = pathinfo($path_to_image);
    $cache_dir = $path_info['dirname'];
    $cache_dir = substr($cache_dir, -1) == '/' ? $cache_dir . 'cache' : $cache_dir . '/cache';
    $new_image_name = $path_info['filename'] . '_w' . (is_null($max_width) ? 'NULL' : $max_width) . '_h' . (is_null($max_height) ? 'NULL' : $max_height) . '.' . $path_info['extension'];
    $new_image_path = $path_info['dirname'];
    $new_image_path = $cache_dir . '/' . $new_image_name;
    if (!file_exists($new_image_path) || filemtime($new_image_path) < filemtime($path_to_image)) {
        $config['image_library'] = 'gd2';
        $config['source_image'] = $path_to_image;
        $config['create_thumb'] = FALSE;
        $config['maintain_ratio'] = TRUE;
        $config['new_image'] = $new_image_path;
        if (!is_null($max_width)) {
            $config['width'] = $max_width;
        }
        if (!is_null($max_height)) {
            $config['height'] = $max_height;
        }
        $CI->load->library('image_lib');
        $CI->image_lib->initialize($config);
        $CI->image_lib->resize();
    }
    $new_image_basepath = $base_url . ($new_image_path[0] == '/' ? substr($new_image_path, 1) : $new_image_path);
    return $new_image_basepath;
}