Return"; if(!in_array($sExt,$asAllowedFiletypes)) { die('The file you attempted to upload is not allowed.' . $sReturn); } if(filesize($_FILES['xBannerImage']['tmp_name']) > $nMaxFilesize) { die('The file you attempted to upload is too large.' . $sReturn); } if(!is_writable($sUploadPath)) { die('You cannot upload to the specified directory, please CHMOD it to 777.' . $sReturn); } if (!(move_uploaded_file($_FILES['xBannerImage']['tmp_name'],$sUploadPath . $sFile))) { die('There was an error during the file upload. Please try again.' . $sReturn); // It failed :(. } return $sFile; } function anya_readOptions() { $asOptions = unserialize(get_option('anya-options-group')); $ANYA = $asOptions; if (!empty($ANYA)) { foreach($ANYA as $sKey => $sVal) { $ANYA[$sKey] = anya_cleanOutput($sVal); } } if (empty($ANYA['fldShowHeading'])) { $ANYA['fldShowHeading'] = 'Yes'; } if (empty($ANYA['fldFontFamily'])) { $ANYA['fldFontFamily'] = 'Verdana'; } if (empty($ANYA['fldFontSize'])) { $ANYA['fldFontSize'] = '24pt'; } if (empty($ANYA['fldBoldFont'])) { $ANYA['fldBoldFont'] = 'Yes'; } if (empty($ANYA['fldFontShadow'])) { $ANYA['fldFontShadow'] = 'Yes'; } if (empty($ANYA['fldFontColor'])) { $ANYA['fldFontColor'] = '#FFFFFF'; } if (empty($ANYA['fldBackgroundColor'])) { $ANYA['fldBackgroundColor'] = '#00638D'; } if (empty($ANYA['fldLinkColor'])) { $ANYA['fldLinkColor'] = '#0044EE'; } return $ANYA; } function anya_writeOptions() { if ($_POST) { // this little trick will create the upload dir and chmod it properly if not there @ wp_upload_dir(); // end trick $sImage = anya_handleImageUpload(); $asNew = array(); foreach($_POST as $sKey => $sVal) { if (substr($sKey, 0, 3) == 'fld') { $asNew[$sKey] = anya_cleanInput($sVal); } } @ $asOptions = & anya_readOptions(); if (!empty($sImage)) { $asNew['banner-image'] = $sImage; } else { $asNew['banner-image'] = $asOptions['banner-image']; } @ add_option('anya-options-group',serialize($asNew)); @ update_option('anya-options-group',serialize($asNew)); } } function anya_cleanInput($input, $strip=1, $escape=0) { if(get_magic_quotes_gpc()) { $input = stripslashes($input); } if($strip == 1) { $input = strip_tags($input); } $output = trim($input); if($escape == 1) { $output = mysql_real_escape_string($output); } return $output; } function anya_cleanOutput($output) { if (!is_string($output)) { return $output; } return htmlspecialchars($output); } function anya_showPanel() { anya_writeOptions(); @ $ANYA = & anya_readOptions(); $asOptions = array(); $asOptions['Yes'] = 'Yes'; $asOptions['No'] = 'No'; $ANYA_SHOW_HEADING = anya_convertToOptions($ANYA['fldShowHeading'], $asOptions); unset($asOptions); $asOptions = array(); $asOptions['Arial'] = 'Arial'; $asOptions['Georgia'] = 'Georgia'; $asOptions['Sans'] = 'Sans'; $asOptions['Tahoma'] = 'Tahoma'; $asOptions['Times'] = 'Times'; $asOptions['Verdana'] = 'Verdana'; $ANYA_FONT_FAMILY = anya_convertToOptions($ANYA['fldFontFamily'], $asOptions); unset($asOptions); $asOptions = array(); for($i = 10; $i <= 48; $i++) { $asOptions[$i . 'pt'] = $i . 'pt'; } $ANYA_FONT_SIZE = anya_convertToOptions($ANYA['fldFontSize'], $asOptions); unset($asOptions); $asOptions = array(); $asOptions['Yes'] = 'Yes'; $asOptions['No'] = 'No'; $ANYA_BOLD_FONT = anya_convertToOptions($ANYA['fldBoldFont'], $asOptions); unset($asOptions); $asOptions = array(); $asOptions['Yes'] = 'Yes'; $asOptions['No'] = 'No'; $ANYA_FONT_SHADOW = anya_convertToOptions($ANYA['fldFontShadow'], $asOptions); unset($asOptions); $ANYA_UPDATED = ($_POST); $sDir = dirname(__FILE__); $sDir = rtrim($sDir, '/') . '/'; require_once($sDir . 'template-panel.php'); } function anya_convertToOptions($sMatchKey, & $asOptions) { $s = ''; foreach($asOptions as $sKey => $sVal) { $sSelected = ($sMatchKey == $sKey) ? 'selected="selected"' : ''; $s .= "\n"; } return $s; }