$json_string = '{ "errors" : "' . $msg . '", "updated_category_id" : ' . $_POST['category_id'] . '}'; } catch (PAException $e) { $json_string = '{ "is_error" : true, "errors" : "' . $e->message . '"}'; } print $json_string; /** * Creating a new link under the list */ } else { if (!empty($_POST) && $_POST['form_action'] == 'create_link') { //TODO: check for empty fields $Links = new Links(); $Links->user_id = $_SESSION['user']['id']; $Links->category_id = $_POST['category_id']; $Links->title = $_POST['title']; $Links->url = Validation::validate_url($_POST['url']); try { $Links->save_link(); $json_string = '{ "errors" : "Link has been added successfully", "updated_category_id" : ' . $_POST['category_id'] . '}'; } catch (PAException $e) { $json_string = '{ "is_error" : true, "errors" : "' . $e->message . '"}'; } print $json_string; } else { if (!empty($_POST) && $_POST['form_action'] == 'remove_list') { $Links = new Links(); $Links->user_id = $_SESSION['user']['id']; $Links->category_id = $_POST['category_id']; try { $Links->delete_category(true); $json_string = '{ "errors" : "List has been deleted successfully"}';
} } else { if ($section == 'server_announcement') { /* $networks_data['announcement_image_url'] = @$_POST['video_url']; $networks_data['importance'] = $_POST['importance']; $networks_data['description1'] = $_POST['description1']; $networks_data['description2'] = $_POST['description2']; $networks_data['description3'] = $_POST['description3']; */ for ($counter = 0; $counter < $announcements; $counter++) { if (empty($_POST['network_url'][$counter])) { $message[] = __('Network URL cannot be left empty for showcased network ') . ($counter + 1); $networks_data[$counter]['network_url'] = null; } else { $networks_data[$counter]['network_url'] = Validation::validate_url($_POST['network_url'][$counter]); } if (!empty($_POST['caption'][$counter])) { $networks_data[$counter]['caption'] = $_POST['caption'][$counter]; } else { $networks_data[$counter]['caption'] = null; } $image_file = 'network_image_' . $counter; if (!empty($_FILES[$image_file]['name'])) { //validating and then uploading the network image. $uploader = new FileUploader(); //creating instance of file. $file = $uploader->upload_file(PA::$upload_path, $image_file, true, true, 'image'); if ($file == false) { $message[] = __(' For showcased network ') . ($counter + 1) . ', ' . $uploader->error; $networks_data[$counter]['network_image'] = null;
public static function split_trackbacks($tblist) { $track = array(); foreach (explode(" ", $tblist) as $tb) { $t = Validation::validate_url(trim($tb)); if ($t) { $track[] = $t; } } return $track; }
function initializeModule($request_method, $request_data) { global $error_msg; $error = false; $msg = array(); $form_data = NULL; $edit = false; $message = NULL; // check permissions! $user_may = false; $user_may = PermissionsHandler::can_user(PA::$login_uid, array('permissions' => 'manage_ads')); // check for manageads of group permissions if (!empty($_REQUEST['gid']) && !$user_may) { // we do this checl only if the user is not already permitted to manage ads $gp_access = PermissionsHandler::can_group_user(PA::$login_uid, $_REQUEST['gid'], array('permissions' => 'manage_ads')); $user_may = $gp_access; } if (!$user_may) { $error_msg = __("You do not have permission to manage Ads."); return "skip"; } // paging if (!empty($request_data['page'])) { $this->Paging["page"] = (int) $request_data['page']; } if (!empty($request_data['action']) && $request_data['action'] == 'edit' && !empty($request_data['ad_id'])) { $edit = TRUE; $res = Advertisement::get($params = NULL, $condition = array('ad_id' => (int) $request_data['ad_id'])); if (!empty($res)) { $form_data['ad_id'] = $res[0]->ad_id; $form_data['ad_image'] = $res[0]->ad_image; $form_data['ad_script'] = $res[0]->ad_script; $form_data['ad_url'] = $res[0]->url; $form_data['ad_title'] = $res[0]->title; $form_data['ad_description'] = $res[0]->description; $form_data['ad_page_id'] = $res[0]->page_id; $form_data['orientation'] = $res[0]->orientation; $form_data['created'] = $res[0]->created; } } else { if (!empty($request_data['action']) && $request_data['action'] == 'delete' && !empty($request_data['ad_id'])) { if (!empty($request_data['ad_id'])) { try { Advertisement::delete((int) $request_data['ad_id']); $error_msg = 19013; } catch (CNException $e) { $msg[] = $e->message; } } } else { if (!empty($request_data['action']) && !empty($request_data['ad_id'])) { $update = false; switch ($request_data['action']) { case 'disable': $field_value = DELETED; $msg_id = 19010; $update = true; break; case 'enable': $field_value = ACTIVE; $msg_id = 19011; $update = true; break; } if ($update) { $update_fields = array('is_active' => $field_value); $condition = array('ad_id' => $request_data['ad_id']); try { Advertisement::update($update_fields, $condition); $error_msg = $msg_id; } catch (CNException $e) { $msg[] = $e->message; } } } } } $advertisement = new Advertisement(); if (!$error && $request_method == 'POST' && $request_data['btn_apply_name']) { // if page is submitted if (!empty($request_data['ad_id'])) { $advertisement->ad_id = $request_data['ad_id']; $advertisement->created = $request_data['created']; $msg_id = 19007; } else { $msg_id = 19008; $advertisement->created = time(); } if (!empty($_FILES['ad_image']['name'])) { $filename = $_FILES['ad_image']['name']; $uploadfile = PA::$upload_path . basename($filename); $myUploadobj = new FileUploader(); $file = $myUploadobj->upload_file(PA::$upload_path, 'ad_image', TRUE, TRUE, 'image'); $advertisement->ad_image = $form_data['ad_image'] = $file; if ($file == FALSE) { $error = TRUE; $msg[] = $myUploadobj->error; } } else { if (!empty($request_data['ad_id'])) { $advertisement->ad_image = $request_data['edit_image']; } } if (empty($request_data['ad_url']) && empty($request_data['ad_script'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19012); } if (!empty($request_data['ad_url'])) { // if url is given then validate $request_data['ad_url'] = Validation::validate_url($request_data['ad_url']); if (!Validation::isValidURL($request_data['ad_url'])) { $error = TRUE; $msg[] = MessagesHandler::get_message(19009); } } $advertisement->user_id = PA::$login_uid; $advertisement->url = $form_data['ad_url'] = $request_data['ad_url']; $advertisement->ad_script = $form_data['ad_script'] = $request_data['ad_script']; $advertisement->title = $form_data['ad_title'] = $request_data['ad_title']; $advertisement->description = $form_data['ad_description'] = $request_data['ad_description']; $advertisement->page_id = $form_data['ad_page_id'] = $request_data['ad_page_id']; $advertisement->orientation = $form_data['orientation'] = $request_data['x_loc'] . ',' . $request_data['y_loc']; $advertisement->changed = time(); $advertisement->is_active = ACTIVE; if (!empty($_REQUEST['gid'])) { $advertisement->group_id = (int) $_REQUEST['gid']; } if (!$error) { try { $ad_id = $advertisement->save(); if (!empty($file)) { Storage::link($file, array("role" => "ad", "ad" => $ad_id)); } $error_msg = $msg_id; } catch (CNException $e) { $error_msg = $e->message; } } else { $error_msg = implode("<br/>", $msg); } } $this->form_data = $form_data; $this->edit = $edit; $this->message = $message; }
function validate_url($url) { return Validation::validate_url($url); }
$networks_data[$counter]['network_image'] = null; } } } //end for } else { if ($section == 'network_of_moment') { if (empty($_POST['network_caption'])) { $message[] = 'No caption given to network of moment'; } else { $networks_data['network_caption'] = $_POST['network_caption']; } if (empty($_POST['network_url'])) { $message[] = 'Please provide url for network of moment'; } else { $networks_data['network_url'] = Validation::validate_url($_POST['network_url']); } } else { if ($section == 'video_tours') { if (empty($_POST['video_url'])) { $message[] = 'No video url provided for video tours'; } else { $networks_data['video_url'] = $_POST['video_url']; } } else { if ($section == 'server_announcement') { $networks_data['announcement_image_url'] = @$_POST['video_url']; } else { if ($section == 'configure') { if (!empty($_POST['show_splash_page']) && $_POST['show_splash_page'] == ACTIVE) { $networks_data['show_splash_page'] = ACTIVE;