source: temp/test-xoops.ec-cube.net/html/modules/tinyd0/admin/index.php @ 405

Revision 405, 37.9 KB checked in by root, 20 years ago (diff)
Line 
1<?php
2//  ------------------------------------------------------------------------ //
3//                XOOPS - PHP Content Management System                      //
4//                    Copyright (c) 2000 XOOPS.org                           //
5//                       <http://www.xoops.org/>                             //
6//  ------------------------------------------------------------------------ //
7//  This program is free software; you can redistribute it and/or modify     //
8//  it under the terms of the GNU General Public License as published by     //
9//  the Free Software Foundation; either version 2 of the License, or        //
10//  (at your option) any later version.                                      //
11//                                                                           //
12//  You may not change or alter any portion of this comment or credits       //
13//  of supporting developers from this source code or any supporting         //
14//  source code which is considered copyrighted (c) material of the          //
15//  original comment or credit authors.                                      //
16//                                                                           //
17//  This program is distributed in the hope that it will be useful,          //
18//  but WITHOUT ANY WARRANTY; without even the implied warranty of           //
19//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
20//  GNU General Public License for more details.                             //
21//                                                                           //
22//  You should have received a copy of the GNU General Public License        //
23//  along with this program; if not, write to the Free Software              //
24//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
25//  ------------------------------------------------------------------------ //
26// Author: Tobias Liegl (AKA CHAPI)                                          //
27// Site: http://www.chapi.de                                                 //
28// Project: The XOOPS Project                                                //
29// ------------------------------------------------------------------------- //
30// Hacker: GIJ=CHECKMATE (AKA GIJOE)                                         //
31// Site: http://www.peak.ne.jp/xoops/                                        //
32// ------------------------------------------------------------------------- //
33
34// for Duplicatable V2.1
35$mydirname = basename( dirname( dirname( __FILE__ ) ) ) ;
36if( ! preg_match( '/^(\D+)(\d*)$/' , $mydirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $mydirname ) ) ;
37$mydirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;
38
39// includes
40include '../../../include/cp_header.php';
41include_once "../include/constants.inc.php";
42include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';
43include_once '../class/tinyd.textsanitizer.php';
44include_once '../include/gtickets.php';
45
46// page wrap search
47$page_wrap_search_allowed_exts = array( 'html','htm','phtml','php','php3','php4','txt' ) ;
48
49// also reading language files of modinfo & main
50if ( file_exists( "../language/{$xoopsConfig['language']}/modinfo.php" ) ) {
51    include( "../language/{$xoopsConfig['language']}/modinfo.php" ) ;
52    include( "../language/{$xoopsConfig['language']}/main.php" ) ;
53} else {
54    include( "../language/english/modinfo.php" ) ;
55    include( "../language/english/main.php" ) ;
56}
57
58// emulates mb functions
59if( ! function_exists( 'mb_convert_encoding' ) ) {
60    function mb_convert_encoding( $str ) { return $str ; }
61}
62if( ! function_exists( 'mb_internal_encoding' ) ) {
63    function mb_internal_encoding( $str ) { return "UTF-8" ; }
64}
65
66
67// these initializing code is provisional. they will be removed
68$globals = array(
69    'op' => '' ,
70    'id' => 0
71) ;
72foreach( $globals as $global => $default ) {
73    if( isset( $_GET[ $global ] ) ) $$global = $_GET[ $global ] ;
74    else if( isset( $_POST[ $global ] ) ) $$global = $_POST[ $global ] ;
75    else $$global = $default ;
76}
77$id = intval( $id ) ;
78// end of initialization
79
80// submit redirection
81if( ! empty( $_POST['preview'] ) && $op == 'add' ) $op = 'submit' ;
82if( ! empty( $_POST['preview'] ) && $op == 'editit' ) $op = 'edit' ;
83if( ! empty( $_POST['moveto'] ) && $op == 'update' ) $op = 'moveto' ;
84if( ! empty( $_POST['cancel'] ) ) {
85    redirect_header( 'index.php?op=show' , 0 , _CANCEL ) ;
86    exit ;
87}
88
89// utility variables
90$mymodpath = XOOPS_ROOT_PATH."/modules/$mydirname" ;
91$mymodurl = XOOPS_URL."/modules/$mydirname" ;
92$wrap_path = XOOPS_ROOT_PATH."/modules/$mydirname/content" ;
93$mytablename = $xoopsDB->prefix( "tinycontent{$mydirnumber}" ) ;
94$myts =& TinyDTextSanitizer::getInstance() ;
95
96
97// ------------------------------------------------------------------------- //
98// Switch Statement for the different operations                             //
99// ------------------------------------------------------------------------- //
100$xoopsDB =& Database::getInstance();
101switch( $op ) {
102
103// ------------------------------------------------------------------------- //
104// Show Content Page -> Overview                                             //
105// ------------------------------------------------------------------------- //
106default :
107    $mymenu_fake_uri = $_SERVER['REQUEST_URI'] . '?op=show' ;
108case "show":
109    xoops_cp_header();
110    include( dirname(__FILE__).'/mymenu.php' ) ;
111
112    if( check_browser_can_use_spaw() ) {
113        $can_use_spaw = true ;
114        $submitlink_with_spaw = "(<a href='index.php?op=submit&amp;usespaw=1' style='font-size:xx-small;'>SPAW</a>)" ;
115    } else {
116        $can_use_spaw = false ;
117        $submitlink_with_spaw = '' ;
118    }
119
120    // get all instances of TinyD using newblocks table
121    $rs = $xoopsDB->query( "SELECT mid FROM ".$xoopsDB->prefix("newblocks")." WHERE func_file='tinycontent_navigation.php'" ) ;
122    $whr_mid = 'mid IN (' ;
123    while( list( $mid ) = $xoopsDB->fetchRow( $rs ) ) {
124        $whr_mid .= intval( $mid ) . ',' ;
125    }
126    $whr_mid .= "0)" ;
127    $rs = $xoopsDB->query( "SELECT mid,dirname,name FROM ".$xoopsDB->prefix("modules")." WHERE $whr_mid ORDER BY weight,mid" ) ;
128    $dest_tinyd_options = "<option value=''>--</option>\n" ;
129    while( list( $mid , $dirname , $name ) = $xoopsDB->fetchRow( $rs ) ) {
130        if( $dirname == $mydirname ) continue ;
131        if( ! $xoopsUser->isAdmin( $mid ) ) continue ;
132        $name4disp = htmlspecialchars( $name , ENT_QUOTES ) ;
133        $dest_tinyd_options .= "<option value='$mid'>$name4disp</option>\n" ;
134    }
135
136    echo "
137        <h4>".$xoopsModule->getVar('name')."</h4>
138        <div align='right' width='95%'>
139            <b>"._TC_TH_VISIBLE."</b>:"._TC_VISIBLE." &nbsp;
140            <b>"._TC_TH_SUBMENU."</b>:"._TC_SUBMENU." &nbsp;
141            <b>"._TC_TH_ENABLECOM."</b>:"._TC_ENABLECOM."
142        </div>
143        <form action='index.php' name='MainForm' method='post'>
144        ".$xoopsGTicket->getTicketHtml( __LINE__ )."
145        <table border='0' cellpadding='0' cellspacing='1' width='95%' class='outer'>
146        <tr>
147            <th>"._TC_STORYID."</th>
148            <th>"._TC_HOMEPAGE."</th>
149            <th>"._TC_LINKNAME."</th>
150            <th>"._TC_LINKID."</th>
151            <th>"._TC_TH_VISIBLE."</th>
152            <th>"._TC_TH_SUBMENU."</th>
153            <th>"._TC_TH_ENABLECOM."</th>
154            <th>"._TC_CONTENTTYPE."</th>
155            <th style='text-align:right;'>"._TC_ACTION."</th>
156        </tr>\n";
157
158    $result = $xoopsDB->query("SELECT storyid,blockid,title,visible,homepage,link,submenu,nocomments,nohtml,UNIX_TIMESTAMP(last_modified) FROM $mytablename ORDER BY blockid");
159
160    while( list( $id , $weight , $title , $visible , $homepage , $link , $submenu , $nocomments , $nohtml , $last_modified ) = $xoopsDB->fetchRow( $result ) ) {
161        $title4show = $myts->makeTboxData4Show( $title ) ;
162
163        $visible_checked = $visible ? "checked='checked'" : "" ;
164        $submenu_checked = $submenu ? "checked='checked'" : "" ;
165        $comments_checked = $nocomments ? "" : "checked='checked'" ;
166
167        if( $link > 0 ) {
168            // page wrap
169            $line_class = 'even' ;
170            $op_for_edit = 'elink' ;
171            $opname_for_edit = _TC_ELINK ;
172            $opname_for_delete = _TC_DELLINK ;
173            $link_to_spaw = '' ;
174            $content_type = "WRAP$link"  ;
175            $extended_link = '' ;
176        } else {
177            // db content
178            $line_class = 'odd' ;
179            $op_for_edit = 'edit' ;
180            $opname_for_edit = _TC_EDIT ;
181            $opname_for_delete = _TC_DELETE ;
182            if( $can_use_spaw ) $link_to_spaw = "(<a href='?op=edit&amp;id=$id&amp;usespaw=1' style='font-size:xx-small;'>SPAW</a>)" ;
183            else $link_to_spaw = '' ;
184            switch( $nohtml ) {
185                case '18' :
186                    $content_type = "Text_Wiki (+bb)" ;
187                    $extended_link = "(<a href='?op=edit&amp;id=$id&amp;useplain=1' style='font-size:xx-small;'>PLAIN</a>)" ;
188                    break ;
189                case '16' :
190                    $content_type = "Text_Wiki" ;
191                    $extended_link = "(<a href='?op=edit&amp;id=$id&amp;useplain=1' style='font-size:xx-small;'>PLAIN</a>)" ;
192                    break ;
193                case '10' :
194                    $content_type = "PHP (+bb)" ;
195                    $extended_link = "(<a href='?op=edit&amp;id=$id&amp;useplain=1' style='font-size:xx-small;'>PLAIN</a>)" ;
196                    break ;
197                case '8' :
198                    $content_type = "PHP" ;
199                    $extended_link = "(<a href='?op=edit&amp;id=$id&amp;useplain=1' style='font-size:xx-small;'>PLAIN</a>)" ;
200                    break ;
201                case '3' :
202                    $content_type = "TEXT (-bb)" ;
203                    $extended_link = '' ;
204                    break ;
205                case '2' :
206                    $content_type = "HTML (-bb)" ;
207                    $extended_link = $link_to_spaw ;
208                    break ;
209                case '1' :
210                    $content_type = "TEXT (+bb)" ;
211                    $extended_link = '' ;
212                    break ;
213                case '0' :
214                    $content_type = "HTML (+bb)" ;
215                    $extended_link = $link_to_spaw ;
216                    break ;
217                default :
218                    $content_type = "unknown" ;
219                    $extended_link = '' ;
220            }
221        }
222
223        echo "
224        <tr class='$line_class'>
225            <td align='right'>$id<input type='hidden' name='id[]' value='$id' /></td>
226            <td align='center'><input type='radio' name='homepage' value='$id' ".($homepage?"checked='checked'":"")." /></td>
227            <td><a href='../index.php?id=$id'>$title4show</a></td>
228            <td align='center'><input type='text' name='blockid[$id]' size='3' maxlength='8' value='$weight' style='text-align:right;' /></td>
229            <td align='center'><input type='checkbox' name='visible[$id]' $visible_checked /></td>
230            <td align='center'><input type='checkbox' name='submenu[$id]' $submenu_checked /></td>
231            <td align='center'><input type='checkbox' name='comments[$id]' $comments_checked /></td>
232            <td>$content_type</td>
233            <td align='right'><a href='index.php?op=$op_for_edit&amp;id=$id'>$opname_for_edit</a> $extended_link | <a href='index.php?op=delete&amp;id=$id'>$opname_for_delete</a> | <input type='checkbox' name='checked_ids[$id]' /><br />".formatTimestamp($last_modified,"m")."</td>
234        </tr>\n" ;
235
236    }
237
238    echo "
239        <tr>
240            <th colspan='9' style='text-align:right;'>
241                "._TC_CHECKED_ITEMS_ARE."
242                <input type='submit' name='moveto' value="._TC_BUTTON_MOVETO." disabled='disabled' />
243                <select name='dest_tinyd' onchange='document.MainForm.moveto.disabled=false;'>
244                    $dest_tinyd_options
245                </select>
246            </th>
247        </tr>
248    </table>
249    <br />
250    <div align='center'>
251        <input type='hidden' name='op' value='update' />
252        <input type='submit' name='submit' value="._SUBMIT." />
253        <input type='reset' />
254    </div>
255    </form>
256    <table border='0' cellpadding='0' cellspacing='5'><tr>
257    <td>
258        <table border='0' cellpadding='0' cellspacing='1' class='outer'>
259        <tr>
260            <td class='odd'><a href='?op=submit'>"._TC_ADDCONTENT."</a> $submitlink_with_spaw</td>
261        </tr>
262        </table>
263    </td>
264    <td>
265        <table border='0' cellpadding='0' cellspacing='1' class='outer'>
266        <tr>
267            <td class='even'><a href='?op=nlink'>"._TC_ADDLINK."</a></td>
268        </tr>
269        </table>
270    </td>
271    <td>
272        <table border='0' cellpadding='0' cellspacing='1' class='outer'>
273        <tr>
274            <td class='odd'><a href='?op=update_wrap_contents'>"._TC_UPDATE_WRAP_CONTENTS."</a></td>
275        </tr>
276        </table>
277    </td>\n" ;
278
279    echo "
280        </table>
281    </td>
282    </tr></table>\n";
283
284    xoops_cp_footer();
285    break;
286
287// ------------------------------------------------------------------------- //
288// Update Content -> Show Content Page                                       //
289// ------------------------------------------------------------------------- //
290case "update":
291
292    // Ticket Check
293    if ( ! $xoopsGTicket->check() ) {
294        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
295    }
296
297    if( ! is_array( $_POST['id'] ) ) break ;
298    $homepage = empty( $_POST['homepage'] ) ? 0 : intval( $_POST['homepage'] ) ;
299    foreach( $_POST['id'] as $storyid ) {
300        $storyid = intval( $storyid ) ;
301        if( $homepage == 0 ) {
302            $hp_flag = 1 ;
303            $homepage = $storyid ;
304        } else {
305            $hp_flag = $storyid == $homepage ? 1 : 0 ;
306        }
307        $blockid = empty( $_POST['blockid'][ $storyid ] ) ? 0 : intval( $_POST['blockid'][ $storyid ] ) ;
308        $visible = empty( $_POST['visible'][ $storyid ] ) ? 0 : 1 ;
309        $nocomments = empty( $_POST['comments'][ $storyid ] ) ? 1 : 0 ;
310        $submenu = empty( $_POST['submenu'][ $storyid ] ) ? 0 : 1 ;
311
312        $sql = "UPDATE $mytablename SET blockid='$blockid',visible='$visible',homepage='$hp_flag',nocomments='$nocomments',submenu='$submenu',last_modified=last_modified WHERE storyid='$storyid'" ;
313        $xoopsDB->query( $sql ) or die( _TC_ERRORINSERT ) ;
314    }
315    redirect_header( "index.php?op=show" , 1 , _TC_DBUPDATED ) ;
316    exit ;
317    break ;
318
319// ------------------------------------------------------------------------- //
320// Show add or edit content Page                                             //
321// ------------------------------------------------------------------------- //
322case "submit" :
323case "edit" :
324
325    xoops_cp_header() ;
326    include( dirname(__FILE__).'/mymenu.php' ) ;
327
328    // initialization
329    if( ! empty( $_POST['preview'] ) ) {
330
331        $globals = array(
332            'id' => 0 ,
333            'title' => '' ,
334            'message' => '' ,
335            'visible' => 0 ,
336            'nohtml' => 0 ,
337            'nosmiley' => 0 ,
338            'nobreaks' => 0 ,
339            'nocomments' => 0 ,
340            'submenu' => 0 ,
341            'last_modified' => 0 ,
342            'created' => 0 ,
343            'html_header' => ''
344        ) ;
345        foreach( $globals as $global => $default ) {
346            if( isset( $_POST[ $global ] ) ) $$global = $myts->stripSlashesGPC( $_POST[ $global ] ) ;
347            else $$global = $default ;
348        }
349        $storyid = intval( $id ) ;
350
351        // write posted data into sesion
352        $_SESSION['tinyd_preview_post'] = array(
353            'message' => $message ,
354            'nohtml' => intval( $nohtml ) ,
355            'nosmiley' => intval( $nosmiley ) ,
356            'nobreaks' => intval( $nobreaks )
357        ) ;
358        /* $content_cache = "{$mydirname}_preview_" . time() ;
359        $fp = fopen( XOOPS_CACHE_PATH . '/' . $content_cache , 'w' ) ;
360        if( $fp === false ) {
361            unset( $_POST['preview'] ) ;
362        } else {
363            fwrite( $fp , $message , 65536 ) ;
364            fclose( $fp ) ;
365        }*/
366
367    } else if( $op == 'edit' ) {
368
369        $result = $xoopsDB->query( "SELECT storyid,title,text,visible,nohtml,nosmiley,nobreaks,nocomments,submenu,UNIX_TIMESTAMP(last_modified),UNIX_TIMESTAMP(created),html_header FROM $mytablename WHERE storyid='$id'" ) ;
370        list($storyid,$title,$message,$visible,$nohtml,$nosmiley,$nobreaks,$nocomments,$submenu,$last_modified,$created,$html_header) = $xoopsDB->fetchRow( $result ) ;
371
372    } else {
373
374        list($storyid,$title,$message,$visible,$nohtml,$nosmiley,$nobreaks,$nocomments,$submenu,$last_modified,$created,$html_header) = array(0,'','',1,0,0,1,0,1,0,0,'');
375
376    }
377
378    if( $op == 'edit' ) {
379        $form_title = _TC_EDITCONTENT ;
380        $next_op = "editit" ;
381    } else {
382        $form_title = _TC_ADDCONTENT ;
383        $next_op = "add" ;
384    }
385
386    // get configs
387    $tarea_width = empty( $xoopsModuleConfig['tc_tarea_width'] ) ? 35 : intval( $xoopsModuleConfig['tc_tarea_width'] ) ;
388    $header_tarea_height = empty( $xoopsModuleConfig['tc_header_tarea_height'] ) ? 0 : intval( $xoopsModuleConfig['tc_header_tarea_height'] ) ;
389    $body_tarea_height = empty( $xoopsModuleConfig['tc_tarea_height'] ) ? 37 : intval( $xoopsModuleConfig['tc_tarea_height'] ) ;
390
391    // title and textarea selection
392    $js_confirm = 'if(MainForm.message.value!="") return confirm("'._TC_JS_CONFIRMDISCARD.'");' ;
393    echo "
394        <div width='100%'>
395            <span style='font-size:normal; font-weight: bold;'>
396                ".$xoopsModule->getVar('name')."
397            </span>
398             &nbsp;
399            <span style='font-size:xx-small'>
400                <a href='?op=$op&amp;id=$id' onclick='$js_confirm'>BB</a> &nbsp;
401                <a href='?op=$op&amp;id=$id&amp;usespaw=1' onclick='$js_confirm'>SPAW</a> &nbsp;
402                <a href='?op=$op&amp;id=$id&amp;useplain=1' onclick='$js_confirm'>PLAIN</a>
403            </span>
404        </div>\n" ;
405
406    // Form target
407    if( ! empty( $_GET['usespaw'] ) ) {
408        $form_target = 'index.php?usespaw=1' ;
409    } else if( ! empty( $_GET['useplain'] ) ) {
410        $form_target = 'index.php?useplain=1' ;
411    } else {
412        $form_target = 'index.php' ;
413    }
414
415    // beggining of xoopsForm
416    $form = new XoopsThemeForm( $form_title , "MainForm" , $form_target ) ;
417
418    // title
419    $form->addElement( new XoopsFormText( _TC_LINKNAME , "title" , 50 , 255 , htmlspecialchars( $title , ENT_QUOTES ) ) ) ;
420
421    // html header
422    if( $header_tarea_height > 0 ) {
423        $h_area = new XoopsFormTextArea( _TC_HTML_HEADER , 'html_header' , htmlspecialchars( $html_header , ENT_QUOTES ) , $header_tarea_height , $tarea_width ) ;
424        $h_area->setExtra( "style='width: {$tarea_width}em;'" ) ;
425        $form->addElement( $h_area ) ;
426    } else {
427        $form->addElement( new XoopsFormHidden( 'html_header' , htmlspecialchars( $html_header , ENT_QUOTES ) ) ) ;
428    }
429
430    // content body
431    $spaw_flag = false ;
432    if( ! empty( $_GET['usespaw'] ) ) {
433        // SPAW Config
434        include XOOPS_ROOT_PATH.'/common/spaw/spaw_control.class.php' ;
435        if( check_browser_can_use_spaw() ) {
436            ob_start() ;
437            $sw = new SPAW_Wysiwyg( 'message' , $message ) ;
438            $sw->show() ;
439            $form->addElement( new XoopsFormLabel( _TC_CONTENT , ob_get_contents() ) ) ;
440            ob_end_clean() ;
441            $spaw_flag = true ;
442        }
443    }
444    if( ! $spaw_flag ) {
445        if( empty( $_GET['useplain'] ) ) {
446            $t_area = new XoopsFormDhtmlTextArea( _TC_CONTENT , 'message' , htmlspecialchars( $message , ENT_QUOTES ) , $body_tarea_height , $tarea_width ) ;
447        } else {
448            $t_area = new XoopsFormTextArea( _TC_CONTENT . "<br /><br /><br /><br /><a href='$mymodurl/admin/text_wiki_sample.php?lang={$xoopsConfig['language']}' target='_blak'>Text_Wiki Sample</a>" , 'message' , htmlspecialchars( $message , ENT_QUOTES ) , $body_tarea_height , $tarea_width ) ;
449        }
450        $t_area->setExtra( "style='width: {$tarea_width}em;'" ) ;
451        $form->addElement( $t_area ) ;
452    }
453
454    // options
455    $option_tray = new XoopsFormElementTray( _OPTIONS , '<br />' ) ;
456    // smiley
457    $smiley_checkbox = new XoopsFormCheckBox( '' , 'nosmiley', $nosmiley ) ;
458    $smiley_checkbox->addOption( 1 , _DISABLESMILEY ) ;
459    $option_tray->addElement( $smiley_checkbox ) ;
460    // nobreaks
461    if( $spaw_flag ) {
462        $form->addElement( new XoopsFormHidden( 'nobreaks' , 1 ) ) ;
463    } else {
464        $breaks_checkbox = new XoopsFormCheckBox( '' , 'nobreaks' , $nobreaks ) ;
465        $breaks_checkbox->addOption( 1 , _TC_DISABLEBREAKS ) ;
466        $option_tray->addElement( $breaks_checkbox ) ;
467    }
468    // visible
469    $visible_checkbox = new XoopsFormCheckBox( '' , 'visible' , $visible ) ;
470    $visible_checkbox->addOption( 1 , _TC_VISIBLE ) ;
471    $option_tray->addElement( $visible_checkbox ) ;
472    // submenu
473    $submenu_checkbox = new XoopsFormCheckBox( '' , 'submenu', $submenu ) ;
474    $submenu_checkbox->addOption( 1 , _TC_SUBMENU ) ;
475    $option_tray->addElement( $submenu_checkbox ) ;
476    // comments
477    $comments_checkbox = new XoopsFormCheckBox( '' , 'comments' , ! $nocomments ) ;
478    $comments_checkbox->addOption( 1 , _TC_ENABLECOM ) ;
479    $option_tray->addElement( $comments_checkbox ) ;
480    $form->addElement( $option_tray ) ;
481    // end of options
482
483    // content type
484    $htmltype_select = new XoopsFormSelect( _TC_CONTENT_TYPE , 'nohtml' , $nohtml ) ;
485    $htmltype_select->addOption( 0 , _TC_TYPE_HTML ) ;
486    $htmltype_select->addOption( 2 , _TC_TYPE_HTMLNOBB ) ;
487    $htmltype_select->addOption( 1 , _TC_TYPE_TEXTWITHBB ) ;
488    $htmltype_select->addOption( 3 , _TC_TYPE_TEXTNOBB ) ;
489    $htmltype_select->addOption( 8 , _TC_TYPE_PHPHTML ) ;
490    $htmltype_select->addOption( 10 , _TC_TYPE_PHPWITHBB ) ;
491    $htmltype_select->addOption( 16 , _TC_TYPE_PEARWIKI ) ;
492    $htmltype_select->addOption( 18 , _TC_TYPE_PEARWIKIWITHBB ) ;
493    $form->addElement( $htmltype_select ) ;
494
495    // last_modified
496    $lm_tray = new XoopsFormElementTray( _TC_LASTMODIFIED , '&nbsp;' ) ;
497    $lm_tray->addElement( new XoopsFormLabel( '' , formatTimestamp( $last_modified ) ) ) ;
498    $lm_checkbox = new XoopsFormCheckBox( '' , 'dont_update_last_modified' , 0 ) ;
499    $lm_checkbox->addOption( 1 , _TC_DONTUPDATELASTMODIFIED ) ;
500    $lm_tray->addElement( $lm_checkbox ) ;
501    $form->addElement( $lm_tray ) ;
502
503    // created
504    $form->addElement( new XoopsFormLabel( _TC_CREATED , formatTimestamp( $created ) ) ) ;
505
506    // buttons
507    $submit_tray = new XoopsFormElementTray( '' , ' &nbsp; &nbsp; ' ) ;
508    $submit_tray->addElement( new XoopsFormButton( "" , "preview" , _PREVIEW , "submit" ) );
509    $submit_tray->addElement( new XoopsFormButton( "" , "submit" , _SUBMIT , "submit" ) );
510    if( $op == 'edit' ) $submit_tray->addElement( new XoopsFormButton( "" , "saveas" , _TC_SAVEAS , "submit" ) ) ;
511    $submit_tray->addElement( new XoopsFormButton( "" , "cancel" , _CANCEL , "submit" ) );
512    $form->addElement( $submit_tray ) ;
513
514    // hiddens
515    $form->addElement( new XoopsFormHidden( 'op' , $next_op ) ) ;
516    $form->addElement( new XoopsFormHidden( 'id' , $storyid ) ) ;
517    $form->addElement( new XoopsFormHidden( 'last_modified' , $last_modified ) ) ;
518    // Ticket
519    $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement( $form , __LINE__ ) ;
520
521/*  echo '
522<!-- tinyMCE -->
523<script language="javascript" type="text/javascript" src="/common/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
524<script language="javascript" type="text/javascript">
525  tinyMCE.init({
526     mode : "textareas"
527  });
528</script>
529<!-- /tinyMCE -->' ;*/
530
531    // end of xoopsForm
532    $form->display() ;
533
534    xoops_cp_footer() ;
535
536    // preview popup
537    if( ! empty( $_POST['preview'] ) ) {
538        // Ticket Check
539        if ( ! $xoopsGTicket->check() ) {
540            redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
541        }
542
543        echo '
544        <script type="text/javascript">
545        <!--//
546        preview_window = openWithSelfMain( "'.$mymodurl.'/preview.php" , "popup" , 680 , 450 ) ;
547        //-->
548        </script>';
549    }
550
551    break ;
552
553// ------------------------------------------------------------------------- //
554// INSERT or UPDATE content to database                                      //
555// ------------------------------------------------------------------------- //
556case "add" :
557case "editit":
558
559    // Ticket Check
560    if ( ! $xoopsGTicket->check() ) {
561        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
562    }
563
564    $title4save = $myts->addSlashes( $_POST['title'] ) ;
565    $html_header4save = $myts->addSlashes( $_POST['html_header'] ) ;
566    $text4save = $myts->addSlashes( $_POST['message'] ) ;
567    $visible = empty( $_POST['visible'] ) ? 0 : 1 ;
568    $nohtml = empty( $_POST['nohtml'] ) ? 0 : intval( $_POST['nohtml'] ) ;
569    $nosmiley = empty( $_POST['nosmiley'] ) ? 0 : 1 ;
570    $nobreaks = empty( $_POST['nobreaks'] ) ? 0 : 1 ;
571    $nocomments = empty( $_POST['comments'] ) ? 1 : 0 ;
572    $submenu = empty( $_POST['submenu'] ) ? 0 : 1 ;
573
574    // hp flag is set if there are no records which has flag of homepage
575    $result = $xoopsDB->query( "SELECT COUNT(*) FROM $mytablename WHERE homepage>0" ) ;
576    list( $count_home ) = $xoopsDB->fetchRow( $result ) ;
577    $hp_flag = $count_home > 0 ? 0 : 1 ;
578
579    $sql_set = "SET title='$title4save',text='$text4save',visible='$visible',nohtml='$nohtml',nosmiley='$nosmiley',nobreaks='$nobreaks',nocomments='$nocomments',link='0',submenu='$submenu',html_header='$html_header4save'" ;
580
581    if( $op == 'add' || ! empty( $_POST['saveas'] ) ) {
582        $sql = "INSERT INTO $mytablename $sql_set,created=NOW(),homepage='$hp_flag'" ;
583    } else {
584        // not to update last_modified
585        if( ! empty( $_POST['dont_update_last_modified'] ) ) $sql_set .= ",last_modified=last_modified" ;
586
587        // change homepage only when it should be turned on
588        if( $hp_flag ) $sql_set .= ",homepage='$hp_flag'" ;
589
590        $id = empty( $_POST['id'] ) ? 0 : intval( $_POST['id'] ) ;
591        $sql = "UPDATE $mytablename $sql_set WHERE storyid='$id'" ;
592    }
593
594    $result = $xoopsDB->query( $sql ) or die ( _TC_ERRORINSERT ) ;
595    redirect_header( "index.php?op=show" , 1 , _TC_DBUPDATED ) ;
596    exit ;
597    break ;
598
599// ------------------------------------------------------------------------- //
600// Show new link & edit link Page                                            //
601// ------------------------------------------------------------------------- //
602case "nlink" :
603case "elink" :
604
605    xoops_cp_header();
606    include( dirname(__FILE__).'/mymenu.php' ) ;
607
608    echo "<h4>".$xoopsModule->getVar('name')."</h4>";
609
610    if( is_writable( $wrap_path ) ) {
611
612        // Upload File
613        echo "<form name='form_name2' id='form_name2' action='index.php' method='post' enctype='multipart/form-data'>";
614        echo "<table cellspacing='1' width='100%' class='outer'>";
615        echo "<tr><th colspan='2'>"._TC_ULFILE."</th></tr>";
616        echo "<tr valign='top' align='left'><td class='head' width='30%'>"._TC_SFILE."</td><td class='even'><input type='file' name='fileupload' id='fileupload' size='50' /></td></tr>";
617        echo "<tr valign='top' align='left'><td class='head'><input type='hidden' name='MAX_FILE_SIZE' id='op' value='500000' /><input type='hidden' name='op' id='op' value='upload' /></td><td class='even'><input type='submit' name='submit' value='"._TC_UPLOAD."' /></td></tr>";
618        echo "</table>";
619        printf( _TC_FMT_WRAPPATHPERMON , $wrap_path ) ;
620        echo $xoopsGTicket->getTicketHtml( __LINE__ ) ;
621        echo "</form>";
622
623        // Delete File
624        $form = new XoopsThemeForm( _TC_DELFILE , "DelForm" , "index.php" ) ;
625
626        $address_select = new XoopsFormSelect( _TC_URL , "address" ) ;
627        $dir_handle = dir( $wrap_path ) ;
628        while( $file = $dir_handle->read() ) {
629            if( is_file( "$wrap_path/$file" ) && $file != 'index.php' ) {
630                $address_select->addOption( $file , htmlspecialchars( $file , ENT_QUOTES ) ) ;
631            }
632        }
633        $dir_handle->close() ;
634        $form->addElement( $address_select ) ;
635
636        $form->addElement( new XoopsFormHidden( 'op' , 'delfile' ) ) ;
637        $form->addElement( new XoopsFormButton( '' , "submit" , _TC_DELETE , 'submit' ) ) ;
638
639        $form->display();
640    } else {
641        echo "<p>" . sprintf( _TC_FMT_WRAPPATHPERMOFF , $wrap_path ) . "</p>" ;
642    }
643
644
645    // initialization
646    if( $op == 'elink' ) {
647        $result = $xoopsDB->query( "SELECT storyid,title,visible,nocomments,address,submenu,link,UNIX_TIMESTAMP(last_modified) FROM $mytablename WHERE storyid='$id'" ) ;
648        list($storyid,$title,$visible,$nocomments,$address,$submenu,$link,$last_modified) = $xoopsDB->fetchRow( $result ) ;
649        $form_name = _TC_EDITLINK ;
650        $next_op = 'linkeditit' ;
651    } else {
652        list($storyid,$title,$visible,$nocomments,$address,$submenu,$link,$last_modified) = array(0,'',1,0,'',1,1,0) ;
653        $form_name = _TC_ADDLINK ;
654        $next_op = 'addlink' ;
655    }
656
657    // beggining of xoopsForm for PageWrapping
658    $form = new XoopsThemeForm( $form_name , "MainForm" , "index.php" ) ;
659
660    // title
661    $form->addElement( new XoopsFormText( _TC_LINKNAME , "title" , 50 , 255 , htmlspecialchars( $title , ENT_QUOTES ) ) ) ;
662
663    // a file should be wrapped
664    $address_select = new XoopsFormSelect( _TC_URL , "address" , $address ) ;
665    $dir_handle = dir( $wrap_path ) ;
666    while( $file = $dir_handle->read() ) {
667        if( is_file( "$wrap_path/$file" ) && $file != 'index.php' ) {
668            $address_select->addOption( $file , htmlspecialchars( $file , ENT_QUOTES ) ) ;
669        }
670    }
671    $dir_handle->close();
672    $form->addElement( $address_select ) ;
673
674    // base path for wrapping
675    $wraproot_radio = new XoopsFormRadio( _TC_WRAPROOT , 'wraproot', $link ) ;
676    $wraproot_radio->addOption( TC_WRAPTYPE_NORMAL , sprintf( _TC_FMT_WRAPROOTTC , $mymodpath ) ) ;
677    $wraproot_radio->addOption( TC_WRAPTYPE_CONTENTBASE , sprintf( _TC_FMT_WRAPROOTPAGE , $wrap_path ) ) ;
678    $wraproot_radio->addOption( TC_WRAPTYPE_USEREWRITE , sprintf( _TC_FMT_WRAPBYREWRITE , $wrap_path ) ) ;
679    $wraproot_radio->addOption( TC_WRAPTYPE_CHANGESRCHREF , sprintf( _TC_FMT_WRAPCHANGESRCHREF , $wrap_path ) ) ;
680    $form->addElement( $wraproot_radio ) ;
681
682    // options
683    $option_tray = new XoopsFormElementTray( _OPTIONS , '<br />' ) ;
684    // visible
685    $visible_checkbox = new XoopsFormCheckBox( '' , 'visible' , $visible ) ;
686    $visible_checkbox->addOption( 1 , _TC_VISIBLE ) ;
687    $option_tray->addElement( $visible_checkbox ) ;
688    // submenu
689    $submenu_checkbox = new XoopsFormCheckBox( '' , 'submenu', $submenu ) ;
690    $submenu_checkbox->addOption( 1 , _TC_SUBMENU ) ;
691    $option_tray->addElement( $submenu_checkbox ) ;
692    // comments
693    $comments_checkbox = new XoopsFormCheckBox( '' , 'comments' , ! $nocomments ) ;
694    $comments_checkbox->addOption( 1 , _TC_ENABLECOM ) ;
695    $option_tray->addElement( $comments_checkbox ) ;
696    $form->addElement( $option_tray ) ;
697    // end of options
698
699    // last_modified
700    $lm_tray = new XoopsFormElementTray( _TC_LASTMODIFIED , '&nbsp;' ) ;
701    $lm_tray->addElement( new XoopsFormLabel( '' , formatTimestamp( $last_modified ) ) ) ;
702    $lm_checkbox = new XoopsFormCheckBox( '' , 'dont_update_last_modified' , 0 ) ;
703    $lm_checkbox->addOption( 1 , _TC_DONTUPDATELASTMODIFIED ) ;
704    $lm_tray->addElement( $lm_checkbox ) ;
705    $form->addElement( $lm_tray ) ;
706
707    // buttons
708    $submit_tray = new XoopsFormElementTray( '' , ' &nbsp; &nbsp; ' ) ;
709    $submit_tray->addElement( new XoopsFormButton( "" , "submit" , _SUBMIT , "submit" ) );
710    $submit_tray->addElement( new XoopsFormButton( "" , "cancel" , _CANCEL , "submit" ) );
711    $form->addElement( $submit_tray ) ;
712
713    // hiddens
714    $form->addElement( new XoopsFormHidden( 'op' , $next_op ) ) ;
715    $form->addElement( new XoopsFormHidden( 'id' , $storyid ) ) ;
716    $form->addElement( new XoopsFormHidden( 'last_modified' , $last_modified ) ) ;
717    // Ticket
718    $GLOBALS['xoopsGTicket']->addTicketXoopsFormElement( $form , __LINE__ ) ;
719
720    // end of xoopsForm
721    $form->display() ;
722
723    xoops_cp_footer() ;
724
725    break ;
726
727// ------------------------------------------------------------------------- //
728// INSERT or UPDATE a PageWrap to database                                   //
729// ------------------------------------------------------------------------- //
730case "addlink" :
731case "linkeditit" :
732
733    // Ticket Check
734    if ( ! $xoopsGTicket->check() ) {
735        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
736    }
737
738    // security fix (thx JM2)
739    $_POST['address'] = str_replace( '..' , '' , $_POST['address'] ) ;
740
741    $title4save = $myts->addSlashes( $_POST['title'] ) ;
742    $address4save = $myts->addSlashes( $_POST['address'] ) ;
743    $visible = empty( $_POST['visible'] ) ? 0 : 1 ;
744    $nocomments = empty( $_POST['comments'] ) ? 1 : 0 ;
745    $submenu = empty( $_POST['submenu'] ) ? 0 : 1 ;
746    $link = empty( $_POST['wraproot'] ) ? 1 : intval( $_POST['wraproot'] ) ;
747
748    // hp flag is set if there are no records which has flag of homepage
749    $result = $xoopsDB->query( "SELECT COUNT(*) FROM $mytablename WHERE homepage>0" ) ;
750    list( $count_home ) = $xoopsDB->fetchRow( $result ) ;
751    $hp_flag = $count_home > 0 ? 0 : 1 ;
752
753    // fetch text for search from wrapped page
754    $wrapped_file = "$wrap_path/{$_POST['address']}" ;
755    $ext = strtolower( substr( strrchr( $wrapped_file , '.' ) , 1 ) ) ;
756    if( in_array( $ext , $page_wrap_search_allowed_exts ) ) {
757        $fp = fopen( $wrapped_file , 'r' ) ;
758        if( ! $fp ) {
759            redirect_header( "index.php?op=nlink" , 2 , _TC_FILENOTFOUND ) ;
760            exit ;
761        }
762        $text = addslashes( tc_convert_wrap_to_ie( strip_tags( fread( $fp , 65536 * 2 ) ) ) ) ;
763        fclose( $fp ) ;
764    } else {
765        $text = '' ;
766    }
767
768    $sql_set = "SET title='$title4save',address='$address4save',visible='$visible',nocomments='$nocomments',submenu='$submenu',link='$link',text='$text',nohtml='0',nosmiley='0',nobreaks='0'" ;
769
770    if( $op == 'addlink' ) {
771        $sql = "INSERT INTO $mytablename $sql_set,created=NOW(),homepage='$hp_flag'" ;
772    } else {
773        // not to update last_modified
774        if( ! empty( $_POST['dont_update_last_modified'] ) ) $sql_set .= ",last_modified=last_modified" ;
775
776        // change homepage only when it should be turned on
777        if( $hp_flag ) $sql_set .= ",homepage='$hp_flag'" ;
778
779        $id = empty( $_POST['id'] ) ? 0 : intval( $_POST['id'] ) ;
780        $sql = "UPDATE $mytablename $sql_set WHERE storyid='$id'" ;
781    }
782
783    $result = $xoopsDB->query( $sql ) or die ( _TC_ERRORINSERT ) ;
784    redirect_header( "index.php?op=show" , 2 , _TC_DBUPDATED ) ;
785    exit ;
786    break;
787
788// ------------------------------------------------------------------------- //
789// Upload File                                                //
790// ------------------------------------------------------------------------- //
791case "update_wrap_contents" :
792
793    $result = $xoopsDB->query( "SELECT storyid,link,address FROM $mytablename WHERE link>0" ) ;
794    while( list( $id , $link , $address ) = $xoopsDB->fetchRow( $result ) ) {
795        if( stristr( $address , '..' ) ) exit ;
796        $wrapped_file = $wrap_path.'/'.$address ;
797        $ext = strtolower( substr( strrchr( $wrapped_file , '.' ) , 1 ) ) ;
798        if( in_array( $ext , $page_wrap_search_allowed_exts ) ) {
799            $fp = fopen( $wrapped_file , 'r' ) ;
800            if( ! $fp ) {
801                continue ;
802            }
803            $text4sql = addslashes( tc_convert_wrap_to_ie( strip_tags( fread( $fp , 65536 * 2 ) ) ) ) ;
804            fclose( $fp ) ;
805        } else {
806            $text4sql = '' ;
807        }
808        $xoopsDB->queryF( "UPDATE $mytablename SET text='$text4sql' WHERE storyid=".intval($id) ) ;
809    }
810
811    redirect_header( "index.php?op=show" , 2 , _TC_DBUPDATED ) ;
812    exit ;
813    break ;
814
815// ------------------------------------------------------------------------- //
816// Upload File                                                //
817// ------------------------------------------------------------------------- //
818case "upload" :
819
820    // Ticket Check
821    if ( ! $xoopsGTicket->check() ) {
822        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
823    }
824
825    $source = $_FILES['fileupload']['tmp_name'] ;
826    $fileupload_name = $_FILES['fileupload']['name'] ;
827    if( $source != 'none' && $source != '' ) {
828        $dest = "$wrap_path/$fileupload_name" ;
829        if( file_exists( $dest ) ) {
830            redirect_header( "index.php?op=nlink" , 5 , _TC_ERROREXIST ) ;
831            exit ;
832        } else {
833            if( copy( $source , $dest ) ) {
834                redirect_header( "index.php?op=nlink" , 2 , _TC_UPLOADED ) ;
835                exit ;
836            } else {
837                redirect_header( "index.php?op=nlink" , 5 , _TC_ERRORUPL ) ;
838                exit ;
839            }
840            unlink( $source ) ;
841        }
842    }
843
844    break;
845
846// ------------------------------------------------------------------------- //
847// Delete File - Confirmation Question                                    //
848// ------------------------------------------------------------------------- //
849case "delfile" :
850    xoops_cp_header() ;
851    include( dirname(__FILE__).'/mymenu.php' ) ;
852
853    // security fix (thx JM2)
854    $_POST['address'] = str_replace( '..' , '' , $_POST['address'] ) ;
855
856    xoops_confirm( array( 'address' => $_POST['address'] , 'op' => 'delfileok' ) + $xoopsGTicket->getTicketArray( __LINE__ ) , 'index.php' , _TC_RUSUREDELF , _YES ) ;
857    xoops_cp_footer() ;
858    break ;
859
860// ------------------------------------------------------------------------- //
861// Delete it definitely                                                      //
862// ------------------------------------------------------------------------- //
863case "delfileok" :
864
865    // Ticket Check
866    if ( ! $xoopsGTicket->check() ) {
867        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
868    }
869
870    // security fix (thx JM2)
871    $_POST['address'] = str_replace( '..' , '' , $_POST['address'] ) ;
872
873    unlink( "$wrap_path/{$_POST['address']}" ) ;
874    redirect_header( "index.php?op=nlink" , 2 , _TC_FDELETED ) ;
875    exit ;
876    break ;
877
878// ------------------------------------------------------------------------- //
879// Delete Content - Confirmation Question                                    //
880// ------------------------------------------------------------------------- //
881case "delete" :
882    xoops_cp_header() ;
883    include( dirname(__FILE__).'/mymenu.php' ) ;
884    xoops_confirm( array( 'id' => intval( $_GET['id'] ) , 'op' => 'deleteit' ) + $xoopsGTicket->getTicketArray( __LINE__ ) , 'index.php' , _TC_RUSUREDEL , _YES ) ;
885    xoops_cp_footer() ;
886    break ;
887
888// ------------------------------------------------------------------------- //
889// Delete it definitely                                                      //
890// ------------------------------------------------------------------------- //
891case "deleteit" :
892    // Ticket Check
893    if ( ! $xoopsGTicket->check() ) {
894        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
895    }
896
897    $id = empty( $_POST['id'] ) ? 0 : intval( $_POST['id'] ) ;
898    $result = $xoopsDB->query( "DELETE FROM $mytablename WHERE storyid='$id'" ) ;
899    xoops_comment_delete( $xoopsModule->getVar( 'mid' ) , $id ) ;
900    redirect_header( "index.php?op=show" , 1 , _TC_DBUPDATED ) ;
901    exit ;
902    break ;
903
904// ------------------------------------------------------------------------- //
905// Export to the other TinyD
906// ------------------------------------------------------------------------- //
907case "moveto" :
908    // Ticket Check
909    if ( ! $xoopsGTicket->check() ) {
910        redirect_header(XOOPS_URL.'/',3,$xoopsGTicket->getErrors());
911    }
912
913    $destModule = $module_handler->get( intval( $_POST['dest_tinyd'] ) ) ;
914
915    // error check
916    if( empty( $_POST['checked_ids'] ) || ! is_object( $destModule ) ) {
917        redirect_header( "index.php?op=show" , 1 , _TC_DBUPDATED ) ;
918        exit ;
919    }
920
921    $dest_dirname = $destModule->getVar( 'dirname' ) ;
922    if( ! preg_match( '/^(\D+)(\d*)$/' , $dest_dirname , $regs ) ) echo ( "invalid dirname: " . htmlspecialchars( $dest_dirname ) ) ;
923    $dest_dirnumber = $regs[2] === '' ? '' : intval( $regs[2] ) ;
924    $dest_tablename = $xoopsDB->prefix( "tinycontent{$dest_dirnumber}" ) ;
925
926    $src_mid = $xoopsModule->getVar( 'mid' ) ;
927    $dest_mid = $destModule->getVar( 'mid' ) ;
928
929    // authority check
930    if( ! $xoopsUser->isAdmin( $dest_mid ) ) {
931        redirect_header( XOOPS_URL.'/' , 1 , _NOPERM ) ;
932        exit ;
933    }
934
935    foreach( $_POST['checked_ids'] as $src_id => $val ) {
936        if( ! $val ) continue ;
937        $rs = $xoopsDB->query( "SELECT * FROM $mytablename WHERE storyid='".intval($src_id)."'" ) ;
938        if( ! ( $rows = $xoopsDB->fetchArray( $rs ) ) ) continue ;
939        $set_sql = '' ;
940        foreach( $rows as $colname => $colval ) {
941            if( $colname == 'storyid' || $colname == 'homepage' ) continue ;
942            $set_sql .= "$colname='".addslashes($colval)."'," ;
943        }
944        $set_sql = substr( $set_sql , 0 , -1 ) ;
945        $ins_rs = $xoopsDB->query( "INSERT INTO $dest_tablename SET $set_sql" ) ;
946        $dest_id = $xoopsDB->getInsertId() ;
947        if( ! $ins_rs || $dest_id <= 0 ) {
948            redirect_header( "index.php?op=show" , 5 , 'The target module should be updated' ) ;
949            exit ;
950        }
951
952        // delete the record
953        $del_rs = $xoopsDB->query( "DELETE FROM $mytablename WHERE storyid='".intval($src_id)."'" ) ;
954        // moving comments
955        $sql = "UPDATE ".$xoopsDB->prefix('xoopscomments')." SET com_modid='$dest_mid',com_itemid='$dest_id' WHERE com_modid='$src_mid' AND com_itemid='$src_id'" ;
956        $xoopsDB->query( $sql ) ;
957    }
958
959    redirect_header( "index.php?op=show" , 1 , _TC_DBUPDATED ) ;
960    exit ;
961    break ;
962
963}
964
965
966
967// checks browser compatibility with the control
968function check_browser_can_use_spaw() {
969
970    return true ;   // for nobunobu's spaw 2005-5-10
971
972    $browser = $_SERVER['HTTP_USER_AGENT'] ;
973    // check if msie
974    if( eregi( "MSIE[^;]*" , $browser , $msie ) ) {
975        // get version
976        if( eregi( "[0-9]+\.[0-9]+" , $msie[0] , $version ) ) {
977            // check version
978            if( (float)$version[0] >= 5.5 ) {
979                // finally check if it's not opera impersonating ie
980                if( ! eregi( "opera" , $browser ) ) {
981                    return true ;
982                }
983            }
984        }
985    }
986    return false ;
987}
988
989
990
991
992?>
Note: See TracBrowser for help on using the repository browser.