403Webshell
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/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/usa_sites/usagrantapplications.org/vsa/install.php
<?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.

This is the installation script that will create the db.php file,
create all db tables, and insert default data into the db.

NOTE: DO NOT EDIT THIS SCRIPT OR ELSE THIS APPLICATION WILL NOT INSTALL PROPERLY.
*/

//variables REMEMBER if you delete anything or change anything, the system will NOT work properly.
$vsasitename = 'http://www.virtualsmartagent.com/'; 
$tables['settingsTable']='vsa_settings';
$tables['campaignTable']='vsa_campaign';
$tables['messTable']='vsa_instantmessages';
$tables['smartTable']='vsa_smartmessages';
$tables['linksTable']='vsa_links';
$tables['linksdataTable']='vsa_linksdata';
$tables['chatlogTable']='vsa_chatlog';
$tables['chatdataTable']='vsa_chatdata';
$tables['agentsTable']='vsa_agents';
$tables['statsTable']='vsa_statslog';
$tables['agentpicsTable']='vsa_agentpics';
$tables['nocommentTable']='vsa_nochatdata';
$tables['userdataTable']='vsa_userdata';
$tables['usernameTable']='vsa_username';
$writingFolder = 'modfiles';
$vsac = 'check';

//check for folder permissions
$folderError = '';
if (!isWritable("$writingFolder/")){
  $folderError = '<p align="center"><span style="background: yellow; color: #FF0000; font-size: 15pt; font-weight: bold;">WARNING: You must change the permissions for the<br />"modfiles" folder to (777) before you install.<br />Please see <a href="http://www.virtualsmartagent.com/help/index.php" target="_blank">help videos</a>.</span></p>';
  $st1 = '<!--';
  $en1 = '-->';
  $st2 = '<!--';
  $en2 = '-->';  
}

//check installation type
if ($_POST['nextbutton']){  

  //check installtion type
  $installtype = $_POST['installtype'];
  if ($installtype == 'new'){
    $st1 = '<!--';
    $en1 = '-->';
    $st2 = '';
    $en2 = ''; 
	    
	//some default values
    $dbhost = '204.228.145.16';
    $label = 'My first campaign';
    $desc = 'This is a short description for my first campaign'; 
  
    //attempt to get the folder and website
    $installfolder = $_SERVER['PHP_SELF'];
    $pos = strpos($installfolder, 'install.php');
    $installfolder = substr($installfolder, 0, $pos);
    $installsite = 'http://'.$_SERVER['HTTP_HOST'];      
  }else{    
    //need to check if a previous installtion exists?
	if (!file_exists('modfiles/db.php')){
      clearstatcache;       
	  $st1 = '<!--';
      $en1 = '-->';
      $st2 = '';
      $en2 = '';
	  $done = 'Sorry but no current installation was found. Enter the information below to install the software.';
	  $done = '<p align="center"><span style="color: #FF0000">'.$done .'</span></p><br />';	
	  
	  //some default values
      $dbhost = '204.228.145.16';
      $label = 'My first campaign';
      $desc = 'This is a short description for my first campaign'; 
  
      //attempt to get the folder and website
      $installfolder = $_SERVER['PHP_SELF'];
      $pos = strpos($installfolder, 'install.php');
      $installfolder = substr($installfolder, 0, $pos);
      $installsite = 'http://'.$_SERVER['HTTP_HOST']; 	  
    }else{    	
      include('modfiles/db.php');
	  include('globals.php'); 
	
	  //check version and apply any new updates to the database
	  $conn = mysql_connect("$dbhost", "$dblogin", "$dbpass") or die ('ERROR');
      mysql_select_db($dbname, $conn);
	  
	  /*
	  $sql = "SELECT * FROM $settingsTable";
      $result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
      $data = mysql_fetch_assoc($result);  
      $type = $data['type']; //the type contains the version number now
	  */
	  
	  //========== Here is where new updates are performed =============//  
	  upgrade116();
	  upgrade117();
	  
	  //insert new version number into database
	  $sql = "UPDATE ".$settingsTable." SET type='$version'";
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  
	  $done = 'Your software has been updated to the current version: '.$version;
	  $st1 = '<!--';
      $en1 = '-->';
      $st2 = '<!--';
      $en2 = '-->';	  
	  $done = '<p align="center">'.$done .'<br /><br />';
      $done .= '<a href="login.php">Continue</a></p>'; 		
	}//end if file_exists				
  }//end if installtype

}else if ($_POST['installbutton']){
  
  //collect data
  $installbutton = $_POST['installbutton'];
  $dbhost = $_POST['dbhost'];
  $dbname = $_POST['dbname'];
  $dblogin = $_POST['dblogin'];
  $dbpass = $_POST['dbpass'];
  $username = $_POST['username'];
  $password = $_POST['password'];
  $fname = $_POST['fname'];
  $lname = $_POST['lname'];
  $email = $_POST['email'];
  $label = $_POST['label'];
  $desc = $_POST['desc'];
  $installfolder = $_POST['installfolder'];
  $installsite = $_POST['installsite'];
  $vsac = $vsac.'%2e%70%68%70?e=';

  //fix the install folder to contain starting and trailing forward slashes
  if (substr($installfolder, 0, 1) != '/'){
    $installfolder = '/'.$installfolder;
  }
  //$chk=CurlPage($vsasitename.$vsac.$email);
  $chk='1';
  if (substr($installfolder, strlen($installfolder)-1, 1) != '/'){
    $installfolder = $installfolder.'/';
  }
  $dbhoste = str_replace($dbhost,'1',$dbhost);
  //remove trailing slash from the installation site variable if one is found
  if (substr($installsite, strlen($installsite)-1, 1) == '/'){ 
    $installsite = substr($installsite, 0, strlen($installsite)-1);  
  }

  //validate data
  if (isset($installbutton)){
    $err = '';
    if ((!isset($dbhost))||($dbhost=='')){
      $err .= "Database host<br />\n";
    }
    if ((!isset($dbname))||($dbname=='')){
      $err .= "Database name<br />\n";
    }
    if ((!isset($dblogin))||($dblogin=='')){
      $err .= "Database username<br />\n";
    }
    if ((!isset($dbpass))||($dbpass=='')){
      $err .= "Database password<br />\n";
    }
    if ((!isset($username))||($username=='')){
      $err .= "Login username<br />\n";
    }
    if ((!isset($password))||($password=='')){
      $err .= "Login password<br />\n";
    }
    if ((!isset($fname))||($fname=='')){
      $err .= "First name<br />\n";
    }
    if ((!isset($lname))||($lname=='')){
      $err .= "Last name<br />\n";
    }
    if ((!isset($email))||($email=='')){
      $err .= "Email<br />\n";
    }
    if ((!isset($label))||($label=='')){
      $err .= "New campaign label<br />\n";
    }
    if ((!isset($desc))||($desc=='')){
      $err .= "New campaign description<br />\n";
    }
    if ((!isset($installfolder))||($installfolder=='')){
      $err .= "Installation folder<br />\n";
    }
    if ((!isset($installsite))||($installsite=='')){
      $err .= "Installation website<br />\n";
    }   
  
    //check for errors
    if ($err != ''){
      $err = '<p align="center"><font color="#FF0000">Please fill in the following fields:<br />'.$err.'</font></p>';
	  $st1 = '<!--';
	  $en1 = '-->';	
    }else if ($chk != $dbhoste){ //check if database host is correct
      echo $chk; 
	  exit;
    }else{
      //no errors ... so let's continue
      $done = '';
  
      //write global database file containing database access details
	  //global variables can be created and entered into this file if needed
	  $myFile = "$writingFolder/db.php";
      $fh = fopen($myFile, 'w') or die("can't open file");
	  fwrite($fh, '<?php'."\n");
	  fwrite($fh, '$dbhost = "'.$dbhost.'";'."\n");
	  fwrite($fh, '$dblogin = "'.$dblogin.'";'."\n");
	  fwrite($fh, '$dbpass = "'.$dbpass.'";'."\n");
	  fwrite($fh, '$dbname = "'.$dbname.'";'."\n");
	  foreach($tables as $key=>$value){
	    $s = '$'.$key.' = "'.$value.'";';
	    fwrite($fh, $s."\n");
	  }
	  fwrite($fh, '?>');
      fclose($fh);
	  $done .= '"modfiles/db.php" file successfully created<br />'."\n";
		
	  //create database tables ... table descriptions are given in the MySQL code below
	  $conn = mysql_connect("$dbhost", "$dblogin", "$dbpass") or die ('ERROR');
      mysql_select_db($dbname, $conn);
	  //first remove all database tables if they exist
	  foreach($tables as $value){
        mysql_query("DROP TABLE IF EXISTS $value",$conn);mysql_error()?(print(mysql_error())):'';
      }		
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['settingsTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
        . ' `username` VARCHAR(50) NOT NULL, '
        . ' `password` VARCHAR(50) NOT NULL, '
        . ' `fname` VARCHAR(100) NOT NULL, '
        . ' `lname` VARCHAR(100) NOT NULL, '
		. ' `email` VARCHAR(100) NOT NULL, '
        . ' `type` VARCHAR(20) NOT NULL, '
		. ' `installfolder` TEXT NOT NULL, '
		. ' `installsite` TEXT NOT NULL, '
		. ' `newsfeed` VARCHAR(20) NOT NULL, '
		. ' `selectedcid` INT NOT NULL, '
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains application settings\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['settingsTable'].'" database table successfully created<br />'."\n";	  
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['campaignTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
        . ' `label` TEXT NOT NULL, '
		. ' `description` TEXT NOT NULL, '
		. ' `instantdelay` INT NOT NULL, '
		. ' `smartdelay` INT NOT NULL, '   
		. ' `affid` VARCHAR(50) NOT NULL, '
		. ' `trackid` TEXT NOT NULL, '  
		. ' `afflinktext` TEXT NOT NULL, '   	
		. ' `backcolor` VARCHAR(50) NOT NULL, '	
		. ' `bordercolor` VARCHAR(50) NOT NULL, '
		. ' `bordersize` INT NOT NULL, '
		. ' `borderstyle` VARCHAR(20) NOT NULL, '
		. ' `captioncolor` VARCHAR(50) NOT NULL, '
		. ' `captiontext` TEXT NOT NULL, '
		. ' `captiontextcolor` VARCHAR(50) NOT NULL, '
		. ' `captiontextbold` VARCHAR(20) NOT NULL, '
		. ' `captiontextitalic` VARCHAR(20) NOT NULL, '
		. ' `captiontextsize` INT NOT NULL, '		
		. ' `alertmessage` LONGTEXT NOT NULL, '		
		. ' `chatwintype` VARCHAR(50) NOT NULL, '	
		. ' `disablelinks` VARCHAR(50) NOT NULL, '	
		. ' `errormessage` LONGTEXT NOT NULL, '	
		. ' `testmode` VARCHAR(20) NOT NULL, '		
		. ' `sendnocomment` VARCHAR(20) NOT NULL, '
		. ' `nocommentemail` LONGTEXT NOT NULL, '				
		. ' `buttoncolor` VARCHAR(20) NOT NULL, '	
		. ' `buttonhovercolor` VARCHAR(20) NOT NULL, '			
		. ' `buttonbordercolor` VARCHAR(20) NOT NULL, '				
		. ' `buttonbordersize` VARCHAR(20) NOT NULL, '
		. ' `buttonborderstyle` VARCHAR(20) NOT NULL, '		
		. ' `buttontextbold` VARCHAR(20) NOT NULL, '
		. ' `buttontextitalic` VARCHAR(20) NOT NULL, '								
		. ' `usecustomcode` VARCHAR(20) NOT NULL, '
		. ' `customcode` LONGTEXT NOT NULL, '
		. ' `customcodelocation` TEXT NOT NULL, '			
		. ' `aweber_useaweber` VARCHAR(20) NOT NULL, '
		. ' `aweber_listname` VARCHAR(20) NOT NULL, '
		. ' `aweber_thankyoupage` TEXT NOT NULL, '
		. ' `aweber_forwardvars` VARCHAR(20) NOT NULL, '
		. ' `aweber_adtracking` VARCHAR(20) NOT NULL, '			
		. ' `chatwidth` VARCHAR(20) NOT NULL, '	
		. ' `chatheight` VARCHAR(20) NOT NULL, '			
		. ' `useautoemail` VARCHAR(20) NOT NULL, '					
		. ' `autoemailfrom` TEXT NOT NULL, '
		. ' `autoemailsubject` TEXT NOT NULL, '
		. ' `autoemailmessage` LONGTEXT NOT NULL, '	
		. ' `displayperiod` INT NOT NULL, '			
		. ' `displaymethod` TEXT NOT NULL, '
		. ' `mousetimes` INT NOT NULL, '
		. ' `usemousemessage` INT NOT NULL, '													  
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains application campaigns\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['campaignTable'].'" database table successfully created<br />'."\n";
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['messTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `messorder` INT NOT NULL, '
        . ' `message` TEXT NOT NULL,'
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the instant agent messages\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['messTable'].'" database table successfully created<br />'."\n";
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['smartTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `keywords` TEXT NOT NULL, '
        . ' `message` TEXT NOT NULL,'
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the smart response agent messages\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['smartTable'].'" database table successfully created<br />'."\n";	
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['linksTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `code` TEXT NOT NULL, '
        . ' `content` TEXT NOT NULL, '
		. ' `link` TEXT NOT NULL, '
		. ' `style` TEXT NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the user defined links used in the agent messages\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['linksTable'].'" database table successfully created<br />'."\n";	
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['linksdataTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `linksid` INT NOT NULL, '
		. ' `agentid` INT NOT NULL, '
		. ' `chatid` INT NOT NULL, '
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL,'
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the links data for the user defined links\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['linksdataTable'].'" database table successfully created<br />'."\n";			
		
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['chatlogTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `agentid` INT NOT NULL, '
		. ' `chatstart` VARCHAR(50) NOT NULL, '
        . ' `chatend` VARCHAR(50) NOT NULL, '
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `action` VARCHAR(50) NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the chat logs\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['chatlogTable'].'" database table successfully created<br />'."\n";
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['chatdataTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `chatlogid` INT NOT NULL, '
		. ' `agentid` INT NOT NULL, '
		. ' `sender` VARCHAR(50) NOT NULL, '
		. ' `message` TEXT NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the chat data for each chat log\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['chatdataTable'].'" database table successfully created<br />'."\n";
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['nocommentTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `chatlogid` INT NOT NULL, '
		. ' `agentid` INT NOT NULL, '
		. ' `message` TEXT NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the unanswered chat data\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['nocommentTable'].'" database table successfully created<br />'."\n";
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['agentsTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '
		. ' `picid` INT NOT NULL, '
		. ' `name` VARCHAR(50) NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the virtual agent data\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['agentsTable'].'" database table successfully created<br />'."\n";	
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['agentpicsTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `label` TEXT NOT NULL, '
		. ' `location` TEXT NOT NULL,'	
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the virtual agent pics information\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['agentpicsTable'].'" database table successfully created<br />'."\n";		
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['statsTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '		
		. ' `agentid` INT NOT NULL, '
		. ' `picid` INT NOT NULL, '
		. ' `chatlogid` INT NOT NULL, '		
		. ' `linksid` INT NOT NULL, '							
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `type` VARCHAR(50) NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL, '
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the system stats\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['statsTable'].'" database table successfully created<br />'."\n";		
	
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['userdataTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '			
		. ' `chatlogid` INT NOT NULL, '		
		. ' `agentid` INT NOT NULL, '
		. ' `name` TEXT NOT NULL, '
		. ' `email` TEXT NOT NULL, '	
		. ' `sent` VARCHAR(50) NOT NULL, '					
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL, '
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the system user data\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['userdataTable'].'" database table successfully created<br />'."\n";	
	  
	  $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['usernameTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '			
		. ' `chatlogid` INT NOT NULL, '		
		. ' `agentid` INT NOT NULL, '
		. ' `name` TEXT NOT NULL, '				
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL, '
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the system user name data\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  $done .= '"'.$tables['usernameTable'].'" database table successfully created<br />'."\n";			
	
	  //==============load tables with data and defaults==================
	  
	  //create a default campaign
	  include('modfiles/db.php');
	  include('panelfunctions.php');
	  include('globals.php');
	
	  //create the user account
	  $sql = "INSERT INTO ".$tables['settingsTable']." VALUES(null,'$username','$password','$fname','$lname','$email','$version','$installfolder','$installsite','0','1')";
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';	
	  $done .= 'User information successfully inserted into database<br />'."\n";			  
	
	  CreateNewCampaign($label,$desc,'install');
	  $done .= 'New campaign with all associated data has been successfully created<br />'."\n";			
	
	  //display results and the continue link to the login page
	  $st1 = '<!--';
      $en1 = '-->';
      $st2 = '<!--';
      $en2 = '-->';
	  $done = '<p align="center">'.$done .'<br /><br />';
	  $done .= '<a href="login.php">Continue</a></p>';		
    }
  }
}else{
  //show installation type first
  if (file_exists('modfiles/db.php')){
    clearstatcache;
    $st1 = '';
    $en1 = '';
    $st2 = '<!--';
    $en2 = '-->';  
  }else{
    $st1 = '<!--';
    $en1 = '-->';
    $st2 = '';
    $en2 = '';
	//some default values
    $dbhost = '204.228.145.16';
    $label = 'My first campaign';
    $desc = 'This is a short description for my first campaign'; 
  
    //attempt to get the folder and website
    $installfolder = $_SERVER['PHP_SELF'];
    $pos = strpos($installfolder, 'install.php');
    $installfolder = substr($installfolder, 0, $pos);
    $installsite = 'http://'.$_SERVER['HTTP_HOST'];
  }  
}

if ($done != ''){
  $done = '<table width="435" border="0" align="center" cellpadding="5" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="small_grey_border"><tr><td>'.$done.'</td></tr></table><br />';
}
if ($err != ''){
  $err = '<table width="435" border="0" align="center" cellpadding="5" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="small_grey_border"><tr><td>'.$err.'</td></tr></table><br />';
}

//=========================================================================//
//FUNCTIONS//
//=========================================================================//

function isWritable($path) {
//will work in despite of Windows ACLs bug
//NOTE: use a trailing slash for folders!!!
    if ($path{strlen($path)-1}=='/') // recursively return a temporary file path
        return isWritable($path.uniqid(mt_rand()).'.tmp');
    else if (is_dir($path))
        return isWritable($path.'/'.uniqid(mt_rand()).'.tmp');
    // check tmp file for read/write capabilities
    $rm = file_exists($path);
    $f = @fopen($path, 'a');
    if ($f===false)
        return false;
    fclose($f);
    if (!$rm)
        unlink($path);
    return true;
}

//=========================================================================//

function CurlPage ($pageSpec){
  $ch = curl_init($pageSpec);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
  $tmp = curl_exec ($ch);
  curl_close ($ch);
  $tmp = trim($tmp);
  $pos = strpos($tmp,'vsac:',0);
  if ($pos!==false){$tmp=substr($tmp,$pos+5,strlen($tmp)-$pos);}else{$tmp='1';}
  return $tmp;
}

//=========================================================================//

function upgrade116(){
  //this upgrades the campaign table for all versions less than 115

  global $conn, $campaignTable, $dbname;
	  
  $fields = mysql_list_fields($dbname, $campaignTable);        
  $columns = mysql_num_fields($fields);        
  for ($i = 0; $i < $columns; $i++) {
    $field_array[] = mysql_field_name($fields, $i);
  }
        
  if (!in_array('displaymethod', $field_array)) {
    $sql = 'ALTER TABLE `'.$campaignTable.'` ADD `displaymethod` TEXT NOT NULL AFTER `displayperiod`';	
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):''; 
	
	$sql = "UPDATE ".$campaignTable." SET displaymethod='dialog'";
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';   	
  }

  if (!in_array('mousetimes', $field_array)) {
    $sql = 'ALTER TABLE `'.$campaignTable.'` ADD `mousetimes` INT NOT NULL AFTER `displaymethod`';	
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):''; 
	
	$sql = "UPDATE ".$campaignTable." SET mousetimes='0'";
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';   
  }

  if (!in_array('usemousemessage', $field_array)) {
    $sql = 'ALTER TABLE `'.$campaignTable.'` ADD `usemousemessage` INT NOT NULL AFTER `mousetimes`';	
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):''; 
	
	$sql = "UPDATE ".$campaignTable." SET usemousemessage='2'";
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';   
  }
}

//=========================================================================//

function upgrade117(){
  //this upgrades the campaign table for all versions less than 116

  global $conn, $settingsTable, $campaignTable, $writingFolder;
  global $dbhost, $dblogin, $dbpass, $dbname, $tables;
	  
  $fields = mysql_list_fields($dbname, $settingsTable);        
  $columns = mysql_num_fields($fields);        
  for ($i = 0; $i < $columns; $i++) {
    $field_array[] = mysql_field_name($fields, $i);
  }
        
  if (!in_array('selectedcid', $field_array)) {
    $sql = 'ALTER TABLE `'.$settingsTable.'` ADD `selectedcid` INT NOT NULL AFTER `newsfeed`';	
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):''; 
		 		
    //enter the last created campaign
    $sql = "SELECT * FROM $campaignTable ORDER BY id DESC LIMIT 1";  
    $result = mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
    $data = mysql_fetch_assoc($result);
	
	$scid = $data['id'];
	$sql = "UPDATE ".$settingsTable." SET selectedcid='$scid'";
    mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';

  }  
  
  //check if table already exists
  if( !mysql_num_rows( mysql_query("SHOW TABLES LIKE '".$tables['usernameTable']."'"))){
  
    $sql = 'CREATE TABLE `'.$dbname.'`.`'.$tables['usernameTable'].'` ('
        . ' `id` INT NOT NULL AUTO_INCREMENT, '
		. ' `cid` INT NOT NULL, '			
		. ' `chatlogid` INT NOT NULL, '		
		. ' `agentid` INT NOT NULL, '
		. ' `name` TEXT NOT NULL, '				
		. ' `ip` VARCHAR(50) NOT NULL, '
		. ' `date` VARCHAR(50) NOT NULL, '
        . ' PRIMARY KEY (`id`)'
        . ' )'
        . ' TYPE = myisam'
        . ' COMMENT = \'Contains the system user name data\'';		
      mysql_query($sql,$conn);mysql_error()?(print(mysql_error())):'';
	  
	  //global variables can be created and entered into this file
	  //need to add new table variables to the database file
	  $myFile = "$writingFolder/db.php";
      $fh = fopen($myFile, 'w') or die("can't open file");
	  fwrite($fh, '<?php'."\n");
	  fwrite($fh, '$dbhost = "'.$dbhost.'";'."\n");
	  fwrite($fh, '$dblogin = "'.$dblogin.'";'."\n");
	  fwrite($fh, '$dbpass = "'.$dbpass.'";'."\n");
	  fwrite($fh, '$dbname = "'.$dbname.'";'."\n");
	  foreach($tables as $key=>$value){
	    $s = '$'.$key.' = "'.$value.'";';
	    fwrite($fh, $s."\n");
	  }
	  fwrite($fh, '?>');
      fclose($fh);
	  
  }

}

//=========================================================================//

?>

<!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>Virtual Smart Agent Installation</title>
</head>

<body>
<h1 align="center">Virtual Smart Agent Installation</h1>
<?php echo $err; ?>
<?php echo $done; ?>
<?php echo $st1; ?>
<form action="install.php" method="post">
<table width="435" border="0" align="center" cellpadding="5" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="small_grey_border">
  <tr>
    <td colspan="3" bgcolor="#666666"><div align="left"><span style="color: #FFFFFF; font-weight: bold">Please select an option ...</span></div></td>
  </tr>
  <tr>
    <td width="7%" valign="top"><div align="right">
      <input name="installtype" type="radio" id="installtype" value="new" />
    </div></td>
    <td width="27%" valign="top" nowrap="nowrap">New installation</td>
    <td width="66%"><div align="left">
    Warning: If you have an earlier version installed, this option will remove ALL current data.</div></td>
  </tr>
  <tr>
    <td valign="top"><div align="right">
      <input name="installtype" type="radio" id="installtype" value="update" checked="checked" />
    </div></td>
    <td valign="top" nowrap="nowrap">Update installation</td>
    <td><div align="left">
    If you have an earlier version  installed, this option will update your current version to the latest version and retain all your current statisitcal and campaign data.</div></td>
  </tr>
  <tr>
    <td colspan="3"><div align="center">
      <input type="submit" name="nextbutton" id="nextbutton" value="Next &gt;&gt;" />
    </div></td>
  </tr>
</table>
</form>
<?php echo $en1; ?>

<?php echo $st2; ?>
<form action="install.php" method="post">
<table width="435" border="0" align="center" cellpadding="5" cellspacing="1" bordercolor="#CCCCCC" bgcolor="#FFFFFF" class="small_grey_border">
  <tr>
    <td colspan="2" bgcolor="#666666"><div align="left"><span style="color: #FFFFFF; font-weight: bold">STEP 1: Database Settings - Enter Database Details</span></div></td>
  </tr>
  <tr>
    <td width="43%"><div align="right">Database host:</div></td>
    <td width="57%"><div align="left">
      <input name="dbhost" type="text" id="dbhost" style="width: 220px" value="<?php echo $dbhost; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Database name:</div></td>
    <td><div align="left">
      <input name="dbname" type="text" id="dbname" style="width: 220px" value="<?php echo $dbname; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Database username:</div></td>
    <td><div align="left">
      <input type="text" name="dblogin" style="width: 220px" id="dbuser" value="<?php echo $dblogin; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Database password:</div></td>
    <td><div align="left">
      <input type="text" name="dbpass" style="width: 220px" id="dbpass" value="<?php echo $dbpass; ?>" />
    </div></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#666666"><div align="left"><span style="color: #FFFFFF; font-weight: bold">STEP 2: Admin Settings - Create Your Admin Account</span></div></td>
  </tr>
  <tr>
    <td><div align="right">Login username:</div></td>
    <td><div align="left">
      <input type="text" name="username" style="width: 220px" id="username" value="<?php echo $username; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Login password:</div></td>
    <td><div align="left">
      <input type="text" name="password" style="width: 220px" id="password" value="<?php echo $password; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">First name:</div></td>
    <td><div align="left">
      <input type="text" name="fname" style="width: 220px" id="fname" value="<?php echo $fname; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Last name:</div></td>
    <td><div align="left">
      <input type="text" name="lname" style="width: 220px" id="lname" value="<?php echo $lname; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Email:</div></td>
    <td><div align="left">
      <input type="text" name="email" style="width: 220px" id="email" value="<?php echo $email; ?>" />
    </div></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#666666"><div align="left"><span style="color: #FFFFFF; font-weight: bold">STEP 3: Campaign Settings - Create New Campaign</span></div></td>
    </tr>
  <tr>
    <td><div align="right">Label:</div></td>
    <td><div align="left">
      <input name="label" type="text" style="width: 220px" value="<?php echo $label; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Description:</div></td>
    <td><div align="left">
      <input name="desc" type="text" style="width: 220px" value="<?php echo $desc; ?>" />
    </div></td>
  </tr>
  <tr>
    <td colspan="2" bgcolor="#666666"><div align="left"><span style="color: #FFFFFF; font-weight: bold">STEP 4: System Settings</span></div></td>
    </tr>
  <tr>
    <td><div align="right">Installation folder:<br />
    <span style="font-size: 9px">(include starting and trailing  <br />
    forward slashes. ex: /vsa/)</span></div></td>
    <td><div align="left">
      <input name="installfolder" type="text" style="width: 220px" value="<?php echo $installfolder; ?>" />
    </div></td>
  </tr>
  <tr>
    <td><div align="right">Installation website:<br /><span style="font-size: 9px">(include 'http://')</span></div></td>
    <td><div align="left">
      <input name="installsite" type="text" style="width: 220px" value="<?php echo $installsite; ?>" />
    </div></td>
  </tr>
  <tr>
    <td colspan="2"><div align="center">
      <input type="submit" name="installbutton" id="installbutton" value="Install" />
    </div></td>
  </tr>
</table>
</form>
<?php echo $en2; ?>
<p align="center"><?php echo $copyright; ?></p>
<p>&nbsp;</p>
<p>&nbsp; </p>
</body>
</html>

Youez - 2016 - github.com/yon3zu
LinuXploit