00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00128 class User
00129 {
00130 var $userid = 0;
00131 var $error = '';
00132
00133 var $name = '';
00134 var $fullname = '';
00135 var $ldap_dn;
00136 var $tel;
00137 var $mail;
00138 var $desc;
00139 var $style;
00140 var $isAdmin;
00141 var $projects;
00142 var $rights;
00143 var $loginDate = 0;
00144
00145 var $mustChangePassword = false;
00146 var $groups = null;
00147
00148
00149 function User( $userid='' )
00150 {
00151 if ( is_numeric($userid) )
00152 $this->userid = $userid;
00153 }
00154
00155
00156
00157 function listAll()
00158 {
00159 global $conf;
00160 $db = db_connection();
00161
00162 $sql = new Sql( 'SELECT id,name '.
00163 ' FROM {t_user}'.
00164 ' ORDER BY name' );
00165
00166 return $db->getAssoc( $sql->query );
00167 }
00168
00169
00170
00171 function getAllUsers()
00172 {
00173 $list = array();
00174 $db = db_connection();
00175
00176 $sql = new Sql( 'SELECT * '.
00177 ' FROM {t_user}'.
00178 ' ORDER BY name' );
00179
00180 foreach( $db->getAll( $sql->query ) as $row )
00181 {
00182 $user = new User();
00183 $user->setDatabaseRow( $row );
00184
00185 $list[] = $user;
00186 }
00187
00188 return $list;
00189 }
00190
00191
00195 function setCurrent()
00196 {
00197 $this->loadProjects();
00198 $this->loginDate = time();
00199
00200 Session::setUser( $this );
00201 }
00202
00203
00210 function getGroupClause()
00211 {
00212 $groupIds = $this->getGroupIds();
00213
00214 if ( count($groupIds) > 0 )
00215 $groupclause = ' groupid='.implode(' OR groupid=',$groupIds );
00216 else
00217 $groupclause = ' 1=0 ';
00218
00219 return $groupclause;
00220 }
00221
00222
00223
00224 function hasProject( $projectid )
00225 {
00226 $db = db_connection();
00227
00228 $sql = new Sql( 'SELECT COUNT(*)'.
00229 ' FROM {t_acl}'.
00230 ' LEFT JOIN {t_object} ON {t_object}.id={t_acl}.objectid '.
00231 ' WHERE projectid={projectidid} AND '.
00232 ' ( userid={userid} OR'.
00233 ' '.$this->getGroupClause().' )' );
00234 $sql->setInt ( 'userid',$this->userid );
00235
00236 return $db->getOne( $sql->query ) > 0;
00237 }
00238
00239
00240
00246 function getReadableProjects()
00247 {
00248 $db = db_connection();
00249
00250 if ( $this->isAdmin )
00251 {
00252
00253 return Project::getAllProjects();
00254 }
00255 else
00256 {
00257 $groupClause = $this->getGroupClause();
00258 $sql = new Sql(<<<SQL
00259 SELECT DISTINCT {t_project}.id,{t_project}.name
00260 FROM {t_object}
00261 LEFT JOIN {t_acl} ON {t_object}.id = {t_acl}.objectid
00262 LEFT JOIN {t_project} ON {t_project}.id = {t_object}.projectid
00263 WHERE {t_object}.parentid IS NULL AND
00264 {t_acl}.id IS NOT NULL AND
00265 ( {t_acl}.userid={userid} OR
00266 $groupClause OR
00267 ({t_acl}.userid IS NULL AND {t_acl}.groupid IS NULL))
00268 ORDER BY {t_project}.name
00269 SQL
00270 );
00271 $sql->setInt ( 'userid',$this->userid );
00272
00273 return $db->getAssoc( $sql->query );
00274 }
00275
00276 }
00277
00278
00279
00284 function getReadableProjectIds()
00285 {
00286 return array_keys( $this->getReadableProjects() );
00287 }
00288
00289
00294 function loadProjects()
00295 {
00296 $this->projects = $this->getReadableProjects();
00297 }
00298
00299
00300
00304 function load()
00305 {
00306 global $conf;
00307 $db = db_connection();
00308
00309 $sql = new Sql( 'SELECT * FROM {t_user}'.
00310 ' WHERE id={userid}' );
00311 $sql->setInt( 'userid',$this->userid );
00312 $row = $db->getRow( $sql->query );
00313
00314 $this->setDatabaseRow( $row );
00315 }
00316
00317
00325 function loadWithName( $name )
00326 {
00327 global $conf;
00328 $db = db_connection();
00329
00330
00331 $sql = new Sql( 'SELECT id FROM {t_user}'.
00332 ' WHERE name={name}' );
00333 $sql->setString( 'name',$name );
00334 $userId = $db->getOne( $sql->query );
00335
00336
00337 $neuerUser = new User( $userId );
00338 $neuerUser->load();
00339
00340 return $neuerUser;
00341 }
00342
00343
00344
00348 function isValid()
00349 {
00350 return intval($this->userid) > 0;
00351 }
00352
00353
00354
00355
00356 function setDatabaseRow( $row )
00357 {
00358 global $conf;
00359
00360 if ( count($row) > 1 )
00361 {
00362 $this->userid = $row['id' ];
00363 $this->name = $row['name' ];
00364 $this->style = $row['style' ];
00365 $this->isAdmin = ( $row['is_admin'] == '1');
00366 $this->ldap_dn = $row['ldap_dn' ];
00367 $this->fullname = $row['fullname'];
00368 $this->tel = $row['tel' ];
00369 $this->mail = $row['mail' ];
00370 $this->desc = $row['descr' ];
00371
00372 if ( $this->fullname == '' )
00373 $this->fullname = $this->name;
00374
00375 if ( $this->style == '' )
00376 $this->style = $conf['interface']['style']['default'];
00377 }
00378 else
00379 {
00380 $this->userid = -99;
00381 $this->name = lang('UNKNOWN');
00382 $this->style = $conf['interface']['style']['default'];
00383 $this->isAdmin = false;
00384 $this->ldap_dn = '';
00385 $this->fullname = lang('UNKNOWN');
00386 $this->tel = '';
00387 $this->mail = '';
00388 $this->desc = '';
00389 }
00390
00391
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 }
00425
00426
00427
00432 function getName()
00433 {
00434 if ( empty($this->fullname))
00435 return $this->name;
00436 else
00437 return $this->fullname;
00438 }
00439
00440
00441
00448 function getUserName( $userid )
00449 {
00450 $db = db_connection();
00451
00452 $sql = new Sql( 'SELECT name FROM {t_user}'.
00453 ' WHERE id={userid}' );
00454 $sql->setInt( 'userid',$userid );
00455
00456 $name = $db->getOne( $sql->query );
00457
00458 if ( $name == '' )
00459 return lang('UNKNOWN');
00460 else return $name;
00461 }
00462
00463
00467 function save()
00468 {
00469 $db = db_connection();
00470
00471 $sql = new Sql( 'UPDATE {t_user}'.
00472 ' SET name={name},'.
00473 ' fullname={fullname},'.
00474 ' ldap_dn ={ldap_dn} ,'.
00475 ' tel ={tel} ,'.
00476 ' descr ={desc} ,'.
00477 ' mail ={mail} ,'.
00478 ' style ={style} ,'.
00479 ' is_admin={isAdmin} '.
00480 ' WHERE id={userid}' );
00481 $sql->setInt ( 'userid' ,$this->userid );
00482 $sql->setString ( 'fullname',$this->fullname);
00483 $sql->setString ( 'name' ,$this->name );
00484 $sql->setString ( 'ldap_dn' ,$this->ldap_dn );
00485 $sql->setString ( 'tel' ,$this->tel );
00486 $sql->setString ( 'desc' ,$this->desc );
00487 $sql->setString ( 'mail' ,$this->mail );
00488 $sql->setString ( 'style' ,$this->style );
00489 $sql->setBoolean( 'isAdmin' ,$this->isAdmin );
00490
00491
00492 $db->query( $sql->query );
00493 }
00494
00495
00501 function add( $name = '' )
00502 {
00503 if ( $name != '' )
00504 $this->name = $name;
00505
00506 $db = db_connection();
00507
00508 $sql = new Sql('SELECT MAX(id) FROM {t_user}');
00509 $this->userid = intval($db->getOne($sql->query))+1;
00510
00511 $sql = new Sql('INSERT INTO {t_user}'.
00512 ' (id,name,password,ldap_dn,fullname,tel,mail,descr,style,is_admin)'.
00513 " VALUES( {userid},{name},'','','','','','','default',0 )" );
00514 $sql->setInt ('userid',$this->userid);
00515 $sql->setString('name' ,$this->name );
00516
00517
00518 $db->query( $sql->query );
00519
00520 $this->addNewUserGroups();
00521 }
00522
00523
00524
00529 function addNewUserGroups()
00530 {
00531 global $conf;
00532 $groupNames = explode(',',@$conf['security']['newuser']['groups']);
00533
00534 if ( count($groupNames) == 0 )
00535 return;
00536
00537 $db = db_connection();
00538
00539 $sql = new Sql('SELECT id FROM {t_group} WHERE name IN({names})');
00540 $sql->setStringList('names',$groupNames);
00541 $groupIds = array_unique( $db->getCol($sql->query) );
00542
00543
00544
00545
00546
00547
00548 foreach( $groupIds as $groupId )
00549 $this->addGroup( $groupId );
00550 }
00551
00552
00563 function delete()
00564 {
00565 $db = db_connection();
00566
00567
00568 $sql = new Sql( 'UPDATE {t_object} '.
00569 'SET create_userid=null '.
00570 'WHERE create_userid={userid}' );
00571 $sql->setInt ('userid',$this->userid );
00572 $db->query( $sql->query );
00573
00574
00575 $sql = new Sql( 'UPDATE {t_object} '.
00576 'SET lastchange_userid=null '.
00577 'WHERE lastchange_userid={userid}' );
00578 $sql->setInt ('userid',$this->userid );
00579 $db->query( $sql->query );
00580
00581
00582 $sql = new Sql( 'UPDATE {t_value} '.
00583 'SET lastchange_userid=null '.
00584 'WHERE lastchange_userid={userid}' );
00585 $sql->setInt ('userid',$this->userid );
00586 $db->query( $sql->query );
00587
00588
00589 $sql = new Sql( 'DELETE FROM {t_acl} '.
00590 'WHERE userid={userid}' );
00591 $sql->setInt ('userid',$this->userid );
00592 $db->query( $sql->query );
00593
00594
00595 $sql = new Sql( 'DELETE FROM {t_usergroup} '.
00596 'WHERE userid={userid}' );
00597 $sql->setInt ('userid',$this->userid );
00598 $db->query( $sql->query );
00599
00600
00601 $sql = new Sql( 'DELETE FROM {t_user} '.
00602 'WHERE id={userid}' );
00603 $sql->setInt ('userid',$this->userid );
00604 $db->query( $sql->query );
00605 }
00606
00607
00613 function getProperties()
00614 {
00615 return Array( 'userid' => $this->userid,
00616 'id' => $this->userid,
00617 'fullname'=> $this->fullname,
00618 'name' => $this->name,
00619 'ldap_dn' => $this->ldap_dn,
00620 'tel' => $this->tel,
00621 'desc' => $this->desc,
00622 'mail' => $this->mail,
00623 'style' => $this->style,
00624 'is_admin'=> $this->isAdmin,
00625 'isAdmin' => $this->isAdmin );
00626 }
00627
00628
00637 function checkPassword( $password )
00638 {
00639 global $conf;
00640
00641 $db = db_connection();
00642 $this->mustChangePassword = false;
00643
00644
00645 $sql = new Sql( <<<SQL
00646 SELECT * FROM {t_user}
00647 WHERE name={name}
00648 SQL
00649 );
00650 $sql->setString('name',$this->name);
00651
00652 $res_user = $db->query( $sql->query );
00653
00654 $check = false;
00655 $authType = $conf['security']['auth']['type'];
00656
00657 if ( $res_user->numRows() == 1 )
00658 {
00659
00660 $row_user = $res_user->fetchRow();
00661 $this->userid = $row_user['id'];
00662 $this->ldap_dn = $row_user['ldap_dn'];
00663 $check = true;
00664 $autoAdd = false;
00665 }
00666 elseif( $res_user->numRows() == 0 && $authType == 'ldap' && $conf['ldap']['search']['add'] )
00667 {
00668
00669
00670 $check = true;
00671 $autoAdd = true;
00672 }
00673 elseif( $res_user->numRows() == 0 && $authType == 'authdb' && $conf['security']['authdb']['add'] )
00674 {
00675 $check = true;
00676 $autoAdd = true;
00677 }
00678 elseif( $res_user->numRows() == 0 && $authType == 'http' && $conf['security']['http']['add'] )
00679 {
00680 $check = true;
00681 $autoAdd = true;
00682 }
00683
00684 if ( $check )
00685 {
00686
00687 if ( $conf['security']['auth']['userdn'] && !empty($this->ldap_dn ) )
00688 {
00689 Logger::debug( 'checking login via ldap' );
00690 $ldap = new Ldap();
00691 $ldap->connect();
00692
00693
00694
00695 $ok = $ldap->bind( $this->ldap_dn, $password );
00696
00697
00698 $ldap->close();
00699
00700 return $ok;
00701 }
00702 elseif( $authType == 'ldap' )
00703 {
00704 Logger::debug( 'checking login via ldap' );
00705 $ldap = new Ldap();
00706 $ldap->connect();
00707
00708 if ( empty($conf['ldap']['dn']) )
00709 {
00710
00711
00712 $dn = $ldap->searchUser( $this->name );
00713
00714 if ( empty($dn) )
00715 {
00716 Logger::debug( 'User not found in LDAP directory' );
00717 return false;
00718 }
00719
00720 Logger::debug( 'User found: '.$dn );
00721 }
00722 else
00723 {
00724 $dn = str_replace( '{user}',$this->name,$conf['ldap']['dn'] );
00725 }
00726
00727
00728 $ok = $ldap->bind( $dn, $password );
00729
00730 Logger::debug( 'LDAP bind: '.($ok?'success':'failed') );
00731
00732 if ( $ok && $conf['security']['authorize']['type'] == 'ldap' )
00733 {
00734 $sucheAttribut = $conf['ldap']['authorize']['group_name'];
00735 $sucheFilter = str_replace('{dn}',$dn,$conf['ldap']['authorize']['group_filter']);
00736
00737 $ldap_groups = $ldap->searchAttribute( $sucheFilter, $sucheAttribut );
00738
00739 $sql = new Sql( <<<SQL
00740 SELECT id,name FROM {t_group}
00741 WHERE name IN({name_list})
00742 ORDER BY name ASC
00743 SQL
00744 );
00745 $sql->setStringList('name_list',$ldap_groups);
00746 $oldGroups = $this->getGroupIds();
00747 $this->groups = $db->getAssoc( $sql->query );
00748
00749 foreach( $this->groups as $groupid=>$groupname)
00750 {
00751 if ( ! in_array($groupid,$oldGroups))
00752 $this->addGroup($groupid);
00753 }
00754 foreach( $oldGroups as $groupid)
00755 {
00756 if ( !isset($this->groups[$groupid]) )
00757 $this->delGroup($groupid);
00758 }
00759
00760
00761
00762 if ( $conf['ldap']['authorize']['auto_add'] )
00763 {
00764 foreach( $ldap_groups as $group )
00765 {
00766 if ( !in_array($group,$this->groups) )
00767 {
00768 $g = new Group();
00769 $g->name = $group;
00770 $g->add();
00771
00772 $this->groups[$g->groupid] = $group;
00773 }
00774 }
00775 }
00776
00777 }
00778
00779
00780 $ldap->close();
00781
00782 if ( $ok && $autoAdd )
00783 {
00784
00785
00786 $this->ldap_dn = $dn;
00787 $this->fullname = $this->name;
00788 $this->add();
00789 $this->save();
00790 }
00791
00792 return $ok;
00793 }
00794 elseif( $authType == 'database' )
00795 {
00796
00797 if ( $row_user['password'] == $password )
00798 {
00799
00800
00801 $this->mustChangePassword = true;
00802
00803
00804 return false;
00805 }
00806 elseif ( $row_user['password'] == md5( $password ) )
00807 {
00808
00809
00810 return true;
00811 }
00812 else
00813 {
00814
00815 return false;
00816 }
00817 }
00818 elseif( $authType == 'authdb' )
00819 {
00820 $authdb = new DB( $conf['security']['authdb'] );
00821 $sql = new Sql( $conf['security']['authdb']['sql'] );
00822 $sql->setString('username',$this->name);
00823 $sql->setString('password',$password);
00824 $res = $authdb->query($sql->query);
00825 $ok = ($res->numRows() >= 1);
00826
00827 if ( $ok && $autoAdd )
00828 {
00829
00830
00831 $this->fullname = $this->name;
00832 $this->add();
00833 $this->save();
00834 }
00835
00836
00837 return $ok;
00838 }
00839 elseif( $authType == 'http' )
00840 {
00841 $http = new Http( $conf['security']['http']['url'] );
00842 $http->method = 'HEAD';
00843 $http->setBasicAuthentication( $this->name, $password );
00844
00845 $ok = $http->request();
00846
00847 return $ok;
00848 }
00849 else
00850 {
00851 die( 'unknown authentication-type in configuration: '.$authType );
00852 }
00853 }
00854
00855
00856 return false;
00857 }
00858
00859
00866 function setPassword( $password, $always=true )
00867 {
00868 $db = db_connection();
00869
00870 $sql = new Sql( 'UPDATE {t_user} SET password={password}'.
00871 'WHERE id={userid}' );
00872
00873 if ( $always )
00874 $sql->setString('password',md5($password) );
00875 else
00876 $sql->setString('password',$password );
00877
00878 $sql->setInt ('userid' ,$this->userid );
00879
00880 $db->query( $sql->query );
00881 }
00882
00883
00889 function getGroups()
00890 {
00891 if ( !is_array($this->groups) )
00892 {
00893 $db = db_connection();
00894
00895 $sql = new Sql( 'SELECT {t_group}.id,{t_group}.name FROM {t_group} '.
00896 'LEFT JOIN {t_usergroup} ON {t_usergroup}.groupid={t_group}.id '.
00897 'WHERE {t_usergroup}.userid={userid}' );
00898 $sql->setInt('userid',$this->userid );
00899 $this->groups = $db->getAssoc( $sql->query );
00900 }
00901
00902 return $this->groups;
00903 }
00904
00905
00906
00907 function getGroupIds()
00908 {
00909 return array_keys( $this->getGroups() );
00910
00911
00912
00913
00914
00915
00916
00917
00918
00919
00920 }
00921
00922
00923
00924 function getOtherGroups()
00925 {
00926 $db = db_connection();
00927
00928 $sql = new Sql( 'SELECT {t_group}.id,{t_group}.name FROM {t_group}'.
00929 ' LEFT JOIN {t_usergroup} ON {t_usergroup}.groupid={t_group}.id AND {t_usergroup}.userid={userid}'.
00930 ' WHERE {t_usergroup}.userid IS NULL' );
00931 $sql->setInt('userid' ,$this->userid );
00932
00933 return $db->getAssoc( $sql->query );
00934 }
00935
00936
00937
00938 function addGroup( $groupid )
00939 {
00940 $db = db_connection();
00941
00942 $sql = new Sql('SELECT MAX(id) FROM {t_usergroup}');
00943 $usergroupid = intval($db->getOne($sql->query))+1;
00944
00945 $sql = new Sql( 'INSERT INTO {t_usergroup} '.
00946 ' (id,userid,groupid) '.
00947 ' VALUES( {usergroupid},{userid},{groupid} )' );
00948 $sql->setInt('usergroupid',$usergroupid );
00949 $sql->setInt('userid' ,$this->userid );
00950 $sql->setInt('groupid' ,$groupid );
00951
00952 $db->query( $sql->query );
00953
00954 }
00955
00956
00957
00958 function delGroup( $groupid )
00959 {
00960 $db = db_connection();
00961
00962 $sql = new Sql( 'DELETE FROM {t_usergroup} '.
00963 ' WHERE userid={userid} AND groupid={groupid}' );
00964 $sql->setInt ('userid' ,$this->userid );
00965 $sql->setInt ('groupid' ,$groupid );
00966
00967 $db->query( $sql->query );
00968 }
00969
00970
00977 function loadRights( $projectid,$languageid )
00978 {
00979 }
00980
00981
00988 function getAllAcls()
00989 {
00990
00991 $this->delRights();
00992
00993 $db = db_connection();
00994
00995 $group_clause = $this->getGroupClause();
00996
00997 $sql = new Sql( 'SELECT {t_acl}.*,{t_object}.projectid,{t_language}.name AS languagename FROM {t_acl}'.
00998 ' LEFT JOIN {t_object} '.
00999 ' ON {t_object}.id={t_acl}.objectid '.
01000 ' LEFT JOIN {t_language} '.
01001 ' ON {t_language}.id={t_acl}.languageid '.
01002 ' WHERE ( {t_acl}.userid={userid} OR '.$group_clause.
01003 ' OR ({t_acl}.userid IS NULL AND {t_acl}.groupid IS NULL) )'.
01004 ' ORDER BY {t_object}.projectid,{t_acl}.languageid' );
01005 $sql->setInt ( 'userid' ,$this->userid );
01006
01007 $aclList = array();
01008
01009 foreach( $db->getAll( $sql->query ) as $row )
01010 {
01011 $acl = new Acl();
01012 $acl->setDatabaseRow( $row );
01013 $acl->projectid = $row['projectid' ];
01014 if ( intval($acl->languageid) == 0 )
01015 $acl->languagename = lang('GLOBAL_ALL_LANGUAGES');
01016 else
01017 $acl->languagename = $row['languagename'];
01018 $aclList[] = $acl;
01019 }
01020
01021 return $aclList;
01022 }
01023
01024
01029 function getRights()
01030 {
01031 die('User.class::getRights()');
01032
01033
01034
01035
01036
01037
01038
01039
01040
01041
01042
01043
01044
01045
01046
01047
01048
01049
01050
01051
01052
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084 }
01085
01086
01090 function delRights()
01091 {
01092 $this->rights = array();
01093 }
01094
01095
01102 function hasRight( $objectid,$type )
01103 {
01104 global $conf;
01105 if ( $this->isAdmin && !$conf['security']['readonly'] )
01106 return true;
01107
01108 if ( $this->isAdmin && $type & ACL_READ )
01109 return true;
01110
01111 if ( !isset($this->rights[$objectid]) )
01112 return false;
01113
01114 return $this->rights[$objectid] & $type;
01115 }
01116
01117
01124 function addRight( $objectid,$type )
01125 {
01126 global $conf;
01127
01128 if ( $conf['security']['readonly'] )
01129 if ( $type & ACL_READ )
01130 $type = ACL_READ;
01131 else
01132 $type = 0;
01133
01134 if ( $type & ACL_PUBLISH && $conf['security']['nopublish'] )
01135 $type -= ACL_PUBLISH;
01136
01137
01138 if ( !isset($this->rights[$objectid]) )
01139 $this->rights[$objectid] = 0;
01140
01141 $this->rights[$objectid] = $this->rights[$objectid] | $type;
01142 }
01143
01144
01148 function getAvailableStyles()
01149 {
01150 global $conf_themedir;
01151
01152 $allstyles = array();
01153
01154
01155 $dir = $conf_themedir.'/css';
01156 $handle = @opendir( $dir );
01157
01158 if ( !is_resource($handle) )
01159 Http::serverError('Cannot open CSS dir: '.$dir);
01160
01161 while ($file = readdir ($handle))
01162 {
01163 if ( eregi('\.css$',$file) )
01164 {
01165 $file = eregi_replace('\.css$','',$file);
01166 $allstyles[$file] = ucwords($file);
01167 }
01168 }
01169 closedir($handle);
01170
01171 asort($allstyles);
01172 return $allstyles;
01173 }
01174
01175
01183 function createPassword()
01184 {
01185 global $conf;
01186
01187 $pw = '';
01188 $c = 'bcdfghjklmnprstvwz';
01189 $v = 'aeiou';
01190 $a = $c.$v;
01191
01192
01193 for ( $i=0; $i < intval($conf['security']['password']['min_length'])/3; $i++ )
01194 {
01195 $pw .= $c[rand(0, strlen($c)-1)];
01196 $pw .= $v[rand(0, strlen($v)-1)];
01197 $pw .= $a[rand(0, strlen($a)-1)];
01198 }
01199
01200 $pw .= rand(10,99);
01201
01202 return $pw;
01203 }
01204 }
01205
01206 ?>