| Server IP : 10.200.247.200 / Your IP : 216.73.217.19 Web Server : Apache System : Linux synergy-usa-sites 6.8.0-138-generic #138-Ubuntu SMP PREEMPT_DYNAMIC Fri Jul 31 22:41:49 UTC 2026 x86_64 User : jeremy ( 1001) PHP Version : 8.4.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : OFF Directory : /var/www/usa_sites/usagrantapplications.org/vsa/boxes/ |
Upload File : |
<?php
/*
Copyright (c) 2007-present InnAnTech Industries
Author: Dave Guindon
Web: www.VirtualSmartAgent.com
Support: www.DaveGuindonSupport.com
Please send bug reports, suggestions and/or feedback to the support
website given above.
Virtual Smart Agent is a commercial software. Any distribution is strictly prohibited
unless a resale rights license was delivered along with this software.
*/
include('../modfiles/db.php');
include('../globals.php');
include('boxfunctions.php');
//some vars
$buttonstyle = 'style="width: 130px"';
$cancelstyle = 'style="width: 55px"';
//get posted data
$cid = $_GET['cid'];
if ($_POST['actionbutton']){
//get posted campaign id
$cid = $_POST['cid'];
//check php's built-in errors
$err = '';
if ($_FILES['ssimportfile']['error'] == 1){
$err[] = "php.ini max file size exceeded.";
}else if ($_FILES['ssimportfile']['error'] == 2){
$err[] = "html form max file size exceeded.";
}else if ($_FILES['ssimportfile']['error'] == 3){
$err[] = "file upload was only partial.";
}else if ($_FILES['ssimportfile']['error'] == 4){
$err[] = "no file was attached.";
}
//check if the file was uploaded via HTTP POST
if (!is_uploaded_file($_FILES['ssimportfile']['tmp_name'])) {
$err[] = "not an HTTP upload.";
}
//validate the type of file input. Only accept .vbk file
$fname = $_FILES['ssimportfile']['name'];
$fname = strtolower($fname);
if (strpos($fname,'.vbk') !== false){
//nothing
}else{
$err[] = "the file does not appear to be a Virtual Smart Agent backup file";
}
//get the contents of the uploaded file
$file = fopen ($_FILES['ssimportfile']['tmp_name'], "r");
if (!$file) {
echo "<p>Unable to open file.\n";
echo "<br><br><a href='../index.php' target='_parent'>close</a>";
exit;
}
$lines = '';
while (!feof ($file)) {
//$s = fgets ($file, 4096);
$s = fgets ($file, 8192);
if ($s != ''){
$lines[]=$s;
}
}
fclose($file);
$conn = mysql_connect("$dbhost", "$dblogin", "$dbpass") or die ('I cannot connect to the database.');
mysql_select_db($dbname, $conn);
//search and replace id codes
$codes='';
if ($lines != ''){
foreach($lines as $sql){
if($sql != ''){
//insert campaigns first
if (strpos($sql,$campaignTable) !== false){
//grab the code
$p = strpos($sql,'INSERT');
$thecode = substr($sql,0,$p);
$sql = substr($sql,$p,strlen($sql)-$p);
//enter this campaign id
mysql_query($sql,$conn); if (mysql_error()){ $err[] = mysql_error(); break; }
//get the id
$thisres = mysql_query("SELECT LAST_INSERT_ID()",$conn);if (mysql_error()){ $err[] = mysql_error(); break; }
$tmprec = mysql_fetch_row($thisres);
$lastid = $tmprec[0];
//store codes
$codes[$lastid] = $thecode;
}else{
//replace codes with new cids
foreach($codes as $key=>$value){
$sql = str_replace($value, $key, $sql);
}
//insert into corresponding db table
mysql_query($sql,$conn); if (mysql_error()){ $err[] = mysql_error(); break; }
}//end if strpos
}//end if $sql
}//end foreach
}//end of if lines
//show errors
if ($err !== ''){
$show = 'There were errors with the data you are trying to input:<br />';
$show .= '<ul>';
foreach($err as $value){
$show .= '<li>'.$value.'</li>';
}
$show .= '</ul><br />';
$show .= '<a href="campaignimportbox.php?cid='.$cid.'">Click Here to Go Back</a>';
$show = '<span style="color: #FF0000">'.$show.'</span>';
}else{
$show = '<p style="color: #0000FF">The given campaign has been successfully imported. </p>';
$show .= '<p style="color: #0000FF"><b>NOTE:</b> Make sure to add agents for the imported campaigns<br>';
$show .= 'using the "AGENTS" section of the control panel.<br>';
$show .= 'By default there are no agents for all imported campaigns.</p>';
$show .= '<a href="../index.php?ncid='.$cid.'" target="_parent">click here to continue</a>';
}
//wrap html in a table and hide the input table
$show = '<table width="100%" cellspacing="0" cellpadding="10"><tr><td>'.$show.'</td></tr></table>';
$hide1 = '<!--';
$hide2 = '-->';
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<LINK href="style.css" type=text/css rel=stylesheet>
<title>campaign</title>
</head>
<body>
<?php echo $show; ?>
<?php echo $hide1; ?>
<form action="campaignimportbox.php" method="post" enctype="multipart/form-data">
<input type="hidden" name="cid" value="<?php echo $cid; ?>" />
<table width="350" border="0" align="center" cellpadding="10" cellspacing="0">
<tr>
<td><table width="100%" border="0" cellspacing="1" cellpadding="2">
<tr>
<td width="100%" valign="top"><div align="center"><strong>Import Campaign</strong></div></td>
</tr>
<tr>
<td valign="top" bgcolor="#E9E9E9"><div align="center">VSA .vbk backup files only</div></td>
</tr>
<tr>
<td valign="top" bgcolor="#E9E9E9"><div align="center">
<input type="file" name="ssimportfile" size="40" />
</div></td>
</tr>
<tr>
<td bgcolor="#E9E9E9"><table align="center" width="100" border="0" cellspacing="0" cellpadding="2">
<tr>
<td><div align="left">
<input type="submit" name="actionbutton" value="Import Campaign" <?php echo $buttonstyle; ?> />
</div></td>
<td><div align="right">
<input type="submit" id="Login" value="Cancel" onclick="self.parent.tb_remove();" <?php echo $cancelstyle; ?> />
</div></td>
</tr>
</table></td>
</tr>
</table>
</td>
</tr>
</table>
</form>
<?php echo $hide2; ?>
</body>
</html>