Esempio n. 1
0
function setCharts()
{
    global $SUBS, $PARAM, $MSG;
    global $tbl_1d_charts, $tbl_1d_kino_charts, $tbl_1d_videodvd_charts, $tbl_1d_films, $tbl_1d_videodvd;
    global $MONTHS, $MONTHS2;
    // check chart length
    $query = "SELECT Length, Type\n\t\tFROM {$tbl_1d_charts}\n\t\tORDER BY ID = " . dbQuote($PARAM['PLACES']) . " DESC ";
    $result = runQuery($query, 'setCharts()', 'GET_CHART_LENGTH_AND_TYPE');
    if ($row = db_fetch_row($result)) {
        $max = $row[0];
        $type = $row[1];
    } else {
        adminMenu();
        return;
    }
    //iztriwane
    if ($PARAM['Delete'] == 1) {
        reset($PARAM);
        $Films = '0';
        while (list($k, $v) = each($PARAM)) {
            if (ereg('^c_([0-9]+)$', $k, $R)) {
                $Films .= ",{$R['1']}";
            }
        }
        //get chart type
        $query = "SELECT Type\n\t\t\tFROM {$tbl_1d_charts}\n\t\t\tWHERE ID = " . dbQuote($PARAM['PLACES']);
        $result = runQuery($query, 'setCharts()', 'GET_CHART_TYPE2');
        if ($row = db_fetch_row($result)) {
            $type = $row[0];
        } else {
            $SUBS['ERROR'] = $MSG[20008];
        }
        switch ($type) {
            case 'videodvd':
                $query = "DELETE FROM {$tbl_1d_videodvd_charts} WHERE ID IN ({$Films})";
                break;
            case 'kino':
                $query = "DELETE FROM {$tbl_1d_kino_charts} WHERE ID IN ({$Films})";
                break;
        }
        if ($Films == '0') {
            $SUBS['ERROR'] = $MSG[20008];
        }
        if ($SUBS['ERROR']) {
            $SUBS['ERROR'] = fileParse('_admin_error.htmlt');
        } else {
            runQuery($query, 'setCharts()', 'DEL_CHART_RECORDS');
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20030&WHEN=" . $PARAM['WEEK'] . "&WEEK=" . $PARAM['WEEK'] . "&WHERE=" . $PARAM['WHERE'] . "&PLACES=" . $PARAM['PLACES'];
            printPage('_admin_done.htmlt');
            return;
        }
    }
    //add chart record
    if ($PARAM['Add'] == 1) {
        $SUBS['ERROR'] = '';
        if ($PARAM['NO'] == '') {
            //poziciya w klasaciyata
            $SUBS['ERROR'] = $MSG[20097];
        }
        if ($SUBS['ERROR'] == '' && !is_numeric($PARAM['NO'])) {
            $SUBS['ERROR'] = $MSG[20099];
        }
        //poziciyata dali e cefira
        if ($SUBS['ERROR'] == '' && $PARAM['NO'] > $max) {
            $SUBS['ERROR'] = $MSG[20099];
        }
        //poziciyata dali e po-golyama ot poziciite w klasaciyata
        if ($SUBS['ERROR'] == '' && $PARAM['NO'] < 0) {
            $SUBS['ERROR'] = $MSG[20099];
        }
        //poziciyata dali e po-malka ot nula
        //tipa na filma
        switch ($PARAM['TYPE']) {
            case 'list':
                //list
                if ($SUBS['ERROR'] == '' && $PARAM['FILMS'] == 0) {
                    $SUBS['ERROR'] = $MSG[20026];
                }
                $film = $PARAM['FILMS'];
                break;
            case 'raw':
                //raw
                if ($SUBS['ERROR'] == '' && $PARAM['FILM'] == '') {
                    $SUBS['ERROR'] = $MSG[20027];
                }
                $film = $PARAM['FILM'];
                break;
            default:
                if ($SUBS['ERROR'] == '') {
                    $SUBS['ERROR'] = $MSG[20028];
                }
        }
        switch ($type) {
            case 'kino':
                if ($SUBS['ERROR'] == '' && $PARAM['WEEKS'] == '') {
                    $SUBS['ERROR'] = $MSG[20098];
                }
                //sedmici w klasaciyata
                if ($SUBS['ERROR'] == '' && !is_numeric($PARAM['WEEKS'])) {
                    $SUBS['ERROR'] = $MSG[20100];
                }
                //sedmicite dali sa cefira
                if ($SUBS['ERROR'] == '' && $PARAM['SCREENS'] == '') {
                    $SUBS['ERROR'] = $MSG[20101];
                }
                //ekrani na klasaciyata
                if ($SUBS['ERROR'] == '' && !is_numeric($PARAM['SCREENS'])) {
                    $SUBS['ERROR'] = $MSG[20102];
                }
                //ekranite dali sa cefira
                if ($SUBS['ERROR'] == '' && $PARAM['BO'] == '') {
                    $SUBS['ERROR'] = $MSG[20103];
                }
                //sedmichen prihod na klasaciyata
                /*if (($SUBS['ERROR'] =='' ) && (!is_numeric($PARAM['BO'])))
                		$SUBS['ERROR'] = $MSG[20104];	//sedmichen prihod dali sa cefira*/
                if ($SUBS['ERROR'] == '' && $PARAM['CBO'] == '') {
                    $SUBS['ERROR'] = $MSG[20105];
                }
                //obscht prihod na klasaciyata
                /*if (($SUBS['ERROR'] =='' ) && (!is_numeric($PARAM['CBO'])))
                		$SUBS['ERROR'] = $MSG[20106];	//obscht prihod dali sa cefira*/
                break;
            case 'videodvd':
                if ($SUBS['ERROR'] == '' && $PARAM['WEEKS'] == '') {
                    $SUBS['ERROR'] = $MSG[20098];
                }
                //sedmici w klasaciyata
                if ($SUBS['ERROR'] == '' && !is_numeric($PARAM['WEEKS'])) {
                    $SUBS['ERROR'] = $MSG[20100];
                }
                //sedmicite dali sa cefira
                break;
        }
        if ($SUBS['ERROR'] == '') {
            if ($PARAM['id'] == '') {
                switch ($type) {
                    case 'videodvd':
                        $query = "INSERT INTO {$tbl_1d_videodvd_charts} (\n\t\t\t\t\t\t\t\tChartID,\n\t\t\t\t\t\t\t\tNo,\n\t\t\t\t\t\t\t\tType,\n\t\t\t\t\t\t\t\tFilm,\n\t\t\t\t\t\t\t\tWeeks,\n\t\t\t\t\t\t\t\ttsWhen\n\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($film) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEK']) . " )";
                        break;
                    case 'kino':
                        $query = "INSERT INTO {$tbl_1d_kino_charts} (\n\t\t\t\t\t\t\t\tChartID,\n\t\t\t\t\t\t\t\tNo,\n\t\t\t\t\t\t\t\tType,\n\t\t\t\t\t\t\t\tFilm,\n\t\t\t\t\t\t\t\tBoxOffice,\n\t\t\t\t\t\t\t\tcumBoxOffice,\n\t\t\t\t\t\t\t\tWeeks,\n\t\t\t\t\t\t\t\tScreens,\n\t\t\t\t\t\t\t\ttsWhen\n\t\t\t\t\t\t\t\t) VALUES (\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($film) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['BO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['CBO']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['SCREENS']) . ",\n\t\t\t\t\t\t\t\t" . dbQuote($PARAM['WEEK']) . " )";
                        break;
                }
            } else {
                switch ($type) {
                    case 'videodvd':
                        $query = "UPDATE {$tbl_1d_videodvd_charts} SET\n\t\t\t\t\t\t\t\tChartID = " . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\tNo = " . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\tType = " . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\tFilm = " . dbQuote($film) . ",\n\t\t\t\t\t\t\t\tWeeks = " . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\ttsWhen = " . dbQuote($PARAM['WEEK']) . " \n\t\t\t\t\t\t\tWHERE ID = " . dbQuote($PARAM['id']);
                        break;
                    case 'kino':
                        $query = "UPDATE {$tbl_1d_kino_charts} SET\n\t\t\t\t\t\t\t\tChartID = " . dbQuote($PARAM['PLACES']) . ",\n\t\t\t\t\t\t\t\tNo = " . dbQuote($PARAM['NO']) . ",\n\t\t\t\t\t\t\t\tType = " . dbQuote($PARAM['TYPE']) . ",\n\t\t\t\t\t\t\t\tFilm = " . dbQuote($film) . ",\n\t\t\t\t\t\t\t\tBoxOffice = " . dbQuote($PARAM['BO']) . ",\n\t\t\t\t\t\t\t\tcumBoxOffice = " . dbQuote($PARAM['CBO']) . ",\n\t\t\t\t\t\t\t\tWeeks = " . dbQuote($PARAM['WEEKS']) . ",\n\t\t\t\t\t\t\t\tScreens = " . dbQuote($PARAM['SCREENS']) . ",\n\t\t\t\t\t\t\t\ttsWhen = " . dbQuote($PARAM['WEEK']) . " \n\t\t\t\t\t\t\tWHERE ID = " . dbQuote($PARAM['id']);
                        break;
                }
            }
            $result = runQuery($query, 'setCharts()', 'SAVE_CHART');
            $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20107&PLACES=" . $PARAM['PLACES'] . "&WHEN=" . $PARAM['WEEK'] . "&WEEK=" . $PARAM['WEEK'];
            printPage('_admin_done.htmlt');
            return;
        } else {
            $SUBS['ERROR'] = fileParse('_admin_error.htmlt');
        }
    }
    ////----[Mrasnika's] Edition 12.10.2002
    if ($PARAM['WHEN']) {
        $PARAM['Year1'] = date('Y', $PARAM['WHEN']);
        $PARAM['Month1'] = date('m', $PARAM['WHEN']);
        $PARAM['Day1'] = date('d', $PARAM['WHEN']);
    } else {
        if ($PARAM['Day1'] && $PARAM['Month1'] && $PARAM['Year1']) {
            $PARAM['WHEN'] = 1 + strToTime($PARAM['Day1'] . ' ' . $MONTHS2[$PARAM['Month1']] . ' ' . $PARAM['Year1']);
        } else {
            $PARAM['WHEN'] = getNextWeek();
        }
    }
    $SUBS['PREV'] = week($PARAM['WHEN']) - 518400;
    $SUBS['NEXT'] = week($PARAM['WHEN']) + 1026800;
    //show charts records
    switch ($type) {
        case 'kino':
            $query = "SELECT\t{$tbl_1d_kino_charts}.ID,\n\t\t\t\tChartID,\n\t\t\t\tNo,\n\t\t\t\tType,\n\t\t\t\tFilm,\n\t\t\t\tBoxOffice,\n\t\t\t\tcumBoxOffice,\n\t\t\t\tWeeks,\n\t\t\t\tScreens,\n\t\t\t\ttsWhen,\n\t\t\t\t\n\t\t\t\t{$tbl_1d_films}.Title,\n\t\t\t\t{$tbl_1d_films}.OriginalTitle\n\n\t\t\t\tFROM {$tbl_1d_kino_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_kino_charts}.Type = 'list'\n\t\t\t\t\t\tAND {$tbl_1d_films}.ID = {$tbl_1d_kino_charts}.Film\n\t\t\t\tWHERE {$tbl_1d_kino_charts}.ChartID = " . dbQuote($PARAM['PLACES']) . "\n\t\t\t\t\tAND {$tbl_1d_kino_charts}.tsWhen >= " . week($PARAM['WHEN']) . "\n\t\t\t\t\tAND {$tbl_1d_kino_charts}.tsWhen <= (" . week($PARAM['WHEN']) . "+604799)\n\t\t\t\tORDER BY {$tbl_1d_kino_charts}.No,\n\t\t\t\t\t{$tbl_1d_kino_charts}.BoxOffice";
            break;
        case 'videodvd':
            $query = "SELECT\t{$tbl_1d_videodvd_charts}.ID,\n\t\t\t\tChartID,\n\t\t\t\tNo,\n\t\t\t\tType,\n\t\t\t\tFilm,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\tWeeks,\n\t\t\t\ttsWhen,\n\t\t\t\t\n\t\t\t\t{$tbl_1d_films}.Title,\n\t\t\t\t{$tbl_1d_films}.OriginalTitle\n\n\t\t\t\tFROM {$tbl_1d_videodvd_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_videodvd_charts}.Type = 'list'\n\t\t\t\t\t\tAND {$tbl_1d_films}.ID = {$tbl_1d_videodvd_charts}.Film\n\t\t\t\tWHERE {$tbl_1d_videodvd_charts}.ChartID = " . dbQuote($PARAM['PLACES']) . "\n\t\t\t\t\tAND {$tbl_1d_videodvd_charts}.tsWhen >= " . week($PARAM['WHEN']) . "\n\t\t\t\t\tAND {$tbl_1d_videodvd_charts}.tsWhen <= (" . week($PARAM['WHEN']) . "+604799)\n\t\t\t\tORDER BY {$tbl_1d_videodvd_charts}.No ";
            break;
    }
    $result = runQuery($query, 'setCharts()', 'GET_CHART_RECORDS');
    while ($row = db_fetch_row($result)) {
        $SUBS['CHECK'] = $row[0];
        $SUBS['CHARTID'] = $row[1];
        $SUBS['NO2'] = sprintf("%02d", $row[2]);
        if ($row[3] == 'list') {
            if ($row[10]) {
                $SUBS['TITLE'] = htmlEncode($row[10]);
            } else {
                $SUBS['TITLE'] = htmlEncode($row[11]);
            }
            $SUBS['MOVIE'] = $SUBS['ACTION'] . "?cmd=insertfilm&ID={$row['4']}";
        } else {
            $SUBS['TITLE'] = htmlEncode($row[4]);
            $SUBS['MOVIE'] = "javascript:alert('{$MSG['20031']}')";
        }
        $SUBS['PRATI'] = $row[9];
        switch ($type) {
            case 'kino':
                $SUBS['BO2'] = $row[5];
                $SUBS['CBO2'] = $row[6];
                $SUBS['SCREENS2'] = $row[8];
                $SUBS['WEEKS2'] = $row[7];
                $SUBS['SHOWCHARTS'] .= fileParse('_admin_charts_row.htmlt');
                break;
            case 'videodvd':
                $SUBS['WEEKS2'] = $row[7];
                $SUBS['SHOWCHARTS'] .= fileParse('_admin_charts_row2.htmlt');
                break;
        }
        if ($PARAM['Add'] != 1 && $PARAM['id'] == $row[0]) {
            //load form
            $PARAM['PLACES'] = $row[1];
            $PARAM['TYPE'] = $row[3];
            if ($row[3] != 'list') {
                $PARAM['FILM'] = $row[4];
            } else {
                $PARAM['FILMS'] = htmlEncode($row[4]);
            }
            $PARAM['WEEK'] = $row[9];
            $PARAM['NO'] = $row[2];
            switch ($type) {
                default:
                    //kino
                    $PARAM['BO'] = $row[5];
                    $PARAM['CBO'] = $row[6];
                    $PARAM['WEEKS'] = $row[7];
                    $PARAM['SCREENS'] = $row[8];
            }
        }
    }
    //get charts
    $SUBS['CHARTS'] = $PARAM['PLACES'];
    $query = "SELECT ID, Title\n \t\tFROM {$tbl_1d_charts}";
    $result = runQuery($query, 'setCharts()', 'GET_CHARTS');
    while ($row = db_fetch_row($result)) {
        ////----[Mrasnika's] Edition 12.10.2002
        // if ($row[0] == $PARAM['chartid'])
        //	$SUBS['CHARTS'] .= "<OPTION value=\"$row[0]\" SELECTED>".htmlEncode($row[1]);
        //	else $SUBS['CHARTS'] .= "<OPTION value=\"$row[0]\">".htmlEncode($row[1]);
        if (!$s1) {
            //store default chart
            $s1 = $row[0];
            $s2 = $row[1];
        }
        if ($row[0] == $PARAM['PLACES']) {
            $SUBS['CHARTTITLE'] = htmlEncode($row[1]);
        }
        if ($row[0] == $PARAM['PLACES']) {
            $SUBS['PLACES'] .= "<OPTION value=\"{$row['0']}\" SELECTED>" . htmlEncode($row[1]);
        } else {
            $SUBS['PLACES'] .= "<OPTION value=\"{$row['0']}\">" . htmlEncode($row[1]);
        }
    }
    if (!$SUBS['CHARTTITLE']) {
        //no default chart
        $SUBS['CHARTS'] = $s1;
        $SUBS['CHARTTITLE'] = htmlEncode($s2);
    }
    //get oldest week
    switch ($type) {
        default:
            //kino
            $query = "SELECT\tmin({$tbl_1d_kino_charts}.tsWhen)\n\t\t\t\tFROM\t{$tbl_1d_kino_charts}\n\t\t\t\tGROUP BY {$tbl_1d_kino_charts}.ChartID\n\t\t\t\tORDER BY {$tbl_1d_kino_charts}.ChartID=" . dbQuote($PARAM['PLACES']) . " DESC";
            $result = runQuery($query, 'setCharts()', 'GET_OLDEST_WEEK_KINO');
            if ($row = db_fetch_row($result)) {
                $span = $row[0];
            }
            break;
        case 'videodvd':
            //videodvd
            $query = "SELECT\tmin({$tbl_1d_videodvd_charts}.tsWhen)\n\t\t\t\tFROM\t{$tbl_1d_videodvd_charts}";
            $result = runQuery($query, 'setCharts()', 'GET_OLDEST_WEEK_VIDEO');
            if ($row = db_fetch_row($result)) {
                $span = $row[0];
            }
            break;
    }
    if (!$span) {
        $span = getNextWeek();
    }
    ////----[Mrasnika's] Edition 12.10.2002
    // $SUBS['WEEK'] = getWeeks($PARAM['WEEK']);
    // $SUBS['WHEN'] = getWeeks($PARAM['WHEN']);
    //compatibility
    if (!$PARAM['WHEN']) {
        //no date applied
        if (!$PARAM['Day1'] || !$PARAM['Month1'] || !$PARAM['Year1']) {
            $PARAM['WHEN'] = getNextWeek();
            $PARAM['Year1'] = date('Y', $PARAM['WHEN']);
            $PARAM['Month1'] = date('m', $PARAM['WHEN']);
            $PARAM['Day1'] = date('d', $PARAM['WHEN']);
        } else {
            $PARAM['WHEN'] = 1 + strToTime($PARAM['Day1'] . ' ' . $MONTHS2[$PARAM['Month1']] . ' ' . $PARAM['Year1']);
        }
    } else {
        //load date form
        $PARAM['Year1'] = date('Y', $PARAM['WHEN']);
        $PARAM['Month1'] = date('m', $PARAM['WHEN']);
        $PARAM['Day1'] = date('d', $PARAM['WHEN']);
    }
    if ($span > $PARAM['WHEN']) {
        //ima data, no e po-malka ot naj-starata klasaciya
        $SUBS['COMMAND'] = $PARAM['cmd'] . "&WHEN={$span}&PLACES=" . $PARAM['PLACES'];
        printPage('_admin_done.htmlt');
        return;
    }
    $Year2 = 1 + date('Y', max($PARAM['WHEN'], time()));
    $Year1 = date('Y', $span);
    for ($i = $Year1; $i <= $Year2; $i++) {
        if ($i == $PARAM['Year1']) {
            $SUBS['YEAR1'] .= "<OPTION value=\"{$i}\" selected>{$i}";
        } else {
            $SUBS['YEAR1'] .= "<OPTION value=\"{$i}\">{$i}";
        }
    }
    for ($i = 1; $i <= 12; $i++) {
        if ($i == $PARAM['Month1']) {
            $SUBS['MONTH1'] .= "<OPTION value=\"{$i}\" selected>" . $MONTHS[$i];
        } else {
            $SUBS['MONTH1'] .= "<OPTION value=\"{$i}\">" . $MONTHS[$i];
        }
    }
    for ($i = 1; $i <= 31; $i++) {
        if ($i == $PARAM['Day1']) {
            $SUBS['DAY1'] .= "<OPTION value=\"{$i}\" selected>" . sprintf('%02d', $i);
        } else {
            $SUBS['DAY1'] .= "<OPTION value=\"{$i}\">" . sprintf('%02d', $i);
        }
    }
    $SUBS['WEEK'] = $PARAM['WHEN'];
    $SUBS['DISPLAYWEEK'] = displayWeek($SUBS['WEEK']);
    //get films
    switch ($type) {
        case 'kino':
            $query = "SELECT\t{$tbl_1d_films}.ID,\n\t\t\t\tTitle,\n\t\t\t\tOriginalTitle\n\t\t\tFROM {$tbl_1d_films}\n\t\t\tLEFT JOIN {$tbl_1d_videodvd}\n\t\t\t\tON {$tbl_1d_videodvd}.FilmID = {$tbl_1d_films}.ID\n\t\t\tWHERE\t{$tbl_1d_videodvd}.ID IS NULL\n\t\t\tGROUP BY {$tbl_1d_films}.ID\n\t\t\tORDER BY OriginalTitle !='' DESC, Title='' DESC";
            break;
        case 'videodvd':
            $query = "SELECT\t{$tbl_1d_films}.ID, Title\n\t\t\tFROM {$tbl_1d_films}\n\t\t\tLEFT JOIN {$tbl_1d_videodvd}\n\t\t\t\tON {$tbl_1d_videodvd}.FilmID = {$tbl_1d_films}.ID\n\t\t\tWHERE\t{$tbl_1d_videodvd}.ID IS NOT NULL\n\t\t\tGROUP BY {$tbl_1d_films}.ID\n\t\t\tORDER BY Title DESC";
            break;
    }
    $result = runQuery($query, 'setCharts()', 'GET_FILMS');
    while ($row = db_fetch_row($result)) {
        //fix titles
        if (!$row[1]) {
            $row[1] = $row[2];
        }
        if ($PARAM['FILMS'] == $row[0]) {
            ////----[Mrasnika's] Edition 12.10.2002
            // $SUBS['FILM'] .= "\n<option value=\"$row[0]\" selected>".htmlEncode("$row[1] $row[2] ");
            // else $SUBS['FILM'] .= "\n<option value=\"$row[0]\">".htmlEncode("$row[1] $row[2] ");
            $SUBS['FILM'] .= "\n<option value=\"{$row['0']}\" selected>" . htmlEncode($row[1]);
        } else {
            $SUBS['FILM'] .= "\n<option value=\"{$row['0']}\">" . htmlEncode($row[1]);
        }
    }
    // display
    $SUBS['TYPE' . strToUpper($PARAM['TYPE'])] = ' checked ';
    $SUBS['FILM2'] = htmlEncode($PARAM['FILM']);
    $SUBS['NO'] = htmlEncode($PARAM['NO']);
    switch ($type) {
        default:
            //kino
            $SUBS['WEEKS'] = htmlEncode($PARAM['WEEKS']);
            $SUBS['SCREENS'] = htmlEncode($PARAM['SCREENS']);
            $SUBS['BO'] = htmlEncode($PARAM['BO']);
            $SUBS['CBO'] = htmlEncode($PARAM['CBO']);
            $SUBS['DISPLAYCHART'] = fileParse("_admin_charts_kino.htmlt");
            break;
        case 'videodvd':
            //video & dvd
            $SUBS['WEEKS'] = htmlEncode($PARAM['WEEKS']);
            $SUBS['DISPLAYCHART'] = fileParse("_admin_charts_videodvd.htmlt");
            break;
    }
    $SUBS['ID'] = htmlEncode($PARAM['id']);
    if ($PARAM['err'] != '' && $SUBS['ERROR'] == '') {
        $SUBS['ERROR'] = $MSG[$PARAM['err']];
        $SUBS['ERROR'] = fileParse('_admin_error.htmlt');
    }
    printPage('_admin_charts.htmlt');
}
Esempio n. 2
0
function fixPicture($filename, $type, $id, $PICPARAM)
{
    global $tbl_1d_pictures;
    $OK = 0;
    $name = $type . "_" . time() . "_" . md5($PICPARAM[0] . $PICPARAM[1] . $filename);
    switch ($type) {
        //margins
        case 'dvd':
            $MARGINS['IMG_WIDTH'] = getAdmSetting('DVD_WIDTH');
            $MARGINS['IMG_HEIGHT'] = getAdmSetting('DVD_HEIGHT');
            break;
        case 'video':
            $MARGINS['IMG_WIDTH'] = getAdmSetting('VIDEO_WIDTH');
            $MARGINS['IMG_HEIGHT'] = getAdmSetting('VIDEO_HEIGHT');
            break;
        case 'thumb':
            $MARGINS['IMG_WIDTH'] = getAdmSetting('THUMB_WIDTH');
            $MARGINS['IMG_HEIGHT'] = getAdmSetting('THUMB_HEIGHT');
            break;
        case 'article':
            $MARGINS['IMG_WIDTH'] = getAdmSetting('ARTICLE_WIDTH');
            $MARGINS['IMG_HEIGHT'] = getAdmSetting('ARTICLE_HEIGHT');
            break;
        default:
            //CASE film
            $MARGINS['IMG_WIDTH'] = getAdmSetting('IMG_WIDTH');
            $MARGINS['IMG_HEIGHT'] = getAdmSetting('IMG_HEIGHT');
    }
    switch ($PICPARAM[2]) {
        case 3:
            $src = @ImageCreateFromPNG($filename);
        case 2:
            if ($PICPARAM[2] == 2) {
                $src = @ImageCreateFromJPEG($filename);
            }
            if ($PICPARAM[0] < $MARGINS['IMG_WIDTH']) {
                if ($PICPARAM[1] < $MARGINS['IMG_HEIGHT']) {
                    $OK = 1;
                } else {
                    $percent = $PICPARAM[1] / $MARGINS['IMG_HEIGHT'];
                }
            } else {
                if ($PICPARAM[1] < $MARGINS['IMG_HEIGHT']) {
                    $percent = $PICPARAM[0] / $MARGINS['IMG_WIDTH'];
                } else {
                    $img_per[0] = $PICPARAM[0] / $MARGINS['IMG_WIDTH'];
                    $img_per[1] = $PICPARAM[1] / $MARGINS['IMG_HEIGHT'];
                    $percent = max($img_per);
                }
            }
            $new = getAdmSetting('UPLOAD_DIR') . "{$name}.JPG";
            switch ($type) {
                case 'thumb':
                    $dst = @ImageCreateFromJPEG(getAdmSetting('TEMPLATES_DIR') . 'default.jpg');
                    $img_per[0] = $PICPARAM[0] / $MARGINS['IMG_WIDTH'];
                    $img_per[1] = $PICPARAM[1] / $MARGINS['IMG_HEIGHT'];
                    $percent = min($img_per);
                    $img_2[0] = $MARGINS['IMG_WIDTH'] * $percent;
                    $img_2[1] = $MARGINS['IMG_HEIGHT'] * $percent;
                    $img_cor[0] = ($PICPARAM[0] - $MARGINS['IMG_WIDTH'] * $percent) / 2;
                    $img_cor[1] = ($PICPARAM[1] - $MARGINS['IMG_HEIGHT'] * $percent) / 2;
                    ImageCopyResampled($dst, $src, getAdmSetting('THUMB_LEFT'), getAdmSetting('THUMB_TOP'), $img_cor[0], $img_cor[1], $MARGINS['IMG_WIDTH'], $MARGINS['IMG_HEIGHT'], $img_2[0], $img_2[1]);
                    ImageJPEG($dst, $new);
                    $PICPARAM = getImageSize($new);
                    break;
                case 'video':
                case 'dvd':
                    $dst = @ImageCreateTrueColor($MARGINS['IMG_WIDTH'], $MARGINS['IMG_HEIGHT']);
                    $img_per[0] = $PICPARAM[0] / $MARGINS['IMG_WIDTH'];
                    $img_per[1] = $PICPARAM[1] / $MARGINS['IMG_HEIGHT'];
                    $percent = min($img_per);
                    $img_2[0] = $MARGINS['IMG_WIDTH'] * $percent;
                    $img_2[1] = $MARGINS['IMG_HEIGHT'] * $percent;
                    $img_cor[0] = ($PICPARAM[0] - $MARGINS['IMG_WIDTH'] * $percent) / 2;
                    $img_cor[1] = ($PICPARAM[1] - $MARGINS['IMG_HEIGHT'] * $percent) / 2;
                    ImageCopyResampled($dst, $src, 0, 0, $img_cor[0], $img_cor[1], $MARGINS['IMG_WIDTH'], $MARGINS['IMG_HEIGHT'], $img_2[0], $img_2[1]);
                    ImageJPEG($dst, $new);
                    $PICPARAM = getImageSize($new);
                    break;
                default:
                    if ($OK == 1) {
                        //no resize
                        @ImageJPEG($src, $new);
                    } else {
                        $img_2[0] = round($PICPARAM[0] / $percent);
                        $img_2[1] = round($PICPARAM[1] / $percent);
                        $dst = @ImageCreateTrueColor($img_2[0], $img_2[1]);
                        ImageCopyResampled($dst, $src, 0, 0, 0, 0, $img_2[0], $img_2[1], $PICPARAM[0], $PICPARAM[1]);
                        //src w,h
                        ImageJPEG($dst, $new);
                        $PICPARAM[0] = $img_2[0];
                        $PICPARAM[1] = $img_2[1];
                    }
                    break;
            }
            $query = "INSERT INTO {$tbl_1d_pictures}\n\t\t\t\t\t(URL, RefID, RefType, Width, Height) VALUES\n\t\t\t\t\t(" . dbQuote("{$name}.JPG") . ", {$id}, " . dbQuote($type) . ", {$PICPARAM['0']}, {$PICPARAM['1']})";
            $result = runQuery($query, 'fixPicture()', 'INSERT_PIC');
            $id = mysql_insert_id();
            switch ($type) {
                //thumbnails
                case 'article':
                case 'film':
                    fixPicture($new, 'thumb', $id, $PICPARAM);
                    break;
            }
            return 1;
            break;
        default:
            return 0;
    }
}
Esempio n. 3
0
<?php

define("NO_STAT", 1);
require_once dirname(__FILE__) . "/../configuration.php";
//$heConfig_encoding=array('html'=>"Windows-1251",'mysql'=>"cp1251");
$heConfig_encoding = array('html' => "UTF-8", 'mysql' => "utf8");
require_once dirname(__FILE__) . "/../includes/begin.php";
//require_once(dirname(__FILE__)."/../includes/mime_mail.php");
//require_once(dirname(__FILE__)."/../includes/addons/heCaptcha.php");
componentStart();
$lat = floatval(mosGetParam($_GET, "lat", 0));
$long = floatval(mosGetParam($_GET, "long", 0));
$cityid = intval(mosGetParam($_GET, "cityid", 0));
if ($cityid > 0) {
    $query = "SELECT id, 0 as dist\r\n\t\t\tFROM #__city\r\n\t\t\tWHERE id=" . dbQuote($cityid) . "\r\n\t\t\tLIMIT 1";
    $rdDb->setQuery($query);
    $o = $_cache['query']->call("rdDb->loadObjectList", "", "", $query);
} else {
    $query = "SELECT cityid, (ABS(`long`-{$long})+ABS(`lat`-{$lat})) as dist\r\n\t\t\tFROM #__city_ll\r\n\t\t\tORDER BY dist ASC\r\n\t\t\tLIMIT 1";
    $rdDb->setQuery($query);
    $o = $_cache['query']->call("rdDb->loadObjectList", "", "", $query);
}
$o = reset($o);
if ($o->cityid && $o->dist < 1) {
    $city = heGeo::getCity($o->cityid, 1);
    echo "<p>Ваш город ";
    echo "<strong>";
    echo $city->params['small_name_imen'];
    echo "</strong>?";
    echo "</p>";
    echo "<div id=\"mn_city_popup_buttons\">";
Esempio n. 4
0
        $SUBS['CINEMA'] .= "\n<option value=\"{$row['0']}\">" . htmlEncode($row[2]) . " - " . htmlEncode($row[1]);
    }
}
//pokaji gradowete
$query = "SELECT\t{$tbl_1d_cities}.ID,\n\t\t\t{$tbl_1d_cities}.City\n\t\tFROM {$tbl_1d_cities}\n\t\tWHERE ({$tbl_1d_cities}.Active='yes'\n\t\t\tOR {$tbl_1d_cities}.ID=" . dbQuote($PARAM['WHERE']) . ")\n\t\tORDER BY {$tbl_1d_cities}.ID";
$result = runQuery($query, 'manageAgenda()', 'GET_CITIES');
while ($row = db_fetch_row($result)) {
    if ($PARAM['WHERE'] == $row[0]) {
        $SUBS['WHERE'] .= "\n<option value=\"{$row['0']}\" selected>" . htmlEncode($row[1]);
    } else {
        $SUBS['WHERE'] .= "\n<option value=\"{$row['0']}\">" . htmlEncode($row[1]);
    }
}
if ($PARAM['WHERE']) {
    //pokaji kinata
    $query = "SELECT\t{$tbl_1d_cinemas}.ID,\n\t\t\t\t{$tbl_1d_cinemas}.Cinema\n\t\t\tFROM {$tbl_1d_cinemas}\n\t\t\tWHERE {$tbl_1d_cinemas}.CityID = " . dbQuote($PARAM['WHERE']) . "\n\t\t\tORDER BY {$tbl_1d_cinemas}.ID";
    $result = runQuery($query, 'manageAgenda()', 'GET_CINEMAS_FOR_CITY');
    while ($row = db_fetch_row($result)) {
        if ($PARAM['PLACES'] == $row[0]) {
            $SUBS['PLACES'] .= "\n<option value=\"{$row['0']}\" selected>" . htmlEncode($row[1]);
        } else {
            $SUBS['PLACES'] .= "\n<option value=\"{$row['0']}\">" . htmlEncode($row[1]);
        }
    }
}
$SUBS['FILM2'] = htmlEncode($PARAM['FILM']);
$SUBS['DATE'] = htmlEncode($PARAM['DATE']);
$SUBS['ID'] = htmlEncode($PARAM['id']);
$SUBS['NO'] = $PARAM['NO'];
$SUBS['TYPE' . strtoupper($PARAM['TYPE'])] = ' checked';
//get oldest week
Esempio n. 5
0
function dbText($text, $length = null)
{
    return "'" . dbQuote($text, $length) . "'";
}
Esempio n. 6
0
function showCharts()
{
    global $SUBS, $PARAM, $MSG;
    global $tbl_1d_charts, $tbl_1d_videodvd_charts, $tbl_1d_kino_charts, $tbl_1d_films, $tbl_1d_pictures;
    ////----[Mrasnika's] Edition 26.10.2002
    // proweri tipa na klasaciyata
    $query = "SELECT Type\n\t\tFROM {$tbl_1d_charts}\n\t\tWHERE ID = " . dbQuote($PARAM['id']);
    $result = runQuery($query, 'showCharts()', 'GET_CHART_TYPE');
    if ($row = db_fetch_row($result)) {
        $type = $row[0];
    }
    switch ($type) {
        case 'videodvd':
            $query = "SELECT\t{$tbl_1d_charts}.ID,\n\t\t\t\t\t{$tbl_1d_charts}.Type,\n\t\t \t\t\t{$tbl_1d_charts}.Title AS a1,\n\n\t\t \t\t\t{$tbl_1d_videodvd_charts}.No,\n\t\t \t\t\t{$tbl_1d_videodvd_charts}.Type,\n\t\t \t\t\t{$tbl_1d_videodvd_charts}.Film,\n\n\t\t \t\t\t{$tbl_1d_films}.Title AS a2,\n\t\t \t\t\t{$tbl_1d_films}.OriginalTitle,\n\t\t \t\t\t{$tbl_1d_films}.Actors,\n\n\t\t \t\t\t'',\n\t\t \t\t\t'',\n\t\t \t\t\t{$tbl_1d_videodvd_charts}.Weeks,\n\t\t \t\t\t'',\n\t\t \t\t\t{$tbl_1d_videodvd_charts}.tsWhen,\n\n\t\t \t\t\t{$tbl_1d_pictures}.URL,\n\t\t\t\t\t{$tbl_1d_pictures}.Width,\n\t\t\t\t\t{$tbl_1d_pictures}.Height,\n\n\t\t\t\t\tp1.URL,\n\t\t\t\t\tp1.Width,\n\t\t\t\t\tp1.Height\n\n\t\t \t\tFROM {$tbl_1d_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_videodvd_charts}\n\t\t\t\t\tON {$tbl_1d_videodvd_charts}.ChartID = {$tbl_1d_charts}.ID\n\t\t\t\t\t\tAND {$tbl_1d_charts}.Type = 'videodvd'\n\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_videodvd_charts}.Film = {$tbl_1d_films}.ID\n\t\t\t\t\t\tAND {$tbl_1d_videodvd_charts}.Type = 'list'\n\t\t\t\t\t\t\n\t\t\t\tLEFT JOIN {$tbl_1d_pictures}\n\t\t\t\t\tON {$tbl_1d_pictures}.RefID = {$tbl_1d_films}.ID\n\t\t\t\t\t\tAND {$tbl_1d_pictures}.RefType = 'film'\n\t\t\t\tLEFT JOIN {$tbl_1d_pictures} AS p1\n\t\t\t\t\tON {$tbl_1d_pictures}.ID = p1.RefID\n\t\t\t\t\t\tAND p1.RefType = 'thumb'\n\t\t\t\t\n\t\t\t\tWHERE\t({$tbl_1d_videodvd_charts}.ID IS NOT NULL)\n\t\t\t\t\t\tAND ({$tbl_1d_videodvd_charts}.tsWhen <= (" . week() . "+604800))\n\t\t\t\t\t\tAND {$tbl_1d_charts}.ID = " . dbQuote($PARAM['id']) . "\n\t\t\t\t\n\t\t\t\tGROUP BY {$tbl_1d_videodvd_charts}.ID\n\t\t\t\t\n\t\t\t\tORDER BY ({$tbl_1d_videodvd_charts}.tsWhen > " . week() . ") DESC,\n\t\t\t\t\t{$tbl_1d_videodvd_charts}.No,\n\t\t\t\t\t{$tbl_1d_videodvd_charts}.tsWhen DESC,\n\t\t\t\t\tRAND()";
            break;
        default:
        case 'kino':
            $query = "SELECT\t{$tbl_1d_charts}.ID,\n\t\t\t\t\t{$tbl_1d_charts}.Type,\n\t\t \t\t\t{$tbl_1d_charts}.Title AS a1,\n\n\t\t \t\t\t{$tbl_1d_kino_charts}.No,\n\t\t \t\t\t{$tbl_1d_kino_charts}.Type,\n\t\t \t\t\t{$tbl_1d_kino_charts}.Film,\n\n\t\t \t\t\t{$tbl_1d_films}.Title AS a2,\n\t\t \t\t\t{$tbl_1d_films}.OriginalTitle,\n\t\t \t\t\t{$tbl_1d_films}.Actors,\n\n\t\t \t\t\t{$tbl_1d_kino_charts}.BoxOffice,\n\t\t \t\t\t{$tbl_1d_kino_charts}.cumBoxOffice,\n\t\t \t\t\t{$tbl_1d_kino_charts}.Weeks,\n\t\t \t\t\t{$tbl_1d_kino_charts}.Screens,\n\t\t \t\t\t{$tbl_1d_kino_charts}.tsWhen,\n\n\t\t \t\t\t{$tbl_1d_pictures}.URL,\n\t\t\t\t\t{$tbl_1d_pictures}.Width,\n\t\t\t\t\t{$tbl_1d_pictures}.Height,\n\n\t\t\t\t\tp1.URL,\n\t\t\t\t\tp1.Width,\n\t\t\t\t\tp1.Height\n\n\t\t \t\tFROM {$tbl_1d_charts}\n\t\t\t\tLEFT JOIN {$tbl_1d_kino_charts}\n\t\t\t\t\tON {$tbl_1d_kino_charts}.ChartID = {$tbl_1d_charts}.ID\n\t\t\t\t\t\tAND {$tbl_1d_charts}.Type = 'kino'\n\n\t\t\t\tLEFT JOIN {$tbl_1d_films}\n\t\t\t\t\tON {$tbl_1d_kino_charts}.Film = {$tbl_1d_films}.ID\n\t\t\t\t\t\tAND {$tbl_1d_kino_charts}.Type = 'list'\n\t\t\t\t\t\t\n\t\t\t\tLEFT JOIN {$tbl_1d_pictures}\n\t\t\t\t\tON {$tbl_1d_pictures}.RefID = {$tbl_1d_films}.ID\n\t\t\t\t\t\tAND {$tbl_1d_pictures}.RefType = 'film'\n\t\t\t\tLEFT JOIN {$tbl_1d_pictures} AS p1\n\t\t\t\t\tON {$tbl_1d_pictures}.ID = p1.RefID\n\t\t\t\t\t\tAND p1.RefType = 'thumb'\n\t\t\t\t\n\t\t\t\tWHERE\t({$tbl_1d_kino_charts}.ID IS NOT NULL)\n\t\t\t\t\t\tAND ({$tbl_1d_kino_charts}.tsWhen <= (" . week() . "+604800))\n\t\t\t\t\t\tAND {$tbl_1d_charts}.ID = " . dbQuote($PARAM['id']) . "\n\t\t\t\t\n\t\t\t\tGROUP BY {$tbl_1d_kino_charts}.ID\n\t\t\t\t\n\t\t\t\tORDER BY ({$tbl_1d_kino_charts}.tsWhen > " . week() . ") DESC,\n\t\t\t\t\t{$tbl_1d_kino_charts}.No,\n\t\t\t\t\t{$tbl_1d_kino_charts}.tsWhen DESC,\n\t\t\t\t\tRAND()";
            break;
    }
    $result = runQuery($query, 'showCharts()', 'GET_CHARTS_INFO');
    $week = '0';
    $chart = '0';
    $path = getAdmSetting('UPLOAD_DIR');
    $SUBS['ALIGN'] = 'absmiddle';
    while ($row = db_fetch_row($result)) {
        switch ($row[1]) {
            case 'videodvd':
                $SUBS['CHART_TITLE'] = htmlEncode($row[2]);
                $SUBS['CHART_WEEK'] = showWeek($row[13]);
                if ($chart != $row[0]) {
                    //pechatay zaglawie
                    $SUBS['KLASACII'] .= fileParse('_index_charts_title.htmlt');
                    $chart = $row[0];
                    $week = $row[13];
                } else {
                    if (week($week) != week($row[13])) {
                        continue;
                    }
                }
                $SUBS['NO'] = sprintf('%02d', $row[3]);
                $SUBS['ACTORS'] = '';
                if ($row['4'] != 'list') {
                    $SUBS['TITLE'] = htmlEncode($row[5]);
                } else {
                    $SUBS['FILMID'] = $row[5];
                    if ($row[6]) {
                        $SUBS['TITLE'] = htmlEncode($row[6]);
                    } else {
                        $SUBS['TITLE'] = htmlEncode($row[7]);
                    }
                    $SUBS['ALT'] = $SUBS['TITLE'];
                    $SUBS['TITLE'] = fileParse('_index_charts_link.htmlt');
                    $SUBS['ACTORS'] = htmlEncode($row[8]);
                }
                $SUBS['WEEKS'] = $row[11];
                //kartinka, ako ima
                $SUBS['PIC'] = '';
                if ($row[14]) {
                    $SUBS['URL'] = $path . $row[14];
                    $SUBS['WIDTH'] = $row[15];
                    $SUBS['HEIGHT'] = $row[16];
                    $SUBS['TURL'] = $path . $row[17];
                    $SUBS['TWIDTH'] = $row[18];
                    $SUBS['THEIGHT'] = $row[19];
                    $SUBS['PIC'] = fileParse('_index_thumb.htmlt');
                }
                $SUBS['KLASACII'] .= fileParse('_index_charts_videodvd.htmlt');
                break;
            default:
            case 'kino':
                $SUBS['CHART_TITLE'] = htmlEncode($row[2]);
                $SUBS['CHART_WEEK'] = showWeek($row[13]);
                if ($chart != $row[0]) {
                    //pechatay zaglawie
                    $SUBS['KLASACII'] .= fileParse('_index_charts_title.htmlt');
                    $chart = $row[0];
                    $week = $row[13];
                } else {
                    if (week($week) != week($row[13])) {
                        continue;
                    }
                }
                $SUBS['NO'] = sprintf('%02d', $row[3]);
                $SUBS['ACTORS'] = '';
                if ($row['4'] != 'list') {
                    $SUBS['TITLE'] = htmlEncode($row[5]);
                } else {
                    $SUBS['FILMID'] = $row[5];
                    if ($row[6]) {
                        $SUBS['TITLE'] = htmlEncode($row[6]);
                    } else {
                        $SUBS['TITLE'] = htmlEncode($row[7]);
                    }
                    $SUBS['ALT'] = $SUBS['TITLE'];
                    $SUBS['TITLE'] = fileParse('_index_charts_link.htmlt');
                    $SUBS['ACTORS'] = htmlEncode($row[8]);
                }
                $SUBS['BO'] = '';
                while (ereg('([0-9]{1,3}$)', $row[9], $R)) {
                    if (strlen($R[1]) < 3) {
                        $SUBS['BO'] = "{$R['1']}" . $SUBS['BO'];
                    } else {
                        $SUBS['BO'] = ",{$R['1']}" . $SUBS['BO'];
                    }
                    $row[9] = ereg_replace('([0-9]{0,3}$)', '', $row[9]);
                }
                $SUBS['BO'] = ereg_replace('^,', '', $SUBS['BO']);
                $SUBS['CBO'] = '';
                while (ereg('([0-9]{1,3}$)', $row[10], $R)) {
                    if (strlen($R[1]) < 3) {
                        $SUBS['CBO'] = "{$R['1']}" . $SUBS['CBO'];
                    } else {
                        $SUBS['CBO'] = ",{$R['1']}" . $SUBS['CBO'];
                    }
                    $row[10] = ereg_replace('([0-9]{0,3}$)', '', $row[10]);
                }
                $SUBS['CBO'] = ereg_replace('^,', '', $SUBS['CBO']);
                $SUBS['WEEKS'] = $row[11];
                $SUBS['SCREENS'] = $row[12];
                //kartinka, ako ima
                $SUBS['PIC'] = '';
                if ($row[14]) {
                    $SUBS['URL'] = $path . $row[14];
                    $SUBS['WIDTH'] = $row[15];
                    $SUBS['HEIGHT'] = $row[16];
                    $SUBS['TURL'] = $path . $row[17];
                    $SUBS['TWIDTH'] = $row[18];
                    $SUBS['THEIGHT'] = $row[19];
                    $SUBS['PIC'] = fileParse('_index_thumb.htmlt');
                }
                $SUBS['KLASACII'] .= fileParse('_index_charts_kino.htmlt');
                break;
        }
    }
    ////----[Mrasnika's] Edition 24.10.2002
    // $SUBS['MORE'] = getBlock(1) . getBlock(2) . getBlock(3);
    if ($SUBS['KLASACII']) {
        $SUBS['MORE'] = getBlock(7);
    } else {
        $SUBS['CHARTS2'] = '<br>' . getBlock(7, 1) . '<br><br>';
        $SUBS['MORE'] = getBlock(1) . getBlock(2) . getBlock(3) . getBlock(4);
    }
    index('_index_charts.htmlt');
}