switching to the new Object factory method

This commit is contained in:
seek3r 2001-01-11 10:04:28 +00:00
parent e97ef24062
commit 431f841cba
40 changed files with 10 additions and 8274 deletions

View File

@ -81,11 +81,11 @@
\**************************************************************************/
$phpgw_info["server"]["api_inc"] = $phpgw_info["server"]["include_root"]."/phpgwapi/inc";
include($phpgw_info["server"]["server_root"]."/version.inc.php");
$phpgw_info["server"]["versions"]["header"] = "1.9";
$phpgw_info["server"]["versions"]["header"] = "1.10";
// This is a fix for NT
if (!isset($phpgw_info["flags"]["noapi"]) ||
!$phpgw_info["flags"]["noapi"] == True){
include($phpgw_info["server"]["api_inc"] . "/phpgw.inc.php");
include($phpgw_info["server"]["api_inc"] . "/functions.inc.php");
}
// Leave off the final php closing tag, some editors will add

View File

@ -1,4 +1,4 @@
<?php
include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/class.accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/class.accounts_shared.inc.php");
include($phpgw_info["server"]["api_inc"]."/class.accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
include($phpgw_info["server"]["api_inc"]."/class.accounts_shared.inc.php");
?>

View File

@ -1 +1 @@
<?php include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/class.auth_".$phpgw_info["server"]["auth_type"].".inc.php"); ?>
<?php include($phpgw_info["server"]["api_inc"]."/class.auth_".$phpgw_info["server"]["auth_type"].".inc.php"); ?>

View File

@ -1 +1 @@
<?php include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/class.db_".$phpgw_info["server"]["db_type"].".inc.php"); ?>
<?php include($phpgw_info["server"]["api_inc"]."/class.db_".$phpgw_info["server"]["db_type"].".inc.php"); ?>

View File

@ -1 +1 @@
<?php include($phpgw_info["server"]["include_root"]."/phpgwapi/inc/class.translation_".$phpgw_info["server"]["translation_system"].".inc.php"); ?>
<?php include($phpgw_info["server"]["api_inc"]."/class.translation_".$phpgw_info["server"]["translation_system"].".inc.php"); ?>

View File

@ -20,440 +20,7 @@
exit;
} unset($d1);unset($d2);unset($d3);
error_reporting(7);
/****************************************************************************\
* Quick verification of updated header.inc.php *
* This file is retired, but I left ut here for backward compatibility. Seek3r*
\****************************************************************************/
if ($phpgw_info["server"]["versions"]["header"] != $phpgw_info["server"]["versions"]["current_header"]){
echo "You need to port your settings to the new header.inc.php version.";
}
/****************************************************************************\
* Load up all the base files *
\****************************************************************************/
include($phpgw_info["server"]["api_inc"] . "/phpgw_info.inc.php");
/****************************************************************************\
* Required classes *
\****************************************************************************/
/* Load selected database class */
if (empty($phpgw_info["server"]["db_type"])){$phpgw_info["server"]["db_type"] = "mysql";}
include($phpgw_info["server"]["api_inc"] . "/phpgw_db_".$phpgw_info["server"]["db_type"].".inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_session.inc.php");
/* Load selected translation class */
if (empty($phpgw_info["server"]["translation_system"])){$phpgw_info["server"]["translation_system"] = "sql";}
include($phpgw_info["server"]["api_inc"] . "/phpgw_lang_".$phpgw_info["server"]["translation_system"].".inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_crypto.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_template.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_common.inc.php");
/****************************************************************************\
* Optional classes, which can be disabled for performance increases *
* - they are loaded after pulling in the config from the DB *
\****************************************************************************/
function load_optional()
{
global $phpgw,$phpgw_info;
if ($phpgw_info["flags"]["enable_categories_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_categories.inc.php");
$phpgw->categories = new categories;
}
if ($phpgw_info["flags"]["enable_network_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_network.inc.php");
$phpgw->network = new network;
}
if ($phpgw_info["flags"]["enable_send_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_send.inc.php");
$phpgw->send = new send;
}
if ($phpgw_info["flags"]["enable_nextmatchs_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_nextmatchs.inc.php");
$phpgw->nextmatchs = new nextmatchs;
}
if ($phpgw_info["flags"]["enable_utilities_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities.inc.php");
$phpgw->utilities = new utilities;
}
if ($phpgw_info["flags"]["enable_vfs_class"]) {
include($phpgw_info["server"]["api_inc"] . "/phpgw_vfs.inc.php");
$phpgw->vfs = new vfs;
}
}
/****************************************************************************\
* Our API class starts here *
\****************************************************************************/
class phpgw
{
var $accounts;
var $acl;
var $auth;
var $db;
var $debug = 0; // This will turn on debugging information.
// (Not fully working)
var $crypto;
var $categories;
var $common;
var $hooks;
var $network;
var $nextmatchs;
var $preferences;
var $session;
var $send;
var $template;
var $translation;
var $utilities;
var $vfs;
var $calendar;
var $msg;
var $addressbook;
var $todo;
// This is here so you can decied what the best way to handle bad sessions
// You could redirect them to login.php with code 2 or use the default
// I recommend using the default until all of the bugs are worked out.
function phpgw_()
{
global $phpgw_info, $sessionid, $login;
/************************************************************************\
* Required classes *
\************************************************************************/
$this->db = new db;
$this->db->Host = $phpgw_info["server"]["db_host"];
$this->db->Type = $phpgw_info["server"]["db_type"];
$this->db->Database = $phpgw_info["server"]["db_name"];
$this->db->User = $phpgw_info["server"]["db_user"];
$this->db->Password = $phpgw_info["server"]["db_pass"];
if ($this->debug) {
$this->db->Debug = 1;
}
if ($phpgw_info["flags"]["currentapp"] == "login") {
$this->db->query("select * from config",__LINE__,__FILE__);
while($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = $this->db->f("config_value");
}
} else {
$config_var = array("encryptkey","auth_type","account_repository");
$c= "";
for ($i=0;$i<count($config_var);$i++) {
if($i) $c .= " OR ";
$c .= "config_name='".$config_var[$i]."'";
}
$this->db->query("select * from config where $c",__LINE__,__FILE__);
while($this->db->next_record()) {
$phpgw_info["server"][$this->db->f("config_name")] = $this->db->f("config_value");
}
}
/************************************************************************\
* Continue adding the classes *
\************************************************************************/
$this->common = new common;
$this->hooks = new hooks;
/* Load selected authentication class */
if (empty($phpgw_info["server"]["auth_type"])){$phpgw_info["server"]["auth_type"] = "sql";}
include($phpgw_info["server"]["api_inc"] . "/phpgw_auth_".$phpgw_info["server"]["auth_type"].".inc.php");
$this->auth = new auth;
/* Load selected accounts class */
if (empty($phpgw_info["server"]["account_repository"])){$phpgw_info["server"]["account_repository"] = $phpgw_info["server"]["auth_type"];}
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_".$phpgw_info["server"]["account_repository"].".inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_accounts_shared.inc.php");
$this->accounts = new accounts;
$this->preferences = new preferences(0);
$this->session = new sessions;
if ($phpgw_info["flags"]["currentapp"] == "login") {
$log = explode("@",$login);
$this->preferences = new preferences($log[0]);
}else{
if (! $this->session->verify()) {
$this->db->query("select config_value from config where config_name='webserver_url'",__LINE__,__FILE__);
$this->db->next_record();
Header("Location: " . $this->redirect($this->link($this->db->f("config_value")."/login.php","cd=10")));
exit;
}
$this->preferences = new preferences(intval($phpgw_info["user"]["account_id"]));
}
$this->translation = new translation;
$this->acl = new acl;
$sep = filesystem_separator();
$template_root = $this->common->get_tpl_dir();
if (is_dir($template_root)) {
$this->template = new Template($template_root);
}
}
/**************************************************************************\
* Core functions *
\**************************************************************************/
/* A function to handle session support via url session id, or cookies */
function link($url = "", $extravars = "")
{
global $phpgw, $phpgw_info, $usercookie, $kp3, $PHP_SELF;
if (! $kp3)
$kp3 = $phpgw_info["user"]["kp3"];
// PHP won't allow you to set a var to a var
// or function for default values
if (! $url) {
$url_root = split ("/", $phpgw_info["server"]["webserver_url"]);
$url = $url_root[0]."//".$url_root[2].$PHP_SELF;
/* Some hosting providers have their paths screwy.
If the value from $PHP_SELF is not what you expect, you can use this to patch it
It will need to be adjusted to your specific problem tho.
*/
//$patched_php_self = str_replace("/php4/php/phpgroupware", "/phpgroupware", $PHP_SELF);
$patched_php_self = $PHP_SELF;
$url = $url_root[0]."//".$url_root[2].$patched_php_self;
}
if (isset($phpgw_info["server"]["usecookies"]) &&
$phpgw_info["server"]["usecookies"]) {
if ($extravars) {
$url .= "?$extravars";
}
} else {
$url .= "?sessionid=" . $phpgw_info["user"]["sessionid"];
$url .= "&kp3=" . $kp3;
$url .= "&domain=" . $phpgw_info["user"]["domain"];
// This doesn't belong in the API.
// Its up to the app to pass this value. (jengo)
// Putting it into the app requires a massive number of updates in email app.
// Until that happens this needs to stay here (seek3r)
if ($phpgw_info["flags"]["newsmode"]) {
$url .= "&newsmode=on";
}
if ($extravars) {
$url .= "&$extravars";
}
}
$url = str_replace("/?", "/index.php?", $url);
$webserver_url_count = strlen($phpgw_info["server"]["webserver_url"]);
$slash_check = strtolower(substr($url ,0,1));
if(substr($url ,0,$webserver_url_count) != $phpgw_info["server"]["webserver_url"]) {
$app = $phpgw_info["flags"]["currentapp"];
if($slash_check == "/") {
$url = $phpgw_info["server"]["webserver_url"].$url;
} elseif ($app == "home" || $app == "logout" || $app == "login"){
$url = $phpgw_info["server"]["webserver_url"]."/".$url;
}else{
$url = $phpgw_info["server"]["webserver_url"]."/".$app."/".$url;
}
}
return $url;
}
function strip_html($s)
{
return htmlspecialchars(stripslashes($s));
}
function redirect($url = "")
{
// This function handles redirects under iis and apache
// it assumes that $phpgw->link() has already been called
global $HTTP_ENV_VARS;
$iis = strpos($HTTP_ENV_VARS["SERVER_SOFTWARE"], "IIS", 0);
if ( !$url ) {
$url = $PHP_SELF;
}
if ( $iis ) {
echo "\n<HTML>\n<HEAD>\n<TITLE>Redirecting to $url</TITLE>";
echo "\n<META HTTP-EQUIV=REFRESH CONTENT=\"0; URL=$url\">";
echo "\n</HEAD><BODY>";
echo "<H3>Please continue to <a href=\"$url\">this page</a></H3>";
echo "\n</BODY></HTML>";
exit;
} else {
Header("Location: $url");
print("\n\n");
exit;
}
}
function lang($key, $m1 = "", $m2 = "", $m3 = "", $m4 = "")
{
global $phpgw;
return $phpgw->translation->translate($key);
}
// Some people might prefear to use this one
function _L($key, $m1 = "", $m2 = "", $m3 = "", $m4 = "")
{
global $phpgw;
return $phpgw->translation->translate($key);
}
}
/****************************************************************************\
* Our API class ends here *
\****************************************************************************/
/****************************************************************************\
* Direct functions, which are not part of the API class *
* for whatever reason. *
\****************************************************************************/
function lang($key, $m1="", $m2="", $m3="", $m4="", $m5="", $m6="", $m7="", $m8="", $m9="", $m10="" )
{
global $phpgw;
// # TODO: check if $m1 is of type array.
// If so, use it instead of $m2-$mN (Stephan)
$vars = array( $m1, $m2, $m3, $m4, $m5, $m6, $m7, $m8, $m9, $m10 );
$value = $phpgw->translation->translate("$key", $vars );
return $value;
}
// Just a temp wrapper.
function check_code($code)
{
global $phpgw;
return $phpgw->common->check_code($code);
}
/****************************************************************************\
* These lines load up the API, fill up the $phpgw_info array, etc *
\****************************************************************************/
$phpgw = new phpgw;
$phpgw->phpgw_();
if ($phpgw_info["flags"]["currentapp"] != "login" &&
$phpgw_info["flags"]["currentapp"] != "logout") {
// if (! $phpgw->session->verify()) {
// Header("Location: " . $phpgw->link($phpgw_info["server"]["webserver_url"] . "/login.php", "cd=10"));
// exit;
// }
load_optional();
phpgw_fillarray();
$phpgw->common->common_();
if ($phpgw_info["flags"]["enable_utilities_class"]){
$phpgw->utilities->utilities_();
}
if (!isset($phpgw_info["flags"]["nocommon_preferences"]) ||
!$phpgw_info["flags"]["nocommon_preferences"]) {
if (!isset($phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) ||
!$phpgw_info["user"]["preferences"]["common"]["maxmatchs"]) {
$phpgw->preferences->change("common","maxmatchs",15);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["theme"]) ||
!$phpgw_info["user"]["preferences"]["common"]["theme"]) {
$phpgw->preferences->change("common","theme","default");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["dateformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["dateformat"]) {
$phpgw->preferences->change("common","dateformat","m/d/Y");
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["timeformat"]) ||
!$phpgw_info["user"]["preferences"]["common"]["timeformat"]) {
$phpgw->preferences->change("common","timeformat",12);
$preferences_update = True;
}
if (!isset($phpgw_info["user"]["preferences"]["common"]["lang"]) ||
!$phpgw_info["user"]["preferences"]["common"]["lang"]) {
$phpgw->preferences->change("common","lang",$phpgw->common->getPreferredLanguage());
$preferences_update = True;
}
if ($preferences_update) {
echo "Committing new preferences<br>\n";
$phpgw->preferences->commit(__LINE__,__FILE__);
}
unset($preferences_update);
}
/*************************************************************************\
* These lines load up the themes *
\*************************************************************************/
include($phpgw_info["server"]["server_root"] . "/phpgwapi/themes/" .
$phpgw_info["user"]["preferences"]["common"]["theme"] . ".theme");
if ($phpgw_info["theme"]["bg_color"] == "") {
/* Looks like there was a problem finding that theme. Try the default */
echo "Warning: error locating selected theme";
include ($phpgw_info["server"]["server_root"] . "/phpgwapi/themes/default.theme");
if ($phpgw_info["theme"]["bg_color"] == "") {
// Hope we don't get to this point. Better then the user seeing a
// complety back screen and not know whats going on
echo "<body bgcolor=FFFFFF>Fatal error: no themes found";
exit;
}
}
/*************************************************************************\
* If they are using frames, we need to set some variables *
\*************************************************************************/
if (($phpgw_info["user"]["preferences"]["common"]["useframes"] && $phpgw_info["server"]["useframes"] == "allowed")
|| ($phpgw_info["server"]["useframes"] == "always")) {
$phpgw_info["flags"]["navbar_target"] = "phpgw_body";
}
/*************************************************************************\
* Verify that the users session is still active otherwise kick them out *
\*************************************************************************/
if ($phpgw_info["flags"]["currentapp"] != "home" &&
$phpgw_info["flags"]["currentapp"] != "logout" &&
$phpgw_info["flags"]["currentapp"] != "preferences" &&
$phpgw_info["flags"]["currentapp"] != "about") {
if (! $phpgw_info["user"]["apps"][$phpgw_info["flags"]["currentapp"]]) {
$phpgw->common->phpgw_header();
echo "<p><center><b>".lang("Access not permitted")."</b></center>";
exit;
}
}
/*************************************************************************\
* Load the header unless the developer turns it off *
\*************************************************************************/
if (! $phpgw_info["flags"]["noheader"]) {
$phpgw->common->phpgw_header();
}
/*************************************************************************\
* Load the app include files if the exists *
\*************************************************************************/
/* Then the include file */
if (file_exists ($phpgw_info["server"]["app_inc"]."/functions.inc.php")){
include($phpgw_info["server"]["app_inc"]."/functions.inc.php");
}
if (!$phpgw_info["flags"]["noheader"] &&
!$phpgw_info["flags"]["noappheader"] &&
file_exists ($phpgw_info["server"]["app_inc"]."/header.inc.php")) {
include($phpgw_info["server"]["app_inc"]."/header.inc.php");
}
}
error_reporting(7);
include($phpgw_info["server"]["api_inc"] . "/functions.inc.php");

View File

@ -1,312 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class accounts_
{
var $groups;
var $group_names;
var $apps;
function phpgw_fillarray()
{
global $phpgw_info, $phpgw;
// get a ldap connection handle
$ds = $phpgw->common->ldapConnect();
// search the dn for the given uid
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uid=".$phpgw_info["user"]["userid"]);
$allValues = ldap_get_entries($ds, $sri);
/* Now dump it into the array; take first entry found */
$phpgw_info["user"]["account_id"] = $allValues[0]["uidnumber"][0];
$phpgw_info["user"]["account_dn"] = $allValues[0]["dn"];
$phpgw_info["user"]["account_lid"] = $allValues[0]["uid"][0];
$phpgw_info["user"]["firstname"] = $allValues[0]["givenname"][0];
$phpgw_info["user"]["lastname"] = $allValues[0]["sn"][0];
$phpgw_info["user"]["fullname"] = $allValues[0]["cn"][0];
/*
// Please don't remove this code. Lars Kneschke
// remove the "count" value
for ($i=0; $i < $allValues[0]["phpgw_groups"]["count"]; $i++)
{
$phpgw_info["user"]["groups"][] = $allValues[0]["phpgw_groups"][$i];
}
// remove the "count" value
for ($i=0; $i < $allValues[0]["phpgw_account_perms"]["count"]; $i++)
{
$phpgw_info["user"]["app_perms"][] = $allValues[0]["phpgw_account_perms"][$i];
}
$phpgw_info["user"]["lastlogin"] = $allValues[0]["phpgw_lastlogin"][0];
$phpgw_info["user"]["lastloginfrom"] = $allValues[0]["phpgw_lastfrom"][0];
$phpgw_info["user"]["lastpasswd_change"] = $allValues[0]["phpgw_lastpasswd_change"][0];
$phpgw_info["user"]["status"] = $allValues[0]["phpgw_status"][0];
*/
$db = $phpgw->db;
$db->query("select * from accounts where account_lid='" . $phpgw_info["user"]["userid"] . "'",__LINE__,__FILE__);
$db->next_record();
$phpgw_info["user"]["groups"] = explode (",",$db->f("account_groups"));
$phpgw_info["user"]["app_perms"] = explode (":",$db->f("account_permissions"));
$phpgw_info["user"]["lastlogin"] = $db->f("account_lastlogin");
$phpgw_info["user"]["lastloginfrom"] = $db->f("account_lastloginfrom");
$phpgw_info["user"]["lastpasswd_change"] = $db->f("account_lastpwd_change");
$phpgw_info["user"]["status"] = $db->f("account_status");
}
function read_userData($dn)
{
global $phpgw_info, $phpgw;
// get a ldap connection handle
$ds = $phpgw->common->ldapConnect();
// search the dn for the given uid
$sri = ldap_read($ds,rawurldecode("$dn"),"objectclass=*");
$allValues = ldap_get_entries($ds, $sri);
/* Now dump it into the array; take first entry found */
$userData["account_id"] = $allValues[0]["uidnumber"][0];
$userData["account_dn"] = $allValues[0]["dn"];
$userData["account_lid"] = $allValues[0]["uid"][0];
$userData["firstname"] = $allValues[0]["givenname"][0];
$userData["lastname"] = $allValues[0]["sn"][0];
$userData["fullname"] = $allValues[0]["cn"][0];
/* // Please don't remove this code. Lars Kneschke
// remove the "count" value
for ($i=0; $i < $allValues[0]["phpgw_groups"]["count"]; $i++)
{
$userData["groups"][] = $allValues[0]["phpgw_groups"][$i];
}
// remove the "count" value
for ($i=0; $i < $allValues[0]["phpgw_app_perms"]["count"]; $i++)
{
$userData["app_perms"][] = $allValues[0]["phpgw_account_perms"][$i];
}
$userData["lastlogin"] = $allValues[0]["phpgw_lastlogin"][0];
$userData["lastloginfrom"] = $allValues[0]["phpgw_lastfrom"][0];
$userData["lastpasswd_change"] = $allValues[0]["phpgw_lastpasswd_change"][0];
$userData["status"] = $allValues[0]["phpgw_status"][0];
*/
$db = $phpgw->db;
$db->query("select * from accounts where account_lid='" . $userData["account_lid"] . "'",__LINE__,__FILE__);
$db->next_record();
$userData["groups"] = explode (",",$db->f("account_groups"));
$userData["app_perms"] = explode (":",$db->f("account_permissions"));
$userData["lastlogin"] = $db->f("account_lastlogin");
$userData["lastloginfrom"] = $db->f("account_lastloginfrom");
$userData["lastpasswd_change"] = $db->f("account_lastpwd_change");
$userData["status"] = $db->f("account_status");
return $userData;
}
function read_groups($lid) {
global $phpgw_info, $phpgw;
$db = $phpgw->db;
$db->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
$db->next_record();
$gl = explode(",",$db->f("account_groups"));
for ($i=1; $i<(count($gl)-1); $i++) {
$ga = explode(":",$gl[$i]);
$groups[$ga[0]] = $ga[1];
}
return $groups;
}
function read_group_names($lid = "")
{
global $phpgw, $phpgw_info;
if (! $lid) {
$lid = $phpgw_info["user"]["userid"];
}
$groups = $this->read_groups($lid);
$db = $phpgw->db;
$i = 0;
while ($groups && $group = each($groups)) {
$db->query("select group_name from groups where group_id=".$group[0],__LINE__,__FILE__);
$db->next_record();
$group_names[$i][0] = $group[0];
$group_names[$i][1] = $db->f("group_name");
$group_names[$i++][2] = $group[1];
}
if (! $lid)
$this->group_names = $group_names;
return $group_names;
}
/* // This works a little odd, but it is required for apps to be listed in the correct order.
// We first take an array of apps in the correct order and give it a value of 1. Which local means false.
// After the app is verified, it is giving the value of 2, meaning true.
function read_apps($lid)
{
global $phpgw, $phpgw_info;
$db = $phpgw->db;
// fing enabled apps in this system
$db->query("select app_name from applications where app_enabled != 0 order by app_order",__LINE__,__FILE__);
while ($phpgw->db->next_record()) {
$enabled_apps[$db->f("app_name")] = 1;
}
// get a ldap connection handle
$ds = $phpgw->common->ldapConnect();
// search the dn for the given uid
$sri = ldap_search($ds, $phpgw_info["server"]["ldap_context"], "uid=$lid");
$allValues = ldap_get_entries($ds, $sri);
for ($i=0; $i < $allValues[0]["phpgw_account_perms"]["count"]; $i++)
{
$pl = $allValues[0]["phpgw_account_perms"][$i];
if ($enabled_apps[$pl])
{
$enabled_apps[$pl] = 2;
}
}
// This is to prevent things from being loaded twice
if ($phpgw_info["user"]["userid"] == $lid) {
$group_list = $this->groups;
} else {
$group_list = $this->read_groups($lid);
}
while ($group_list && $group = each($group_list)) {
$db->query("select group_apps from groups where group_id=".$group[0]);
$db->next_record();
$gp = explode(":",$db->f("group_apps"));
for ($i=1,$j=0;$i<count($gp)-1;$i++,$j++) {
$enabled_apps[$gp[$i]] = 2;
}
}
while ($sa = each($enabled_apps)) {
if ($sa[1] == 2) {
$return_apps[$sa[0]] = True;
}
}
return $return_apps;
}
*/
// This works a little odd, but it is required for apps to be listed in the correct order.
// We first take an array of apps in the correct order and give it a value of 1. Which local means false.
// After the app is verified, it is giving the value of 2, meaning true.
function read_apps($lid)
{
global $phpgw, $phpgw_info;
$db2 = $phpgw->db;
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
while ($db2->next_record()) {
$name = $db2->f("app_name");
$title = $db2->f("app_title");
$status = $db2->f("app_enabled");
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
$enabled_apps[$db2->f("app_name")] = 1;
$app_status[$db2->f("app_name")] = $db2->f("app_status");
}
if (gettype($lid) == "integer") {
$db2->query("select account_permissions from accounts where account_id=$lid",__LINE__,__FILE__);
} else {
$db2->query("select account_permissions from accounts where account_lid='$lid'",__LINE__,__FILE__);
}
$db2->next_record();
$pl = explode(":",$db2->f("account_permissions"));
for ($i=0; $i<count($pl); $i++) {
if ($enabled_apps[$pl[$i]]) {
$enabled_apps[$pl[$i]] = 2;
}
}
$group_list = $this->read_groups($lid);
while ($group_list && $group = each($group_list)) {
$db2->query("select group_apps from groups where group_id=".$group[0],__LINE__,__FILE__);
$db2->next_record();
$gp = explode(":",$db2->f("group_apps"));
for ($i=1,$j=0;$i<count($gp)-1;$i++,$j++) {
$enabled_apps[$gp[$i]] = 2;
}
}
while ($sa = each($enabled_apps)) {
if ($sa[1] == 2) {
$return_apps[$sa[0]] = True;
}
}
return $return_apps;
}
// This will return the group permissions in an array
function read_group_apps($group_id)
{
global $phpgw;
$db = $phpgw->db;
$db->query("select group_apps from groups where group_id=".$group_id,__LINE__,__FILE__);
$db->next_record();
$gp = explode(":",$db->f("group_apps"));
for ($i=1,$j=0;$i<count($gp)-1;$i++,$j++) {
$apps_array[$j] = $gp[$i];
}
return $apps_array;
}
// Note: This needs to work off LDAP (jengo)
function listusers($groups="")
{
global $phpgw;
$db = $phpgw->db;
if ($groups) {
$db->query("select account_lid,account_firstname,account_lastname from accounts where account_groups"
. "like '%,$groups,%'",__LINE__,__FILE__);
} else {
$db->query("select account_lid,account_firstname,account_lastname from accounts",__LINE__,__FILE__);
}
$i = 0;
while ($db->next_record()) {
$accounts["account_lid"][$i] = $db->f("account_lid");
$accounts["account_firstname"][$i] = $db->f("account_firstname");
$accounts["account_lastname"][$i] = $db->f("account_lastname");
$i++;
}
return $accounts;
}
}

View File

@ -1,361 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class accounts extends accounts_
{
function accounts_const($line,$file)
{
global $phpgw, $phpgw_info;
//echo "accounts_const called<br>line: $line<br>$file";
$phpgw->accounts->phpgw_fillarray();
if(!$phpgw->preferences->account_id) {
$phpgw->preferences = new preferences($phpgw_info["user"]["account_id"]);
}
$phpgw_info["user"]["preferences"] = $phpgw->preferences->get_preferences();
$this->groups = $this->read_groups($phpgw_info["user"]["userid"]);
$this->apps = $this->read_apps($phpgw_info["user"]["userid"]);
$phpgw_info["user"]["apps"] = $this->apps;
}
// use this if you make any changes to phpgw_info, including preferences, config table changes, etc
function sync($line="",$file="")
{
global $phpgw_info, $phpgw;
$db = $phpgw->db;
//echo "<br>sync called<br>Line: $line<br>File:$file";
/* ********This sets the server variables from the database******** */
$db->query("select * from config",__LINE__,__FILE__);
while($db->next_record()) {
$phpgw_info["server"][$db->f("config_name")] = $db->f("config_value");
}
$phpgw->accounts->accounts_const(__LINE__,__FILE__);
$phpgw_info_temp["user"] = $phpgw_info["user"];
$phpgw_info_temp["apps"] = $phpgw_info["apps"];
$phpgw_info_temp["server"] = $phpgw_info["server"];
$phpgw_info_temp["hooks"] = $phpgw->hooks->read();
$phpgw_info_temp["user"]["preferences"] = $phpgw_info["user"]["preferences"];
$phpgw_info_temp["user"]["kp3"] = ""; // We don't want it anywhere in the
// database for security.
if ($PHP_VERSION < "4.0.0") {
$info_string = addslashes($phpgw->crypto->encrypt($phpgw_info_temp));
} else {
$info_string = $phpgw->crypto->encrypt($phpgw_info_temp);
}
$db->query("update phpgw_sessions set session_info='$info_string' where session_id='"
. $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__);
}
function add_app($appname,$rebuild = False)
{
if (! $rebuild) {
if (gettype($appname) == "array") {
$t .= ":";
$t .= implode(":",$appname);
$this->temp_app_list .= $t;
} else {
$this->temp_app_list .= ":" . $appname;
}
} else {
$t = $this->temp_app_list . ":";
unset($this->temp_app_list);
return $t;
}
}
function sql_search($table,$owner=0)
{
global $phpgw_info;
global $phpgw;
$s = "";
// Changed By: Skeeter 29 Nov 00
// This is to allow the user to search for other individuals group info....
if(!$owner) {
$owner = $phpgw_info["user"]["account_id"];
}
$db = $phpgw->db;
$db->query("SELECT account_lid FROM accounts WHERE account_id=".$owner,__LINE__,__FILE__);
$db->next_record();
$groups = $this->read_groups($db->f("account_lid"));
if (gettype($groups) == "array") {
// echo "\n\n\n\n\ntest: " . count($groups) . "\n\n\n\n\n\n";
while ($group = each($groups)) {
$s .= " or $table like '%," . $group[0] . ",%'";
}
}
return $s;
}
// This is used to split the arrays in the access column into an array
function string_to_array($s)
{
$raw_array = explode(",",$s);
for ($i=1,$j=0;$i<count($raw_array)-1; $i++,$j++) {
$return_array[$j] = $raw_array[$i];
}
return $return_array;
}
// This is used to convert a raw group string (,5,6,7,) into a string of
// there names.
// Example: accounting, billing, developers
function convert_string_to_names($gs)
{
global $phpgw;
$groups = explode(",",$gs);
$s = "";
for ($i=1;$i<count($groups)-1; $i++) {
$group_number = explode(",",$groups[$i]);
//$phpgw->db->query("select group_name from groups where group_id=".$groups[$i]);
$phpgw->db->query("select group_name from groups where group_id=".$group_number[0],__LINE__,__FILE__);
$phpgw->db->next_record();
$s .= $phpgw->db->f("group_name");
if (count($groups) != 0 && $i != count($groups)-2)
$s .= ",";
}
return $s;
}
// This one is used for the access column
// This is used to convert a raw group string (,5,6,7,) into a string of
// there names.
// Example: accounting, billing, developers
function convert_string_to_names_access($gs)
{
global $phpgw;
$groups = explode(",",$gs);
$db2 = $phpgw->db;
$s = ""; $i = 0;
for ($j=1;$j<count($groups)-1; $j++) {
$db2->query("select group_name from groups where group_id=".$groups[$j],__LINE__,__FILE__);
$db2->next_record();
$group_names[$i] = $db2->f("group_name");
$i++;
}
return implode(",",$group_names);
}
// Convert an array into the format needed for the groups column in the accounts table.
// This function is only temp, until we create the wrapper class's for different forms
// of auth.
function groups_array_to_string($groups)
{
$s = "";
if (count($groups)) {
while (list($t,$group,$level) = each($groups)) {
$s .= "," . $group . ":0";
}
$s .= ",";
}
return $s;
}
// Convert an array into the format needed for the access column.
function array_to_string($access,$array)
{
$s = "";
if ($access == "group" || $access == "public" || $access == "none") {
if (count($array)) {
while ($t = each($array)) {
$s .= "," . $t[1];
}
$s .= ",";
}
if (! count($array) && $access == "none") {
$s = "";
}
}
return $s;
}
}
class preferences
{
var $account_id;
var $preference;
function preferences($account_id)
{
global $phpgw;
// echo "Account ID (Initializing) = ".$account_id."<br>\n";
$db2 = $phpgw->db;
$load_pref = True;
if (is_long($account_id) && $account_id) {
$this->account_id = $account_id;
} elseif(is_string($account_id)) {
$db2->query("SELECT account_id FROM accounts WHERE account_lid='".$account_id."'",__LINE__,__FILE__);
if($db2->num_rows()) {
$db2->next_record();
$this->account_id = $db2->f("account_id");
} else {
$load_pref = False;
}
} else {
$load_pref = False;
}
//echo "Load Pref = $load_pref<br>\n";
//echo "Account ID (After Initializing) = ".$this->account_id."<br>\n";
if ($load_pref) {
$db2->query("SELECT preference_value FROM preferences WHERE preference_owner=".$this->account_id,__LINE__,__FILE__);
$db2->next_record();
$pref_info = $db2->f("preference_value");
$this->preference = unserialize($pref_info);
// echo "Preferences = ".$this->get_preferences()."<br>\n";
}
}
// This should be called when you are done makeing changes to the preferences
function commit($line = "",$file = "")
{
global $phpgw, $phpgw_info;
//echo "<br>commit called<br>Line: $line<br>File: $file".$phpgw_info["user"]["account_id"]."<br>";
if ($this->account_id) {
$db = $phpgw->db;
$db->query("delete from preferences where preference_owner=" . $this->account_id,__LINE__,__FILE__);
if ($PHP_VERSION < "4.0.0") {
$pref_info = addslashes(serialize($this->preference));
} else {
$pref_info = serialize($this->preference);
}
$db->query("insert into preferences (preference_owner,preference_value) values ("
. $this->account_id . ",'" . $pref_info . "')",__LINE__,__FILE__);
if ($phpgw_info["user"]["account_id"] == $this->account_id) {
$phpgw->preferences->preference = $this->get_preferences();
$phpgw->accounts->sync(__LINE__,__FILE__);
}
}
}
// Add a new preference.
function change($app_name,$var,$value = "")
{
global $phpgw_info;
if (! $value) {
global $$var;
$value = $$var;
}
$this->preference["$app_name"]["$var"] = $value;
}
function delete($app_name,$var)
{
if (! $var) {
$this->reset($app_name);
} else {
unset($this->preference["$app_name"]["$var"]);
}
}
// This will kill all preferences within a certain app
function reset($app_name)
{
$this->preference["$app_name"] = array();
}
function get_preferences()
{
return $this->preference;
}
} //end of preferences class
class acl
{
/* This is a new class. These are sample table entries
insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
values('filemanager', 'create', 1, 'u', 4);
insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
values('filemanager', 'create', 1, 'g', 2);
insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
values('filemanager', 'create', 2, 'u', 1);
insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)
values('filemanager', 'create', 2, 'g', 2);
*/
function check($location, $required, $appname = False){
global $phpgw, $phpgw_info;
if ($appname == False){
$appname = $phpgw_info["flags"]["currentapp"];
}
// User piece
$sql = "select acl_rights from phpgw_acl where acl_appname='$appname'";
$sql .= " and (acl_location in ('$location','everywhere')) and ";
$sql .= "((acl_account_type = 'u' and acl_account = ".$phpgw_info["user"]["account_id"].")";
// Group piece
$sql .= " or (acl_account_type='g' and acl_account in (0"; // group 0 covers all users
$memberships = $phpgw->accounts->read_group_names();
if (is_array($memberships) && count($memberships) > 0){
for ($idx = 0; $idx < count($memberships); ++$idx){
$sql .= ",".$memberships[$idx][0];
}
}
$sql .= ")))";
$rights = 0;
$phpgw->db->query($sql ,__LINE__,__FILE__);
if ($phpgw->db->num_rows() == 0 && $phpgw_info["server"]["acl_default"] != "deny"){ return True; }
while ($phpgw->db->next_record()) {
if ($phpgw->db->f("acl_rights") == 0){ return False; }
$rights |= $phpgw->db->f("acl_rights");
}
return !!($rights & $required);
}
function add($app, $location, $id, $id_type, $rights){
$sql = "insert into phpgw_acl (acl_appname, acl_location, acl_account, acl_account_type, acl_rights)";
$sql .= " values('".$app."', '".$location."', ".$id.", '".$id_type."', ".$rights.")";
$phpgw->db->query($sql ,__LINE__,__FILE__);
return True;
}
function delete($app, $location, $id, $id_type){
$sql = "delete from phpgw_acl where acl_appname='".$app."'";
$sql .= " and acl_location ='".$location."' and ";
$sql .= " acl_account_type = '".$id_type."' and acl_account = ".$id.")";
$phpgw->db->query($sql ,__LINE__,__FILE__);
return True;
}
function view($app, $location, $id, $id_type){
}
} //end of acl class
?>

View File

@ -1,213 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class accounts_
{
var $groups;
var $group_names;
var $apps;
function phpgw_fillarray()
{
global $phpgw_info, $phpgw;
$db2 = $phpgw->db;
$db2->query("select * from accounts where account_lid='" . $phpgw_info["user"]["userid"] . "'",__LINE__,__FILE__);
$db2->next_record();
/* Now dump it into the array */
$phpgw_info["user"]["account_id"] = $db2->f("account_id");
$phpgw_info["user"]["firstname"] = $db2->f("account_firstname");
$phpgw_info["user"]["lastname"] = $db2->f("account_lastname");
$phpgw_info["user"]["fullname"] = $db2->f("account_firstname") . " "
. $db2->f("account_lastname");
$phpgw_info["user"]["groups"] = explode (",", $db2->f("account_groups"));
$phpgw_info["user"]["app_perms"] = explode (":", $db2->f("account_permissions"));
$phpgw_info["user"]["lastlogin"] = $db2->f("account_lastlogin");
$phpgw_info["user"]["lastloginfrom"] = $db2->f("account_lastloginfrom");
$phpgw_info["user"]["lastpasswd_change"] = $db2->f("account_lastpwd_change");
$phpgw_info["user"]["status"] = $db2->f("account_status");
}
function read_userData($id)
{
global $phpgw_info, $phpgw;
$db2 = $phpgw->db;
$db2->query("select * from accounts where account_id='$id'",__LINE__,__FILE__);
$db2->next_record();
/* Now dump it into the array */
$userData["account_id"] = $db2->f("account_id");
$userData["account_lid"] = $db2->f("account_lid");
$userData["firstname"] = $db2->f("account_firstname");
$userData["lastname"] = $db2->f("account_lastname");
$userData["fullname"] = $db2->f("account_firstname") . " "
. $db2->f("account_lastname");
$userData["groups"] = explode(",", $db2->f("account_groups"));
$userData["app_perms"] = explode(":", $db2->f("account_permissions"));
$userData["lastlogin"] = $db2->f("account_lastlogin");
$userData["lastloginfrom"] = $db2->f("account_lastloginfrom");
$userData["lastpasswd_change"] = $db2->f("account_lastpwd_change");
$userData["status"] = $db2->f("account_status");
return $userData;
}
function read_groups($lid)
{
global $phpgw_info, $phpgw;
$db2 = $phpgw->db;
if ($phpgw_info["user"]["userid"] != $lid) {
$db2->query("select account_groups from accounts where account_lid='$lid'",__LINE__,__FILE__);
$db2->next_record();
$gl = explode(",",$db2->f("account_groups"));
} else {
$gl = $phpgw_info["user"]["groups"];
}
for ($i=1; $i<(count($gl)-1); $i++) {
$ga = explode(":",$gl[$i]);
$groups[$ga[0]] = $ga[1];
}
return $groups;
}
function read_group_names($lid = "")
{
global $phpgw, $phpgw_info;
$db2 = $phpgw->db;
if (! $lid) {
$lid = $phpgw_info["user"]["userid"];
}
$groups = $this->read_groups($lid);
$i = 0;
while ($groups && $group = each($groups)) {
$db2->query("select group_name from groups where group_id=".$group[0],__LINE__,__FILE__);
$db2->next_record();
$group_names[$i][0] = $group[0];
$group_names[$i][1] = $db2->f("group_name");
$group_names[$i++][2] = $group[1];
}
if (! $lid) {
$this->group_names = $group_names;
}
return $group_names;
}
// This works a little odd, but it is required for apps to be listed in the correct order.
// We first take an array of apps in the correct order and give it a value of 1. Which local means false.
// After the app is verified, it is giving the value of 2, meaning true.
function read_apps($lid)
{
global $phpgw, $phpgw_info;
$db2 = $phpgw->db;
$db2->query("select * from applications where app_enabled != '0'",__LINE__,__FILE__);
while ($db2->next_record()) {
$name = $db2->f("app_name");
$title = $db2->f("app_title");
$status = $db2->f("app_enabled");
$phpgw_info["apps"][$name] = array("title" => $title, "enabled" => True, "status" => $status);
$enabled_apps[$db2->f("app_name")] = 1;
$app_status[$db2->f("app_name")] = $db2->f("app_status");
}
if (gettype($lid) == "integer") {
$db2->query("select account_permissions from accounts where account_id=$lid",__LINE__,__FILE__);
} else {
$db2->query("select account_permissions from accounts where account_lid='$lid'",__LINE__,__FILE__);
}
$db2->next_record();
$pl = explode(":",$db2->f("account_permissions"));
for ($i=0; $i<count($pl); $i++) {
if ($enabled_apps[$pl[$i]]) {
$enabled_apps[$pl[$i]] = 2;
}
}
$group_list = $this->read_groups($lid);
while ($group_list && $group = each($group_list)) {
$db2->query("select group_apps from groups where group_id=".$group[0],__LINE__,__FILE__);
$db2->next_record();
$gp = explode(":",$db2->f("group_apps"));
for ($i=1,$j=0;$i<count($gp)-1;$i++,$j++) {
$enabled_apps[$gp[$i]] = 2;
}
}
while ($sa = each($enabled_apps)) {
if ($sa[1] == 2) {
$return_apps[$sa[0]] = True;
}
}
return $return_apps;
}
// This will return the group permissions in an array
function read_group_apps($group_id)
{
global $phpgw;
$db2 = $phpgw->db;
$db2->query("select group_apps from groups where group_id=".$group_id,__LINE__,__FILE__);
$db2->next_record();
$gp = explode(":",$db2->f("group_apps"));
for ($i=1,$j=0;$i<count($gp)-1;$i++,$j++) {
$apps_array[$j] = $gp[$i];
}
return $apps_array;
}
function listusers($groups="")
{
global $phpgw;
$db2 = $phpgw->db;
if ($groups) {
$db2->query("select account_lid,account_firstname,account_lastname from accounts where account_groups"
. "like '%,$groups,%'",__LINE__,__FILE__);
} else {
$db2->query("select account_lid,account_firstname,account_lastname from accounts",__LINE__,__FILE__);
}
$i = 0;
while ($db2->next_record()) {
$accounts["account_lid"][$i] = $db2->f("account_lid");
$accounts["account_firstname"][$i] = $db2->f("account_firstname");
$accounts["account_lastname"][$i] = $db2->f("account_lastname");
$i++;
}
return $accounts;
}
}

View File

@ -1,31 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $ Id $ */
class auth
{
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw, $PHP_AUTH_USER;
if (isset($PHP_AUTH_USER)) {
return True;
} else {
return False;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?>

View File

@ -1,62 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id $ */
class auth
{
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw;
// error_reporting MUST be set to zero, otherwise you'll get nasty LDAP errors with a bad login/pass...
// these are just "warnings" and can be ignored.....
error_reporting(0);
$ldap = ldap_connect($phpgw_info["server"]["ldap_host"]);
// find the dn for this uid, the uid is not always in the dn
$sri = ldap_search($ldap, $phpgw_info["server"]["ldap_context"], "uid=$username");
$allValues = ldap_get_entries($ldap, $sri);
if($allValues["count"] > 0)
{
// we only care about the first dn
$userDN = $allValues[0]["dn"];
// generate a bogus password to pass if the user doesn't give us one
// this gets around systems that are anonymous search enabled
if (empty($passwd)) $passwd = crypt(microtime());
// try to bind as the user with user suplied password
if (ldap_bind($ldap,$userDN, $passwd)) return True;
}
// Turn error reporting back to normal
error_reporting(7);
// dn not found or password wrong
return False;
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
$ldap = $phpgw->common->ldapConnect();
$encrypted_passwd = $phpgw->common->encrypt_password($new_passwd);
$entry["userpassword"] = $encrypted_passwd;
#$entry["phpgw_lastpasswd_change"] = time();
$dn = $phpgw_info["user"]["account_dn"];
if (!@ldap_modify($ldap, $dn, $entry)) return false;
return $encrypted_passwd;
}
}
?>

View File

@ -1,47 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id $ */
class auth
{
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw;
error_reporting(error_reporting() - 2);
if ($phpgw_info["server"]["mail_login_type"] == "vmailmgr") {
$username = $username . "@" . $phpgw_info[server][mail_suffix];
}
if ($phpgw_info["server"]["mail_server_type"]=="imap") {
$phpgw_info["server"]["mail_port"] = "143";
} elseif ($phpgw_info["server"]["mail_server_type"]=="pop3") {
$phpgw_info["server"]["mail_port"] = "110";
}
$mailauth = imap_open("{".$phpgw_info["server"]["mail_server"]
.":".$phpgw_info["server"]["mail_port"]."}INBOX", $username , $passwd);
error_reporting(error_reporting() + 2);
if ($mailauth == False) {
return False;
} else {
imap_close($mailauth);
return True;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
return False;
}
}
?>

View File

@ -1,50 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $ Id $ */
class auth
{
function authenticate($username, $passwd) {
global $phpgw_info, $phpgw;
$db = $phpgw->db;
$local_debug = false;
if ($local_debug) {
echo "<b>Debug SQL: uid - $username passwd - $passwd</b>";
}
$db->query("SELECT * FROM accounts WHERE account_lid = '$username' AND "
. "account_pwd='" . md5($passwd) . "' AND account_status ='A'",__LINE__,__FILE__);
$db->next_record();
if ($db->f("account_lid")) {
return True;
} else {
return False;
}
}
function change_password($old_passwd, $new_passwd) {
global $phpgw_info, $phpgw;
$encrypted_passwd = md5($new_passwd);
$phpgw->db->query("update accounts set account_pwd='" . md5($new_passwd) . "' "
. "where account_lid='" . $phpgw_info["user"]["userid"] . "'",__LINE__,__FILE__);
$phpgw->db->query("update accounts set account_lastpwd_change='" . time() . "' where account_id='"
. $phpgw_info["user"]["account_id"] . "'",__LINE__,__FILE__);
return $encrypted_passwd;
}
}
?>

View File

@ -1,68 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - API (categories) *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class categories
{
var $account_id;
var $app_name;
var $cats;
var $db;
function categories($account_id,$app_name)
{
global $phpgw;
$this->account_id = $account_id;
$this->app_name = $app_name;
$this->db = $phpgw->db;
$this->db->query("select * from phpgw_categories where cat_owner='$account_id' and app_name='"
. "$app_name'",__LINE__,__FILE__);
while ($this->db->next_record()) {
$this->cats[]["id"] = $this->db->f("cat_id");
$this->cats[]["parent"] = $this->db->f("cat_parent");
$this->cats[]["name"] = $this->db->f("cat_name");
$this->cats[]["description"] = $this->db->f("cat_description");
$this->cats[]["data"] = $this->db->f("cat_data");
}
}
// Return into a select box, list or other formats
function list()
{
}
function add($app_name,$cat_name,$cat_parent,$cat_description = "", $cat_data = "")
{
$this->db->query("insert into phpgw_categories (cat_parent,cat_owner,cat_appname,cat_name,"
. "cat_description,cat_data) values ('$cat_parent','" . $this->account_id . "','"
. "$app_name','" . addslashes($cat_name) . "','" . addslashes($cat_description)
. "','$cat_data'",__LINE__,__FILE__);
}
function delete($cat_id)
{
$this->db->query("delete from phpgw_categories where cat_id='$cat_id' and cat_owner='"
. $this->account_id . "'",__LINE__,__FILE__);
}
function edit($owner,$app_name,$cat_name,$cat_description)
{
$db2->query("update categories set cat_name='" . addslashes($cat_name) . "', cat_description='"
. addslashes($cat_description) . "' where account_id='$owner' and app_name='"
. addslashes($app_name) . "'");
}
}
?>

View File

@ -1,968 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$d1 = strtolower(substr($phpgw_info["server"]["api_inc"],0,3));
$d2 = strtolower(substr($phpgw_info["server"]["server_root"],0,3));
$d3 = strtolower(substr($phpgw_info["server"]["app_inc"],0,3));
if($d1 == "htt" || $d1 == "ftp" || $d2 == "htt" || $d2 == "ftp" || $d3 == "htt" || $d3 == "ftp") {
echo "Failed attempt to break in via an old Security Hole!<br>\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<br>";
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("<b>Error: Can't connect to LDAP server %s!</b><br>",$host);
return False;
}
// bind as admin, we not to able to do everything
if (! ldap_bind($ds,$dn,$passwd)) {
printf("<b>Error: Can't bind to LDAP server: %s!</b><br>",$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 = '<table border="0" width="50%"><tr><td align="right"><b>' . lang("error") . '</b>: </td><td align="left">' . $error[0] . '</td></tr>';
for ($i=1; $i<count($error); $i++) {
$html_error .= '<tr><td>&nbsp;</td><td align="left">' . $error[$i] . '</td></tr>';
}
return $html_error . '</table>';
}
function check_owner($record,$link,$label,$extravars = "")
{
global $phpgw, $phpgw_info;
$s = '<a href="' . $phpgw->link($link,$extravars) . '"> ' . lang($label) . ' </a>';
if (ereg("^[0-9]+$",$record)) {
if ($record != $phpgw_info["user"]["account_id"]) {
$s = "&nbsp;";
}
} else {
if ($record != $phpgw_info["user"]["userid"]) {
$s = "&nbsp";
}
}
return $s;
}
function display_fullname($lid = "", $firstname = "", $lastname = "")
{
if (! $lid && ! $firstname && ! $lastname) {
global $phpgw_info;
$lid = $phpgw_info["user"]["account_lid"];
$firstname = $phpgw_info["user"]["firstname"];
$lastname = $phpgw_info["user"]["lastname"];
}
if (! $firstname && ! $lastname) {
$s = $lid;
}
if (! $firstname && $lastname) {
$s = $lastname;
}
if ($firstname && ! $lastname) {
$s = $firstname;
}
if ($firstname && $lastname) {
$s = "$lastname, $firstname";
}
return $s;
}
function grab_owner_name($id)
{
global $phpgw;
$db = $phpgw->db;
$db->query("select account_lid,account_firstname,account_lastname from accounts where account_id=".$id,__LINE__,__FILE__);
$db->next_record();
return $phpgw->common->display_fullname($db->f("account_lid"),$db->f("account_firstname"),$db->f("account_lastname"));
}
function create_tabs($tabs, $selected, $fontsize = "")
{
global $phpgw_info;
$output_text = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
$ir = $phpgw_info["server"]["images_dir"];
if ($fontsize) {
$fs = '<font size="' . $fontsize . '">';
$fse = '</font>';
}
$i = 1;
while ($tab = each($tabs)) {
if ($tab[0] == $selected) {
if ($i == 1) {
$output_text .= '<td align="right"><img src="' . $ir . '/tabs-start1.gif"></td>';
}
$output_text .= '<td align="left" background="' . $ir . '/tabs-bg1.gif">&nbsp;<b><a href="'
. $tab[1]["link"] . '" class="tablink">' . $fs . $tab[1]["label"]
. $fse . '</a></b>&nbsp;</td>';
if ($i == count($tabs)) {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end1.gif"></td>';
} else {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepr.gif"></td>';
}
} else {
if ($i == 1) {
$output_text .= '<td align="right"><img src="' . $ir . '/tabs-start0.gif"></td>';
}
$output_text .= '<td align="left" background="' . $ir . '/tabs-bg0.gif">&nbsp;<b><a href="'
. $tab[1]["link"] . '" class="tablink">' . $fs . $tab[1]["label"] . $fse
. '</a></b>&nbsp;</td>';
if (($i + 1) == $selected) {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepl.gif"></td>';
} else if ($i == $selected || $i != count($tabs)) {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepm.gif"></td>';
} else if ($i == count($tabs)) {
if ($i == $selected) {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end1.gif"></td>';
} else {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end0.gif"></td>';
}
} else {
if ($i != count($tabs)) {
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepr.gif"></td>';
}
}
}
$i++;
$output_text .= "\n";
}
$output_text .= "</table>\n";
return $output_text;
}
function get_app_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
$appdir = $phpgw_info["server"]["include_root"]."/".$appname;
$appdir_default = $phpgw_info["server"]["server_root"]."/".$appname;
if (is_dir ($appdir)){
return $appdir;
}elseif (is_dir ($appdir_default)){
return $appdir_default;
}else{
return False;
}
}
function get_inc_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
$incdir = $phpgw_info["server"]["include_root"]."/".$appname."/inc";
$incdir_default = $phpgw_info["server"]["server_root"]."/".$appname."/inc";
if (is_dir ($incdir)){
return $incdir;
}elseif (is_dir ($incdir_default)){
return $incdir_default;
}else{
return False;
}
}
function list_themes(){
global $phpgw_info;
$dh = opendir($phpgw_info["server"]["server_root"] . "/phpgwapi/themes");
while ($file = readdir($dh)) {
if (eregi("\.theme$", $file)) {
$list[] = substr($file,0,strpos($file,"."));
}
}
//$dh->close();
reset ($list);
return $list;
}
function list_templates(){
global $phpgw_info;
$d = dir($phpgw_info["server"]["server_root"]."/phpgwapi/templates");
while($entry=$d->read()) {
if ($entry != "CVS" && $entry != "." && $entry != ".."){
$list[$entry]["name"] = $entry;
$f = $phpgw_info["server"]["server_root"]."/phpgwapi/templates/".$entry."/details.inc.php";
if (file_exists ($f)){
include($f);
$list[$entry]["title"] = "Use ".$phpgw_info["template"][$entry]["title"]."interface";
}else{
$list[$entry]["title"] = $entry;
}
}
}
$d->close();
reset ($list);
return $list;
}
function get_tpl_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if ($appname == "home" || $appname == "logout" || $appname == "login"){$appname = "phpgwapi";}
// Setting this for display of template choices in user preferences
if ($phpgw_info["server"]["template_set"] == "user_choice" ){$phpgw_info["server"]["usrtplchoice"] = "user_choice"; }
if ($phpgw_info["server"]["template_set"] == "user_choice" && isset($phpgw_info["user"]["preferences"]["common"]["template_set"])){
$phpgw_info["server"]["template_set"] = $phpgw_info["user"]["preferences"]["common"]["template_set"];
}elseif ($phpgw_info["server"]["template_set"] == "user_choice" || !isset($phpgw_info["server"]["template_set"])){
$phpgw_info["server"]["template_set"] = "default";
}
$tpldir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"];
$tpldir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default";
if (is_dir ($tpldir)){
return $tpldir;
}elseif (is_dir ($tpldir_default)){
return $tpldir_default;
}else{
return False;
}
}
function get_image_dir($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if (empty($phpgw_info["server"]["template_set"])){$phpgw_info["server"]["template_set"] = "default";}
$imagedir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
$imagedir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default/images";
$imagedir_olddefault = $phpgw_info["server"]["server_root"]."/".$appname."/images";
if (is_dir ($imagedir)){
return $imagedir;
}elseif (is_dir ($imagedir_default)){
return $imagedir_default;
}elseif (is_dir ($imagedir_olddefault)){
return $imagedir_olddefault;
}else{
return False;
}
}
function get_image_path($appname = ""){
global $phpgw_info;
if ($appname == ""){$appname = $phpgw_info["flags"]["currentapp"];}
if (empty($phpgw_info["server"]["template_set"])){$phpgw_info["server"]["template_set"] = "default";}
$imagedir = $phpgw_info["server"]["server_root"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
$imagedir_default = $phpgw_info["server"]["server_root"]."/".$appname."/templates/default/images";
$imagedir_olddefault = $phpgw_info["server"]["server_root"]."/".$appname."/images";
if (is_dir ($imagedir)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/templates/".$phpgw_info["server"]["template_set"]."/images";
}elseif (is_dir ($imagedir_default)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/templates/default/images";
}elseif (is_dir ($imagedir_olddefault)){
return $phpgw_info["server"]["webserver_url"]."/".$appname."/images";
}else{
return False;
}
}
function navbar($called_directly = True)
{
// This is only temp, until will change everything to use the new method
if ($called_directly) {
echo '<center><b>Warning: You can no longer call navbar() directly, use echo parse_navbar() from now on.</b></center>';
}
global $phpgw_info, $phpgw;
$phpgw_info["navbar"]["home"]["title"] = "Home";
$phpgw_info["navbar"]["home"]["url"] = $phpgw->link($phpgw_info["server"]["webserver_url"] . "/index.php");
$phpgw_info["navbar"]["home"]["icon"] = $phpgw_info["server"]["webserver_url"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/images/home.gif";
while ($permission = each($phpgw_info["user"]["apps"])) {
if ($phpgw_info["apps"][$permission[0]]["status"] != 2) {
$phpgw_info["navbar"][$permission[0]]["title"] = $phpgw_info["apps"][$permission[0]]["title"];
$phpgw_info["navbar"][$permission[0]]["url"] = $phpgw->link($phpgw_info["server"]["webserver_url"]
. "/" . $permission[0] . "/index.php");
$icon_file = $phpgw_info["server"]["server_root"]."/".$permission[0] . "/templates/". $phpgw_info["server"]["template_set"]. "/images/navbar.gif";
if (file_exists($icon_file)){
$phpgw_info["navbar"][$permission[0]]["icon"] = $phpgw_info["server"]["webserver_url"] . "/"
. $permission[0] . "/templates/" . $phpgw_info["server"]["template_set"] . "/images/navbar.gif";
}else{
$phpgw_info["navbar"][$permission[0]]["icon"] = $phpgw_info["server"]["webserver_url"] . "/"
. $permission[0] . "/templates/default/images/navbar.gif";
}
}
}
$phpgw_info["navbar"]["preferences"]["title"] = "preferences";
$phpgw_info["navbar"]["preferences"]["url"] = $phpgw->link($phpgw_info["server"]["webserver_url"]
. "/preferences/index.php");
$phpgw_info["navbar"]["preferences"]["icon"] = $phpgw_info["server"]["webserver_url"] . "/preferences/templates/"
. $phpgw_info["server"]["template_set"] . "/images/navbar.gif";
if ($phpgw_info["flags"]["currentapp"] == "home" || $phpgw_info["flags"]["currentapp"] == "preferences" || $phpgw_info["flags"]["currentapp"] == "about") {
$app = "phpGroupWare";
} else {
$app = $phpgw_info["flags"]["currentapp"];
}
$phpgw_info["navbar"]["about"]["title"] = lang("About x",$about); // We handle this here
// becuase its special
$phpgw_info["navbar"]["about"]["url"] = $phpgw->link($phpgw_info["server"]["webserver_url"]
. "/about.php");
$phpgw_info["navbar"]["about"]["icon"] = $phpgw_info["server"]["webserver_url"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/images/about.gif";
$phpgw_info["navbar"]["logout"]["title"] = "Logout";
$phpgw_info["navbar"]["logout"]["url"] = $phpgw->link($phpgw_info["server"]["webserver_url"]
. "/logout.php");
$phpgw_info["navbar"]["logout"]["icon"] = $phpgw_info["server"]["webserver_url"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/images/logout.gif";
}
function app_header() {
if (file_exists ($phpgw_info["server"]["app_inc"]."/header.inc.php")) {
include($phpgw_info["server"]["app_inc"]."/header.inc.php");
}
}
function phpgw_header() {
global $phpgw, $phpgw_info;
include($phpgw_info["server"]["include_root"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/head.inc.php");
$this->navbar(False);
include($phpgw_info["server"]["include_root"] . "/phpgwapi/templates/"
. $phpgw_info["server"]["template_set"] . "/navbar.inc.php");
if ((! isset($phpgw_info["flags"]["nonavbar"]) || ! $phpgw_info["flags"]["nonavbar"]) && ! $phpgw_info["flags"]["navbar_target"]) {
echo parse_navbar();
}
}
function phpgw_footer()
{
global $phpgw, $phpgw_info, $HTMLCOMPLAINT;
if (!isset($phpgw_info["flags"]["nofooter"]) || !$phpgw_info["flags"]["nofooter"]) {
include($phpgw_info["server"]["api_inc"] . "/footer.inc.php");
}
// Clean up mcrypt
if (is_object($this->crypto)) {
$this->crypto->cleanup();
unset($this->crypto);
}
}
function hex2bin($data)
{
$len = strlen($data);
return pack("H" . $len, $data);
}
function encrypt($data) {
global $phpgw_info, $phpgw;
$data = serialize($data);
return $phpgw->crypto->encrypt($data);
}
function decrypt($data) {
global $phpgw_info, $phpgw;
$data = $phpgw->crypto->decrypt($data);
return unserialize($data);
}
function des_cryptpasswd($userpass, $random)
{
$lcrypt = "{crypt}";
$password = crypt($userpass);
$ldappassword = sprintf("%s%s", $lcrypt, $password);
return $ldappassword;
}
function md5_cryptpasswd($userpass, $random)
{
$bsalt = "$1$";
$esalt = "$"; // patch
$lcrypt = "{crypt}";
// $modsalt = sprintf("%s%s", $bsalt, $random);
$modsalt = sprintf("%s%s%s", $bsalt, $random, $esalt); // patch
$password = crypt($userpass, $modsalt);
$ldappassword = sprintf("%s%s", $lcrypt, $password);
return $ldappassword;
}
function encrypt_password($password)
{
global $phpgw, $phpgw_info;
if ($phpgw_info["server"]["ldap_encryption_type"] == "DES") {
$salt = $this->randomstring(2);
$e_password = $this->des_cryptpasswd($password, $salt);
}
if ($phpgw_info["server"]["ldap_encryption_type"] == "MD5") {
// $salt = $this->randomstring(9);
$salt = $this->randomstring(8); // patch
$e_password = $this->md5_cryptpasswd($password, $salt);
}
return $e_password;
}
function hook($location = "", $order = ""){
global $phpgw, $phpgw_info;
if ($order == ""){$order[] = $phpgw_info["flags"]["currentapp"];}
/* First include the ordered apps hook file */
reset ($order);
while (list (, $appname) = each ($order)){
$f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"];
if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; }
if (file_exists($f)) {include($f);}
$completed_hooks[$appname] = True;
}
/* Then add the rest */
reset ($phpgw_info["user"]["app_perms"]);
while (list (, $appname) = each ($phpgw_info["user"]["app_perms"])){
if ($appname != "" && $completed_hooks[$appname] != True){
$f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"];
if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; }
if (file_exists($f)) {include($f);}
}
}
}
function hook_single($location = "", $appname = "")
{
global $phpgw, $phpgw_info;
if (! $appname) {
$appname = $phpgw_info["flags"]["currentapp"];
}
$s = $phpgw->common->filesystem_separator();
/* First include the ordered apps hook file */
$f = $phpgw_info["server"]["server_root"] . $s . $appname . $s . "inc" . $s . "hook_".$appname;
if ($location != "") {
$f .= "_".$location.".inc.php";
} else {
$f .= ".inc.php";
}
if (file_exists($f)) {
include($f);
return True;
} else {
return False;
}
}
function hook_count($location = ""){
global $phpgw, $phpgw_info;
reset ($phpgw_info["user"]["app_perms"]);
$count = 0;
while (list (, $appname) = each ($phpgw_info["user"]["app_perms"])){
$f = $phpgw_info["server"]["server_root"] . "/" . $appname . "/inc/hook_".$phpgw_info["flags"]["currentapp"];
if ($location != ""){$f .= "_".$location.".inc.php";}else{$f .= ".inc.php"; }
if (file_exists($f)) {++$count;}
}
return $count;
}
function appsession($data = "##NOTHING##") {
global $phpgw_info, $phpgw;
if ($data == "##NOTHING##") { /* This allows the user to put "" as the value. */
$phpgw->db->query("select content from phpgw_app_sessions where sessionid = '"
.$phpgw_info["user"]["sessionid"]."' and loginid = '"
.$phpgw_info["user"]["userid"]."' and app = '"
.$phpgw_info["flags"]["currentapp"] . "'",__LINE__,__FILE__);
if($phpgw->db->num_rows()) {
$phpgw->db->next_record();
$data = $phpgw->db->f("content");
$data = $this->decrypt($data);
return $data;
}
} else {
$data = $this->encrypt($data);
$phpgw->db->query("select * from phpgw_app_sessions where sessionid = '"
. $phpgw_info["user"]["sessionid"] . "' and app = '"
. $phpgw_info["flags"]["currentapp"] . "'",__LINE__,__FILE__);
if ($phpgw->db->num_rows()==0) {
$phpgw->db->query("INSERT INTO phpgw_app_sessions (sessionid,loginid,app,content)"
." VALUES ('".$phpgw_info["user"]["sessionid"]."','"
.$phpgw_info["user"]["userid"]
."','".$phpgw_info["flags"]["currentapp"]."','".$data."');",__LINE__,__FILE__);
} else {
$phpgw->db->query("update phpgw_app_sessions set content = '$data' where sessionid = '"
.$phpgw_info["user"]["sessionid"]."' and loginid = '"
.$phpgw_info["user"]["userid"]."'",__LINE__,__FILE__);
}
$data = $this->decrypt($data);
return $data;
}
}
function show_date($t = "", $format = "")
{
global $phpgw_info;
if (! $t)
$t = time();
$t = $t + ((60*60) * $phpgw_info["user"]["preferences"]["common"]["tz_offset"]);
if (! $format) {
$format = $phpgw_info["user"]["preferences"]["common"]["dateformat"] . " - ";
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
$format .= "h:i:s a";
} else {
$format .= "H:i:s";
}
}
return date($format,$t);
}
function dateformatorder($yearstr,$monthstr,$daystr,$add_seperator = False)
{
global $phpgw_info;
$dateformat = strtolower($phpgw_info["user"]["preferences"]["common"]["dateformat"]);
$sep = substr($phpgw_info["user"]["preferences"]["common"]["dateformat"],1,1);
$dlarr[strpos($dateformat,'y')] = $yearstr;
$dlarr[strpos($dateformat,'m')] = $monthstr;
$dlarr[strpos($dateformat,'d')] = $daystr;
ksort($dlarr);
if ($add_seperator) {
return (implode($sep,$dlarr));
} else {
return (implode(" ",$dlarr));
}
}
function formattime($hour,$min,$sec="")
{
global $phpgw_info;
$h12 = $hour;
if ($phpgw_info["user"]["preferences"]["common"]["timeformat"] == "12") {
if ($hour > 12)
$ampm = " pm";
else
$ampm = " am";
$h12 %= 12;
if ($h12 == 0 && $hour)
$h12 = 12;
if ($h12 == 0 && ! $hour)
$h12 = 0;
} else
$h12 = $hour;
if ($sec)
$sec = ":$sec";
return "$h12:$min$sec$ampm";
}
// This will be moved into the applications area.
function check_code($code)
{
$s = "<br>";
switch ($code)
{
case 13: $s .= lang("Your message has been sent");break;
case 14: $s .= lang("New entry added sucessfully");break;
case 15: $s .= lang("Entry updated sucessfully"); break;
case 16: $s .= lang("Entry has been deleted sucessfully"); break;
case 18: $s .= lang("Password has been updated"); break;
case 38: $s .= lang("Password could not be changed"); break;
case 19: $s .= lang("Session has been killed"); break;
case 27: $s .= lang("Account has been updated"); break;
case 28: $s .= lang("Account has been created"); break;
case 29: $s .= lang("Account has been deleted"); break;
case 30: $s .= lang("Your settings have been updated"); break;
case 31: $s .= lang("Group has been added"); break;
case 32: $s .= lang("Group has been deleted"); break;
case 33: $s .= lang("Group has been updated"); break;
case 34: $s .= lang("Account has been deleted") . "<p>"
. lang("Error deleting x x directory",lang("users")," ".lang("private")." ")
. ",<br>" . lang("Please x by hand",lang("delete")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 35: $s .= lang("Account has been updated") . "<p>"
. lang("Error renaming x x directory",lang("users"),
" ".lang("private")." ")
. ",<br>" . lang("Please x by hand",
lang("rename")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 36: $s .= lang("Account has been created") . "<p>"
. lang("Error creating x x directory",lang("users"),
" ".lang("private")." ")
. ",<br>" . lang("Please x by hand",
lang("create")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/users/");
break;
case 37: $s .= lang("Group has been added") . "<p>"
. lang("Error creating x x directory",lang("groups")," ")
. ",<br>" . lang("Please x by hand",
lang("create")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/groups/");
break;
case 38: $s .= lang("Group has been deleted") . "<p>"
. lang("Error deleting x x directory",lang("groups")," ")
. ",<br>" . lang("Please x by hand",
lang("delete")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . lang("On *nix systems please type: x","chmod 707 "
. $phpgw_info["server"]["files_dir"] . "/groups/");
break;
case 39: $s .= lang("Group has been updated") . "<p>"
. lang("Error renaming x x directory",lang("groups")," ")
. ",<br>" . lang("Please x by hand",
lang("rename")) . "<br><br>"
. lang("To correct this error for the future you will need to properly set the")
. "<br>" . lang("permissions to the files/users directory")
. "<br>" . 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 "<p><b>phpGroupWare internal error:</b><p>$error";
if ($line) {
echo "Line: $line";
}
if ($file) {
echo "File: $file";
}
echo "<p>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<br>";
}
} else {
echo "phpgw_info[$key][$key2][$key3]=$val3<br>";
}
}
} else {
echo "phpgw_info[$key][$key2]=$val2<br>";
}
}
} else {
echo "phpgw_info[$key]=$val<br>";
}
}
}
// This will return a list of functions in the API
function debug_list_core_functions()
{
global $phpgw_info;
echo "<br><b>core functions</b><br>";
echo "<pre>";
chdir($phpgw_info["server"]["include_root"]."/phpgwapi");
system("grep -r '^[ \t]*function' *");
echo "</pre>";
}
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);
}
}
}
}
}
}

View File

@ -1,122 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class crypto {
var $td = False; // Handle for mcrypt
var $iv = "";
var $key = "";
function crypto($key,$iv)
{
global $phpgw, $phpgw_info;
if ($phpgw_info["server"]["mcrypt_enabled"] && extension_loaded("mcrypt")) {
if ($phpgw_info["server"]["versions"]["mcrypt"] == "old") {
$this->td = false;
if (PHP_VERSION > "4.0.2pl1") {
$keysize = mcrypt_get_key_size(MCRYPT_TRIPLEDES);
$ivsize = mcrypt_get_iv_size(MCRYPT_TRIPLEDES,MCRYPT_MODE_CBC);
} else {
$keysize = 8;
$ivsize = 8;
}
} else {
// Start up mcrypt
$this->td = mcrypt_module_open (MCRYPT_TRIPLEDES, "", MCRYPT_MODE_CBC, "");
$ivsize = mcrypt_enc_get_iv_size($this->td);
$keysize = mcrypt_enc_get_key_size($this->td);
}
// Hack IV to be the correct size
$x = strlen($iv);
for ($i = 0; $i < $ivsize; $i++) {
$this->iv .= $iv[$i % $x];
}
// Hack Key to be the correct size
$x = strlen($key);
for ($i = 0; $i < $keysize; $i++) {
$this->key .= $key[$i % $x];
}
if ($phpgw_info["server"]["versions"]["mcrypt"] != "old") {
mcrypt_generic_init ($this->td, $this->key, $this->iv);
}
}
// If mcrypt isn't loaded key and iv are not needed
}
function cleanup()
{
global $phpgw_info;
if ($phpgw_info["server"]["mcrypt_enabled"] && extension_loaded("mcrypt")) {
if ($phpgw_info["server"]["versions"]["mcrypt"] != "old") {
mcrypt_generic_end ($this->td);
}
}
}
function hex2bin($data)
{
$len = strlen($data);
return pack("H" . $len, $data);
}
function encrypt($data) {
global $phpgw_info;
$data = serialize($data);
// Disable all encryption if the admin didn't set it up
if ($phpgw_info["server"]["mcrypt_enabled"] && extension_loaded("mcrypt")) {
switch ($phpgw_info["server"]["versions"]["mcrypt"]) {
// The old code, only works with mcrypt <= 2.2.x
case "old": {
$encrypteddata = mcrypt_cbc(MCRYPT_TripleDES, $this->key, $data, MCRYPT_ENCRYPT);
break;
}
default: { // Handle 2.4 and newer API
$encrypteddata = mcrypt_generic($this->td, $data);
}
}
$encrypteddata = bin2hex($encrypteddata);
return $encrypteddata;
} else { // No mcrypt == insecure !
return $data;
}
}
function decrypt($encrypteddata) {
global $phpgw_info;
// Disable all encryption if the admin didn't set it up
if ($phpgw_info["server"]["mcrypt_enabled"] && extension_loaded("mcrypt")) {
$data = $this->hex2bin($encrypteddata);
switch ($phpgw_info["server"]["versions"]["mcrypt"]) {
// The old code, only works with mcrypt <= 2.2.x
case "old": {
$data = mcrypt_cbc(MCRYPT_TripleDES, $this->key, $data, MCRYPT_DECRYPT);
break;
}
default: { // Handle 2.4 and newer API
$data = mdecrypt_generic($this->td, $data);
}
}
return unserialize($data);
} else {
return unserialize($encrypteddata);
}
}
} // class crypto

View File

@ -1,143 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998,1999 SH Online Dienst GmbH
* Boris Erdmann, Kristian Koehntopp
*
* Derived from db_mysql.inc by Sascha Schumann <sascha@schumann.cx>
*
* $Id$
*
*/
class db {
var $Host = "";
var $Database = "";
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row;
var $Error = "";
var $Auto_Free = 0; ## Set this to 1 for automatic msql_free_result()
function connect() {
// Not connected? Then connect?
if ( 0 == $this->Link_ID ) {
// Check for local connect
$this->Link_ID = empty($this->Host)?
$this->Link_ID=msql_pconnect():
$this->Link_ID=msql_pconnect($this->Host);
}
// Still not connected? Raise error.
if ( 0 == $this->Link_ID ) {
$this->halt("Link-ID == false, pconnect failed");
}
// Select current database
if (!msql_select_db($this->Database, $this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
}
function query($Query_String) {
$this->connect();
# printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = msql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Error = msql_error();
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
$this->Record = msql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Error = msql_error();
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
msql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}
function seek($pos) {
$status = msql_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
return;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = @msql_list_fields($this->Database, $table);
if ($id < 0) {
$this->Error = msql_error();
$this->halt("Metadata query failed.");
}
$count = msql_num_fields($id);
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = msql_fieldtable ($id, $i);
$res[$i]["name"] = msql_fieldname ($id, $i);
$res[$i]["type"] = msql_fieldtype ($id, $i);
$res[$i]["len"] = msql_fieldlen ($id, $i);
$res[$i]["flags"] = msql_fieldflags ($id, $i);
$res["meta"][$res[$i]["name"]] = $i;
$res["num_fields"]= $count;
}
msql_free_result($id);
return $res;
}
function affected_rows() {
return msql_affected_rows($this->Query_ID);
}
function num_rows() {
return msql_num_rows($this->Query_ID);
}
function num_fields() {
return msql_num_fields($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name) {
return $this->Record[$Name];
}
function p($Name) {
print $this->Record[$Name];
}
function halt($msg) {
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>MSQL Error</b>: %s<br>\n", $this->Error);
die("Session halted.");
}
}
?>

View File

@ -1,146 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* (C) Copyright 1998 Cameron Taggart (cameront@wolfenet.com)
* Modified by Guarneri carmelo (carmelo@melting-soft.com)
* Modified by Cameron Just (C.Just@its.uq.edu.au)
*
* $Id$
*/
# echo "<BR>This is using the MSSQL class<BR>";
class db {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row = 0;
var $Errno = 0;
var $Error = "";
var $Auto_Free = 0; ## set this to 1 to automatically free results
function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mssql_pconnect($this->Host, $this->User, $this->Password);
if (!$this->Link_ID)
$this->halt("Link-ID == false, mssql_pconnect failed");
else
mssql_select_db($this->Database, $this->Link_ID);
}
}
function free_result(){
mssql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
function query($Query_String) {
if (!$this->Link_ID)
$this->connect();
# printf("<br>Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = mssql_query($Query_String, $this->Link_ID);
$this->Row = 0;
if (!$this->Query_ID) {
$this->Errno = 1;
$this->Error = "General Error (The MSSQL interface cannot return detailed error messages).";
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
if ($this->Record = mssql_fetch_row($this->Query_ID)) {
// add to Record[<key>]
$count = mssql_num_fields($this->Query_ID);
for ($i=0; $i<$count; $i++){
$fieldinfo = mssql_fetch_field($this->Query_ID,$i);
$this->Record[strtolower($fieldinfo->name)] = $this->Record[$i];
}
$this->Row += 1;
$stat = 1;
} else {
if ($this->Auto_Free) {
$this->free_result();
}
$stat = 0;
}
return $stat;
}
function seek($pos) {
mssql_data_seek($this->Query_ID,$pos);
$this->Row = $pos;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = mssql_query("select * from $table", $this->Link_ID);
if (!$id) {
$this->Errno = 1;
$this->Error = "General Error (The MSSQL interface cannot return detailed error messages).";
$this->halt("Metadata query failed.");
}
$count = mssql_num_fields($id);
for ($i=0; $i<$count; $i++) {
$info = mssql_fetch_field($id, $i);
$res[$i]["table"] = $table;
$res[$i]["name"] = $info["name"];
$res[$i]["len"] = $info["max_length"];
$res[$i]["flags"] = $info["numeric"];
}
$this->free_result();
return $res;
}
function affected_rows() {
return mssql_affected_rows($this->Query_ID);
}
function num_rows() {
return mssql_num_rows($this->Query_ID);
}
function num_fields() {
return mssql_num_fields($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Field_Name) {
return $this->Record[strtolower($Field_Name)];
}
function p($Field_Name) {
print $this->f($Field_Name);
}
function halt($msg) {
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>MSSQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
die("Session halted.");
}
}
?>

View File

@ -1,404 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998-2000 NetUSE AG
* Boris Erdmann, Kristian Koehntopp
*
* $Id$
*
*/
class db {
/* public: connection parameters */
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
/* public: configuration parameters */
var $auto_stripslashes = False;
var $Auto_Free = 0; ## Set to 1 for automatic mysql_free_result()
var $Debug = 0; ## Set to 1 for debugging messages.
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Seq_Table = "db_sequence";
/* public: result array and current row number */
var $Record = array();
var $Row;
/* public: current error number and error text */
var $Errno = 0;
var $Error = "";
/* public: this is an api revision, not a CVS revision. */
var $type = "mysql";
var $revision = "1.2";
/* private: link and query handles */
var $Link_ID = 0;
var $Query_ID = 0;
/* public: constructor */
function db($query = "") {
$this->query($query);
}
/* public: some trivial reporting */
function link_id() {
return $this->Link_ID;
}
function query_id() {
return $this->Query_ID;
}
/* public: connection management */
function connect($Database = "", $Host = "", $User = "", $Password = "") {
/* Handle defaults */
if ("" == $Database)
$Database = $this->Database;
if ("" == $Host)
$Host = $this->Host;
if ("" == $User)
$User = $this->User;
if ("" == $Password)
$Password = $this->Password;
/* establish connection, select database */
if ( 0 == $this->Link_ID ) {
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
if (!$this->Link_ID) {
$this->halt("pconnect($Host, $User, \$Password) failed.");
return 0;
}
if (!@mysql_select_db($Database,$this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
return 0;
}
}
return $this->Link_ID;
}
// This only affects systems not using persistant connections
function disconnect()
{
return mysql_close($this->Link_ID);
}
/* public: discard the query result */
function free() {
@mysql_free_result($this->Query_ID);
$this->Query_ID = 0;
}
/* public: perform a query */
// I added the line and file section so we can have better error reporting. (jengo)
function query($Query_String, $line = "", $file = "") {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new db_Subclass;'
*/
return 0;
if (!$this->connect()) {
return 0; /* we already complained in connect() about that. */
};
# New query, discard previous result.
if ($this->Query_ID) {
$this->free();
}
if ($this->Debug)
printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
$this->Row = 0;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
if (! $this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String, $line, $file);
}
# Will return nada if it fails. That's fine.
return $this->Query_ID;
}
/* public: walk result set */
function next_record() {
if (!$this->Query_ID) {
$this->halt("next_record called with no query pending.");
return 0;
}
$this->Record = @mysql_fetch_array($this->Query_ID);
$this->Row += 1;
$this->Errno = mysql_errno();
$this->Error = mysql_error();
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
$this->free();
}
return $stat;
}
/* public: position in result set */
function seek($pos = 0) {
$status = @mysql_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
else {
$this->halt("seek($pos) failed: result has ".$this->num_rows()." rows");
/* half assed attempt to save the day,
* but do not consider this documented or even
* desireable behaviour.
*/
@mysql_data_seek($this->Query_ID, $this->num_rows());
$this->Row = $this->num_rows;
return 0;
}
return 1;
}
/* public: table locking */
function lock($table, $mode="write") {
$this->connect();
$query="lock tables ";
if (is_array($table)) {
while (list($key,$value)=each($table)) {
if ($key=="read" && $key!=0) {
$query.="$value read, ";
} else {
$query.="$value $mode, ";
}
}
$query=substr($query,0,-2);
} else {
$query.="$table $mode";
}
$res = @mysql_query($query, $this->Link_ID);
if (!$res) {
$this->halt("lock($table, $mode) failed.");
return 0;
}
return $res;
}
function unlock() {
$this->connect();
$res = @mysql_query("unlock tables");
if (!$res) {
$this->halt("unlock() failed.");
return 0;
}
return $res;
}
/* public: evaluate the result (size, width) */
function affected_rows() {
return @mysql_affected_rows($this->Link_ID);
}
function num_rows() {
return @mysql_num_rows($this->Query_ID);
}
function num_fields() {
return @mysql_num_fields($this->Query_ID);
}
/* public: shorthand notation */
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name, $strip_slashes = "")
{
if ($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes)) {
return stripslashes($this->Record[$Name]);
} else {
return $this->Record[$Name];
}
}
function p($Name) {
print $this->Record[$Name];
}
/* public: sequence numbers */
function nextid($seq_name) {
$this->connect();
if ($this->lock($this->Seq_Table)) {
/* get sequence number (locked) and increment */
$q = sprintf("select nextid from %s where seq_name = '%s'",
$this->Seq_Table,
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
$res = @mysql_fetch_array($id);
/* No current value, make one */
if (!is_array($res)) {
$currentid = 0;
$q = sprintf("insert into %s values('%s', %s)",
$this->Seq_Table,
$seq_name,
$currentid);
$id = @mysql_query($q, $this->Link_ID);
} else {
$currentid = $res["nextid"];
}
$nextid = $currentid + 1;
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
$this->Seq_Table,
$nextid,
$seq_name);
$id = @mysql_query($q, $this->Link_ID);
$this->unlock();
} else {
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
return 0;
}
return $nextid;
}
/* public: return table metadata */
function metadata($table='',$full=false) {
$count = 0;
$id = 0;
$res = array();
/*
* Due to compatibility problems with Table we changed the behavior
* of metadata();
* depending on $full, metadata returns the following values:
*
* - full is false (default):
* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
*
* - full is true
* $result[]:
* ["num_fields"] number of metadata records
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags
* ["meta"][field name] index of field named "field name"
* The last one is used, if you have a field name, but no index.
* Test: if (isset($result['meta']['myfield'])) { ...
*/
// if no $table specified, assume that we are working with a query
// result
if ($table) {
$this->connect();
$id = @mysql_list_fields($this->Database, $table);
if (!$id)
$this->halt("Metadata query failed.");
} else {
$id = $this->Query_ID;
if (!$id)
$this->halt("No query specified.");
}
$count = @mysql_num_fields($id);
// made this IF due to performance (one if is faster than $count if's)
if (!$full) {
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = @mysql_field_table ($id, $i);
$res[$i]["name"] = @mysql_field_name ($id, $i);
$res[$i]["type"] = @mysql_field_type ($id, $i);
$res[$i]["len"] = @mysql_field_len ($id, $i);
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
}
} else { // full
$res["num_fields"]= $count;
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = @mysql_field_table ($id, $i);
$res[$i]["name"] = @mysql_field_name ($id, $i);
$res[$i]["type"] = @mysql_field_type ($id, $i);
$res[$i]["len"] = @mysql_field_len ($id, $i);
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
$res["meta"][$res[$i]["name"]] = $i;
}
}
// free the result only if we were called on a table
if ($table) @mysql_free_result($id);
return $res;
}
/* private: error handling */
function halt($msg, $line = "", $file = "")
{
global $phpgw;
$this->unlock(); // Just in case there is a table currently locked
$this->Error = @mysql_error($this->Link_ID);
$this->Errno = @mysql_errno($this->Link_ID);
if ($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
if ($file) {
printf("<br><b>File:</b> %s",$file);
}
if ($line) {
printf("<br><b>Line:</b> %s",$line);
}
if ($this->Halt_On_Error != "report") {
echo "<p><b>Session halted.</b>";
$phpgw->common->phpgw_exit(True);
}
}
function haltmsg($msg)
{
printf("<b>Database error:</b> %s<br>\n", $msg);
if ($this->Errno != "0" && $this->Error != "()") {
printf("<b>MySQL Error</b>: %s (%s)<br>\n",$this->Errno,$this->Error);
}
}
function table_names() {
$this->query("SHOW TABLES");
$i=0;
while ($info=mysql_fetch_row($this->Query_ID))
{
$return[$i]["table_name"]= $info[0];
$return[$i]["tablespace_name"]=$this->Database;
$return[$i]["database"]=$this->Database;
$i++;
}
return $return;
}
}

View File

@ -1,172 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998,1999 Cameron Taggart (cameront@wolfenet.com)
* Modified by Guarneri carmelo (carmelo@melting-soft.com)
*
* $Id$
*/
class db {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $UseODBCCursor = 0;
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row = 0;
var $Errno = 0;
var $Error = "";
var $Auto_Free = 0; ## set this to 1 to automatically free results
function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=odbc_pconnect($this->Database, $this->User, $this->Password, $this->UseODBCCursor);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, odbc_pconnect failed");
}
}
}
function query($Query_String) {
$this->connect();
# printf("<br>Debug: query = %s<br>\n", $Query_String);
# rei@netone.com.br suggested that we use this instead of the odbc_exec().
# He is on NT, connecting to a Unix MySQL server with ODBC. -- KK
# $this->Query_ID = odbc_prepare($this->Link_ID,$Query_String);
# $this->Query_Ok = odbc_execute($this->Query_ID);
$this->Query_ID = odbc_exec($this->Link_ID,$Query_String);
$this->Row = 0;
odbc_binmode($this->Query_ID, 1);
odbc_longreadlen($this->Query_ID, 4096);
if (!$this->Query_ID) {
$this->Errno = 1;
$this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
$this->Record = array();
$stat = odbc_fetch_into($this->Query_ID, ++$this->Row, &$this->Record);
if (!$stat) {
if ($this->Auto_Free) {
odbc_free_result($this->Query_ID);
$this->Query_ID = 0;
};
} else {
// add to Record[<key>]
$count = odbc_num_fields($this->Query_ID);
for ($i=1; $i<=$count; $i++)
$this->Record[strtolower(odbc_field_name ($this->Query_ID, $i)) ] = $this->Record[ $i - 1 ];
}
return $stat;
}
function seek($pos) {
$this->Row = $pos;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = odbc_exec($this->Link_ID, "select * from $table");
if (!$id) {
$this->Errno = 1;
$this->Error = "General Error (The ODBC interface cannot return detailed error messages).";
$this->halt("Metadata query failed.");
}
$count = odbc_num_fields($id);
for ($i=1; $i<=$count; $i++) {
$res[$i]["table"] = $table;
$name = odbc_field_name ($id, $i);
$res[$i]["name"] = $name;
$res[$i]["type"] = odbc_field_type ($id, $name);
$res[$i]["len"] = 0; // can we determine the width of this column?
$res[$i]["flags"] = ""; // any optional flags to report?
}
odbc_free_result($id);
return $res;
}
function affected_rows() {
return odbc_num_rows($this->Query_ID);
}
function num_rows() {
# Many ODBC drivers don't support odbc_num_rows() on SELECT statements.
$num_rows = odbc_num_rows($this->Query_ID);
//printf ($num_rows."<br>");
# This is a workaround. It is intended to be ugly.
if ($num_rows < 0) {
$i=10;
while (odbc_fetch_row($this->Query_ID, $i))
$i*=10;
$j=0;
while ($i!=$j) {
$k= $j+intval(($i-$j)/2);
if (odbc_fetch_row($this->Query_ID, $k))
$j=$k;
else
$i=$k;
if (($i-$j)==1) {
if (odbc_fetch_row($this->Query_ID, $i))
$j=$i;
else
$i=$j;
};
//printf("$i $j $k <br>");
};
$num_rows=$i;
}
return $num_rows;
}
function num_fields() {
return count($this->Record)/2;
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Field_Name) {
return $this->Record[strtolower($Field_Name)];
}
function p($Field_Name) {
print $this->f($Field_Name);
}
function halt($msg) {
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>ODBC Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
die("Session halted.");
}
}
?>

View File

@ -1,432 +0,0 @@
<?php
/*
* Oracle accessor based on Session Management for PHP3
*
* Copyright (c) 1998-2000 Luis Francisco Gonzalez Hernandez
*
* $Id$
*
*/
class db {
var $Debug = false;
var $Home = "/u01/app/oracle/product/8.0.4";
var $Remote = 1;
/* Due to a strange error with Oracle 8.0.5, Apache and PHP3.0.6
you don't need to set the ENV - on my system Apache
will change to a zombie, if I don't set this to FALSE!
If unsure try it out, if it works. */
var $OraPutEnv = true;
var $Database = "";
var $User = "";
var $Password = "";
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row;
var $Errno = 0;
var $Error = "";
var $ora_no_next_fetch=false;
/* copied from db_mysql for completeness */
/* public: identification constant. never change this. */
var $type = "oracle";
var $revision = "1.2";
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
/* public: constructor */
function db($query = "") {
$this->query($query);
}
/* public: some trivial reporting */
function link_id() {
return $this->Link_ID;
}
function query_id() {
return $this->Query_ID;
}
function connect() {
## see above why we do this
if ($this->OraPutEnv) {
PutEnv("ORACLE_SID=$this->Database");
PutEnv("ORACLE_HOME=$this->Home");
}
if ( 0 == $this->Link_ID ) {
if($this->Debug) {
printf("<br>Connect()ing to $this->Database...<br>\n");
}
if($this->Remote) {
if($this->Debug) {
printf("<br>connect() $this->User/******@$this->Database.world<br>\n");
}
$this->Link_ID=ora_plogon
("$this->User/$this->Password@$this->Database","");
/************** (comment by SSilk)
this dosn't work on my system:
$this->Link_ID=ora_plogon
("$this->User@$this->Database.world","$this->Password");
***************/
} else {
if($this->Debug) {
printf("<br>connect() $this->User, $this->Password <br>\n");
}
$this->Link_ID=ora_plogon("$this->User","$this->Password");
/* (comment by SSilk: don't know how this could work, but I leave this untouched!) */
}
if($this->Debug) {
printf("<br>connect() Link_ID: $this->Link_ID<br>\n");
}
if (!$this->Link_ID) {
$this->halt("connect() Link-ID == false " .
"($this->Link_ID), ora_plogon failed");
} else {
//echo "commit on<p>";
ora_commiton($this->Link_ID);
}
if($this->Debug) {
printf("<br>connect() Obtained the Link_ID: $this->Link_ID<br>\n");
}
}
}
## In order to increase the # of cursors per system/user go edit the
## init.ora file and increase the max_open_cursors parameter. Yours is on
## the default value, 100 per user.
## We tried to change the behaviour of query() in a way, that it tries
## to safe cursors, but on the other side be carefull with this, that you
## don't use an old result.
##
## You can also make extensive use of ->disconnect()!
## The unused QueryIDs will be recycled sometimes.
function query($Query_String) {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new DB_Sql_Subclass;'
*/
return 0;
$this->connect();
$this->lastQuery=$Query_String;
if (!$this->Query_ID) {
$this->Query_ID= ora_open($this->Link_ID);
}
if($this->Debug) {
printf("Debug: query = %s<br>\n", $Query_String);
printf("<br>Debug: Query_ID: %d<br>\n", $this->Query_ID);
}
if(!@ora_parse($this->Query_ID,$Query_String)) {
$this->Errno=ora_errorcode($this->Query_ID);
$this->Error=ora_error($this->Query_ID);
$this->halt("<BR>ora_parse() failed:<BR>$Query_String<BR><small>Snap & paste this to sqlplus!</SMALL>");
} elseif (!@ora_exec($this->Query_ID)) {
$this->Errno=ora_errorcode($this->Query_ID);
$this->Error=ora_error($this->Query_ID);
$this->halt("<BR>\n$Query_String\n<BR><small>Snap & paste this to sqlplus!</SMALL>");
}
$this->Row=0;
if(!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
if (!$this->no_next_fetch &&
0 == ora_fetch($this->Query_ID)) {
if ($this->Debug) {
printf("<br>next_record(): ID: %d,Rows: %d<br>\n",
$this->Query_ID,$this->num_rows());
}
$this->Row +=1;
$errno=ora_errorcode($this->Query_ID);
if(1403 == $errno) { # 1043 means no more records found
$this->Errno=0;
$this->Error="";
$this->disconnect();
$stat=0;
} else {
$this->Error=ora_error($this->Query_ID);
$this->Errno=$errno;
if($this->Debug) {
printf("<br>%d Error: %s",
$this->Errno,
$this->Error);
}
$stat=0;
}
} else {
$this->no_next_fetch=false;
for($ix=0;$ix<ora_numcols($this->Query_ID);$ix++) {
$col=strtolower(ora_columnname($this->Query_ID,$ix));
$value=ora_getcolumn($this->Query_ID,$ix);
$this->Record[ "$col" ] = $value;
# echo"<b>[$col]</b>: $value <br>\n";
}
$stat=1;
}
return $stat;
}
## seek() works only for $pos - 1 and $pos
## Perhaps I make a own implementation, but my
## opinion is, that this should be done by PHP3
function seek($pos) {
if ($this->Row - 1 == $pos) {
$this->no_next_fetch=true;
} elseif ($this->Row == $pos ) {
## do nothing
} else {
$this->halt("Invalid seek(): Position is cannot be handled by API.<BR>".
"Difference too big. Wanted: $pos Current pos: $this->Row");
}
if ($Debug) echo "<BR>Debug: seek = $pos<BR>";
$this->Row=$pos;
}
function lock($table, $mode = "write") {
if ($mode == "write") {
$result = ora_do($this->Link_ID, "lock table $table in row exclusive mode");
} else {
$result = 1;
}
return $result;
}
function unlock() {
return ora_do($this->Link_ID, "commit");
}
function metadata($table,$full=false) {
$count = 0;
$id = 0;
$res = array();
/*
* Due to compatibility problems with Table we changed the behavior
* of metadata();
* depending on $full, metadata returns the following values:
*
* - full is false (default):
* $result[]:
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags ("NOT NULL", "INDEX")
* [0]["format"] precision and scale of number (eg. "10,2") or empty
* [0]["index"] name of index (if has one)
* [0]["chars"] number of chars (if any char-type)
*
* - full is true
* $result[]:
* ["num_fields"] number of metadata records
* [0]["table"] table name
* [0]["name"] field name
* [0]["type"] field type
* [0]["len"] field length
* [0]["flags"] field flags ("NOT NULL", "INDEX")
* [0]["format"] precision and scale of number (eg. "10,2") or empty
* [0]["index"] name of index (if has one)
* [0]["chars"] number of chars (if any char-type)
* ["meta"][field name] index of field named "field name"
* The last one is used, if you have a field name, but no index.
* Test: if (isset($result['meta']['myfield'])) {} ...
*/
$this->connect();
## This is a RIGHT OUTER JOIN: "(+)", if you want to see, what
## this query results try the following:
## $table = new Table; $db = new my_DB_Sql; # you have to make
## # your own class
## $table->show_results($db->query(see query vvvvvv))
##
$this->query("SELECT T.table_name,T.column_name,T.data_type,".
"T.data_length,T.data_precision,T.data_scale,T.nullable,".
"T.char_col_decl_length,I.index_name".
" FROM ALL_TAB_COLUMNS T,ALL_IND_COLUMNS I".
" WHERE T.column_name=I.column_name (+)".
" AND T.table_name=I.table_name (+)".
" AND T.table_name=UPPER('$table') ORDER BY T.column_id");
$i=0;
while ($this->next_record()) {
$res[$i]["table"] = $this->Record[table_name];
$res[$i]["name"] = strtolower($this->Record[column_name]);
$res[$i]["type"] = $this->Record[data_type];
$res[$i]["len"] = $this->Record[data_length];
if ($this->Record[index_name]) $res[$i]["flags"] = "INDEX ";
$res[$i]["flags"] .= ( $this->Record[nullable] == 'N') ? '' : 'NOT NULL';
$res[$i]["format"]= (int)$this->Record[data_precision].",".
(int)$this->Record[data_scale];
if ("0,0"==$res[$i]["format"]) $res[$i]["format"]='';
$res[$i]["index"] = $this->Record[index_name];
$res[$i]["chars"] = $this->Record[char_col_decl_length];
if ($full) {
$j=$res[$i]["name"];
$res["meta"][$j] = $i;
$res["meta"][strtoupper($j)] = $i;
}
if ($full) $res["meta"][$res[$i]["name"]] = $i;
$i++;
}
if ($full) $res["num_fields"]=$i;
# $this->disconnect();
return $res;
}
## THIS FUNCTION IS UNSTESTED!
function affected_rows() {
if ($Debug) echo "<BR>Debug: affected_rows=". ora_numrows($this->Query_ID)."<BR>";
return ora_numrows($this->Query_ID);
}
## Known bugs: It will not work for SELECT DISTINCT and any
## other constructs which are depending on the resulting rows.
## So you *really need* to check every query you make, if it
## will work with it.
##
## Also, for a qualified replacement you need to parse the
## selection, cause this will fail: "SELECT id, from FROM ...").
## "FROM" is - as far as I know a keyword in Oracle, so it can
## only be used in this way. But you have been warned.
function num_rows() {
$curs=ora_open($this->Link_ID);
## this is the important part and it is also the HACK!
if (eregi("^[[:space:]]*SELECT[[:space:]]",$this->lastQuery) ) {
$from_pos = strpos(strtoupper($this->lastQuery),"FROM");
$q = "SELECT count(*) ". substr($this->lastQuery, $from_pos);
ORA_parse($curs,$q);
ORA_exec($curs);
ORA_fetch($curs);
if ($Debug) echo "<BR>Debug: num_rows=". ORA_getcolumn($curs,0)."<BR>";
return(ORA_getcolumn($curs,0));
} else {
$this->halt("Last Query was not a SELECT: $this->lastQuery");
}
}
function num_fields() {
if ($Debug) echo "<BR>Debug: num_fields=". ora_numcols($this->Query_ID) . "<BR>";
return ora_numcols($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name) {
return $this->Record[$Name];
}
function p($Name) {
print $this->Record[$Name];
}
/* public: sequence number */
function nextid($seq_name)
{
$this->connect();
/* Independent Query_ID */
$Query_ID = ora_open($this->Link_ID);
if(!@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL"))
{
// There is no such sequence yet, then create it
if(!@ora_parse($Query_ID,"CREATE SEQUENCE $seq_name")
||
!@ora_exec($Query_ID)
)
{
$this->halt("<BR> nextid() function - unable to create sequence");
return 0;
}
@ora_parse($Query_ID,"SELECT $seq_name.NEXTVAL FROM DUAL");
}
if (!@ora_exec($Query_ID)) {
$this->halt("<BR>ora_exec() failed:<BR>nextID function");
}
if (@ora_fetch($Query_ID) ) {
$next_id = ora_getcolumn($Query_ID, 0);
}
else {
$next_id = 0;
}
if ( Query_ID > 0 ) {
ora_close(Query_ID);
}
return $next_id;
}
function disconnect() {
if($this->Debug) {
echo "Debug: Disconnecting $this->Query_ID...<br>\n";
}
if ( $this->Query_ID < 1 ) {
echo "<B>Warning</B>: disconnect(): Cannot free ID $this->Query_ID\n";
# return();
}
ora_close($this->Query_ID);
$this->Query_ID=0;
}
/* private: error handling */
function halt($msg) {
if ($this->Halt_On_Error == "no")
return;
$this->haltmsg($msg);
if ($this->Halt_On_Error != "report")
die("Session halted.");
}
function haltmsg($msg) {
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>Oracle Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
}
function table_names() {
$this->connect();
$this->query("
SELECT table_name,tablespace_name
FROM user_tables");
$i=0;
while ($this->next_record())
{
$info[$i]["table_name"] =$this->Record["table_name"];
$info[$i]["tablespace_name"]=$this->Record["tablespace_name"];
$i++;
}
return $info;
}
}

View File

@ -1,271 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998-2000 NetUSE AG
* Boris Erdmann, Kristian Koehntopp
*
* $Id$
*
*/
class db {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $auto_stripslashes = False;
var $Halt_On_Error = "yes"; ## "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row = 0;
var $Seq_Table = "db_sequence";
var $Errno = 0;
var $Error = "";
var $Auto_Free = 0; # Set this to 1 for automatic pg_freeresult on
# last record.
function ifadd($add, $me) {
if("" != $add) return " ".$me.$add;
}
/* public: constructor */
function db($query = "") {
$this->query($query);
}
function connect() {
if ( 0 == $this->Link_ID ) {
$cstr = "dbname=".$this->Database.
$this->ifadd($this->Host, "host=").
$this->ifadd($this->Port, "port=").
$this->ifadd($this->User, "user=").
$this->ifadd($this->Password, "password=");
$this->Link_ID=pg_pconnect($cstr);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, pconnect failed");
}
}
}
// This only affects systems not using persistant connections
function disconnect()
{
return pg_close($this->Link_ID);
}
// I added the line and file section so we can have better error reporting. (jengo)
function query($Query_String, $line = "", $file = "") {
/* No empty queries, please, since PHP4 chokes on them. */
if ($Query_String == "")
/* The empty query string is passed on from the constructor,
* when calling the class without a query, e.g. in situations
* like these: '$db = new db_Subclass;'
*/
return 0;
$this->connect();
# printf("<br>Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = pg_Exec($this->Link_ID, $Query_String);
$this->Row = 0;
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == "")?0:1;
if (! $this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String, $line, $file);
}
return $this->Query_ID;
}
// public: discard the query result
function free() {
@pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
function next_record() {
$this->Record = @pg_fetch_array($this->Query_ID, $this->Row++);
$this->Error = pg_ErrorMessage($this->Link_ID);
$this->Errno = ($this->Error == "")?0:1;
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
pg_freeresult($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}
function seek($pos) {
$this->Row = $pos;
}
function lock($table, $mode = "write") {
$result = pg_Exec($this->Link_ID, "begin work");
if ($mode == "write") {
if (is_array($table)) {
while ($t = each($table)) {
$result = pg_Exec($this->Link_ID,"lock table $t[1] in share mode");
}
} else {
$result = pg_Exec($this->Link_ID, "lock table $table in share mode");
}
} else {
$result = 1;
}
return $result;
}
function unlock() {
return pg_Exec($this->Link_ID, "commit work");
}
/* public: sequence numbers */
function nextid($seq_name) {
$this->connect();
if ($this->lock($this->Seq_Table)) {
/* get sequence number (locked) and increment */
$q = sprintf("select nextid from %s where seq_name = '%s'",
$this->Seq_Table,
$seq_name);
$id = @pg_Exec($this->Link_ID, $q);
$res = @pg_Fetch_Array($id, 0);
/* No current value, make one */
if (!is_array($res)) {
$currentid = 0;
$q = sprintf("insert into %s values('%s', %s)",
$this->Seq_Table,
$seq_name,
$currentid);
$id = @pg_Exec($this->Link_ID, $q);
} else {
$currentid = $res["nextid"];
}
$nextid = $currentid + 1;
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
$this->Seq_Table,
$nextid,
$seq_name);
$id = @pg_Exec($this->Link_ID, $q);
$this->unlock();
} else {
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
return 0;
}
return $nextid;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$id = pg_exec($this->Link_ID, "select * from $table");
if ($id < 0) {
$this->Error = pg_ErrorMessage($id);
$this->Errno = 1;
$this->halt("Metadata query failed.");
}
$count = pg_NumFields($id);
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = $table;
$res[$i]["name"] = pg_FieldName ($id, $i);
$res[$i]["type"] = pg_FieldType ($id, $i);
$res[$i]["len"] = pg_FieldSize ($id, $i);
$res[$i]["flags"] = "";
}
pg_FreeResult($id);
return $res;
}
function affected_rows() {
return pg_cmdtuples($this->Query_ID);
}
function num_rows() {
return pg_numrows($this->Query_ID);
}
function num_fields() {
return pg_numfields($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name,$strip_slashes = "")
{
if ($strip_slashes || ($this->auto_stripslashes && ! $strip_slashes)) {
return stripslashes($this->Record[$Name]);
} else {
return $this->Record[$Name];
}
}
function p($Name) {
print $this->Record[$Name];
}
function halt($msg, $line = "", $file = "")
{
global $phpgw;
if($this->Halt_On_Error == "no") {
return;
}
$this->unlock(); // Just in case there is a table currently locked
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>PostgreSQL Error</b>: %s (%s)<br>\n",
$this->Errno,
$this->Error);
if ($file) {
printf("<br><b>File:</b> %s",$file);
}
if ($line) {
printf("<br><b>Line:</b> %s",$line);
}
if ($this->Halt_On_Error == "yes") {
echo "<p><b>Session halted.</b>";
$phpgw->common->phpgw_exit(True);
}
}
function table_names() {
$this->query("select relname from pg_class where relkind = 'r' and not relname like 'pg_%'");
$i=0;
while ($this->next_record())
{
$return[$i]["table_name"]= $this->f(0);
$return[$i]["tablespace_name"]=$this->Database;
$return[$i]["database"]=$this->Database;
$i++;
}
return $return;
}
}

View File

@ -1,133 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* Copyright (c) 1998,1999 SH Online Dienst GmbH
* Boris Erdmann, Kristian Koehntopp
*
* Adapted from db_mysql.inc by Sascha Schumann <sascha@schumann.cx>
*
* metadata() contributed by Adelino Monteiro <adelino@infologia.pt>
*
* $Id$
*
*/
class db {
var $Host = "";
var $Database = "";
var $User = "";
var $Password = "";
var $Link_ID = 0;
var $Query_ID = 0;
var $Record = array();
var $Row;
var $Auto_Free = 0; ## Set this to 1 for automatic sybase_free_result()
function connect() {
if ( 0 == $this->Link_ID ) {
$this->Link_ID=sybase_pconnect($this->Host,$this->User,$this->Password);
if (!$this->Link_ID) {
$this->halt("Link-ID == false, pconnect failed");
}
if(!sybase_select_db($this->Database, $this->Link_ID)) {
$this->halt("cannot use database ".$this->Database);
}
}
}
function query($Query_String) {
$this->connect();
# printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = sybase_query($Query_String,$this->Link_ID);
$this->Row = 0;
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}
return $this->Query_ID;
}
function next_record() {
$this->Record = sybase_fetch_array($this->Query_ID);
$this->Row += 1;
$stat = is_array($this->Record);
if (!$stat && $this->Auto_Free) {
sybase_free_result($this->Query_ID);
$this->Query_ID = 0;
}
return $stat;
}
function seek($pos) {
$status = sybase_data_seek($this->Query_ID, $pos);
if ($status)
$this->Row = $pos;
return;
}
function metadata($table) {
$count = 0;
$id = 0;
$res = array();
$this->connect();
$result = $this->query("exec sp_columns $table");
if ($result < 0) {
$this->Errno = 1;
$this->Error = "Metadata query failed";
$this->halt("Metadata query failed.");
}
$count = sybase_num_rows($result);
for ($i=0; $i<$count; $i++) {
$res[$i]["table"] = $table ;
$res[$i]["name"] = sybase_result ($result, $i, "COLUMN_NAME");
$res[$i]["type"] = sybase_result ($result, $i, "TYPE_NAME");
$res[$i]["len"] = sybase_result ($result, $i, "LENGTH");
$res[$i]["position"] = sybase_result ($result, $i, "ORDINAL_POSITION");
$res[$i]["flags"] = sybase_result ($result, $i, "REMARKS");
}
}
function affected_rows() {
return sybase_affected_rows($this->Query_ID);
}
function num_rows() {
return sybase_num_rows($this->Query_ID);
}
function num_fields() {
return sybase_num_fields($this->Query_ID);
}
function nf() {
return $this->num_rows();
}
function np() {
print $this->num_rows();
}
function f($Name) {
return $this->Record[$Name];
}
function p($Name) {
print $this->Record[$Name];
}
function halt($msg) {
printf("<b>Database error:</b> %s<br>\n", $msg);
printf("<b>Sybase Error</b><br>\n");
die("Session halted.");
}
}
?>

View File

@ -1,107 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* Written by Dan Kuykendall <seek3r@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$d1 = strtolower(substr($phpgw_info["server"]["api_inc"],0,3));
$d2 = strtolower(substr($phpgw_info["server"]["server_root"],0,3));
$d3 = strtolower(substr($phpgw_info["server"]["app_inc"],0,3));
if($d1 == "htt" || $d1 == "ftp" || $d2 == "htt" || $d2 == "ftp" || $d3 == "htt" || $d3 == "ftp") {
echo "Failed attempt to break in via an old Security Hole!<br>\n";
exit;
} unset($d1);unset($d2);unset($d3);
magic_quotes_runtime(false);
/* Make sure the developer is following the rules. */
if (!isset($phpgw_info["flags"]["currentapp"])) {
echo "!!! YOU DO NOT HAVE YOUR \$phpgw_info[\"flags\"][\"currentapp\"] SET !!!";
echo "!!! PLEASE CORRECT THIS SITUATION !!!";
}
if (!isset($phpgw_domain)) { // make them fix their header
echo "The administration is required to upgrade the header.inc.php file before you can continue.";
exit;
}
reset($phpgw_domain);
$default_domain = each($phpgw_domain);
$phpgw_info["server"]["default_domain"] = $default_domain[0];
unset ($default_domain); // we kill this for security reasons
// This code will handle virtdomains so that is a user logins with user@domain.com, it will switch into virtualization mode.
if (isset($domain)){
$phpgw_info["user"]["domain"] = $domain;
}elseif (isset($login) && isset($logindomain)){
if (!ereg ("\@", $login)){
$login = $login."@".$logindomain;
}
$phpgw_info["user"]["domain"] = $logindomain;
unset ($logindomain);
}elseif (isset($login) && !isset($logindomain)){
if (ereg ("\@", $login)){
$login_array = explode("@", $login);
$phpgw_info["user"]["domain"] = $login_array[1];
}else{
$phpgw_info["user"]["domain"] = $phpgw_info["server"]["default_domain"];
$login = $login."@".$phpgw_info["user"]["domain"];
}
}
if (isset($phpgw_domain[$phpgw_info["user"]["domain"]])){
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["user"]["domain"]]["db_type"];
}else{
$phpgw_info["server"]["db_host"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_host"];
$phpgw_info["server"]["db_name"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_name"];
$phpgw_info["server"]["db_user"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_user"];
$phpgw_info["server"]["db_pass"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_pass"];
$phpgw_info["server"]["db_type"] = $phpgw_domain[$phpgw_info["server"]["default_domain"]]["db_type"];
}
if ($phpgw_info["flags"]["currentapp"] != "login" && ! $phpgw_info["server"]["show_domain_selectbox"]) {
unset ($phpgw_domain); // we kill this for security reasons
}
unset ($domain); // we kill this to save memory
// some constants which can be used in setting user acl rights.
define("PHPGW_ACL_READ",1);
define("PHPGW_ACL_ADD",2);
define("PHPGW_ACL_EDIT",4);
define("PHPGW_ACL_DELETE",8);
// This function needs to be optimized, its reading duplicate information.
function phpgw_fillarray()
{
global $phpgw, $phpgw_info, $cd, $colspan;
$phpgw_info["server"]["template_dir"] = $phpgw->common->get_tpl_dir("phpgwapi");
$phpgw_info["server"]["images_dir"] = $phpgw->common->get_image_path("phpgwapi");
$phpgw_info["server"]["images_filedir"] = $phpgw->common->get_image_dir("phpgwapi");
$phpgw_info["server"]["app_root"] = $phpgw->common->get_app_dir();
$phpgw_info["server"]["app_inc"] = $phpgw->common->get_inc_dir();
$phpgw_info["server"]["app_tpl"] = $phpgw->common->get_tpl_dir();
$phpgw_info["server"]["app_images"] = $phpgw->common->get_image_path();
$phpgw_info["server"]["app_images_dir"] = $phpgw->common->get_image_dir();
/* ********This sets the user variables******** */
$phpgw_info["user"]["private_dir"] = $phpgw_info["server"]["files_dir"] . "/users/"
. $phpgw_info["user"]["userid"];
// This shouldn't happen, but if it does get ride of the warnings it will spit out
if (gettype($phpgw_info["user"]["preferences"]) != "array") {
$phpgw_info["user"]["preferences"] = array();
}
}
?>

View File

@ -1,77 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class translation
{
function translate($key, $vars=false )
{
if ( ! $vars ) $vars = array();
global $phpgw, $phpgw_info, $lang;
$ret = $key;
if (!isset($lang) || !$lang) {
if (isset($phpgw_info["user"]["preferences"]["common"]["lang"]) &&
$phpgw_info["user"]["preferences"]["common"]["lang"]) {
$userlang = $phpgw_info["user"]["preferences"]["common"]["lang"];
}else{
$userlang = "en";
}
$sql = "select message_id,content from lang where lang like '".$userlang."' ".
"and (app_name like '".$phpgw_info["flags"]["currentapp"]."' or app_name like 'common')";
if (strcasecmp ($phpgw_info["flags"]["currentapp"], "common")>0){
$sql .= " order by app_name asc";
}else{
$sql .= " order by app_name desc";
}
$phpgw->db->query($sql,__LINE__,__FILE__);
$phpgw->db->next_record();
$count = $phpgw->db->num_rows();
for ($idx = 0; $idx < $count; ++$idx) {
$lang[strtolower ($phpgw->db->f("message_id"))] = $phpgw->db->f("content");
$phpgw->db->next_record();
}
}
if (isset($lang[strtolower ($key)]) && $lang[strtolower ($key)]){
$ret = $lang[strtolower ($key)];
}else{
$ret = $key."*";
}
$ndx = 1;
while( list($key,$val) = each( $vars ) ) {
$ret = preg_replace( "/%$ndx/", $val, $ret );
++$ndx;
}
return $ret;
}
function add_app($app)
{
global $phpgw, $phpgw_info, $lang;
if ($phpgw_info["user"]["preferences"]["common"]["lang"]){
$userlang = $phpgw_info["user"]["preferences"]["common"]["lang"];
}else{
$userlang = "en";
}
$sql = "select message_id,content from lang where lang like '".$userlang."' and app_name like '".$app."'";
$phpgw->db->query($sql,__LINE__,__FILE__);
$phpgw->db->next_record();
$count = $phpgw->db->num_rows();
for ($idx = 0; $idx < $count; ++$idx) {
$lang[strtolower ($phpgw->db->f("message_id"))] = $phpgw->db->f("content");
$phpgw->db->next_record();
}
}
}

View File

@ -1,187 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare Library (Network) *
* http://www.phpgroupware.org *
* Written by Mark Peters <mpeters@satx.rr.com> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class network
{
var $socket;
var $addcrlf = TRUE;
var $error;
var $errorset = 0;
function network($addcrlf=true)
{
$this->errorset = 0;
$this->set_addcrlf($addcrlf);
}
function set_addcrlf($value)
{
$this->addcrlf = $value;
}
function set_error($code,$msg,$desc)
{
$this->error = array("code","msg","desc");
$this->error["code"] = $code;
$this->error["msg"] = $msg;
$this->error["desc"] = $desc;
// $this->close_port();
$this->errorset = 1;
return 0;
}
function open_port($server,$port,$timeout=15)
{
global $phpgw_info;
switch($port) {
case 80:
case 443:
if((isset($phpgw_info["server"]["httpproxy_server"]) && $phpgw_info["server"]["httpproxy_server"]) &&
(isset($phpgw_info["server"]["httpproxy_port"]) && $phpgw_info["server"]["httpproxy_port"])) {
$server = $phpgw_info["server"]["httpproxy_server"];
$port = (int)$phpgw_info["server"]["httpproxy_port"];
}
break;
}
if(floor(phpversion()) == 4)
$this->socket = fsockopen($server,$port,&$errcode,&$errmsg,$timeout);
else
$this->socket = fsockopen($server,$port,&$errcode,&$errmsg);
if (!$this->socket) {
return $this->set_error("Error","$errcode:$errmsg","Connection to $server:$port failed - could not open socket.");
} else {
return 1;
}
}
function close_port()
{
return fclose($this->socket);
}
function read_port()
{
return fgets($this->socket, 1024);
}
function bs_read_port($bytes)
{
return fread($this->socket, $bytes);
}
function write_port($str)
{
if (isset($this->addcrlf) && $this->addcrlf == True) $str .= "\r\n";
$ok = fputs($this->socket,$str);
if (!$ok)
{
return $this->set_error("Error","Connection Lost","lost connection to server");
} else {
return 1;
}
}
function bs_write_port($str,$bytes=0)
{
if (isset($this->addcrlf) && $this->addcrlf == True) $str .= "\r\n";
if ($bytes)
$ok = fwrite($this->socket,$str,$bytes);
else
$ok = fwrite($this->socket,$str);
if (!$ok)
{
return $this->set_error("Error","Connection Lost","lost connection to server");
} else {
return 1;
}
}
function msg2socket($str,$expected_response,$response)
{
if(!$this->socket && substr($expected_response,1,1) == "+") {
return $this->set_error("521",
"socket does not exist",
"The required socket does not exist. The settings for your mail server may be wrong.");
}
if (!$this->write_port($str)) {
if(substr($expected_response,1,1) == "+") {
return $this->set_error("420",
"lost connection",
"Lost connection to pop server.");
} else {
return 0;
}
}
$response = $this->read_port();
if (!ereg(strtoupper($expected_response),strtoupper($response))) {
if(substr($expected_response,1,1) == "+") {
return $this->set_error("550",
"",
"");
}
$pos = strpos(" ",$response);
return $this->set_error(substr($response,0,$pos),
"invalid response($expected_response)",
substr($response,($pos + 1),(strlen($response)-$pos)));
} else {
return 1;
}
}
// return contents of a web url as an array or false if timeout
function gethttpsocketfile($file)
{
global $phpgw_info;
$server = str_replace("http://","",$file);
$file = strstr($server,"/");
$server = str_replace("$file","",$server);
if ($phpgw_info["server"]["httpproxy_server"]) {
if ($this->open_port($server,80, 15)) {
if (! $this->write_port("GET http://" . $server . $file . " HTTP/1.0\n\n")) {
return False;
}
$i = 0;
while ($line = $this->read_port()) {
if (feof($this->socket)) {
break;
}
$lines[] = $line;
$i++;
}
$this->close_port();
return $lines;
} else {
return False;
}
} else {
if ($this->open_port($server, 80, 15)) {
if (!$this->write_port("GET $file HTTP/1.0\nHost: $server\n\n")) {
return 0;
}
while ($line = $this->read_port()) {
$lines[] = $line;
}
$this->close_port();
return $lines;
} else {
return 0;
}
}
}
}

View File

@ -1,341 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file written by Joseph Engo <jengo@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class nextmatchs
{
// I split this up so it can be used in differant layouts.
function show($sn,$start,$total,$extra, $twidth, $bgtheme,
$search_obj=0,$filter_obj=1,$showsearch=1)
{
echo $this->tablestart($sn,$twidth, $bgtheme);
echo $this->left($sn,$start,$total,$extra);
if ($showsearch == 1)
{
echo $this->search($search_obj);
}
echo $this->filter($filter_obj);
echo $this->right($sn,$start,$total,$extra);
echo $this->tableend();
}
// --------------------------------------------------------------------
// same as show, only without direct output for use within templates
// *** the show function can be removed as soon as every program using
// nextmatch is converted to use template and show_tpl (loge)
// --------------------------------------------------------------------
function show_tpl($sn,$start,$total,$extra, $twidth, $bgtheme,
$search_obj=0,$filter_obj=1,$showsearch=1)
{
$var = $this->tablestart($sn,$twidth, $bgtheme);
$var .= $this->left($sn,$start,$total,$extra);
if ($showsearch == 1)
{
$var .= $this->search($search_obj);
}
$var .= $this->filter($filter_obj);
$var .= $this->right($sn,$start,$total,$extra);
$var .= $this->tableend();
return $var;
}
function tablestart($scriptname, $twidth="75%", $bgtheme="D3DCE3")
{
global $filter, $qfield, $start, $order, $sort, $query, $phpgw;
$str = "<form method=\"POST\" action=\"" . $phpgw->link($scriptname) . "\">
<input type=\"hidden\" name=\"filter\" value=\"$filter\">
<input type=\"hidden\" name=\"qfield\" value=\"$qfield\">
<input type=\"hidden\" name=\"start\" value=\"$start\">
<input type=\"hidden\" name=\"order\" value=\"$order\">
<input type=\"hidden\" name=\"sort\" value=\"$sort\">
<input type=\"hidden\" name=\"query\" value=\"$query\">";
$str .= "<table width=\"$twidth\" height=\"50\" border=\"0\" bgcolor=\"$bgtheme\" cellspacing=\"0\" cellpadding=\"0\">\n<tr>\n";
return $str;
}
function tableend()
{
$str = "</tr>\n</table>\n<br>";
$str .= "</form>";
return $str;
}
function left($scriptname,$start,$total,$extradata = "")
{
global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
$str = "";
$maxmatchs = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
if (( $start != 0 ) && ( $start > $maxmatchs ))
$str .= "<td width=\"2%\" align=\"left\">&nbsp;<a href=\""
. $phpgw->link($scriptname,"start=0"
. "&order=$order&filter=$filter&qfield=$qfield"
. "&sort=$sort&query=$query".$extradata)
. "\"><img src=\"".$phpgw_info["server"]["images_dir"]
. "/first.gif\" border=0 width=\"12\" height=\"12\" alt=\""
. lang("First Page") . "\"></a></td>\n";
else
$str .= "<td width=\"2%\" align=\"left\">"
. "&nbsp;<img src=\"".$phpgw_info["server"]["images_dir"]
. "/first-grey.gif\" "."width=\"12\" height=\"12\" alt=\""
. lang("First Page")."\"></td>\n";
if ($start != 0) {
// Changing the sorting order screaws up the starting number
if ( ($start - $maxmatchs) < 0)
$t_start = 0;
else
$t_start = ($start - $maxmatchs);
$str .= "<td width=\"2%\" align=\"left\"><a href=\""
. $phpgw->link($scriptname,"start=$t_start"
. "&order=$order&filter=$filter&qfield=$qfield"
. "&sort=$sort&query=$query".$extradata)
. "\"><img src=\"".$phpgw_info["server"]["images_dir"]
. "/left.gif\" border=0 width=\"12\" height=\"12\" alt=\""
. lang("Previous Page") . "\"></a></td>\n";
} else
$str .= "<td width=\"2%\" align=\"left\">"
. "<img src=\"" . $phpgw_info["server"]["images_dir"]
. "/left-grey.gif\" width=\"12\" height=\"12\" alt=\""
. lang("Previous Page") . "\"></td>\n";
return $str;
} /* left() */
function search($search_obj=0)
{
global $query;
$str = "<td width=\"40%\">"
. "<div align=\"center\">"
. "<input type=\"text\" name=\"query\" value=\"".urldecode($query)."\">&nbsp;"
. $this->searchby($search_obj)
. "<input type=\"submit\" name=\"Search\" value=\"" . lang("Search") ."\">"
. "</div>"
. "</td>";
return $str;
} /* search() */
function filterobj($filtertable, $idxfieldname, $strfieldname)
{
global $phpgw;
$filter_obj = array(array("none","show all"));
$index = 0;
$phpgw->db->query("SELECT $idxfieldname, $strfieldname from $filtertable",__LINE__,__FILE__);
while($phpgw->db->next_record())
{
$index++;
$filter_obj[$index][0] = $phpgw->db->f("$idxfieldname");
$filter_obj[$index][1] = $phpgw->db->f("$strfieldname");
}
return $filter_obj;
} /* filterobj() */
function searchby($search_obj)
{
global $qfield, $phpgw, $phpgw_info;
$str = "";
if (is_array($search_obj))
{
$str .= "<select name=\"qfield\">";
$indexlimit = count($search_obj);
for ($index=0; $index<$indexlimit; $index++)
{
if ($qfield == "")
{
$qfield = $search_obj[$index][0];
}
$str .= "<option value=\"".$search_obj[$index][0]."\"";
if ($qfield == $search_obj[$index][0])
{
$str .= " selected";
}
$str .= ">" . lang($search_obj[$index][1]) . "</option>";
}
$str .= "</select>\n";
}
return $str;
} /* searchby() */
function filter($filter_obj)
{
global $filter, $phpgw, $phpgw_info;
$str = "";
if (is_long($filter_obj))
{
if ($filter_obj == 1)
{
$user_groups =
$phpgw->accounts->read_group_names($phpgw_info["user"]["userid"]);
$indexlimit = count($user_groups);
$filter_obj = array(array("none",lang("show all")),
array("private",lang("only yours")));
for ($index=0; $index<$indexlimit; $index++)
{
$filter_obj[2+$index][0] = $user_groups[$index][0];
$filter_obj[2+$index][1] = "Group - " . $user_groups[$index][1];
}
}
}
if (is_array($filter_obj))
{
$str .= "<td width=\"14%\">"
. "<select name=\"filter\">";
$indexlimit = count($filter_obj);
for ($index=0; $index<$indexlimit; $index++)
{
if ($filter == "")
{
$filter = $filter_obj[$index][0];
}
$str .= "<option value=\"".$filter_obj[$index][0]."\"";
if ($filter == $filter_obj[$index][0])
{
$str .= " selected";
}
$str .= ">" . $filter_obj[$index][1] . "</option>";
}
$str .= "</select>\n";
$str .= "<input type=\"submit\" value=\"" . lang("filter") . "\">\n";
$str .= "</td>\n";
}
return $str;
} /* filter() */
function right($scriptname,$start,$total,$extradata = "")
{
global $filter, $qfield, $order, $sort, $query, $phpgw_info, $phpgw;
$maxmatchs = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
$str = "";
if (($total > $maxmatchs) && ($total > $start + $maxmatchs))
$str .= "<td width=\"2%\" align=\"right\"><a href=\""
. $phpgw->link($scriptname,"start=".($start+$maxmatchs)
. "&order=$order&filter=$filter&qfield=$qfield"
. "&sort=$sort&query=$query".$extradata)
. "\"><img src=\"".$phpgw_info["server"]["images_dir"]
. "/right.gif\" width=\"12\" height=\"12\" border=\"0\" alt=\""
. lang("Next Page")."\"></a></td>\n";
else
$str .= "<td width=\"2%\" align=\"right\"><img src=\""
. $phpgw_info["server"]["images_dir"]."/right-grey.gif\" "
. "width=\"12\" height=\"12\" alt=\"".lang("Next Page")
. "\"></td>\n";
if (($start != $total - $maxmatchs)
&& ( ($total - $maxmatchs) > ($start + $maxmatchs) ))
$str .= "<td width=\"2%\" align=\"right\"><a href=\""
. $phpgw->link($scriptname,"start=".($total-$maxmatchs)
. "&order=$order&filter=$filter&qfield=$qfield"
. "&sort=$sort&query=$query".$extradata)
. "\"><img src=\"".$phpgw_info["server"]["images_dir"]
. "/last.gif\" border=\"0\" width=\"12\" height=\"12\" alt=\""
. lang("Last Page")."\"></a>&nbsp;</td>\n";
else
$str .= "<td width=\"2%\" align=\"right\"><img src=\""
. $phpgw_info["server"]["images_dir"]."/last-grey.gif\" "
. "width=\"12\" height=\"12\" alt=\"".lang("Last Page")
. "\">&nbsp;</td>";
return $str;
} /* right() */
function alternate_row_color($currentcolor = "")
{
global $phpgw_info;
if (! $currentcolor) {
global $tr_color;
$currentcolor = $tr_color;
}
if ($currentcolor == $phpgw_info["theme"]["row_on"]) {
$tr_color = $phpgw_info["theme"]["row_off"];
} else {
$tr_color = $phpgw_info["theme"]["row_on"];
}
return $tr_color;
}
function show_sort_order($sort,$var,$order,$program,$text,$extra="")
{
global $phpgw, $filter, $qfield, $start, $query;
if (($order == $var) && ($sort == "ASC"))
$sort = "DESC";
else if (($order == $var) && ($sort == "DESC"))
$sort = "ASC";
else
$sort = "ASC";
return "<a href=\"".$phpgw->link($program,"order=$var&sort=$sort"
. "&filter=$filter&qfield=$qfield"
. "&start=$start&query=$query".$extra)."\">$text</a>";
}
// Postgre and MySQL switch the vars in limit. This will make it easier
// if there are any other databases that pull this.
function sql_limit($start)
{
global $phpgw_info;
$max = $phpgw_info["user"]["preferences"]["common"]["maxmatchs"];
switch ($phpgw_info["server"]["db_type"]) {
case "pgsql":
if ($start == 0)
$l = $max;
else
$l = "$max,$start";
return $l;
break;
case "mysql":
if ($start == 0)
$l = $max;
else
$l = "$start,$max";
return $l;
break;
case "oracle":
if ($start == 0)
$l = "rownum < $max";
else
$l = "rownum >= $start AND rownum <= $max";
// if ($new_where)
// return "WHERE $l";
// else
// return "AND $l";
break;
}
}
}

View File

@ -1,248 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - smtp mailer *
* http://www.phpgroupware.org *
* Written by Itzchak Rehberg <izzysoft@qumran.org> *
* ------------------------------------------------ *
* This module should replace php's mail() function. It is fully syntax *
* compatible. In addition, when an error occures, a detailed error info *
* is stored in the array $send->err (see ../inc/email/global.inc.php for *
* details on this variable). *
\**************************************************************************/
/* $Id$ */
class send {
var $err = array("code","msg","desc");
var $to_res = array();
function send() {
$this->err["code"] = " ";
$this->err["msg"] = " ";
$this->err["desc"] = " ";
}
function msg($service, $to, $subject, $body, $msgtype="", $cc="", $bcc="") {
global $phpgw_info, $phpgw, $attach_sig;
if ($service == "email") {
$now = getdate();
$header = "Date: " . gmdate("D, d M Y H:i:s") . " +0000\n";
$header .= "From: ".$phpgw_info["user"]["fullname"]." <".$phpgw_info["user"]["preferences"]["email"]["address"].">\n";
$header .= "Reply-To: ".$phpgw_info["user"]["preferences"]["email"]["address"]."\n";
$header .= "To: $to\n";
if (!empty($cc)) {
$header .= "Cc: $cc\n";
}
if (!empty($bcc)) {
$header .= "Bcc: $bcc\n";
}
if (!empty($msgtype)) {
$header .= "X-phpGW-Type: $msgtype\n";
}
$header .= "X-Mailer: phpGroupWare (http://www.phpgroupware.org)\n";
if ($phpgw_info["user"]["preferences"]["email"]["email_sig"] && $attach_sig) {
$body .= "\n-----\n" . $phpgw_info["user"]["preferences"]["email"]["email_sig"];
}
if (ereg("Message-Boundary", $body))
{
$header .= "Subject: " . stripslashes($subject) . "\n"
. "MIME-Version: 1.0\n"
. "Content-Type: multipart/mixed;\n"
. " boundary=\"Message-Boundary\"\n\n"
. "--Message-Boundary\n"
. "Content-type: text/plain; charset=US-ASCII\n";
// if (!empty($msgtype)) {
// $header .= "Content-type: text/plain; phpgw-type=".$msgtype."\n";
// }
$header .= "Content-Disposition: inline\n"
. "Content-transfer-encoding: 7BIT\n\n"
. $body;
$body = "";
} else {
$header .= "Subject: " . stripslashes($subject) . "\n"
. "MIME-version: 1.0\n"
. "Content-type: text/plain; charset=\"".lang("charset")."\"\n";
if (!empty($msgtype)) {
$header .= "Content-type: text/plain; phpgw-type=".$msgtype."\n";
}
$header .= "Content-Disposition: inline\n"
. "Content-description: Mail message body\n";
}
if ($phpgw_info["user"]["preferences"]["email"]["mail_server_type"] == "imap" && $phpgw_info["user"]["apps"]["email"]){
$stream = $phpgw->msg->login("Sent");
$phpgw->msg->append($stream, "Sent", $header, $body);
$phpgw->msg->close($stream);
}
if (strlen($cc)>1) $to .= ",".$cc;
if (strlen($bcc)>1) $to .= ",".$bcc;
$returnccode = $this->smail($to, "", $body, $header);
return $returnccode;
} elseif ($type == "nntp") {
}
}
// ==================================================[ some sub-functions ]===
function socket2msg($socket) {
$followme = "-"; $this->err["msg"] = "";
do {
$rmsg = fgets($socket,255);
// echo "< $rmsg<BR>\n";
$this->err["code"] = substr($rmsg,0,3);
$followme = substr($rmsg,3,1);
$this->err["msg"] = substr($rmsg,4);
if (substr($this->err["code"],0,1) != 2 && substr($this->err["code"],0,1) != 3) {
$rc = fclose($socket);
return false;
}
if ($followme = " ") { break; }
} while ($followme = "-");
return true;
}
function msg2socket($socket,$message) { // send single line\n
// echo "raw> $message<BR>\n";
// echo "hex> ".bin2hex($message)."<BR>\n";
$rc = fputs($socket,"$message");
if (!$rc) {
$this->err["code"] = "420";
$this->err["msg"] = "lost connection";
$this->err["desc"] = "Lost connection to smtp server.";
$rc = fclose($socket);
return false;
}
return true;
}
function put2socket($socket,$message) { // check for multiple lines 1st
$pos = strpos($message,"\n");
if (!is_int($pos)) { // no new line found
$message .= "\r\n";
$this->msg2socket($socket,$message);
} else { // multiple lines, we have to split it
do {
$msglen = $pos + 1;
$msg = substr($message,0,$msglen);
$message = substr($message,$msglen);
$pos = strpos($msg,"\r\n");
if (!is_int($pos)) { // line not terminated
$msg = chop($msg)."\r\n";
}
$pos = strpos($msg,"."); // escape leading periods
if (is_int($pos) && !$pos) {
$msg = "." . $msg;
}
if (!$this->msg2socket($socket,$msg)) { return false; }
$pos = strpos($message,"\n");
} while (strlen($message)>0);
}
return true;
}
function check_header($subject,$header) { // check if header contains subject
// and is correctly terminated
$header = chop($header);
$header .= "\n";
if (is_string($subject) && !$subject) { // no subject specified
return $header;
}
$theader = strtolower($header);
$pos = strpos($theader,"\nsubject:");
if (is_int($pos)) { // found after a new line
return $header;
}
$pos = strpos($theader,"subject:");
if (is_int($pos) && !$pos) { // found at start
return $header;
}
$pos = substr($subject,"\n");
if (!is_int($pos)) $subject .= "\n";
$subject = "Subject: " .$subject;
$header .= $subject;
return $header;
}
// ==============================================[ main function: smail() ]===
function smail($to,$subject,$message,$header) {
global $phpgw_info;
$fromuser = $phpgw_info["user"]["preferences"]["email"]["address"];
$mymachine = $phpgw_info["server"]["hostname"];
$errcode = ""; $errmsg = ""; // error code and message of failed connection
$timeout = 5; // timeout in secs
// now we try to open the socket and check, if any smtp server responds
$socket = fsockopen($phpgw_info["server"]["smtp_server"],$phpgw_info["server"]["smtp_port"],$errcode,$errmsg,$timeout);
if (!$socket) {
$this->err["code"] = "420";
$this->err["msg"] = "$errcode:$errmsg";
$this->err["desc"] = "Connection to ".$phpgw_info["server"]["smtp_server"].":".$phpgw_info["server"]["smtp_port"]." failed - could not open socket.";
return false;
} else {
$rrc = $this->socket2msg($socket);
}
// now we can send our message. 1st we identify ourselves and the sender
$cmds = array (
"\$src = \$this->msg2socket(\$socket,\"HELO \$mymachine\r\n\");",
"\$rrc = \$this->socket2msg(\$socket);",
"\$src = \$this->msg2socket(\$socket,\"MAIL FROM:<\$fromuser>\r\n\");",
"\$rrc = \$this->socket2msg(\$socket);"
);
for ($src=true,$rrc=true,$i=0; $i<count($cmds);$i++) {
eval ($cmds[$i]);
if (!$src || !$rrc) return false;
}
// now we've got to evaluate the $to's
$toaddr = explode(",",$to);
$numaddr = count($toaddr);
for ($i=0; $i<$numaddr; $i++) {
$src = $this->msg2socket($socket,"RCPT TO:<$toaddr[$i]>\r\n");
$rrc = $this->socket2msg($socket);
$this->to_res[$i][addr] = $toaddr[$i]; // for lateron validation
$this->to_res[$i][code] = $this->err["code"];
$this->to_res[$i][msg] = $this->err["msg"];
$this->to_res[$i][desc] = $this->err["desc"];
}
//now we have to make sure that at least one $to-address was accepted
$stop = 1;
for ($i=0;$i<count($this->to_res);$i++) {
$rc = substr($this->to_res[$i][code],0,1);
if ($rc == 2) { // at least to this address we can deliver
$stop = 0;
}
}
if ($stop) return false; // no address found we can deliver to
// now we can go to deliver the message!
if (!$this->msg2socket($socket,"DATA\r\n")) return false;
if (!$this->socket2msg($socket)) return false;
if ($header != "") {
$header = $this->check_header($subject,$header);
if (!$this->put2socket($socket,$header)) return false;
if (!$this->put2socket($socket,"\r\n")) return false;
}
$message = chop($message);
$message .= "\n";
if (!$this->put2socket($socket,$message)) return false;
if (!$this->msg2socket($socket,".\r\n")) return false;
if (!$this->socket2msg($socket)) return false;
if (!$this->msg2socket($socket,"QUIT\r\n")) return false;
Do {
$closing = $this->socket2msg($socket);
} while ($closing);
return true;
}
// end of class
}

View File

@ -1,196 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file written by Joseph Engo <jengo@phpgroupware.org> *
* and Dan Kuykendall <dan@kuykendall.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class sessions
{
function getuser_ip()
{
global $REMOTE_ADDR, $HTTP_X_FORWARDED_FOR;
if ($HTTP_X_FORWARDED_FOR) {
return $HTTP_X_FORWARDED_FOR;
} else {
return $REMOTE_ADDR;
}
}
function verify()
{
global $phpgw, $phpgw_info, $sessionid, $kp3;
$db = $phpgw->db;
$db2 = $phpgw->db;
// PHP 3 complains that these are not defined when the already are defined.
$phpgw->common->key = $phpgw_info["server"]["encryptkey"];
$phpgw->common->key .= $sessionid;
$phpgw->common->key .= $kp3;
$phpgw->common->iv = $phpgw_info["server"]["mcrypt_iv"];
$phpgw->crypto = new crypto($phpgw->common->key,$phpgw->common->iv);
$db->query("select * from phpgw_sessions where session_id='$sessionid'",__LINE__,__FILE__);
$db->next_record();
if ($db->f("session_info") == "" || $db->f("session_info") == "NULL") {
$phpgw_info["user"]["account_lid"] = $db->f("session_lid");
$phpgw_info["user"]["sessionid"] = $sessionid;
$phpgw_info["user"]["session_ip"] = $db->f("session_ip");
$t = explode("@",$db->f("session_lid"));
$phpgw_info["user"]["userid"] = $t[0];
$phpgw->accounts->sync(__LINE__,__FILE__);
// Now we need to re-read eveything
$db->query("select * from phpgw_sessions where session_id='$sessionid'",__LINE__,__FILE__);
$db->next_record();
}
$phpgw_info["user"]["kp3"] = $kp3;
$phpgw_info_flags = $phpgw_info["flags"];
$phpgw_info = $phpgw->crypto->decrypt($db->f("session_info"));
$phpgw_info["flags"] = $phpgw_info_flags;
$userid_array = explode("@",$db->f("session_lid"));
$phpgw_info["user"]["userid"] = $userid_array[0];
if ($userid_array[1] != $phpgw_info["user"]["domain"]) {
return False;
}
if (PHP_OS != "Windows" && (! $phpgw_info["user"]["session_ip"] || $phpgw_info["user"]["session_ip"] != $this->getuser_ip())){
return False;
}
$this->update_dla();
if (! $phpgw_info["user"]["userid"] ) {
return False;
} else {
// PHP 3 complains that these are not defined when the already are defined.
return True;
}
}
// This will remove stale sessions out of the database
function clean_sessions()
{
global $phpgw_info, $phpgw;
// Note: I need to add a db->lock() in here
if (!isset($phpgw_info["server"]["cron_apps"]) || ! $phpgw_info["server"]["cron_apps"]) {
$phpgw->db->query("delete from phpgw_sessions where session_dla <= '" . (time() - 7200)
. "'",__LINE__,__FILE__);
}
}
function create($login,$passwd)
{
global $phpgw_info, $phpgw;
$this->clean_sessions();
$login_array = explode("@", $login);
$phpgw_info["user"]["userid"] = $login_array[0];
if ($phpgw_info["server"]["global_denied_users"][$phpgw_info["user"]["userid"]]) {
return False;
}
if (!$phpgw->auth->authenticate($phpgw_info["user"]["userid"], $passwd)) {
return False;
exit;
}
$phpgw_info["user"]["sessionid"] = md5($phpgw->common->randomstring(10));
$phpgw_info["user"]["kp3"] = md5($phpgw->common->randomstring(15));
$phpgw->common->key = $phpgw_info["server"]["encryptkey"];
$phpgw->common->key .= $phpgw_info["user"]["sessionid"];
$phpgw->common->key .= $phpgw_info["user"]["kp3"];
$phpgw->common->iv = $phpgw_info["server"]["mcrypt_iv"];
$phpgw->crypto = new crypto($phpgw->common->key,$phpgw->common->iv);
$phpgw_info["user"]["passwd"] = $phpgw->common->encrypt($passwd);
if ($phpgw_info["server"]["usecookies"]) {
Setcookie("sessionid",$phpgw_info["user"]["sessionid"]);
Setcookie("kp3",$phpgw_info["user"]["kp3"]);
Setcookie("domain",$phpgw_info["user"]["domain"]);
Setcookie("last_domain",$phpgw_info["user"]["domain"],time()+1209600);
if ($phpgw_info["user"]["domain"] ==$phpgw_info["server"]["default_domain"]) {
Setcookie("last_loginid",$phpgw_info["user"]["userid"],time()+1209600); // For 2 weeks
} else {
Setcookie("last_loginid",$loginid,time()+1209600); // For 2 weeks
}
unset ($phpgw_info["server"]["default_domain"]); // we kill this for security reasons
}
//$phpgw->accounts->accounts_const();
$phpgw_info["user"]["session_ip"] = $this->getuser_ip();
$phpgw->db->query("insert into phpgw_sessions values ('" . $phpgw_info["user"]["sessionid"]
. "','".$login."','" . $this->getuser_ip() . "','"
. time() . "','" . time() . "','')",__LINE__,__FILE__);
$phpgw->accounts->sync(__LINE__,__FILE__);
$phpgw->db->query("insert into phpgw_access_log values ('" . $phpgw_info["user"]["sessionid"] . "','"
. "$login','" . $this->getuser_ip() . "','" . time()
. "','') ",__LINE__,__FILE__);
$phpgw->db->query("update accounts set account_lastloginfrom='"
. $this->getuser_ip() . "', account_lastlogin='" . time()
. "' where account_lid='".$login."'",__LINE__,__FILE__);
return $phpgw_info["user"]["sessionid"];
}
// This will update the DateLastActive column, so the login does not expire
function update_dla()
{
global $phpgw_info, $phpgw;
$phpgw->db->query("update phpgw_sessions set session_dla='" . time() . "' where session_id='"
. $phpgw_info["user"]["sessionid"]."'",__LINE__,__FILE__);
}
function destroy()
{
global $phpgw, $phpgw_info, $sessionid, $kp3;
$phpgw_info["user"]["sessionid"] = $sessionid;
$phpgw_info["user"]["kp3"] = $kp3;
$phpgw->db->query("delete from phpgw_sessions where session_id='"
. $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__);
$phpgw->db->query("delete from phpgw_app_sessions where sessionid='"
. $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__);
$phpgw->db->query("update phpgw_access_log set lo='" . time() . "' where sessionid='"
. $phpgw_info["user"]["sessionid"] . "'",__LINE__,__FILE__);
if ($phpgw_info["server"]["usecookies"]) {
Setcookie("sessionid");
Setcookie("kp3");
if ($phpgw_info["multiable_domains"]) {
Setcookie("domain");
}
}
$this->clean_sessions();
return True;
}
}
?>

View File

@ -1,346 +0,0 @@
<?php
/*
* Session Management for PHP3
*
* (C) Copyright 1999-2000 NetUSE GmbH
* Kristian Koehntopp
*
* $Id$
*
*/
class Template {
var $classname = "Template";
/* if set, echo assignments */
var $debug = false;
/* $file[handle] = "filename"; */
var $file = array();
/* relative filenames are relative to this pathname */
var $root = "";
/* $varkeys[key] = "key"; $varvals[key] = "value"; */
var $varkeys = array();
var $varvals = array();
/* "remove" => remove undefined variables
* "comment" => replace undefined variables with comments
* "keep" => keep undefined variables
*/
var $unknowns = "remove";
/* "yes" => halt, "report" => report error, continue, "no" => ignore error quietly */
var $halt_on_error = "yes";
/* last error message is retained here */
var $last_error = "";
/***************************************************************************/
/* public: Constructor.
* root: template directory.
* unknowns: how to handle unknown variables.
*/
function Template($root = ".", $unknowns = "remove") {
$this->set_root($root);
$this->set_unknowns($unknowns);
}
/* public: setroot(pathname $root)
* root: new template directory.
*/
function set_root($root) {
if (!is_dir($root)) {
$this->halt("set_root: $root is not a directory.");
return false;
}
$this->root = $root;
return true;
}
/* public: set_unknowns(enum $unknowns)
* unknowns: "remove", "comment", "keep"
*
*/
function set_unknowns($unknowns = "keep") {
$this->unknowns = $unknowns;
}
/* public: set_file(array $filelist)
* filelist: array of handle, filename pairs.
*
* public: set_file(string $handle, string $filename)
* handle: handle for a filename,
* filename: name of template file
*/
function set_file($handle, $filename = "") {
if (!is_array($handle)) {
if ($filename == "") {
$this->halt("set_file: For handle $handle filename is empty.");
return false;
}
$this->file[$handle] = $this->filename($filename);
} else {
reset($handle);
while(list($h, $f) = each($handle)) {
$this->file[$h] = $this->filename($f);
}
}
}
/* public: set_block(string $parent, string $handle, string $name = "")
* extract the template $handle from $parent,
* place variable {$name} instead.
*/
function set_block($parent, $handle, $name = "") {
if (!$this->loadfile($parent)) {
$this->halt("subst: unable to load $parent.");
return false;
}
if ($name == "")
$name = $handle;
$str = $this->get_var($parent);
$reg = "/<!--\s+BEGIN $handle\s+-->(.*)\n\s*<!--\s+END $handle\s+-->/sm";
preg_match_all($reg, $str, $m);
$str = preg_replace($reg, "{" . "$name}", $str);
$this->set_var($handle, $m[1][0]);
$this->set_var($parent, $str);
}
/* public: set_var(array $values)
* values: array of variable name, value pairs.
*
* public: set_var(string $varname, string $value)
* varname: name of a variable that is to be defined
* value: value of that variable
*/
function set_var($varname, $value = "") {
if (!is_array($varname)) {
if (!empty($varname))
if ($this->debug) print "scalar: set *$varname* to *$value*<br>\n";
$this->varkeys[$varname] = "/".$this->varname($varname)."/";
$this->varvals[$varname] = $value;
} else {
reset($varname);
while(list($k, $v) = each($varname)) {
if (!empty($k))
if ($this->debug) print "array: set *$k* to *$v*<br>\n";
$this->varkeys[$k] = "/".$this->varname($k)."/";
$this->varvals[$k] = $v;
}
}
}
/* public: subst(string $handle)
* handle: handle of template where variables are to be substituted.
*/
function subst($handle) {
if (!$this->loadfile($handle)) {
$this->halt("subst: unable to load $handle.");
return false;
}
$str = $this->get_var($handle);
$str = @preg_replace($this->varkeys, $this->varvals, $str);
return $str;
}
/* public: psubst(string $handle)
* handle: handle of template where variables are to be substituted.
*/
function psubst($handle) {
print $this->subst($handle);
return false;
}
/* public: parse(string $target, string $handle, boolean append)
* public: parse(string $target, array $handle, boolean append)
* target: handle of variable to generate
* handle: handle of template to substitute
* append: append to target handle
*/
function parse($target, $handle, $append = false) {
if (!is_array($handle)) {
$str = $this->subst($handle);
if ($append) {
$this->set_var($target, $this->get_var($target) . $str);
} else {
$this->set_var($target, $str);
}
} else {
reset($handle);
while(list($i, $h) = each($handle)) {
$str = $this->subst($h);
$this->set_var($target, $str);
}
}
return $str;
}
function pparse($target, $handle, $append = false) {
print $this->parse($target, $handle, $append);
return false;
}
/* public: get_vars()
*/
function get_vars() {
reset($this->varkeys);
while(list($k, $v) = each($this->varkeys)) {
$result[$k] = $this->varvals[$k];
}
return $result;
}
/* public: get_var(string varname)
* varname: name of variable.
*
* public: get_var(array varname)
* varname: array of variable names
*/
function get_var($varname) {
if (!is_array($varname)) {
return $this->varvals[$varname];
} else {
reset($varname);
while(list($k, $v) = each($varname)) {
$result[$k] = $this->varvals[$k];
}
return $result;
}
}
/* public: get_undefined($handle)
* handle: handle of a template.
*/
function get_undefined($handle) {
if (!$this->loadfile($handle)) {
$this->halt("get_undefined: unable to load $handle.");
return false;
}
preg_match_all("/\{([^}]+)\}/", $this->get_var($handle), $m);
$m = $m[1];
if (!is_array($m))
return false;
reset($m);
while(list($k, $v) = each($m)) {
if (!isset($this->varkeys[$v]))
$result[$v] = $v;
}
if (count($result))
return $result;
else
return false;
}
/* public: finish(string $str)
* str: string to finish.
*/
function finish($str) {
switch ($this->unknowns) {
case "keep":
break;
case "remove":
$str = preg_replace('/{[^ \t\r\n}]+}/', "", $str);
break;
case "comment":
$str = preg_replace('/{([^ \t\r\n}]+)}/', "<!-- Template $handle: Variable \\1 undefined -->", $str);
break;
}
return $str;
}
/* public: p(string $varname)
* varname: name of variable to print.
*/
function p($varname) {
print $this->finish($this->get_var($varname));
}
function get($varname) {
return $this->finish($this->get_var($varname));
}
/***************************************************************************/
/* private: filename($filename)
* filename: name to be completed.
*/
function filename($filename) {
if (substr($filename, 0, 1) != "/") {
$filename = $this->root."/".$filename;
}
if (!file_exists($filename))
$this->halt("filename: file $filename does not exist.");
return $filename;
}
/* private: varname($varname)
* varname: name of a replacement variable to be protected.
*/
function varname($varname) {
return preg_quote("{".$varname."}");
}
/* private: loadfile(string $handle)
* handle: load file defined by handle, if it is not loaded yet.
*/
function loadfile($handle) {
if (isset($this->varkeys[$handle]) and !empty($this->varvals[$handle]))
return true;
if (!isset($this->file[$handle])) {
$this->halt("loadfile: $handle is not a valid handle.");
return false;
}
$filename = $this->file[$handle];
$str = implode("", @file($filename));
if (empty($str)) {
$this->halt("loadfile: While loading $handle, $filename does not exist or is empty.");
return false;
}
$this->set_var($handle, $str);
return true;
}
/***************************************************************************/
/* public: halt(string $msg)
* msg: error message to show.
*/
function halt($msg) {
$this->last_error = $msg;
if ($this->halt_on_error != "no")
$this->haltmsg($msg);
if ($this->halt_on_error == "yes")
die("<b>Halted.</b>");
return false;
}
/* public, override: haltmsg($msg)
* msg: error message to show.
*/
function haltmsg($msg) {
printf("<b>Template Error:</b> %s<br>\n", $msg);
}
}

View File

@ -1,49 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
$d1 = strtolower(substr($phpgw_info["server"]["api_inc"],0,3));
if($d1 == "htt" || $d1 == "ftp") {
echo "Failed attempt to break in via an old Security Hole!<br>\n";
exit;
} unset($d1);
// Note: We should add a way to force the developer to say which ones to use. (jengo)
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_rssparse.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_clientsniffer.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_http.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_matrixview.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_menutree.inc.php");
include($phpgw_info["server"]["api_inc"] . "/phpgw_utilities_sbox.inc.php");
class utilities
{
var $rssparser;
var $clientsniffer;
var $http;
var $matrixview;
var $menutree;
var $sbox;
function utilities_()
{
$this->rssparser = new rssparser;
$this->clientsniffer = new clientsniffer;
$this->http = new http;
$this->matrixview = new matrixview;
$this->menutree = new menutree;
$this->sbox = new sbox;
}
}
?>

View File

@ -1,329 +0,0 @@
<?php
/******************************************
** Description : PHPClientSniffer
** Version : 1.0.0
** File Name : PHPClientSniffer.php3
** Author : Roger Raymond for PHyX8 studios
** Author Email : roger.raymond@asphyxia.com
** Created : Wednesday, August 23, 2000
** Last Modified :
** Modified By :
*'
INFO:
Returns client information based on HTTP_USER_AGENT
BASED ON WORKS AND IDEAS BY:
Tim Perdue of PHPBuilder.com
http://www.phpbuilder.com/columns/tim20000821.php3
The Ultimate JavaScript Client Sniffer by Netscape.
http://developer.netscape.com/docs/examples/javascript/NAME_type.html
========================================================================
USAGE:
========================================================================
include("PHPClientSniffer.php3");
$is = new sniffer;
========================================================================
VARIABLE NAMES VALUES
========================================================================
$is->UA The HTTP USER AGENT String
$is->NAME Browser Name (Netscape, IE, Opera, iCab, Unknown)
$is->VERSION Browser Full Version
$is->MAJORVER Browser Major Version
$is->MINORVER Browser Minor Version
$is->AOL True/False
$is->WEBTV True/False
$is->JS Assumed JavaScript Version Supported by Browser
$is->PLATFORM System Platform (Win16,Win32,Mac,OS2,Unix)
$is->OS System OS (Win98,OS2,Mac68k,linux,bsd,etc...) see code
$is->IP REMOTE_ADDR
========================================================================
'****************************************/
/* $Id$ */
class clientsniffer
{ var $UA = "";
var $NAME = "Unknown";
var $VERSION = 0;
var $MAJORVER = 0;
var $MINORVER = 0;
var $AOL = false;
var $WEBTV = false;
var $JS = 0.0;
var $PLATFORM = "Unknown";
var $OS = "Unknown";
var $IP = "Unknown";
/* START CONSTRUCTOR */
function clientsniffer()
{ $this->UA = getenv(HTTP_USER_AGENT);
// Determine NAME Name and Version
if ( eregi( 'MSIE ([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) ||
eregi( 'Microsoft Internet Explorer ([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) )
{ $this->VERSION = $info[1];
$this->NAME = 'IE';
}
elseif ( eregi( 'Opera ([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) ||
eregi( 'Opera/([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) )
{ $this->VERSION = $info[1];
$this->NAME = 'Opera';
}
elseif ( eregi( 'iCab ([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) ||
eregi( 'iCab/([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) )
{ $this->VERSION = $info[1];
$this->NAME = 'iCab';
}
elseif ( eregi( 'Netscape6/([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) )
{ $this->VERSION = $info[1];
$this->NAME = 'Netscape';
}
elseif ( eregi( 'Mozilla/([0-9].[0-9a-zA-Z]{1,4})',$this->UA,$info) )
{ $this->VERSION = $info[1];
$this->NAME = 'Netscape';
}
else
{ $this->VERSION = 0;
$this->NAME = 'Unknown';
}
// Determine if AOL or WEBTV
if( eregi( 'aol',$this->UA,$info))
{ $this->AOL = true;
}
elseif( eregi( 'webtv',$this->UA,$info))
{ $this->WEBTV = true;
}
// Determine Major and Minor Version
if($this->VERSION > 0)
{ $pos = strpos($this->VERSION,".");
if ($pos > 0)
{ $this->MAJORVER = substr($this->VERSION,0,$pos);
$this->MINORVER = substr($this->VERSION,$pos,strlen($this->VERSION));
}
else $this->MAJORVER = $this->VERSION;
}
// Determine Platform and OS
// Check for Windows 16-bit
if( eregi('Win16',$this->UA) ||
eregi('windows 3.1',$this->UA) ||
eregi('windows 16-bit',$this->UA) ||
eregi('16bit',$this->UA))
{ $this->PLATFORM = "Win16";
$this->OS = "Win31";
}
// Check for Windows 32-bit
if(eregi('Win95',$this->UA) || eregi('windows 95',$this->UA))
{ $this->PLATFORM = "Win32";
$this->OS = "Win95";
}
elseif(eregi('Win98',$this->UA) || eregi('windows 98',$this->UA))
{ $this->PLATFORM = "Win32";
$this->OS = "Win98";
}
elseif(eregi('WinNT',$this->UA) || eregi('windows NT',$this->UA))
{ $this->PLATFORM = "Win32";
$this->OS = "WinNT";
}
else
{ $this->PLATFORM = "Win32";
$this->OS = "Win9xNT";
}
// Check for OS/2
if( eregi('os/2',$this->UA) ||
eregi('ibm-webexplorer',$this->UA))
{ $this->PLATFORM = "OS2";
$this->OS = "OS2";
}
// Check for Mac 68000
if( eregi('68k',$this->UA) ||
eregi('68000',$this->UA))
{ $this->PLATFORM = "Mac";
$this->OS = "Mac68k";
}
//Check for Mac PowerPC
if( eregi('ppc',$this->UA) ||
eregi('powerpc',$this->UA))
{ $this->PLATFORM = "Mac";
$this->OS = "MacPPC";
}
// Check for Unix Flavor
//SunOS
if(eregi('sunos',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "sun";
}
if(eregi('sunos 4',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "sun4";
}
elseif(eregi('sunos 5',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "sun5";
}
elseif(eregi('i86',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "suni86";
}
// Irix
if(eregi('irix',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "irix";
}
if(eregi('irix 6',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "irix6";
}
elseif(eregi('irix 5',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "irix5";
}
//HP-UX
if(eregi('hp-ux',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "hpux";
}
if(eregi('hp-ux',$this->UA) && ereg('10.',$this-UA))
{ $this->PLATFORM = "Unix";
$this->OS = "hpux10";
}
elseif(eregi('hp-ux',$this->UA) && ereg('09.',$this-UA))
{ $this->PLATFORM = "Unix";
$this->OS = "hpux9";
}
//AIX
if(eregi('aix',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "aix";
}
if(eregi('aix1',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "aix1";
}
elseif(eregi('aix2',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "aix2";
}
elseif(eregi('aix3',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "aix3";
}
elseif(eregi('aix4',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "aix4";
}
// Linux
if(eregi('inux',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "linux";
}
//Unixware
if(eregi('unix_system_v',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "unixware";
}
//mpras
if(eregi('ncr',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "mpras";
}
//Reliant
if(eregi('reliantunix',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "reliant";
}
// DEC
if(eregi('dec',$this->UA) ||
eregi('osfl',$this->UA) ||
eregi('alphaserver',$this->UA) ||
eregi('ultrix',$this->UA) ||
eregi('alphastation',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "dec";
}
// Sinix
if(eregi('sinix',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "sinix";
}
// FreeBSD
if(eregi('freebsd',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "freebsd";
}
// BSD
if(eregi('bsd',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "bsd";
}
// VMS
if(eregi('vax',$this->UA) || eregi('openvms',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "vms";
}
// SCO
if(eregi('sco',$this->UA) || eregi('unix_sv',$this->UA))
{ $this->PLATFORM = "Unix";
$this->OS = "sco";
}
// Assume JavaScript Version
// make the code a bit easier to read
$ie = eregi("ie",$this->NAME);
$ie5 = ( eregi("ie",$this->NAME) && ($this->MAJORVER >= 5) );
$ie4 = ( eregi("ie",$this->NAME) && ($this->MAJORVER >= 4) );
$ie3 = ( eregi("ie",$this->NAME) && ($this->MAJORVER >= 3) );
$nav = eregi("netscape",$this->NAME);
$nav5 = ( eregi("netscape",$this->NAME) && ($this->MAJORVER >= 5) );
$nav4 = ( eregi("netscape",$this->NAME) && ($this->MAJORVER >= 4) );
$nav3 = ( eregi("netscape",$this->NAME) && ($this->MAJORVER >= 3) );
$nav2 = ( eregi("netscape",$this->NAME) && ($this->MAJORVER >= 2) );
$opera = eregi("opera",$this->NAME);
// do the assumption
// update as new versions are released
// Provide upward compatibilty
if($nav && ($this->MAJORVER > 5)) $this->JS = 1.4;
elseif($ie && ($this->MAJORVER > 5)) $this->JS = 1.3;
// check existing versions
elseif($nav5) $this->JS = 1.4;
elseif(($nav4 && ($this->VERSION > 4.05)) || $ie4) $this->JS = 1.3;
elseif(($nav4 && ($this->VERSION <= 4.05)) || $ie4) $this->JS = 1.2;
elseif($nav3 || $opera) $this->JS = 1.1;
elseif(($nav && ($this->MAJORVER >= 2)) || ($ie && ($this->MAJORVER >=3))) $this->JS = 1.0;
//no idea
else $this->JS = 0.0;
// Grab IP Address
$this->IP = getenv('REMOTE_ADDR');
}
}

View File

@ -1,467 +0,0 @@
<?
/*
* http.php
*
*
$Id$
*/
class http
{
var $host_name="";
var $host_port=80;
var $proxy_host_name="";
var $proxy_host_port=80;
var $request_method="GET";
var $user_agent="Manuel Lemos HTTP class test script";
var $request_uri="";
var $protocol_version="1.0";
var $debug=0;
var $support_cookies=1;
var $cookies=array();
/* private variables - DO NOT ACCESS */
var $state="Disconnected";
var $connection=0;
var $content_length=0;
var $read_length=0;
var $request_host="";
var $months=array(
"Jan"=>"01",
"Feb"=>"02",
"Mar"=>"03",
"Apr"=>"04",
"May"=>"05",
"Jun"=>"06",
"Jul"=>"07",
"Aug"=>"08",
"Sep"=>"09",
"Oct"=>"10",
"Nov"=>"11",
"Dec"=>"12");
/* Private methods - DO NOT CALL */
Function OutputDebug($message)
{
echo $message,"\n";
}
Function GetLine()
{
for($line="";;)
{
if(feof($this->connection)
|| !($part=fgets($this->connection,100)))
return(0);
$line.=$part;
$length=strlen($line);
if($length>=2
&& substr($line,$length-2,2)=="\r\n")
{
$line=substr($line,0,$length-2);
if($this->debug)
$this->OutputDebug("< $line");
return($line);
}
}
}
Function PutLine($line)
{
if($this->debug)
$this->OutputDebug("> $line");
return(fputs($this->connection,"$line\r\n"));
}
Function PutData($data)
{
if($this->debug)
$this->OutputDebug("> $data");
return(fputs($this->connection,$data));
}
Function Readbytes($length)
{
if($this->debug)
{
if(($bytes=fread($this->connection,$length))!="")
$this->OutputDebug("< $bytes");
return($bytes);
}
else
return(fread($this->connection,$length));
}
Function EndOfInput()
{
return(feof($this->connection));
}
Function Connect($host_name,$host_port)
{
if($this->debug)
$this->OutputDebug("Connecting to $host_name...");
if(($this->connection=fsockopen($host_name,$host_port,&$error))==0)
{
switch($error)
{
case -3:
return("-3 socket could not be created");
case -4:
return("-4 dns lookup on hostname \"".$host_name."\" failed");
case -5:
return("-5 connection refused or timed out");
case -6:
return("-6 fdopen() call failed");
case -7:
return("-7 setvbuf() call failed");
default:
return($error." could not connect to the host \"".$host_name."\"");
}
}
else
{
if($this->debug)
$this->OutputDebug("Connected to $host_name");
$this->state="Connected";
return("");
}
}
Function Disconnect()
{
if($this->debug)
$this->OutputDebug("Disconnected from ".$this->host_name);
fclose($this->connection);
return("");
}
/* Public methods */
Function Open($arguments)
{
if($this->state!="Disconnected")
return("1 already connected");
if(IsSet($arguments["HostName"]))
$this->host_name=$arguments["HostName"];
if(IsSet($arguments["HostPort"]))
$this->host_port=$arguments["HostPort"];
if(IsSet($arguments["ProxyHostName"]))
$this->proxy_host_name=$arguments["ProxyHostName"];
if(IsSet($arguments["ProxyHostPort"]))
$this->proxy_host_port=$arguments["ProxyHostPort"];
if(strlen($this->proxy_host_name)==0)
{
if(strlen($this->host_name)==0)
return("2 it was not specified a valid hostname");
$host_name=$this->host_name;
$host_port=$this->host_port;
}
else
{
$host_name=$this->proxy_host_name;
$host_port=$this->proxy_host_port;
}
$error=$this->Connect($host_name,$host_port);
if(strlen($error)==0)
$this->state="Connected";
return($error);
}
Function Close()
{
if($this->state=="Disconnected")
return("1 already disconnected");
$error=$this->Disconnect();
if(strlen($error)==0)
$this->state="Disconnected";
return($error);
}
Function SendRequest($arguments)
{
switch($this->state)
{
case "Disconnected":
return("1 connection was not yet established");
case "Connected":
break;
default:
return("2 can not send request in the current connection state");
}
if(IsSet($arguments["RequestMethod"]))
$this->request_method=$arguments["RequestMethod"];
if(IsSet($arguments["User-Agent"]))
$this->user_agent=$arguments["User-Agent"];
if(strlen($this->request_method)==0)
return("3 it was not specified a valid request method");
if(IsSet($arguments["RequestURI"]))
$this->request_uri=$arguments["RequestURI"];
if(strlen($this->request_uri)==0
|| substr($this->request_uri,0,1)!="/")
return("4 it was not specified a valid request URI");
$request_body="";
$headers=(IsSet($arguments["Headers"]) ? $arguments["Headers"] : array());
if($this->request_method=="POST")
{
if(IsSet($arguments["PostValues"]))
{
$values=$arguments["PostValues"];
if(GetType($values)!="array")
return("5 it was not specified a valid POST method values array");
for($request_body="",Reset($values),$value=0;$value<count($values);Next($values),$value++)
{
if($value>0)
$request_body.="&";
$request_body.=Key($values)."=".UrlEncode($values[Key($values)]);
}
$headers["Content-type"]="application/x-www-form-urlencoded";
}
}
if(strlen($this->proxy_host_name)==0)
$request_uri=$this->request_uri;
else
$request_uri="http://".$this->host_name.($this->host_port==80 ? "" : ":".$this->host_port).$this->request_uri;
if(($success=$this->PutLine($this->request_method." ".$request_uri." HTTP/".$this->protocol_version)))
{
if(($body_length=strlen($request_body)))
$headers["Content-length"]=$body_length;
for($host_set=0,Reset($headers),$header=0;$header<count($headers);Next($headers),$header++)
{
$header_name=Key($headers);
$header_value=$headers[$header_name];
if(GetType($header_value)=="array")
{
for(Reset($header_value),$value=0;$value<count($header_value);Next($header_value),$value++)
{
if(!$success=$this->PutLine("$header_name: ".$header_value[Key($header_value)]))
break 2;
}
}
else
{
if(!$success=$this->PutLine("$header_name: $header_value"))
break;
}
if(strtolower(Key($headers))=="host")
{
$this->request_host=strtolower($header_value);
$host_set=1;
}
}
if($success)
{
if(!$host_set)
{
$success=$this->PutLine("Host: ".$this->host_name);
$this->request_host=strtolower($this->host_name);
}
if(count($this->cookies)
&& IsSet($this->cookies[0]))
{
$now=gmdate("Y-m-d H-i-s");
for($cookies=array(),$domain=0,Reset($this->cookies[0]);$domain<count($this->cookies[0]);Next($this->cookies[0]),$domain++)
{
$domain_pattern=Key($this->cookies[0]);
$match=strlen($this->request_host)-strlen($domain_pattern);
if($match>=0
&& !strcmp($domain_pattern,substr($this->request_host,$match))
&& ($match==0
|| $domain_pattern[0]=="."
|| $this->request_host[$match-1]=="."))
{
for(Reset($this->cookies[0][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[0][$domain_pattern]);Next($this->cookies[0][$domain_pattern]),$path_part++)
{
$path=Key($this->cookies[0][$domain_pattern]);
if(strlen($this->request_uri)>=strlen($path)
&& substr($this->request_uri,0,strlen($path))==$path)
{
for(Reset($this->cookies[0][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[0][$domain_pattern][$path]);Next($this->cookies[0][$domain_pattern][$path]),$cookie++)
{
$cookie_name=Key($this->cookies[0][$domain_pattern][$path]);
$expires=$this->cookies[0][$domain_pattern][$path][$cookie_name]["expires"];
if($expires==""
|| strcmp($now,$expires)<0)
$cookies[$cookie_name]=$this->cookies[0][$domain_pattern][$path][$cookie_name];
}
}
}
}
}
for(Reset($cookies),$cookie=0;$cookie<count($cookies);Next($cookies),$cookie++)
{
$cookie_name=Key($cookies);
if(!($success=$this->PutLine("Cookie: ".UrlEncode($cookie_name)."=".$cookies[$cookie_name]["value"].";")))
break;
}
}
if($success)
{
if($success)
{
$success=$this->PutLine("");
if($body_length
&& $success)
$success=$this->PutData($request_body);
}
}
}
}
if(!$success)
return("5 could not send the HTTP request");
$this->state="RequestSent";
return("");
}
Function ReadReplyHeaders(&$headers)
{
switch($this->state)
{
case "Disconnected":
return("1 connection was not yet established");
case "Connected":
return("2 request was not sent");
case "RequestSent":
break;
default:
return("3 can not get request headers in the current connection state");
}
$headers=array();
$this->content_length=$this->read_length=0;
$this->content_length_set=0;
for(;;)
{
$line=$this->GetLine();
if(GetType($line)!="string")
return("4 could not read request reply");
if($line=="")
{
$this->state="GotReplyHeaders";
return("");
}
$header_name=strtolower(strtok($line,":"));
$header_value=Trim(Chop(strtok("\r\n")));
if(IsSet($headers[$header_name]))
{
if(GetType($headers[$header_name])=="string")
$headers[$header_name]=array($headers[$header_name]);
$headers[$header_name][]=$header_value;
}
else
$headers[$header_name]=$header_value;
switch($header_name)
{
case "content-length":
$this->content_length=intval($headers[$header_name]);
$this->content_length_set=1;
break;
case "set-cookie":
if($this->support_cookies)
{
$cookie_name=trim(strtok($headers[$header_name],"="));
$cookie_value=strtok(";");
$domain=$this->request_host;
$path="/";
$expires="";
$secure=0;
while(($name=strtolower(trim(strtok("="))))!="")
{
$value=UrlDecode(strtok(";"));
switch($name)
{
case "domain":
if($value==""
|| !strpos($value,".",$value[0]=="."))
break;
$domain=strtolower($value);
break;
case "path":
if($value!=""
&& $value[0]=="/")
$path=$value;
break;
case "expires":
if(ereg("^((Mon|Monday|Tue|Tuesday|Wed|Wednesday|Thu|Thursday|Fri|Friday|Sat|Saturday|Sun|Sunday), )?([0-9]{2})\\-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\-([0-9]{2,4}) ([0-9]{2})\\:([0-9]{2})\\:([0-9]{2}) GMT$",$value,$matches))
{
$year=intval($matches[5]);
if($year<1900)
$year+=($year<70 ? 2000 : 1900);
$expires="$year-".$this->months[$matches[4]]."-".$matches[3]." ".$matches[6].":".$matches[7].":".$matches[8];
}
break;
case "secure":
$secure=1;
break;
}
}
$this->cookies[$secure][$domain][$path][$cookie_name]=array(
"name"=>$cookie_name,
"value"=>$cookie_value,
"domain"=>$domain,
"path"=>$path,
"expires"=>$expires,
"secure"=>$secure
);
}
}
}
}
Function ReadReplyBody(&$body,$length)
{
switch($this->state)
{
case "Disconnected":
return("1 connection was not yet established");
case "Connected":
return("2 request was not sent");
case "RequestSent":
if(($error=$this->ReadReplyHeaders(&$headers))!="")
return($error);
break;
case "GotReplyHeaders":
break;
default:
return("3 can not get request headers in the current connection state");
}
$body="";
if($this->content_length_set)
$length=min($this->content_length-$this->read_length,$length);
if($length>0
&& !$this->EndOfInput()
&& ($body=$this->ReadBytes($length))=="")
return("4 could not get the request reply body");
return("");
}
Function GetPersistentCookies(&$cookies)
{
$now=gmdate("Y-m-d H-i-s");
$cookies=array();
for($secure_cookies=0,Reset($this->cookies);$secure_cookies<count($this->cookies);Next($this->cookies),$secure_cookies++)
{
$secure=Key($this->cookies);
for($domain=0,Reset($this->cookies[$secure]);$domain<count($this->cookies[$secure]);Next($this->cookies[$secure]),$domain++)
{
$domain_pattern=Key($this->cookies[$secure]);
for(Reset($this->cookies[$secure][$domain_pattern]),$path_part=0;$path_part<count($this->cookies[$secure][$domain_pattern]);Next($this->cookies[$secure][$domain_pattern]),$path_part++)
{
$path=Key($this->cookies[$secure][$domain_pattern]);
for(Reset($this->cookies[$secure][$domain_pattern][$path]),$cookie=0;$cookie<count($this->cookies[$secure][$domain_pattern][$path]);Next($this->cookies[$secure][$domain_pattern][$path]),$cookie++)
{
$cookie_name=Key($this->cookies[$secure][$domain_pattern][$path]);
$expires=$this->cookies[$secure][$domain_pattern][$path][$cookie_name]["expires"];
if($expires!=""
&& strcmp($now,$expires)<0)
$cookies[$secure][$domain_pattern][$path][$cookie_name]=$this->cookies[$secure][$domain_pattern][$path][$cookie_name];
}
}
}
}
}
};

View File

@ -1,304 +0,0 @@
<?PHP
/**
*
* class for creating matrix like timeframes for items
*
* this matrix is having the days of actual month in
* the x-axis and the items, which could be projects,
* in the y-axis.
* You will see a top-down view of all items and their
* associated timeframes. You probably saw this in
* projectmanagement apps
*
* @author Marc Logemann [loge@mail.com]
* @version 0.9
*
*/
class matrixview {
var $sumdays = 0;
var $month = 0;
var $monthname = "";
var $year = 0;
var $day = 0;
var $items_content = array();
var $items_count = 0;
var $arr_second_dim = 0;
var $image1pix = "images/pix.gif";
var $color_headerfield = "#FFFF33";
var $color_emptyfield = "#CCCCCC";
var $selection = 1;
/**
*
* construtor: graphview class
*
* constructor waits for the desired month in
* integer presentation and the desired year also
* in integer presentation 4 digits (ex. 2001)
*
* @param int month (for example: 02)
* @param int year (for example: 2001)
*
*/
function matrixview ($month_int = 0, $year_int = 0)
{
for($i;$i<32;$i++)
{
if(checkdate($month_int,$i,$year_int)) $days++;
}
$this->month = $month_int;
$this->year = $year_int;
}
/**
*
* set a Period for a specified item
*
* setting a period for an element means to define
* a fromDate and and a toDate together with the
* item itself. This will store a timeframe associated
* with an item for later usage
*
* @param string item for the timeframe
* @param date fromdate in format yyyymmdd
* @param date todate in format yyyymmdd
*
* @return boolean false if item cannot be saved
* otherwise true
*/
function setPeriod ($item, $fromdate, $todate, $color="#990033")
{
$fyear = substr($fromdate,0,4);
$fmonth = substr($fromdate,4,2);
$fday = substr($fromdate,6,2);
$tyear = substr($todate,0,4);
$tmonth = substr($todate,4,2);
$tday = substr($todate,6,2);
if(mktime(0,0,0, $tmonth, $tday, $tyear) < mktime(0,0,0, $this->month+1,0,$this->year))
$this->day = $tday;
else
{
$dinfo = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->day = $dinfo[mday];
}
$go = 1;
$i = 0;
$z = 0;
while($go==1)
{
// calculates fromdate
// echo date("d/m/Y", mktime(0,0,0, $fmonth, $fday+$i, $fyear)); echo "<br>";
$datinfo = getdate(mktime(0,0,0, $fmonth, $fday+$i, $fyear));
if($datinfo["mon"]==$this->month
&& $datinfo["year"]==$this->year
&& $datinfo["mday"]<=$this->day)
{
$t = $datinfo["mday"];
$this->items_content[$this->items_count][$t] = "x";
}
if (mktime(0,0,0, $fmonth, $fday+$i, $fyear) >=
mktime(0,0,0, $this->month+1, 0, $this->year)
||
mktime(0,0,0, $fmonth, $fday+$i, $fyear) >=
mktime(0,0,0, $tmonth, $tday, $tyear)) $go = 0
;
$i++;
}
$this->items_content[$this->items_count][0] = "$item;$color";
// increase number of items in two-dimensional array
$this->items_count++;
}
/**
*
* sets the color for empty dayfields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setEmptyFieldColor ($color)
{
$this->color_emptyfield=$color;
}
/**
*
* sets the color for calendar day fields
*
* @param string color in hexadecimal (ex. "#336699")
*/
function setHeaderFieldColor ($color)
{
$this->color_headerfield=$color;
}
/**
*
* sets a new path for 1pixel (pix.gif) gif needed for the table
* default is set actual script dir + /images
*
* @param string path and name to 1pixel gif
*/
function set1PixelGif ($filepath)
{
$this->image1pix=$filepath;
}
/**
*
* disable selection of new timeframe
*
*/
function diableSelection ()
{
$this->selection=0;
}
/**
*
* return the html code for the matrix
*
* will return the complete html code for the matrix.
* In the calling program you can do some other
* operations on it, because it wont be echoed directly
*
* @return string html code for the matrix
*/
function out ()
{
// get days of desired month (month submitted in constructor)
$in = getdate(mktime(0,0,0, $this->month+1,0,$this->year));
$this->sumdays = $in[mday];
$this->monthname = $in[month];
$this->out_monthyear();
echo "<div align=\"center\">\n";
echo "<table border=0>\n";
$this->out_header();
// loop through number of items
for($z=0;$z<$this->items_count;$z++)
{
// seperate color and name from first array element
$itemname = strtok($this->items_content[$z][0],";");
$itemcolor = strtok(";");
echo "<tr>\n";
echo "<td>" . $itemname . "</td>\n";
// loop through days of desired month
for($r=1;$r<$this->sumdays+1;$r++)
{
if($this->items_content[$z][$r]=="x") $color = $itemcolor; else $color = $this->color_emptyfield;
echo "<td bgcolor=\"$color\">&nbsp;</td>\n";
}
echo "</tr>\n";
$this->out_ruler();
}
echo "</table>";
echo "</div>\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_header ()
{
echo "<tr>\n";
echo "<td height=\"1\" colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=black><img src=\"" . $this->image1pix . "\"></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td>Projectname</td>\n";
for($i=1;$i<$this->sumdays+1;$i++)
{
echo "<td bgcolor=\""; echo $this->color_headerfield; echo "\">" . sprintf("%02d",$i) . "</td>\n";
}
echo "</tr>\n";
echo "<tr>\n";
echo "<td height=\"1\" colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=black><img src=\"" . $this->image1pix ."\"></td>\n";
echo "</tr>\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_ruler ()
{
echo "<tr>\n";
echo "<td colspan=\""; echo $this->sumdays+1; echo "\" bgcolor=\"#999999\"><img src=\"" . $this->image1pix ."\"></td>\n";
echo "</tr>\n";
}
/**
*
* private class for out method
*
* should not be used from external
*
*/
function out_monthyear ()
{
global $phpgw;
echo "<form action=\"" . $phpgw->link() . "\" method=\"post\">\n";
echo "<table border=0 width=\"100%\" cellpadding=\"0\" cellspacing=\"0\">";
echo "<tr>\n";
echo "<td align=\"center\"><h2>"; echo $this->monthname; echo " "; echo $this->year; echo "</h2></td>\n";
if($this->selection==1)
{
echo "<td align=\"right\">Month: <select name=\"month\"";
for($i=0;$i<13;$i++)
{
if($this->month==$i) $sel = " selected"; else unset($sel);
echo "<option value=\"$i\"$sel>$i</option>"; }
echo "</select>";
echo "Year: <select name=\"year\"";
for($i = date("Y") -2;$i<date("Y")+5;$i++)
{
if($this->year==$i) $sel = " selected"; else unset($sel);
echo "<option value=\"$i\"$sel>$i</option>";
}
echo "</select>";
echo "&nbsp;<input type=\"submit\" name=\"selection\" value=\"Select\">&nbsp;";
echo "</td>\n";
}
echo "</tr>\n";
echo "</table>\n";
echo "</form>\n";
}
}
?>

View File

@ -1,294 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file based on PHP3 TreeMenu *
* (c)1999 Bjorge Dijkstra <bjorge@gmx.net> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
/*********************************************/
/* Settings */
/*********************************************/
/* */
/* $treefile variable needs to be set in */
/* main file */
/* */
/*********************************************/
class menutree {
function showtree($treefile, $expandlevels="", $num_menus = 50, $invisible_menus = Null){
global $phpgw_info, $phpgw;
$script = $SCRIPT_NAME;
$img_expand = "templates/default/images/tree_expand.gif";
$img_collapse = "templates/default/images/tree_collapse.gif";
$img_line = "templates/default/images/tree_vertline.gif";
$img_split = "templates/default/images/tree_split.gif";
$img_end = "templates/default/images/tree_end.gif";
$img_leaf = "templates/default/images/tree_leaf.gif";
$img_spc = "templates/default/images/tree_space.gif";
/*********************************************/
/* Read text file with tree structure */
/*********************************************/
/*********************************************/
/* read file to $tree array */
/* tree[x][0] -> tree level */
/* tree[x][1] -> item text */
/* tree[x][2] -> item link */
/* tree[x][3] -> link target */
/* tree[x][4] -> last item in subtree */
/*********************************************/
$maxlevel=0;
$cnt=0;
$fd = fopen($treefile, "r");
if ($fd==0) die("menutree.inc : Unable to open file ".$treefile);
while ($buffer = fgets($fd, 4096)) {
$tree[$cnt][0]=strspn($buffer,".");
$tmp=rtrim(substr($buffer,$tree[$cnt][0]));
$node=explode("|",$tmp);
$tree[$cnt][1]=$node[0];
$tree[$cnt][2]=$node[1];
$tree[$cnt][3]=$node[2];
$tree[$cnt][4]=0;
if ($tree[$cnt][0] > $maxlevel) $maxlevel=$tree[$cnt][0];
$cnt++;
}
fclose($fd);
for ($i=0; $i<count($tree); $i++) {
$expand[$i]=0;
$visible[$i]=0;
$levels[$i]=0;
}
/*********************************************/
/* Get Node numbers to expand */
/*********************************************/
if ($expandlevels!="") $explevels = explode("|",$expandlevels);
$i=0;
while($i<count($explevels)) {
$expand[$explevels[$i]]=1;
$i++;
}
/*********************************************/
/* Find last nodes of subtrees */
/*********************************************/
$lastlevel=$maxlevel;
for ($i=count($tree)-1; $i>=0; $i--) {
if ( $tree[$i][0] < $lastlevel ) {
for ($j=$tree[$i][0]+1; $j <= $maxlevel; $j++) {
$levels[$j]=0;
}
}
if ( $levels[$tree[$i][0]]==0 ) {
$levels[$tree[$i][0]]=1;
$tree[$i][4]=1;
} else
$tree[$i][4]=0;
$lastlevel=$tree[$i][0];
}
/*********************************************/
/* Determine visible nodes */
/*********************************************/
$visible[0]=1; // root is always visible
$visible[1]=1; // root is always visible
$visible[2]=1; // root is always visible
$visible[3]=0; // root is always visible
$visible[4]=0; // root is always visible
$visible[5]=0; // root is always visible
$visible[6]=0; // root is always visible
$visible[7]=1; // root is always visible
$visible[8]=0; // root is always visible
$visible[9]=0; // root is always visible
$visible[10]=0; // root is always visible
$visible[11]=1; // root is always visible
$visible[12]=0; // root is always visible
$visible[13]=0; // root is always visible
$visible[14]=0; // root is always visible
$visible[15]=0; // root is always visible
$visible[16]=1; // root is always visible
$visible[17]=1; // root is always visible
$visible[18]=1; // root is always visible
$visible[19]=1; // root is always visible
$visible[20]=1; // root is always visible
$visible[21]=0; // root is always visible
$visible[22]=0; // root is always visible
$visible[23]=1; // root is always visible
$visible[24]=0; // root is always visible
$visible[25]=0; // root is always visible
$visible[26]=1; // root is always visible
$visible[27]=0; // root is always visible
$visible[28]=0; // root is always visible
for ($i=0; $i<count($explevels); $i++) {
$n=$explevels[$i];
if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
$j=$n+1;
while ( $tree[$j][0] > $tree[$n][0] ) {
if ($tree[$j][0]==$tree[$n][0]+1) $visible[$j]=1;
$j++;
}
}
}
for ($i=0; $i<count($explevels); $i++) {
$n=$explevels[$i];
if ( ($visible[$n]==1) && ($expand[$n]==1) ) {
$j=$n+1;
while ( $tree[$j][0] == $tree[$n][0] + 1 ) {
$visible[$j]=1;
$j++;
}
}
}
/*********************************************/
/* Output nicely formatted tree */
/*********************************************/
for ($i=0; $i<$maxlevel; $i++) $levels[$i]=1;
$maxlevel++;
$cnt=0;
while ($cnt<count($tree)) {
if ($visible[$cnt]) {
/****************************************/
/* Create expand/collapse parameters */
/****************************************/
$i=1; $params="p=";
while($i<count($expand)) {
if ( ($expand[$i]==1) && ($cnt!=$i) || ($expand[$i]==0 && $cnt==$i)) {
$params=$params.$i;
$params=$params."|";
}
$i++;
}
/****************************************/
/* Always display the extreme top level */
/****************************************/
if($cnt==0) {
$str = "<table cellspacing=0 cellpadding=0 border=0 cols=".($maxlevel+3)." width=".($maxlevel*16+100).">\n";
$str .= "<a href=\"".$phpgw->link("index.php",$params)."\" target=_parent><img src=\"templates/default/images/docs.gif\" border=\"0\"></a>\n";
$str .= "<tr>";
for ($i=0; $i<$maxlevel; $i++) $str .= "<td width=16></td>";
$str .= "<td width=100></td></tr>\n";
}
/****************************************/
/* start new row */
/****************************************/
$str .= "<tr>";
/****************************************/
/* vertical lines from higher levels */
/****************************************/
$i=0;
while ($i<$tree[$cnt][0]-1) {
if ($levels[$i]==1)
$str .= "<td><img src=\"".$img_line."\"></td>";
else
$str .= "<td><img src=\"".$img_spc."\"></td>";
$i++;
}
/****************************************/
/* corner at end of subtree or t-split */
/****************************************/
if ($tree[$cnt][4]==1) {
$str .= "<td><img src=\"".$img_end."\"></td>";
$levels[$tree[$cnt][0]-1]=0;
} else {
$str .= "<td><img src=\"".$img_split."\"></td>";
$levels[$tree[$cnt][0]-1]=1;
}
/********************************************/
/* Node (with subtree) or Leaf (no subtree) */
/********************************************/
if ($tree[$cnt+1][0]>$tree[$cnt][0]) {
if ($expand[$cnt]==0)
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_expand."\" border=no></a></td>";
else
$str .= "<td><a href=\"".$phpgw->link($script,$params)."\"><img src=\"".$img_collapse."\" border=no></a></td>";
} else {
/*************************/
/* Tree Leaf */
/*************************/
$str .= "<td><img src=\"".$img_leaf."\"></td>";
}
/****************************************/
/* output item text */
/****************************************/
if ($tree[$cnt][2]=="")
$str .= "<td colspan=".($maxlevel-$tree[$cnt][0]).">".$tree[$cnt][1]."<font face\=\"Arial, Helvetica, san-serif\" size=\"2\"></td>";
else
$str .= "<td colspan=".($maxlevel-$tree[$cnt][0])."><font face\=\"Arial, Helvetica, san-serif\" size=\"2\"><a href=\"".$phpgw->link($tree[$cnt][2],$params)."\" target=\"".$tree[$cnt][3]."\">".$tree[$cnt][1]."</a></td>";
/****************************************/
/* end row */
/****************************************/
$str .= "</tr>\n";
}
$cnt++;
}
$str .= "</table>\n";
return $str;
/***************************************************/
/* Tree file format */
/* */
/* */
/* The first line is always of format : */
/* .[rootname] */
/* */
/* each line contains one item, the line starts */
/* with a series of dots(.). Each dot is one level */
/* deeper. Only one level at a time once is allowed*/
/* Next comes the come the item name, link and */
/* link target, seperated by a |. */
/* */
/* example: */
/* */
/* .top */
/* ..category 1 */
/* ...item 1.1|item11.htm|main */
/* ...item 2.2|item12.htm|main */
/* ..category 2|cat2overview.htm|main */
/* ...item 2.1|item21.htm|main */
/* ...item 2.2|item22.htm|main */
/* ...item 2.3|item23.htm|main */
/* */
/***************************************************/
}
}

View File

@ -1,155 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare - API *
* http://www.phpgroupware.org *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class baseportalbox {
//Set up the Object, reserving memory space for variables
var $outerwidth;
var $outerbordercolor;
var $outerborderwidth;
var $titlebgcolor;
var $width;
var $innerwidth;
var $innerbgcolor;
// Textual variables
var $title;
/*
Use these functions to get and set the values of this
object's variables. This is good OO practice, as it means
that datatype checking can be completed and errors raised accordingly.
*/
function setvar($var,$value="") {
if ($value=="") {
global $$var;
$value = $$var;
}
$this->$var = $value;
// echo $var." = ".$this->$var."<br>\n";
}
function getvar($var="") {
if ($var=="" || !isset($this->$var)) {
global $phpgw;
echo 'Programming Error: '.$this->classname().'->getvar('.$var.')!<br>\n';
$phpgw->common->phpgw_exit();
}
//echo "Var = ".$var."<br>\n";
//echo $var." = ".$this->$var."<br>\n";
return $this->$var;
}
/*
This is the constructor for the object.
*/
function baseportalbox($title="", $primary="", $secondary="", $tertiary="") {
$this->setvar("title",$title);
// echo "After SetVar Title = ".$this->getvar("title")."<br>\n";
$this->setvar("outerborderwidth",1);
$this->setvar("titlebgcolor",$primary);
$this->setvar("innerbgcolor",$secondary);
$this->setvar("outerbordercolor",$tertiary);
}
// Methods
}
class linkbox extends baseportalbox {
/*
Set up the Object. You will notice, we have not reserved
memory space for variables. In this circumstance it is not necessary.
*/
/*
This is the constructor for the linkbox. The only thing this does
is to call the constructor of the parent class. Why? Well, whilst
PHP manages a certain part of OO, one of the bits it falls down on
(at the moment) is constructors within sub-classes. So, to
be sure that the sub-class is instantiated with the constructor of
the parent class, I simply call the parent constructor. Of course,
if I then wanted to override any of the values, I could easily do so.
*/
function linkbox($title="", $primary="", $secondary="", $tertiary="") {
$this->baseportalbox($title, $primary, $secondary, $tertiary);
$this->setvar("outerwidth",300);
$this->setvar("innerwidth",300);
$this->setvar("width",300);
}
/*
This is the only method within the class. Quite simply, as you can see
it draws the table(s), placing the required data in the appropriate place.
*/
function draw() {
global $phpgw, $phpgw_info;
$p = new Template($phpgw->common->get_tpl_dir('home'));
$p->set_file(array('portal_main' => 'portal_main.tpl',
'portal_linkbox_header' => 'portal_linkbox_header.tpl',
'portal_linkbox' => 'portal_linkbox.tpl',
'portal_linkbox_footer' => 'portal_linkbox_footer.tpl'));
$p->set_block('portal_main','portal_linkbox_header','portal_linkbox','portal_linkbox_footer');
$p->set_var('outer_border',$this->getvar('outerborderwidth'));
$p->set_var('outer_width',$this->getvar('width'));
$p->set_var('outer_bordercolor',$this->getvar('outerbordercolor'));
$p->set_var('outer_bgcolor',$this->getvar('titlebgcolor'));
$p->set_var('title',$this->getvar('title'));
$p->set_var('inner_width',$this->getvar('width'));
$p->set_var('inner_bgcolor',$this->getvar('innerbgcolor'));
$p->set_var('header_background_image',$this->getvar('header_background_image'));
$p->parse('output','portal_linkbox_header',True);
for ($x = 0; $x < count($this->data); $x++) {
$p->set_var('link',$this->data[$x][1]);
$p->set_var('text',$this->data[$x][0]);
$p->parse('output','portal_linkbox',True);
}
$p->parse('output','portal_linkbox_footer',True);
return $p->parse('out','portal_main');
}
}
class resultbox extends baseportalbox {
/*
Set up the Object. You will notice, we have not reserved memory
space for variables. In this circumstance it is not necessary.
*/
//constructor
function resultbox($title="", $primary="", $secondary="", $tertiary="") {
$this->baseportalbox($title, $primary, $secondary, $tertiary);
$this->setvar("outerwidth",400);
$this->setvar("innerwidth",400);
}
/*
This is the only method within the class. Quite simply, as you can see
it draws the table(s), placing the required data in the appropriate place.
*/
function draw() {
echo '<table border="'.$this->getvar("outerborderwidth").'" cellpadding="0" cellspacing="0" width="'.$this->getvar("outerwidth").'" bordercolor="'.$this->getvar("outerbordercolor").'" bgcolor="'.$this->getvar("titlebgcolor").'">';
echo '<tr><td align="center">'.$this->getvar("title").'</td></tr>';
echo '<tr><td>';
echo '<table border="0" cellpadding="0" cellspacing="0" width="'.$this->getvar("innerwidth").'" bgcolor="'.$this->getvar("innerbgcolor").'">';
for ($x = 0; $x < count($this->data); $x++) {
echo '<tr>';
echo '<td width="50%">'.$this->data[$x][0].'</td>';
echo '<td width="50%">'.$this->data[$x][1].'</td>';
echo '</tr>';
}
echo '</table>';
echo '</td></tr>';
echo '</table>';
}
}
?>

View File

@ -1,237 +0,0 @@
<?PHP
/*
* rssparse.php3
*
* Copyright (C) 2000 Jeremey Barrett
* j@nwow.org
* http://nwow.org
*
* Version 0.4
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation,Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*
* rssparse.php3 is a small PHP script for parsing RDF/RSS XML data. It has been
* tested with a number of popular web news and information sites such as
* slashdot.org, lwn.net, and freshmeat.net. This is not meant to be exhaustive
* but merely to provide the basic necessities. It will grow in capabilities with
* time, I'm sure.
*
* This is code I wrote for Nerds WithOut Wires, http://nwow.org.
*
*
* USAGE:
* In your PHP script, simply do something akin to this:
*
* include("rssparse.php3");
* $fp = fopen("file", "r");
* $rss = rssparse($fp);
*
* if (!$rss) {
* ERROR;
* }
*
* while (list(,$item) = each($rss->items)) {
* printf("Title: %s\n", $item["title"]);
* printf("Link: %s\n", $item["link"]);
* printf("Description: %s\n", $item["desc"]);
* }
*
* printf("Channel Title: %s\n", $rss->title);
* printf("Channel Description: %s\n", $rss->desc);
* printf("Channel Link: %s\n", $rss->link);
*
* printf("Image Title: %s\n", $rss->image["title"]);
* printf("Image URL: %s\n", $rss->image["url"]);
* printf("Image Description: %s\n", $rss->image["desc"]);
* printf("Image Link: %s\n", $rss->image["link"]);
*
*
* CHANGES:
* 0.4 - rssparse.php3 now supports the channel image tag and correctly supports
* RSS-style channels.
*
*
* BUGS:
* Width and height tags in image not supported, some other tags not supported
* yet.
*
*
* IMPORTANT NOTE:
* This requires PHP's XML routines. You must configure PHP with --with-xml.
*/
/* $Id$ */
function _rssparse_start_elem ($parser, $elem, $attrs) {
global $_rss;
if ($elem == "CHANNEL") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "channel";
$_rss->tmptitle[$_rss->depth] = "";
$_rss->tmplink[$_rss->depth] = "";
$_rss->tmpdesc[$_rss->depth] = "";
}
else if ($elem == "IMAGE") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "image";
$_rss->tmptitle[$_rss->depth] = "";
$_rss->tmplink[$_rss->depth] = "";
$_rss->tmpdesc[$_rss->depth] = "";
$_rss->tmpurl[$_rss->depth] = "";
}
else if ($elem == "ITEM") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "item";
$_rss->tmptitle[$_rss->depth] = "";
$_rss->tmplink[$_rss->depth] = "";
$_rss->tmpdesc[$_rss->depth] = "";
}
else if ($elem == "TITLE") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "title";
}
else if ($elem == "LINK") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "link";
}
else if ($elem == "DESCRIPTION") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "desc";
}
else if ($elem == "URL") {
$_rss->depth++;
$_rss->state[$_rss->depth] = "url";
}
}
function _rssparse_end_elem ($parser, $elem) {
global $_rss;
if ($elem == "CHANNEL") {
$_rss->set_channel($_rss->tmptitle[$_rss->depth], $_rss->tmplink[$_rss->depth], $_rss->tmpdesc[$_rss->depth]);
$_rss->depth--;
}
else if ($elem == "IMAGE") {
$_rss->set_image($_rss->tmptitle[$_rss->depth], $_rss->tmplink[$_rss->depth], $_rss->tmpdesc[$_rss->depth], $_rss->tmpurl[$_rss->depth]);
$_rss->depth--;
}
else if ($elem == "ITEM") {
$_rss->add_item($_rss->tmptitle[$_rss->depth], $_rss->tmplink[$_rss->depth], $_rss->tmpdesc[$_rss->depth]);
$_rss->depth--;
}
else if ($elem == "TITLE") {
$_rss->depth--;
}
else if ($elem == "LINK") {
$_rss->depth--;
}
else if ($elem == "DESCRIPTION") {
$_rss->depth--;
}
else if ($elem == "URL") {
$_rss->depth--;
}
}
function _rssparse_elem_data ($parser, $data) {
global $_rss;
if ($_rss->state[$_rss->depth] == "title") {
$_rss->tmptitle[($_rss->depth - 1)] .= $data;
}
else if ($_rss->state[$_rss->depth] == "link") {
$_rss->tmplink[($_rss->depth - 1)] .= $data;
}
else if ($_rss->state[$_rss->depth] == "desc") {
$_rss->tmpdesc[($_rss->depth - 1)] .= $data;
}
else if ($_rss->state[$_rss->depth] == "url") {
$_rss->tmpurl[($_rss->depth - 1)] .= $data;
}
}
class rssparser {
var $title;
var $link;
var $desc;
var $items = array();
var $nitems;
var $image = array();
var $state = array();
var $tmptitle = array();
var $tmplink = array();
var $tmpdesc = array();
var $tmpurl = array();
var $depth;
function rssparser() {
$this->nitems = 0;
$this->depth = 0;
}
function set_channel($in_title, $in_link, $in_desc) {
$this->title = $in_title;
$this->link = $in_link;
$this->desc = $in_desc;
}
function set_image($in_title, $in_link, $in_desc, $in_url) {
$this->image["title"] = $in_title;
$this->image["link"] = $in_link;
$this->image["desc"] = $in_desc;
$this->image["url"] = $in_url;
}
function add_item($in_title, $in_link, $in_desc) {
$this->items[$this->nitems]["title"] = $in_title;
$this->items[$this->nitems]["link"] = $in_link;
$this->items[$this->nitems]["desc"] = $in_desc;
$this->nitems++;
}
function parse($fp) {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "_rssparse_start_elem", "_rssparse_end_elem");
xml_set_character_data_handler($xml_parser, "_rssparse_elem_data");
while ($data = fread($fp, 4096)) {
if (!xml_parse($xml_parser, $data, feof($fp))) {
return 1;
}
}
xml_parser_free($xml_parser);
return 0;
}
}
function rssparse ($fp) {
global $_rss;
$_rss = new rssparser();
if ($_rss->parse($fp)) {
return 0;
}
return $_rss;
}

View File

@ -1,208 +0,0 @@
<?PHP
/**
*
* class for creating predefines select boxes
*
* @author Marc Logemann [loge@mail.com]
* @version 0.9
* $Id$
*/
class sbox {
var $monthnames = array ("", "january", "February", "March", "April", "May", "June", "July",
"August", "September", "October", "November", "December");
function hour_formated_text($name, $selected = 0)
{
global $phpgw;
$s = '<select name="' . $name . '">';
$t_s[$selected] = " selected";
for ($i=0; $i<24; $i++) {
$s .= '<option value="' . $i . '"' . $t_s[$i] . '>'
. $phpgw->common->formattime($i+1,"00") . '</option>';
$s .= "\n";
}
$s .= "</select>";
return $s;
}
function hour_text($name, $selected = 0)
{
global $phpgw;
$s = '<select name="' . $name . '">';
$t_s[$selected] = " selected";
for ($i=1; $i<13; $i++) {
$s .= '<option value="' . $i . '"' . $t_s[$i] . '>'
. $i . '</option>';
$s .= "\n";
}
$s .= "</select>";
return $s;
}
// I would like to add a increment feature
function sec_minute_text($name, $selected = 0)
{
$s = '<select name="' . $name . '">';
$t_s[$selected] = " selected";
for ($i=0; $i<60; $i++) {
$s .= '<option value="' . $i . '"' . $t_s[sprintf("%02d",$i)] . '>' . sprintf("%02d",$i) . '</option>';
$s .= "\n";
}
$s .= "</select>";
return $s;
}
function ap_text($name,$selected)
{
$selected = strtolower($selected);
$t[$selected] = " selected";
$s = '<select name="' . $name . '">'
. ' <option value="am"' . $t["am"] . '>am</option>'
. ' <option value="pm"' . $t["pm"] . '>pm</option>';
$s .= "</select>";
return $s;
}
function full_time($hour_name,$hour_selected,$min_name,$min_selected,$sec_name,$sec_selected,$ap_name,$ap_selected)
{
// This needs to be changed to support there time format preferences
$s = $this->hour_text($hour_name,$hour_selected)
. $this->sec_minute_text($min_name,$min_selected)
. $this->sec_minute_text($sec_name,$sec_selected)
. $this->ap_text($ap_name,$ap_selected);
return $s;
}
function getMonthText($name, $selected=0)
{
$out = "<select name=\"$name\">\n";
for($i=0;$i<count($this->monthnames);$i++)
{
$out .= "<option value=\"$i\"";
if($selected==$i) $out .= " SELECTED";
$out .= ">";
if($this->monthnames[$i]!="")
$out .= lang($this->monthnames[$i]);
else
$out .= "";
$out .= "</option>\n";
}
$out .= "</select>\n";
return $out;
}
function getDays($name, $selected=0)
{
$out = "<select name=\"$name\">\n";
for($i=0;$i<32;$i++)
{
if($i==0) $val = ""; else $val = $i;
$out .= "<option value=\"$val\"";
if($selected==$i) $out .= " SELECTED";
$out .= ">$val</option>\n";
}
$out .= "</select>\n";
return $out;
}
function getYears($name, $selected=0, $startYear=0)
{
if(!$startYear) $startYear = date("Y");
$out = "<select name=\"$name\">\n";
$out .= "<option value=\"\"";
if($selected == 0 OR $selected == "") $out .= " SELECTED";
$out .= "></option>\n";
for($i=$startYear - 1;$i<$startYear + 5;$i++)
{
$out .= "<option value=\"$i\"";
if($selected==$i) $out .= " SELECTED";
$out .= ">$i</option>\n";
}
$out .= "</select>\n";
return $out;
}
function getPercentage($name, $selected=0)
{
$out = "<select name=\"$name\">\n";
for($i=0;$i<101;$i=$i+10)
{
$out .= "<option value=\"$i\"";
if($selected==$i) $out .= " SELECTED";
$out .= ">$i%</option>\n";
}
$out .= "</select>\n";
// echo $out;
return $out;
}
function getPriority($name, $selected=2)
{
$arr = array("", "low", "normal", "high");
$out = "<select name=\"$name\">\n";
for($i=1;$i<count($arr);$i++)
{
$out .= "<option value=\"";
$out .= $i;
$out .= "\"";
if($selected==$i) $out .= " SELECTED";
$out .= ">";
$out .= lang($arr[$i]);
$out .= "</option>\n";
}
$out .= "</select>\n";
return $out;
}
function getAccessList($name, $selected="private")
{
$arr = array("private" => "Private",
"public" => "Global public",
"group" => "Group public");
if (ereg(",", $selected))
{
$selected = "group";
}
$out = "<select name=\"$name\">\n";
for(reset($arr);current($arr);next($arr))
{
$out .= '<option value="' . key($arr) . '"';
if($selected==key($arr)) $out .= " SELECTED";
$out .= ">" . pos($arr) . "</option>\n";
}
$out .= "</select>\n";
return $out;
}
function getGroups($groups, $selected="", $name="")
{
global $phpgw;
if(!$name) $name = "n_groups[]";
$out = '<select name="' . $name . '" multiple>';
while (list($null,$group) = each($groups)) {
$out .= '<option value="' . $group[0] . '"';
if (ereg("," . $group[0] . ",", $selected))
{
$out .= " SELECTED";
}
$out .= ">" . $group[1] . "</option>\n";
}
$out .= "</select>\n";
return $out;
}
}

View File

@ -1,351 +0,0 @@
<?php
/**************************************************************************\
* phpGroupWare *
* http://www.phpgroupware.org *
* This file written by Dan Kuykendall <seek3r@phpgroupware.org> *
* -------------------------------------------- *
* This program is free software; you can redistribute it and/or modify it *
* under the terms of the GNU General Public License as published by the *
* Free Software Foundation; either version 2 of the License, or (at your *
* option) any later version. *
\**************************************************************************/
/* $Id$ */
class vfs
{
var $basedir;
function sanitize($string) {
global $phpgw, $phpgw_info;
$sep = $phpgw_info["server"]["dir_separator"];
return(ereg_replace( "^\.+", "",str_replace($sep, "",strrchr($string,$sep))));
}
function securitycheck($string) {
if(substr($string,0,1) == "." || substr($string,0,1) == "\\" || strstr($string, "..") || strstr($string, "\\..") || strstr($string, ".\\.")) {
return False;
}else{
return True;
}
}
function rawname2array($string) {
global $phpgw, $phpgw_info;
$sep = $phpgw_info["server"]["dir_separator"];
if(substr($string,0,1) == $sep) {
// we have a starting slash...
$sub = substr($string,1); // take everything past the first slash...
$basedir = substr($sub,0,strpos($sub,$sep)); // ...to the second slash
if (!$basedir){
$basedir = substr($sub,strpos($sub,$sep)); // it becomes the basedir
}else{
$file = substr($sub,strpos($sub,$sep)); // take everything after the second slash.
}
} else {
// we have no starting slash...
$basedir = $phpgw->common->appsession();
$file = $string;
}
// security check (might want to spin this into it's own function...)
if(substr($file,0,1) == "." || substr($file,0,1) == "\\" || strstr($file, "..") || strstr($file, "\\..") || strstr($file, ".\\.")) {
return False;
}
return(array( "basedir" => $basedir, "file" => $file));
}
function getabsolutepath($target = False) {
global $phpgw, $phpgw_info;
$sep = $phpgw_info["server"]["dir_separator"];
$basedir = $phpgw_info["server"]["files_dir"].$sep."groups";
$currentdir = $phpgw->common->appsession();
if(!$this->securitycheck($target)) {
return False;
} else {
$dir_array = explode($sep,$target);
$dir_count = count($dir_array);
if (substr ($target, 0, 1) != $sep){
if (!empty($currentdir)){
$basedir .= $currentdir;
}
}
for ($diridx=0;$diridx<$dir_count;++$diridx) {
if (!empty($dir_array[$diridx])){
$basedir .= $sep.$dir_array[$diridx];
}
}
return $basedir = ereg_replace ($phpgw_info["server"]["files_dir"].$sep."groups".$sep."home", $phpgw_info["server"]["files_dir"].$sep."users".$sep.$phpgw_info["user"]["userid"], $basedir);
}
}
function ls($target = False, $checksubdirs = "No") {
global $phpgw, $phpgw_info;
$sep = $phpgw_info["server"]["dir_separator"];
if(!$this->securitycheck($target)) {
return False;
} else {
$basedir = $this->getabsolutepath($target);
if ($basedir == $phpgw_info["server"]["files_dir"].$sep."groups".$sep || $target == "/"){
//if ($basedir == $phpgw_info["server"]["files_dir"].$sep."groups".$sep){
if ($checksubdirs == "Yes"){ //if its a dir, does that dir have subdirs?
$path = $phpgw_info["server"]["files_dir"].$sep."users".$sep.$phpgw_info["user"]["userid"];
$subdir = dir($path);
while($subentry=$subdir->read()) {
$subpath = $path.$sep.$subentry;
$subtype = filetype($subpath);
if ($subentry != "." && $subentry != ".." && $subtype == "dir"){
$hassubdir = True;
}
}
}
$list[] = array("name" => "home", "type" => "dir", "subdirs" => $hassubdir);
$hassubdir = False;
$groups = $phpgw->accounts->read_group_names();
if (!empty ($groups[0][1])) {
$group_count = count($groups);
for ($groupidx=0;$groupidx<$group_count;++$groupidx) {
$this->verifydir("group",$groups[$groupidx][1]);
if ($checksubdirs == "Yes"){ //if its a dir, does that dir have subdirs?
$path = $phpgw_info["server"]["files_dir"].$sep."groups".$sep.$groups[$groupidx][1];
$subdir = dir($path);
while($subentry=$subdir->read()) {
$subpath = $path.$sep.$subentry;
$subtype = filetype($subpath);
if ($subentry != "." && $subentry != ".." && $subtype == "dir"){
$hassubdir = True;
}
}
}
$list[] = array("name" => $groups[$groupidx][1], "type" => "dir", "subdirs" => $hassubdir);
$hassubdir = False;
}
}
return $list;
}elseif (is_dir($basedir)){ //if basedir is a directory, then we fill the array
$dir = dir($basedir);
while($entry=$dir->read()) {
if ($entry != "." && $entry != ".." ){ //make sure we filter out . and ..
$path = $basedir.$sep.$entry;
if (filetype($path) == "dir"){
$entrytype = "dir";
if ($checksubdirs == "Yes"){ //if its a dir, does that dir have subdirs?
$subdir = dir($path);
while($subentry=$subdir->read()) {
$subpath = "$path$sep$subentry";
$subtype = filetype($subpath);
if ($subentry != "." && $subentry != ".." && $subtype == "dir"){
$hassubdir = True;
}
}
}
$list[] = array("name" => $entry, "type" => $entrytype, "subdirs" => $hassubdir);
}
if (filetype($path) == "file"){
$entrytype = "file";
$entrysize = filesize($path);
$entrymodifiedtime = filemtime($path);
$list[] = array("name" => $entry, "type" => $entrytype, "size" => $entrysize, "modified" =>$entrymodifiedtime);
}
}
}
$dir->close();
return $list;
}elseif(is_file($basedir)){
$dir_array = explode($sep,$basedir);
unset($basedir);
$dir_count = count($dir_array);
for ($diridx=0;$diridx<($dir_count-1);++$diridx) {
if (!empty($dir_array[$diridx])){
$basedir .= $sep.$dir_array[$diridx];
}
}
if (!is_dir($basedir) && !is_file($basedir)){
return False;
}elseif (is_dir($basedir)) {
$file = $dir_array[$dir_count];
}
}
}
}
function dir($target, $checksubdirs) {
return $this->ls($target, $checksubdirs);
}
function cd ($target = "/", $targettype = "relative"){
global $phpgw, $phpgw_info;
$sep = $phpgw_info["server"]["dir_separator"];
if ($targettype == "relative"){
$basedir = $this->getabsolutepath($target);
}else{
$basedir = $target;
}
$currentdir = $phpgw->common->appsession();
if (substr ($target, 0, 1) != $sep){
if (!empty($currentdir)){
$appsession_dir = $currentdir.$sep.$target;
}
}else{
$appsession_dir = $target;
}
if (!is_dir($basedir)){
return False;
}else{
$var = chdir ($basedir);
if ($var){
$phpgw->common->appsession($appsession_dir);
return True;
}else{
return False;
}
}
}
function pwd() {
global $phpgw;
$currentdir = $phpgw->common->appsession();
if ($currentdir == ""){$currentdir = "/";}
return $currentdir;
}
function read($file) {
global $phpgw_info;
$path = $this->getabsolutepath($file);
if ($fp = fopen($path, "r")) {
$contents = fread($fp, filesize($path));
fclose($fp);
return $contents;
} else {
return False;
}
}
function write($file, $contents) {
global $phpgw_info;
$path = $this->getabsolutepath($file);
umask(000);
if ($fp = fopen($path, "w")) {
fputs($fp, $contents, strlen($contents));
fclose($fp);
return 1;
} else {
return 0;
}
}
function cp($fromfile, $tofile, $from_absolute = "") {
global $phpgw_info;
if ($from_absolute){
$frompath = $fromfile;
}else{
$frompath = $this->getabsolutepath($fromfile);
}
$topath = $this->getabsolutepath($tofile);
umask(000);
if (!copy($frompath, $topath)) {
return False;
}else{
return True;
}
}
function copy($fromfile, $tofile) {
umask(000);
return $this->cp($fromfile, $tofile);
}
function mv($fromfile, $tofile, $from_absolute = False) {
global $phpgw_info;
if ($from_absolute){
$frompath = $fromfile;
}else{
$frompath = $this->getabsolutepath($fromfile);
}
$topath = $this->getabsolutepath($tofile);
umask(000);
if (!copy($frompath, $topath)) {
return False;
}else{
if (!unlink($frompath)) {
return False;
}else{
return True;
}
}
}
function move($fromfile, $tofile, $from_absolute) {
umask(000);
return $this->mv($fromfile, $tofile, $from_absolute);
}
function rm($file) {
global $phpgw_info;
$path = $this->getabsolutepath($file);
if (!unlink($path)) {
return False;
}else{
return True;
}
}
function delete($file) {
return $this->rm($file);
}
function rmdir($dir) {
global $phpgw_info;
$path = $this->getabsolutepath($dir);
if (!rmdir($path)) {
return False;
}else{
return True;
}
}
function mkdir($dir) {
global $phpgw_info;
$path = $this->getabsolutepath($dir);
umask(000);
if (!mkdir($path, 01707)) {
return False;
}else{
return True;
}
}
function verifydir($type = "user", $account = False) {
global $phpgw_info;
if (!$account){
$path = "/home";
}else{
$path = "/".$account;
}
if (!is_dir ($this->getabsolutepath($path))) {
if (!$this->mkdir ($path)) {
$msg = "To correct this error you will need to properly set the "
. "permissions to the files/users directory.<br> "
."On *nix systems please type: chmod 707 ";
if ($type = "user"){
$msg .= $phpgw_info["server"]["files_dir"] . "/users/";
}else{
$msg .= $phpgw_info["server"]["files_dir"] . "/groups/";
}
echo $msg;
return False;
}else{
return True;
}
}else{
return True;
}
}
}

View File

@ -12,4 +12,4 @@
/* $Id$ */
$phpgw_info["server"]["versions"]["phpgwapi"] = "0.9.9";
$phpgw_info["server"]["versions"]["current_header"] = "1.9";
$phpgw_info["server"]["versions"]["current_header"] = "1.10";