function wpmanga_settings()
{
    global $wpdb;
    if (isset($_POST['settings_nonce'])) {
        if (!wp_verify_nonce($_POST['settings_nonce'], plugin_basename(plugin_sDIR() . '/wpmanga.php'))) {
            echo '<div class="error"><p>Error: Security Verification Failed.</p></div>';
        } else {
            $_POST = array_map('trim', $_POST);
            // Check Boxes Suck (Search for Alternative Method)
            if (!$_POST['wpmanga_releasebar_style']) {
                $_POST['wpmanga_releasebar_style'] = 0;
            }
            if (!$_POST['wpmanga_page_details_title']) {
                $_POST['wpmanga_page_details_title'] = 0;
            }
            if (!$_POST['wpmanga_page_details_header']) {
                $_POST['wpmanga_page_details_header'] = 0;
            }
            if (!$_POST['wpmanga_foolreader']) {
                $_POST['wpmanga_foolreader'] = 0;
            }
            if (!$_POST['wpmanga_widget_icons']) {
                $_POST['wpmanga_widget_icons'] = 0;
            }
            if (!$_POST['wpmanga_delay_megaupload']) {
                $_POST['wpmanga_delay_megaupload'] = 0;
            }
            if (!$_POST['wpmanga_delay_mediafire']) {
                $_POST['wpmanga_delay_mediafire'] = 0;
            }
            if (!$_POST['wpmanga_delay_depositfiles']) {
                $_POST['wpmanga_delay_depositfiles'] = 0;
            }
            if (!$_POST['wpmanga_delay_fileserve']) {
                $_POST['wpmanga_delay_fileserve'] = 0;
            }
            if (!$_POST['wpmanga_delay_filesonic']) {
                $_POST['wpmanga_delay_filesonic'] = 0;
            }
            if (!$_POST['wpmanga_delay_pdf']) {
                $_POST['wpmanga_delay_pdf'] = 0;
            }
            if (!$_POST['wpmanga_disable_megaupload']) {
                $_POST['wpmanga_disable_megaupload'] = 0;
            }
            if (!$_POST['wpmanga_disable_mediafire']) {
                $_POST['wpmanga_disable_mediafire'] = 0;
            }
            if (!$_POST['wpmanga_disable_depositfiles']) {
                $_POST['wpmanga_disable_depositfiles'] = 0;
            }
            if (!$_POST['wpmanga_disable_fileserve']) {
                $_POST['wpmanga_disable_fileserve'] = 0;
            }
            if (!$_POST['wpmanga_disable_filesonic']) {
                $_POST['wpmanga_disable_filesonic'] = 0;
            }
            if (!$_POST['wpmanga_disable_pdf']) {
                $_POST['wpmanga_disable_pdf'] = 0;
            }
            //Url and Title not empty
            if (!$_POST['wpmanga_projectslist_url']) {
                $_POST['wpmanga_projectslist_url'] = 'projects';
            } else {
                $_POST['wpmanga_projectslist_url'] = get_sSanitizedSlug($_POST['wpmanga_projectslist_url']);
            }
            if (!$_POST['wpmanga_projectslist_title']) {
                $_POST['wpmanga_projectslist_title'] = 'Projects';
            }
            // Filter $_POST and Update Setting
            $_DATA = array();
            foreach ($_POST as $key => $value) {
                if (preg_match("/wpmanga_(.*?)/i", $key)) {
                    $status = wpmanga_set($key, $value);
                    $_DATA[$key] = $status;
                }
            }
            // Update Thumbnails
            if ($_DATA['wpmanga_thumbnail_list_width'] || $_DATA['wpmanga_thumbnail_list_height']) {
                set_time_limit(0);
                $thumbnail = new WP_Http();
                foreach (get_sListProject() as $project) {
                    $thumbnail->request(plugin_sURL() . 'includes/generate_thumbnail.php?src=' . $project->image . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300));
                }
            }
            echo '<div class="updated"><p>Updated Settings.</p></div>';
        }
    }
    if (isset($_GET['generate'])) {
        if ($_GET['generate'] == 'thumbnails') {
            set_time_limit(0);
            $thumbnail = new WP_Http();
            foreach (get_sListProject() as $project) {
                $thumbnail->request(plugin_sURL() . 'includes/generate_thumbnail.php?src=' . $project->image . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300));
            }
            echo '<div class="updated"><p>Finished Generating Thumbnails.</p></div>';
        }
    }
    ?>
	<div class="wrap">
		<?php 
    screen_icon('options-general');
    ?>
		<h2>WP Manga Settings</h2>

		<p>WP Manga Project Manager has several options which affect the plugin behavior in different areas. The Frontend Options influence the output and features available in the pages, posts, or text-widgets. The Backend Options control the plugin's administrative area.</p>

		<div id="dashboard-widgets-wrap">
			<div id="dashboard-widgets" class="metabox-holder">
				<form method="post" action="admin.php?page=manga/settings">
					<div class="postbox">
						<h3 class='hndle'><span>Frontend Options</span></h3>
						<div class="inside">
							<table class="form-table fixed">
								<tr class="form-field">
									<td width="250px"><label for="wpmanga_thumbnail_list_width">Thumbnail Dimensions</label></td>
									<td>
										Width <input name="wpmanga_thumbnail_list_width" id="wpmanga_thumbnail_list_width" type="number" value="<?php 
    echo wpmanga_get('wpmanga_thumbnail_list_width', 145);
    ?>
" style="width: 10%;"> &nbsp;
										Height <input name="wpmanga_thumbnail_list_height" id="wpmanga_thumbnail_list_height" type="number" value="<?php 
    echo wpmanga_get('wpmanga_thumbnail_list_height', 300);
    ?>
" style="width: 10%;"> &nbsp; <a class="button-secondary" href="admin.php?page=manga/settings&generate=thumbnails">Force Generate Thumbnails</a>
									</td>
								</tr>

								<tr class="form">
									<td valign="top" width="250px"><label>Individual Project Page</label></td>
									<td>
										<input type="checkbox" name="wpmanga_page_details_title" id="wpmanga_page_details_title" value="1" <?php 
    if (wpmanga_get('wpmanga_page_details_title', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_page_details_title">Disable Title Filter <span class="description">(For Specific Themes)</span></label> <br>
										<input type="checkbox" name="wpmanga_page_details_header" id="wpmanga_page_details_header" value="1" <?php 
    if (wpmanga_get('wpmanga_page_details_header', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_page_details_header">Display Header <span class="description">(For Specific Themes)</span></label>
									</td>
								</tr>

								<tr class="form">
									<td valign="top" width="250px"><label>Online Reader Link Generator</label></td>
									<td>
										<input name="wpmanga_reader" id="reader_foolreader" type="radio" value="1"<?php 
    if (wpmanga_get('wpmanga_reader', 1) == 1) {
        echo ' checked="checked"';
    }
    ?>
> <label for="reader_foolreader">FoOlSlide</label> &nbsp;
										<input name="wpmanga_reader" id="reader_none" type="radio" value="0"<?php 
    if (!wpmanga_get('wpmanga_reader', 1) == 0) {
        echo ' checked="checked"';
    }
    ?>
> <label for="reader_none">None</label>
									</td>
								</tr>

								<tr class="form">
									<td valign="top" width="250px"><label for="wpmanga_releasebar_style">Release Bar Display Style</label></td>
									<td>
										<select name="wpmanga_releasebar_style" id="wpmanga_releasebar_style" style="width: 100%">
											<option value="1"<?php 
    if (wpmanga_get('wpmanga_releasebar_style', 1) == '1') {
        echo ' selected="selected"';
    }
    ?>
>Default Release Bar</option>
											<option value="2"<?php 
    if (wpmanga_get('wpmanga_releasebar_style', 1) == '2') {
        echo ' selected="selected"';
    }
    ?>
>Plain Release Bar</option>
										</select>
									</td>
								</tr>

								<tr class="form">
									<td width="250px"><label for="wpmanga_widget_icons">Latest Widget List</label></td>
									<td>
										<input type="checkbox" name="wpmanga_widget_icons" id="wpmanga_widget_icons" value="1" <?php 
    if (wpmanga_get('wpmanga_widget_icons', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_widget_icons">Show Release Icons</label>
									</td>
								</tr>

								<tr class="form">
									<td width="250px"><label for="wpmanga_channel">IRC Channel</label></td>
									<td>
										<input name="wpmanga_channel" id="wpmanga_channel" type="text" placeholder="irc://irc.irchighway.net/beta" value="<?php 
    echo wpmanga_get('wpmanga_channel', '');
    ?>
" style="width: 100%;">
									</td>
								</tr>

								<tr class="form">
									<td width="250px"><label for="wpmanga_projectslist_url">Projects List Url</label></td>
									<td>
										<input name="wpmanga_projectslist_url" id="wpmanga_projectslist_url" type="text" value="<?php 
    echo wpmanga_get('wpmanga_projectslist_url', 'projects');
    ?>
" style="width: 100%;">
									</td>
								</tr>

								<tr class="form">
									<td width="250px"><label for="wpmanga_projectslist_title">Projects List Title</label></td>
									<td>
										<input name="wpmanga_projectslist_title" id="wpmanga_projectslist_title" type="text" value="<?php 
    echo wpmanga_get('wpmanga_projectslist_title', 'Projects');
    ?>
" style="width: 100%;">
									</td>
								</tr>

								<tr class="form-field">
									<td valign="top" style="padding-top: 10px;" width="250px"><label for="wpmanga_delay">Delay Download Link</label></td>
									<td>
										<input name="wpmanga_delay" id="wpmanga_delay" type="number" value="<?php 
    echo wpmanga_get('wpmanga_delay', 0);
    ?>
" style="width: 10%;"> Hours <br>
										<input type="checkbox" name="wpmanga_delay_depositfiles" id="wpmanga_delay_depositfiles" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_depositfiles', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_depositfiles">Deposit Files</label> <br>
										<input type="checkbox" name="wpmanga_delay_fileserve" id="wpmanga_delay_fileserve" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_fileserve', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_fileserve">FileServe</label> <br>
										<input type="checkbox" name="wpmanga_delay_filesonic" id="wpmanga_delay_filesonic" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_filesonic', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_filesonic">FileSonic</label> <br>
										<input type="checkbox" name="wpmanga_delay_mediafire" id="wpmanga_delay_mediafire" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_mediafire', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_mediafire">MediaFire</label> <br>
										<input type="checkbox" name="wpmanga_delay_megaupload" id="wpmanga_delay_megaupload" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_megaupload', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_megaupload">MEGAUPLOAD</label> <br>
										<input type="checkbox" name="wpmanga_delay_pdf" id="wpmanga_delay_pdf" value="1" <?php 
    if (wpmanga_get('wpmanga_delay_pdf', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_delay_pdf">PDF</label>
									</td>
								</tr>
							</table>

							&nbsp; <input type="submit" class="button-primary" name="save" value="Save Settings"><br><br>
							<input type="hidden" name="settings_nonce" value="<?php 
    echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php'));
    ?>
">
						</div>
					</div>

					<div class="postbox" >
						<h3 class='hndle'><span>Backend Options</span></h3>
						<div class="inside">
							<table class="form-table fixed">
								<tr class="form-field">
									<td valign="top" style="padding-top: 10px;" width="250px"><label>Disable Download Links</label></td>
									<td>
										<input type="checkbox" name="wpmanga_disable_depositfiles" id="wpmanga_disable_depositfiles" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_depositfiles', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_depositfiles">Deposit Files</label> <br>
										<input type="checkbox" name="wpmanga_disable_fileserve" id="wpmanga_disable_fileserve" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_fileserve', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_fileserve">FileServe</label> <br>
										<input type="checkbox" name="wpmanga_disable_filesonic" id="wpmanga_disable_filesonic" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_filesonic', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_filesonic">FileSonic</label> <br>
										<input type="checkbox" name="wpmanga_disable_mediafire" id="wpmanga_disable_mediafire" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_mediafire', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_mediafire">MediaFire</label> <br>
										<input type="checkbox" name="wpmanga_disable_megaupload" id="wpmanga_disable_megaupload" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_megaupload', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_megaupload">MEGAUPLOAD</label> <br>
										<input type="checkbox" name="wpmanga_disable_pdf" id="wpmanga_disable_pdf" value="1" <?php 
    if (wpmanga_get('wpmanga_disable_pdf', 0)) {
        echo 'checked="checked"';
    }
    ?>
 style="width: 20px;"> <label for="wpmanga_disable_pdf">PDF</label>
									</td>
								</tr>

								<tr class="form">
									<td width="250px"><label for="wpmanga_release_statuspublished">Release publication status (0 for auto publish)</label></td>
									<td>
										<input name="wpmanga_release_statuspublished" id="wpmanga_release_statuspublished" type="text" value="<?php 
    echo wpmanga_get('wpmanga_release_statuspublished', '');
    ?>
" style="width: 100%;">
									</td>
								</tr>
							</table>

							&nbsp; <input type="submit" class="button-primary" name="save" value="Save Settings"><br><br>
							<input type="hidden" name="settings_nonce" value="<?php 
    echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php'));
    ?>
">
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
<?php 
}
/**
 * Display Administrative Menu for Releases.
 * @return menu
 */
function wpmanga_dataRelease()
{
    global $wpdb;
    // Action Variable
    if (isset($_GET['action'])) {
        $action = strtolower($_GET['action']);
    } else {
        $action = 'add';
    }
    // Sanity Check on EDIT and DEL
    if (!isset($_GET['id']) && $action != 'add') {
        $action = 'add';
    }
    if (isset($_POST['wpmanga_nonce'])) {
        if (!wp_verify_nonce($_POST['wpmanga_nonce'], plugin_basename(plugin_sDIR() . '/wpmanga.php'))) {
            echo '<div class="error"><p>Error: Security Verification Failed.</p></div>';
        } else {
            $_POST = array_map('trim', $_POST);
            $_POST = array_map('stripslashes', $_POST);
            if ($_POST['project_id']) {
                // UNIXTIME Fix
                if ($_POST['unixtime'] != 0) {
                    if ($_POST['revision'] == 0) {
                        $_POST['unixtime_mod'] = $_POST['unixtime'];
                        $_POST['revision'] = 1;
                    } else {
                        $edit = get_sRelease($_GET['id']);
                        $_POST['unixtime_mod'] = $_POST['unixtime'];
                        $_POST['unixtime'] = $edit->unixtime;
                    }
                } else {
                    $_POST['unixtime'] = time();
                    $_POST['unixtime_mod'] = $_POST['unixtime'];
                }
                if (preg_match("/(edit)/i", $action)) {
                    $edit = get_sRelease($_GET['id']);
                    if ($_POST['revision'] > $edit->revision) {
                        $_POST['unixtime_mod'] = time();
                    }
                }
                $data = array('project_id' => $_POST['project_id'], 'unixtime' => $_POST['unixtime'], 'unixtime_mod' => $_POST['unixtime_mod'], 'volume' => $_POST['volume'], 'chapter' => $_POST['chapter'], 'subchapter' => $_POST['subchapter'], 'revision' => $_POST['revision'], 'type' => $_POST['type'], 'title' => $_POST['title'], 'download_megaupload' => $_POST['download_megaupload'], 'download_mediafire' => $_POST['download_mediafire'], 'download_depositfiles' => $_POST['download_depositfiles'], 'download_fileserve' => $_POST['download_fileserve'], 'download_filesonic' => $_POST['download_filesonic'], 'download_pdf' => $_POST['download_pdf'], 'download_irc' => $_POST['download_irc'], 'link_reader' => $_POST['link_reader'], 'language' => $_POST['language'], 'status' => $_POST['status']);
                switch ($action) {
                    case 'edit':
                        $status = $wpdb->update($wpdb->prefix . 'projects_releases', $data, array('id' => $_GET['id']));
                        if ($status) {
                            echo '<div class="updated"><p>Updated Release Information.</p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to update information.</p></div>';
                        }
                        break;
                    case 'delete':
                        $status = $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects_releases` WHERE `id` = '%d'", $_GET['id']));
                        if ($status) {
                            echo '<div class="updated"><p>Deleted Release Information.</p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to delete information.</p></div>';
                        }
                        break;
                    default:
                        $wpdb->insert($wpdb->prefix . 'projects_releases', $data);
                        if ($wpdb->insert_id) {
                            echo '<div class="updated"><p>Added Release for Projects. <a href="admin.php?page=manga/release&action=edit&id=' . $wpdb->insert_id . '">Edit Release</a></p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to add new release.</p></div>';
                        }
                }
            } else {
                echo '<div class="error"><p>Error: Please fill in the required fields.</p></div>';
            }
        }
    }
    $projects = $wpdb->get_results("SELECT `id`, `title` FROM `" . $wpdb->prefix . "projects` ORDER BY `title` ASC");
    if ($projects) {
        if (preg_match("/(edit|delete)/i", $action)) {
            $release = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects_releases` WHERE `id` = '%d' LIMIT 1", $_GET['id']));
        }
        ?>
		<div class="wrap">
			<?php 
        screen_icon('edit');
        ?>
			<h2><?php 
        echo ucfirst($action);
        ?>
 Release</h2>

			<p>Add a new release for a project.</p>
<?php 
        switch ($action) {
            case 'edit':
                echo '<form method="post" action="admin.php?page=manga/release&action=edit&id=' . $_GET['id'] . '">';
                break;
            case 'delete':
                echo '<form method="post" action="admin.php?page=manga/release&action=delete&id=' . $_GET['id'] . '">';
                break;
            default:
                echo '<form method="post" action="admin.php?page=manga/release">';
        }
        ?>
				<table class="form-table">
					<tr class="form-field">
						<th scope="row"><label for="project_id">Project</label></th>
						<td>
							<select name="project_id" id="project_id" style="width: 460px">
								<?php 
        foreach ($projects as $project) {
            if (preg_match("/(edit|delete)/i", $action)) {
                if ($project->id == $release->project_id) {
                    echo "<option value='{$project->id}' selected='selected'>{$project->title}</option>";
                } else {
                    echo "<option value='{$project->id}'>{$project->title}</option>";
                }
            } else {
                echo "<option value='{$project->id}'>{$project->title}</option>";
            }
        }
        ?>
							</select>
						</td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="volume">Volume</label></th>
						<td><input name="volume" id="volume" type="number" value="<?php 
        if (isset($release)) {
            echo $release->volume;
        } else {
            echo '0';
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
 autofocus></td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="chapter">Chapter</label></th>
						<td><input name="chapter" id="chapter" type="number" value="<?php 
        if (isset($release)) {
            echo $release->chapter;
        } else {
            echo '0';
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
></td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="subchapter">Sub-Chapter</label></th>
						<td><input name="subchapter" id="subchapter" type="number" value="<?php 
        if (isset($release)) {
            echo $release->subchapter;
        } else {
            echo '0';
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
></td>
					</tr>

					<?php 
        if (preg_match("/(edit|delete)/i", $action)) {
            ?>
					<tr class="form-field">
						<th scope="row"><label for="revision">Revision</label></th>
						<td><input name="revision" id="revision" type="number" value="<?php 
            if (isset($release)) {
                echo $release->revision;
            }
            ?>
"<?php 
            if ($action == 'delete') {
                echo ' readonly="readonly"';
            }
            ?>
></td>
					</tr>
					<?php 
        } else {
            ?>
					<input type="hidden" name="revision" id="revision" value="0">
					<?php 
        }
        ?>

					<tr class="form">
						<th scope="row"><label>Release Type</label></th>
						<td>
							<input name="type" id="normal" type="radio" value="0"<?php 
        if (!preg_match("/(edit|delete)/i", $action)) {
            echo ' checked="checked"';
        }
        if (isset($release) && $release->type == 0) {
            echo ' checked="checked"';
        }
        if ($action == 'delete') {
            echo ' disabled="disabled"';
        }
        ?>
> <label for="normal">Chapter</label> &nbsp;
							<input name="type" id="volumet" type="radio" value="5"<?php 
        if (isset($release) && $release->type == 5) {
            echo ' checked="checked"';
        }
        if ($action == 'delete') {
            echo ' disabled="disabled"';
        }
        ?>
> <label for="volumet">Volume (Batch)</label> &nbsp;
							<input name="type" id="special" type="radio" value="10"<?php 
        if (isset($release) && $release->type == 10) {
            echo ' checked="checked"';
        }
        if ($action == 'delete') {
            echo ' disabled="disabled"';
        }
        ?>
> <label for="special">Special</label> &nbsp;
							<input name="type" id="oneshot" type="radio" value="20"<?php 
        if (isset($release) && $release->type == 20) {
            echo ' checked="checked"';
        }
        if ($action == 'delete') {
            echo ' disabled="disabled"';
        }
        ?>
> <label for="oneshot">Oneshot</label> &nbsp;
						</td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="title">Title</label></th>
						<td><input name="title" id="title" type="text" value="<?php 
        if (isset($release)) {
            echo $release->title;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
></td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="download_depositfiles">Downloads Links</label></th>
						<td>
							<input name="download_depositfiles" id="download_depositfiles" type="<?php 
        if (wpmanga_get('wpmanga_disable_depositfiles', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for Deposit Files here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_depositfiles;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_depositfiles"><?php 
        if (!wpmanga_get('wpmanga_disable_depositfiles', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-depositfiles-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>

							<input name="download_fileserve" id="download_fileserve" type="<?php 
        if (wpmanga_get('wpmanga_disable_fileserve', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for FileServe here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_fileserve;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_fileserve"><?php 
        if (!wpmanga_get('wpmanga_disable_fileserve', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-fileserve-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>

							<input name="download_filesonic" id="download_filesonic" type="<?php 
        if (wpmanga_get('wpmanga_disable_filesonic', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for FileSonic here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_filesonic;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_filesonic"><?php 
        if (!wpmanga_get('wpmanga_disable_filesonic', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-filesonic-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>

							<input name="download_mediafire" id="download_mediafire" type="<?php 
        if (wpmanga_get('wpmanga_disable_mediafire', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for MediaFire here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_mediafire;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_mediafire"><?php 
        if (!wpmanga_get('wpmanga_disable_mediafire', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-mediafire-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>

							<input name="download_megaupload" id="download_megaupload" type="<?php 
        if (wpmanga_get('wpmanga_disable_megaupload', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for MEGAUPLOAD here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_megaupload;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_megaupload"><?php 
        if (!wpmanga_get('wpmanga_disable_megaupload', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-megaupload-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>

							<input name="download_pdf" id="download_pdf" type="<?php 
        if (wpmanga_get('wpmanga_disable_pdf', 0)) {
            echo 'hidden';
        } else {
            'url';
        }
        ?>
" placeholder="Enter download link for PDF here." style="width:90%;" value="<?php 
        if (isset($release)) {
            echo $release->download_pdf;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_pdf"><?php 
        if (!wpmanga_get('wpmanga_disable_pdf', 0)) {
            echo '<img src="' . plugin_sURL() . 'images/download-icon-pdf-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br>';
        }
        ?>
</label>
						</td>
					</tr>

					<?php 
        if (!wpmanga_get('wpmanga_reader', 1) == 1) {
            ?>
					<tr class="form-field">
						<th scope="row"><label for="link_reader">Chapter Links</label></th>
						<td>
							<input name="link_reader" id="link_reader" type="url" placeholder="Enter chapter link here." style="width:90%;" value="<?php 
            if (isset($release)) {
                echo $release->link_reader;
            }
            ?>
"<?php 
            if ($action == 'delete') {
                echo ' readonly="readonly"';
            }
            ?>
>
							<label for="link_reader"><img src=" <?php 
            echo plugin_sURL();
            ?>
images/download-icon-onlinereader-24.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"><br></label>
						</td>
					</tr>
					<?php 
        }
        ?>
					<tr class="form-field">
						<th scope="row"><label for="language">Language</label></th>
						<td>
							<select name="language" id="language" style="width:460px" <?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
								<?php 
        foreach (wpmanga_listLanguages() as $language => $description) {
            if (preg_match("/(edit|delete)/i", $action)) {
                if ($release->language == $language) {
                    echo "<option value='{$language}' selected='selected'>{$description}</option>";
                } else {
                    echo "<option value='{$language}'>{$description}</option>";
                }
            } else {
                if ('en' == $language) {
                    echo "<option value='{$language}' selected='selected'>{$description}</option>";
                } else {
                    echo "<option value='{$language}'>{$description}</option>";
                }
            }
        }
        ?>
							</select>
						</td>
					</tr>

<?php 
        // end add by busaway
        ?>

					<tr class="form-field">
						<th scope="row"><label for="download_irc">IRC Download Command</label></th>
						<td>
							<input name="download_irc" id="download_irc" type="text" placeholder="/MSG BOTNAME XDCC SEND #1  or  !TRIGGER1" style="width:91%;" value="<?php 
        if (isset($release)) {
            echo $release->download_irc;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
>
							<label for="download_irc"><img src="<?php 
        echo plugin_sURL();
        ?>
images/download-icon-irc.png" width="24px" style="vertical-align: middle; padding-bottom: 2px"></label>
						</td>
					</tr>

					<tr class="form-field">
						<th scope="row"><label for="unixtime">Release Date/Time</label></th>
						<td>
							<input name="unixtime_datetime" id="unixtime_datetime" type="text">
							<input name="unixtime" id="unixtime" type="hidden" value="0">
							<script type="text/javascript">
								jQuery('#unixtime_datetime').datetimepicker();
								<?php 
        if (!preg_match("/(edit|delete)/i", $action)) {
            ?>
								jQuery('#unixtime_datetime').datetimepicker('setDate', (new Date()));
								<?php 
        } else {
            ?>
								jQuery('#unixtime_datetime').datetimepicker('setDate', (new Date(<?php 
            echo $release->unixtime;
            ?>
 * 1000)));
								<?php 
        }
        ?>

								datetime = Date.parse(jQuery('#unixtime_datetime').val()) / 1000;
								jQuery('#unixtime').val(datetime);

								jQuery(document).click(function() {
									datetime = Date.parse(jQuery('#unixtime_datetime').val()) / 1000;
									jQuery('#unixtime').val(datetime);
								});
							</script>
						</td>
					</tr>
					<?php 
        if (wpmanga_get('wpmanga_release_statuspublished', 0) != 0) {
            ?>
					<tr class="form-field">
						<th scope="row"><label for="status">Status</label></th>
						<td><input name="status" id="status" type="number" value="<?php 
            if (isset($release)) {
                echo $release->status;
            } else {
                echo '0';
            }
            ?>
"<?php 
            if ($action == 'delete') {
                echo ' readonly="readonly"';
            }
            ?>
></td>
					</tr>
					<?php 
        }
        ?>

				</table>

				<p class="submit">
					<input type="submit" class="button-primary" name="save" value="<?php 
        echo ucfirst($action);
        ?>
 Release">
					<input type="hidden" name="wpmanga_nonce" value="<?php 
        echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php'));
        ?>
">
				</p>
			</form>
		</div>
<?php 
    } else {
        ?>
		<script type="text/javascript">
			location.replace("admin.php?page=manga/project")
		</script>
<?php 
    }
}
/**
 * Obtain the path to the template specified.
 * @param string $template Template filename
 * @return string Path to the template
 */
function get_sTemplate($template)
{
    if (file_exists(plugin_sDIR() . 'templates/' . strtolower(basename(TEMPLATEPATH)) . '/' . $template)) {
        $templatePath = plugin_sDIR() . 'templates/' . strtolower(basename(TEMPLATEPATH)) . '/' . $template;
    } elseif (file_exists(plugin_sDIR() . 'templates/' . $template)) {
        $templatePath = plugin_sDIR() . 'templates/' . $template;
    } else {
        $templatePath = '';
    }
    return (string) $templatePath;
}
/**
 * Display Administrative Menu for Projects.
 * @return menu
 */
function wpmanga_dataProject()
{
    global $wpdb;
    // Action Variable
    if (isset($_GET['action'])) {
        $action = strtolower($_GET['action']);
    } else {
        $action = 'add';
    }
    // Sanity Check on EDIT and DEL
    if (!isset($_GET['id']) && $action != 'add') {
        $action = 'add';
    }
    if (isset($_POST['wpmanga_nonce'])) {
        if (!wp_verify_nonce($_POST['wpmanga_nonce'], plugin_basename(plugin_sDIR() . '/wpmanga.php'))) {
            echo '<div class="error"><p>Error: Security Verification Failed.</p></div>';
        } else {
            $_POST = array_map('trim', $_POST);
            $_POST = array_map('stripslashes', $_POST);
            if (!$_POST['mature']) {
                $_POST['mature'] = 0;
            }
            if ($_POST['title']) {
                if ($_POST['image']) {
                    $thumbnail = new WP_Http();
                    $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image'] . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300));
                    $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image'] . '&w=60&h=60');
                }
                if ($_POST['image_thumbnail']) {
                    $thumbnail = new WP_Http();
                    $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image_thumbnail'] . '&w=' . wpmanga_get('wpmanga_thumbnail_list_width', 145) . '&h=' . wpmanga_get('wpmanga_thumbnail_list_height', 300));
                    $thumbnail->request(plugin_sURL() . '/includes/generate_thumbnail.php?src=' . $_POST['image_thumbnail'] . '&w=60&h=60');
                }
                $custom_settings = json_encode(array('chapter' => $_POST['custom_chapter'], 'subchapter' => $_POST['custom_subchapter']));
                $data = array('category' => $_POST['category'], 'slug' => wpmanga_getUrl($_POST['slug'], $_POST['title']), 'title' => $_POST['title'], 'title_alt' => $_POST['title_alt'], 'description' => $_POST['description'], 'description_short' => $_POST['description_short'], 'author' => $_POST['author'], 'genre' => $_POST['genre'], 'status' => $_POST['status'], 'image' => $_POST['image'], 'image_thumbnail' => $_POST['image_thumbnail'], 'team_origin' => $_POST['team_origin'], 'reader' => $_POST['reader'], 'url' => $_POST['url'], 'mature' => $_POST['mature'], 'custom' => $custom_settings);
                switch ($action) {
                    case 'edit':
                        $check = $wpdb->query($wpdb->prepare("SELECT `slug` FROM `" . $wpdb->prefix . "projects` WHERE `id` <>" . $_GET['id'] . " and `slug` = '%s'", wpmanga_getUrl($_POST['slug'], $_POST['title'])));
                        if (!$check) {
                            $status = $wpdb->update($wpdb->prefix . 'projects', $data, array('id' => $_GET['id']));
                            if ($status) {
                                echo '<div class="updated"><p>Updated Project Information for <i>' . $_POST['title'] . '</i>.</p></div>';
                            } else {
                                echo '<div class="error"><p>Error: Failed to update information.</p></div>';
                            }
                        } else {
                            echo '<div class="error"><p>Error: Failed to edit project. (Duplicate Url)</p></div>';
                        }
                        break;
                    case 'delete':
                        $status = $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects` WHERE `id` = '%d'", $_GET['id']));
                        $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects_releases` WHERE `project_id` = '%d'", $_GET['id']));
                        if ($status) {
                            echo '<div class="updated"><p>Deleted Project Information for <i>' . $_POST['title'] . '</i>.</p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to delete information.</p></div>';
                        }
                        break;
                    default:
                        $check = $wpdb->query($wpdb->prepare("SELECT `slug` FROM `" . $wpdb->prefix . "projects` WHERE `slug` = '%s'", wpmanga_getUrl($_POST['slug'], $_POST['title'])));
                        if (!$check) {
                            $wpdb->insert($wpdb->prefix . 'projects', $data);
                            if ($wpdb->insert_id) {
                                echo '<div class="updated"><p>Added <i>' . $_POST['title'] . '</i> to Projects. <a href="admin.php?page=manga/project&action=edit&id=' . $wpdb->insert_id . '">Edit Information</a></p></div>';
                            } else {
                                echo '<div class="error"><p>Error: Failed to add new project.</p></div>';
                            }
                        } else {
                            echo '<div class="error"><p>Error: Failed to add new project. (Duplicate Url)</p></div>';
                        }
                }
            } else {
                echo '<div class="error"><p>Error: Please fill in the required fields.</p></div>';
            }
        }
    }
    if (preg_match("/(edit|delete)/i", $action)) {
        $project = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects` WHERE `id` = '%d' LIMIT 1", $_GET['id']));
    }
    ?>
	<div class="wrap">
		<?php 
    screen_icon('edit');
    ?>
		<h2><?php 
    echo ucfirst($action);
    ?>
 Project Information</h2>
		
		<p>Create a new project and add it to this site.</p>
<?php 
    switch ($action) {
        case 'edit':
            echo '<form method="post" action="admin.php?page=manga/project&action=edit&id=' . $_GET['id'] . '">';
            break;
        case 'delete':
            echo '<form method="post" action="admin.php?page=manga/project&action=delete&id=' . $_GET['id'] . '">';
            break;
        default:
            echo '<form method="post" action="admin.php?page=manga/project">';
    }
    ?>
			<table class="form-table">
				<tr class="form-field">
					<th scope="row"><label for="category">Category</label></th>
					<td>
						<select name="category" id="category" style="width: 460px">
							<?php 
    $categories = get_sListCategories();
    foreach ($categories as $category) {
        if (preg_match("/(edit|delete)/i", $action)) {
            if ($project->category == $category->id) {
                echo "<option value='{$category->id}' selected='selected'>{$category->name}</option>";
            } else {
                echo "<option value='{$category->id}'>{$category->name}</option>";
            }
        } else {
            echo "<option value='{$category->id}'>{$category->name}</option>";
        }
    }
    ?>
						</select>
					</td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="title">Title <span class="description">(required)</span></label></th>
					<td><input name="title" id="title" type="text" value="<?php 
    if (isset($project)) {
        echo $project->title;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly" ';
    }
    ?>
autofocus required></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="title_alt">Alternative Title</label></th>
					<td><input name="title_alt" id="title_alt" type="text" value="<?php 
    if (isset($project)) {
        echo $project->title_alt;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>

				<tr class="form-field">
					<th scope="row"><label for="title_alt">Url Fragment <br /><span class="description">(optional, blank for auto-generated url)</span></label></th>
					<td><input name="slug" id="slug" type="text" value="<?php 
    if (isset($project)) {
        echo $project->slug;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>

				<tr class="form-field">
					<th scope="row"><label for="author">Author & Artist</label></th>
					<td><input name="author" id="author" type="text" value="<?php 
    if (isset($project)) {
        echo esc_textarea($project->author);
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="description">Description</label></th>
					<td><textarea name="description" id="description"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><?php 
    if (isset($project)) {
        echo esc_textarea($project->description);
    }
    ?>
</textarea></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="short_description">Short Description <span class="description">(optional)</span></label></th>
					<td><textarea name="description_short" id="description_short"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><?php 
    if (isset($project)) {
        echo esc_textarea($project->description_short);
    }
    ?>
</textarea></td>
				</tr>

				<tr class="form-field">
					<th scope="row"><label for="genre">Genre(s)</label></th>
					<td><textarea name="genre" id="genre"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><?php 
    if (isset($project)) {
        echo esc_textarea($project->genre);
    }
    ?>
</textarea></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="status">Status in Country of Origin</label></th>
					<td><textarea name="status" id="status"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><?php 
    if (isset($project)) {
        echo esc_textarea($project->status);
    }
    ?>
</textarea></td>
				</tr>
				
				<tr class="form">
					<th scope="row"><label for="image">Image</label></th>
					<td><input id="image" type="url" name="image" class="upload" size="66" placeholder="Enter an URL or upload an image for this project." value="<?php 
    if (isset($project)) {
        echo $project->image;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><input class="<?php 
    if ($action != 'delete') {
        echo 'upload_image_button';
    }
    ?>
" type="button" value="Upload Image"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>

				<tr class="form">
					<th scope="row"><label for="image_thumbnail">Image Thumbnail <span class="description">(optional)</span></label></th>
					<td><input id="image_thumbnail" type="url" name="image_thumbnail" class="upload" size="66" placeholder="Enter an URL or upload an image thumbnail for this project." value="<?php 
    if (isset($project)) {
        echo $project->image_thumbnail;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
><input class="<?php 
    if ($action != 'delete') {
        echo 'upload_image_button';
    }
    ?>
" type="button" value="Upload Image Thumbnail"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>

				<tr class="form-field">
					<th scope="row"><label for="team_origin">Original Team</label></th>
					<td><input name="team_origin" id="team_origin" type="text" value="<?php 
    if (isset($project)) {
        echo esc_textarea($project->team_origin);
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>

				<tr class="form-field">
					<th scope="row"><label for="reader">Online Reader Link</label></th>
					<td><input name="reader" id="reader" type="url" placeholder="http://reader.<?php 
    echo $_SERVER['HTTP_HOST'];
    ?>
/serie/..." value="<?php 
    if (isset($project)) {
        echo $project->reader;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="url">Reference Link</label></th>
					<td><input name="url" id="url" type="url" placeholder="http://mangaupdates.com/series.html?id=..." value="<?php 
    if (isset($project)) {
        echo $project->url;
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>
				
				<tr class="form">
					<th scope="row"><label for="custom_subchapter">Mature Content</label></th>
					<td><input name="mature" id="mature" type="checkbox" value="1"<?php 
    if ($project->mature) {
        echo ' checked="checked"';
    }
    ?>
> Yes</td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="custom_chapter">Custom Chapter <span class="description">(optional)</span></label></th>
					<td><input name="custom_chapter" id="custom_chapter" type="text" placeholder="Episode %num%" value="<?php 
    if (isset($project)) {
        echo get_sJSON($project->custom, 'chapter');
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>
				
				<tr class="form-field">
					<th scope="row"><label for="custom_subchapter">Custom Sub-Chapter <span class="description">(optional)</span></label></th>
					<td><input name="custom_subchapter" id="custom_subchapter" type="text" placeholder="Act %num%" value="<?php 
    if (isset($project)) {
        echo get_sJSON($project->custom, 'subchapter');
    }
    ?>
"<?php 
    if ($action == 'delete') {
        echo ' readonly="readonly"';
    }
    ?>
></td>
				</tr>
			</table>
			
			<p class="submit">
				<input type="submit" class="button-primary" name="save" value="<?php 
    echo ucfirst($action);
    ?>
 Project">
				<input type="hidden" name="wpmanga_nonce" value="<?php 
    echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php'));
    ?>
">
			</p>
		</form>
	</div>
<?php 
}
/**
 * Display Administrative Menu for Covers.
 * @return menu
 */
function wpmanga_dataCover()
{
    global $wpdb;
    // Action Variable
    if (isset($_GET['action'])) {
        $action = strtolower($_GET['action']);
    } else {
        $action = 'add';
    }
    // Sanity Check on EDIT and DEL
    if (!isset($_GET['id']) && $action != 'add') {
        $action = 'add';
    }
    if (isset($_POST['wpmanga_nonce'])) {
        if (!wp_verify_nonce($_POST['wpmanga_nonce'], plugin_basename(plugin_sDIR() . '/wpmanga.php'))) {
            echo '<div class="error"><p>Error: Security Verification Failed.</p></div>';
        } else {
            $_POST = array_map('trim', $_POST);
            $_POST = array_map('stripslashes', $_POST);
            if ($_POST['project_id']) {
                $data = array('project_id' => $_POST['project_id'], 'volume' => $_POST['volume'], 'image' => $_POST['image']);
                switch ($action) {
                    case 'edit':
                        $status = $wpdb->update($wpdb->prefix . 'projects_volumes', $data, array('id' => $_GET['id']));
                        if ($status) {
                            echo '<div class="updated"><p>Updated Volume Cover Information.</p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to update information.</p></div>';
                        }
                        break;
                    case 'delete':
                        $status = $wpdb->query($wpdb->prepare("DELETE FROM `{$wpdb->prefix}projects_volumes` WHERE `id` = '%d'", $_GET['id']));
                        if ($status) {
                            echo '<div class="updated"><p>Deleted Volume Cover Information.</p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to delete information.</p></div>';
                        }
                        break;
                    default:
                        $wpdb->insert($wpdb->prefix . 'projects_volumes', $data);
                        if ($wpdb->insert_id) {
                            echo '<div class="updated"><p>Added Volume Cover for Releases. <a href="admin.php?page=manga/volume&action=edit&id=' . $wpdb->insert_id . '">Edit Cover Information</a></p></div>';
                        } else {
                            echo '<div class="error"><p>Error: Failed to add new cover.</p></div>';
                        }
                }
            } else {
                echo '<div class="error"><p>Error: Please fill in the required fields.</p></div>';
            }
        }
    }
    $projects = $wpdb->get_results("SELECT `id`, `title` FROM `" . $wpdb->prefix . "projects` ORDER BY `title` ASC");
    if ($projects) {
        if (preg_match("/(edit|delete)/i", $action)) {
            $cover = $wpdb->get_row($wpdb->prepare("SELECT * FROM `{$wpdb->prefix}projects_volumes` WHERE `id` = '%d' LIMIT 1", $_GET['id']));
        }
        ?>
		<div class="wrap">
			<?php 
        screen_icon('edit');
        ?>
			<h2><?php 
        echo ucfirst($action);
        ?>
 Volume Cover</h2>
			
			<p>Add a new cover for a volume.</p>
<?php 
        switch ($action) {
            case 'edit':
                echo '<form method="post" action="admin.php?page=manga/volume&action=edit&id=' . $_GET['id'] . '">';
                break;
            case 'delete':
                echo '<form method="post" action="admin.php?page=manga/volume&action=delete&id=' . $_GET['id'] . '">';
                break;
            default:
                echo '<form method="post" action="admin.php?page=manga/volume">';
        }
        ?>
				<table class="form-table">
					<tr class="form-field">
						<th scope="row"><label for="project_id">Project</label></th>
						<td>
							<select name="project_id" id="project_id" style="width: 460px">
								<?php 
        foreach ($projects as $project) {
            if (preg_match("/(edit|delete)/i", $action)) {
                if ($project->id == $cover->project_id) {
                    echo "<option value='{$project->id}' selected='selected'>{$project->title}</option>";
                } else {
                    echo "<option value='{$project->id}'>{$project->title}</option>";
                }
            } else {
                echo "<option value='{$project->id}'>{$project->title}</option>";
            }
        }
        ?>
							</select>
						</td>
					</tr>
					
					<tr class="form-field">
						<th scope="row"><label for="volume">Volume</label></th>
						<td><input name="volume" id="volume" type="number" value="<?php 
        if (isset($cover)) {
            echo $cover->volume;
        } else {
            echo '0';
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
 autofocus></td>
					</tr>
					
					<tr class="form">
						<th scope="row"><label for="image">Image <span class="description">(required)</span></label></th>
						<td><input id="image" type="url" name="image" class="upload" size="66" placeholder="Enter an URL or upload an image cover for this volume." value="<?php 
        if (isset($cover)) {
            echo $cover->image;
        }
        ?>
"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
 required><input class="<?php 
        if ($action != 'delete') {
            echo 'upload_image_button';
        }
        ?>
" type="button" value="Upload Image"<?php 
        if ($action == 'delete') {
            echo ' readonly="readonly"';
        }
        ?>
></td>
					</tr>
				</table>
				
				<p class="submit">
					<input type="submit" class="button-primary" name="save" value="<?php 
        echo ucfirst($action);
        ?>
 Volume Cover" />
					<input type="hidden" name="wpmanga_nonce" value="<?php 
        echo wp_create_nonce(plugin_basename(plugin_sDIR() . '/wpmanga.php'));
        ?>
" />
				</p>
			</form>
		</div>
<?php 
    } else {
        ?>
		<script type="text/javascript">
			location.replace("admin.php?page=manga/project")
		</script>
<?php 
    }
}
예제 #6
0
/**
 * Returns the Thumbnail Generated for the source and dimensions specified.
 * @param string $dimensions The dimensions of the thumbnail generated by WIDTHxHEIGHT.
 * @param string $limit The original source of the thumbnail.
 * @return string
 */
function get_sThumbnail($dimensions, $source = NULL)
{
    if ($source != NULL && file_exists(plugin_sDIR() . 'cache/' . $dimensions . '__' . basename($source))) {
        return plugin_sURL() . 'cache/' . $dimensions . '__' . basename($source);
    } else {
        return plugin_sURL() . 'images/__blank.png';
    }
}