function uploadMyPhoto()
 {
     $title = $this->input->post('title');
     $price = round($this->input->post('price'), 2);
     $myPhoto = '';
     if (!$price or $price <= 0) {
         echo "Price must greater than 0.";
         exit;
     }
     $uploadDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_orig'] . "photos/";
     $thumbnailDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_thumb'] . "photos/";
     $thumb_height = $GLOBALS['global']['IMAGE']['thumb_height'];
     $thumb_width = $GLOBALS['global']['IMAGE']['thumb_width'];
     $orig_width = $GLOBALS['global']['IMAGE']['orig_width'];
     $orig_height = $GLOBALS['global']['IMAGE']['orig_height'];
     if (isset($_FILES["my_photo"]) and !empty($_FILES["my_photo"]['name'])) {
         if ($_FILES["my_photo"]['size'] / 1000000 > allowMaxFileSize()) {
             $myPhoto = '';
         } else {
             $myPhoto = $this->module_helper->uploadFile($_FILES["my_photo"]['tmp_name'], $_FILES["my_photo"]['name'], $uploadDir, allowExtensionPictureUpload());
         }
     }
     if (!$myPhoto) {
         echo "Upload picture failure.";
         exit;
     } else {
         copy($uploadDir . $myPhoto, $thumbnailDir . $myPhoto);
         //chmod( $thumbnailDir.$myPhoto, 0777 );
         makeThumb($myPhoto, $uploadDir, $orig_width, $orig_height);
         makeThumb($myPhoto, $thumbnailDir, $thumb_width, $thumb_height);
         $data['image'] = $myPhoto;
         $data['id_user'] = getAccountUserId();
         $data['image_type'] = $GLOBALS['global']['IMAGE_STATUS']['private'];
         $data['price'] = $price;
         $data['comment'] = $title;
         $data['prof_flag'] = 0;
         $data['v_count'] = 0;
         $data['rate_num'] = 0;
         $data['rating'] = 0;
         $data['added_date'] = mysqlDate();
         $id_photo = $this->gallery_io_m->insert_map($data);
         $array['id_parent'] = 0;
         $array['id_user'] = getAccountUserId();
         $array['description'] = "priced at {$price}J\$";
         $array['add_date_post'] = mysqlDate();
         $array['post_name'] = getAccountUserId() . '_' . filterCharacter($title);
         $array['post_id'] = $id_photo;
         $array['post_code'] = $GLOBALS['global']['CHATTER_CODE']['backstage_photo'];
         $id_wall = $this->mod_io_m->insert_map($array, TBL_WALL);
         $this->user_io_m->postItemOnFbTt($id_wall, TIMELINE_BACKSTAGE_PHOTO);
         $_SESSION['BACKSTAGE_PRICE'] = $price;
         echo 'ok';
         exit;
     }
     echo 'Unknown error';
     exit;
 }
 function saveGift()
 {
     $id_gift = intval($this->input->post('id_gift', 0));
     $giftdata = $this->mod_io_m->init('id_gift', $id_gift, TBL_GIFT);
     if ($giftdata) {
         $image = $giftdata->image;
     } else {
         $image = '';
     }
     $uploadDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_orig'] . 'gift/';
     $thumbnailDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_thumb'] . 'gift/';
     $thumb_height = 60;
     $thumb_width = 60;
     if (isset($_FILES["image"]) and !empty($_FILES["image"]['name'])) {
         if ($_FILES["image"]['size'] / 1000000 > allowMaxFileSize()) {
             $image = '';
         } else {
             $image = $this->module_helper->uploadFile($_FILES["image"]['tmp_name'], $_FILES["image"]['name'], $uploadDir, allowExtensionPictureUpload());
         }
     }
     if (!$image) {
         echo 'Image must not empty';
         exit;
     } else {
         copy($uploadDir . $image, $thumbnailDir . $image);
         makeThumb($image, $thumbnailDir, $thumb_width, $thumb_height);
         $data['image'] = $image;
     }
     if (!$this->phpvalidator->is_numeric($this->input->post('price'))) {
         echo 'Price must be numeric.';
         exit;
     } else {
         $data['price'] = $this->input->post('price');
     }
     if ($this->input->post('name_gift')) {
         $data['name_gift'] = $this->input->post('name_gift');
         $data['code_gift'] = slugify($this->input->post('name_gift'));
     }
     $data['ip'] = $this->geo_lib->getIpAddress();
     $data['description'] = $this->input->post('description');
     $data['id_category'] = $this->input->post('category');
     $data['status'] = $this->input->post('status');
     if ($giftdata) {
         $data['last_update'] = mysqlDate();
         $this->mod_io_m->update_map($data, array('id_gift' => $id_gift), TBL_GIFT);
     } else {
         $data['add_date'] = mysqlDate();
         $this->mod_io_m->insert_map($data, TBL_GIFT);
     }
     echo 'ok';
     $this->session->set_flashdata('success', lang('templates.tmpl_save_success'));
     exit;
 }
 function uploadMyPhoto()
 {
     $title = $this->input->post('title');
     $myPhoto = '';
     $uploadDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_orig'] . "photos/";
     $thumbnailDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_thumb'] . "photos/";
     $thumb_height = $GLOBALS['global']['IMAGE']['thumb_height'];
     $thumb_width = $GLOBALS['global']['IMAGE']['thumb_width'];
     $orig_width = $GLOBALS['global']['IMAGE']['orig_width'];
     $orig_height = $GLOBALS['global']['IMAGE']['orig_height'];
     if (isset($_FILES["my_photo"]) and !empty($_FILES["my_photo"]['name'])) {
         if ($_FILES["my_photo"]['size'] / 1000000 > allowMaxFileSize()) {
             $myPhoto = '';
         } else {
             $myPhoto = $this->module_helper->uploadFile($_FILES["my_photo"]['tmp_name'], $_FILES["my_photo"]['name'], $uploadDir, allowExtensionPictureUpload());
         }
     }
     if (!$myPhoto) {
         echo "Upload picture failure.";
         exit;
     } else {
         copy($uploadDir . $myPhoto, $thumbnailDir . $myPhoto);
         //chmod( $thumbnailDir.$myPhoto, 0777 );
         makeThumb($myPhoto, $uploadDir, $orig_width, $orig_height);
         makeThumb($myPhoto, $thumbnailDir, $thumb_width, $thumb_height);
         $data['image'] = $myPhoto;
         $data['id_user'] = getAccountUserId();
         $data['image_type'] = $GLOBALS['global']['IMAGE_STATUS']['public'];
         $data['price'] = 0;
         $data['comment'] = $title;
         $data['prof_flag'] = 0;
         $data['v_count'] = 0;
         $data['rate_num'] = 0;
         $data['rating'] = 0;
         $data['added_date'] = mysqlDate();
         $this->gallery_io_m->insert_map($data);
         echo 'ok';
         exit;
     }
     echo 'Unknown error';
     exit;
 }
 function saveSeries()
 {
     $id_series = $this->input->post('id_series');
     $seriesdata = $this->mod_io_m->init('id_series', $id_series, TBL_SERIES);
     $data['id_hentai_category'] = $this->input->post('id_hentai_category');
     if ($data['id_hentai_category'] == 1) {
         //facebook
         $data['img_url'] = $this->input->post('img_url');
     } else {
         $uploadDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_orig'] . 'hentai/';
         $thumbnailDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_thumb'] . 'hentai/dailymotion/';
         $thumb_height = 160;
         $thumb_width = 120;
         if ($seriesdata) {
             $image = $seriesdata->image . '.jpg';
         } else {
             $image = '';
         }
         if (isset($_FILES["image"]) and !empty($_FILES["image"]['name'])) {
             if ($_FILES["image"]['size'] / 1000000 > allowMaxFileSize()) {
                 $image = '';
             } else {
                 $image = $this->module_helper->uploadFile($_FILES["image"]['tmp_name'], $_FILES["image"]['name'], $uploadDir, array('jpg'));
             }
         }
         if ($image) {
             copy($uploadDir . $image, $thumbnailDir . $image);
             makeThumb($image, $thumbnailDir, $thumb_width, $thumb_height);
             $data['image'] = substr($image, 0, strrpos($image, '.'));
         }
     }
     $data['name'] = $this->input->post('name');
     if ($seriesdata) {
         $this->mod_io_m->update_map($data, array('id_series' => $id_series), TBL_SERIES);
     } else {
         $this->mod_io_m->insert_map($data, TBL_SERIES);
     }
     echo 'ok';
     $this->session->set_flashdata('success', lang('templates.tmpl_save_success'));
     exit;
 }
defined('BASEPATH') or exit('No direct script access allowed');
?>

<?php 
echo form_open($action = site_url("mod_io/backstage_func/submit_my_photo"), $attributes = "method='post' id='submit_my_photo' name='submit_my_photo' ", $hidden = array());
?>

<div id="wrap-dialog-box">	
	<div class="input">
		Accept picture file format: <?php 
echo implode(', ', allowExtensionPictureUpload());
?>
 <br/>
		Maximum file size: <?php 
echo allowMaxFileSize();
?>
Mb.
	</div>
	
	<div class="input">
		<label><strong>&nbsp;</strong></label>
		<?php 
echo form_upload("my_photo");
?>
	</div>
	
	<div class="input" id="questionArea">
		<label><strong>Title:</strong></label>
		<input type="text" class="disablecopypaste" name="title" id="title" maxlength="45" value="" style="width:200px;" />
		
 function submitPhotoUpload()
 {
     $desc = $this->input->post('status');
     $photo = '';
     $uploadDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_orig'] . "photos/";
     $thumbnailDir = APP_ROOT . $GLOBALS['global']['IMAGE']['image_thumb'] . "photos/";
     $thumb_height = $GLOBALS['global']['IMAGE']['thumb_height'];
     $thumb_width = $GLOBALS['global']['IMAGE']['thumb_width'];
     $orig_width = $GLOBALS['global']['IMAGE']['orig_width'];
     $orig_height = $GLOBALS['global']['IMAGE']['orig_height'];
     if (isset($_FILES["photo"]) and !empty($_FILES["photo"]['name'])) {
         if ($_FILES["photo"]['size'] / 1000000 > allowMaxFileSize()) {
             $photo = '';
         } else {
             $photo = $this->module_helper->uploadFile($_FILES["photo"]['tmp_name'], $_FILES["photo"]['name'], $uploadDir, allowExtensionPictureUpload());
         }
     }
     if (!$photo) {
         echo "Upload picture failure.";
         exit;
     } else {
         copy($uploadDir . $photo, $thumbnailDir . $photo);
         //chmod( $thumbnailDir.$photo, 0777 );
         makeThumb($photo, $uploadDir, $orig_width, $orig_height);
         makeThumb($photo, $thumbnailDir, $thumb_width, $thumb_height);
         $data['image'] = $photo;
         $data['id_user'] = getAccountUserId();
         $data['image_type'] = $GLOBALS['global']['IMAGE_STATUS']['public'];
         $data['price'] = 0;
         $data['comment'] = $desc;
         $data['prof_flag'] = 0;
         $data['v_count'] = 0;
         $data['rate_num'] = 0;
         $data['rating'] = 0;
         $data['added_date'] = mysqlDate();
         $id_photo = $this->gallery_io_m->insert_map($data);
         $array['id_parent'] = 0;
         $array['id_user'] = getAccountUserId();
         $array['description'] = substr($desc, 0, $GLOBALS['global']['INPUT_LIMIT']['wall_status']);
         $array['add_date_post'] = mysqlDate();
         $array['post_id'] = $id_photo;
         $array['image'] = $photo;
         $this->mod_io_m->insert_map($array, TBL_WALL);
         echo 'ok';
         exit;
     }
     echo 'Unknown error';
     exit;
 }