File: //home/httpd/mech_ftp/baretube.com/admin/csv_stats.php
<?
include_once "./db.php";
if (!isset($_SESSION['isAdmin'])) {
die();
}
if (isset($_GET['csv_reset']) || isset($_GET['csv_start'])) {
ini_set('default_socket_timeout', 24000);
ignore_user_abort();
shell_exec("pkill -f csv_cron.php");
dbQuery("UPDATE `status` SET `csv_import_running` = 0, `csv_import_total` = 0", false);
$pid = backgroundProcess("$php_path $basepath/admin/csv_cron.php", "csv_log.txt");
setMessage('CSV Importer has been ' . ($_GET['csv_reset'] ? 're' : '') . 'started as PID: ' . $pid);
header("Location: $_SERVER[HTTP_REFERER]");
exit();
}
$csvImportStatus = dbRow("SELECT * FROM `status`");
$csvImportLeftCount = dbValue("SELECT COUNT(`record_num`) AS `count` FROM `csv_import`", 'count');
$csvImportPercent = ($csvImportLeftCount > 0 && $csvImportStatus['csv_import_total'] > 0) ? round((($csvImportStatus['csv_import_total'] - $csvImportLeftCount) / $csvImportStatus['csv_import_total']) * 100) : 0;
?>
<? if ($csvImportStatus['csv_import_running'] == 1) { ?>
<h2>CSV Import</h2>
<div class="content">
<div class="msg success">CSV Import is currently running!</div>
<div class="progress-bar<? echo $csvImportPercent <= 20 ? ' short' : ''; ?>"><span style="width:<?php echo $csvImportPercent; ?>%;"><i><? echo $csvImportPercent; ?>%</i></span></div>
<div class="queue-processing">Processing Video: <b><? echo $csvImportStatus['csv_import_total'] - $csvImportLeftCount; ?></b> of <b><? echo $csvImportStatus['csv_import_total']; ?></b></div>
<a href="<? echo $basehttp; ?>/admin/csv_stats.php?csv_reset=1" class="btn red">Reset CSV Import</a>
</div>
<? } else if ($csvImportLeftCount > 0) { ?>
<h2>CSV Import</h2>
<div class="content">
<div class="msg error">CSV Import is not running!</div>
<div class="queue-processing">Videos in Queue: <b><? echo $csvImportLeftCount; ?></b></div>
<a href="<? echo $basehttp; ?>/admin/csv_stats.php?csv_start=1" class="btn red">Start CSV Import</a>
</div>
<? } ?>