< ? p h p 
 
 / / i n c l u d i n g   n e e d e d   f i l e s 
 
 i n c l u d e ( " . . / . . / i n c / c l a r o _ i n i t _ g l o b a l . i n c . p h p " ) ;   
 
 i n c l u d e _ o n c e   ( a p i _ g e t _ l i b r a r y _ p a t h ( ) . " / c o u r s e . l i b . p h p " ) ; 
 
 i n c l u d e _ o n c e   ( a p i _ g e t _ l i b r a r y _ p a t h ( ) . " / g r o u p m a n a g e r . l i b . p h p " ) ; 
 
 i n c l u d e _ o n c e   ( a p i _ g e t _ l i b r a r y _ p a t h ( ) . " / t e x t . l i b . p h p " ) ; 
 
 / / e r r o r _ r e p o r t i n g ( E _ A L L ) ; 
 
 
 
 $ t o o l _ n a m e   =   " W i k i " ;   / /   t i t l e   o f   t h e   p a g e   ( s h o u l d   c o m e   f r o m   t h e   l a n g u a g e   f i l e )   
 
 
 
 i f   ( $ _ S E S S I O N [ ' _ g i d ' ]   O R   $ _ G E T [ ' g r o u p _ i d ' ] ) 
 
 { 
 
 	 i f   ( i s s e t ( $ _ S E S S I O N [ ' _ g i d ' ] ) ) 
 
 	 { 
 
 	 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 } 
 
 	 i f   ( i s s e t ( $ _ G E T [ ' g r o u p _ i d ' ] ) ) 
 
 	 { 
 
 	 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ G E T [ ' g r o u p _ i d ' ] ; 
 
 	 } 
 
 	 $ c u r r e n t _ g r o u p   =   G r o u p M a n a g e r   : :   g e t _ g r o u p _ p r o p e r t i e s ( $ _ c l e a n [ ' g r o u p _ i d ' ] ) ; 
 
 	 $ i n t e r b r e d c r u m p [ ]   =   a r r a y   ( " u r l "   = >   " . . / g r o u p / g r o u p _ s p a c e . p h p ? g i d R e q = " . $ _ c l e a n [ ' g r o u p _ i d ' ] ,   " n a m e "   = >   $ c u r r e n t _ g r o u p [ ' n a m e ' ] ) ; 
 
 	 $ g r o u p f i l t e r = ' g r o u p _ i d = " ' . $ _ c l e a n [ ' g r o u p _ i d ' ] . ' " ' ; 
 
 } 
 
 e l s e 
 
 { 
 
 	 $ g r o u p f i l t e r = ' g r o u p _ i d   I S   N U L L ' ; 
 
 } 
 
 
 
 D i s p l a y : : d i s p l a y _ h e a d e r ( $ t o o l _ n a m e ) ; 
 
 	 
 
 a p i _ d i s p l a y _ t o o l _ t i t l e ( $ t o o l _ n a m e ) ; 
 
 
 
 $ n o t _ a l l o w e d _ t i t l e s = a r r a y ( " I n d e x " ,   " R e c e n t C h a n g e s " , " A l l P a g e s " ,   " C a t e g o r i e s " ) ; 
 
 
 
 / * * 
 
 S o m e   l a n g u a g e   v a r i a b l e s 
 
 * / 
 
 i f   ( $ G L O B A L S [ " H T T P _ S E S S I O N _ V A R S " ] [ ' _ c o u r s e ' ] [ ' l a n g u a g e ' ]   = =   ' g r e e k ' )   { 
 
 	 i n c l u d e _ o n c e ( ' g r e e k . i n c . p h p ' ) ; 
 
 }   e l s e   { 
 
 $ S t a r t P a g e = " S t a r t   P a g e " ; 
 
 $ E d i t T h i s P a g e = " E d i t   t h i s   p a g e " ; 
 
 $ S h o w P a g e H i s t o r y = " P a g e   H i s t o r y " ; 
 
 $ R e c e n t C h a n g e s = ' R e c e n t   C h a n g e s ' ; 
 
 $ A l l P a g e s = ' A l l   P a g e s ' ; 
 
 $ A d d N e w = ' A d d   a   n e w   p a g e ' ; 
 
 $ C h a n g e s S t o r e d = ' Y o u r   c h a n g e s   h a v e   b e e n   s t o r e d . ' ; 
 
 $ E x p l a i n R e c e n t c h a n g e s = ' O n   t h i s   p a g e   y o u   s e e   a l l   t h e   l a t e s t   c h a n g e s .   T h e   f i r s t   c o l u m n   d i s p l a y s   t h e   d a t e   o f   t h e   c h a n g e .   C l i c k i n g   t h i s   c o l u m n   b r i n g s   y o u   t o   t h a t   s p e c i f i c   ( o l d e r )   v e r s i o n .   T h e   s e c o n d   c o l u m n   d i s p l a y s   t h e   t i t l e   t h a t   h a s   b e e n   c h a n g e d .   C l i c k i n g   t h a t   c o l u m n   t a k e s   y o u   t o   t h e   l a t e s t   ( m o s t   r e c e n t )   v e r s i o n   o f   t h a t   t i t l e .   T h e   t h i r d   c o l u m n   d i s p l a y s   w h o   h a s   c h a n g e d   i t .   C l i c k i n g   t h a t   l i n k   b r i n g s   y o u   t o   t h e   p r o f i l e   o f   t h e   u s e r . ' ; 
 
 $ N e w W i k i S a v e d = ' T h e   n e w   w i k i   e n t r y   h a s   b e e n   s a v e d .   Y o u   c a n   v i e w   i t   b y   c l i c k i n g :   ' ; 
 
 $ D e f a u l t C o n t e n t = ' T h i s   i s   t h e   d e f a u l t   t e x t   f o r   t h e   s t a r t   p a g e .   Y o u   c a n   w r i t e   s o m e   t e x t   h e r e   b y   c l i c k i n g   t h e   " e d i t   t h i s   p a g e "   l i n k ' ; 
 
 $ D e f a u l t T i t l e = ' S t a r t   P a g e ' ; 
 
 $ S u b m i t   =   ' S u b m i t ' ; 
 
 } 
 
 
 
 / * * 
 
 S o m e   C S S   s t y l e s 
 
 * / 
 
 ? > 
 
 < s t y l e   t y p e = " t e x t / c s s " > 
 
 < ! - - 
 
 # w i k i t i t l e   { 
 
 	 f o n t - f a m i l y :   V e r d a n a ,   A r i a l ,   H e l v e t i c a ,   s a n s - s e r i f ; 
 
 	 f o n t - s i z e :   1 0 0 % ; 
 
 	 f o n t - w e i g h t :   b o l d ; 
 
 	 b a c k g r o u n d - c o l o r :   # E F E F E F ; 
 
 	 b o r d e r - b o t t o m - w i d t h :   2 p x ; 
 
 	 b o r d e r - b o t t o m - s t y l e :   s o l i d ; 
 
 	 b o r d e r - b o t t o m - c o l o r :   # 3 3 3 3 3 3 ; 
 
 	 p a d d i n g :   3 p x ; 
 
 } 
 
 # m e n u w i k i   { 
 
 	 b a c k g r o u n d - c o l o r :   # F F F F F F ; 
 
 } 
 
 
 
 # m e n u w i k i   l i { 
 
 	 d i s p l a y :   i n l i n e ;   
 
 } 
 
 - - > 
 
 < / s t y l e > 
 
 < ? p h p 
 
 / / t h e   p a g e   w e   a r e   d e a l i n g   w i t h 
 
 i f   ( ! i s s e t ( $ _ G E T [ ' t i t l e ' ] ) ) 
 
 { 
 
 	 $ p a g e = ' i n d e x ' ; 
 
 } 
 
 e l s e 
 
 { 
 
 	 $ p a g e = $ _ G E T [ ' t i t l e ' ] ; 
 
 } 
 
 
 
 
 
 e c h o   " < d i v   i d = ' w i k i w r a p p e r ' > " ; 
 
 
 
 / * * 
 
 T h i s   i s   t h e   s m a l l   m e n u   o n   t h e   l e f t 
 
 * / 
 
 e c h o   " < d i v   i d = ' m e n u w i k i ' > " ; 
 
 e c h o   ' < u l > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = s h o w & t i t l e = i n d e x " > ' . $ S t a r t P a g e . ' < / a >   |   < / l i > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = e d i t & t i t l e = ' . $ p a g e . ' " > ' . $ E d i t T h i s P a g e . ' < / a >   |   < / l i > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = h i s t o r y & t i t l e = ' . $ p a g e . ' " > ' . $ S h o w P a g e H i s t o r y . ' < / a >   |   < / l i > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = a d d n e w " > ' . $ A d d N e w . ' < / a >   |   < / l i > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = r e c e n t c h a n g e s " > ' . $ R e c e n t C h a n g e s . ' < / a >   |   < / l i > ' ; 
 
 e c h o   ' < l i > < a   h r e f = " i n d e x . p h p ? a c t i o n = a l l p a g e s " > ' . $ A l l P a g e s . ' < / a > < / l i > ' ; 
 
 e c h o   " < / u l > " ; 
 
 e c h o   " < / d i v > " ; 
 
 
 
 
 
 e c h o   " < d i v   i d = ' m a i n w i k i ' > " ; 
 
 
 
 / /   D a t a b a s e   d e f i n i t i o n 
 
 $ t b l _ w i k i   =   " ` " . $ _ c o u r s e [ ' d b N a m e G l u ' ] . " w i k i ` " ; 
 
 
 
 / /   D a t a b a s e   c r e a t i o n   i f   n o t   c r e a t e d   y e t 
 
 i f   ( m y s q l _ q u e r y ( " S E L E C T   *   F R O M   $ t b l _ w i k i " )   = =   F A L S E ) 
 
 { 
 
 	 	 / /   c r e a t e   t h e   t a b l e   t h a t   c o n t a i n s   t h e   m e s s a g e s 
 
 	 	 $ s q l = " C R E A T E   T A B L E   " . $ t b l _ w i k i . "   ( 
 
 	 	 	     ` i d `   i n t ( 1 1 )   N O T   N U L L   a u t o _ i n c r e m e n t , 
 
 	 	 	     ` r e f l i n k `   v a r c h a r ( 2 5 0 )   N O T   N U L L   d e f a u l t   ' i n d e x ' , 
 
 	 	 	     ` t i t l e `   t e x t   N O T   N U L L , 
 
 	 	 	     ` c o n t e n t `   t e x t   N O T   N U L L , 
 
 	 	 	     ` u s e r _ i d `   i n t ( 1 1 )   N O T   N U L L   d e f a u l t   ' 0 ' , 
 
 	 	 	     ` g r o u p _ i d `   i n t ( 1 1 )   d e f a u l t   N U L L , 
 
 	 	 	     ` t i m e s t a m p `   t i m e s t a m p ( 1 4 )   N O T   N U L L , 
 
 	 	 	     P R I M A R Y   K E Y     ( ` i d ` ) 
 
 	 	 	 )   T Y P E = M y I S A M " ; 
 
 	 	 $ r e s u l t = m y s q l _ q u e r y ( $ s q l )   o r   d i e ( m y s q l _ e r r o r ( ) ) ; 
 
 } 
 
 
 
 / /   s a v i n g   a   c h a n g e 
 
 i f   ( $ _ P O S T [ ' S a v e W i k i C h a n g e ' ]   A N D   $ _ P O S T [ ' r e f l i n k ' ] < > ' ' ) 
 
 { 
 
 	 $ _ c l e a n [ ' r e f l i n k ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( $ _ P O S T [ ' r e f l i n k ' ] ) ; 
 
 	 $ _ c l e a n [ ' t i t l e ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( $ _ P O S T [ ' t i t l e ' ] ) ; 
 
 	 $ _ c l e a n [ ' c o n t e n t ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( $ _ P O S T [ ' c o n t e n t ' ] ) ; 
 
 	 $ _ c l e a n [ ' c o n t e n t ' ] = $ _ P O S T [ ' c o n t e n t ' ] ; 
 
 	 $ _ c l e a n [ ' u s e r _ i d ' ] = ( i n t ) $ _ u i d ; 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 
 
 	 $ s q l = " I N S E R T   I N T O   " . $ t b l _ w i k i . "   ( r e f l i n k ,   t i t l e , c o n t e n t , u s e r _ i d )   V A L U E S   ( ' " . $ _ c l e a n [ ' r e f l i n k ' ] . " ' , ' " . $ _ c l e a n [ ' t i t l e ' ] . " ' , ' " . $ _ c l e a n [ ' c o n t e n t ' ] . " ' , ' " . $ _ c l e a n [ ' u s e r _ i d ' ] . " ' ) " ; 
 
 	 i f   ( $ _ S E S S I O N [ ' _ g i d ' ] ) 
 
 	 { 
 
 	 	 $ s q l = " I N S E R T   I N T O   " . $ t b l _ w i k i . "   ( r e f l i n k ,   t i t l e , c o n t e n t , u s e r _ i d ,   g r o u p _ i d )   V A L U E S   ( ' " . $ _ c l e a n [ ' r e f l i n k ' ] . " ' , ' " . $ _ c l e a n [ ' t i t l e ' ] . " ' , ' " . $ _ c l e a n [ ' c o n t e n t ' ] . " ' , ' " . $ _ c l e a n [ ' u s e r _ i d ' ] . " ' , ' " . $ _ c l e a n [ ' g r o u p _ i d ' ] . " ' ) " ; 
 
 	 } 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l ) ; 
 
 	 D i s p l a y : : d i s p l a y _ n o r m a l _ m e s s a g e ( $ C h a n g e s S t o r e d ) ; 
 
 } 
 
 
 
 / /   s a v i n g   a   n e w   w i k i   e n t r y 
 
 i f   ( $ _ P O S T [ ' S a v e W i k i N e w ' ] ) 
 
 { 
 
 	 
 
 	 / /   c l e a n i n g   t h e   v a r i a b l e s 
 
 	 $ _ c l e a n [ ' r e f l i n k ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( s t r _ r e p l a c e ( '   ' , ' ' , $ _ P O S T [ ' t i t l e ' ] ) ) ; 
 
 	 $ _ c l e a n [ ' t i t l e ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( $ _ P O S T [ ' t i t l e ' ] ) ; 
 
 	 $ _ c l e a n [ ' c o n t e n t ' ] = m y s q l _ r e a l _ e s c a p e _ s t r i n g ( $ _ P O S T [ ' c o n t e n t ' ] ) ; 
 
 	 $ _ c l e a n [ ' u s e r _ i d ' ] = ( i n t ) $ _ u i d ; 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 
 
 	 / /   c h e c k i n g   i f   t h e   c u r r e n t   d e f a u l t   r e f l i n k   i s   n o t   i n   u s e   y e t 
 
 	 $ v a r = $ _ c l e a n [ ' r e f l i n k ' ] ; 
 
 	 $ _ c l e a n [ ' r e f l i n k ' ] = c r e a t e r e f l i n k ( $ v a r ) ; 
 
 
 
 	 $ s q l = " I N S E R T   I N T O   " . $ t b l _ w i k i . "   ( r e f l i n k ,   t i t l e , c o n t e n t , u s e r _ i d )   V A L U E S   ( ' " . $ _ c l e a n [ ' r e f l i n k ' ] . " ' , ' " . $ _ c l e a n [ ' t i t l e ' ] . " ' , ' " . $ _ c l e a n [ ' c o n t e n t ' ] . " ' , ' " . $ _ c l e a n [ ' u s e r _ i d ' ] . " ' ) " ; 
 
 	 i f   ( $ _ S E S S I O N [ ' _ g i d ' ] ) 
 
 	 { 
 
 	 	 $ s q l = " I N S E R T   I N T O   " . $ t b l _ w i k i . "   ( r e f l i n k ,   t i t l e , c o n t e n t , u s e r _ i d ,   g r o u p _ i d )   V A L U E S   ( ' " . $ _ c l e a n [ ' r e f l i n k ' ] . " ' , ' " . $ _ c l e a n [ ' t i t l e ' ] . " ' , ' " . $ _ c l e a n [ ' c o n t e n t ' ] . " ' , ' " . $ _ c l e a n [ ' u s e r _ i d ' ] . " ' , ' " . $ _ c l e a n [ ' g r o u p _ i d ' ] . " ' ) " ; 
 
 	 } 	 
 
 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 
 
 	 D i s p l a y : : d i s p l a y _ n o r m a l _ m e s s a g e ( $ N e w W i k i S a v e d . ' < a   h r e f = " i n d e x . p h p ? a c t i o n = s h o w & t i t l e = ' . $ _ c l e a n [ ' r e f l i n k ' ] . ' " > ' . $ _ P O S T [ ' t i t l e ' ] . ' < / a > ' ) ; 
 
 
 
 } 
 
 
 
 / /   A d d   a   n e w   w i k i   e n t r y 
 
 i f   ( $ _ G E T [ ' a c t i o n ' ] = = ' a d d n e w ' ) 
 
 { 
 
 	 e c h o   ' < f o r m   n a m e = " f o r m 1 "   m e t h o d = " p o s t "   a c t i o n = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ p a g e . ' " > ' ; 
 
 	 e c h o   ' < i n p u t   t y p e = " t e x t "   n a m e = " t i t l e "   v a l u e = " ' . $ r o w [ ' t i t l e ' ] . ' " > ' ; 
 
 	 a p i _ d i s p _ h t m l _ a r e a ( ' c o n t e n t ' , ' ' , ' 3 0 0 p x ' ) ;   
 
 	 e c h o   ' < i n p u t   t y p e = " s u b m i t "   n a m e = " S a v e W i k i N e w "   v a l u e = " ' . $ S u b m i t . ' " > ' ; 
 
 	 e c h o   ' < / f o r m > ' ; 
 
 } 
 
 
 
 / /   D i s p l a y i n g   t h e   w i k i   t e x t 
 
 i f   ( ! $ _ G E T [ ' a c t i o n ' ]   O R   $ _ G E T [ ' a c t i o n ' ] = = ' s h o w '   A N D   ! $ _ P O S T [ ' S a v e W i k i N e w ' ] ) 
 
 { 
 
 	 / / $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 i f   ( $ _ G E T [ ' v i e w ' ] ) 
 
 	 { 
 
 	 	 $ _ c l e a n [ ' v i e w ' ] = ( i n t ) $ _ G E T [ ' v i e w ' ] ; 
 
 	 	 $ f i l t e r = "   A N D   i d = ' " . $ _ c l e a n [ ' v i e w ' ] . " ' " ; 
 
 	 } 
 
 	 
 
 	 $ s q l = " S E L E C T   *   F R O M   " . $ t b l _ w i k i . " W H E R E   r e f l i n k = ' " . $ p a g e . " '   A N D   $ g r o u p f i l t e r   $ f i l t e r   O R D E R   B Y   i d   D E S C " ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 	 $ r o w = m y s q l _ f e t c h _ a r r a y ( $ r e s u l t ) ;   / /   w e   d o   n o t   n e e d   a   w h i l e   l o o p   s i n c e   w e   a r e   a l w a y s   d i s p l a y i n g   t h e   l a s t   v e r s i o n 
 
 	 
 
 	 / /   i f   b o t h   a r e   e m p t y   a n d   w e   a r e   d i s p l a y i n g   t h e   i n d e x   p a g e   t h e n   w e   d i s p l a y   t h e   d e f a u l t   t e x t 
 
 	 i f   ( $ r o w [ ' c o n t e n t ' ] = = ' '   A N D   $ r o w [ ' t i t l e ' ] = = ' '   A N D   $ p a g e = ' i n d e x ' ) 
 
 	 { 
 
 	 	 $ c o n t e n t = $ D e f a u l t C o n t e n t ; 
 
 	 	 $ t i t l e = $ D e f a u l t T i t l e ; 
 
 	 } 
 
 	 e l s e 
 
 	 { 
 
 	 	 $ c o n t e n t = $ r o w [ ' c o n t e n t ' ] ; 
 
 	 	 $ t i t l e = $ r o w [ ' t i t l e ' ] ; 	 
 
 	 } 
 
 	 
 
 	 e c h o   ' < d i v   i d = " w i k i t i t l e " > ' . $ t i t l e . ' < / d i v > ' ; 
 
 	 e c h o   $ c o n t e n t ; 
 
 } 
 
 
 
 / /   E d i t i n g   t h e   w i k i   t e x t 
 
 i f   ( $ _ G E T [ ' a c t i o n ' ] = = ' e d i t ' ) 
 
 { 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 
 
 	 $ s q l = ' S E L E C T   *   F R O M   ' . $ t b l _ w i k i . ' W H E R E   r e f l i n k = " ' . $ p a g e . ' "   A N D   ' . $ g r o u p f i l t e r . '   O R D E R   B Y   i d   D E S C ' ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 	 $ r o w = m y s q l _ f e t c h _ a r r a y ( $ r e s u l t ) ;   / /   w e   d o   n o t   n e e d   a   w h i l e   l o o p   s i n c e   w e   a r e   a l w a y s   d i s p l a y i n g   t h e   l a s t   v e r s i o n 
 
 	 
 
 	 i f   ( $ r o w [ ' c o n t e n t ' ] = = ' '   A N D   $ r o w [ ' t i t l e ' ] = = ' '   A N D   $ p a g e = ' i n d e x ' ) 
 
 	 { 
 
 	 	 $ c o n t e n t = $ D e f a u l t C o n t e n t ; 
 
 	 	 $ t i t l e = $ D e f a u l t T i t l e ; 
 
 	 } 
 
 	 e l s e 
 
 	 { 
 
 	 	 $ c o n t e n t = $ r o w [ ' c o n t e n t ' ] ; 
 
 	 	 $ t i t l e = $ r o w [ ' t i t l e ' ] ; 	 
 
 	 } 
 
 	 
 
 	 e c h o   ' < f o r m   n a m e = " f o r m 1 "   m e t h o d = " p o s t "   a c t i o n = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ p a g e . ' " > ' ; 
 
 	 e c h o   ' T i t l e :   < i n p u t   t y p e = " h i d d e n "   n a m e = " r e f l i n k "   v a l u e = " ' . $ p a g e . ' " > ' ; 
 
 	 e c h o   ' < i n p u t   t y p e = " t e x t "   n a m e = " t i t l e "   v a l u e = " ' . $ t i t l e . ' "   s i z e = " 5 0 " > < b r > < b r > ' ; 
 
 	 a p i _ d i s p _ h t m l _ a r e a ( ' c o n t e n t ' , $ c o n t e n t , ' 3 0 0 p x ' ,   ' 2 0 0 p x ' ) ;   
 
 	 e c h o   ' < i n p u t   t y p e = " s u b m i t "   n a m e = " S a v e W i k i C h a n g e "   v a l u e = " ' . $ S u b m i t . ' " > ' ; 
 
 	 e c h o   ' < / f o r m > ' ; 
 
 } 
 
 
 
 / /   P a g e   h i s t o r y 
 
 i f   ( $ _ G E T [ ' a c t i o n ' ] = = ' h i s t o r y ' ) 
 
 { 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 
 
 	 $ s q l = ' S E L E C T   *   F R O M   ' . $ t b l _ w i k i . ' W H E R E   r e f l i n k = " ' . $ p a g e . ' "   A N D   ' . $ g r o u p f i l t e r . '   O R D E R   B Y   i d   D E S C ' ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 	 e c h o   ' < u l > ' ; 
 
 	 w h i l e   ( $ r o w = m y s q l _ f e t c h _ a r r a y ( $ r e s u l t ) ) 
 
 	 { 
 
 	 	 $ u s e r i n f o = D a t a b a s e : : g e t _ u s e r _ i n f o _ f r o m _ i d ( $ r o w [ ' u s e r _ i d ' ] ) ; 
 
 	 	 e c h o   ' < l i > < a   h r e f = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ p a g e . ' & v i e w = ' . $ r o w [ ' i d ' ] . ' " > ' ; 
 
 	 	 e c h o   u c f i r s t ( f o r m a t _ l o c a l e _ d a t e ( $ d a t e F o r m a t L o n g , s t r t o t i m e ( $ r o w [ ' t i m e s t a m p ' ] ) ) ) ; 
 
 	 	 e c h o   ' < / a >   -   < a   h r e f = " . . / . . / u s e r / u s e r I n f o . p h p ? u I n f o = ' . $ u s e r i n f o [ ' u s e r _ i d ' ] . ' " > ' . $ u s e r i n f o [ ' l a s t n a m e ' ] . '   ' . $ u s e r i n f o [ ' f i r s t n a m e ' ] . ' < / a > < / l i > ' ; 
 
 	 	 / / p r i n t _ r ( $ u s e r i n f o ) ; 
 
 	 } 
 
 	 e c h o   ' < / u l > ' ; 	 
 
 } 
 
 
 
 / /   R e c e n t   C h a n g e s 
 
 i f   ( $ _ G E T [ ' a c t i o n ' ] = = ' r e c e n t c h a n g e s ' ) 
 
 { 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 
 
 	 $ s q l = ' S E L E C T   *   F R O M   ' . $ t b l _ w i k i . '   W H E R E   ' . $ g r o u p f i l t e r . '   O R D E R   B Y   t i m e s t a m p   D E S C   L I M I T   0 , 1 0 ' ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 	 e c h o   $ E x p l a i n R e c e n t c h a n g e s ; 
 
 	 e c h o   ' < u l > ' ; 
 
 	 w h i l e   ( $ r o w = m y s q l _ f e t c h _ a r r a y ( $ r e s u l t ) ) 
 
 	 { 
 
 	 	 $ u s e r i n f o = D a t a b a s e : : g e t _ u s e r _ i n f o _ f r o m _ i d ( $ r o w [ ' u s e r _ i d ' ] ) ; 
 
 	 	 e c h o   ' < l i > < a   h r e f = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ r o w [ ' r e f l i n k ' ] . ' & v i e w = ' . $ r o w [ ' i d ' ] . ' " > ' ; 
 
 	 	 e c h o   u c f i r s t ( f o r m a t _ l o c a l e _ d a t e ( $ d a t e F o r m a t L o n g , s t r t o t i m e ( $ r o w [ ' t i m e s t a m p ' ] ) ) ) ; 
 
 	 	 e c h o   ' < / a >   -   < a   h r e f = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ r o w [ ' r e f l i n k ' ] . ' " > ' . $ r o w [ ' t i t l e ' ] . ' < / a >   -   < a   h r e f = " . . / . . / u s e r / u s e r I n f o . p h p ? u I n f o = ' . $ u s e r i n f o [ ' u s e r _ i d ' ] . ' " > ' . $ u s e r i n f o [ ' l a s t n a m e ' ] . '   ' . $ u s e r i n f o [ ' f i r s t n a m e ' ] . ' < / a > < / l i > ' ; 
 
 	 	 / / p r i n t _ r ( $ u s e r i n f o ) ; 
 
 	 } 
 
 	 e c h o   ' < / u l > ' ; 	 
 
 } 
 
 
 
 
 
 / /   A l l   P a g e s 
 
 i f   ( $ _ G E T [ ' a c t i o n ' ] = = ' a l l p a g e s ' ) 
 
 { 
 
 	 $ _ c l e a n [ ' g r o u p _ i d ' ] = ( i n t ) $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 	 
 
 	 $ s q l = ' S E L E C T   *   F R O M   ' . $ t b l _ w i k i . '   W H E R E   ' . $ g r o u p f i l t e r . '   G R O U P   B Y   r e f l i n k   O R D E R   B Y   r e f l i n k   A S C ' ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ L I N E _ _ , _ _ F I L E _ _ ) ; 
 
 	 e c h o   ' < u l > ' ; 
 
 	 w h i l e   ( $ r o w = m y s q l _ f e t c h _ a r r a y ( $ r e s u l t ) ) 
 
 	 { 
 
 	 	 $ u s e r i n f o = D a t a b a s e : : g e t _ u s e r _ i n f o _ f r o m _ i d ( $ r o w [ ' u s e r _ i d ' ] ) ; 
 
 	 	 e c h o   ' < l i > ' ; 
 
 	 	 e c h o   u c f i r s t ( f o r m a t _ l o c a l e _ d a t e ( $ d a t e F o r m a t L o n g , s t r t o t i m e ( $ r o w [ ' t i m e s t a m p ' ] ) ) ) ; 
 
 	 	 e c h o   '   -   < a   h r e f = " ' . $ _ S E R V E R [ ' P H P _ S E L F ' ] . ' ? a c t i o n = s h o w & t i t l e = ' . $ r o w [ ' r e f l i n k ' ] . ' " > ' . $ r o w [ ' t i t l e ' ] . ' < / a > < / l i > ' ; 
 
 	 	 / / p r i n t _ r ( $ u s e r i n f o ) ; 
 
 	 } 
 
 	 e c h o   ' < / u l > ' ; 	 
 
 } 
 
 
 
 e c h o   " < / d i v > " ;   / /   e c h o   " < d i v   i d = ' m a i n w i k i ' > " ; 
 
 
 
 e c h o   " < / d i v > " ;   / /   e c h o   " < d i v   i d = ' w i k i w r a p p e r ' > " ; 
 
   
 
   
 
   
 
 / * 
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 	 	 F O O T E R   
 
 = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 * /   
 
 / / $ _ S E S S I O N [ ' _ g i d ' ] ; 
 
 D i s p l a y : : d i s p l a y _ f o o t e r ( ) ; 
 
 
 
 / * * 
 
 *   @ a u t h   P a t r i c k   C o o l   < p a t r i c k . c o o l @ u g e n t . b e > ,   G h e n t   U n i v e r s i t y 
 
 *   @ d e s c   T h i s   f u n c t i o n   c h e c k s   w e i t h e r   t h e   p r o p o s e d   r e f l i n k   i s   n o t   i n   u s e   y e t .   I t   i s   a   r e c u r s i v e   f u n c t i o n   b e c a u s e   e v e r y   n e w l y   c r e a t e d   r e f l i n k   s u g g e s t i o n 
 
 	 	 h a s   t o   b e   c h e c k e d   a l s o 
 
 * / 
 
 f u n c t i o n   c r e a t e r e f l i n k ( $ t e s t v a l u e ) 
 
 { 
 
 	 g l o b a l   $ g r o u p f i l t e r ; 
 
 	 
 
 	 $ c o u n t e r = ' ' ; 
 
 	 
 
 	 w h i l e   ( ! c h e c k r e f l i n k ( $ t e s t v a l u e . $ c o u n t e r ) ) 
 
 	 { 
 
 	 	 $ c o u n t e r + + ; 
 
 	 	 e c h o   $ c o u n t e r . " - " . $ t e s t v a l u e . $ c o u n t e r . " < b r > " ; 
 
 	 } 
 
 	 	 	 / /   t h e   r e f l i n k   h a s   n o t   b e e n   f o u n d   y e t ,   s o   i t   i s   O K 
 
 	 r e t u r n   $ t e s t v a l u e . $ c o u n t e r ; 
 
 } 
 
 f u n c t i o n   c h e c k r e f l i n k ( $ p a r a m ) 
 
 { 
 
 	 g l o b a l   $ t b l _ w i k i ; 
 
 	 g l o b a l   $ g r o u p f i l t e r ;   
 
 	 
 
 	 $ s q l = ' S E L E C T   *   F R O M   ' . $ t b l _ w i k i . '   W H E R E   r e f l i n k = " ' . $ p a r a m . ' "   A N D   ' . $ g r o u p f i l t e r . ' ' ; 
 
 	 $ r e s u l t = a p i _ s q l _ q u e r y ( $ s q l , _ _ F I L E _ _ , _ _ L I N E _ _ ) ; 
 
 	 $ n u m b e r o f r e s u l t s = m y s q l _ n u m _ r o w s ( $ r e s u l t ) ; 
 
 	 
 
 	 i f   ( $ n u m b e r o f r e s u l t s = = 0 )   / /   t h e   f 
 
 	 { 
 
 	 	 r e t u r n   t r u e ; 
 
 	 } 
 
 	 e l s e   / /   t h e   v a l u e   h a s   b e e n   f o u n d   
 
 	 { 
 
 	 	 r e t u r n   f a l s e ;   
 
 	 } 
 
 } 
 
 ? > 
 
 