function comic_display_frontpage($data_id, $scale, $censor_level) { /************************************************************************** * get the admin settings *************************************************************************/ comic_admin_data(&$image_src, &$admin_censorlvl, &$censor_override, &$remote_enabled, &$filesize); /************************************************************************** * determine what comic to get *************************************************************************/ $comic_day = substr(date("D", time()), 0, 2); /* today */ /************************************************************************** * try to successfully get a random comic match... * this would be better with a validated comic_day since some * comics have to look back *************************************************************************/ if ($data_id == 0) { $match_str = "WHERE data_censorlvl <= '" . $censor_level . "' AND " . " data_pubdays LIKE '%" . $comic_day . "%' AND " . "data_enabled='T'"; } else { $match_str = "WHERE data_id='" . intval($data_id) . "' AND " . "data_enabled='T'"; } /************************************************************************** * get the comic data *************************************************************************/ $GLOBALS['phpgw']->db->query("select * from phpgw_comic_data " . $match_str); /************************************************************************** * of the potentially valid returns...lets try to shake it up a bit and * pick only one *************************************************************************/ if ($data_id == 0) { srand((double) microtime() * 1000000); $randval = rand(1, $GLOBALS['phpgw']->db->num_rows()); for ($index = 1; $index < $randval; $index++) { $GLOBALS['phpgw']->db->next_record(); } } /************************************************************************** * process valid comic data *************************************************************************/ if ($GLOBALS['phpgw']->db->next_record()) { $comic_censorlvl = $GLOBALS['phpgw']->db->f("data_censorlvl"); $comic_url = ""; $fetch_url = ""; /********************************************************************** * if user meets censorship criteria *********************************************************************/ if ($comic_censorlvl <= $censor_level && ($comic_censorlvl <= $admin_censorlvl || $censor_override == 1)) { /****************************************************************** * resolve the url *****************************************************************/ $status = comic_resolve_url($remote_enabled, &$fetch_url, &$comic_url, &$comic_day); } else { /****************************************************************** * otherwise have been censored *****************************************************************/ $status = STD_CENSOR; } /********************************************************************** * set the link data *********************************************************************/ $link_tgt = comic_resolve_linkurl($status, $fetch_url, &$link_url, &$comment); /********************************************************************** * if comic_day is not in days allowed flag error *********************************************************************/ if (!strstr($GLOBALS['phpgw']->db->f("data_pubdays"), $comic_day)) { $status = STD_WARNING; $end++; } /********************************************************************** * snarf the image *********************************************************************/ if ($image_src == COMIC_SNARFED && $status == STD_SUCCESS) { $status = comic_snarf(&$comic_url, $filesize); } /********************************************************************** * need to determine image size & location *********************************************************************/ if ($comic_day == "Su") { $image_width = $GLOBALS['phpgw']->db->f("data_swidth"); } else { $image_width = $GLOBALS['phpgw']->db->f("data_width"); } if ($image_width <= 300) { $image_location = 'S'; } else { $image_location = 'C'; } /********************************************************************** * if no image available, then give error image *********************************************************************/ if ($status != STD_SUCCESS && $status != STD_WARNING && $status != STD_CURRENT) { comic_error($image_location, $status, &$comic_url); $status = STD_TEMPLATE; } /********************************************************************** * effectively have something to display *********************************************************************/ if ($status == STD_SUCCESS || $status == STD_CURRENT || $status == STD_TEMPLATE) { /****************************************************************** * image scaling *****************************************************************/ switch ($scale) { case 1: switch ($image_location) { case 'S': $image_width = "350"; break; default: $image_width = "700"; break; } break; default: if ($image_width <= 0) { $image_width = "100%"; } break; } $name = lang("%1 by %2", $GLOBALS['phpgw']->db->f("data_title"), $GLOBALS['phpgw']->db->f("data_author")); /****************************************************************** * our template *****************************************************************/ $comic_tpl = CreateObject('phpgwapi.Template', $GLOBALS['phpgw']->common->get_tpl_dir('comic')); $comic_tpl->set_unknowns("remove"); $comic_tpl->set_file(array(table => "table.front.tpl", row => "row.common.tpl")); $comic_tpl->set_var(array(image_url => $comic_url, image_width => $image_width, link_url => $link_url, link_tgt => $link_tgt, comment => $comment, name => $name, th_bg => $GLOBALS['phpgw_info']['theme']['th_bg'], th_text => $GLOBALS['phpgw_info']['theme']['th_text'])); $comic_tpl->parse("center_part", "row"); $comic_tpl->parse(TABLE, "table"); /****************************************************************** * put the url and date in the database *****************************************************************/ if ($status == STD_SUCCESS) { comic_flag_success($comic_url, $data_id); } return $comic_tpl->fp('out', 'TABLE'); } } }
$done_label = lang("Done"); $actionurl = $phpgw->link('/comic/admin_options.php'); $doneurl = $phpgw->link('/admin/index.php'); $message = ""; if ($_POST['submit']) { $message = lang("Global Options Updated"); $image_source = intval($_POST['image_source']); $remote_enabled = intval($_POST['remote_enabled']); $censor_level = intval($_POST['censor_level']); $override_enabled = intval($_POST['override_enabled']); $filesize = intval($_POST['filesize']); $phpgw->db->lock("phpgw_comic_admin"); $phpgw->db->query("update phpgw_comic_admin set " . "admin_imgsrc='" . $image_source . "', " . "admin_rmtenabled='" . $remote_enabled . "', " . "admin_censorlvl='" . $censor_level . "', " . "admin_coverride='" . $override_enabled . "', " . "admin_filesize='" . $filesize . "'", __LINE__, __FILE__); $phpgw->db->unlock(); } comic_admin_data(&$image_source, &$censor_level, &$override_enabled, &$remote_enabled, &$filesize); $remote_checked = ""; if ($remote_enabled == 1) { $remote_checked = "checked"; } $override_checked = ""; if ($override_enabled == 1) { $override_checked = "checked"; } $options_tpl = CreateObject('phpgwapi.Template', $phpgw->common->get_tpl_dir('comic')); $options_tpl->set_unknowns("remove"); $options_tpl->set_file(array(message => "message.common.tpl", options => "admin.options.tpl", coptions => "option.common.tpl")); for ($loop = 0; $loop < count($g_censor_level); $loop++) { $selected = ""; if ($censor_level == $loop) { $selected = "selected";