示例#1
0
if (!isset($bannerlib)) {
    $bannerlib = new BannerLib($dbTiki);
}
// CHECK FEATURE BANNERS AND ADMIN PERMISSION HERE
if ($feature_banners != 'y') {
    $smarty->assign('msg', tra("This feature is disabled") . ": feature_banners");
    $smarty->display("error.tpl");
    die;
}
if ($tiki_p_admin_banners != 'y') {
    $smarty->assign('msg', tra("You do not have permissions to edit banners"));
    $smarty->display("error.tpl");
    die;
}
if (isset($_REQUEST["bannerId"]) && $_REQUEST["bannerId"] > 0) {
    $info = $bannerlib->get_banner($_REQUEST["bannerId"]);
    if (!$info) {
        $smarty->assign('msg', tra("Banner not found"));
        $smarty->display("error.tpl");
        die;
    }
    // Check user is admin or the client
    if ($user != $info["client"] && $tiki_p_admin_banners != 'y') {
        $smarty->assign('msg', tra("You do not have permission to edit this banner"));
        $smarty->display("error.tpl");
        die;
    }
    $fromTime = substr($info["hourFrom"], 0, 2) . ":" . substr($info["hourFrom"], 2, 2);
    $toTime = substr($info["hourTo"], 0, 2) . ":" . substr($info["hourTo"], 2, 2);
    $smarty->assign('bannerId', $info["bannerId"]);
    $smarty->assign('client', $info["client"]);
    die;
}
$bannercachefile = $prefs['tmpDir'];
if ($tikidomain) {
    $bannercachefile .= "/{$tikidomain}";
}
$bannercachefile .= "/banner." . $_REQUEST["id"];
if (is_file($bannercachefile) and !isset($_REQUEST["reload"])) {
    $size = getimagesize($bannercachefile);
    $type = $size['mime'];
} else {
    include_once 'lib/banners/bannerlib.php';
    if (!isset($bannerlib)) {
        $bannerlib = new BannerLib($dbTiki);
    }
    $data = $bannerlib->get_banner($_REQUEST["id"]);
    if (!$data) {
        die;
    }
    $type = $data["imageType"];
    $data = $data["imageData"];
    if ($data) {
        $fp = fopen($bannercachefile, "wb");
        fputs($fp, $data);
        fclose($fp);
    }
}
header("Content-type: {$type}");
if (is_file($bannercachefile)) {
    readfile($bannercachefile);
} else {