$data = $app->request->post();
     $data = escape($data);
     $j = new Jobs($id);
     $job = $j->getJobFromToken($token);
     $data['is_featured'] = isset($data['is_featured']) ? 1 : 0;
     if ($data['trap'] != '') {
         $app->redirect(ADMIN_URL . "jobs/new");
     }
     if (isset($_FILES['logo']) && $_FILES['logo']['name'] != '') {
         $file = $_FILES['logo'];
         $path = IMAGE_PATH;
         $data['logo'] = time() . '_' . $file['name'];
         $data['logo_type'] = $file['type'];
         $data['logo_size'] = $file['size'];
         $ext = strtolower(pathinfo($data['logo'], PATHINFO_EXTENSION));
         if (move_uploaded_file($file['tmp_name'], "{$path}{$data['logo']}") && isValidImageExt($ext)) {
             $resize = new ResizeImage("{$path}{$data['logo']}");
             $resize->resizeTo(LOGO_H, LOGO_W);
             $resize->saveImage("{$path}thumb_{$data['logo']}");
         }
     } else {
         $data['logo'] = $job->logo;
     }
     $data['step'] = 3;
     $j->jobCreateUpdate($data, ACTIVE);
     $app->redirect(ADMIN_URL . "jobs/{$id}/publish/{$token}");
 });
 // get publish job details
 $app->get('/:id/publish/:token', 'validateUser', function ($id, $token) use($app) {
     $j = new Jobs($id);
     $job = $j->getJobFromToken($token);
Example #2
0
 public function add_new_step_four($url_key)
 {
     $data = array();
     $user_id = $this->session->userdata["user_id"];
     $model = new Common_model();
     $trip_details = $this->redis_functions->get_trip_details($url_key);
     $post_title = stripslashes($trip_details['post_title']);
     $post_id = $trip_details['post_id'];
     if ($this->input->post() && isset($user_id)) {
         $arr = $this->input->post();
         // To update existing media data
         if (!empty($arr['existing_media_id']) && isset($arr['existing_media_id'])) {
             foreach ($arr['existing_media_id'] as $existing_key => $existing_value) {
                 $pm_id = getEncryptedString($existing_value, 'decode');
                 $pm_media_title = addslashes($arr['existing_media_title'][$existing_key]);
                 $model->updateData(TABLE_POST_MEDIA, array('pm_media_title' => $pm_media_title), array('pm_post_id' => $post_id, 'pm_id' => $pm_id));
             }
         }
         // To upload fresh/new selected media
         if (!empty($arr['media_type']) && isset($arr['media_type'])) {
             foreach ($arr['media_type'] as $key => $media_type) {
                 $media_filename = NULL;
                 $image_i = 0;
                 if ($media_type == 'image') {
                     $file_tmpSource = $_FILES['media_image']['tmp_name'][$key];
                     if (!empty($file_tmpSource) && isset($file_tmpSource)) {
                         $ext = getFileExtension($_FILES['media_image']['name'][$key]);
                         if (isValidImageExt($ext)) {
                             $random_number = rand(1000, 9999999);
                             $media_filename = str_replace('//', '/', $this->redis_functions->get_site_setting('POST_IMAGE_PATH') . $url_key . '-' . $random_number . '.' . $ext);
                             if (uploadImage($file_tmpSource, $media_filename, $this->redis_functions->get_site_setting('POST_IMAGE_WIDTH'), $this->redis_functions->get_site_setting('POST_IMAGE_HEIGHT'))) {
                                 $new_filename = NULL;
                             }
                         }
                     }
                     $image_i++;
                 } elseif ($media_type == 'video') {
                     if (!empty($arr['media_video'][$key])) {
                         $media_filename = $arr['media_video'][$key];
                     }
                 }
                 // inserting data here
                 if ($media_filename != NULL) {
                     $data_array = array('pm_post_id' => $post_id, 'pm_primary' => $image_i == 1 && strtolower($media_type) == 'image' ? '1' : '0', 'pm_media_type' => strtolower($media_type), 'pm_media_title' => addslashes($arr['media_type']), 'pm_media_url' => $media_filename, 'pm_ipaddress' => USER_IP, 'pm_useragent' => USER_AGENT, 'pm_created_on' => date('Y-m-d H:i:s'));
                     $model->insertData(TABLE_POST_MEDIA, $data_array);
                 }
             }
         }
         // setting post details to redis
         $this->redis_functions->set_trip_details($url_key);
         redirect(base_url('trip/review/' . $url_key));
     } else {
         $input_arr = array(base_url() => 'Home', base_url('trips') => 'Trips', '#' => $post_title);
         $breadcrumbs = get_breadcrumbs($input_arr);
         $data["breadcrumbs"] = $breadcrumbs;
         $data["post_records"] = $trip_details;
         $data["page_title"] = $post_title;
         $data['meta_title'] = $data["page_title"] . ' - ' . $this->redis_functions->get_site_setting('SITE_NAME');
         $this->template->write_view("content", "pages/trip/post/step-4", $data);
         $this->template->render();
     }
 }