function save_announce($id = 0, $starttime, $endtime, $subject, $type, $message, $displayorder = 0) { global $_G; $displayorder = intval($displayorder); $type = intval($type); $starttime = empty($starttime) || strtotime($starttime) < TIMESTAMP ? TIMESTAMP : strtotime($starttime); $endtime = empty($endtime) ? 0 : (strtotime($endtime) < $starttime ? $starttime + 86400 * 30 : strtotime($endtime)); $subject = htmlspecialchars(trim($subject)); if ($type == 1) { list($message) = explode("\n", trim($message)); $message = dhtmlspecialchars($message); } else { $type = 0; $message = trim($message); } if (empty($subject) || empty($message)) { acpmsg('modcp_ann_empty'); } elseif ($type == 1 && substr(strtolower($message), 0, 7) != 'http://') { acpmsg('modcp_ann_urlerror'); } else { $sql = "author='{$_G['username']}', subject='{$subject}', type='{$type}', starttime='{$starttime}', endtime='{$endtime}',\r\n\t\t\tmessage='{$message}', displayorder='{$displayorder}'"; if (empty($id)) { DB::query("INSERT INTO " . DB::table('forum_announcement') . " SET {$sql}"); } else { DB::query("UPDATE " . DB::table('forum_announcement') . " SET {$sql} WHERE id='{$id}'", 'UNBUFFERED'); } update_announcecache(); return true; } }
function save_announce($id = 0, $starttime, $endtime, $subject, $type, $message, $displayorder = 0) { global $_G; $displayorder = intval($displayorder); $type = intval($type); $starttime = empty($starttime) || strtotime($starttime) < TIMESTAMP ? TIMESTAMP : strtotime($starttime); $endtime = empty($endtime) ? 0 : (strtotime($endtime) < $starttime ? $starttime + 86400 * 30 : strtotime($endtime)); $subject = dhtmlspecialchars(trim($subject)); if ($type == 1) { list($message) = explode("\n", trim($message)); $message = dhtmlspecialchars($message); } else { $type = 0; $message = trim($message); } if (empty($subject) || empty($message)) { acpmsg('modcp_ann_empty'); } elseif ($type == 1 && substr(strtolower($message), 0, 7) != 'http://') { acpmsg('modcp_ann_urlerror'); } else { $data = array('author' => $_G['username'], 'subject' => $subject, 'type' => $type, 'starttime' => $starttime, 'endtime' => $endtime, 'message' => $message, 'displayorder' => $displayorder); if (empty($id)) { C::t('forum_announcement')->insert($data); } else { C::t('forum_announcement')->update($id, $data, true); } update_announcecache(); return true; } }