\n";
exit;
} unset($d1);unset($d2);unset($d3);
//incase we are dealing with a fresh login
if (!isset($phpgw_info["user"]["preferences"]["common"]["template_set"])){
$phpgw_info["user"]["preferences"]["common"]["template_set"] = "default";
}
// Since LDAP will return system accounts, there are a few we don't want to login.
$phpgw_info["server"]["global_denied_users"] = array('root' => True,
'bin' => True,
'daemon' => True,
'adm' => True,
'lp' => True,
'sync' => True,
'shutdown' => True,
'halt' => True,
'mail' => True,
'news' => True,
'uucp' => True,
'operator' => True,
'games' => True,
'gopher' => True,
'nobody' => True,
'xfs' => True,
'pgsql' => True,
'mysql' => True,
'postgres' => True,
'ftp' => True,
'gdm' => True,
'named' => True);
// I had to create this has a wrapper, becuase the phpgw.inc.php files needs it before the classes
// are finished loading (jengo)
function filesystem_separator()
{
if (PHP_OS == "Windows" || PHP_OS == "OS/2") {
return "\\";
} else {
return "/";
}
}
class common
{
var $phpgw;
var $iv = "";
var $key = "";
var $crypto;
// return a array of installed languages
function getInstalledLanguages()
{
global $phpgw;
$phpgw->db->query("select distinct lang from lang");
while (@$phpgw->db->next_record())
{
$installedLanguages[$phpgw->db->f("lang")] = $phpgw->db->f("lang");
}
return $installedLanguages;
}
// return the preferred language of the users
// it's using HTTP_ACCEPT_LANGUAGE (send from the users browser)
// and ...(to find out which languages are installed)
function getPreferredLanguage()
{
global $HTTP_ACCEPT_LANGUAGE;
// create a array of languages the user is accepting
$userLanguages = explode(",",$HTTP_ACCEPT_LANGUAGE);
$supportedLanguages = $this->getInstalledLanguages();
// find usersupported language
while (list($key,$value) = each($userLanguages))
{
// remove everything behind "-" example: de-de
$value = trim($value);
$pieces = explode("-", $value);
$value = $pieces[0];
# print "current lang $value
";
if ($supportedLanguages[$value])
{
$retValue=$value;
break;
}
}
// no usersupported language found -> return english
if (empty($retValue))
{
$retValue="en";
}
return $retValue;
}
// connect to the ldap server and return a handle
function ldapConnect($host = "", $dn = "", $passwd = "")
{
global $phpgw_info;
if (! $host) {
$host = $phpgw_info["server"]["ldap_host"];
}
if (! $dn) {
$dn = $phpgw_info["server"]["ldap_root_dn"];
}
if (! $passwd) {
$passwd = $phpgw_info["server"]["ldap_root_passwd"];
}
// connect to ldap server
if (! $ds = ldap_connect($host)) {
printf("Error: Can't connect to LDAP server %s!
",$host);
return False;
}
// bind as admin, we not to able to do everything
if (! ldap_bind($ds,$dn,$passwd)) {
printf("Error: Can't bind to LDAP server: %s!
",$dn);
return False;
}
return $ds;
}
// This function is used if the developer wants to stop a running app in the middle of execution
// We may need to do some clean up before hand
function phpgw_exit($call_footer = False)
{
global $phpgw;
if ($call_footer) {
$this->phpgw_footer();
}
$phpgw->db->disconnect();
exit;
}
function randomstring($size)
{
$s = "";
srand((double)microtime()*1000000);
$random_char = array("0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f",
"g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v",
"w","x","y","z","A","B","C","D","E","F","G","H","I","J","K","L",
"M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");
for ($i=0; $i<$size; $i++) {
$s .= $random_char[rand(1,61)];
}
return $s;
}
// Look at the note towards the top of this file (jengo)
function filesystem_separator()
{
return filesystem_separator();
}
function error_list($error)
{
$html_error = '
' . lang("error") . ': | ' . $error[0] . ' |
'; } $output_text .= ' | ' . $fs . $tab[1]["label"] . $fse . ' | '; if ($i == count($tabs)) { $output_text .= ''; } else { $output_text .= ' | '; } } else { if ($i == 1) { $output_text .= ' | '; } $output_text .= ' | ' . $fs . $tab[1]["label"] . $fse . ' | '; if (($i + 1) == $selected) { $output_text .= ''; } else if ($i == $selected || $i != count($tabs)) { $output_text .= ' | '; } else if ($i == count($tabs)) { if ($i == $selected) { $output_text .= ' | '; } else { $output_text .= ' | '; } } else { if ($i != count($tabs)) { $output_text .= ' | '; } } } $i++; $output_text .= "\n"; } $output_text .= " |
"
. lang("Error deleting x x directory",lang("users")," ".lang("private")." ")
. ",
" . lang("Please x by hand",lang("delete")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 35: $s .= lang("Account has been updated") . "
"
. lang("Error renaming x x directory",lang("users"),
" ".lang("private")." ")
. ",
" . lang("Please x by hand",
lang("rename")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 36: $s .= lang("Account has been created") . "
"
. lang("Error creating x x directory",lang("users"),
" ".lang("private")." ")
. ",
" . lang("Please x by hand",
lang("create")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 37: $s .= lang("Group has been added") . "
"
. lang("Error creating x x directory",lang("groups")," ")
. ",
" . lang("Please x by hand",
lang("create")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/groups/");
break;
case 38: $s .= lang("Group has been deleted") . "
"
. lang("Error deleting x x directory",lang("groups")," ")
. ",
" . lang("Please x by hand",
lang("delete")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/groups/");
break;
case 39: $s .= lang("Group has been updated") . "
"
. lang("Error renaming x x directory",lang("groups")," ")
. ",
" . lang("Please x by hand",
lang("rename")) . "
"
. lang("To correct this error for the future you will need to properly set the")
. "
" . lang("permissions to the files/users directory")
. "
" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/groups/");
break;
case 40: $s .= lang("You have not entered a\nBrief Description").".";
break;
case 41: $s .= lang("You have not entered a\nvalid time of day.");
break;
case 42: $s .= lang("You have not entered a\nvalid date.");
break;
default: return "";
}
return $s;
}
function phpgw_error($error,$line = "", $file = "")
{
echo "
phpGroupWare internal error:
$error"; if ($line) { echo "Line: $line"; } if ($file) { echo "File: $file"; } echo "
Your session has been halted.";
exit;
}
function create_phpcode_from_array($array)
{
while (list($key, $val) = each($array)) {
if (is_array($val)) {
while (list($key2, $val2) = each($val)) {
if (is_array($val2)) {
while (list($key3, $val3) = each ($val2)) {
if (is_array($val3)) {
while (list($key4, $val4) = each ($val3)) {
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]["' . $key3 . '"]["' .$key4 . '"]="' . $val4 . '";';
$s .= "\n";
}
} else {
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]["' . $key3 . '"]="' . $val3 . '";';
$s .= "\n";
}
}
} else {
$s .= '$phpgw_info["' . $key .'"]["' . $key2 . '"]="' . $val2 . '";';
$s .= "\n";
}
}
} else {
$s .= '$phpgw_info["' . $key . '"]="' . $val . '";';
$s .= "\n";
}
}
return $s;
}
// This will return the full phpgw_info array, used for debugging
function debug_phpgw_info()
{
global $phpgw_info;
while (list($key, $val) = each($phpgw_info)) {
if (is_array($val)) {
while (list($key2, $val2) = each($val)) {
if (is_array($val2)) {
while (list($key3, $val3) = each ($val2)) {
if (is_array($val3)) {
while (list($key4, $val4) = each ($val3)) {
echo "phpgw_info[$key][$key2][$key3][$key4]=$val4
";
}
} else {
echo "phpgw_info[$key][$key2][$key3]=$val3
";
}
}
} else {
echo "phpgw_info[$key][$key2]=$val2
";
}
}
} else {
echo "phpgw_info[$key]=$val
";
}
}
}
// This will return a list of functions in the API
function debug_list_core_functions()
{
global $phpgw_info;
echo "
core functions
";
echo "
"; chdir($phpgw_info["server"]["include_root"]."/phpgwapi"); system("grep -r '^[ \t]*function' *"); echo ""; } function common_() { global $phpgw, $phpgw_info; $phpgw_info["server"]["dir_separator"] = $this->filesystem_separator(); } } class hooks { function read() { global $phpgw; $db = $phpgw->db; $db->query("select * from phpgw_hooks"); while ($db->next_record()) { $return_array[$db->f("hook_id")]["app"] = $db->f("hook_appname"); $return_array[$db->f("hook_id")]["location"] = $db->f("hook_location"); $return_array[$db->f("hook_id")]["filename"] = $db->f("hook_filename"); } return $return_array; } function proccess($type,$where = "") { global $phpgw_info, $phpgw; $currentapp = $phpgw_info["flags"]["currentapp"]; $type = strtolower($type); if ($type != "location" && $type != "app") { return False; } // Add a check to see if that location/app has a hook // This way it doesn't have to loop everytime while ($hook = each($phpgw_info["hooks"])) { if ($type == "app") { if ($hook[1]["app"] == $currentapp) { $include_file = $phpgw_info["server"]["server_root"] . "/" . $currentapp . "/hooks/" . $hook[1]["app"] . $hook[1]["filename"]; include($include_file); } } else if ($type == "location") { if ($hook[1]["location"] == $where) { $include_file = $phpgw_info["server"]["server_root"] . "/" . $hook[1]["app"] . "/hooks/" . $hook[1]["filename"]; if (! is_file($include_file)) { $phpgw->common->phpgw_error("Failed to include hook: $include_file"); } else { include($include_file); } } } } } }