alert('" . _('This extension can not be be viewed: ') . "' + ext)
return
}
- window.open('" . $path_to_root . BACKUP_PATH . "'+pFilename, '', 'toolbar=no,scrollbars=yes')
+ window.open('" . BACKUP_PATH . "'+pFilename, '', 'toolbar=no,scrollbars=yes')
}
function deleteBackup() {
pFilename = document.forms[0].cmb_backups.options[document.forms[0].cmb_backups.selectedIndex].value
//Download the file
if ($_GET['c']=='d')
{
- download_file($path_to_root . BACKUP_PATH . $_GET['fn']);
+ download_file(BACKUP_PATH . $_GET['fn']);
exit;
}
//Delete the file
if ($_GET['c']=='df')
{
$filename = $_GET['fn'];
- @unlink($path_to_root . BACKUP_PATH . $filename);
+ @unlink(BACKUP_PATH . $filename);
header("Location: backups.php?c=dff&fn=" . urlencode($filename));
return "";
}
if ($_GET['c']=='r')
{
$filename=$_GET['fn'];
- restore_backup($path_to_root . BACKUP_PATH . $filename, $conn);
+ restore_backup(BACKUP_PATH . $filename, $conn);
header("Location: backups.php?c=rs&fn=" . urlencode($filename));
return "";
}
global $path_to_root;
$ar_files = array();
- $dh = opendir($path_to_root . BACKUP_PATH);
+ $dh = opendir(BACKUP_PATH);
while (($file = readdir($dh)) !== false)
$ar_files[] = $file;
closedir($dh);
global $path_to_root;
$st = "";
- if (!file_exists($path_to_root . BACKUP_PATH))
- $st .= " - " . _("cannot find backup directory") . " - " . $path_to_root . BACKUP_PATH . "<br>";
+ if (!file_exists(BACKUP_PATH))
+ $st .= " - " . _("cannot find backup directory") . " - " . BACKUP_PATH . "<br>";
return $st;
}
page(_("Create/Update Company"));
+$comp_subdirs = array('images', 'pdf_files', 'backup','js_cache');
//---------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------------------------
+function remove_connection($id) {
+ global $db_connections;
+
+ $dbase = $db_connections[$id]['dbname'];
+ $err = db_drop_db($db_connections[$id]);
+
+ unset($db_connections[$id]);
+ $conn = array_values($db_connections);
+ $db_connections = $conn;
+ //$$db_connections = array_values($db_connections);
+ return $err;
+}
+//---------------------------------------------------------------------------------------------
+
function handle_submit()
{
- global $db_connections, $def_coy, $tb_pref_counter, $db;
+ global $db_connections, $def_coy, $tb_pref_counter, $db,
+ $comp_path, $comp_subdirs;
$new = false;
}
if ((bool)$_POST['def'] == true)
$def_coy = $id;
- $error = write_config_db($new);
- if ($error == -1)
- display_error(_("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
- else if ($error == -2)
- display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
- else if ($error == -3)
- display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
- if ($error != 0)
- return false;
if (isset($_GET['ul']) && $_GET['ul'] == 1)
{
$conn = $db_connections[$id];
if (($db = db_create_db($conn)) == 0)
{
display_error(_("Error creating Database: ") . $conn['dbname'] . _(", Please create it manually"));
+ remove_connection($id);
set_global_connection();
return false;
}
}
set_global_connection();
}
+ $error = write_config_db($new);
+ if ($error == -1)
+ display_error(_("Cannot open the configuration file - ") . $path_to_root . "/config_db.php");
+ else if ($error == -2)
+ display_error(_("Cannot write to the configuration file - ") . $path_to_root . "/config_db.php");
+ else if ($error == -3)
+ display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
+ if ($error != 0) {
+ return false;
+ }
+ $index = "<?php\nheader(\"Location: ../../index.php\");\n?>";
+
+ if ($new) {
+ $cdir = $comp_path.'/'.($tb_pref_counter-1);
+ @mkdir($cdir);
+ save_to_file($cdir.'/'.'index.php', 0, $index);
+
+ foreach($comp_subdirs as $dir) {
+ @mkdir($cdir.'/'.$dir);
+ save_to_file($cdir.'/'.$dir.'/'.'index.php', 0, $index);
+ }
+ }
return true;
}
function handle_delete()
{
- global $def_coy, $db_connections;
+ global $comp_path, $def_coy, $db_connections, $comp_subdirs;
$id = $_GET['id'];
- $dbase = $db_connections[$id]['dbname'];
- $err = db_drop_db($db_connections[$id]);
+ $pref = $db_connections[$id]['tbpref'];
+ if($pref!='')
+ $pref = substr($pref, 0, strlen($pref)-1);
- unset($db_connections[$id]);
- $conn = array_values($db_connections);
- $db_connections = $conn;
+ $err = remove_connection($id);
+ if ($err == 0)
+ display_error(_("Error removing Database: ") . $dbase . _(", please remove it manuallly"));
- //$$db_connections = array_values($db_connections);
if ($def_coy == $id)
$def_coy = 0;
$error = write_config_db();
display_error(_("The configuration file ") . $path_to_root . "/config_db.php" . _(" is not writable. Change its permissions so it is, then re-run the operation."));
if ($error != 0)
return;
- if ($err == 0)
- display_error(_("Error removing Database: ") . $dbase . _(", please remove it manuallly"));
- else
- meta_forward($_SERVER['PHP_SELF']);
+
+ $cdir = $comp_path.'/'.$pref;
+ flush_dir($cdir);
+ if (!rmdir($cdir)) {
+ display_error(_("Cannot remove company data directory ") . $cdir);
+ return;
+ }
+
+ meta_forward($_SERVER['PHP_SELF']);
}
//---------------------------------------------------------------------------------------------
// get table structures
foreach ($all_tables as $table)
{
- if (strpos($table['Name'], $connection["tbpref"]) !== false)
+ if (strpos($table['Name'], $connection["tbpref"]) === 0)
db_query("DROP TABLE `".$table['Name'] . "`");
}
//deleting the tables, how??
}
elseif ($error)
{
- @unlink($path_to_root . BACKUP_PATH . $backupfile);
+ @unlink(BACKUP_PATH . $backupfile);
return false;
}
}
else
{
- @unlink($path_to_root . BACKUP_PATH . $backupfile);
+ @unlink(BACKUP_PATH . $backupfile);
return false;
}
}
else
{
- @unlink($path_to_root . BACKUP_PATH . $backupfile);
+ @unlink(BACKUP_PATH . $backupfile);
return false;
}
return $backupfile;
if ($zip == "gzip")
{
- if ($zp = @gzopen($path_to_root . BACKUP_PATH . $backupfile, "a9"))
+ if ($zp = @gzopen(BACKUP_PATH . $backupfile, "a9"))
{
@gzwrite($zp, $fileData);
@gzclose($zp);
// total # of entries "on this disk", total # of entries overall, size of central dir, offset to start of central dir, .zip file comment length
$fileData .= pack('v', 1) . pack('v', 1) . pack('V', strlen($cdrec)) . pack('V', strlen($fr)) . "\x00\x00";
- if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
+ if ($zp = @fopen(BACKUP_PATH . $backupfile, "a"))
{
@fwrite($zp, $fileData);
@fclose($zp);
}
else
{
- if ($zp = @fopen($path_to_root . BACKUP_PATH . $backupfile, "a"))
+ if ($zp = @fopen(BACKUP_PATH . $backupfile, "a"))
{
@fwrite($zp, $fileData);
@fclose($zp);
<?php
-
error_reporting(E_ALL);
ini_set("display_errors", "On");
// Start a session
}
}
$path_to_root = "..";
+include_once($path_to_root.'/config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<tr>
<td style="color: #666666;">config_db.php</td>
<td><?php if(is_writable($path_to_root.'/config_db.php')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/config_db.php')) { echo '<font class="bad">File Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
- <td style="color: #666666;">inventory/manage/image/</td>
- <td><?php if(is_writable($path_to_root.'/inventory/manage/image/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/inventory/manage/image/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
+ <td style="color: #666666;">modules/</td>
+ <td><?php if(is_writable($path_to_root.'/modules/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/lang/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
</tr>
<tr>
<td style="color: #666666;">lang/</td>
<td><?php if(is_writable($path_to_root.'/lang/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/lang/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
- <td style="color: #666666;">reporting/pdf_files/</td>
- <td><?php if(is_writable($path_to_root.'/reporting/pdf_files/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/reporting/pdf_files/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
- </tr>
- <tr>
- <td style="color: #666666;">modules/</td>
- <td><?php if(is_writable($path_to_root.'/modules/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/lang/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
- <td style="color: #666666;">admin/backup/</td>
- <td><?php if(is_writable($path_to_root.'/admin/backup/')) { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($path_to_root.'/admin/backup/')) { echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
+ <td style="color: #666666;"><?php echo 'Company data dirs ('. $comp_path. '/*)'; ?></td>
+ <td><?php if(is_writable($comp_path) && is_writable($comp_path.'/0') && is_writable($comp_path.'/0/images'))
+ { echo '<font class="good">Writeable</font>'; } elseif(!file_exists($comp_path)) {
+ echo '<font class="bad">Directory Not Found</font>'; } else { echo '<font class="bad">Unwriteable</font>'; } ?></td>
</tr>
</table>
<table cellpadding="3" cellspacing="0" width="100%" align="center">
{
$result = $_FILES['pic']['error'];
$upload_file = 'Yes'; //Assume all is well to start off with
- $filename = $path_to_root . "/inventory/manage/image/$user_comp/";
+ $filename = $comp_path . "/$user_comp/images";
if (!file_exists($filename))
{
mkdir($filename);
$stock_id = $_POST['NewStockID'];
delete_item($stock_id);
- $filename = $path_to_root . "/inventory/manage/image/$user_comp/$stock_id.jpg";
+ $filename = $comp_path . "/$user_comp/images/$stock_id.jpg";
if (file_exists($filename))
unlink($filename);
meta_forward($_SERVER['PHP_SELF']);
start_row();
label_cells(_("Image File (.jpg)") . ":", "<input type='file' id='pic' name='pic'>");
// Add Image upload for New Item - by Joe
-if (isset($_POST['NewStockID']) && file_exists("$path_to_root/inventory/manage/image/$user_comp/".$_POST['NewStockID'].".jpg"))
+if (isset($_POST['NewStockID']) && file_exists("$comp_path/$user_comp/images/".$_POST['NewStockID'].".jpg"))
{
- $stock_img_link = "<img src='$path_to_root/inventory/manage/image/$user_comp/".$_POST['NewStockID'].".jpg' width='$pic_width' height='$pic_height' border='0'>";
+ $stock_img_link = "<img src='$comp_path/$user_comp/images/".$_POST['NewStockID'].".jpg' width='$pic_width' height='$pic_height' border='0'>";
}
else
{
$page_security = 8;
include_once($path_to_root . "reporting/includes/class.pdf.inc");
include_once($path_to_root . "admin/db/company_db.inc");
-
+include_once($path_to_root . "config.php");
class FrontReport extends Cpdf
{
var $size;
function Header2($myrow, $branch, $sales_order, $bankaccount, $doctype)
{
- global $path_to_root, $print_as_quote, $print_invoice_no;
+ global $comp_path, $path_to_root, $print_as_quote, $print_invoice_no;
$this->pageNumber++;
if ($this->pageNumber > 1)
$this->row = $upper - 2 * $this->lineHeight - 2;
if ($this->company['coy_logo'] != '')
{
- $logo = $path_to_root . "themes/default/images/" . $this->company['coy_logo'];
+ $logo = $comp_path .'/'. user_company() . "/images/" . $this->company['coy_logo'];
$this->AddImage($logo, $ccol, $iline1 + 5, 250, 40);
}
else
function End($email=0, $subject=null, $myrow=null, $doctype = 0)
{
- global $go_debug, $path_to_root;
+ global $go_debug, $path_to_root, $comp_path;
// this is no good in IE so has been replaced, see down under
// but good for debugging purposes in IE
{
$buf = $this->output();
$len = strlen($buf);
- $dir = './pdf_files';
+ $dir = $comp_path.'/'.user_company(). '/pdf_files';
//save the file
if (!file_exists($dir))
{
+++ /dev/null
-<?php
-header("Location: ../index.php");
-?>
function print_aged_customer_analysis()
{
- global $path_to_root;
+ global $comp_path, $path_to_root;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
$rep->Line($rep->row + 4);
$rep->NewLine();
}
- $rep->fontSize += 2;
+ $rep->fontSize += 2;
$rep->TextCol(0, 3, _('Grand Total'));
$rep->fontSize -= 2;
for ($i = 0; $i < count($total); $i++)
$pg->built_in = false;
$pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
$pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
- $filename = $path_to_root . "reporting/pdf_files/test.png";
+ $filename = $comp_path .'/'. user_company(). "/images/test.png";
$pg->display($filename, true);
$w = $pg->width / 1.5;
$h = $pg->height / 1.5;
function print_price_listing()
{
- global $path_to_root, $pic_height, $pic_width;
+ global $comp_path, $path_to_root, $pic_height, $pic_width;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
}
if ($pictures)
{
- $image = $path_to_root . "inventory/manage/image/" . $user_comp . "/" . $myrow['stock_id'] . ".jpg";
+ $image = $comp_path . '/'. $user_comp . "/images/" . $myrow['stock_id'] . ".jpg";
if (file_exists($image))
{
$rep->NewLine();
function print_aged_supplier_analysis()
{
- global $path_to_root;
+ global $comp_path, $path_to_root;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
$pg->built_in = false;
$pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
$pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
- $filename = $path_to_root . "reporting/pdf_files/test.png";
+ $filename = $comp_path.'/'.user_company(). "/pdf_files/test.png";
$pg->display($filename, true);
$w = $pg->width / 1.5;
$h = $pg->height / 1.5;
function print_stock_check()
{
- global $path_to_root, $pic_height, $pic_width;
+ global $comp_path, $path_to_root, $pic_height, $pic_width;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
$rep->TextCol(4, 5, number_format2($trans['QtyOnHand'] - $demandqty, $dec));
if ($pictures)
{
- $image = $path_to_root . "inventory/manage/image/" . $user_comp . "/" . $trans['stock_id'] . ".jpg";
+ $image = $comp_path .'/'. $user_comp . '/images/' . $trans['stock_id'] . '.jpg';
if (file_exists($image))
{
$rep->NewLine();
function print_balance_sheet()
{
- global $path_to_root;
+ global $comp_path, $path_to_root;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
$dim = get_company_pref('use_dimension');
$pg->built_in = false;
$pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
$pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
- $filename = $path_to_root . "reporting/pdf_files/test.png";
+ $filename = $comp_path.'/'.user_company()."/pdf_files/test.png";
$pg->display($filename, true);
$w = $pg->width / 1.5;
$h = $pg->height / 1.5;
function print_profit_and_loss_statement()
{
- global $path_to_root;
+ global $comp_path, $path_to_root;
include_once($path_to_root . "reporting/includes/pdf_report.inc");
$dim = get_company_pref('use_dimension');
$pg->built_in = false;
$pg->fontfile = $path_to_root . "reporting/fonts/Vera.ttf";
$pg->latin_notation = ($decseps[$_SESSION["wa_current_user"]->prefs->dec_sep()] != ".");
- $filename = $path_to_root . "reporting/pdf_files/test.png";
+ $filename = $comp_path.'/'.user_company(). ."/pdf_files/test.png";
$pg->display($filename, true);
$w = $pg->width / 1.5;
$h = $pg->height / 1.5;