Reformat almost all functions, except for two, which use unbracketed

if statements and are very confusing to me... if this breaks anyone, please
rollback cvs!
This commit is contained in:
Miles Lott 2001-06-13 21:10:36 +00:00
parent c73aeb5c62
commit c7926c1366

View File

@ -28,10 +28,12 @@
$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') {
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);
}
unset($d1);unset($d2);unset($d3);
/*!
@class common
@ -96,7 +98,6 @@
return $s;
}
// This is used for searching the access fields
/*!
@function sql_search
@ -197,27 +198,31 @@
{
global $phpgw_info;
if (! $host) {
if (! $host)
{
$host = $phpgw_info['server']['ldap_host'];
}
if (! $dn) {
if (! $dn)
{
$dn = $phpgw_info['server']['ldap_root_dn'];
}
if (! $passwd) {
if (! $passwd)
{
$passwd = $phpgw_info['server']['ldap_root_pw'];
}
// connect to ldap server
if (! $ds = ldap_connect($host)) {
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)) {
if (! ldap_bind($ds,$dn,$passwd))
{
printf("<b>Error: Can't bind to LDAP server: %s!</b><br>",$dn);
return False;
}
@ -238,7 +243,8 @@
{
global $phpgw;
if ($call_footer) {
if ($call_footer)
{
$this->phpgw_footer();
}
$phpgw->db->disconnect();
@ -258,7 +264,8 @@
'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++) {
for ($i=0; $i<$size; $i++)
{
$s .= $random_char[rand(1,61)];
}
return $s;
@ -388,6 +395,7 @@
return $phpgw->common->display_fullname($db->f('account_lid'),$db->f('account_firstname'),$db->f('account_lastname'));
}
/*!
@function create_tabs
@abstract create tabs
@ -401,45 +409,66 @@
$output_text = '<table border="0" cellspacing="0" cellpadding="0"><tr>';
$ir = $phpgw_info['server']['images_dir'];
if ($fontsize) {
if ($fontsize)
{
$fs = '<font size="' . $fontsize . '">';
$fse = '</font>';
}
$i = 1;
while ($tab = each($tabs)) {
if ($tab[0] == $selected) {
if ($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)) {
if ($i == count($tabs))
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end1.gif"></td>';
} else {
}
else
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepr.gif"></td>';
}
} else {
if ($i == 1) {
}
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) {
if (($i + 1) == $selected)
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepl.gif"></td>';
} else if ($i == $selected || $i != count($tabs)) {
}
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) {
}
else if ($i == count($tabs))
{
if ($i == $selected)
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end1.gif"></td>';
} else {
}
else
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-end0.gif"></td>';
}
} else {
if ($i != count($tabs)) {
}
else
{
if ($i != count($tabs))
{
$output_text .= '<td align="left"><img src="' . $ir . '/tabs-sepr.gif"></td>';
}
}
@ -456,26 +485,35 @@
@discussion $appname can either be passed or derived from $phpgw_info['flags']['currentapp'];
@param $appname name of application
*/
function get_app_dir($appname = ''){
function get_app_dir($appname = '')
{
global $phpgw_info;
if ($appname == '') {
if ($appname == '')
{
$appname = $phpgw_info['flags']['currentapp'];
}
if ($appname == 'home' || $appname == 'logout' || $appname == 'login') {
if ($appname == 'home' || $appname == 'logout' || $appname == 'login')
{
$appname = 'phpgwapi';
}
$appdir = PHPGW_INCLUDE_ROOT . '/'.$appname;
$appdir_default = PHPGW_SERVER_ROOT . '/'.$appname;
if (is_dir ($appdir)){
if (is_dir ($appdir))
{
return $appdir;
}elseif (is_dir ($appdir_default)){
}
elseif (is_dir ($appdir_default))
{
return $appdir_default;
}else{
}
else
{
return False;
}
}
/*!
@function get_inc_dir
@abstract get inc (include dir) of application
@ -486,24 +524,32 @@
{
global $phpgw_info;
if (! $appname){
if (! $appname)
{
$appname = $phpgw_info['flags']['currentapp'];
}
if ($appname == 'home' || $appname == 'logout' || $appname == 'login') {
if ($appname == 'home' || $appname == 'logout' || $appname == 'login')
{
$appname = 'phpgwapi';
}
$incdir = PHPGW_INCLUDE_ROOT . '/' . $appname . '/inc';
$incdir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/inc';
if (is_dir ($incdir)) {
if (is_dir ($incdir))
{
return $incdir;
} elseif (is_dir ($incdir_default)) {
}
elseif (is_dir ($incdir_default))
{
return $incdir_default;
} else {
}
else
{
return False;
}
}
/*!
@function list_themes
@abstract list themes available
@ -511,8 +557,10 @@
function list_themes()
{
$dh = opendir(PHPGW_SERVER_ROOT . '/phpgwapi/themes');
while ($file = readdir($dh)) {
if (eregi("\.theme$", $file)) {
while ($file = readdir($dh))
{
if (eregi("\.theme$", $file))
{
$list[] = substr($file,0,strpos($file,'.'));
}
}
@ -520,21 +568,28 @@
reset ($list);
return $list;
}
/*!
@function list_templates
@abstract list available templates
*/
function list_templates(){
function list_templates()
{
global $phpgw_info;
$d = dir(PHPGW_SERVER_ROOT . '/phpgwapi/templates');
while ($entry=$d->read()) {
if ($entry != 'CVS' && $entry != '.' && $entry != '..'){
while ($entry=$d->read())
{
if ($entry != 'CVS' && $entry != '.' && $entry != '..')
{
$list[$entry]['name'] = $entry;
$f = PHPGW_SERVER_ROOT . '/phpgwapi/templates/' . $entry . '/details.inc.php';
if (file_exists ($f)){
if (file_exists ($f))
{
include($f);
$list[$entry]['title'] = 'Use '.$phpgw_info['template'][$entry]['title'].'interface';
} else {
}
else
{
$list[$entry]['title'] = $entry;
}
}
@ -543,6 +598,7 @@
reset ($list);
return $list;
}
/*!
@function get_tpl_dir
@abstract get template dir of an application
@ -551,21 +607,29 @@
function get_tpl_dir($appname = '')
{
global $phpgw_info;
if (! $appname) {
if (! $appname)
{
$appname = $phpgw_info['flags']['currentapp'];
}
if ($appname == 'home' || $appname == 'logout' || $appname == 'login') {
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') {
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'])) {
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'])) {
}
elseif ($phpgw_info['server']['template_set'] == 'user_choice' ||
!isset($phpgw_info['server']['template_set']))
{
$phpgw_info['server']['template_set'] = 'default';
}
@ -573,25 +637,34 @@
. $phpgw_info['server']['template_set'];
$tpldir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default';
if (is_dir($tpldir)) {
if (is_dir($tpldir))
{
return $tpldir;
} elseif (is_dir($tpldir_default)) {
}
elseif (is_dir($tpldir_default))
{
return $tpldir_default;
} else {
}
else
{
return False;
}
}
/*!
@function get_image_dir
@abstract get image dir of an application
@param $appname application name optional can be derived from $phpgw_info['flags']['currentapp'];
*/
function get_image_dir($appname = ''){
function get_image_dir($appname = '')
{
global $phpgw_info;
if ($appname == '') {
if ($appname == '')
{
$appname = $phpgw_info['flags']['currentapp'];
}
if (empty($phpgw_info['server']['template_set'])) {
if (empty($phpgw_info['server']['template_set']))
{
$phpgw_info['server']['template_set'] = 'default';
}
@ -600,16 +673,24 @@
$imagedir_default = PHPGW_SERVER_ROOT . '/' . $appname . '/templates/default/images';
$imagedir_olddefault = PHPGW_SERVER_ROOT . '/' . $appname . '/images';
if (is_dir ($imagedir)){
if (is_dir ($imagedir))
{
return $imagedir;
} elseif (is_dir ($imagedir_default)) {
}
elseif (is_dir ($imagedir_default))
{
return $imagedir_default;
} elseif (is_dir ($imagedir_olddefault)) {
}
elseif (is_dir ($imagedir_olddefault))
{
return $imagedir_olddefault;
} else {
}
else
{
return False;
}
}
/*!
@function get_image_path
@abstract get image path of an application
@ -878,13 +959,13 @@
*/
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
$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);
$ldappassword = sprintf('%s%s', $lcrypt, $password);
return $ldappassword;
}
@ -898,12 +979,14 @@
{
global $phpgw, $phpgw_info;
if ($phpgw_info['server']['ldap_encryption_type'] == 'DES') {
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);
if ($phpgw_info['server']['ldap_encryption_type'] == 'MD5')
{
//$salt = $this->randomstring(9);
$salt = $this->randomstring(8); // patch
$e_password = $this->md5_cryptpasswd($password, $salt);
}
@ -911,7 +994,7 @@
}
/*!
@function hook
@abstract hooking function which allows applications to "hook" into each other
@abstract hooking function which allows applications to 'hook' into each other
@discussion Someone flesh this out please
*/
function hook($location, $order = '')
@ -1023,15 +1106,21 @@
global $phpgw_info;
if (! $t)
{
$t = time();
}
$t = $t + ((60*60) * $phpgw_info['user']['preferences']['common']['tz_offset']);
if (! $format) {
if (! $format)
{
$format = $phpgw_info['user']['preferences']['common']['dateformat'] . ' - ';
if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12') {
if ($phpgw_info['user']['preferences']['common']['timeformat'] == '12')
{
$format .= 'h:i:s a';
} else {
}
else
{
$format .= 'H:i:s';
}
}
@ -1056,9 +1145,12 @@
$dlarr[strpos($dateformat,'d')] = $daystr;
ksort($dlarr);
if ($add_seperator) {
if ($add_seperator)
{
return (implode($sep,$dlarr));
} else {
}
else
{
return (implode(' ',$dlarr));
}
}
@ -1254,18 +1346,18 @@
. '<br>' . lang('On *nix systems please type: x','chmod 770 '
. $phpgw_info['server']['files_dir'] . '/groups/');
break;
case 40: $s .= lang("You have not entered a title").'.';
case 40: $s .= lang('You have not entered a title').'.';
break;
case 41: $s .= lang("You have not entered a valid time of day").'.';
case 41: $s .= lang('You have not entered a valid time of day').'.';
break;
case 42: $s .= lang("You have not entered a valid date").'.';
case 42: $s .= lang('You have not entered a valid date').'.';
break;
default: return '';
}
return $s;
}
/*!
@fucntion phpgw_error
@function phpgw_error
@abstract process error message
@param $error error
@param $line line
@ -1274,10 +1366,12 @@
function phpgw_error($error,$line = '', $file = '')
{
echo '<p><b>phpGroupWare internal error:</b><p>'.$error;
if ($line) {
if ($line)
{
echo 'Line: '.$line;
}
if ($file) {
if ($file)
{
echo 'File: '.$file;
}
echo '<p>Your session has been halted.';
@ -1291,27 +1385,40 @@
*/
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)) {
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 {
}
else
{
$s .= '$phpgw_info["' . $key . '"]["' . $key2 . '"]["' . $key3 . '"]="' . $val3 . '";';
$s .= "\n";
}
}
} else {
}
else
{
$s .= '$phpgw_info["' . $key .'"]["' . $key2 . '"]="' . $val2 . '";';
$s .= "\n";
}
}
} else {
}
else
{
$s .= '$phpgw_info["' . $key . '"]="' . $val . '";';
$s .= "\n";
}
@ -1319,7 +1426,6 @@
return $s;
}
// This will return the full phpgw_info array, used for debugging
/*!
@function debug_list_array_contents
@ -1328,24 +1434,37 @@
*/
function debug_list_array_contents($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)) {
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))
{
echo $$array . "[$key][$key2][$key3][$key4]=$val4<br>";
}
} else {
}
else
{
echo $$array . "[$key][$key2][$key3]=$val3<br>";
}
}
} else {
}
else
{
echo $$array . "[$key][$key2]=$val2<br>";
}
}
} else {
}
else
{
echo $$array . "[$key]=$val<br>";
}
}
@ -1356,7 +1475,6 @@
@function debug_list_core_functions
@abstract return a list of functionsin the API
*/
function debug_list_core_functions()
{
echo '<br><b>core functions</b><br>';
@ -1375,24 +1493,33 @@
{
global $phpgw;
if (!$appname) {
if (!$appname)
{
return -1;
}
$phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__);
while( $phpgw->db->next_record() ) {
while( $phpgw->db->next_record() )
{
$id = $phpgw->db->f("id");
}
if (empty($id) || !$id) {
if (empty($id) || !$id)
{
$id = 1;
$phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__);
} elseif($id<$min) {
}
elseif($id<$min)
{
$id = $min;
$phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__);
} elseif ($max && ($id > $max)) {
}
elseif ($max && ($id > $max))
{
return False;
} else {
}
else
{
$id = $id + 1;
$phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__);
}
@ -1410,25 +1537,40 @@
{
global $phpgw;
if (!$appname) {
if (!$appname)
{
return -1;
}
$phpgw->db->query("SELECT id FROM phpgw_nextid WHERE appname='".$appname."'",__LINE__,__FILE__);
while( $phpgw->db->next_record() ) {
while( $phpgw->db->next_record() )
{
$id = $phpgw->db->f("id");
}
if (empty($id) || !$id) {
if($min) { $id = $min; }
else { $id = 1; }
if (empty($id) || !$id)
{
if($min)
{
$id = $min;
}
else
{
$id = 1;
}
$phpgw->db->query("INSERT INTO phpgw_nextid (appname,id) VALUES ('".$appname."',".$id.")",__LINE__,__FILE__);
} elseif($id<$min) {
}
elseif($id<$min)
{
$id = $min;
$phpgw->db->query("UPDATE phpgw_nextid SET id=".$id." WHERE appname='".$appname."'",__LINE__,__FILE__);
} elseif ($max && ($id > $max)) {
}
elseif ($max && ($id > $max))
{
return False;
} else {
}
else
{
return intval($id);
}
}