Location: PHPKode > scripts > HostBuilder > hostbuilder/admin.functions.php
<?php
/*
	HostBuilder
	Free Edition
	(C) 2007-2008 Data Components Software Development

	Administrative functions and procedures
*/

function showadminlogin ($commname) {
  $t['community'] = $commname;
  return parse_tpl("admin.login", $t);
}

function showadminmain () {
  $t['total'] = gettotalindex();
  $t['inactivity'] = getconfig(7)." days";
  $t['inactive'] = gettotalinactive();
  $t['size'] = round((membersusedspace()/1024), 2)." KB";
  return parse_tpl("admin", $t);
}

function fileget($file) {
	// To set more compatibility with PHP 4.3- versions
	// Replaces file_get_contents
	if (filesize($file) > 0) {
		$h = fopen($file, "r");
		$data = fread($h, filesize($file));
		fclose($h);
	}
	return $data;
}

function gettotalindex () {
	$inline = file(getcwd()."/accounts.db");
	return count($inline);
}

function gettotalinactive () {
	$inline = file(getcwd()."/accounts.db");
	$index = 0;
	$xt = time();
	foreach ($inline as $l) {
	  $values = split("::", $l);
		$lastlogin = $values[6];
		$toinactive = $values[6]+(getconfig(7)*24*60*60);
		if ($toinactive <= $xt) {
			$index++;
		}
	}
	return $index;
}

function membersusedspace () {
  include_once "functions.php";
	$space = 0;
	$inline = file(getcwd()."/accounts.db");
	foreach ($inline as $l) {
	  $values = split("::", $l);
		$space .= getmemberusedspace($values[0]);
	}
	return $space;
}

function showemailall($from, $subject, $content) {
  $t['from'] = $from;
  $t['subject'] = $subject;
  $t['content'] = $content;
  return parse_tpl ("admin.emailall", $t);
}

function emailallusers ($subject, $from, $content) {
	$l = file(getcwd()."/accounts.db");
	$from = stripslashes($from);
  foreach ($l as $lv) {
		$values = split("::", $lv);
		$to = $values[10];
		$headers = "From: ".$from.
				"Reply-to: ".$from;
		mail($to, stripslashes($subject), stripslashes($content), $headers);
	}
}

function showallaccounts () {
  $inact1 = "";
	$f = file(getcwd()."/accounts.db");
	foreach ($f as $l) {
		$values = split("::", $l);
		$lastlogin = $values[6];
		$toinactive = $values[6]+(getconfig(7)*24*60*60);
		$i['username'] = $values[0];
		$i['size'] = round((getmemberusedspace($values[0])/1024), 2)." KB";
    if ($toinactive <= time()) {
		  $inact1 .= parse_tpl("admin.acctitem", $i);
    } elseif ($toinactive > time()) {
			$act1 .= parse_tpl("admin.acctitem", $i);
		}
	}
	$t['inactive'] = $inact1;
	$t['active'] = $act1;
	return parse_tpl("admin.accounts", $t);
}

function deleteallinactive () {
	$f = file(getcwd()."/accounts.db");
	$hnd = fopen(getcwd()."/accounts.db", "w");
	foreach ($f as $l) {
	  $values = split("::", $l);
	  $lastlogin = $values[6];
		$toinactive = $values[6]+(getconfig(7)*24*60*60);
	  if ($toinactive <= time()) {
			removedir($values[6]);
		} else {
		  fwrite($hnd, $l);
		}
	}
	fclose($hnd);
}

function removedir($dir) {
  if (is_dir($dir)) {
    $h = opendir($dir);
    while ($d = readdir($h)) {
      if (is_dir($dir."/".$d)) {
        removedir($dir."/".$d);
      } else {
        unlink($dir."/".$d);
      }
    }
    closedir($dir);
    rmdir($dir);
  } else {
    return false;
  }
}

function deleteaccounts ($accounts) {
	$f = file(getcwd()."/accounts.db");
	$hnd = fopen(getcwd()."/accounts.db", "w");
	foreach ($f as $l) {
	  $values = split("::", $l);
	  $lastlogin = $values[6];
		$toinactive = $values[6]+(getconfig(7)*24*60*60);
		$ok = 1;
		foreach ($accounts as $a) {
		  if ($a == $values[0]) {
		    $ok = 0;
		  }
		}
	  if ($ok == 0)
      removedir($values[6]);
		else
		  fwrite($hnd, $l);
	}
	fclose($hnd);
}

function showaccount ($user) {
  include_once "functions.php";
	if (intval(getaccountinfo($user, 11)) == 1) {
		$ads = "Yes";
	} else {
		$ads = "No";
	}
	$t['username'] = $user;
	$t['password'] = getaccountinfo($user, 1);
  $t['space'] = getaccountinfo($user, 2);
  $t['used'] = getmemberusedspace($user);
  $t['filesize'] = getaccountinfo($user, 3);
  $t['exts'] = getaccountinfo($user, 4);
  $t['dir'] = getaccountinfo($user, 5);
  $t['login'] = getaccountinfo($user, 6);
  $t['name'] = getaccountinfo($user, 7);
  $t['group'] = getaccountinfo($user, 8);
  $t['url'] = getaccountinfo($user, 9);
  $t['email'] = getaccountinfo($user, 10);
  $t['ads'] = $ads;
	return parse_tpl("admin.viewacct", $t);
}

function showfiletypespanel ($exts) {
	$exts1 = split(",", $exts);
	foreach ($exts1 as $e) {
	  $a['ext'] = $e;
	  $t['exts'] .= parse_tpl("admin.ext", $a);
	}
	return parse_tpl("admin.exts", $t);
}

function changeconfig ($index, $newvalue) {
	$f = file(getcwd()."/config.inc");
	$h = fopen(getcwd()."/config.inc", "w");
	foreach ($f as $l) {
	  $fl .= trim($l);
	}
	$c = split("::", $fl);
	$c[$index] = $newvalue;
	$co = "";
	foreach ($c as $ct) {
    if ($co == NULL) {
      $co = $ct;
    } else {
      $co .= "::".$ct;
    }
	}
  fwrite($h, $co);
	fclose($h);
}

function showgroupspanel ($newgroup) {
  $f = file(getcwd()."/groups.db");
  $grps = split(",", $f[0]);
  foreach ($grps as $g) {
    $a['group'] = $g;
    $t['groups'] .= parse_tpl("admin.groupitem", $a);
  }
	return parse_tpl("admin.groups", $t);
}

function showconfigpanel () {
	$t['0'] = getconfig(0);
	$t['1'] = getconfig(1);
  $t['2'] = getconfig(2);
  $t['3'] = getconfig(3);
  $t['5'] = getconfig(5);
  $t['6'] = getconfig(6);
  $t['7'] = getconfig(7);
  $t['9'] = getconfig(9);
  return parse_tpl("admin.config", $t);
}

function showadspanel () {
	return get_raw_tpl("admin.ads");
}

function showadedit ($adfile, $type) {
	$f = file($adfile);
  $basefile = basename($adfile);
	$t['type'] = $type;
	$t['file'] = $basefile;
	foreach ($f as $l) {
	  $t['content'] .= $l;
	}
  return parse_tpl("admin.editad", $t);
}

?>
Return current item: HostBuilder