Moved files

This commit is contained in:
Deon George
2009-06-30 19:39:45 +10:00
parent df48b8ff9b
commit bbcd2cb3b6
313 changed files with 0 additions and 0 deletions

475
lib/blowfish.php Normal file
View File

@@ -0,0 +1,475 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/blowfish.php,v 1.3 2005/02/25 13:44:05 wurley Exp $
/**
* The Cipher_blowfish:: class implements the Cipher interface enryption data
* using the Blowfish algorithm.
*
* $Horde: horde/lib/Cipher/blowfish.php,v 1.2.2.3 2003/01/03 13:23:22 jan Exp $
*
* Copyright 2002-2003 Mike Cochrane <mike@graftonhall.co.nz>
*
* See the enclosed file COPYING for license information (LGPL). If you
* did not receive this file, see http://www.fsf.org/copyleft/lgpl.html.
*
* @author Mike Cochrane <mike@graftonhall.co.nz>
* @version $Revision: 1.3 $
* @since Horde 2.2
* @package horde.cipher
*/
/**
* @package horde.cipher
*/
// Change for phpMyAdmin by lem9:
//class Horde_Cipher_blowfish extends Horde_Cipher {
class Horde_Cipher_blowfish {
/* Pi Array */
var $p = array(
0x243F6A88, 0x85A308D3, 0x13198A2E, 0x03707344,
0xA4093822, 0x299F31D0, 0x082EFA98, 0xEC4E6C89,
0x452821E6, 0x38D01377, 0xBE5466CF, 0x34E90C6C,
0xC0AC29B7, 0xC97C50DD, 0x3F84D5B5, 0xB5470917,
0x9216D5D9, 0x8979FB1B);
/* S Boxes */
var $s1 = array(
0xD1310BA6, 0x98DFB5AC, 0x2FFD72DB, 0xD01ADFB7,
0xB8E1AFED, 0x6A267E96, 0xBA7C9045, 0xF12C7F99,
0x24A19947, 0xB3916CF7, 0x0801F2E2, 0x858EFC16,
0x636920D8, 0x71574E69, 0xA458FEA3, 0xF4933D7E,
0x0D95748F, 0x728EB658, 0x718BCD58, 0x82154AEE,
0x7B54A41D, 0xC25A59B5, 0x9C30D539, 0x2AF26013,
0xC5D1B023, 0x286085F0, 0xCA417918, 0xB8DB38EF,
0x8E79DCB0, 0x603A180E, 0x6C9E0E8B, 0xB01E8A3E,
0xD71577C1, 0xBD314B27, 0x78AF2FDA, 0x55605C60,
0xE65525F3, 0xAA55AB94, 0x57489862, 0x63E81440,
0x55CA396A, 0x2AAB10B6, 0xB4CC5C34, 0x1141E8CE,
0xA15486AF, 0x7C72E993, 0xB3EE1411, 0x636FBC2A,
0x2BA9C55D, 0x741831F6, 0xCE5C3E16, 0x9B87931E,
0xAFD6BA33, 0x6C24CF5C, 0x7A325381, 0x28958677,
0x3B8F4898, 0x6B4BB9AF, 0xC4BFE81B, 0x66282193,
0x61D809CC, 0xFB21A991, 0x487CAC60, 0x5DEC8032,
0xEF845D5D, 0xE98575B1, 0xDC262302, 0xEB651B88,
0x23893E81, 0xD396ACC5, 0x0F6D6FF3, 0x83F44239,
0x2E0B4482, 0xA4842004, 0x69C8F04A, 0x9E1F9B5E,
0x21C66842, 0xF6E96C9A, 0x670C9C61, 0xABD388F0,
0x6A51A0D2, 0xD8542F68, 0x960FA728, 0xAB5133A3,
0x6EEF0B6C, 0x137A3BE4, 0xBA3BF050, 0x7EFB2A98,
0xA1F1651D, 0x39AF0176, 0x66CA593E, 0x82430E88,
0x8CEE8619, 0x456F9FB4, 0x7D84A5C3, 0x3B8B5EBE,
0xE06F75D8, 0x85C12073, 0x401A449F, 0x56C16AA6,
0x4ED3AA62, 0x363F7706, 0x1BFEDF72, 0x429B023D,
0x37D0D724, 0xD00A1248, 0xDB0FEAD3, 0x49F1C09B,
0x075372C9, 0x80991B7B, 0x25D479D8, 0xF6E8DEF7,
0xE3FE501A, 0xB6794C3B, 0x976CE0BD, 0x04C006BA,
0xC1A94FB6, 0x409F60C4, 0x5E5C9EC2, 0x196A2463,
0x68FB6FAF, 0x3E6C53B5, 0x1339B2EB, 0x3B52EC6F,
0x6DFC511F, 0x9B30952C, 0xCC814544, 0xAF5EBD09,
0xBEE3D004, 0xDE334AFD, 0x660F2807, 0x192E4BB3,
0xC0CBA857, 0x45C8740F, 0xD20B5F39, 0xB9D3FBDB,
0x5579C0BD, 0x1A60320A, 0xD6A100C6, 0x402C7279,
0x679F25FE, 0xFB1FA3CC, 0x8EA5E9F8, 0xDB3222F8,
0x3C7516DF, 0xFD616B15, 0x2F501EC8, 0xAD0552AB,
0x323DB5FA, 0xFD238760, 0x53317B48, 0x3E00DF82,
0x9E5C57BB, 0xCA6F8CA0, 0x1A87562E, 0xDF1769DB,
0xD542A8F6, 0x287EFFC3, 0xAC6732C6, 0x8C4F5573,
0x695B27B0, 0xBBCA58C8, 0xE1FFA35D, 0xB8F011A0,
0x10FA3D98, 0xFD2183B8, 0x4AFCB56C, 0x2DD1D35B,
0x9A53E479, 0xB6F84565, 0xD28E49BC, 0x4BFB9790,
0xE1DDF2DA, 0xA4CB7E33, 0x62FB1341, 0xCEE4C6E8,
0xEF20CADA, 0x36774C01, 0xD07E9EFE, 0x2BF11FB4,
0x95DBDA4D, 0xAE909198, 0xEAAD8E71, 0x6B93D5A0,
0xD08ED1D0, 0xAFC725E0, 0x8E3C5B2F, 0x8E7594B7,
0x8FF6E2FB, 0xF2122B64, 0x8888B812, 0x900DF01C,
0x4FAD5EA0, 0x688FC31C, 0xD1CFF191, 0xB3A8C1AD,
0x2F2F2218, 0xBE0E1777, 0xEA752DFE, 0x8B021FA1,
0xE5A0CC0F, 0xB56F74E8, 0x18ACF3D6, 0xCE89E299,
0xB4A84FE0, 0xFD13E0B7, 0x7CC43B81, 0xD2ADA8D9,
0x165FA266, 0x80957705, 0x93CC7314, 0x211A1477,
0xE6AD2065, 0x77B5FA86, 0xC75442F5, 0xFB9D35CF,
0xEBCDAF0C, 0x7B3E89A0, 0xD6411BD3, 0xAE1E7E49,
0x00250E2D, 0x2071B35E, 0x226800BB, 0x57B8E0AF,
0x2464369B, 0xF009B91E, 0x5563911D, 0x59DFA6AA,
0x78C14389, 0xD95A537F, 0x207D5BA2, 0x02E5B9C5,
0x83260376, 0x6295CFA9, 0x11C81968, 0x4E734A41,
0xB3472DCA, 0x7B14A94A, 0x1B510052, 0x9A532915,
0xD60F573F, 0xBC9BC6E4, 0x2B60A476, 0x81E67400,
0x08BA6FB5, 0x571BE91F, 0xF296EC6B, 0x2A0DD915,
0xB6636521, 0xE7B9F9B6, 0xFF34052E, 0xC5855664,
0x53B02D5D, 0xA99F8FA1, 0x08BA4799, 0x6E85076A);
var $s2 = array(
0x4B7A70E9, 0xB5B32944, 0xDB75092E, 0xC4192623,
0xAD6EA6B0, 0x49A7DF7D, 0x9CEE60B8, 0x8FEDB266,
0xECAA8C71, 0x699A17FF, 0x5664526C, 0xC2B19EE1,
0x193602A5, 0x75094C29, 0xA0591340, 0xE4183A3E,
0x3F54989A, 0x5B429D65, 0x6B8FE4D6, 0x99F73FD6,
0xA1D29C07, 0xEFE830F5, 0x4D2D38E6, 0xF0255DC1,
0x4CDD2086, 0x8470EB26, 0x6382E9C6, 0x021ECC5E,
0x09686B3F, 0x3EBAEFC9, 0x3C971814, 0x6B6A70A1,
0x687F3584, 0x52A0E286, 0xB79C5305, 0xAA500737,
0x3E07841C, 0x7FDEAE5C, 0x8E7D44EC, 0x5716F2B8,
0xB03ADA37, 0xF0500C0D, 0xF01C1F04, 0x0200B3FF,
0xAE0CF51A, 0x3CB574B2, 0x25837A58, 0xDC0921BD,
0xD19113F9, 0x7CA92FF6, 0x94324773, 0x22F54701,
0x3AE5E581, 0x37C2DADC, 0xC8B57634, 0x9AF3DDA7,
0xA9446146, 0x0FD0030E, 0xECC8C73E, 0xA4751E41,
0xE238CD99, 0x3BEA0E2F, 0x3280BBA1, 0x183EB331,
0x4E548B38, 0x4F6DB908, 0x6F420D03, 0xF60A04BF,
0x2CB81290, 0x24977C79, 0x5679B072, 0xBCAF89AF,
0xDE9A771F, 0xD9930810, 0xB38BAE12, 0xDCCF3F2E,
0x5512721F, 0x2E6B7124, 0x501ADDE6, 0x9F84CD87,
0x7A584718, 0x7408DA17, 0xBC9F9ABC, 0xE94B7D8C,
0xEC7AEC3A, 0xDB851DFA, 0x63094366, 0xC464C3D2,
0xEF1C1847, 0x3215D908, 0xDD433B37, 0x24C2BA16,
0x12A14D43, 0x2A65C451, 0x50940002, 0x133AE4DD,
0x71DFF89E, 0x10314E55, 0x81AC77D6, 0x5F11199B,
0x043556F1, 0xD7A3C76B, 0x3C11183B, 0x5924A509,
0xF28FE6ED, 0x97F1FBFA, 0x9EBABF2C, 0x1E153C6E,
0x86E34570, 0xEAE96FB1, 0x860E5E0A, 0x5A3E2AB3,
0x771FE71C, 0x4E3D06FA, 0x2965DCB9, 0x99E71D0F,
0x803E89D6, 0x5266C825, 0x2E4CC978, 0x9C10B36A,
0xC6150EBA, 0x94E2EA78, 0xA5FC3C53, 0x1E0A2DF4,
0xF2F74EA7, 0x361D2B3D, 0x1939260F, 0x19C27960,
0x5223A708, 0xF71312B6, 0xEBADFE6E, 0xEAC31F66,
0xE3BC4595, 0xA67BC883, 0xB17F37D1, 0x018CFF28,
0xC332DDEF, 0xBE6C5AA5, 0x65582185, 0x68AB9802,
0xEECEA50F, 0xDB2F953B, 0x2AEF7DAD, 0x5B6E2F84,
0x1521B628, 0x29076170, 0xECDD4775, 0x619F1510,
0x13CCA830, 0xEB61BD96, 0x0334FE1E, 0xAA0363CF,
0xB5735C90, 0x4C70A239, 0xD59E9E0B, 0xCBAADE14,
0xEECC86BC, 0x60622CA7, 0x9CAB5CAB, 0xB2F3846E,
0x648B1EAF, 0x19BDF0CA, 0xA02369B9, 0x655ABB50,
0x40685A32, 0x3C2AB4B3, 0x319EE9D5, 0xC021B8F7,
0x9B540B19, 0x875FA099, 0x95F7997E, 0x623D7DA8,
0xF837889A, 0x97E32D77, 0x11ED935F, 0x16681281,
0x0E358829, 0xC7E61FD6, 0x96DEDFA1, 0x7858BA99,
0x57F584A5, 0x1B227263, 0x9B83C3FF, 0x1AC24696,
0xCDB30AEB, 0x532E3054, 0x8FD948E4, 0x6DBC3128,
0x58EBF2EF, 0x34C6FFEA, 0xFE28ED61, 0xEE7C3C73,
0x5D4A14D9, 0xE864B7E3, 0x42105D14, 0x203E13E0,
0x45EEE2B6, 0xA3AAABEA, 0xDB6C4F15, 0xFACB4FD0,
0xC742F442, 0xEF6ABBB5, 0x654F3B1D, 0x41CD2105,
0xD81E799E, 0x86854DC7, 0xE44B476A, 0x3D816250,
0xCF62A1F2, 0x5B8D2646, 0xFC8883A0, 0xC1C7B6A3,
0x7F1524C3, 0x69CB7492, 0x47848A0B, 0x5692B285,
0x095BBF00, 0xAD19489D, 0x1462B174, 0x23820E00,
0x58428D2A, 0x0C55F5EA, 0x1DADF43E, 0x233F7061,
0x3372F092, 0x8D937E41, 0xD65FECF1, 0x6C223BDB,
0x7CDE3759, 0xCBEE7460, 0x4085F2A7, 0xCE77326E,
0xA6078084, 0x19F8509E, 0xE8EFD855, 0x61D99735,
0xA969A7AA, 0xC50C06C2, 0x5A04ABFC, 0x800BCADC,
0x9E447A2E, 0xC3453484, 0xFDD56705, 0x0E1E9EC9,
0xDB73DBD3, 0x105588CD, 0x675FDA79, 0xE3674340,
0xC5C43465, 0x713E38D8, 0x3D28F89E, 0xF16DFF20,
0x153E21E7, 0x8FB03D4A, 0xE6E39F2B, 0xDB83ADF7);
var $s3 = array(
0xE93D5A68, 0x948140F7, 0xF64C261C, 0x94692934,
0x411520F7, 0x7602D4F7, 0xBCF46B2E, 0xD4A20068,
0xD4082471, 0x3320F46A, 0x43B7D4B7, 0x500061AF,
0x1E39F62E, 0x97244546, 0x14214F74, 0xBF8B8840,
0x4D95FC1D, 0x96B591AF, 0x70F4DDD3, 0x66A02F45,
0xBFBC09EC, 0x03BD9785, 0x7FAC6DD0, 0x31CB8504,
0x96EB27B3, 0x55FD3941, 0xDA2547E6, 0xABCA0A9A,
0x28507825, 0x530429F4, 0x0A2C86DA, 0xE9B66DFB,
0x68DC1462, 0xD7486900, 0x680EC0A4, 0x27A18DEE,
0x4F3FFEA2, 0xE887AD8C, 0xB58CE006, 0x7AF4D6B6,
0xAACE1E7C, 0xD3375FEC, 0xCE78A399, 0x406B2A42,
0x20FE9E35, 0xD9F385B9, 0xEE39D7AB, 0x3B124E8B,
0x1DC9FAF7, 0x4B6D1856, 0x26A36631, 0xEAE397B2,
0x3A6EFA74, 0xDD5B4332, 0x6841E7F7, 0xCA7820FB,
0xFB0AF54E, 0xD8FEB397, 0x454056AC, 0xBA489527,
0x55533A3A, 0x20838D87, 0xFE6BA9B7, 0xD096954B,
0x55A867BC, 0xA1159A58, 0xCCA92963, 0x99E1DB33,
0xA62A4A56, 0x3F3125F9, 0x5EF47E1C, 0x9029317C,
0xFDF8E802, 0x04272F70, 0x80BB155C, 0x05282CE3,
0x95C11548, 0xE4C66D22, 0x48C1133F, 0xC70F86DC,
0x07F9C9EE, 0x41041F0F, 0x404779A4, 0x5D886E17,
0x325F51EB, 0xD59BC0D1, 0xF2BCC18F, 0x41113564,
0x257B7834, 0x602A9C60, 0xDFF8E8A3, 0x1F636C1B,
0x0E12B4C2, 0x02E1329E, 0xAF664FD1, 0xCAD18115,
0x6B2395E0, 0x333E92E1, 0x3B240B62, 0xEEBEB922,
0x85B2A20E, 0xE6BA0D99, 0xDE720C8C, 0x2DA2F728,
0xD0127845, 0x95B794FD, 0x647D0862, 0xE7CCF5F0,
0x5449A36F, 0x877D48FA, 0xC39DFD27, 0xF33E8D1E,
0x0A476341, 0x992EFF74, 0x3A6F6EAB, 0xF4F8FD37,
0xA812DC60, 0xA1EBDDF8, 0x991BE14C, 0xDB6E6B0D,
0xC67B5510, 0x6D672C37, 0x2765D43B, 0xDCD0E804,
0xF1290DC7, 0xCC00FFA3, 0xB5390F92, 0x690FED0B,
0x667B9FFB, 0xCEDB7D9C, 0xA091CF0B, 0xD9155EA3,
0xBB132F88, 0x515BAD24, 0x7B9479BF, 0x763BD6EB,
0x37392EB3, 0xCC115979, 0x8026E297, 0xF42E312D,
0x6842ADA7, 0xC66A2B3B, 0x12754CCC, 0x782EF11C,
0x6A124237, 0xB79251E7, 0x06A1BBE6, 0x4BFB6350,
0x1A6B1018, 0x11CAEDFA, 0x3D25BDD8, 0xE2E1C3C9,
0x44421659, 0x0A121386, 0xD90CEC6E, 0xD5ABEA2A,
0x64AF674E, 0xDA86A85F, 0xBEBFE988, 0x64E4C3FE,
0x9DBC8057, 0xF0F7C086, 0x60787BF8, 0x6003604D,
0xD1FD8346, 0xF6381FB0, 0x7745AE04, 0xD736FCCC,
0x83426B33, 0xF01EAB71, 0xB0804187, 0x3C005E5F,
0x77A057BE, 0xBDE8AE24, 0x55464299, 0xBF582E61,
0x4E58F48F, 0xF2DDFDA2, 0xF474EF38, 0x8789BDC2,
0x5366F9C3, 0xC8B38E74, 0xB475F255, 0x46FCD9B9,
0x7AEB2661, 0x8B1DDF84, 0x846A0E79, 0x915F95E2,
0x466E598E, 0x20B45770, 0x8CD55591, 0xC902DE4C,
0xB90BACE1, 0xBB8205D0, 0x11A86248, 0x7574A99E,
0xB77F19B6, 0xE0A9DC09, 0x662D09A1, 0xC4324633,
0xE85A1F02, 0x09F0BE8C, 0x4A99A025, 0x1D6EFE10,
0x1AB93D1D, 0x0BA5A4DF, 0xA186F20F, 0x2868F169,
0xDCB7DA83, 0x573906FE, 0xA1E2CE9B, 0x4FCD7F52,
0x50115E01, 0xA70683FA, 0xA002B5C4, 0x0DE6D027,
0x9AF88C27, 0x773F8641, 0xC3604C06, 0x61A806B5,
0xF0177A28, 0xC0F586E0, 0x006058AA, 0x30DC7D62,
0x11E69ED7, 0x2338EA63, 0x53C2DD94, 0xC2C21634,
0xBBCBEE56, 0x90BCB6DE, 0xEBFC7DA1, 0xCE591D76,
0x6F05E409, 0x4B7C0188, 0x39720A3D, 0x7C927C24,
0x86E3725F, 0x724D9DB9, 0x1AC15BB4, 0xD39EB8FC,
0xED545578, 0x08FCA5B5, 0xD83D7CD3, 0x4DAD0FC4,
0x1E50EF5E, 0xB161E6F8, 0xA28514D9, 0x6C51133C,
0x6FD5C7E7, 0x56E14EC4, 0x362ABFCE, 0xDDC6C837,
0xD79A3234, 0x92638212, 0x670EFA8E, 0x406000E0);
var $s4 = array(
0x3A39CE37, 0xD3FAF5CF, 0xABC27737, 0x5AC52D1B,
0x5CB0679E, 0x4FA33742, 0xD3822740, 0x99BC9BBE,
0xD5118E9D, 0xBF0F7315, 0xD62D1C7E, 0xC700C47B,
0xB78C1B6B, 0x21A19045, 0xB26EB1BE, 0x6A366EB4,
0x5748AB2F, 0xBC946E79, 0xC6A376D2, 0x6549C2C8,
0x530FF8EE, 0x468DDE7D, 0xD5730A1D, 0x4CD04DC6,
0x2939BBDB, 0xA9BA4650, 0xAC9526E8, 0xBE5EE304,
0xA1FAD5F0, 0x6A2D519A, 0x63EF8CE2, 0x9A86EE22,
0xC089C2B8, 0x43242EF6, 0xA51E03AA, 0x9CF2D0A4,
0x83C061BA, 0x9BE96A4D, 0x8FE51550, 0xBA645BD6,
0x2826A2F9, 0xA73A3AE1, 0x4BA99586, 0xEF5562E9,
0xC72FEFD3, 0xF752F7DA, 0x3F046F69, 0x77FA0A59,
0x80E4A915, 0x87B08601, 0x9B09E6AD, 0x3B3EE593,
0xE990FD5A, 0x9E34D797, 0x2CF0B7D9, 0x022B8B51,
0x96D5AC3A, 0x017DA67D, 0xD1CF3ED6, 0x7C7D2D28,
0x1F9F25CF, 0xADF2B89B, 0x5AD6B472, 0x5A88F54C,
0xE029AC71, 0xE019A5E6, 0x47B0ACFD, 0xED93FA9B,
0xE8D3C48D, 0x283B57CC, 0xF8D56629, 0x79132E28,
0x785F0191, 0xED756055, 0xF7960E44, 0xE3D35E8C,
0x15056DD4, 0x88F46DBA, 0x03A16125, 0x0564F0BD,
0xC3EB9E15, 0x3C9057A2, 0x97271AEC, 0xA93A072A,
0x1B3F6D9B, 0x1E6321F5, 0xF59C66FB, 0x26DCF319,
0x7533D928, 0xB155FDF5, 0x03563482, 0x8ABA3CBB,
0x28517711, 0xC20AD9F8, 0xABCC5167, 0xCCAD925F,
0x4DE81751, 0x3830DC8E, 0x379D5862, 0x9320F991,
0xEA7A90C2, 0xFB3E7BCE, 0x5121CE64, 0x774FBE32,
0xA8B6E37E, 0xC3293D46, 0x48DE5369, 0x6413E680,
0xA2AE0810, 0xDD6DB224, 0x69852DFD, 0x09072166,
0xB39A460A, 0x6445C0DD, 0x586CDECF, 0x1C20C8AE,
0x5BBEF7DD, 0x1B588D40, 0xCCD2017F, 0x6BB4E3BB,
0xDDA26A7E, 0x3A59FF45, 0x3E350A44, 0xBCB4CDD5,
0x72EACEA8, 0xFA6484BB, 0x8D6612AE, 0xBF3C6F47,
0xD29BE463, 0x542F5D9E, 0xAEC2771B, 0xF64E6370,
0x740E0D8D, 0xE75B1357, 0xF8721671, 0xAF537D5D,
0x4040CB08, 0x4EB4E2CC, 0x34D2466A, 0x0115AF84,
0xE1B00428, 0x95983A1D, 0x06B89FB4, 0xCE6EA048,
0x6F3F3B82, 0x3520AB82, 0x011A1D4B, 0x277227F8,
0x611560B1, 0xE7933FDC, 0xBB3A792B, 0x344525BD,
0xA08839E1, 0x51CE794B, 0x2F32C9B7, 0xA01FBAC9,
0xE01CC87E, 0xBCC7D1F6, 0xCF0111C3, 0xA1E8AAC7,
0x1A908749, 0xD44FBD9A, 0xD0DADECB, 0xD50ADA38,
0x0339C32A, 0xC6913667, 0x8DF9317C, 0xE0B12B4F,
0xF79E59B7, 0x43F5BB3A, 0xF2D519FF, 0x27D9459C,
0xBF97222C, 0x15E6FC2A, 0x0F91FC71, 0x9B941525,
0xFAE59361, 0xCEB69CEB, 0xC2A86459, 0x12BAA8D1,
0xB6C1075E, 0xE3056A0C, 0x10D25065, 0xCB03A442,
0xE0EC6E0E, 0x1698DB3B, 0x4C98A0BE, 0x3278E964,
0x9F1F9532, 0xE0D392DF, 0xD3A0342B, 0x8971F21E,
0x1B0A7441, 0x4BA3348C, 0xC5BE7120, 0xC37632D8,
0xDF359F8D, 0x9B992F2E, 0xE60B6F47, 0x0FE3F11D,
0xE54CDA54, 0x1EDAD891, 0xCE6279CF, 0xCD3E7E6F,
0x1618B166, 0xFD2C1D05, 0x848FD2C5, 0xF6FB2299,
0xF523F357, 0xA6327623, 0x93A83531, 0x56CCCD02,
0xACF08162, 0x5A75EBB5, 0x6E163697, 0x88D273CC,
0xDE966292, 0x81B949D0, 0x4C50901B, 0x71C65614,
0xE6C6C7BD, 0x327A140A, 0x45E1D006, 0xC3F27B9A,
0xC9AA53FD, 0x62A80F00, 0xBB25BFE2, 0x35BDD2F6,
0x71126905, 0xB2040222, 0xB6CBCF7C, 0xCD769C2B,
0x53113EC0, 0x1640E3D3, 0x38ABBD60, 0x2547ADF0,
0xBA38209C, 0xF746CE76, 0x77AFA1C5, 0x20756060,
0x85CBFE4E, 0x8AE88DD8, 0x7AAAF9B0, 0x4CF9AA7E,
0x1948C25C, 0x02FB8A8C, 0x01C36AE4, 0xD6EBE1F9,
0x90D4F869, 0xA65CDEA0, 0x3F09252D, 0xC208E69F,
0xB74E6132, 0xCE77E25B, 0x578FDFE3, 0x3AC372E6);
/* The number of rounds to do */
var $_rounds = 16;
/* Constructor */
function Cipher_blowfish($params = null)
{
}
/**
* Set the key to be used for en/decryption
*
* @param String $key The key to use
*/
function setKey($key)
{
$key = $this->_formatKey($key);
$keyPos = $keyXor = 0;
$iMax = count($this->p);
$keyLen = count($key);
for ($i = 0; $i < $iMax; $i++) {
for ($t = 0; $t < 4; $t++) {
$keyXor = ($keyXor << 8) | (($key[$keyPos]) & 0x0ff);
if (++$keyPos == $keyLen) {
$keyPos = 0;
}
}
$this->p[$i] = $this->p[$i] ^ $keyXor;
}
$encZero = array('L' => 0, 'R' => 0);
for ($i = 0; $i + 1 < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->p[$i] = $encZero['L'];
$this->p[$i + 1] = $encZero['R'];
}
$iMax = count($this->s1);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s1[$i] = $encZero['L'];
$this->s1[$i + 1] = $encZero['R'];
}
$iMax = count($this->s2);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s2[$i] = $encZero['L'];
$this->s2[$i + 1] = $encZero['R'];
}
$iMax = count($this->s3);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s3[$i] = $encZero['L'];
$this->s3[$i + 1] = $encZero['R'];
}
$iMax = count($this->s4);
for ($i = 0; $i < $iMax; $i += 2) {
$encZero = $this->_encryptBlock($encZero['L'], $encZero['R']);
$this->s4[$i] = $encZero['L'];
$this->s4[$i + 1] = $encZero['R'];
}
}
/**
* Return the size of the blocks that this cipher needs
*
* @return Integer The number of characters per block
*/
function getBlockSize()
{
return 8;
}
/**
* Encrypt a block on data.
*
* @param String $block The data to encrypt
* @param optional String $key The key to use
*
* @return String the encrypted output
*/
function encryptBlock($block, $key = null)
{
if (!is_null($key)) {
$this->setKey($key);
}
list($L, $R) = array_values(unpack('N*', $block));
$parts = $this->_encryptBlock($L, $R);
return pack("NN", $parts['L'], $parts['R']);
}
/**
* Encrypt a block on data.
*
* @param String $L The data to encrypt.
* @param String $R The data to encrypt.
*
* @return String The encrypted output.
*/
function _encryptBlock($L, $R)
{
$L ^= $this->p[0];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[1];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[2];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[3];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[4];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[5];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[6];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[7];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[8];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[9];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[10];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[11];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[12];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[13];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[14];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[15];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[16];
$R ^= $this->p[17];
return array('L' => $R, 'R' => $L);
}
/**
* Decrypt a block on data.
*
* @param String $block The data to decrypt
* @param optional String $key The key to use
*
* @return String the decrypted output
*/
function decryptBlock($block, $key = null)
{
if (!is_null($key)) {
$this->setKey($key);
}
list($L, $R) = array_values(unpack('N*', $block));
$L ^= $this->p[17];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[16];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[15];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[14];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[13];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[12];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[11];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[10];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[9];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[8];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[7];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[6];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[5];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[4];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[3];
$R ^= ((($this->s1[($L >> 24) & 0xFF] + $this->s2[($L >> 16) & 0x0ff]) ^ $this->s3[($L >> 8) & 0x0ff]) + $this->s4[$L & 0x0ff]) ^ $this->p[2];
$L ^= ((($this->s1[($R >> 24) & 0xFF] + $this->s2[($R >> 16) & 0x0ff]) ^ $this->s3[($R >> 8) & 0x0ff]) + $this->s4[$R & 0x0ff]) ^ $this->p[1];
$decrypted = pack("NN", $R ^ $this->p[0], $L);
return $decrypted;
}
/**
* Converts a text key into an array.
*
* @return array The key.
*/
function _formatKey($key)
{
return array_values(unpack('C*', $key));
}
}
?>

154
lib/common.php Normal file
View File

@@ -0,0 +1,154 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/common.php,v 1.68 2005/09/25 16:11:44 wurley Exp $
/**
* Contains code to be executed at the top of each phpLDAPadmin page.
* include this file at the top of every PHP file.
*
* This file will "pre-initialise" a PLA environment so that any PHP file will have a consistent
* environment with other PLA PHP files.
*
* This code WILL NOT check that all required functions are usable/readable, etc. This process has
* been moved to index.php (which really is only called once when a browser hits PLA for the first time).
*
* The list of ADDITIONAL function files is now defined in functions.php.
*
* @package phpLDAPadmin
*/
@DEFINE(LIBDIR,'./');
# Turn on all notices and warnings. This helps us write cleaner code (we hope at least)
if (phpversion() >= "5") {
# Work-around to get PLA to work in PHP5
ini_set( "zend.ze1_compatibility_mode", 1 );
# E_DEBUG is PHP5 specific and prevents warnings about using 'var' to declar class members
error_reporting( 'E_DEBUG' );
} else
# For PHP4
error_reporting( E_ALL );
# For PHP5 backward/forward compatibility
if (! defined('E_STRICT'))
define('E_STRICT',2048);
# General functions needed to proceed (pla_ldap_search(), pla_error(), get_object_attrs(), etc.)
ob_start();
require_once realpath(LIBDIR.'functions.php');
ob_end_clean();
/* Our custom error handler receives all error notices that pass the error_reporting()
level set above. */
set_error_handler('pla_error_handler');
/* Creates the language array which will be populated with localized strings
based on the user-configured language. */
$lang = array();
/*
* functions.php should have defined our pla_function_files array, listing all our
* required functions (order IS important).
* index.php should have checked they exist and are usable - we'll assume that the user
* has been via index.php, and fixed any problems already.
*/
ob_start();
foreach ($pla_function_files as $file_name) {
require_once realpath ($file_name);
}
# Now read in config_default.php, which also reads in config.php
require_once realpath(LIBDIR.'config_default.php');
ob_end_clean();
/**
* At this point we have read all our additional function PHP files and our configuration.
*/
# Check our custom variables.
$config->CheckCustom();
if (pla_session_start())
run_hook('post_session_init',array());
/*
* Language configuration. Auto or specified?
* Shall we attempt to auto-determine the language?
*/
$language = $config->GetValue('appearance','language');
if ($language == "auto") {
# Make sure their browser correctly reports language. If not, skip this.
if( isset( $_SERVER['HTTP_ACCEPT_LANGUAGE'] ) ) {
# get the languages which are spetcified in the HTTP header
$HTTP_LANGS1 = preg_split ("/[;,]+/", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
$HTTP_LANGS2 = preg_split ("/[;,]+/", $_SERVER['HTTP_ACCEPT_LANGUAGE'] );
foreach( $HTTP_LANGS2 as $key => $value ) {
$value=preg_split ("/[-]+/", $value );
$HTTP_LANGS2[$key]=$value[0];
}
$HTTP_LANGS = array_merge ($HTTP_LANGS1, $HTTP_LANGS2);
foreach( $HTTP_LANGS as $HTTP_LANG) {
# try to grab one after the other the language file
if( file_exists( realpath( "lang/recoded/$HTTP_LANG.php" ) ) &&
is_readable( realpath( "lang/recoded/$HTTP_LANG.php" ) ) ) {
ob_start();
include realpath( "lang/recoded/$HTTP_LANG.php" );
ob_end_clean();
break;
}
}
}
} else {
# grab the language file configured in config.php
if( $language != null ) {
if( 0 == strcmp( $language, 'english' ) )
$language = 'en';
if( file_exists( realpath( "lang/recoded/$language.php" ) ) &&
is_readable( realpath( "lang/recoded/$language.php" ) ) ) {
ob_start();
include realpath( "lang/recoded/$language.php" );
ob_end_clean();
} else {
pla_error( "Could not read language file 'lang/recoded/$language.php'. Either the file
does not exist, or its permissions do not allow phpLDAPadmin to read it." );
}
}
}
# If config.php doesn't create the templates array, create it here.
if (! isset($templates) || ! is_array($templates))
$templates = array();
# Always including the 'custom' template (the most generic and flexible)
$templates['custom'] =
array('desc' => 'Custom',
'icon' => 'images/object.png',
'handler' => 'custom.php' );
/*
* Strip slashes from GET, POST, and COOKIE variables if this
* PHP install is configured to automatically addslashes()
*/
if (get_magic_quotes_gpc() && (! isset($slashes_stripped) || ! $slashes_stripped)) {
array_stripslashes($_REQUEST);
array_stripslashes($_GET);
array_stripslashes($_POST);
array_stripslashes($_COOKIE);
array_stripslashes($_FILES);
$slashes_stripped = true;
}
/*
* Update $_SESSION['activity']
* for timeout and automatic logout feature
*/
if (isset($_REQUEST['server_id'])) {
$ldapserver = $ldapservers->Instance($_REQUEST['server_id']);
if ($ldapserver->haveAuthInfo())
set_lastactivity($ldapserver);
}
?>

376
lib/config_default.php Normal file
View File

@@ -0,0 +1,376 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/config_default.php,v 1.11 2005/09/25 16:11:44 wurley Exp $
/**
* Configuration processing and defaults.
* @author The phpLDAPadmin development team
* @package phpLDAPadmin
* @todo Add validation of set variables to enforce limits or particular values.
*/
# The minimum version of PHP required to run phpLDAPadmin.
@define( 'REQUIRED_PHP_VERSION', '4.1.0' );
class Config {
var $custom;
var $default;
function Config() {
$this->custom = new stdClass;
$this->default = new stdClass;
## Appearance Attributes
/** Anonymous implies read only
* Set to true if you want LDAP data to be displayed read-only (without input fields)
* when a user logs in to a server anonymously
*/
$this->default->appearance['anonymous_bind_implies_read_only'] = array(
'desc'=>'Display as read only if user logs in with anonymous bind',
'default'=>true);
//$anonymous_bind_implies_read_only = true;
/* Anonymous redirect
* Set to true if you want phpLDAPadmin to redirect anonymous
* users to a search form with no tree viewer on the left after
* logging in.
*/
$this->default->appearance['anonymous_bind_redirect_no_tree'] = array(
'desc'=>'Redirect user to search form if anonymous',
'default'=>false);
//$anonymous_bind_redirect_no_tree = false;
$this->default->appearance['date'] = array(
'desc'=>'Date format whenever dates are shown',
'default'=>'%A %e %B %Y');
//$date_format = "%A %e %B %Y";
$this->default->appearance['hide_configuration_management'] = array(
'desc'=>'Hide the Sourceforge related links',
'default'=>false);
//$hide_configuration_management = false;
/** Language
* The language setting. If you set this to 'auto', phpLDAPadmin will
* attempt to determine your language automatically. Otherwise, available
* lanaguages are: 'ct', 'de', 'en', 'es', 'fr', 'it', 'nl', and 'ru'
* Localization is not complete yet, but most strings have been translated.
* Please help by writing language files. See lang/en.php for an example.
*/
$this->default->appearance['language'] = array(
'desc'=>'Language',
'default'=>'auto');
//$language = 'auto';
/** Mass Delete
* Set to true if you want to draw a checkbox next to each entry in the tree viewer
* to be able to delete multiple entries at once
*/
$this->default->appearance['mass_delete'] = array(
'desc'=>'Enable mass delete in tree viewer',
'default'=>false);
//$enable_mass_delete = false;
/**
* If you want certain attributes to be editable as multi-line, include them in this list
* A multi-line textarea will be drawn instead of a single-line text field
*/
$this->default->appearance['multi_line_attributes'] = array(
'desc'=>'Attributes to show as multiline attributes',
'default'=>array("postalAddress","homePostalAddress","personalSignature"));
//$multi_line_attributes = array( "postalAddress", "homePostalAddress", "personalSignature" );
/**
* A list of syntax OIDs which support multi-line attribute values:
*/
$this->default->appearance['multi_line_syntax_oids'] = array(
'desc'=>'Attributes to show as multiline attributes',
'default'=>array(
// octet string syntax OID:
"1.3.6.1.4.1.1466.115.121.1.40",
// postal address syntax OID:
"1.3.6.1.4.1.1466.115.121.1.41"));
//$multi_line_syntax_oids ...
/** Obfuscate Password
* If true, display all password hash values as "******". Note that clear-text
* passwords will always be displayed as "******", regardless of this setting.
*/
$this->default->appearance['obfuscate_password_display'] = array(
'desc'=>'Obfuscate the display of passwords',
'default'=>false);
//$obfuscate_password_display = false;
$this->default->appearance['show_clear_password'] = array(
'desc'=>'Whether to show clear passwords if we dont obfuscate them',
'default'=>false);
$this->default->appearance['page_title'] = array(
'desc'=>'Change the page title to this text',
'default'=>'');
$this->default->appearance['show_hints'] = array(
'desc'=>'Show helpful hints',
'default'=>true);
//$show_hints = true; // set to false to disable hints
/** Tree display
* A format string used to display enties in the tree viewer (left-hand side)
* You can use special tokens to draw the entries as you wish. You can even mix in HTML to format the string
* Here are all the tokens you can use:
* %rdn - draw the RDN of the entry (ie, "cn=Dave")
* %dn - draw the DN of the entry (ie, "cn=Dave,ou=People,dc=example,dc=com"
* %rdnValue - draw the value of the RDN (ie, instead of "cn=Dave", just draw "Dave")
* %[attrname]- draw the value (or values) of the specified attribute.
* example: %gidNumber
*
* Examples:
*
* To draw the gidNumber and uidNumber to the right of the RDN in a small, gray font:
* '%rdn <small style="color:gray">( %gidNumber / %uidNumber )</span>'
* To draw the full DN of each entry:
* '%dn'
* To draw the objectClasses to the right in parenthesis:
* '%rdn <small style="color: gray">( %objectClass )</small>'
* To draw the user-friendly RDN value (ie, instead of "cn=Dave", just draw "Dave"):
* '%rdnValue'
*/
$this->default->appearance['tree_display_format'] = array(
'desc'=>'LDAP attribute to show in the tree',
'default'=>'%rdn');
//$tree_display_format = '%rdn';
$this->default->appearance['tree_width'] = array(
'desc'=>'Pixel width of the left frame view (tree browser)',
'default'=>320);
//$tree_width = 320; // pixels
/** Caching
*/
$this->default->cache['schema'] = array(
'desc'=>'Cache schema activity',
'default'=>true);
$this->default->cache['template'] = array(
'desc'=>'Cache Template configuration',
'default'=>true);
/** Aliases and Referrrals
* Similar to ldapsearch's -a option, the following options allow you to configure
* how phpLDAPadmin will treat aliases and referrals in the LDAP tree.
* For the following four settings, avaialable options include:
*
* LDAP_DEREF_NEVER - aliases are never dereferenced (eg, the contents of
* the alias itself are shown and not the referenced entry).
* LDAP_DEREF_SEARCHING - aliases should be dereferenced during the search but
* not when locating the base object of the search.
* LDAP_DEREF_FINDING - aliases should be dereferenced when locating the base
* object but not during the search.
* LDAP_DEREF_ALWAYS - aliases should be dereferenced always (eg, the contents
* of the referenced entry is shown and not the aliasing entry)
*/
$this->default->deref['export'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$export_deref = LDAP_DEREF_NEVER;
$this->default->deref['search'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_ALWAYS);
//$search_deref = LDAP_DEREF_ALWAYS;
$this->default->deref['tree'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$tree_deref = LDAP_DEREF_NEVER;
$this->default->deref['view'] = array(
'desc'=>'',
'default'=>LDAP_DEREF_NEVER);
//$view_deref = LDAP_DEREF_NEVER;
## Debug Attributes
$this->default->debug['level'] = array(
'desc'=>'Debug level verbosity',
'default'=>0);
//$debug_level
$this->default->debug['syslog'] = array(
'desc'=>'Whether to send debug messages to syslog',
'default'=>false);
//$use_syslog
/** Temp Directories
* This directory must be readable and writable by your web server
*/
$this->default->jpeg['tmpdir'] = array(
'desc'=>'Temporary directory for jpegPhoto data',
'default'=>'/tmp');
//$jpeg_temp_dir = "/tmp";
$this->default->jpeg['tmp_keep_time'] = array(
'desc'=>'Time in seconds to keep jpegPhoto temporary files in the temp directory',
'default'=>120);
//$jpeg_tmp_keep_time = 120; // seconds
## Session Attributes
/** Cookie Encryption
* phpLDAPadmin can encrypt the content of sensitive cookies if you set this to a big random string.
*/
$this->default->session['blowfish'] = array(
'desc'=>'Blowfish key to encrypt cookie details',
'default'=>null);
//$blowfish_secret = '';
/** Cookie Time
* If you used auth_type 'form' in the servers list, you can adjust how long the cookie will last
* (default is 0 seconds, which expires when you close the browser)
*/
$this->default->session['cookie_time'] = array(
'desc'=>'Time in seconds for the life of cookies',
'default'=>0);
//$cookie_time = 0;
## Password Generation
$this->default->password['length'] = array(
'desc'=>'Length of autogenerated password',
'default'=>8);
$this->default->password['numbers'] = array(
'desc'=>'Number of numbers required in the password',
'default'=>2);
$this->default->password['lowercase'] = array(
'desc'=>'Number of lowercase letters required in the password',
'default'=>2);
$this->default->password['uppercase'] = array(
'desc'=>'Number of uppercase letters required in the password',
'default'=>2);
$this->default->password['punctuation'] = array(
'desc'=>'Number of punctuation letters required in the password',
'default'=>2);
$this->default->password['use_similar'] = array(
'desc'=>'Whether to use similiar characters',
'default'=>true);
## Template Engine Configuration
$this->default->template_engine['enable'] = array(
'desc'=>'Use templates from parsed by the template engine',
'default'=>true);
$this->default->template_engine['disable_old'] = array(
'desc'=>'Disable access to old templates',
'default'=>true);
/** Search display
* By default, when searching you may display a list or a table of results.
* Set this to 'table' to see table formatted results.
* Set this to 'list' to see "Google" style formatted search results.
*/
$this->default->search['display'] = array(
'desc'=>'Display a list or table of search results',
'default'=>'list');
//$default_search_display = 'list';
$this->default->search['size_limit'] = array(
'desc'=>'Limit the size of searchs on the search page',
'default'=>50);
//$search_result_size_limit = 50;
/**
* Which attributes to include in the drop-down menu of the simple search form (comma-separated)
* Change this to suit your needs for convenient searching. Be sure to change the corresponding
* list below ($search_attributes_display)
*/
$this->default->search['attributes'] = array(
'desc'=>'Attributes to include in the drop down menu of the simple search form (comma separated)',
'default'=>array('uid','cn','gidNumber','objectClass','telephoneNumber','mail','street'));
//$search_attributes ...
/**
* You can re-arrange the order of the search criteria on the simple search form by modifying this array
* You cannot however change the names of the criteria. Criteria names will be translated at run-time.
*/
$this->default->search['criteria_options'] = array(
'desc'=>'Rearrange the order of the search criteria',
'default'=>array("equals","starts with","contains","ends with","sounds like"));
//$search_criteria_options ...
/**
* The list of attributes to display in each search result entry.
* Note that you can add * to the list to display all attributes
*/
$this->default->search['result_attributes'] = array(
'desc'=>'List of attributes to display in each search result entry',
'default'=>array('cn','sn','uid','postalAddress','telephoneNumber'));
//$search_result_attributes ...
}
function GetValue($key,$index) {
$value = null;
if (! isset($this->default->$key))
pla_error("A call was made to GetValue requesting [$key] that isnt predefined.");
else
$default = $this->default->$key;
if (! isset($default[$index]))
pla_error("Requesting a index [$index] that isnt predefined.");
else
$default = $default[$index];
if (isset($default['default']))
$value = $default['default'];
if (isset($this->custom->$key)) {
$custom = $this->custom->$key;
if (isset($custom[$index]))
$value = $custom[$index];
}
//print "Returning [$value] for key [$key], index [$index]<BR>";
return $value;
}
/**
* Function to check and warn about any unusual defined variables.
*/
function CheckCustom() {
if (isset($this->custom)) {
foreach ($this->custom as $masterkey => $masterdetails) {
if (isset($this->default->$masterkey)) {
if (! is_array($masterdetails))
pla_error("Error in configuration file, [$masterdetails] should be an ARRAY.");
foreach ($masterdetails as $key => $value) {
# Test that the key is correct.
if (! in_array($key,array_keys($this->default->$masterkey)))
pla_error("Error in configuration file, [$key] has not been defined as a PLA configurable variable.");
# Test if its should be an array or not.
if (is_array($this->default->{$masterkey}[$key]['default']) && ! is_array($value))
pla_error("Error in configuration file, {$masterkey}['$key'] SHOULD be an array of values.");
if (! is_array($this->default->{$masterkey}[$key]['default']) && is_array($value))
pla_error("Error in configuration file, {$masterkey}['$key'] should NOT be an array of values.");
}
} else {
pla_error("Error in configuration file, [$masterkey] has not been defined as a PLA MASTER configurable variable.");
}
}
}
}
}
# Define our configuration variable.
$config = new Config;
require (CONFDIR.'config.php');
?>

200
lib/custom_functions.php Normal file
View File

@@ -0,0 +1,200 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/custom_functions.php,v 1.8 2005/03/05 06:27:06 wurley Exp $
/**
* CUSTOM_FUCTIONS has been DEPRECIATED, please use the hooks functions now.
* Let the phpLDAPadmin developers know if you REALLY need this - it will be removed
* in future releases.
*
* custom_functions.php:
*
* This file is full of functions (callbacks really) that are
* meant to be filled in by users of phpLDAPadmin (you). These functions
* are called as the result of a phpLDAPadmin event, like adding
* a new entry, deleting an entry, changing an attribute value, etc.
* Consider this concept an attempt to provide something like SQL
* triggers for LDAP users.
*
* This can be very handy, for example, for system administrators
* who want to execute custom code after a user is created or deleted.
*
* These functions generally have 2 parameters, $server_id and $dn:
*
* 1. $server_id.
* The $server_id can be used to connect to the server using
* pla_ldap_connect( $server_id ) to fetch additional information about
* the entry being deleted. It can also be used to call
* get_object_attrs( $server_id, $dn ) to fetch the entry's attributes.
*
* 2. $dn
* The dn is provided so users can determine where in the LDAP tree
* this entry resides and act accordingly. For example, if the DN
* contains "ou=development", you may want to act differently than
* if it contains "ou=accounting".
*
* Types of callback functions:
*
* These callbacks generally fall into two categories: "pre" and "post",
* "pre" callbacks run before an event has occurred and their return
* value (true or false) is used to decide whether to allow the event
* to proceed. "post" callbacks run after an event has occurred and
* their return value (void) is ignored.
*
* NOTE: These custom callbacks are NOT executed for LDIF imports.
*
* ALSO NOTE: These callbacks are responsible for printing out error
* messages. The calling code will die silently without notifying
* the user why. YOU are responsible for creating output here.
*
* TODO: This section outlines events that phpLDAPadmin does not yet
* support. This list includes:
* - ldap_mod_add (ie, adding a new value to a multi-valued attribute)
* - ldap_mod_del (ie, deleting a value from a multi-valued attribute
* or deleting an attribute from an entry)
* - ldap_rename (ie, renaming an entry's RDN)
*
* DONE: This section lists events that phpLDAPadmin *does* support.
* This list includes:
* - ldap_add (ie, creating new entries)
* - ldap_delete (ie, removing entries)
* - ldap_modify (ie, changing the value of an attribute, for both
* multi- and single-valued attributes)
* @deprecated
* @see hooks.php
* @package phpLDAPadmin
*/
/*
* This function is executed before modifying an entry's
* attribute. Unlike preAttrModify, this function's
* return value is ignored. In addition to the standard
* $server_id and $dn paramaters, this function also
* gives you the attribute name ($attr_name), and the new
* value that the attribute will have ($new_value). $new_value
* may be a string or an array of strings.
*/
function postAttrModify( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
//
// A very simple (and lame) example:
// if( 0 == strcasecmp( $attr_name, "userPassword" ) ) {
// mail( "user@example.com", "Password change notification",
// "User '$dn' has changed their password." );
// }
}
/*
* This function is executed before modifying an entry's
* attribute. If it returns true, the entry is modified.
* If it returns false, the entry is not modified.
* In addition to the standard $server_id and $dn params,
* this function also gives you the attribute name ($attr_name)
* and the new value that the attribute will have ($new_value).
* $new_value may be a string or an array of strings.
* @deprecated
*/
function preAttrModify( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
return true;
}
/*
* This function is executed before adding an entry's
* attribute. If it returns true, the entry is added.
* If it returns false, the entry is not added.
* In addition to the standard $server_id and $dn params,
* this function also gives you the attribute name ($attr_name)
* and the new value that the attribute will have ($new_value).
* $new_value may be a string or an array of strings.
* @deprecated
*/
function preAttrAdd( $server_id, $dn, $attr_name, $new_value )
{
// Fill me in
return true;
}
/*
* This function is executed after an entry is created.
* Unlike preEntryCreate(), this function's return
* value is ignored. This is very handy for executing
* custom code after creating a user account. For example,
* one may wish to create the user's home directory.
* See the documentation for preEntryCreate() below for
* the description of the $attrs parameter.
* @deprecated
*/
function postEntryCreate( $server_id, $dn, $attrs )
{
// Fill me in
//
// A very simple example:
// if( preg_match( "/^uid=(\w+),/", $dn, $user_name ) ) {
// $user_name = $user_name[1];
// mkdir( "/home/$user_name" );
// } else {
// // not a user account
// }
}
/*
* This function is executed before an entry is created.
* If it returns true, the entry is created, if false is
* returned, the entry is not created. This function has
* the additional parameters, $attrs, which is an assoc-
* iative array of attribute/vale pairs of the same form
* expected by ldap_add(), example:
*
* Array (
* [objectClass] => Array (
* [0] => top
* [1] => person
* [2] => inetOrgPerson
* )
* [cn] => John
* [sn] => Doe
* ...
* )
*
* @deprecated
*/
function preEntryCreate( $server_id, $dn, $attrs )
{
// Fill me in
return true;
}
/*
* This function is executed before an entry is deleted.
* If it returns true, the entry is deleted, if false
* is returned, the entry is not deleted.
* @deprecated
*/
function preEntryDelete( $server_id, $dn )
{
// Fill me in
return true;
}
/*
* This function is executed after an entry is deleted.
* Unlike preEntryDelete(), this function's return
* value is ignored.
* @deprecated
*/
function postEntryDelete( $server_id, $dn )
{
// Fill me in
}
/**
* This function is called, after a new session is initilaized
* @deprecated
*/
function postSessionInit()
{
// Fill me in
}
?>

114
lib/emuhash_functions.php Normal file
View File

@@ -0,0 +1,114 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/emuhash_functions.php,v 1.6 2005/03/25 00:59:48 wurley Exp $
/**
* @package other
*/
/*******************************************************************************
* emuhash - partly emulates the php mhash functions
* version: 2004040701
*
* (c) 2004 - Simon Matter <simon.matter@invoca.ch>
*
* 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
*
******************************************************************************/
/******************************************************************************/
/* Do we have builtin mhash support in this PHP version ? */
/******************************************************************************/
if( ! function_exists( 'mhash' ) && ! function_exists( 'mhash_keygen_s2k' ) ) {
if( ! isset( $emuhash_openssl ) )
$emuhash_openssl = '/usr/bin/openssl';
// don't create mhash functions if we don't have a working openssl
if( ! file_exists( $emuhash_openssl ) )
unset( $emuhash_openssl );
elseif ( function_exists( 'is_executable' ) && ! is_executable( $emuhash_openssl ) )
unset( $emuhash_openssl );
else {
if( ! isset( $emuhash_temp_dir ) )
$emuhash_temp_dir = '/tmp';
/******************************************************************************/
/* Define constants used in the mhash emulation code. */
/******************************************************************************/
define('MHASH_MD5', 'md5');
define('MHASH_SHA1', 'sha1');
define('MHASH_RIPEMD160', 'rmd160');
/******************************************************************************/
/* Functions to emulate parts of php-mash. */
/******************************************************************************/
function openssl_hash( $openssl_hash_id, $password_clear ) {
global $emuhash_openssl, $emuhash_temp_dir;
$current_magic_quotes = get_magic_quotes_runtime();
set_magic_quotes_runtime( 0 );
$tmpfile = tempnam( $emuhash_temp_dir, "emuhash" );
$pwhandle = fopen( $tmpfile, "w" );
if( ! $pwhandle )
pla_error( "Unable to create a temporary file '$tmpfile' to create hashed password" );
fwrite( $pwhandle, $password_clear );
fclose( $pwhandle );
$cmd = $emuhash_openssl . ' ' . $openssl_hash_id . ' -binary < ' . $tmpfile;
$prog = popen( $cmd, "r" );
$pass = fread( $prog, 1024 );
pclose( $prog );
unlink( $tmpfile );
set_magic_quotes_runtime( $current_magic_quotes );
return $pass;
}
function mhash( $hash_id, $password_clear ) {
switch( $hash_id ) {
case MHASH_MD5:
$emuhash = openssl_hash( MHASH_MD5, $password_clear );
break;
case MHASH_SHA1:
$emuhash = openssl_hash( MHASH_SHA1, $password_clear );
break;
case MHASH_RIPEMD160:
$emuhash = openssl_hash( MHASH_RIPEMD160, $password_clear );
break;
default:
$emuhash = FALSE;
}
return $emuhash;
}
function mhash_keygen_s2k( $hash_id, $password_clear, $salt, $bytes ) {
return substr(pack("H*", bin2hex(mhash($hash_id, ($salt . $password_clear)))), 0, $bytes);
}
/******************************************************************************/
}
}
?>

875
lib/export_functions.php Executable file
View File

@@ -0,0 +1,875 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/export_functions.php,v 1.30 2005/09/04 16:17:08 wurley Exp $
/**
* Fuctions and classes for exporting ldap entries to others formats
* (LDIF,DSML,..)
* An example is provided at the bottom of this file if you want implement yours. *
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
* @see export.php and export_form.php
*/
/**
*/
// include common configuration definitions
include('./common.php');
// registry for the exporters
$exporters = array();
$exporters[] = array(
'output_type'=>'ldif',
'desc' => 'LDIF',
'extension' => 'ldif'
);
$exporters[] = array(
'output_type'=>'dsml',
'desc' => 'DSML V.1',
'extension' => 'xml'
);
$exporters[] = array(
'output_type'=>'vcard',
'desc' => 'VCARD 2.1',
'extension' => 'vcf'
);
$exporters[] = array(
'output_type'=>'csv',
'desc' => $lang['csv_spreadsheet'],
'extension' => 'csv'
);
/**
* This class encapsulate informations about the ldap server
* from which the export is done.
* The following info are provided within this class:
*
* $server_id: the id of the server.
* $base_dn: if the source of the export is the ldap server,
* it indicates the base dn of the search.
* $query_filter: if the source of the export is the ldap server,
* it indicates the query filter for the search.
* $scope: if the source of the export is the ldap server,
* it indicates the scope of the search.
*
* @package phpLDAPadmin
*/
class LdapExportInfo {
var $base_dn;
var $query_filter;
var $scope;
/**
* Create a new LdapExportInfo object
*
* @param int $server_id the server id
* @param String $base_dn the base_dn for the search in a ldap server
* @param String $query_filter the query filter for the search
* @param String $scope the scope of the search in a ldap server
*/
function LdapExportInfo($server_id,$base_dn = NULL,$query_filter = NULL,$scope = NULL){
global $ldapservers;
$this->ldapserver = $ldapservers->Instance($server_id);
$this->ldapserver->base_dn = $base_dn;
$this->ldapserver->query_filter = $query_filter;
$this->ldapserver->scope = $scope;
}
}
/**
* This class represents the base class of all exporters
* It can be subclassed directly if your intend is to write
* a source exporter(ie. it will act only as a decoree
* which will be wrapped by an another exporter.)
* If you consider writting an exporter for filtering data
* or directly display entries, please consider subclass
* the PlaExporter
*
* @see PlaExporter
* @package phpLDAPadmin
*/
class PlaAbstractExporter{
/**
* Return the number of entries
* @return int the number of entries to be exported
*/
function pla_num_entries(){}
/**
* Return true if there is some more entries to be processed
* @return bool if there is some more entries to be processed
*/
function pla_has_entry(){}
/**
* Return the entry as an array
* @return array an entry as an array
*/
function pla_fetch_entry_array(){}
/**
* Return the entry as an Entry object
* @return Entry an entry as an Entry Object
*/
function pla_fetch_entry_object(){}
/**
* Return a PlaLdapInfo Object
* @return LdapInfo Object with info from the ldap serveur
*/
function pla_get_ldap_info(){}
/**
* May be call when the processing is finished
* and to free some ressources.
* @return bool true or false if any errors is encountered
*/
function pla_close(){}
}// end PlaAbstractExporter
/**
* PlaExporter acts a wrapper around another exporter.
* In other words, it will act as a decorator for another decorator
*
* @package phpLDAPadmin
*/
class PlaExporter extends PlaAbstractExporter{
// the default CRLN
var $br="\n";
// the wrapped $exporter
var $exporter;
/**
* Constructor
* @param source $source the decoree for this exporter
*/
function PlaExporter( $source ){
$this->exporter = $source;
}
/**
* Return the number of entries
* @return int the number of entries to be exported
*/
function pla_num_entries(){
return $this->exporter->pla_num_entries();
}
/**
* Return true if there is some more entries to be processed
* @return bool if there is some more entries to be processed
*/
function pla_has_entry(){
return $this->exporter->pla_has_entry();
}
/**
* Return the entry as an array
* @return array an entry as an array
*/
function pla_fetch_entry_array(){
return $this->exporter->pla_fetch_entry_array();
}
/**
* Return the entry as an Entry object
* @return Entry an entry as an Entry Object
*/
function pla_fetch_entry_object(){
return $this->exporter->pla_fetch_entry_object();
}
/**
* Return a PlaLdapInfo Object
* @return LdapInfo Object with info from the ldap serveur
*/
function pla_get_ldap_info(){
return $this->exporter->pla_get_ldap_info();
}
/**
* May be call when the processing is finished
* and to free some ressources.
* @return bool false if any errors are encountered,false otherwise
*/
function pla_close(){
return $this->exporter->pla_close();
}
/**
* Helper method to check if the attribute value should be base 64 encoded.
* @param String $str the string to check.
* @return bool true if the string is safe ascii, false otherwise.
*/
function is_safe_ascii( $str ){
for( $i=0; $i<strlen($str); $i++ )
if( ord( $str{$i} ) < 32 || ord( $str{$i} ) > 127 )
return false;
return true;
}
/**
* Abstract method use to export data.
* Must be implemented in a sub-class if you write an exporter
* which export data.
* Leave it empty if you write a sub-class which do only some filtering.
*/
function export(){}
/**
* Set the carriage return /linefeed for the export
* @param String $br the CRLF to be set
*/
function setOutputFormat( $br ){
$this->br = $br;
}
}// end PlaExporter
/**
* Export data from a ldap server
* @extends PlaAbstractExporter
* @package phpLDAPadmin
*/
class PlaLdapExporter extends PlaAbstractExporter{
var $entry_id;
var $results;
var $server_id;
var $scope;
var $entry_array;
var $num_entries;
var $ldap_info;
var $queryFilter;
var $hasNext;
var $attributes;
/**
* Create a PlaLdapExporter object.
* @param int $server_id the server id
* @param String $queryFilter the queryFilter for the export
* @param String $base_dn the base_dn for the data to export
* @param String $scope the scope for export
*/
function PlaLdapExporter( $server_id , $queryFilter , $base_dn , $scope, $attributes){
global $lang, $config;
$this->scope = $scope;
$this->base_dn = $base_dn;
$this->server_id = $server_id;
$this->queryFilter = $queryFilter;
// infos for the server
$this->ldap_info = new LdapExportInfo($server_id,$base_dn,$queryFilter,$scope);
// boolean to check if there is more entries
$this->hasNext = 0;
// boolean to check the state of the connection
$this->attributes = $attributes;
// connect to the server
$this->ds = $this->ldap_info->ldapserver->connect();
// @todo test whether we need to call pla_ldap_connection_is_error here.
//pla_ldap_connection_is_error( $this->ds );
// get the data to be exported
if( $this->scope == 'base' )
$this->results = @ldap_read( $this->ds, $this->base_dn, $this->queryFilter,$this->attributes,
0, 0, 0, $config->GetValue('deref','export'));
elseif( $this->scope == 'one' )
$this->results = @ldap_list( $this->ds, $this->base_dn, $this->queryFilter, $this->attributes,
0, 0, 0, $config->GetValue('deref','export'));
else // scope == 'sub'
$this->results = @ldap_search( $this->ds, $this->base_dn, $this->queryFilter, $this->attributes,
0, 0, 0, $config->GetValue('deref','export'));
// if no result, there is a something wrong
if( ! $this->results )
pla_error( $lang['error_performing_search'], ldap_error( $this->ds ), ldap_errno( $this->ds ) );
// get the number of entries to be exported
$this->num_entries = @ldap_count_entries( $this->ds,$this->results );
if( $this->entry_id = @ldap_first_entry( $this->ds,$this->results ) ){
$this->hasNext = 1;
}
}//end constructor
/**
* Return the entry as an array
* @return array an entry as an array
*/
function pla_fetch_entry_array(){
return $this->entry_array;
}
/**
* Return the entry as an Entry object
* @return Entry an entry as an Entry Object
*/
function pla_fetch_entry_object(){
// to do
}
/**
* Return a PlaLdapInfo Object
* @return LdapInfo Object with info from the ldap serveur
*/
function pla_get_ldap_info(){
return $this->ldap_info->ldapserver;
}
/**
* Return the number of entries
* @return int the number of entries to be exported
*/
function pla_num_entries(){
return $this->num_entries;
}
/**
* Return true if there is some more entries to be processed
* @return bool if there is some more entries to be processed
*/
function pla_has_entry(){
if( $this->hasNext ){
unset( $this->entry_array );
$dn = @ldap_get_dn( $this->ds,$this->entry_id );
$this->entry_array['dn'] = $dn;
//get the attributes of the entry
$attrs = @ldap_get_attributes($this->ds,$this->entry_id);
if( $attr = @ldap_first_attribute( $this->ds,$this->entry_id,$attrs ) ){
//iterate over the attributes
while( $attr ){
if( is_attr_binary( $this,$attr ) ){
$this->entry_array[$attr] = @ldap_get_values_len( $this->ds,$this->entry_id,$attr );
}
else{
$this->entry_array[$attr] = @ldap_get_values( $this->ds,$this->entry_id,$attr );
}
unset( $this->entry_array[$attr]['count'] );
$attr = @ldap_next_attribute( $this->ds,$this->entry_id,$attrs );
}// end while attr
if(!$this->entry_id = @ldap_next_entry( $this->ds,$this->entry_id ) ){
$this->hasNext = 0;
}
}// end if attr
return true;
}
else{
$this->pla_close();
return false;
}
}
/**
* May be call when the processing is finished
* and to free some ressources.
* @return bool true or false if any errors is encountered
* @todo This could break something, so need to add a method to LDAPServer to close connection and reset $connected.
*/
function pla_close(){
// if($this->ldap_info->connected){
// return @ldap_close( $this->ds );
// }
// else{
// return true;
// }
}
} // end PlaLdapExporter
/**
* Export entries to ldif format
* @extends PlaExporter
* @package phpLDAPadmin
*/
class PlaLdifExporter extends PlaExporter{
// variable to keep the count of the entries
var $counter = 0;
// the maximum length of the ldif line
var $MAX_LDIF_LINE_LENGTH = 76;
/**
* Create a PlaLdifExporter object
* @param PlaAbstractExporter $exporter the source exporter
*/
function PlaLdifExporter( $exporter ){
$this->exporter = $exporter;
}
/**
* Export entries to ldif format
*/
function export(){
$pla_ldap_info = $this->pla_get_ldap_info();
$this->displayExportInfo($pla_ldap_info);
//While there is an entry, fecth the entry as an array
while($this->pla_has_entry()){
$entry = $this->pla_fetch_entry_array();
$this->counter++;
// display comment before each entry
global $lang;
$title_string = "# " . $lang['entry'] . " " . $this->counter . ": " . $entry['dn'] ;
if( strlen( $title_string ) > $this->MAX_LDIF_LINE_LENGTH-3 )
$title_string = substr( $title_string, 0, $this->MAX_LDIF_LINE_LENGTH-3 ) . "...";
echo "$title_string$this->br";
// display dn
if( $this->is_safe_ascii( $entry['dn'] ))
$this->multi_lines_display("dn: ". $entry['dn']);
else
$this->multi_lines_display("dn:: " . base64_encode( $entry['dn'] ));
array_shift($entry);
// display the attributes
foreach( $entry as $key => $attr ){
foreach( $attr as $value ){
if( !$this->is_safe_ascii($value) || is_attr_binary($pla_ldap_info,$key ) ){
$this->multi_lines_display( $key.":: " . base64_encode( $value ) );
}
else{
$this->multi_lines_display( $key.": ".$value );
}
}
}// end foreach $entry
echo $this->br;
// flush every 5th entry (sppeds things up a bit)
if( 0 == $this->counter % 5 )
flush();
}
}
// display info related to this export
function displayExportInfo($pla_ldap_info){
global $lang;
echo "version: 1$this->br$this->br";
echo "# " . sprintf( $lang['ldif_export_for_dn'], $pla_ldap_info->base_dn ) . $this->br;
echo "# " . sprintf( $lang['generated_on_date'], date("F j, Y g:i a") ) . $this->br;
echo "# " . $lang['server'] . ": " .$pla_ldap_info->name . " (" . $pla_ldap_info->host . ")" . $this->br;
echo "# " . $lang['search_scope'] . ": " . $pla_ldap_info->scope . $this->br;
echo "# " . $lang['search_filter'] . ": " . $pla_ldap_info->query_filter . $this->br;
echo "# " . $lang['total_entries'] . ": " . $this->pla_num_entries() . $this->br;
echo $this->br;
}
/**
* Helper method to wrap ldif lines
* @param String $str the line to be wrapped if needed.
*/
function multi_lines_display( $str ){
$length_string = strlen($str);
$max_length = $this->MAX_LDIF_LINE_LENGTH;
while ($length_string > $max_length){
echo substr($str,0,$max_length).$this->br." ";
$str= substr($str,$max_length,$length_string);
$length_string = strlen($str);
// need to do minus one to align on the right
// the first line with the possible following lines
// as these will have an extra space
$max_length = $this->MAX_LDIF_LINE_LENGTH-1;
}
echo $str."".$this->br;
}
}
/**
* Export entries to DSML v.1
* @extends PlaExporter
* @package phpLDAPadmin
*/
class PlaDsmlExporter extends PlaExporter{
//not in use
var $indent_step = 2;
var $counter = 0;
/**
* Create a PlaDsmlExporter object
* @param PlaAbstractExporter $exporter the decoree exporter
*/
function PlaDsmlExporter( $exporter ){
$this->exporter = $exporter;
}
/**
* Export the entries to DSML
*/
function export(){
global $lang;
$pla_ldap_info = $this->pla_get_ldap_info();
// not very elegant, but do the job for the moment as we have just 4 level
$directory_entries_indent = " ";
$entry_indent= " ";
$attr_indent = " ";
$attr_value_indent = " ";
// print declaration
echo "<?xml version=\"1.0\"?>$this->br";
// print root element
echo "<dsml>$this->br";
// print info related to this export
echo "<!-- " . $this->br;
echo "# " . sprintf( $lang['dsml_export_for_dn'], $pla_ldap_info->base_dn ) . $this->br;
echo "# " . sprintf( $lang['generated_on_date'], date("F j, Y g:i a") ) . $this->br;
echo "# " . $lang['server'] . ": " . $pla_ldap_info->name . " (" . $pla_ldap_info->host . ")" . $this->br;
echo "# " . $lang['search_scope'] . ": " . $pla_ldap_info->scope . $this->br;
echo "# " . $lang['search_filter'] . ": " . $pla_ldap_info->query_filter . $this->br;
echo "# " . $lang['total_entries'] . ": " . $this->pla_num_entries() . $this->br;
echo "-->" . $this->br;
echo $directory_entries_indent."<directory-entries>$this->br";
//While there is an entry, fetch the entry as an array
while($this->pla_has_entry()){
$entry = $this->pla_fetch_entry_array();
$this->counter++;
// display dn
echo $entry_indent."<entry dn=\"". htmlspecialchars( $entry['dn'] ) ."\">".$this->br;
array_shift($entry);
// echo the objectclass attributes first
if(isset($entry['objectClass'])){
echo $attr_indent."<objectClass>".$this->br;
foreach($entry['objectClass'] as $ocValue){
echo $attr_value_indent."<oc-value>$ocValue</oc-value>".$this->br;
}
echo $attr_indent."</objectClass>".$this->br;
unset($entry['objectClass']);
}
$binary_mode = 0;
// display the attributes
foreach($entry as $key=>$attr){
echo $attr_indent."<attr name=\"$key\">".$this->br;
// if the attribute is binary, set the flag $binary_mode to true
$binary_mode = is_attr_binary($pla_ldap_info,$key)?1:0;
foreach($attr as $value){
echo $attr_value_indent."<value>".($binary_mode?base64_encode( $value): htmlspecialchars( $value ) )."</value>".$this->br;
}
echo $attr_indent."</attr>".$this->br;
}// end foreach $entry
echo $entry_indent."</entry>".$this->br;
// flush every 5th entry (speeds things up a bit)
if( 0 == $this->counter % 5 )
flush();
}
echo $directory_entries_indent."</directory-entries>$this->br";
echo "</dsml>".$this->br;
}
}
/**
* @package phpLDAPadmin
*/
class PlaVcardExporter extends PlaExporter{
// mappping one to one attribute
var $vcardMapping = array('cn' => 'FN',
'title' => 'TITLE',
'homePhone' => 'TEL;HOME',
'mobile' => 'TEL;CELL',
'mail' => 'EMAIL;Internet',
'labeledURI' =>'URL',
'o' => 'ORG',
'audio' => 'SOUND',
'facsmileTelephoneNumber' =>'TEL;WORK;HOME;VOICE;FAX',
'jpegPhoto' => 'PHOTO;ENCODING=BASE64',
'businessCategory' => 'ROLE',
'description' => 'NOTE'
);
var $deliveryAddress = array("postOfficeBox",
"street",
"l",
"st",
"postalCode",
"c");
function PlaVcardExporter($exporter){
$this->exporter = $exporter;
}
/**
* When doing an exporter, the method export need to be overriden.
* A basic implementation is provided here. Customize to your need
**/
function export(){
// With the method pla->get_ldap_info,
// you have access to some values related
// to you ldap server
$ldap_info = $this->pla_get_ldap_info();
$base_dn = $ldap_info->base_dn;
$server_id = $ldap_info->server_id;
$scope = $ldap_info->scope;
$server_name = $ldap_info->name;
$server_host = $ldap_info->host;
while( $this->pla_has_entry() ){
$entry = $this->pla_fetch_entry_array();
//fetch the dn
$dn = $entry['dn'];
unset( $entry['dn'] );
// check the attributes needed for the delivery address
// field
$addr = "ADR:";
foreach( $this->deliveryAddress as $attr_name ){
if( isset( $entry[$attr_name] ) ){
$addr .= $entry[$attr_name][0];
unset($entry[$attr_name]);
}
$addr .= ';';
}
echo "BEGIN:VCARD$this->br";
// loop for the attributes
foreach( $entry as $attr_name=>$attr_values ){
// if an attribute of the ldap entry exist
// in the mapping array for vcard
if( isset( $this->vcardMapping[$attr_name] ) ){
// case of organisation. Need to append the
// possible ou attribute
if( 0 == strcasecmp( $attr_name , 'o' )){
echo $this->vcardMapping[$attr_name].":$attr_values[0]";
if( isset($entry['ou'] ) )
foreach( $entry['ou'] as $ou_value ){
echo ";$ou_value";
}
}
// the attribute is binary. (to do : need to fold the line)
else if( 0 == strcasecmp( $attr_name,'audio') || 0 == strcasecmp( $attr_name,'jpegPhoto') ){
echo $this->vcardMapping[$attr_name].":$this->br";
echo " ".base64_encode( $attr_values[0]);
}
/* else if( $attr_name == "sn"){
echo $this->vcardMapping[$attr_name].":$attr_values[0]";
}
elseif( $attr_name == "homePostalAddress"){
}*/
// else just print the value with the relevant attribute name
else{
echo $this->vcardMapping[$attr_name].":$attr_values[0]";
}
echo $this->br;
}
}
// need to check
echo "UID:$dn";
echo $this->br;
echo "VERSION:2.1";
echo $this->br;
echo $addr;
echo $this->br;
echo "END:VCARD";
echo $this->br;
}// end while
}
}
/**
* Export to cvs format
*
* @author Glen Ogilvie
* @package phpLDAPadmin
*/
class PlaCSVExporter extends PlaExporter{
function PlaCSVExporter($exporter){
$this->exporter = $exporter;
}
/**
* When doing an exporter, the method export need to be overriden.
* A basic implementation is provided here. Customize to your need
**/
var $separator = ",";
var $qualifier = '"';
var $multivalue_separator = " | ";
var $escapeCode = '"';
function export(){
// With the method pla->get_ldap_info,
// you have access to some values related
// to you ldap server
$ldap_info = $this->pla_get_ldap_info();
$base_dn = $ldap_info->base_dn;
$server_id = $ldap_info->server_id;
$scope = $ldap_info->scope;
$server_name = $ldap_info->name;
$server_host = $ldap_info->host;
$entries = array();
$headers = array();
// go thru and find all the attribute names first. This is needed, because, otherwise we have
// no idea as to which search attributes were actually populated with data
while( $this->pla_has_entry() ) {
$entry = $this->pla_fetch_entry_array();
foreach (array_keys($entry) as $key) {
if (!in_array($key, $headers))
array_push($headers,$key);
}
array_push($entries, $entry);
}
$num_headers = count($headers);
// print out the headers
for ($i = 0; $i < $num_headers; $i++) {
echo $this->qualifier. $headers[$i].$this->qualifier;
if ($i < $num_headers-1)
echo $this->separator;
}
array_shift($headers);
$num_headers--;
echo $this->br;
// loop on every entry
foreach ($entries as $entry) {
//print the dn
$dn = $entry['dn'];
unset( $entry['dn'] );
echo $this->qualifier. $this->LdapEscape($dn).$this->qualifier.$this->separator;
// print the attributes
for($j=0;$j<$num_headers;$j++){
$attr_name = $headers[$j];
echo $this->qualifier;
if (key_exists($attr_name, $entry)) {
$binary_attribute = is_attr_binary( $ldap_info, $attr_name )?1:0;
$attr_values = $entry[$attr_name];
$num_attr_values = count( $attr_values );
for( $i=0 ; $i<$num_attr_values; $i++){
if($binary_attribute)
echo base64_encode($attr_values[$i]);
else
echo $this->LdapEscape($attr_values[$i]);
if($i < $num_attr_values - 1)
echo $this->multivalue_separator;
}
}// end if key
echo $this->qualifier;
if( $j < $num_headers - 1 )
echo $this->separator;
}
echo $this->br;
}
}//end export
// function to escape data, where the qualifier happens to also
// be in the data.
function LdapEscape ($var) {
return str_replace($this->qualifier, $this->escapeCode.$this->qualifier, $var);
}
}
/**
* @package phpLDAPadmin
*/
class MyCustomExporter extends PlaExporter{
function MyCutsomExporter($exporter){
$this->exporter = $exporter;
}
/**
* When doing an exporter, the method export need to be overriden.
* A basic implementation is provided here. Customize to your need
**/
function export(){
// With the method pla->get_ldap_info,
// you have access to some values related
// to you ldap server
$ldap_info = $this->pla_get_ldap_info();
$base_dn = $ldap_info->base_dn;
$server_id = $ldap_info->server_id;
$scope = $ldap_info->scope;
$server_name = $ldap_info->name;
$server_host = $ldap_info->host;
// Just a simple loop. For each entry
// do your custom export
// see PlaLdifExporter or PlaDsmlExporter as an example
while( $this->pla_has_entry() ){
$entry = $this->pla_fetch_entry_array();
//fetch the dn
$dn = $entry['dn'];
unset( $entry['dn'] );
// loop for the attributes
foreach( $entry as $attr_name=>$attr_values ){
foreach( $attr_values as $value ){
// simple example
// echo "Attribute Name:".$attr_name;
// echo " - value:".$value;
// echo $this->br;
}
}
}// end while
}
}
?>

4232
lib/functions.php Normal file

File diff suppressed because it is too large Load Diff

186
lib/hooks.php Normal file
View File

@@ -0,0 +1,186 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/hooks.php,v 1.6 2005/04/15 13:16:59 wurley Exp $
/**
* Functions related to hooks management.
*
* @author Benjamin Drieu <benjamin.drieu@fr.alcove.com> and Alcôve
* @package phpLDAPadmin
*
* 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
*/
if ( ! isset($hooks) ) {
/** This variable contains all hooks that are defined. */
$hooks = array();
}
/**
* Compares two arrays by numerically comparing their 'prority'
* value. Standard `cmp-like' function.
*
* @param a First element to compare.
* @param b Second element to compare.
*
* @return -1 if priority of first element is smaller than second
* element priority. 1 otherwise.
*/
function sort_array_by_priority ( $a, $b ) {
return ( ( $a['priority'] < $b['priority'] ) ? -1 : 1 );
}
/**
* Runs procedures attached to a hook.
*
* @param hook_name Name of hook to run.
* @param args Array of optional arguments set by
* phpldapadmin. It is normally in a form known
* by call_user_func_array() :
* <pre>[ 'server_id' => 0,
* 'dn' => 'uid=epoussa,ou=tech,o=corp,o=fr' ]</pre>
*
* @return true if all procedures returned true, false otherwise.
*/
function run_hook ( $hook_name, $args ) {
global $hooks;
$debug = 0;
syslog_debug ( "Running hook $hook_name." );
if ( ! array_key_exists ( $hook_name, $hooks ) ) {
syslog_notice ( "Hook '$hook_name' not defined !\n" );
return true;
}
unset ( $rollbacks );
$rollbacks = array ();
reset ( $hooks[$hook_name] );
/** Execution of procedures attached is done using a numeric order
* since all procedures have been attached to the hook with a
* numerical weight. */
while ( list ( $key, $hook ) = each ( $hooks[$hook_name] ) ) {
array_push ( $rollbacks, $hook['rollback_function'] );
syslog_debug ( "Calling " . $hook['hook_function'] . "\n" );
$result = call_user_func_array ( $hook['hook_function'], $args );
syslog_notice ( "Called " . $hook['hook_function'] . "\n" );
/** If a procedure fails, its optional rollback is executed with
* the same arguments. After that, all rollbacks from
* previously executed procedures are executed in the reverse
* order. */
if ( $result != true ) {
syslog_debug ( "Function " . $hook['hook_function'] . " returned $result\n" );
while ( $rollbacks ) {
$rollback = array_pop ( $rollbacks );
if ( $rollback != false ) {
syslog_debug ( "Executing rollback $rollback\n" );
call_user_func_array ( $rollback, $args );
}
}
return false;
}
}
return true;
}
/**
* Adds a procedure to a hook for later execution.
*
* @param hook_name Name of the hook.
* @param priority Numeric priority. Lowest means
* procedure will be executed before.
* @param hook_function Name of the php function called upon
* hook trigger.
* @param rollback_function Name of the php rollback function
* called upon failure.
*/
function add_hook ( $hook_name, $priority, $hook_function, $rollback_function ) {
global $hooks;
if ( ! array_key_exists ( $hook_name, $hooks ) ) {
$hooks[$hook_name] = array();
}
array_push ( $hooks[$hook_name], array ( 'priority' => $priority, 'hook_function' => $hook_function,
'rollback_function' => $rollback_function ) );
uasort ( $hooks[$hook_name], "sort_array_by_priority" );
}
/**
* Removes a procedure from a hook, based on a filter.
*
* @param hook_name Name of the hook.
* @param priority Numeric priority. If set, all
* procedures of that priority will be
* removed.
* @param hook_function Name of the procedure function. If
* set, all procedures that call this
* function will be removed.
* @param rollback_function Name of the php rollback function
* called upon failure. If set, all
* procedures that call this function
* as a rollback will be removed.
*/
function remove_hook ( $hook_name, $priority, $hook_function, $rollback_function ) {
global $hooks;
if ( array_key_exists ( $hook_name, $hooks ) ) {
reset ( $hooks[$hook_name] );
while ( list ( $key, $hook ) = each ( $hooks[$hook_name] ) ) {
if ( ( $priority >= 0 && $priority == $hook['priority'] ) ||
( $hook_function && $hook_function == $hook['hook_function'] ) ||
( $rollback_function && $rollback_function == $hook['rollback_function'] ) ) {
unset ( $hooks[$hook_name][$key] );
}
}
}
}
/**
* Removes all procedures from a hook.
*
* @param hook_name Name of hook to clear.
*/
function clear_hooks ( $hook_name ) {
global $hooks;
if ( array_key_exists ( $hook_name, $hooks ) ) {
unset ( $hooks[$hook_name] );
}
}
/* Evaluating user-made hooks */
if ( is_dir('hooks') ) {
$dir = dir ('hooks');
while (false !== ($entry = $dir -> read() ) ) {
if ( is_file ("hooks/$entry") and eregi ('php[0-9]?$', $entry) ) {
require_once "hooks/$entry";
}
}
$dir -> close();
}
?>

95
lib/ldap_error_codes.txt Normal file
View File

@@ -0,0 +1,95 @@
0x00 LDAP_SUCCESS "The operation completed successfully."
0x01 LDAP_OPERATIONS_ERROR "An operations error occurred. This is
typically the result of an internal error on your LDAP server."
0x02 LDAP_PROTOCOL_ERROR "A protocol violation was detected."
0x03 LDAP_TIMELIMIT_EXCEEDED "The operation timed out waiting to complete."
0x04 LDAP_SIZELIMIT_EXCEEDED "The LDAP server refused to serve such a large result set."
0x05 LDAP_COMPARE_FALSE "A compare operation returned false."
0x06 LDAP_COMPARE_TRUE "A compare operation returned true."
0x07 LDAP_AUTH_METHOD_NOT_SUPPORTED "The authentication method you specified is not supported by
the LDAP server."
0x08 LDAP_STRONG_AUTH_REQUIRED "This LDAP server requires strong (encrypted) authentication,
not clear text."
0x09 LDAP_PARTIAL_RESULTS "The result set received is a partial result set."
0x0a LDAP_REFERRAL ""
0x0b LDAP_ADMINLIMIT_EXCEEDED ""
0x0c LDAP_UNAVAILABLE_CRITICAL_EXTENSION ""
0x0d LDAP_CONFIDENTIALITY_REQUIRED ""
0x0e LDAP_SASL_BIND_INPROGRESS ""
0x10 LDAP_NO_SUCH_ATTRIBUTE "That entry does not contain the attribute specified."
0x11 LDAP_UNDEFINED_TYPE "The attribute type specified is invalid."
0x12 LDAP_INAPPROPRIATE_MATCHING "This usually means that your LDAP server has not defined an equality rule
for the attribute you are trying to alter. This is not phpLDAPadmin's fault as the
LDAP server has refused to perform the operation (as well it should if there is
no equality rule for it to use for the operation). This generally applies when
adding a new value to a binary attribute, or removing a single value from a
multi-valued binary attribute."
0x13 LDAP_CONSTRAINT_VIOLATION "Some constraint would be violated by performing the action. This can happen when
you try to add a second value to a single-valued attribute, for example."
0x14 LDAP_TYPE_OR_VALUE_EXISTS "An attribute type or attribute value
specified already exists in the entry"
0x15 LDAP_INVALID_SYNTAX "An invalid attribute value was specified."
0x20 LDAP_NO_SUCH_OBJECT "That object does not exist."
0x21 LDAP_ALIAS_PROBLEM "An alias in the directory points to a
non-existent entry."
0x22 LDAP_INVALID_DN_SYNTAX "You used an invalid syntax in the specified DN."
0x23 LDAP_IS_LEAF "The object specified is a leaf"
0x24 LDAP_ALIAS_DEREF_PROBLEM "A problem was encountereed when
dereferencing an alias"
0x30 LDAP_INAPPROPRIATE_AUTH "Inappropriate authentication was
specified (e.g. LDAP_AUTH_SIMPLE was
specified and the entry does not have
a userPassword attribute)."
0x31 LDAP_INVALID_CREDENTIALS "Incorrect login DN and/or password."
0x32 LDAP_INSUFFICIENT_ACCESS "You do not have sufficient permissions
to perform that operation."
0x33 LDAP_BUSY "The LDAP server is busy."
0x34 LDAP_UNAVAILABLE "The LDAP server is unavailable."
0x35 LDAP_UNWILLING_TO_PERFORM "The LDAP server refused to perform the operation."
0x36 LDAP_LOOP_DETECT "A loop was detected."
0x3C LDAP_SORT_CONTROL_MISSING ""
0x3D LDAP_INDEX_RANGE_ERROR ""
0x40 LDAP_NAMING_VIOLATION "A naming violation occurred. This usually
means that you tried to change the value of an attribute that is used in the
DN. For example, if you change the 'cn' value of an entry whose DN is 'cn=Bob
Jones,dc=example,dc=com', you must also rename the entry to reflect the
change."
0x41 LDAP_OBJECT_CLASS_VIOLATION "You tried to perform an operation that would cause an undefined attribute
to exist or that would remove a required attribute, given the current list
of ObjectClasses. This can also occur if you do not
specify a structural objectClass when creating an entry, or if you specify
more than one structural objectClass."
0x42 LDAP_NOT_ALLOWED_ON_NONLEAF "The entry you tried to operate on has children. Usually this means you
tried to delete or rename the entry, which you cannot do to an entry
with children."
0x43 LDAP_NOT_ALLOWED_ON_RDN "You cannot preform that operation on a the relative distinguished name
(RDN) of an object."
0x44 LDAP_ALREADY_EXISTS "The object already exists. Usually you are trying to create a new object
on top of an existing one."
0x45 LDAP_NO_OBJECT_CLASS_MODS "ObjectClass modifications are not
allolwed."
0x46 LDAP_RESULTS_TOO_LARGE ""
0x47 LDAP_AFFECTS_MULTIPLE_DSAS ""
0x50 LDAP_OTHER ""
0x51 LDAP_SERVER_DOWN "The LDAP server is down."
0x52 LDAP_LOCAL_ERROR ""
0x53 LDAP_ENCODING_ERROR ""
0x54 LDAP_DECODING_ERROR ""
0x55 LDAP_TIMEOUT ""
0x56 LDAP_AUTH_UNKNOWN ""
0x57 LDAP_FILTER_ERROR "The LDAP search filter specified is inavlid."
0x58 LDAP_USER_CANCELLED "The user cancelled the LDAP operation."
0x59 LDAP_PARAM_ERROR "An ldap routine was called with a bad
parameter."
0x5a LDAP_NO_MEMORY "A memory allocation (e.g., malloc(3)
or other dynamic memory allocator)
call failed in an ldap library rou-
tine."
0x5b LDAP_CONNECT_ERROR ""
0x5c LDAP_NOT_SUPPORTED "The requested operation is not supported by the LDAP server."
0x5d LDAP_CONTROL_NOT_FOUND ""
0x5e LDAP_NO_RESULTS_RETURNED "The search came back empty."
0x5f LDAP_MORE_RESULTS_TO_RETURN "The LDAP server has more results that it would like to return."
0x60 LDAP_CLIENT_LOOP ""
0x61 LDAP_REFERRAL_LIMIT_EXCEEDED "This means that a search was performed that required the LDAP
server to follow a chain of referrals that was too lengthy."

180
lib/ldap_supported_oids.txt Normal file
View File

@@ -0,0 +1,180 @@
# $Header: /cvsroot/phpldapadmin/phpldapadmin/ldap_supported_oids.txt,v 1.3 2005/09/11 14:59:47 wurley Exp $
# If you find some reliable and more meaningful descriptions to this OIDS,
# then please let the phpldapadmin development know so that this file can be
# more descriptive.
1.2.826.0.1.334810.2.3 "LDAP_CONTROL_VALUESRETURNFILTER"
1.2.826.0.1.3344810.2.3 "Matched Values Control" "RFC 3876" "Describes a control for the LDAP v3 that is used to return a subset of attribute values from an entry. Specifically, only those values that match a 'values return' filter. Without support for this control, a client must retrieve all of an attribute's values and search for specific values locally."
1.2.826.0.1050.11.1.1 "Read-Only LDAP Server"
1.2.826.0.1050.11.2.1 "Read-Write LDAP Server"
1.2.826.0.1050.11.3.1 "White Pages Application LDAP Server"
1.2.826.0.1050.11.4.1 "Certificate Application LDAP Server"
1.2.826.0.1050.11.5.1 "Single Sign On Application LDAP Server"
1.2.840.113549.6.0.0 "Signed Operation"
1.2.840.113549.6.0.1 "Demand Signed Result"
1.2.840.113549.6.0.2 "Signed Result RFC 2649"
1.2.840.113556.1.4.319 "Simple Paged Results Manipulation Control Extension" "RFC 2696" "This control extension allows a client to control the rate at which an LDAP server returns the results of an LDAP search operation. This control may be useful when the LDAP client has limited resources and may not be able to process the entire result set from a given LDAP query, or when the LDAP client is connected over a low-bandwidth connection."
1.2.840.113556.1.4.417 "Show deleted control" "" "The LDAP_SERVER_SHOW_DELETED_OID control is used with an extended LDAP search function to specify that the search results include any deleted objects that match the search filter."
1.2.840.113556.1.4.473 "LDAP Server Sort Result extension" "draft-ietf-ldapext-sorting-01" "This control is included in the searchRequest message as part of the controls field of the LDAPMessage."
1.2.840.113556.1.4.474 "LDAP Server Sort Result extension response control" "" "This control is included in the searchResultDone message as part of the controls field of the LDAPMessage"
1.2.840.113556.1.4.521 "Cross-domain move control" "" "The LDAP_SERVER_CROSSDOM_MOVE_TARGET_OID control is used with an extended LDAP rename function to move an LDAP object from one domain to another. The control specifies the DNS hostname of the domain controller in the destination domain."
1.2.840.113556.1.4.528 "Server search notification control" "" "The LDAP_SERVER_NOTIFICATION_OID control is used with an extended LDAP asynchronous search function to register the client to be notified when changes are made to an object in Active Directory."
1.2.840.113556.1.4.529 "Extended DN control" "" "The LDAP_SERVER_EXTENDED_DN_OID control is used with an extended LDAP search function to request an extended form of an Active Directory object distinguished name. The extended form includes a string representation of the object objectGUID property. For security principal objects such as users, groups, and computers, the extended form also includes a string representation of the object objectSID property."
1.2.840.113556.1.4.616 "LDAP_CONTROL_REFERRALS"
1.2.840.113556.1.4.619 "Lazy commit control" "" "The LDAP_SERVER_LAZY_COMMIT_OID control is used to instruct the server to return the results of a DS modification command, such as add, delete, or replace, after it has been completed in memory, but before it has been committed to disk. The server can then return results quickly, and save the data to disk without holding the client."
1.2.840.113556.1.4.800 "LDAP_CAP_ACTIVE_DIRECTORY_OID" "" "This is an Actrive Directory Server (Win2k and later)."
1.2.840.113556.1.4.801 "Security descriptor flags control" "" "The LDAP_SERVER_SD_FLAGS_OID control is used to pass flags to the server to control various security descriptor results."
1.2.840.113556.1.4.802 "Attribute Range Option" "" "Server supports the Range property enabling clients to incremental retrieve values from multivalue attributes."
1.2.840.113556.1.4.803 "LDAP_MATCHING_RULE_BIT_AND"
1.2.840.113556.1.4.804 "LDAP_MATCHING_RULE_BIT_OR"
1.2.840.113556.1.4.805 "Tree Delete" "" "The LDAP_SERVER_TREE_DELETE_OID control is used with an extended LDAP delete function to delete an entire subtree in the directory."
1.2.840.113556.1.4.841 "Directory synchronization control" "" "The LDAP_SERVER_DIRSYNC_OID control enables an application to search the directory for objects changed from a previous state. It is also used with the extended LDAP search functions such as ldap_search_ext."
1.2.840.113556.1.4.906 "Microsoft Large Integer"
1.2.840.113556.1.4.970 "Get stats control (Stateless)"
1.2.840.113556.1.4.1302 "Microsoft OID used with DEN Attributes"
1.2.840.113556.1.4.1338 "Verify name control" "" "The LDAP_SERVER_VERIFY_NAME_OID control is used with extended LDAP add and modify requests to instruct the DC accepting the update which DC it should verify with, the existence of any DN attribute values."
1.2.840.113556.1.4.1339 "LDAP_SERVER_DOMAIN_SCOPE_OID" "" "The LDAP_SERVER_DOMAIN_SCOPE_OID control is used to instruct the LDAP server not to generate any referrals when completing a request. This control also limits any search using it to a single naming context."
1.2.840.113556.1.4.1340 "Search options control" "" " The LDAP_SERVER_SEARCH_OPTIONS_OID control is used to pass flags to the server to control various search behaviors."
1.2.840.113556.1.4.1413 "LDAP ease modify restrictions" "" "Allows an LDAP modify to work under less restrictive conditions. Without it, a delete will fail if an attribute does not exist, and an add will fail if an attribute already exists."
1.2.840.113556.1.4.1504 "Attribute scoped query control" "" "The LDAP_SERVER_ASQ_OID control is used with an extended LDAP search function to force the query to be based on a specific DN-valued attribute. Only one source attribute can be specified with this control and the search request is limited to base object scoped queries."
1.2.840.113556.1.4.1670 "LDAP_CAP_ACTIVE_DIRECTORY_V51_OID" "" "This server is a Whistler Active Directory server (Win2k3 and later)."
1.2.840.113556.1.4.1781 "Fast concurrent bind extended operation" "" "The Microsoft LDAP API will send an extended request with this name to Active Directory to request that all binds on this connection be processed as 'fast' binds."
1.2.840.113556.1.4.1791 "LDAP_CAP_ACTIVE_DIRECTORY_LDAP_INTEG_OID" "" "LDAP server is capable of doing signing and sealing on an NTLM authenticated connection, and that the server is capable of performing subsequent binds on a signed or sealed connection."
1.2.840.113556.1.4.1852 "LDAP_SERVER_QUOTA_CONTROL_OID" "" "The LDAP_SERVER_QUOTA_CONTROL_OID control is used to pass the SID of a security principal, whose quota is being queried, to the server in a LDAP search operation."
1.3.6.1.1.7.1 "LCUP Sync Request Control. RFC 3928 control"
1.3.6.1.1.7.2 "LCUP Sync Update Control. RFC 3928 control"
1.3.6.1.1.7.3 "LCUP Sync Done Control. RFC 3928 control"
1.3.6.1.1.8 "Cancel Operation. RFC 3909 extension"
1.3.6.1.4.1.42.2.27.8.5.1 "passwordPolicyRequest"
1.3.6.1.4.1.1466.101.119.1 "Dynamic Directory Services Refresh Request RFC2589"
1.3.6.1.4.1.1466.20036 "LDAP_NOTICE_OF_DISCONNECTION"
1.3.6.1.4.1.1466.20037 "Transport Layer Security Extension" "RFC 2830" "This operation provides for TLS establishment in an LDAP association and is defined in terms of an LDAP extended request."
1.3.6.1.4.1.1466.29539.1 "LDAP_CONTROL_ATTR_SIZELIMIT"
1.3.6.1.4.1.1466.29539.2 "LDAP_CONTROL_NO_COPY"
1.3.6.1.4.1.1466.29539.3 "LDAP_CONTROL_PARTIAL_COPY"
1.3.6.1.4.1.1466.29539.5 "LDAP_CONTROL_NO_CHAINING"
1.3.6.1.4.1.1466.29539.7 "LDAP_CONTROL_ALIAS_ON_UPDATE"
1.3.6.1.4.1.1466.29539.10 "LDAP_CONTROL_TRIGGER"
1.3.6.1.4.1.1466.29539.12 "nsTransmittedControl"
1.3.6.1.4.1.4203.1.5.1 "All Operational Attribute" "RFC 3673" "An LDAP extension which clients may use to request the return of all operational attributes."
1.3.6.1.4.1.4203.1.5.2 "Requesting Attributes by Object Class" "draft-zeilenga-ldap-adlist-10.txt" "Extends LDAP to support a mechanism that LDAP clients may use to request the return of all attributes of an object class."
1.3.6.1.4.1.4203.1.5.3 "LDAP Absolute True and False Filters" "draft-zeilenga-ldap-t-f-10.txt" "Implementations of this extension SHALL allow 'and' and 'or' choices with zero filter elements."
1.3.6.1.4.1.4203.1.5.4 "Language Tags" "RFC 3866" "Supports storing attributes with language tag options in the DIT"
1.3.6.1.4.1.4203.1.5.5 "Language Ranges" "RFC 3866" "Supports language range matching of attributes with language tag options stored in the DIT"
1.3.6.1.4.1.4203.1.10.1 "Subentries in LDAP" "RFC 3672" "The subentries control MAY be sent with a searchRequest to control the visibility of entries and subentries which are within scope. Non-visible entries or subentries are not returned in response to the request."
1.3.6.1.4.1.4203.1.10.2 "LDAP No-Op Control" "draft-zeilenga-ldap-noop-02.txt" "The No-Op control can be used to disable the normal effect of an operation. The control can be used to discover how a server might react to a particular update request without updating the directory."
1.3.6.1.4.1.4203.1.11.1 "LDAP Password Modify Extended Operation" "RFC 3062" "An LDAP extended operation to allow modification of user passwords which is not dependent upon the form of the authentication identity nor the password storage mechanism used."
1.3.6.1.4.1.4203.1.11.2 "LDAP Cancel Extended Operation"
1.3.6.1.4.1.4203.1.11.3 "Who Am I? Extended Operation" "draft-zeilenga-ldap-authzid-10.txt" "This specification provides a mechanism for Lightweight Directory Access Protocol (LDAP) clients to obtain the authorization identity which the server has associated with the user or application entity."
1.3.6.1.4.1.4203.666.5.1 "Subentries Control"
1.3.6.1.4.1.4203.666.5.2 "NO OP Control"
1.3.18.0.2.12.1 "The ACL credential controls provide a method to flow a subject's credentials associated with a bind."
1.3.18.0.2.12.5 "tranExtOpInit"
1.3.18.0.2.12.6 "tranExtOpInit"
2.16.840.1.113531.18.2.1 "LDAP_C_SETOPTIONS_OID"
2.16.840.1.113531.18.2.2 "LDAP_C_SETDONTUSECOPY_OID"
2.16.840.1.113531.18.2.3 "LDAP_C_SETLOCALSCOPE_OID"
2.16.840.1.113531.18.2.4 "Return operational attributes as well as user attributes"
2.16.840.1.113531.18.2.5 "Return only subentries"
2.16.840.1.113531.18.2.6 "LDAP_C_SETUSEALIAS_OID"
2.16.840.1.113531.18.2.7 "LDAP_C_SETPREFERCHAIN_OID"
2.16.840.1.113531.18.2.8 "LDAP_C_SETX500DN_OID"
2.16.840.1.113531.18.2.9 "LDAP_C_SETCOPYSHALLDO_OID"
2.16.840.1.113531.18.2.10 "LDAP_C_SETDONTMAPATTRS_OID"
2.16.840.1.113531.18.2.11 "Return normal entries as well as sub-entries"
2.16.840.1.113719.1.27.99.1 "Superior References"
2.16.840.1.113719.1.27.100.1 "ndsToLdapResponse"
2.16.840.1.113719.1.27.100.2 "ndsToLdapRequest"
2.16.840.1.113719.1.27.100.3 "createNamingContextRequest"
2.16.840.1.113719.1.27.100.4 "createNamingContextResponse"
2.16.840.1.113719.1.27.100.5 "mergeNamingContextRequest"
2.16.840.1.113719.1.27.100.6 "mergeNamingContextResponse"
2.16.840.1.113719.1.27.100.7 "addReplicaRequest"
2.16.840.1.113719.1.27.100.8 "addReplicaResponse"
2.16.840.1.113719.1.27.100.9 "refreshLDAPServerRequest"
2.16.840.1.113719.1.27.100.10 "refreshLDAPServerResponse"
2.16.840.1.113719.1.27.100.11 "removeReplicaRequest"
2.16.840.1.113719.1.27.100.12 "removeReplicaResponse"
2.16.840.1.113719.1.27.100.13 "namingContextEntryCountRequest"
2.16.840.1.113719.1.27.100.14 "namingContextEntryCountResponse"
2.16.840.1.113719.1.27.100.15 "changeReplicaTypeRequest"
2.16.840.1.113719.1.27.100.16 "changeReplicaTypeResponse"
2.16.840.1.113719.1.27.100.17 "getReplicaInfoRequest"
2.16.840.1.113719.1.27.100.18 "getReplicaInfoResponse"
2.16.840.1.113719.1.27.100.19 "listReplicaRequest"
2.16.840.1.113719.1.27.100.20 "listReplicaResponse"
2.16.840.1.113719.1.27.100.21 "receiveAllUpdatesRequest"
2.16.840.1.113719.1.27.100.22 "receiveAllUpdatesResponse"
2.16.840.1.113719.1.27.100.23 "sendAllUpdatesRequest"
2.16.840.1.113719.1.27.100.24 "sendAllUpdatesResponse"
2.16.840.1.113719.1.27.100.25 "requestNamingContextSyncRequest"
2.16.840.1.113719.1.27.100.26 "requestNamingContextSyncResponse"
2.16.840.1.113719.1.27.100.27 "requestSchemaSyncRequest"
2.16.840.1.113719.1.27.100.28 "requestSchemaSyncResponse"
2.16.840.1.113719.1.27.100.29 "abortNamingContextOperationRequest"
2.16.840.1.113719.1.27.100.30 "abortNamingContextOperationResponse"
2.16.840.1.113719.1.27.100.31 "Get Bind DN Request"
2.16.840.1.113719.1.27.100.32 "Get Bind DN Response"
2.16.840.1.113719.1.27.100.33 "Get Effective Privileges Request"
2.16.840.1.113719.1.27.100.34 "Get Effective Privileges Response"
2.16.840.1.113719.1.27.100.35 "Set Replication Filter Request"
2.16.840.1.113719.1.27.100.36 "Set Replication Filter Response"
2.16.840.1.113719.1.27.100.37 "Get Replication Filter Request"
2.16.840.1.113719.1.27.100.38 "Get Replication Filter Response"
2.16.840.1.113719.1.27.100.39 "Create Orphan Partition Request"
2.16.840.1.113719.1.27.100.40 "Create Orphan Partition Response"
2.16.840.1.113719.1.27.100.41 "Remove Orphan Partition Request"
2.16.840.1.113719.1.27.100.42 "Remove Orphan Partition Response"
2.16.840.1.113719.1.27.100.43 "Trigger Backlinker Request"
2.16.840.1.113719.1.27.100.44 "Trigger Backlinker Response"
2.16.840.1.113719.1.27.100.47 "Trigger Janitor Request"
2.16.840.1.113719.1.27.100.48 "Trigger Janitor Response"
2.16.840.1.113719.1.27.100.49 "Trigger Limber Request"
2.16.840.1.113719.1.27.100.50 "Trigger Limber Response"
2.16.840.1.113719.1.27.100.51 "Trigger Skulker Request"
2.16.840.1.113719.1.27.100.52 "Trigger Skulker Response"
2.16.840.1.113719.1.27.100.53 "Trigger Schema Synch Request"
2.16.840.1.113719.1.27.100.54 "Trigger Schema Synch Response"
2.16.840.1.113719.1.27.100.55 "Trigger Partition Purge Request"
2.16.840.1.113719.1.27.100.56 "Trigger Partition Purge Response"
2.16.840.1.113719.1.27.100.79 "Monitor Events Request"
2.16.840.1.113719.1.27.100.80 "Monitor Events Response"
2.16.840.1.113719.1.27.100.81 "Event Notification"
2.16.840.1.113719.1.27.101.1 "Duplicate Entry Request"
2.16.840.1.113719.1.27.101.2 "DuplicateSearchResult"
2.16.840.1.113719.1.27.101.3 "DuplicateEntryResponseDone"
2.16.840.1.113719.1.27.101.5 "Simple Password"
2.16.840.1.113719.1.27.101.6 "Forward Reference"
2.16.840.1.113719.1.142.100.1 "startFramedProtocolRequest"
2.16.840.1.113719.1.142.100.2 "startFramedProtocolResponse"
2.16.840.1.113719.1.142.100.3 "ReplicationUpdate"
2.16.840.1.113719.1.142.100.4 "endFramedProtocolRequest"
2.16.840.1.113719.1.142.100.5 "endFramedProtocolResponse"
2.16.840.1.113719.1.142.100.6 "lburpOperationRequest"
2.16.840.1.113719.1.142.100.7 "lburpOperationResponse"
2.16.840.1.113730.3.4 "Netscape LDAPv3 controls"
2.16.840.1.113730.3.4.2 "ManageDsaIT Control" "RFC 3296" "The client may provide the ManageDsaIT control with an operation to indicate that the operation is intended to manage objects within the DSA (server) Information Tree. The control causes Directory-specific entries (DSEs), regardless of type, to be treated as normal entries allowing clients to interrogate and update these entries using LDAP operations."
2.16.840.1.113730.3.4.3 "Persistent Search LDAPv3 control"
2.16.840.1.113730.3.4.4 "Netscape Password Expired LDAPv3 control"
2.16.840.1.113730.3.4.5 "Netscape Password Expiring LDAPv3 control"
2.16.840.1.113730.3.4.6 "Netscape NT Synchronization Client LDAPv3 control"
2.16.840.1.113730.3.4.7 "Entry Change Notification LDAPv3 control"
2.16.840.1.113730.3.4.8 "Transaction ID Request Control"
2.16.840.1.113730.3.4.9 "VLV Request LDAPv3 control" "" "As defined in the 'LDAPv3 Extensions for Virtual List View' IETF document."
2.16.840.1.113730.3.4.10 "VLV Response LDAPv3 control" "" "As defined in the 'LDAPv3 Extensions for Virtual List View' IETF document."
2.16.840.1.113730.3.4.11 "Transaction ID Response Control"
2.16.840.1.113730.3.4.12 "Proxied Authorization (version 1) control" "draft-weltman-ldapv3-proxy-05" "For assuming the identity of another entry for the duration of a request. This has been replaced by a new 'version 2' Proxied Authorization control."
2.16.840.1.113730.3.4.13 "iPlanet Directory Server Replication Update Information Control"
2.16.840.1.113730.3.4.14 "iPlanet Directory Server 'search on specific backend' control"
2.16.840.1.113730.3.4.15 "Authentication Response Control"
2.16.840.1.113730.3.4.16 "Authentication Request Control"
2.16.840.1.113730.3.4.17 "Real Attributes Only Request Control"
2.16.840.1.113730.3.4.18 "LDAP Proxied Authorization Control" "draft-weltman-ldapv3-proxy-06.txt" "The Proxied Authorization Control allows a client to request that an operation be processed under a provided authorization identity [AUTH] instead of as the current authorization identity associated with the connection. "
2.16.840.1.113730.3.4.999 "iPlanet Replication Modrdn Extra Mods Control"
2.16.840.1.113730.3.5.3 "iPlanet Start Replication Request Extended Operation"
2.16.840.1.113730.3.5.4 "iPlanet Replication Response Extended Operation"
2.16.840.1.113730.3.5.5 "iPlanet End Replication Request Extended Operation"
2.16.840.1.113730.3.5.6 "iPlanet Replication Entry Request Extended Operation"
2.16.840.1.113730.3.5.7 "iPlanet Bulk Import Start Extended Operation"
2.16.840.1.113730.3.5.8 "iPlanet Bulk Import Finished Extended Operation"

1014
lib/ldif_functions.php Normal file

File diff suppressed because it is too large Load Diff

1755
lib/schema_functions.php Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,98 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/search_form_advanced.php,v 1.22 2005/07/16 03:13:54 wurley Exp $
/**
* @package phpLDAPadmin
*/
?>
<script>
<?php foreach ($server_info_list as $i => $ignore) { ?>
addToServersList(new server(<?php echo $i; ?>,"<?php echo $server_info_list[$i]['name']; ?>","<?php echo $server_info_list[$i]['base_dn']; ?>"));
<?php } ?>
function focus_filter() {
document.advanced_search_form.filter.focus();
}
</script>
<form action="search.php" method="get" class="search" name="advanced_search_form">
<input type="hidden" name="search" value="true" />
<input type="hidden" name="form" value="advanced" />
<input type="hidden" name="format" value="<?php echo $format; ?>" />
<center><b><?php echo $lang['advanced_search_form_str']; ?></b></center>
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=simple"><?php echo $lang['simple_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo $lang['predefined_searches']; ?></a>)</small><br />
<br />
<table>
<tr>
<td><small><?php echo $lang['server']; ?></small></td>
<td><?php echo $server_menu_html; ?></td>
</tr>
<tr>
<td><small><?php echo $lang['base_dn']; ?></small></td>
<td><input type="text" name="base_dn" value="<?php echo count($base_dns) == 1 ? $base_dns[0] : '' ?>" style="width: 200px" id="base_dn" />
<?php draw_chooser_link( 'advanced_search_form.base_dn' );
if( isset( $base_dn_is_invalid ) && $base_dn_is_invalid )
echo "<small style=\"color:red; white-space: nowrap\">" . $lang['this_base_dn_is_not_valid'] . "</small>";
if( isset( $base_dn_does_not_exist ) && $base_dn_does_not_exist )
echo "<small style=\"color:red; white-space: nowrap\">" . $lang['this_base_dn_does_not_exist'] . "</small>"; ?>
</td>
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['scope_in_which_to_search']; ?>"><?php echo $lang['search_scope']; ?></acronym></small></td>
<td>
<select name="scope" style="width: 200px">
<option<?php echo $scope=='sub'?' selected':''; ?> value="sub">
<?php echo $lang['scope_sub']; ?>
</option>
<option<?php echo $scope=='one'?' selected':''; ?> value="one">
<?php echo $lang['scope_one']; ?>
</option>
<option<?php echo $scope=='base'?' selected':''; ?> value="base">
<?php echo $lang['scope_base']; ?>
</option>
</select>
</td>
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['standard_ldap_search_filter']; ?>">
<?php echo $lang['search_filter']; ?></acronym></small></td>
<td><input type="text" name="filter" id="filter" style="width: 200px" value="<?php echo $filter ? htmlspecialchars($filter) : 'objectClass=*'; ?>" /></td>
</tr>
<tr>
<td><small><acronym title="<?php echo $lang['list_of_attrs_to_display_in_results']; ?>">
<?php echo $lang['show_attributes']; ?></acronym></small></td>
<td><input type="text" name="display_attrs" style="width: 200px" value="<?php
echo isset( $_GET['display_attrs'] ) ?
htmlspecialchars( $_GET['display_attrs'] ) :
join(', ',$config->GetValue('search','result_attributes')); ?>" />
</tr>
<tr>
<td colspan="2"><br /><center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center></td>
</tr>
</table>
</form>
<script language="javascript">
// Move the cursor to the filter field
focus_filter();
</script>

View File

@@ -0,0 +1,69 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/search_form_predefined.php,v 1.8 2005/07/16 03:13:54 wurley Exp $
/**
* @package phpLDAPadmin
*/
?>
<form action="search.php" method="get" class="search">
<input type="hidden" name="search" value="true" />
<input type="hidden" name="form" value="predefined" />
<input type="hidden" name="format" value="<?php echo $format; ?>" />
<table>
<tr>
<td>
<?php if( isset( $_GET['predefined'] ) )
$selected_q_number = intval( $_GET['predefined'] );
else
$selected_q_number = null; ?>
<center><b><?php echo $lang['predefined_searches']; ?></b><br />
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=simple"><?php echo $lang['simple_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=advanced"><?php echo $lang['advanced_search_form_str']; ?></a>)</small><br />
<br />
<?php if( ! isset( $queries ) || ! is_array( $queries ) || 0 == count( $queries ) ) {
echo "<br />\n";
echo $lang['no_predefined_queries'];
echo "<br />\n";
echo "<br />\n";
echo "<br />\n";
echo "</td></tr></table>\n";
echo "</body>\n";
echo "</html>\n";
die();
} else { ?>
<small><?php echo $lang['predefined_search_str']; ?>: </small>
<select name="predefined">
<?php foreach( $queries as $q_number => $q ) {
if ($selected_q_number === $q_number)
$selected = " selected";
else
$selected = "";
print("\t<option value=\"" . $q_number . "\"" . $selected . ">\n");
print("\t" . htmlspecialchars( $q['name'] ) . "\n");
print("\t</option>\n");
} ?>
</select>
<?php } ?>
<br />
<br />
<center><input type="hidden" name="server_id" value="<?php echo $ldapserver->server_id; ?>" /></center>
<center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center>
</td>
</table>
</form>

View File

@@ -0,0 +1,66 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/search_form_simple.php,v 1.14 2005/07/16 03:13:54 wurley Exp $
/**
* @package phpLDAPadmin
*/
?>
<script language="javascript">
function focus_filter() {
document.simple_search_form.filter.focus();
}
</script>
<form action="search.php" method="get" class="search" name="simple_search_form">
<input type="hidden" name="search" value="true" />
<input type="hidden" name="form" value="simple" />
<input type="hidden" name="scope" value="sub" />
<input type="hidden" name="format" value="<?php echo $format; ?>" />
<table>
<tr>
<td>
<center><b><?php echo $lang['simple_search_form_str']; ?></b><br />
<small>(<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=advanced"><?php echo $lang['advanced_search_form_str']; ?></a> |
<a href="search.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;form=predefined"><?php echo $lang['predefined_searches']; ?></a>)</small><br />
</center>
<br />
<small><?php echo $lang['server']; ?></small><br /> <?php echo $server_menu_html; ?><br />
<br />
<small><?php echo $lang['search_for_entries_whose']; ?></small><br />
<nobr>
<select name="attribute">
<?php foreach( $config->GetValue('search','attributes') as $id => $attribute ) { ?>
<option value="<?php echo rawurlencode( $attribute ); ?>"<?php echo $attribute==$attr?' selected="true"':''; ?>>
<?php echo htmlspecialchars(show_friendly_attribute($attribute)); ?>
</option>
<?php } ?>
</select>
<select name="criterion">
<?php
foreach( $config->GetValue('search','criteria_options') as $c ) { ?>
<option value="<?php echo $c; ?>"<?php echo $c==$criterion?' selected="true"':''; ?>>
<?php echo htmlspecialchars( $lang[$c] ); ?>
</option>
<?php } ?>
</select>
<input type="text" name="filter" id="filter" size="20" value="<?php echo htmlspecialchars($filter); ?>" /><br />
<br />
<center><input type="submit" value="<?php echo $lang['Search']; ?>" /></center>
</nobr>
</td>
</tr>
</table>
</form>
<script language="javascript">
// Move the cursor to the filter field
focus_filter();
</script>

View File

@@ -0,0 +1,92 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/search_results_list.php,v 1.5 2005/04/29 11:24:15 wurley Exp $
/**
* @package phpLDAPadmin
*/
$friendly_attrs = process_friendly_attr_table();
$entry_id = ldap_first_entry( $ldapserver->connect(), $results );
// Iterate over each entry
$i = 0;
while( $entry_id ) {
$i++;
if( $i <= $start_entry ) {
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
continue;
}
if( $i >= $end_entry )
break;
$dn = ldap_get_dn( $ldapserver->connect(), $entry_id );
$encoded_dn = rawurlencode( $dn );
$rdn = get_rdn( $dn ); ?>
<div class="search_result">
<table>
<tr>
<td><img src="images/<?php echo get_icon_use_cache( $ldapserver, $dn ); ?>" /></td>
<td><a href="edit.php?server_id=<?php echo $ldapserver->server_id; ?>&amp;dn=<?php echo $encoded_dn; ?>"><?php echo htmlspecialchars($rdn); ?></a></td>
</tr>
</table>
</div>
<table class="attrs">
<?php $attrs = ldap_get_attributes( $ldapserver->connect(), $entry_id );
$attr = ldap_first_attribute( $ldapserver->connect(), $entry_id, $attrs );
// Always print out the DN in the attribute list
echo "<tr><td class=\"attr\" valign=\"top\">dn</td>";
echo "<td>" . htmlspecialchars($dn) . "</td></tr>\n";
// Iterate over each attribute for this entry
while( $attr ) {
if( is_attr_binary( $ldapserver, $attr ) )
$values = array( "(binary)" );
else
$values = ldap_get_values( $ldapserver->connect(), $entry_id, $attr );
if( isset( $values['count'] ) )
unset( $values['count'] );
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) )
$attr = "<acronym title=\"Alias for $attr\">".htmlspecialchars( $friendly_attrs[ strtolower($attr) ] ) .
"</acronym>";
else
$attr = htmlspecialchars( $attr ); ?>
<tr>
<td class="attr" valign="top"><?php echo $attr; ?></td>
<td class="val">
<?php if( is_jpeg_photo( $ldapserver, $attr ) )
draw_jpeg_photos( $ldapserver, $dn, $attr, false, false, 'align="left"' );
else
foreach( $values as $value )
echo str_replace( ' ', '&nbsp;', htmlspecialchars( $value ) ) . "<br />\n"; ?>
</td>
</tr>
<?php $attr = ldap_next_attribute( $ldapserver->connect(), $entry_id, $attrs );
} // end while( $attr ) ?>
</table>
<?php $entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
// flush every 5th entry (speeds things up a bit)
if( 0 == $i % 5 )
flush();
} // end while( $entry_id )
?>

View File

@@ -0,0 +1,133 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/search_results_table.php,v 1.7 2005/04/29 11:24:15 wurley Exp $
/**
* Incoming variables (among others)
* $results: The result of ldap_search(), ldap_list(), or ldap_read().
* $ldapserver: LDAP Server Object.
* $start_entry: The index of the entry at which to begin displaying
* $end_entry: The index of the entry at which to end displaying
* @package phpLDAPadmin
*/
$friendly_attrs = process_friendly_attr_table();
$entry_id = ldap_first_entry( $ldapserver->connect(), $results );
$all_attrs = array( '' => 1, 'dn' => 1 );
// Iterate over each entry and store the whole dang thing in memory (necessary to extract
// all attribute names and display in table format in a single pass)
$i = 0;
$entries = array();
$entries_display = array();
while( $entry_id ) {
$i++;
if( $i <= $start_entry ) {
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
continue;
}
if( $i >= $end_entry )
break;
$dn = ldap_get_dn( $ldapserver->connect(), $entry_id );
$dn_display = strlen( $dn ) > 40 ? "<acronym title=\"" . htmlspecialchars( $dn ) . "\">" .
htmlspecialchars( substr( $dn, 0, 40 ) . '...' ) .
"</acronym>"
: htmlspecialchars( $dn );
$encoded_dn = rawurlencode( $dn );
$rdn = get_rdn( $dn );
$icon = get_icon_use_cache( $ldapserver, $dn );
$attrs = ldap_get_attributes( $ldapserver->connect(), $entry_id );
$attr = ldap_first_attribute( $ldapserver->connect(), $entry_id, $attrs );
$attrs_display = array();
$edit_url = sprintf("edit.php?server_id=%s&amp;dn=%s",$ldapserver->server_id,$encoded_dn);
$attrs_display[''] = "<center><a href=\"$edit_url\"><img src=\"images/$icon\" /></a><center>";
$attrs_display['dn'] = "<a href=\"$edit_url\">$dn_display</a>";
// Iterate over each attribute for this entry and store in associative array $attrs_display
while( $attr ) {
//echo "getting values for dn $dn, attr $attr\n";
// Clean up the attr name
if( isset( $friendly_attrs[ strtolower( $attr ) ] ) )
$attr_display = "<acronym title=\"Alias for $attr\">" .
htmlspecialchars( $friendly_attrs[ strtolower($attr) ] ) .
"</acronym>";
else
$attr_display = htmlspecialchars( $attr );
if( ! isset( $all_attrs[ $attr_display ] ) )
$all_attrs[ $attr_display ] = 1;
// Get the values
$display = '';
if( is_jpeg_photo( $ldapserver, $attr ) ) {
ob_start();
draw_jpeg_photos( $ldapserver, $dn, $attr, false, false, 'align="center"' );
$display = ob_get_contents();
ob_end_clean();
} elseif( is_attr_binary( $ldapserver, $attr ) ) {
$display = array( "(binary)" );
} else {
$values = @ldap_get_values( $ldapserver->connect(), $entry_id, $attr );
if( ! is_array( $values ) ) {
$display = 'Error';
} else {
if( isset( $values['count'] ) )
unset( $values['count'] );
foreach( $values as $value )
$display .= str_replace( ' ', '&nbsp;',
htmlspecialchars( $value ) ) . "<br />\n";
}
}
$attrs_display[ $attr_display ] = $display;
$attr = ldap_next_attribute( $ldapserver->connect(), $entry_id, $attrs );
} // end while( $attr )
$entries_display[] = $attrs_display;
//echo '<pre>';
//print_r( $attrs_display );
//echo "\n\n";
$entry_id = ldap_next_entry( $ldapserver->connect(), $entry_id );
} // end while( $entry_id )
$all_attrs = array_keys( $all_attrs );
/*
echo "<pre>";
print_r( $all_attrs );
print_r( $entries_display );
echo "</pre>";
*/
// Store the header row so it can be repeated later
$header_row = "<tr>";
foreach( $all_attrs as $attr )
$header_row .= "<th>$attr</th>";
$header_row .= "</tr>\n";
// begin drawing table
echo "<br />";
echo "<center>";
echo "<table class=\"search_result_table\">\n";
for( $i=0; $i<count($entries_display); $i++ ) {
$entry = $entries_display[$i];
if( $i %10 == 0 )
echo $header_row;
if( $i % 2 == 0 )
echo "<tr class=\"highlight\">";
else
echo "<tr>";
foreach( $all_attrs as $attr ) {
echo "<td>";
if( isset( $entry[ $attr ] ) )
echo $entry[ $attr ];
echo "</td>\n";
}
echo "</tr>\n";
}
echo "</table>";
echo "</center>";
?>

1066
lib/server_functions.php Normal file

File diff suppressed because it is too large Load Diff

120
lib/session_functions.php Normal file
View File

@@ -0,0 +1,120 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/session_functions.php,v 1.14 2005/07/16 03:13:54 wurley Exp $
/**
* A collection of functions to handle sessions throughout phpLDAPadmin.
* @author The phpLDAPadmin development team
* @package phpLDAPadmin
*/
/** The session ID that phpLDAPadmin will use for all sessions */
@define( 'PLA_SESSION_ID', 'PLASESSID' );
/** Enables session paranoia, which causes SIDs to change each page load (EXPERIMENTAL!) */
define('pla_session_id_paranoid', false);
/** Flag to indicate whether the session has already been initialized (this constant gets stored in $_SESSION) */
define('pla_session_id_init', 'pla_initialized');
/** The minimum first char value IP in hex for IP hashing. */
define('pla_session_id_ip_min', 8);
/** The maximum first char value of the IP in hex for IP hashing. */
define('pla_session_id_ses_max', 36);
/**
* Creates a new session id, which includes an IP hash.
*
* @return string the new session ID string
*/
function pla_session_get_id() {
debug_log(sprintf('pla_session_get_id(): Entered with ()'),2);
$id_md5 = md5(rand(1,1000000));
$ip_md5 = md5($_SERVER['REMOTE_ADDR']);
$id_hex = hexdec($id_md5[0]) + 1;
$ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= pla_session_id_ip_min)
$ip_len = pla_session_id_ip_min;
else
$ip_len = $ip_hex - 1;
$new_id = substr($id_md5, 0, $id_hex) .
substr($ip_md5, $ip_hex, $ip_len) .
substr($id_md5, $id_hex, pla_session_id_ses_max - ($id_hex + $ip_len));
return $new_id;
}
/**
* Checks if the session belongs to an IP
*
* @return bool True, if the session is valid
*/
function pla_session_verify_id() {
debug_log(sprintf('pla_session_verify_id(): Entered with ()'),2);
$check_id = session_id();
$ip_md5 = md5($_SERVER['REMOTE_ADDR']);
$id_hex = hexdec($check_id[0]) + 1;
$ip_hex = hexdec($ip_md5[0]);
if ($ip_hex <= pla_session_id_ip_min)
$ip_len = pla_session_id_ip_min;
else
$ip_len = $ip_hex - 1;
$ip_ses = substr($check_id, $id_hex, $ip_len);
$ip_ver = substr($ip_md5, $ip_hex, $ip_len);
return ($ip_ses == $ip_ver);
}
/**
* The only function which should be called by a user
*
* @see common.php
* @see PLA_SESSION_ID
* @return bool Returns true if the session was started the first time
*/
function pla_session_start() {
debug_log(sprintf('pla_session_start(): Entered with ()'),2);
// If session.auto_start is on in the server's PHP configuration (php.ini), then
// we will have problems loading our schema cache since the session will have started
// prior to loading the SchemaItem (and descedants) class. Destroy the auto-started
// session to prevent this problem.
if( ini_get( 'session.auto_start' ) )
@session_destroy();
// Do we already have a session?
if( @session_id() ) {
return;
}
@session_name( PLA_SESSION_ID );
@session_start();
// Do we have a valid session?
$is_initialized = is_array( $_SESSION ) && array_key_exists( pla_session_id_init, $_SESSION );
if( ! $is_initialized ) {
if( pla_session_id_paranoid ) {
ini_set('session.use_trans_sid', 0);
@session_destroy();
@session_id(pla_session_get_id());
@session_start();
ini_set('session.use_trans_sid', 1);
}
$_SESSION[pla_session_id_init] = true;
}
@header("Cache-control: private"); // IE 6 Fix
if( pla_session_id_paranoid && ! pla_session_verify_id() )
pla_error("Session inconsistent or session timeout");
return ( ! $is_initialized ) ? true : false;
}
/**
* Stops the current session.
*/
function pla_session_close() {
@session_write_close();
}
?>

106
lib/syslog.php Normal file
View File

@@ -0,0 +1,106 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/syslog.php,v 1.11 2005/08/10 06:07:32 wurley Exp $
/**
* Functions related to syslog logging.
*
* @author Benjamin Drieu <benjamin.drieu@fr.alcove.com> and Alcôve
* @package phpLDAPadmin
*
* 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
*/
# If config_default.php hasnt been called yet, then return.
if (! isset($config))
return;
/* Initialize syslog */
if ($config->GetValue('debug','syslog')) {
define_syslog_variables();
openlog('phpldapadmin', LOG_ODELAY, LOG_DAEMON );
}
/**
* Verify that syslog logging is activated in the config via the
* debug->syslog variable and does a call to the syslog() function is it
* is true.
*
* @param emergency Syslog emergency.
* @param log_string String to log.
*/
function syslog_msg ( $emergency, $log_string, $ldapserver=null ) {
global $config;
if (isset($config) && $config->GetValue('debug','syslog')) {
if (isset($ldapserver->server_id))
$log_string = sprintf('(%s) %s',get_logged_in_dn($ldapserver->server_id),$log_string);
syslog ( $emergency, $log_string );
}
return true;
}
/**
* Issue an error message via syslog.
*
* @param log_string Log message to send to syslog.
* @param server_id If set, print the logged user as well.
*
* @return true on success.
*/
function syslog_err ( $log_string, $ldapserver=null ) {
return syslog_msg ( LOG_ERR, $log_string, $ldapserver );
}
/**
* Issue a warning message via syslog.
*
* @param log_string Log message to send to syslog.
* @param server_id If set, print the logged user as well.
*
* @return true on success.
*/
function syslog_warning ( $log_string, $ldapserver=null ) {
return syslog_msg ( LOG_WARNING, $log_string, $ldapserver );
}
/**
* Issue a notice message via syslog.
*
* @param log_string Log message to send to syslog.
* @param server_id If set, print the logged user as well.
*
* @return true on success.
*/
function syslog_notice ( $log_string, $ldapserver=null ) {
return syslog_msg ( LOG_NOTICE, $log_string, $ldapserver );
}
/**
* Issue a debug message via syslog, only if $log_level is set to
* 'debug' from the config file.
*
* @param log_string Log message to send to syslog.
* @param server_id If set, print the logged user as well.
*
* @return true on success or if debug log is not activated.
*/
function syslog_debug ( $log_string, $ldapserver=null ) {
return syslog_msg ( LOG_DEBUG, $log_string, $ldapserver );
}
?>

542
lib/template_functions.php Normal file
View File

@@ -0,0 +1,542 @@
<?php
/* $Header: /cvsroot/phpldapadmin/phpldapadmin/template_functions.php,v 1.25 2005/09/25 16:11:44 wurley Exp $ */
/**
* Classes and functions for the template engine.ation and capability
*
* @author The phpLDAPadmin development team
* @package phpLDAPadmin
* @todo: Should be able to auto figure what type of entry we are asking for ie: DN entry.
*/
class xml2array {
var $stack = array();
var $stack_ref;
var $arrOutput = array();
var $resParser;
var $strXmlData;
function push_pos(&$pos) {
$this->stack[count($this->stack)] = &$pos;
$this->stack_ref = &$pos;
}
function pop_pos() {
unset($this->stack[count($this->stack) - 1]);
$this->stack_ref = &$this->stack[count($this->stack) - 1];
}
function parse($file) {
$f = fopen($file,'r');
$strInputXML = fread($f,filesize($file));
fclose($f);
$this->resParser = xml_parser_create();
xml_set_object($this->resParser,$this);
xml_set_element_handler($this->resParser,"tagOpen","tagClosed");
xml_set_character_data_handler($this->resParser,"tagData");
$this->push_pos($this->arrOutput);
$this->strXmlData = xml_parse($this->resParser,$strInputXML);
if (! $this->strXmlData)
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->resParser)),
xml_get_current_line_number($this->resParser)));
xml_parser_free($this->resParser);
return $this->arrOutput;
}
function tagOpen($parser,$name,$attrs) {
$name = strtolower($name);
if (isset($this->stack_ref[$name])) {
if (! isset($this->stack_ref[$name][0])) {
$tmp = $this->stack_ref[$name];
unset($this->stack_ref[$name]);
$this->stack_ref[$name][0] = $tmp;
}
$cnt = count($this->stack_ref[$name]);
$this->stack_ref[$name][$cnt] = array();
if (isset($attrs))
$this->stack_ref[$name][$cnt] = $attrs;
$this->push_pos($this->stack_ref[$name][$cnt]);
} else {
$this->stack_ref[$name]=array();
if (isset($attrs))
$this->stack_ref[$name]=$attrs;
$this->push_pos($this->stack_ref[$name]);
}
}
function tagData($parser,$tagData) {
if (trim($tagData) != '') {
if (isset($this->stack_ref['#text']))
$this->stack_ref['#text'] .= $tagData;
else
$this->stack_ref['#text'] = $tagData;
}
}
function tagClosed($parser,$name) {
$this->pop_pos();
}
}
class Templates {
var $_template = array();
function Templates($server_id) {
debug_log(sprintf('%s::init(): Entered with ()',get_class($this)),2);
if ($this->_template = get_cached_item($server_id,'template','all')) {
debug_log(sprintf('%s::init(): Using CACHED [%s]',get_class($this),'templates'),3);
} else {
$dir = opendir(TMPLDIR);
$this->template_num = 0;
while( ( $file = readdir( $dir ) ) !== false ) {
if (! preg_match('/.xml$/',$file)) continue;
$objXML = new xml2array();
$xmldata = $objXML->parse(TMPLDIR.$file);
$template_name = preg_replace('/.xml$/','',$file);
$this->storeTemplate($template_name,$xmldata);
}
masort($this->_template,'title');
set_cached_item($server_id,'template','all',$this->_template);
}
}
function storeTemplate($template,$xmldata) {
debug_log(sprintf('%s::storeTemplate(): Entered with (%s,%s)',get_class($this),$template,serialize($xmldata)),2);
global $ldapserver, $lang;
foreach ($xmldata['template'] as $xml_key => $xml_value) {
debug_log(sprintf('%s::storeTemplate(): Foreach loop Key [%s] Value [%s]',get_class($this),$xml_key,is_array($xml_value)),9);
switch ($xml_key) {
# Build our object Classes from the DN and Template.
case ('objectclasses') :
if (isset($xmldata['template']['objectclasses']) && is_array($xmldata['template']['objectclasses'])) {
foreach ($xmldata['template']['objectclasses']['objectclass'] as $index => $details) {
if (is_numeric($index)) {
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($details['ID'],$this->_template[$template]['objectclass']))
$this->_template[$template]['objectclass'][] = $details['ID'];
} else {
if (! isset($this->_template[$template]['objectclass']) ||
! in_array($xmldata['template']['objectclasses']['objectclass']['ID'],$this->_template[$template]['objectclass']))
$this->_template[$template]['objectclass'][] = $xmldata['template']['objectclasses']['objectclass']['ID'];
}
}
}
break;
# Build our attribute list from the DN and Template.
case ('attributes') :
debug_log(sprintf('%s::storeTemplate(): Case [%s]',get_class($this),'attributes'),8);
if (isset($xmldata['template']['attributes']) && is_array($xmldata['template']['attributes'])) {
$this->_template[$template]['attribute'] = array();
foreach ($xmldata['template']['attributes'] as $tattrs) {
foreach ($tattrs as $index => $attr_details) {
debug_log(sprintf('%s::storeTemplate(): Foreach tattrs Key [%s] Value [%s]',get_class($this),$index,is_array($attr_details)),9);
# Single attribute XML files are not indexed.
if (! is_numeric($index)) {
$this->_template[$template]['attribute'][$tattrs['ID']][$index] = $this->_parseXML($index,$attr_details);
} else {
foreach ($attr_details as $key => $values) {
if (preg_match('/^@/',$key))
continue;
if (isset($values['ID']))
$key = $values['ID'];
$this->_template[$template]['attribute'][$attr_details['ID']][$key] = $this->_parseXML($key,$values);
}
}
}
}
# Do we have an override parameter?
foreach ($this->_template[$template]['attribute'] as $key => $data) {
if (isset($data['override'])) {
$this->_template[$template]['attribute'][$data['override']] = $data;
unset($this->_template[$template]['attribute'][$key]);
$this->_template[$template]['attribute'][$key] = $data['override'];
}
}
#if (isset($this->_template[$template]['attribute']);
}
break;
default :
$this->_template[$template][$xml_key] = $xml_value['#text'];
}
}
# Collect our structural, must & may attributes.
$this->_template[$template]['must'] = array();
$this->_template[$template]['may'] = array();
$this->_template[$template]['empty_attrs'] = array();
$superclasslist = array();
foreach ($this->_template[$template]['objectclass'] as $oclass) {
# If we get some superclasses - then we'll need to go through them too.
$supclass = true;
$enherited = false;
while ($supclass == true) {
$schema_object = get_schema_objectclass( $ldapserver, $oclass);
# Test that this is a valid objectclass - disable if an invalid one found.
if (! $schema_object)
$this->_template[$template]['invalid'] = 1;
if ($schema_object->type == 'structural' && (! $enherited))
$this->_template[$template]['structural'][] = $oclass;
if ($schema_object->must_attrs )
foreach ($schema_object->must_attrs as $index => $detail)
if (! in_array($detail->name,$this->_template[$template]['must']) && $detail->name != 'objectClass') {
if (isset($this->_template[$template]['attribute'][$detail->name]) &&
! is_array($this->_template[$template]['attribute'][$detail->name]))
$this->_template[$template]['must'][] =
$this->_template[$template]['attribute'][$detail->name];
else
$this->_template[$template]['must'][] = $detail->name;
}
if ($schema_object->may_attrs )
foreach ($schema_object->may_attrs as $index => $detail)
if (! in_array($detail->name,$this->_template[$template]['may']))
$this->_template[$template]['may'][] = $detail->name;
# Keep a list to objectclasses we have processed, so we dont get into a loop.
$oclass_processed[] = $oclass;
if ((count($schema_object->sup_classes)) || count($superclasslist)) {
foreach ($schema_object->sup_classes as $supoclass) {
if (! in_array($supoclass,$oclass_processed))
$supoclasslist[] = $supoclass;
}
$oclass = array_shift($supoclasslist);
if ($oclass)
$enherited = true;
else
$supclass = false;
} else {
$supclass = false;
}
}
}
# Translate anything.
foreach (array('title','description','display','hint') as $transkey) {
if (isset($this->_template[$template][$transkey]) && isset($lang[$this->_template[$template][$transkey]]))
$this->_template[$template][$transkey] = $lang[$this->_template[$template][$transkey]];
foreach ($this->_template[$template]['attribute'] as $key => $value) {
if (isset($value[$transkey]) && isset($lang[$value[$transkey]]))
$this->_template[$template]['attribute'][$key][$transkey] = $lang[$value[$transkey]];
if (isset($value['helper'][$transkey]) && isset($lang[$value['helper'][$transkey]]))
$this->_template[$template]['attribute'][$key]['helper'][$transkey] = $lang[$value['helper'][$transkey]];
}
}
# Remove any must attributes in the may list.
foreach ($this->_template[$template]['may'] as $index => $detail) {
if (in_array($detail,$this->_template[$template]['must'])) {
unset($this->_template[$template]['may'][$index]);
continue;
}
}
# Remove any attributes not in the xml file and not in the dn.
foreach ($this->_template[$template]['may'] as $index => $detail) {
if (isset($this->_template[$template]['attribute'])
&& ! isset($this->_template[$template]['attribute'][$detail])) {
unset($this->_template[$template]['may'][$index]);
continue;
}
if (! isset($attrs[$detail]))
if (isset($this->_template[$template]['attribute'][$detail]))
$this->_template[$template]['empty_attrs'][$detail] = $this->_template[$template]['attribute'][$detail];
else
$this->_template[$template]['empty_attrs'][$detail]['display'] = $detail;
else
$this->_template[$template]['attrs'][$detail] = $attrs[$detail];
}
# Add the must attrs to the attributes key.
foreach ($this->_template[$template]['must'] as $index => $detail) {
if (! isset($attrs[$detail])) {
if (isset($this->_template[$template]['attribute'][$detail]))
$this->_template[$template]['empty_attrs'][$detail] = $this->_template[$template]['attribute'][$detail];
else
$this->_template[$template]['empty_attrs'][$detail]['display'] = $detail;
$this->_template[$template]['empty_attrs'][$detail]['must'] = true;
} else
$this->_template[$template]['attrs'][$detail] = $attrs[$detail];
}
# Check if there are any items without a page or order parameter, and make it 1 and 255.
foreach ($this->_template[$template]['empty_attrs'] as $index => $detail) {
if (! isset($detail['page']))
$this->_template[$template]['empty_attrs'][$index]['page'] = 1;
if (! isset($detail['order']))
$this->_template[$template]['empty_attrs'][$index]['order'] = 255;
}
# Check we have some manditory items.
foreach (array('rdn','structural','visible') as $key) {
if (! isset($this->_template[$template][$key])
|| (! is_array($this->_template[$template][$key]) && ! trim($this->_template[$template][$key]))) {
//unset($this->_template[$template]);
$this->_template[$template]['invalid'] = 1;
break;
}
}
}
function _parseXML($index,$attr_details) {
debug_log(sprintf('%s::_parseXML(): Entered with (%s,%s)',get_class($this),$index,serialize($attr_details)),2);
if (! $attr_details) {
return "";
} elseif (isset($attr_details['#text'])) {
return $attr_details['#text'];
}
foreach ($attr_details as $key => $values) {
$parseXML[$key] = $this->_parseXML($index,$values);
}
return $parseXML;
}
function getTemplate($template) {
return isset($this->_template[$template]) ? $this->_template[$template] : null;
}
function OnChangeAdd($function) {
debug_log(sprintf('%s::OnChangeAdd(): Entered with (%s)',get_class($this),$function),2);
global $js;
list($command,$arg) = split(':',$function);
switch ($command) {
#autoFill:attr,string (with %attr%)
#@todo: The autofill mods need to be more flexible, so that multiple can be used eg: /T/l
case 'autoFill' :
list($attr,$string) = split(',',$arg);
preg_match_all('/%(\w+)(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U',$string,$matchall);
//print"<PRE>";print_r($matchall); //0 = highlevel match, 1 = attr, 2 = subst, 3 = mod
$html = sprintf('autoFill%s(this.form)',$attr);
if (! isset($js["autoFill".$attr]) ) {
$js["autoFill".$attr] = sprintf("\nfunction autoFill%s( form ) {\n",$attr);
$formula = $string;
$formula = preg_replace('/^([^%])/','\'$1',$formula);
$formula = preg_replace('/([^%])$/','$1\'',$formula);
foreach ($matchall[0] as $index => $null) {
$substrarray = array();
$js["autoFill".$attr] .= sprintf(" var %s;\n",$matchall[1][$index]);
if (trim($matchall[2][$index])) {
preg_match_all('/([0-9]*)-([0-9]*)/',$matchall[2][$index],$substrarray);
}
if ($matchall[3][$index] == "/T") {
$js["autoFill".$attr] .= sprintf(" %s = form.%s.options[form.%s.selectedIndex].text;\n",
$matchall[1][$index],$matchall[1][$index],$matchall[1][$index]);
} else {
if ((isset($substrarray[1][0]) && $substrarray[1][0]) || (isset($substrarray[2][0]) && $substrarray[2][0])) {
$js["autoFill".$attr] .= sprintf(" %s = form.%s.value.substr(%s,%s)",
$matchall[1][$index],$matchall[1][$index],
$substrarray[1][0] ? $substrarray[1][0] : '0',
$substrarray[2][0] ? $substrarray[2][0] : sprintf('form.%s.value.length',$matchall[1][$index]));
} else {
$js["autoFill".$attr] .= sprintf(" %s = form.%s.value",$matchall[1][$index],$matchall[1][$index]);
}
switch ($matchall[3][$index]) {
case '/l':
$js["autoFill".$attr] .= ".toLowerCase()";
break;
}
$js["autoFill".$attr] .= ";\n";
}
$formula = preg_replace('/^%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','$1 + \'',$formula);
$formula = preg_replace('/%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%$/U','\' + $1 ',$formula);
$formula = preg_replace('/%('.$matchall[1][$index].')(\|[0-9]*-[0-9]*)?(\/[lTU])?%/U','\' + $1 + \'',$formula);
}
$js["autoFill".$attr] .= sprintf(" form.%s.value = %s;\n",$attr,$formula);
$js["autoFill".$attr] .= "}\n";
}
break;
default: $html = '';
}
return $html;
}
function OnChangeDisplay() {
global $js;
return (isset($js) ? implode("\n",$js) : '');
}
function EvaluateDefault($ldapserver,$default,$container,$counter='') {
debug_log(sprintf('%s::EvaluateDefault(): Entered with (%s,%s,%s,%s)',
get_class($this),$ldapserver->server_id,$default,$container,$counter),2);
global $lang;
if (preg_match('/^=php\.(\w+)\((.*)\)$/',$default,$matches)) {
$args = preg_split('/,/',$matches[2]);
switch($matches[1]) {
case 'GetNextNumber' :
$container = get_container_parent ($container, $args[0]);
$detail['default'] = get_next_uid_number($ldapserver, $container, $args[1]);
break;
case 'PickList' :
$container = get_container_parent ($container, $args[0]);
preg_match_all('/%(\w+)(\|.+)?(\/[lU])?%/U',$args[3],$matchall);
//print_r($matchall); // -1 = highlevel match, 1 = attr, 2 = subst, 3 = mod
$ldap_attrs = $matchall[1];
array_push($ldap_attrs,$args[2]);
$picklistvalues = return_ldap_hash($ldapserver,$container,$args[1],$args[2],$ldap_attrs);
$detail['default'] = sprintf('<select name="form[%s]" id="%%s" %%s %%s/>',$args[2]);
foreach ($picklistvalues as $key => $values) {
$display = $args[3];
foreach ($matchall[1] as $arg) {
$display = preg_replace('/%('.$arg.')(\|.+)?(\/[lU])?%/U',$values[$arg],$display);
}
if (! isset($picklist[$display])) {
$detail['default'] .= sprintf('<option name="%s" value="%s">%s</option>',$display,$values[$args[2]],$display);
$picklist[$display] = true;
}
}
$detail['default'] .= '</select>';
break;
case 'RandomPassword' :
$detail['default'] = password_generate();
printf('<script language="javascript">alert(\'%s:\n%s\')</script>',
$lang['random_password'],$detail['default']);
break;
case 'DrawChooserLink' :
$detail['default'] = draw_chooser_link(sprintf("template_form.%s%s",$args[0],$counter),$args[1]);
break;
case 'Function' :
# Capture the function name and remove function name from $args
$function_name = array_shift($args);
# Call the PHP function if exists (PHP 4 >= 4.0.4, PHP 5)
if (function_exists($function_name))
$detail['default'] = call_user_func_array($function_name,$args);
break;
default : $detail['default'] = 'UNKNOWN';
}
$return = $detail['default'];
} else {
$return = $default;
}
debug_log(sprintf('%s::EvaluateDefault(): Returning (%s)',get_class($this),serialize($return)),1);
return $return;
}
function HelperValue($helper,$id='',$container='',$ldapserver='',$counter='',$default='') {
debug_log(sprintf('%s::HelperValue(): Entered with (%s,%s,%s,%s,%s,%s)',
get_class($this),count($helper),$id,$container,$ldapserver->server_id,$counter,$default),2);
$html = '';
if ($container && $ldapserver && ! is_array($helper)) {
return $this->EvaluateDefault($ldapserver,$helper,$container,$counter);
} else {
if (is_array($helper)) {
$html = sprintf('<select name="%s" id="%s" />',$id,$id);
foreach ($helper as $value) {
$html .= sprintf('<option name="%s" value="%s" %s>%s</option>',
$value,$value,($default == $value ? 'selected' : ''),$value);
}
$html .= '</select>';
} else {
print "ERROR: HelperValue NOT complete, how did you get HERE?";
die();
}
}
return $html;
}
}
?>

92
lib/timeout_functions.php Normal file
View File

@@ -0,0 +1,92 @@
<?php
/**
* A collection of functions used throughout phpLDAPadmin for the timeout and automatic logout feature
* @author Samuel Tran
* @package phpLDAPadmin
*
*/
/**
* Responsible for setting/updating two session-vars that are used for the timeout and auto logout feature:
* - "activity" var records the server last activity.
* - "rightframe_server_id" var records the ID of the server active on the right frame.
* where X is the * ID of the server which the user is working on
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
* @return bool
*/
function set_lastactivity( $ldapserver ) {
debug_log(sprintf('set_lastactivity(): Entered with (%s)',$ldapserver->server_id),2);
$_SESSION['activity']['server'][$ldapserver->server_id] = time();
$_SESSION['activity']['rightframe_server_id'] = $ldapserver->server_id;
return true;
}
/**
* Remove the session-var "lastactivity_X" set by update_lastactivity()
* where X is the * ID of the server
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
*/
function unset_lastactivity( $ldapserver ) {
debug_log(sprintf('unset_lastactivity(): Entered with (%s)',$ldapserver->server_id),2);
if (isset($_SESSION['activity']['server'][$ldapserver->server_id])) {
unset($_SESSION['activity']['server'][$ldapserver->server_id]);
session_write_close();
}
}
/**
* Check if custom session timeout has been reached for server $ldapserver.
* If it has:
* - automatically log out user by calling unset_login_dn( $server_id )
* - if $server_id is equal to right frame $server_id, load timeout.php page in the right frame
* - return true
*
* @param object $ldapserver The LDAPServer object of the server which the user has logged in.
* @return bool true on success, false on failure.
*/
function session_timed_out( $ldapserver ) {
debug_log(sprintf('session_timed_out(): Entered with (%s)',$ldapserver->server_id),2);
global $lang;
# If session hasn't expired yet
if( isset( $_SESSION[ 'activity' ]['server'][$ldapserver->server_id] ) ) {
// If $session_timeout not defined, use ( session_cache_expire() - 1 )
if (! isset($ldapserver->session_timeout))
$session_timeout = session_cache_expire()-1;
else
$session_timeout = $ldapserver->session_timeout;
// Get the $last_activity and $rightframe_server_id value
$last_activity = $_SESSION['activity']['server'][$ldapserver->server_id];
$rightframe_server_id = $_SESSION['activity']['rightframe_server_id'];
// If diff between current time and last activity greater than $session_timeout, log out user
if ( ( time()-$last_activity ) > ( $session_timeout*60 ) ) {
if( in_array($ldapserver->auth_type, array('cookie','session')) ) {
syslog_notice ( "Logout for " . get_logged_in_dn( $ldapserver ) );
unset_login_dn( $ldapserver ) or pla_error( $lang['could_not_logout'] );
}
// If $ldapserver->server_id equal $rightframe_server_id load timeout page on right frame
if ( $ldapserver->server_id == $rightframe_server_id ) { ?>
<SCRIPT LANGUAGE="JavaScript">
<!--
parent.right_frame.location.href = 'timeout.php?server_id=<?php echo $ldapserver->server_id; ?>';
//--></SCRIPT>
<?php }
return true;
} else
return false;
}
}

299
lib/tree_functions.php Normal file
View File

@@ -0,0 +1,299 @@
<?php
// $Header: /cvsroot/phpldapadmin/phpldapadmin/tree_functions.php,v 1.19 2005/09/25 16:11:44 wurley Exp $
/**
* @package phpLDAPadmin
* @author The phpLDAPadmin development team
*/
/**
* This function displays the LDAP tree for all the servers that you have
* in config.php. We read the session variable 'tree' to know which
* dns are expanded or collapsed. No query string parameters are expected,
* however, you can use a '#' offset to scroll to a given dn. The syntax is
* tree.php#<server_id>_<rawurlencoded dn>, so if I wanted to scroll to
* dc=example,dc=com for server 3, the URL would be:
* tree.php#3_dc%3Dexample%2Cdc%3Dcom
*/
function draw_server_tree() {
debug_log(sprintf('draw_server_tree(): Entered with ()'),2);
global $lang;
global $tree;
global $tree_icons;
global $ldapserver;
global $recently_timed_out_servers;
global $config;
$server_id = $ldapserver->server_id;
// Does this server want mass deletion availble?
if ($ldapserver->isMassDeleteEnabled()) {
print '<form name="mass_delete" action="mass_delete.php" method="post" target="right_frame">';
printf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
}
print '<tr class="server">';
printf('<td class="icon"><img src="images/server.png" alt="%s" /></td>',$lang['server']);
printf('<td colspan="99"><a name="%s"></a>',$ldapserver->server_id);
printf('<nobr>%s ',htmlspecialchars($ldapserver->name));
if ($ldapserver->haveAuthInfo() && $ldapserver->session_timeout)
printf('<acronym title="%s"><img widht=14 height=14 src="images/timeout.png" alt="timeout"><acronym>',
sprintf($lang['timeout_at'],strftime('%H:%M',time()+($ldapserver->session_timeout*60))));
print '</nobr></td></tr>';
// do we have what it takes to authenticate here, or do we need to
// present the user with a login link (for 'cookie' and 'session' auth_types)?
if ($ldapserver->haveAuthInfo()) {
if ($ldapserver->connect(false)) {
$schema_href = sprintf('schema.php?server_id=%s" target="right_frame',$ldapserver->server_id);
$search_href = sprintf('search.php?server_id=%s" target="right_frame',$ldapserver->server_id);
$refresh_href = sprintf('refresh.php?server_id=%s',$ldapserver->server_id);
$logout_href = get_custom_file($ldapserver->server_id,'logout.php','').'?server_id='.$ldapserver->server_id;
$info_href = sprintf('server_info.php?server_id=%s',$ldapserver->server_id);
$import_href = sprintf('ldif_import_form.php?server_id=%s',$ldapserver->server_id);
$export_href = sprintf('export_form.php?server_id=%s',$ldapserver->server_id);
// Draw the quick-links below the server name:
// ( schema | search | refresh | create )
echo '<tr><td colspan="100" class="links">';
echo '<nobr>';
echo '( ';
echo '<a title="' . $lang['view_schema_for'] . ' ' . $ldapserver->name . '"'.
' href="' . $schema_href . '">' . $lang['schema'] . '</a> | ';
echo '<a title="' . $lang['search'] . ' ' . $ldapserver->name . '"' .
' href="' . $search_href . '">' . $lang['search'] . '</a> | ';
echo '<a title="' . $lang['refresh_expanded_containers'] . ' ' . $ldapserver->name . '"'.
' href="' . $refresh_href . '">' . $lang['refresh'] . '</a> | ';
// if ($ldapserver->isShowCreateEnabled())
// echo '<a title="' . $lang['create_new_entry_on'] . ' ' . $ldapserver->name . '"'.
// ' href="' . sprintf('create_form.php?server_id=%s',$server_id) . '" target="right_frame">' . $lang['create'] . '</a> | ';
echo '<a title="' . $lang['view_server_info'] . '" target="right_frame" '.
'href="' . $info_href . '">' . $lang['info'] . '</a> | ';
echo '<a title="' . $lang['import_from_ldif'] . '" target="right_frame" ' .
'href="' . $import_href .'">' . $lang['import'] . '</a> | ';
echo '<a href="' . $export_href . '" target="right_frame">' . $lang['export_lcase'] . '</a>';
if( $ldapserver->auth_type != 'config' )
echo ' | <a title="' . $lang['logout_of_this_server'] . '" href="' . $logout_href .
'" target="right_frame">' . $lang['logout'] . '</a>';
echo ' )</nobr></td></tr>';
if ($ldapserver->auth_type != 'config') {
$logged_in_dn = get_logged_in_dn( $ldapserver );
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" . $lang['logged_in_as'];
if (dn_get_base($ldapserver,$logged_in_dn) == $logged_in_dn) {
$logged_in_branch = '';
$logged_in_dn_array = array();
} else {
$logged_in_branch = preg_replace("/,".dn_get_base($ldapserver,$logged_in_dn)."$/","",$logged_in_dn);
$logged_in_dn_array = explode(',',$logged_in_branch);
}
$logged_in_dn_array[] = dn_get_base($ldapserver,$logged_in_dn);
$rdn = $logged_in_dn;
if (strcasecmp("anonymous",$logged_in_dn)) {
foreach ($logged_in_dn_array as $rdn_piece) {
printf('<a class="logged_in_dn" href="edit.php?server_id=%s&amp;dn=%s" target="right_frame">%s</a>',
$server_id,rawurlencode($rdn),pretty_print_dn($rdn_piece));
if ($rdn_piece != end($logged_in_dn_array))
echo ',';
$rdn = substr($rdn,(1 + strpos($rdn,',')));
}
} else
echo "Anonymous";
echo "</nobr></td></tr>";
}
if( $ldapserver->isReadOnly() )
echo "<tr><td class=\"links\" colspan=\"100\"><nobr>" .
"(" . $lang['read_only'] . ")</nobr></td></tr>";
$javascript_forms = '';
$javascript_id = 0;
foreach ($ldapserver->getBaseDN() as $base_dn) {
// Did we get a base_dn for this server somehow?
if ($base_dn) {
echo "\n\n<!-- base DN row -->\n<tr>\n";
// is the root of the tree expanded already?
if( isset( $tree[$ldapserver->server_id][$base_dn] ) ) {
$expand_href = sprintf('collapse.php?server_id=%s&amp;dn=%s',
$ldapserver->server_id,rawurlencode( $base_dn ));
$expand_img = "images/minus.png";
$expand_alt = "-";
$child_count = number_format( count( $tree[$ldapserver->server_id][$base_dn] ) );
} else {
// Check if the LDAP server is not yet initialized
// (ie, the base DN configured in config.php does not exist)
if( ! dn_exists( $ldapserver, $base_dn ) ) {
$javascript_id++;
?>
<tr>
<td class="spacer"></td>
<td><img src="images/unknown.png" /></td>
<td colspan="98"><?php echo pretty_print_dn( $base_dn ); ?></td>
</tr>
<?php // Move this form and add it to the end of the html - otherwise the javascript
// doesnt work when isMassDeleteEnabled returning true.
$javascript_forms .= sprintf('<form name="create_base_form_%s" method="post" action="creation_template.php" target="right_frame">',$javascript_id);
$javascript_forms .= sprintf('<input type="hidden" name="template" value="custom" />');
$javascript_forms .= sprintf('<input type="hidden" name="server_id" value="%s" />',$ldapserver->server_id);
$javascript_forms .= sprintf('<input type="hidden" name="container" value="" />');
$javascript_forms .= sprintf('<input type="hidden" name="rdn" value="%s" />',htmlspecialchars($base_dn));
$javascript_forms .= sprintf('</form>'); ?>
<tr>
<td class="spacer"></td>
<td colspan="98">
<small><?php echo $lang['base_entry_does_not_exist']; ?>
<a href="javascript:document.create_base_form_<?php echo $javascript_id ?>.submit()"><?php echo $lang['create_it']; ?></a></small>
</td>
</tr>
<?php
continue;
} else {
$expand_href = sprintf('expand.php?server_id=%s&amp;dn=%s',
$ldapserver->server_id,rawurlencode( $base_dn ));
$expand_img = "images/plus.png";
$expand_alt = "+";
$size_limit = $config->GetValue('search','size_limit');
if( $ldapserver->isLowBandwidth() ) {
$child_count = null;
} else {
$child_count = count( get_container_contents(
$ldapserver, $base_dn, $size_limit+1,
'(objectClass=*)', $config->GetValue('deref','tree') ) );
if( $child_count > $size_limit )
$child_count = $size_limit . '+';
}
}
}
$create_href = sprintf('create_form.php?server_id=%s&amp;container=%s',$ldapserver->server_id,
rawurlencode( $base_dn ));
$edit_href = sprintf("edit.php?server_id=%s&amp;dn=%s",$ldapserver->server_id,rawurlencode( $base_dn ));
$icon = isset( $tree_icons[ $ldapserver->server_id ][ $base_dn ] )
? $tree_icons[ $ldapserver->server_id ][ $base_dn ]
: get_icon( $ldapserver, $base_dn );
// Shall we draw the "mass-delete" checkbox?
if( $ldapserver->isMassDeleteEnabled() ) {
echo "<td><input type=\"checkbox\" name=\"mass_delete[" . htmlspecialchars($base_dn) . "]\" /></td>\n";
}
echo "<td class=\"expander\">";
echo "<a href=\"$expand_href\"><img src=\"$expand_img\" alt=\"$expand_alt\" /></a></td>";
echo "<td class=\"icon\"><a href=\"$edit_href\" target=\"right_frame\">";
echo "<img src=\"images/$icon\" alt=\"img\" /></a></td>\n";
echo "<td class=\"rdn\" colspan=\"98\"><nobr><a href=\"$edit_href\" ";
echo " target=\"right_frame\">" . pretty_print_dn( $base_dn ) . '</a>';
if( $child_count )
echo " <span class=\"count\">($child_count)</span>";
echo "</nobr></td>\n";
echo "</tr>\n<!-- end of base DN row -->";
if( $ldapserver->isShowCreateEnabled() && isset( $tree[ $ldapserver->server_id ][ $base_dn ])
&& count( $tree[ $ldapserver->server_id ][ $base_dn ] ) > 10 )
draw_create_link( $ldapserver->server_id, $base_dn, -1, urlencode( $base_dn ));
} else { // end if( $base_dn )
# The server refuses to give out the base dn
printf('<tr><td class="spacer"></td><td colspan="98"><small>%s<br />%s<br /><b>%s</b></small></td></tr>',
$lang['could_not_determine_root'],$lang['ldap_refuses_to_give_root'],$lang['please_specify_in_config']);
# Proceed to the next server. We cannot draw anything else for this server.
continue;
}
flush();
// Is the root of the tree expanded already?
if( isset( $tree[$ldapserver->server_id][$base_dn] ) && is_array( $tree[$ldapserver->server_id][$base_dn] ) ) {
foreach( $tree[ $ldapserver->server_id ][ $base_dn ] as $child_dn )
draw_tree_html( $child_dn, $ldapserver, 0 );
if( ! $ldapserver->isReadOnly() ) {
echo '<tr><td class="spacer"></td>';
if( $ldapserver->isShowCreateEnabled() ) {
echo '<td class="icon"><a href="' . $create_href .
'" target="right_frame"><img src="images/star.png" alt="' .
$lang['new'] . '" /></a></td>';
echo '<td class="create" colspan="100"><a href="' . $create_href
. '" target="right_frame" title="' . $lang['create_new_entry_in']
. ' ' . $base_dn.'">' . $lang['create_new'] . '</a></td></tr>';
}
}
}
}
} else { // end if( $ldapserver->connect(false) )
// could not connect to LDAP server
echo "<tr>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td><img src=\"images/warning_small.png\" alt=\"" . $lang['warning'] . "\" /></td>\n";
echo "<td colspan=\"99\"><small><span style=\"color:red\">" . $lang['could_not_connect'] . "</span></small></td>\n";
echo "</tr>\n";
if( $ldapserver->auth_type != 'config' ) {
$logout_href = get_custom_file( $ldapserver->server_id, 'logout.php','') . '?server_id=' . $ldapserver->server_id;
echo "<tr>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td class=\"spacer\"></td>\n";
echo "<td colspan=\"99\"><small>";
echo "<a target=\"right_frame\" href=\"$logout_href\">" . $lang['logout'] . "</a></small></td>\n";
echo "</tr>\n";
}
// Proceed to the next server in the list. We cannot do anything mroe here.
return;
}
} else { // end if $ldapserver->haveAuthInfo()
// We don't have enough information to login to this server
// Draw the "login..." link
$login_href = get_custom_file( $ldapserver->server_id, 'login_form.php','' ) . "?server_id=$server_id";
echo '<tr class="login">';
echo '<td class="spacer"></td>';
echo '<td><a href="' . $login_href . '" target="right_frame">';
echo '<img src="images/uid.png" align="top" alt="' . $lang['login'] . '" /></a></td>';
echo '<td colspan="99"><a href="' . $login_href . '" target="right_frame">' . $lang['login_link'] . '</a>';
echo '</td></tr>';
// If the server recently timed out display the message
if ( in_array($ldapserver->server_id,$recently_timed_out_servers) )
echo '<tr><td class="spacer"></td><td colspan="100" class="links">' . $lang['session_timed_out_tree'] . '</td></tr>';
}
if( $ldapserver->isMassDeleteEnabled() ) {
echo "<tr><td colspan=\"99\"><input type=\"submit\" value=\"Delete Checked Entries\" \></td></tr>\n";
echo "<!-- The end of the mass deletion form -->\n";
echo "</form>\n";
}
if (isset($javascript_forms) && $javascript_forms) {
echo "<!-- Forms for javascript submit to call to create base_dns -->\n";
echo $javascript_forms;
echo "<!-- The end of the forms for javascript submit to call to create base_dns -->\n";
}
}
?>