Much thanks for your reply.
Yes, I agree with your logic. Although I understand it is a general purpose example, and I have to figure out how to incorporate that into the existing script, maybe you can guide me as to which php file it should be added to, the ajax/edit.php file?:
<?php
if (IS_LOGGED == false) {
$data = array('status' => 400, 'error' => 'Not logged in');
echo json_encode($data);
exit();
}
if (empty($_POST['title']) || empty($_POST['description']) || empty($_POST['tags']) || empty($_POST['video-id'])) {
$error = $lang->please_check_details;
}
if (($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'pro_users' && $pt->user->is_pro) || ($pt->config->sell_videos_system == 'on' && $pt->config->who_sell == 'users') || ($pt->config->sell_videos_system == 'on' && $pt->user->admin)) {
if (!empty($_POST['set_p_v']) || $_POST['set_p_v'] < 0) {
if (!is_numeric($_POST['set_p_v']) || $_POST['set_p_v'] < 0 || (($pt->config->com_type == 0 && $_POST['set_p_v'] <= $pt->config->admin_com_sell_videos)) ) {
$error = $lang->video_price_error." ".($pt->config->com_type == 0 ? $pt->config->admin_com_sell_videos : 0);
}
}
}
if (PT_IsAdmin()) {
if (!empty($_POST['assign_to_user'])) {
$id = PT_Secure($_POST['video-id']);
$username_ = PT_Secure($_POST['assign_to_user']);
$user_ = $db->where('username', $username_)->getOne(T_USERS);
if (!empty($user_)) {
$db->where('id', $id)->update(T_VIDEOS, array('user_id' => $user_->id));
}
else{
$error = $lang->user_not_exists;
}
}
}
if (empty($error)) {
$id = PT_Secure($_POST['video-id']);
$video = $db->where('id', $id)->getOne(T_VIDEOS);
$can_update = false;
if (PT_IsAdmin() == false) {
if ($db->where('user_id', $user->id)->where('id', $id)->getValue(T_VIDEOS, 'count(*)') > 0) {
$can_update = true;
}
} else {
$can_update = true;
}
if (!empty($_POST['set_p_v']) && $video->sell_video == 0) {
$can_update = false;
}
if ($can_update == true && !empty($video)) {
$video = PT_GetVideoByID($video, 0, 0, 0);
$thumbnail = $video->org_thumbnail;
if (!empty($_FILES['thumbnail']['tmp_name'])) {
$file_info = array(
'file' => $_FILES['thumbnail']['tmp_name'],
'size' => $_FILES['thumbnail']['size'],
'name' => $_FILES['thumbnail']['name'],
'type' => $_FILES['thumbnail']['type'],
'allowed' => 'jpg,png,jpeg,gif',
'crop' => array(
'width' => 1076,
'height' => 604
)
);
$file_upload = PT_ShareFile($file_info);
if (!empty($file_upload['filename'])) {
$thumbnail = PT_Secure($file_upload['filename']);
}
}
$category_id = 0;
if (!empty($_POST['category_id'])) {
if (in_array($_POST['category_id'], array_keys(get_object_vars($pt->categories)))) {
$category_id = PT_Secure($_POST['category_id']);
}
}
$link_regex = '/(http\:\/\/|https\:\/\/|www\.)([^\ ]+)/i';
$i = 0;
preg_match_all($link_regex, PT_Secure($_POST['description']), $matches);
foreach ($matches[0] as $match) {
$match_url = strip_tags($match);
$syntax = '[a]' . urlencode($match_url) . '[/a]';
$_POST['description'] = str_replace($match, $syntax, $_POST['description']);
}
$featured = $video->featured;
if (isset($_POST['featured']) && PT_IsAdmin()) {
$featured = PT_Secure($_POST['featured']);
}
$video_privacy = 0;
if (!empty($_POST['privacy'])) {
if (in_array($_POST['privacy'], array(0, 1, 2))) {
$video_privacy = PT_Secure($_POST['privacy']);
}
}
$age_restriction = 1;
if (!empty($_POST['age_restriction'])) {
if (in_array($_POST['age_restriction'], array(1, 2))) {
$age_restriction = PT_Secure($_POST['age_restriction']);
}
}
$sub_category = 0;
if (!empty($_POST['sub_category_id'])) {
$is_found = $db->where('type',PT_Secure($_POST['category_id']))->where('lang_key',PT_Secure($_POST['sub_category_id']))->getValue(T_LANGS,'COUNT(*)');
if ($is_found > 0) {
$sub_category = PT_Secure($_POST['sub_category_id']);
}
}
$continents_list = array();
if (!empty($_POST['continents-list'])) {
foreach ($_POST['continents-list'] as $key => $value) {
if (in_array($value, $pt->continents)) {
$continents_list[] = $value;
}
}
}
$video_play_price = floatval(PT_Secure($_POST['video_play_price']));
if ( $video_play_price < $config['video_play_price'] ) {
$video_play_price = $config['video_play_price'];
}
$data_update = array(
'title' => PT_Secure($_POST['title']),
'description' => PT_Secure($_POST['description']),
'tags' => PT_Secure($_POST['tags']),
'category_id' => $category_id,
'featured' => $featured,
'thumbnail' => $thumbnail,
'privacy' => $video_privacy,
'age_restriction' => $age_restriction,
'sub_category' => $sub_category,
'geo_blocking' => json_encode($continents_list),
'video_play_price' => $video_play_price,
);
if (!empty($_POST['set_p_v']) && is_numeric($_POST['set_p_v']) && $_POST['set_p_v'] > 0) {
$data_update['sell_video'] = PT_Secure($_POST['set_p_v']);
}
$update = $db->where('id', $id)->update(T_VIDEOS, $data_update);
if ($update) {
$data = array(
'status' => 200,
'message' => $success_icon . $lang->video_saved
);
}
}
} else {
$data = array(
'status' => 400,
'message' => $error_icon . $error
);
}
?>
or the sources/edit.php file?:
<?php
if (IS_LOGGED == false) {
header("Location: " . PT_Link('login'));
exit();
}
if (empty($_GET['id'])) {
header("Location: " . PT_Link('login'));
exit();
}
$id = PT_Secure($_GET['id']);
$video = $db->where('id', $id)->getOne(T_VIDEOS);
if (empty($video)) {
header("Location: " . PT_Link('login'));
exit();
}
if (!PT_IsAdmin()) {
if (empty($db->where('id', $id)->where('user_id', $user->id)->getValue(T_VIDEOS, 'count(*)'))) {
header("Location: " . PT_Link('login'));
exit();
}
}
$video = PT_GetVideoByID($video, 0, 0, 0);
$pt->video = $video;
$pt->page = 'edit-video';
$pt->title = $lang->edit_video . ' | ' . $pt->config->title;
$pt->description = $pt->config->description;
$pt->keyword = $pt->config->keyword;
$min_price=$config[‘video_play_price’];
$temp_price = $videos[‘video_play_price’];
if ($temp_price<$min_price) { $temp_price = $min_price;}
$pt->content = PT_LoadPage('edit-video/content', array(
'ID' => $video->id,
'USER_DATA' => $video->owner,
'THUMBNAIL' => $video->thumbnail,
'URL' => $video->url,
'TITLE' => $video->title,
'DESC' => br2nl($video->edit_description),
'DESC_2' => $video->markup_description,
'VIEWS' => $video->views,
'TIME' => $video->time_ago,
'TAGS' => $video->tags,
'video_play_price_user' => number_format( $video->video_play_price < $config['video_play_price'] ? $config['video_play_price'] : $video->video_play_price)
));
Any additional assistance is appreciated