Sindbad~EG File Manager

Current Path : /home/beeson/public_html/helpwithmath/
Upload File :
Current File : //home/beeson/public_html/helpwithmath/GetSerialNumber.php

 <?php 
 require_once('DB.php');
 require_once('query.php');
 function getStartIndex($Reseller, $WhichDisk, $days, $Increment)
// Get $StartIndex (the number of serial numbers so far issued with these parameters) from the 
// database, and increment that number in the database by 1.
{ $sql = "SELECT Nused FROM NextSerialNumber WHERE Reseller='$Reseller' AND TimeLimit='$days' AND WhichDisk='$WhichDisk';";
   $q = Query($sql);
  $q->fetchInto($row);
  $StartIndex = $row[0];
  if(is_null($StartIndex))
     { $StartIndex = 0;  // first time with this value of $days  
	   $sql = "INSERT INTO NextSerialNumber (Nused, Reseller, TimeLimit, WhichDisk) VALUES ($Increment,'$Reseller',$days, $WhichDisk);";
	   Query($sql);  // store the first value of NextIndex
	 }
  else 
  // increment NextIndex in the database
    { $NextIndex = $StartIndex+$Increment;
      $sql = "UPDATE NextSerialNumber SET Nused = '$NextIndex' WHERE Reseller='$Reseller' AND TimeLimit='$days' AND WhichDisk='$WhichDisk'";
	  Query($sql);  // carry out the increment operation,
	}
  return $StartIndex;
}  

 function getTrialSerialNumber($WhichDisk, $VersionNumber)
 // Nused is the number already used for reseller HelpWithMath and this value of whichdisk
 { // return "7GWL9X-4DL7QH-7C49X0";  // for now
   $days = "14";
   $StartIndex = getStartIndex("HelpWithMath",$WhichDisk,$days,1);
   if(is_null($StartIndex))
      die("Database connection error in getStartIndex.");
	$command = "../../../GenerateSerialNumbers/GenerateSerialNumbers HelpWithMath $WhichDisk $days 1 $StartIndex $VersionNumber";
    exec($command,$lines);
	// mail("sales@HelpWithMath.com","download","Command to generate serial number was: \n $command\n");
    return $lines[0];
 }

function getSerialNumber($WhichDisk, $VersionNumber, $days)
// return a single serial number for a purchased version
{ $StartIndex = getStartIndex("HelpWithMath", $WhichDisk,0,1);
  exec("../../GenerateSerialNumbers/GenerateSerialNumbers HelpWithMath $WhichDisk $days 1 $StartIndex  $VersionNumber",$lines);
  return $lines[0];
}


function getSerialNumbers($WhichDisk, $VersionNumber, $Nunits)
// return a list of $Nunits serial numbers for a purchased version
{ $StartIndex = getStartIndex("HelpWithMath", $WhichDisk,0,$Nunits);
  $days = 0;
   exec("../../GenerateSerialNumbers/GenerateSerialNumbers HelpWithMath $WhichDisk $days $Nunits $StartIndex $VersionNumber",$lines);
   return $lines;
}
 ?>

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists