code
stringlengths
1
2.01M
language
stringclasses
1 value
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <div class="table-list pad-lr-10"> <form name="myform" action="?m=admin&c=role&a=listorder" method="post"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="10%"><?php echo L('listorder');?></th> <th width="10%">ID</th> <th width="15%" align="left" ><?php echo L('role_name');?></th> <th width="265" align="left" ><?php echo L('role_desc');?></th> <th width="5%" align="left" ><?php echo L('role_status');?></th> <th class="text-c"><?php echo L('role_operation');?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td width="10%" align="center"><input name='listorders[<?php echo $info['roleid']?>]' type='text' size='3' value='<?php echo $info['listorder']?>' class="input-text-c"></td> <td width="10%" align="center"><?php echo $info['roleid']?></td> <td width="15%" ><?php echo $info['rolename']?></td> <td width="265" ><?php echo $info['description']?></td> <td width="5%"><a href="?m=admin&c=role&a=change_status&roleid=<?php echo $info['roleid']?>&disabled=<?php echo ($info['disabled']==1 ? 0 : 1)?>"><?php echo $info['disabled']? L('icon_locked'):L('icon_unlock')?></a></td> <td class="text-c"> <?php if($info['roleid'] > 1) {?> <a href="javascript:setting_role(<?php echo $info['roleid']?>, '<?php echo new_addslashes($info['rolename'])?>')"><?php echo L('role_setting');?></a> | <a href="javascript:void(0)" onclick="setting_cat_priv(<?php echo $info['roleid']?>, '<?php echo new_addslashes($info['rolename'])?>')"><?php echo L('usersandmenus')?></a> | <?php } else {?> <font color="#cccccc"><?php echo L('role_setting');?></font> | <font color="#cccccc"><?php echo L('usersandmenus')?></font> | <?php }?> <a href="?m=admin&c=role&a=member_manage&roleid=<?php echo $info['roleid']?>&menuid=<?php echo $_GET['menuid']?>"><?php echo L('role_member_manage');?></a> | <?php if($info['roleid'] > 1) {?><a href="?m=admin&c=role&a=edit&roleid=<?php echo $info['roleid']?>&menuid=<?php echo $_GET['menuid']?>"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=admin&c=role&a=delete&roleid=<?php echo $info['roleid']?>', '<?php echo L('posid_del_cofirm')?>')"><?php echo L('delete')?></a> <?php } else {?> <font color="#cccccc"><?php echo L('edit')?></font> | <font color="#cccccc"><?php echo L('delete')?></font> <?php }?> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </form> </div> </body> <script type="text/javascript"> <!-- function setting_role(id, name) { window.top.art.dialog({title:'<?php echo L('sys_setting')?>《'+name+'》',id:'edit',iframe:'?m=admin&c=role&a=priv_setting&roleid='+id,width:'700',height:'500'}); } function setting_cat_priv(id, name) { window.top.art.dialog({title:'<?php echo L('usersandmenus')?>《'+name+'》',id:'edit',iframe:'?m=admin&c=role&a=setting_cat_priv&roleid='+id,width:'700',height:'500'}); } //--> </script> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"<?php if(isset($addbg)) { ?> class="addbg"<?php } ?>> <head> <meta http-equiv="Content-Type" content="text/html; charset=<?php echo CHARSET?>" /> <meta http-equiv="X-UA-Compatible" content="IE=7" /> <title><?php echo L('website_manage');?></title> <link href="<?php echo CSS_PATH?>reset.css" rel="stylesheet" type="text/css" /> <link href="<?php echo CSS_PATH.SYS_STYLE;?>-system.css" rel="stylesheet" type="text/css" /> <link href="<?php echo CSS_PATH?>table_form.css" rel="stylesheet" type="text/css" /> <?php if(isset($show_dialog)) { ?> <link href="<?php echo CSS_PATH?>dialog.css" rel="stylesheet" type="text/css" /> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>dialog.js"></script> <?php } ?> <link rel="stylesheet" type="text/css" href="<?php echo CSS_PATH?>style/<?php echo SYS_STYLE;?>-styles1.css" title="styles1" media="screen" /> <link rel="alternate stylesheet" type="text/css" href="<?php echo CSS_PATH?>style/<?php echo SYS_STYLE;?>-styles2.css" title="styles2" media="screen" /> <link rel="alternate stylesheet" type="text/css" href="<?php echo CSS_PATH?>style/<?php echo SYS_STYLE;?>-styles3.css" title="styles3" media="screen" /> <link rel="alternate stylesheet" type="text/css" href="<?php echo CSS_PATH?>style/<?php echo SYS_STYLE;?>-styles4.css" title="styles4" media="screen" /> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>jquery.min.js"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>admin_common.js"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>styleswitch.js"></script> <?php if(isset($show_validator)) { ?> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidator.js" charset="UTF-8"></script> <script language="javascript" type="text/javascript" src="<?php echo JS_PATH?>formvalidatorregex.js" charset="UTF-8"></script> <?php } ?> <script type="text/javascript"> window.focus(); var pc_hash = '<?php echo $_SESSION['pc_hash'];?>'; <?php if(!isset($show_pc_hash)) { ?> window.onload = function(){ var html_a = document.getElementsByTagName('a'); var num = html_a.length; for(var i=0;i<num;i++) { var href = html_a[i].href; if(href && href.indexOf('javascript:') == -1) { if(href.indexOf('?') != -1) { html_a[i].href = href+'&pc_hash='+pc_hash; } else { html_a[i].href = href+'?pc_hash='+pc_hash; } } } var html_form = document.forms; var num = html_form.length; for(var i=0;i<num;i++) { var newNode = document.createElement("input"); newNode.name = 'pc_hash'; newNode.type = 'hidden'; newNode.value = pc_hash; html_form[i].appendChild(newNode); } } <?php } ?> </script> </head> <body> <?php if(!isset($show_header)) { ?> <div class="subnav"> <div class="content-menu ib-a blue line-x"> <?php if(isset($big_menu)) { echo '<a class="add fb" href="'.$big_menu[0].'"><em>'.$big_menu[1].'</em></a> ';} else {$big_menu = '';} ?> <?php echo admin::submenu($_GET['menuid'],$big_menu); ?> </div> </div> <?php } ?> <style type="text/css"> html{_overflow-y:scroll} </style>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#name").formValidator({onshow:"<?php echo L('input').L('posid_name')?>",onfocus:"<?php echo L('posid_name').L('not_empty')?>"}).inputValidator({min:1,max:999,onerror:"<?php echo L('posid_name').L('not_empty')?>"}); $("#maxnum").formValidator({onshow:"<?php echo L('input').L('maxnum')?>",onfocus:"<?php echo L('maxnum').L('not_empty')?>"}).inputValidator({min:1,onerror:"<?php echo L('maxnum').L('not_empty')?>"}).regexValidator({datatype:'enum',regexp:'intege1',onerror:'<?php echo L('maxnum').L('not_empty')?>'}).defaultPassed();; }) //--> </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=admin&c=position&a=add" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td width="80"><?php echo L('posid_name')?></td> <td><input type="text" name="info[name]" value="<?php echo $info[name]?>" class="input-text" id="name"></input></td> </tr> <tr> <td><?php echo L('posid_modelid')?></td> <td><?php echo form::select($modelinfo,'','name="info[modelid]" onchange="category_load(this);"',L('posid_select_model'));?> </tr> <tr> <td><?php echo L('posid_catid')?></td> <td id="load_catid"></td> </tr> <tr> <td><?php echo L('listorder')?></td> <td><input type="text" name="info[listorder]" id="listorder" class="input-text" size="5" value=""></input></td> </tr> <tr> <td><?php echo L('maxnum')?></td> <td><input type="text" name="info[maxnum]" id="maxnum" class="input-text" size="5" value="20"></input><?php echo L('posid_num')?></td> </tr> <tr> <td><?php echo L('extention_name')?></td> <td><input type="text" name="info[extention]" id="extention" class="input-text" size="20" value=""></input></td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> <div class="explain-col"> <?php echo L('position_tips')?><br/> <?php echo L('extention_name_tips')?> </div> </div></div> </body> </html> <script type="text/javascript"> function category_load(obj) { var modelid = $(obj).attr('value'); $.get('?m=admin&c=position&a=public_category_load&modelid='+modelid,function(data){ $('#load_catid').html(data); }); } </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_validator = true;include $this->admin_tpl('header');?> <script type="text/javascript"> $(document).ready(function() { $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#realname").formValidator({onshow:"<?php echo L('input').L('realname')?>",onfocus:"<?php echo L('realname').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('realname').L('between_2_to_20')?>"}) $("#email").formValidator({onshow:"<?php echo L('input').L('email')?>",onfocus:"<?php echo L('input').L('email')?>",oncorrect:"<?php echo L('email').L('format_right')?>"}).regexValidator({regexp:"email",datatype:"enum",onerror:"<?php echo L('email').L('format_incorrect')?>"}).ajaxValidator({ type : "get", url : "", data :"m=admin&c=admin_manage&a=public_email_ajx", datatype : "html", async:'false', success : function(data){ if( data == "1" ) { return true; } else { return false; } }, buttons: $("#dosubmit"), onerror : "<?php echo L('email_already_exists')?>", onwait : "<?php echo L('connecting_please_wait')?>" }).defaultPassed(); }) </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=admin&c=admin_manage&a=public_edit_info" method="post" id="myform"> <input type="hidden" name="info[userid]" value="<?php echo $userid?>"></input> <input type="hidden" name="info[username]" value="<?php echo $username?>"></input> <table width="100%" class="table_form contentWrap"> <tr> <td width="80"><?php echo L('username')?></td> <td><?php echo $username?></td> </tr> <tr> <td width="80"><?php echo L('lastlogintime')?></td> <td><?php echo $lastlogintime ? date('Y-m-d H:i:s',$lastlogintime) : ''?></td> </tr> <tr> <td width="80"><?php echo L('lastloginip')?></td> <td><?php echo $lastloginip?></td> </tr> <tr> <td><?php echo L('realname')?></td> <td> <input type="text" name="info[realname]" id="realname" class="input-text" size="30" value="<?php echo $realname?>"></input> </td> </tr> <tr> <td><?php echo L('email')?></td> <td> <input type="text" name="info[email]" id="email" class="input-text" size="40" value="<?php echo $email?>"></input> </td> </tr> <tr> <td>Language</td> <td> <select name="info[lang]" > <?php if(in_array('af',$dir_array)) { ?><option value="af" <?php if($lang=='af') echo 'selected="selected"';?>>Afrikaans</option><?php }?> <?php if(in_array('sq',$dir_array)) { ?><option value="sq" <?php if($lang=='sq') echo 'selected="selected"';?>>Shqip - Albanian</option><?php }?> <?php if(in_array('ar',$dir_array)) { ?><option value="ar" <?php if($lang=='ar') echo 'selected="selected"';?>>&#1575;&#1604;&#1593;&#1585;&#1576;&#1610;&#1577; - Arabic</option><?php }?> <?php if(in_array('az',$dir_array)) { ?><option value="az" <?php if($lang=='az') echo 'selected="selected"';?>>Az&#601;rbaycanca - Azerbaijani</option><?php }?> <?php if(in_array('bn',$dir_array)) { ?><option value="bn" <?php if($lang=='bn') echo 'selected="selected"';?>>Bangla</option><?php }?> <?php if(in_array('eu',$dir_array)) { ?><option value="eu" <?php if($lang=='eu') echo 'selected="selected"';?>>Euskara - Basque</option><?php }?> <?php if(in_array('becyr',$dir_array)) { ?><option value="becyr" <?php if($lang=='becyr') echo 'selected="selected"';?>>&#1041;&#1077;&#1083;&#1072;&#1088;&#1091;&#1089;&#1082;&#1072;&#1103; - Belarusian</option><?php }?> <?php if(in_array('belat',$dir_array)) { ?><option value="belat" <?php if($lang=='belat') echo 'selected="selected"';?>>Bie&#0322;aruskaja - Belarusian latin</option><?php }?> <?php if(in_array('bs',$dir_array)) { ?><option value="bs" <?php if($lang=='bs') echo 'selected="selected"';?>>Bosanski - Bosnian</option><?php }?> <?php if(in_array('ptbr',$dir_array)) { ?><option value="ptbr" <?php if($lang=='ptbr') echo 'selected="selected"';?>>Portugu&ecirc;s - Brazilian portuguese</option><?php }?> <?php if(in_array('bg',$dir_array)) { ?><option value="bg" <?php if($lang=='bg') echo 'selected="selected"';?>>&#1041;&#1098;&#1083;&#1075;&#1072;&#1088;&#1089;&#1082;&#1080; - Bulgarian</option><?php }?> <?php if(in_array('ca',$dir_array)) { ?><option value="ca" <?php if($lang=='ca') echo 'selected="selected"';?>>Catal&agrave; - Catalan</option><?php }?> <?php if(in_array('zh-cn',$dir_array)) { ?><option value="zh-cn" <?php if($lang=='zh-cn') echo 'selected="selected"';?>>&#20013;&#25991; - Chinese simplified</option><?php }?> <?php if(in_array('zhtw',$dir_array)) { ?><option value="zhtw" <?php if($lang=='zhtw') echo 'selected="selected"';?>>&#20013;&#25991; - Chinese traditional</option><?php }?> <?php if(in_array('hr',$dir_array)) { ?><option value="hr" <?php if($lang=='hr') echo 'selected="selected"';?>>Hrvatski - Croatian</option><?php }?> <?php if(in_array('cs',$dir_array)) { ?><option value="cs" <?php if($lang=='cs') echo 'selected="selected"';?>>&#268;esky - Czech</option><?php }?> <?php if(in_array('da',$dir_array)) { ?><option value="da" <?php if($lang=='da') echo 'selected="selected"';?>>Dansk - Danish</option><?php }?> <?php if(in_array('nl',$dir_array)) { ?><option value="nl" <?php if($lang=='nl') echo 'selected="selected"';?>>Nederlands - Dutch</option><?php }?> <?php if(in_array('en',$dir_array)) { ?><option value="en" <?php if($lang=='en') echo 'selected="selected"';?>>English</option><?php }?> <?php if(in_array('et',$dir_array)) { ?><option value="et" <?php if($lang=='et') echo 'selected="selected"';?>>Eesti - Estonian</option><?php }?> <?php if(in_array('fi',$dir_array)) { ?><option value="fi" <?php if($lang=='fi') echo 'selected="selected"';?>>Suomi - Finnish</option><?php }?> <?php if(in_array('fr',$dir_array)) { ?><option value="fr" <?php if($lang=='fr') echo 'selected="selected"';?>>Fran&ccedil;ais - French</option><?php }?> <?php if(in_array('gl',$dir_array)) { ?><option value="gl" <?php if($lang=='gl') echo 'selected="selected"';?>>Galego - Galician</option><?php }?> <?php if(in_array('ka',$dir_array)) { ?><option value="ka" <?php if($lang=='ka') echo 'selected="selected"';?>>&#4325;&#4304;&#4320;&#4311;&#4323;&#4314;&#4312; - Georgian</option><?php }?> <?php if(in_array('de',$dir_array)) { ?><option value="de" <?php if($lang=='de') echo 'selected="selected"';?>>Deutsch - German</option><?php }?> <?php if(in_array('el',$dir_array)) { ?><option value="el" <?php if($lang=='el') echo 'selected="selected"';?>>&Epsilon;&lambda;&lambda;&eta;&nu;&iota;&kappa;&#940; - Greek</option><?php }?> <?php if(in_array('he',$dir_array)) { ?><option value="he" <?php if($lang=='he') echo 'selected="selected"';?>>&#1506;&#1489;&#1512;&#1497;&#1514; - Hebrew</option><?php }?> <?php if(in_array('hi',$dir_array)) { ?><option value="hi" <?php if($lang=='hi') echo 'selected="selected"';?>>&#2361;&#2367;&#2344;&#2381;&#2342;&#2368; - Hindi</option><?php }?> <?php if(in_array('hu',$dir_array)) { ?><option value="hu" <?php if($lang=='hu') echo 'selected="selected"';?>>Magyar - Hungarian</option><?php }?> <?php if(in_array('id',$dir_array)) { ?><option value="id" <?php if($lang=='id') echo 'selected="selected"';?>>Bahasa Indonesia - Indonesian</option><?php }?> <?php if(in_array('it',$dir_array)) { ?><option value="it" <?php if($lang=='it') echo 'selected="selected"';?>>Italiano - Italian</option><?php }?> <?php if(in_array('ja',$dir_array)) { ?><option value="ja" <?php if($lang=='ja') echo 'selected="selected"';?>>&#26085;&#26412;&#35486; - Japanese</option><?php }?> <?php if(in_array('ko',$dir_array)) { ?><option value="ko" <?php if($lang=='ko') echo 'selected="selected"';?>>&#54620;&#44397;&#50612; - Korean</option><?php }?> <?php if(in_array('lv',$dir_array)) { ?><option value="lv" <?php if($lang=='lv') echo 'selected="selected"';?>>Latvie&scaron;u - Latvian</option><?php }?> <?php if(in_array('lt',$dir_array)) { ?><option value="lt" <?php if($lang=='lt') echo 'selected="selected"';?>>Lietuvi&#371; - Lithuanian</option><?php }?> <?php if(in_array('mkcyr',$dir_array)) { ?><option value="mkcyr" <?php if($lang=='mkcyr') echo 'selected="selected"';?>>Macedonian - Macedonian</option><?php }?> <?php if(in_array('ms',$dir_array)) { ?><option value="ms" <?php if($lang=='ms') echo 'selected="selected"';?>>Bahasa Melayu - Malay</option><?php }?> <?php if(in_array('mn',$dir_array)) { ?><option value="mn" <?php if($lang=='mn') echo 'selected="selected"';?>>&#1052;&#1086;&#1085;&#1075;&#1086;&#1083; - Mongolian</option><?php }?> <?php if(in_array('no',$dir_array)) { ?><option value="no" <?php if($lang=='no') echo 'selected="selected"';?>>Norsk - Norwegian</option><?php }?> <?php if(in_array('fa',$dir_array)) { ?><option value="fa" <?php if($lang=='fa') echo 'selected="selected"';?>>&#1601;&#1575;&#1585;&#1587;&#1740; - Persian</option><?php }?> <?php if(in_array('pl',$dir_array)) { ?><option value="pl" <?php if($lang=='pl') echo 'selected="selected"';?>>Polski - Polish</option><?php }?> <?php if(in_array('pt',$dir_array)) { ?><option value="pt" <?php if($lang=='pt') echo 'selected="selected"';?>>Portugu&ecirc;s - Portuguese</option><?php }?> <?php if(in_array('ro',$dir_array)) { ?><option value="ro" <?php if($lang=='ro') echo 'selected="selected"';?>>Rom&acirc;n&#259; - Romanian</option><?php }?> <?php if(in_array('ru',$dir_array)) { ?><option value="ru" <?php if($lang=='ru') echo 'selected="selected"';?>>&#1056;&#1091;&#1089;&#1089;&#1082;&#1080;&#1081; - Russian</option><?php }?> <?php if(in_array('srcyr',$dir_array)) { ?><option value="srcyr" <?php if($lang=='srcyr') echo 'selected="selected"';?>>&#1057;&#1088;&#1087;&#1089;&#1082;&#1080; - Serbian</option><?php }?> <?php if(in_array('srlat',$dir_array)) { ?><option value="srlat" <?php if($lang=='srlat') echo 'selected="selected"';?>>Srpski - Serbian latin</option><?php }?> <?php if(in_array('si',$dir_array)) { ?><option value="si" <?php if($lang=='si') echo 'selected="selected"';?>>&#3523;&#3538;&#3458;&#3524;&#3517; - Sinhala</option><?php }?> <?php if(in_array('af',$dir_array)) { ?><option value="sk" <?php if($lang=='sk') echo 'selected="selected"';?>>Sloven&#269;ina - Slovak</option><?php }?> <?php if(in_array('sl',$dir_array)) { ?><option value="sl" <?php if($lang=='sl') echo 'selected="selected"';?>>Sloven&scaron;&#269;ina - Slovenian</option><?php }?> <?php if(in_array('es',$dir_array)) { ?><option value="es" <?php if($lang=='es') echo 'selected="selected"';?>>Espa&ntilde;ol - Spanish</option><?php }?> <?php if(in_array('sv',$dir_array)) { ?><option value="sv" <?php if($lang=='sv') echo 'selected="selected"';?>>Svenska - Swedish</option><?php }?> <?php if(in_array('tt',$dir_array)) { ?><option value="tt" <?php if($lang=='tt') echo 'selected="selected"';?>>Tatar&ccedil;a - Tatarish</option><?php }?> <?php if(in_array('th',$dir_array)) { ?><option value="th" <?php if($lang=='th') echo 'selected="selected"';?>>&#3616;&#3634;&#3625;&#3634;&#3652;&#3607;&#3618; - Thai</option><?php }?> <?php if(in_array('tr',$dir_array)) { ?><option value="tr" <?php if($lang=='tr') echo 'selected="selected"';?>>T&uuml;rk&ccedil;e - Turkish</option><?php }?> <?php if(in_array('uk',$dir_array)) { ?><option value="uk" <?php if($lang=='uk') echo 'selected="selected"';?>>&#1059;&#1082;&#1088;&#1072;&#1111;&#1085;&#1089;&#1100;&#1082;&#1072; - Ukrainian</option><?php }?> <?php if(in_array('uzcyr',$dir_array)) { ?><option value="uzcyr" <?php if($lang=='uzcyr') echo 'selected="selected"';?>>&#1038;&#1079;&#1073;&#1077;&#1082;&#1095;&#1072; - Uzbek-cyrillic</option><?php }?> <?php if(in_array('uzlat',$dir_array)) { ?><option value="uzlat" <?php if($lang=='uzlat') echo 'selected="selected"';?>>O&lsquo;zbekcha - Uzbek-latin</option><?php }?> </select> </td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button" id="dosubmit"> </form> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <form name="myform" action="?m=admin&c=category&a=listorder" method="post"> <div class="pad_10"> <div class="explain-col"> <?php echo L('category_cache_tips');?>,<a href="?m=admin&c=category&a=public_cache&menuid=43&module=admin"><?php echo L('update_cache');?></a> </div> <div class="bk10"></div> <div class="table-list"> <table width="100%" cellspacing="0" > <thead> <tr> <th width="38"><?php echo L('listorder');?></th> <th width="30">catid</th> <th ><?php echo L('catname');?></th> <th align='left' width='50'><?php echo L('category_type');?></th> <th align='left' width="50"><?php echo L('modelname');?></th> <th align='center' width="40"><?php echo L('items');?></th> <th align='center' width="30"><?php echo L('vistor');?></th> <th align='center' width="80"><?php echo L('domain_help');?></th> <th ><?php echo L('operations_manage');?></th> </tr> </thead> <tbody> <?php echo $categorys;?> </tbody> </table> <div class="btn"> <input type="hidden" name="pc_hash" value="<?php echo $_SESSION['pc_hash'];?>" /> <input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </div> </div> </div> </form> <script language="JavaScript"> <!-- window.top.$('#display_center_id').css('display','none'); //--> </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="searchform" id="searchform" action="?m=admin&c=ipbanned&a=search_ip&menuid=<?php echo $_GET['menuid'];?>" method="get" > <input type="hidden" value="admin" name="m"> <input type="hidden" value="ipbanned" name="c"> <input type="hidden" value="search_ip" name="a"> <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td><div class="explain-col">IP: <input type="text" value="" class="input-text" id="ip" name="search[ip]"> <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit"> </div> </td> </tr> </tbody> </table> </form> <form name="myform" id="myform" action="?m=admin&c=ipbanned&a=delete" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('ipbannedid[]');"></th> <th width="30%">IP</th> <th ><?php echo L('deblocking_time')?></th> <th width="120"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center"> <input type="checkbox" name="ipbannedid[]" value="<?php echo $info['ipbannedid']?>"> </td> <td width="30%" align="left"><span class="<?php echo $info['style']?>"><?php echo $info['ip']?></span> </td> <td align="center"><?php echo date('Y-m-d', $info['expires']);?></td> <td align="center"><a href="javascript:confirmurl('?m=admin&c=ipbanned&a=delete&ipbannedid=<?php echo $info['ipbannedid']?>', '<?php echo L('confirm', array('message' => L('selected')))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?></tbody> </table> <div class="btn"> <a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input type="submit" name="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')" /> </div> <div id="pages"><?php echo $pages?></div> </div> </form></div> </body> </html> <script type="text/javascript"> function checkuid() { var ids=''; $("input[name='ipbannedid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:"<?php echo L('before_select_operation')?>",lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } function checkSubmit() { if (searchform.ip.value=="") { searchform.ip.focus(); alert("<?php echo L('parameters_error')?>"); return false; } else { if(searchform.ip.value.split(".").length!=4) { searchform.ip.focus(); alert("<?php echo L('ip_type_error')?>"); return false; } else { for(i=0;i<searchform.ip.value.split(".").length;i++) { var ipPart; ipPart=searchform.ip.value.split(".")[i]; if(isNaN(ipPart) || ipPart=="" || ipPart==null) { searchform.ip.focus(); alert("<?php echo L('ip_type_error')?>"); return false; } else { if(ipPart/1>255 || ipPart/1<0) { searchform.ip.focus(); alert("<?php echo L('ip_type_error')?>"); return false; } } } } } } </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <div class="pad_10"> <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td> <div class="explain-col"> <?php echo L('select_pdo_op')?> <?php echo form::select($pdos,$pdoname,'name="pdo_select" onchange="show_tbl(this)"',L('select_pdo'))?> <input type="submit" value="<?php echo L('pdo_look')?>" class="button" name="dosubmit"> </div> </td> </tr> </tbody> </table> <div class="table-list"> <form method="post" id="myform" name="myform" > <table width="100%" cellspacing="0"> <thead> <tr> <th width="10%" align="left"><input type="checkbox" value="" id="check_box" onclick="selectall('filenames[]');"></th> <th width="15%"><?php echo L('backup_file_name')?></th> <th width="15%"><?php echo L('backup_file_size')?></th> <th width="15%"><?php echo L('backup_file_time')?></th> <th width="15%"><?php echo L('backup_file_number')?></th> <th width="15%"><?php echo L('database_op')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td width="10%"> <input type="checkbox" name="filenames[]" value="<?php echo $info['filename']?>" id="sql_phpcms" boxid="sql_phpcms"> </td> <td width="15%" align="center"><?php echo $info['filename']?></td> <td width="15%" align="center"><?php echo $info['filesize']?> M</td> <td width="15%" align="center"><?php echo $info['maketime']?></td> <td width="15%" align="center"><?php echo $info['number']?></td> <td width="15%" align="center"> <a href="javascript:confirmurl('?m=admin&c=database&pdoname=<?php echo $pdoname?>&a=import&pre=<?php echo $info['pre']?>&dosubmit=1', '<?php echo L('confirm_recovery')?>')"><?php echo L('backup_import')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"> <label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('backup_del')?>" onclick="document.myform.action='?m=admin&c=database&a=delete&pdoname=<?php echo $pdoname?>';return confirm('<?php echo L('bakup_del_confirm')?>')"/> </div> </form> </div> </div> </body> </html> <script type="text/javascript"> <!-- function show_tbl(obj) { var pdoname = $(obj).val(); location.href='?m=admin&c=database&a=import&pdoname='+pdoname+'&menuid='+<?php echo $_GET['menuid']?>+'&pc_hash=<?php echo $_SESSION['pc_hash']?>'; } //--> </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <style type="text/css"> .table-list td b{color:#666} .tpl_style{background-color:#FBFAE3} </style> <form name="myform" action="?m=admin&c=category&a=batch_edit" method="post"> <div class="pad_10"> <div class="explain-col"> <?php echo L('category_batch_tips');?></a> </div> <div class="bk10"></div> <div id="table-lists" class="table-list" > <table height="auto" cellspacing="0" > <thead > <?php foreach($batch_array as $catid=>$cat) { $batch_array[$catid]['setting'] = string2array($cat['setting']); echo "<th width='260' align='left' ><strong>{$cat[catname]} (catid: <font color='red'>{$catid}</font>)</strong></th>"; } ?> </thead> <tbody> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('catname')?>:</b><br><input type='text' name='info[<?php echo $catid;?>][catname]' id='catname' class='input-text' value='<?php echo $cat['catname']?>' style='width:250px'></td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('catdir')?>:</b><br><input type='text' name='info[<?php echo $catid;?>][catdir]' id='catname' class='input-text' value='<?php echo $cat['catdir']?>' style='width:250px'></td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('catgory_img')?>:</b><br><?php echo form::images('info['.$catid.'][image]', 'image'.$catid, $cat['image'], 'content','',23);?></td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('description')?>:</b><br><textarea name="info[<?php echo $catid;?>][description]" maxlength="255" style="width:240px;height:40px;"><?php echo $cat['description'];?></textarea></td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td class="tpl_style"><b><?php echo L('available_styles')?>:</b><br> <?php echo form::select($template_list, $cat['setting']['template_list'], 'name="setting['.$catid.'][template_list]" id="template_list" onchange="load_file_list(this.value,'.$catid.')"', L('please_select'))?> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td class="tpl_style"><b><?php echo L('page_templates')?>:</b><br> <div id="category_template<?php echo $catid;?>"> <?php echo form::select_template($cat['setting']['template_list'], 'content',$cat['setting']['page_template'],'name="setting['.$catid.'][page_template]" style="width:250px"','page');?> </div> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('ismenu')?>:</b><br> <input boxid="ismenu" type='radio' name='info[<?php echo $catid;?>][ismenu]' value='1' <?php if($cat['ismenu']) echo 'checked';?> onclick="change_radio(event,'ismenu',1)"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input boxid="ismenu" type='radio' name='info[<?php echo $catid;?>][ismenu]' value='0' <?php if(!$cat['ismenu']) echo 'checked';?> onclick="change_radio(event,'ismenu',0)"> <?php echo L('no');?> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('html_category')?>:</b><br> <input boxid="ishtml" catid="<?php echo $catid;?>" type='radio' name='setting[<?php echo $catid;?>][ishtml]' value='1' <?php if($cat['setting']['ishtml']) echo 'checked';?> onClick="change_radio(event,'ishtml',1,'category');urlrule('category',1,<?php echo $catid;?>)"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input boxid="ishtml" catid="<?php echo $catid;?>" type='radio' name='setting[<?php echo $catid;?>][ishtml]' value='0' <?php if(!$cat['setting']['ishtml']) echo 'checked';?> onClick="change_radio(event,'ishtml',0,'category');urlrule('category',0,<?php echo $catid;?>)"> <?php echo L('no');?> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('category_urlrules')?>:</b><br> <div id="category_php_ruleid<?php echo $catid;?>" style="display:<?php if($cat['setting']['ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','category',0,$cat['setting']['category_ruleid'],'name="category_php_ruleid['.$catid.']" style="width:250px;"'); ?> </div> <div id="category_html_ruleid<?php echo $catid;?>" style="display:<?php if(!$cat['setting']['ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','category',1,$cat['setting']['category_ruleid'],'name="category_html_ruleid['.$catid.']" style="width:250px;"'); ?> </div> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('meta_title')?>:</b><br> <input name='setting[<?php echo $catid;?>][meta_title]' type='text' value='<?php echo $cat['setting']['meta_title'];?>' style='width:250px'> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('meta_keywords')?>:</b><br> <input name='setting[<?php echo $catid;?>][meta_keywords]' type='text' value='<?php echo $cat['setting']['meta_keywords'];?>' style='width:250px'> </td> <?php } ?> </tr> <tr> <?php foreach($batch_array as $catid=>$cat) { ?> <td><b><?php echo L('meta_description')?>:</b><br> <input name='setting[<?php echo $catid;?>][meta_description]' type='text' value='<?php echo $cat['setting']['meta_description'];?>' style='width:250px'> </td> <?php } ?> </tr> </tbody> </table> <div class="btn"> <input type="hidden" name="pc_hash" value="<?php echo $_SESSION['pc_hash'];?>" /> <input type="hidden" name="type" value="<?php echo $type;?>" /> <input type="submit" class="button" name="dosubmit" value="<?php echo L('submit')?>" /></div> <BR><BR> </div> </div> </div> </form> <script language="JavaScript"> <!-- $(document).keydown(function(event) { if(event.keyCode==37) { window.scrollBy(-100,0); } else if(event.keyCode==39) { window.scrollBy(100,0); } }); function change_radio(oEvent,boxid,value,type) { altKey = oEvent.altKey; if(altKey) { var obj = $("input[boxid="+boxid+"][value="+value+"]"); obj.attr('checked',true); if(type){ obj.each(function(){ urlrule(type,value,$(this).attr('catid')); }) } } } window.top.$('#display_center_id').css('display','none'); function urlrule(type,html,catid) { if(type=='category') { if(html) { $('#category_php_ruleid'+catid).css('display','none');$('#category_html_ruleid'+catid).css('display',''); } else { $('#category_php_ruleid'+catid).css('display','');$('#category_html_ruleid'+catid).css('display','none');; } } else { if(html) { $('#show_php_ruleid'+catid).css('display','none');$('#show_html_ruleid'+catid).css('display',''); } else { $('#show_php_ruleid'+catid).css('display','');$('#show_html_ruleid'+catid).css('display','none');; } } } function load_file_list(id,catid) { if(id=='') return false; $.getJSON('?m=admin&c=category&a=public_tpl_file_list&batch_str=1&type=1&style='+id+'&catid='+catid, function(data){ if(data==null) return false; $('#category_template'+catid).html(data.page_template);}); } //--> </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <div class="pad_10"> <div class="table-list"> <form name="myform" action="?m=admin&c=role&a=listorder" method="post"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="10%"><?php echo L('userid')?></th> <th width="10%" align="left" ><?php echo L('username')?></th> <th width="10%" align="left" ><?php echo L('userinrole')?></th> <th width="10%" align="left" ><?php echo L('lastloginip')?></th> <th width="20%" align="left" ><?php echo L('lastlogintime')?></th> <th width="15%" align="left" ><?php echo L('email')?></th> <th width="10%"><?php echo L('realname')?></th> <th width="15%" ><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php $admin_founders = explode(',',pc_base::load_config('system','admin_founders'));?> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td width="10%" align="center"><?php echo $info['userid']?></td> <td width="10%" ><?php echo $info['username']?></td> <td width="10%" ><?php echo $roles[$info['roleid']]?></td> <td width="10%" ><?php echo $info['lastloginip']?></td> <td width="20%" ><?php echo $info['lastlogintime'] ? date('Y-m-d H:i:s',$info['lastlogintime']) : ''?></td> <td width="15%"><?php echo $info['email']?></td> <td width="10%" align="center"><?php echo $info['realname']?></td> <td width="15%" align="center"> <a href="javascript:edit(<?php echo $info['userid']?>, '<?php echo new_addslashes($info['username'])?>')"><?php echo L('edit')?></a> | <?php if(!in_array($info['userid'],$admin_founders)) {?> <a href="javascript:confirmurl('?m=admin&c=admin_manage&a=delete&userid=<?php echo $info['userid']?>', '<?php echo L('admin_del_cofirm')?>')"><?php echo L('delete')?></a> <?php } else {?> <font color="#cccccc"><?php echo L('delete')?></font> <?php } ?> | <a href="javascript:void(0)" onclick="card(<?php echo $info['userid']?>)"><?php echo L('ht_card')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div id="pages"> <?php echo $pages?></div> </form> </div> </div> </body> </html> <script type="text/javascript"> <!-- function edit(id, name) { window.top.art.dialog({title:'<?php echo L('edit')?>--'+name, id:'edit', iframe:'?m=admin&c=admin_manage&a=edit&userid='+id ,width:'500px',height:'400px'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe; var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } function card(id) { window.top.art.dialog({title:'<?php echo L('the_password_card')?>', id:'edit', iframe:'?m=admin&c=admin_manage&a=card&userid='+id ,width:'500px',height:'400px'}, '', function(){window.top.art.dialog({id:'edit'}).close()}); } //--> </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header'); ?> <div class="pad_10"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="80">ID</th> <th align="left" ><?php echo L('release_point_name')?></th> <th align="left" ><?php echo L('server_address')?></th> <th align="left" ><?php echo L("username")?></th> <th width="150"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($list)): foreach($list as $v): ?> <tr> <td width="80" align="center"><?php echo $v['id']?></td> <td><?php echo $v['name']?></td> <td><?php echo $v['host']?></td> <td><?php echo $v['username']?></td> <td align="center" ><a href="javascript:edit(<?php echo $v['id']?>, '<?php echo new_addslashes($v['name'])?>')"><?php echo L('edit')?></a> | <a href="?m=admin&c=release_point&a=del&id=<?php echo $v['id']?>" onclick="return confirm('<?php echo new_addslashes(L('confirm', array('message'=>$v['name'])))?>')"><?php echo L('delete')?></a></td> </tr> <?php endforeach; endif; ?> </tbody> </table> </div> </div> <div id="pages"><?php echo $pages?></div> <script type="text/javascript"> <!-- function edit(id, name) { window.top.art.dialog({id:'edit'}).close(); window.top.art.dialog({title:'<?php echo L('release_point_edit')?>《'+name+'》',id:'edit',iframe:'?m=admin&c=release_point&a=edit&id='+id,width:'700',height:'500'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } //--> </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <div class="pad_10"> <div class="table-list"> <form method="post" name="myform" id="myform" action="?m=admin&c=database&a=export"> <input type="hidden" name="tabletype" value="phpcmstables" id="phpcmstables"> <table width="100%" cellspacing="0"> <thead> <tr> <th class="tablerowhighlight" colspan=4><?php echo L('backup_setting')?></th> </tr> </thead> <tr> <td class="align_r"><?php echo L('sizelimit')?></td> <td colspan=3><input type=text name="sizelimit" value="2048" size=5> K</td> </tr> <tr> <td class="align_r"><?php echo L('sqlcompat')?></td> <td colspan=3><input type="radio" name="sqlcompat" value="" checked> <?php echo L('default')?> &nbsp; <input type="radio" name="sqlcompat" value="MYSQL40"> MySQL 3.23/4.0.x &nbsp; <input type="radio" name="sqlcompat" value="MYSQL41"> MySQL 4.1.x/5.x &nbsp;</td> </tr> <tr> <td class="align_r"><?php echo L('sqlcharset')?></td> <td colspan=3><input type="radio" name="sqlcharset" value="" checked> <?php echo L('default')?>&nbsp; <input type="radio" name="sqlcharset" value="latin1"> LATIN1 &nbsp; <input type="radio" name="sqlcharset" value='utf8'> UTF-8</option></td> </tr> <tr> <td class="align_r"><?php echo L('select_pdo')?></td> <td colspan=3><?php echo form::select($pdos,$pdo_name,'name="pdo_select" onchange="show_tbl(this)"',L('select_pdo'))?></td> </tr> <tr> <td></td> <td colspan=3><input type="submit" name="dosubmit" value=" <?php echo L('backup_starting')?> " class="button"></td> </tr> </table> <table width="100%" cellspacing="0"> <?php if(is_array($infos)){ ?> <thead><tr><th align="center" colspan="8"><strong><?php echo $pdo_name?> <?php echo L('pdo_name')?></strong></th></tr></thead> <thead> <tr> <th width="10%"><input type="checkbox" value="" id="check_box" onclick="selectall('tables[]');"> <a class="cu" href="javascript:void(0);" onclick="reselect()"><?php echo L('reselect')?></a></th> <th width="10%" ><?php echo L('database_tblname')?></th> <th width="10%"><?php echo L('database_type')?></th> <th width="10%"><?php echo L('database_char')?></th> <th width="15%"><?php echo L('database_records')?></th> <th width="15%"><?php echo L('database_size')?></th> <th width="15%"><?php echo L('database_block')?></th> <th width="15%"><?php echo L('database_op')?></th> </tr> </thead> <tbody> <?php foreach($infos['phpcmstables'] as $v){?> <tr> <td width="5%" align="center"><input type="checkbox" name="tables[]" value="<?php echo $v['name']?>"/></td> <td width="10%" align="center"><?php echo $v['name']?></td> <td width="10%" align="center"><?php echo $v['engine']?></td> <td width="10%" align="center"><?php echo $v['collation']?></td> <td width="15%" align="center"><?php echo $v['rows']?></td> <td width="15%" align="center"><?php echo $v['size']?></td> <td width="15%" align="center"><?php echo $v['data_free']?></td> <td width="15%" align="center"><a href="?m=admin&c=database&a=public_repair&operation=optimize&pdo_name=<?php echo $pdo_name?>&tables=<?php echo $v['name']?>"><?php echo L('database_optimize')?></a> | <a href="?m=admin&c=database&a=public_repair&operation=repair&pdo_name=<?php echo $pdo_name?>&tables=<?php echo $v['name']?>"><?php echo L('database_repair')?></a> | <a href="javascript:void(0);" onclick="showcreat('<?php echo $v['name']?>','<?php echo $pdo_name?>')"><?php echo L('database_showcreat')?></a></td> </tr> <?php } ?> </tbody> <?php } ?> </table> <?php if(is_array($infos)){ ?> <div class="btn"> <label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="button" class="button" onclick="reselect()" value="<?php echo L('reselect')?>"/> <input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=admin&c=database&a=public_repair&operation=optimize&pdo_name=<?php echo $pdo_name?>'" value="<?php echo L('batch_optimize')?>"/> <input type="submit" class="button" name="dosubmit" onclick="document.myform.action='?m=admin&c=database&a=public_repair&operation=repair&pdo_name=<?php echo $pdo_name?>'" value="<?php echo L('batch_repair')?>"/> </div> <?php } ?> </form> </div> </div> </form> </body> <script type="text/javascript"> <!-- function show_tbl(obj) { var pdoname = $(obj).val(); location.href='?m=admin&c=database&a=export&pdoname='+pdoname+'&pc_hash=<?php echo $_SESSION['pc_hash']?>'; } function showcreat(tblname, pdo_name) { window.top.art.dialog({title:tblname, id:'show', iframe:'?m=admin&c=database&a=public_repair&operation=showcreat&pdo_name='+pdo_name+'&tables=' +tblname,width:'500px',height:'350px'}); } function reselect() { var chk = $("input[name=tables[]]"); var length = chk.length; for(i=0;i < length;i++){ if(chk.eq(i).attr("checked")) chk.eq(i).attr("checked",false); else chk.eq(i).attr("checked",true); } } //--> </script> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#modelid").formValidator({onshow:"<?php echo L('select_model');?>",onfocus:"<?php echo L('select_model');?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L('select_model');?>"}); $("#catname").formValidator({onshow:"<?php echo L('input_catname');?>",onfocus:"<?php echo L('input_catname');?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L('input_catname');?>"}); $("#catdir").formValidator({onshow:"<?php echo L('input_dirname');?>",onfocus:"<?php echo L('input_dirname');?>"}).regexValidator({regexp:"^([a-zA-Z0-9、-]|[_]){0,30}$",onerror:"<?php echo L('enter_the_correct_catname');?>"}).inputValidator({min:1,onerror:"<?php echo L('input_dirname');?>"}).ajaxValidator({type : "get",url : "",data :"m=admin&c=category&a=public_check_catdir",datatype : "html",cached:false,getdata:{parentid:'parentid'},async:'false',success : function(data){ if( data == "1" ){return true;}else{return false;}},buttons: $("#dosubmit"),onerror : "<?php echo L('catname_have_exists');?>",onwait : "<?php echo L('connecting');?>"}); $("#url").formValidator({onshow:" ",onfocus:"<?php echo L('domain_name_format');?>",tipcss:{width:'300px'},empty:true}).inputValidator({onerror:"<?php echo L('domain_name_format');?>"}).regexValidator({regexp:"http:\/\/(.+)\/$",onerror:"<?php echo L('domain_end_string');?>"}); $("#template_list").formValidator({onshow:"<?php echo L('template_setting');?>",onfocus:"<?php echo L('template_setting');?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L('template_setting');?>"}); }) //--> </script> <form name="myform" id="myform" action="?m=admin&c=category&a=add" method="post"> <div class="pad-10"> <div class="col-tab"> <ul class="tabBut cu-li"> <li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',6,1);"><?php echo L('catgory_basic');?></li> <li id="tab_setting_2" onclick="SwapTab('setting','on','',6,2);"><?php echo L('catgory_createhtml');?></li> <li id="tab_setting_3" onclick="SwapTab('setting','on','',6,3);"><?php echo L('catgory_template');?></li> <li id="tab_setting_4" onclick="SwapTab('setting','on','',6,4);"><?php echo L('catgory_seo');?></li> <li id="tab_setting_5" onclick="SwapTab('setting','on','',6,5);"><?php echo L('catgory_private');?></li> <li id="tab_setting_6" onclick="SwapTab('setting','on','',6,6);"><?php echo L('catgory_readpoint');?></li> </ul> <div id="div_setting_1" class="contentList pad-10"> <table width="100%" class="table_form "> <tr> <th><?php echo L('add_category_types');?>:</th> <td> <input type='radio' name='addtype' value='0' checked id="normal_addid"> <?php echo L('normal_add');?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='addtype' value='1' onclick="$('#catdir_tr').html(' ');$('#normal_add').html(' ');$('#normal_add').css('display','none');$('#batch_add').css('display','');$('#normal_addid').attr('disabled','true');this.disabled='true'"> <?php echo L('batch_add');?></td> </tr> <tr> <th width="200"><?php echo L('select_model')?>:</th> <td> <?php $model_datas = array(); foreach($models as $_k=>$_v) { if($_v['siteid']!=$this->siteid) continue; $model_datas[$_v['modelid']] = $_v['name']; } echo form::select($model_datas,$modelid,'name="info[modelid]" id="modelid" onchange="change_tpl(this.value)"',L('select_model')); ?> </td> </tr> <tr> <th width="200"><?php echo L('parent_category')?>:</th> <td> <?php echo form::select_category('category_content_'.$this->siteid,$parentid,'name="info[parentid]" id="parentid"',L('please_select_parent_category'),0,-1);?> </td> </tr> <tr> <th><?php echo L('catname')?>:</th> <td> <span id="normal_add"><input type="text" name="info[catname]" id="catname" class="input-text" value=""></span> <span id="batch_add" style="display:none"> <table width="100%" class="sss"><tr><td width="310"><textarea name="batch_add" maxlength="255" style="width:300px;height:60px;"></textarea></td> <td align="left"> <?php echo L('batch_add_tips');?> </td></tr></table> </span> </td> </tr> <tr id="catdir_tr"> <th><?php echo L('catdir')?>:</th> <td><input type="text" name="info[catdir]" id="catdir" class="input-text" value=""></td> </tr> <tr> <th><?php echo L('catgory_img')?>:</th> <td><?php echo form::images('info[image]', 'image', $image, 'content');?></td> </tr> <tr> <th><?php echo L('description')?>:</th> <td> <textarea name="info[description]" maxlength="255" style="width:300px;height:60px;"><?php echo $description;?></textarea> </td> </tr> <tr> <th><?php echo L('workflow');?>:</th> <td> <?php $workflows = getcache('workflow_'.$this->siteid,'commons'); if($workflows) { $workflows_datas = array(); foreach($workflows as $_k=>$_v) { $workflows_datas[$_v['workflowid']] = $_v['workname']; } echo form::select($workflows_datas,'','name="setting[workflowid]"',L('catgory_not_need_check')); } else { echo '<input type="hidden" name="setting[workflowid]" value="">'; echo L('add_workflow_tips'); } ?> </td> </tr> <tr> <th><?php echo L('ismenu');?>:</th> <td> <input type='radio' name='info[ismenu]' value='1' checked> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='info[ismenu]' value='0' > <?php echo L('no');?></td> </tr> </table> </div> <div id="div_setting_2" class="contentList pad-10 hidden"> <table width="100%" class="table_form "> <tr> <th width="200"><?php echo L('html_category');?>:</th> <td> <input type='radio' name='setting[ishtml]' value='1' <?php if($setting['ishtml']) echo 'checked';?> onClick="$('#category_php_ruleid').css('display','none');$('#category_html_ruleid').css('display','');$('#tr_domain').css('display','');"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[ishtml]' value='0' <?php if(!$setting['ishtml']) echo 'checked';?> onClick="$('#category_php_ruleid').css('display','');$('#category_html_ruleid').css('display','none');$('#tr_domain').css('display','none');"> <?php echo L('no');?> </td> </tr> <tr> <th><?php echo L('html_show');?>:</th> <td> <input type='radio' name='setting[content_ishtml]' value='1' <?php if($setting['content_ishtml']) echo 'checked';?> onClick="$('#show_php_ruleid').css('display','none');$('#show_html_ruleid').css('display','')"> <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[content_ishtml]' value='0' <?php if(!$setting['content_ishtml']) echo 'checked';?> onClick="$('#show_php_ruleid').css('display','');$('#show_html_ruleid').css('display','none')"> <?php echo L('no');?> </td> </tr> <tr> <th><?php echo L('category_urlrules');?>:</th> <td><div id="category_php_ruleid" style="display:<?php if($setting['ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','category',0,$setting['category_ruleid'],'name="category_php_ruleid"'); ?> </div> <div id="category_html_ruleid" style="display:<?php if(!$setting['ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','category',1,$setting['category_ruleid'],'name="category_html_ruleid"'); ?> </div> </td> </tr> <tr> <th><?php echo L('show_urlrules');?>:</th> <td><div id="show_php_ruleid" style="display:<?php if($setting['content_ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','show',0,$setting['category_ruleid'],'name="show_php_ruleid"'); ?> </div> <div id="show_html_ruleid" style="display:<?php if(!$setting['content_ishtml']) echo 'none';?>"> <?php echo form::urlrule('content','show',1,$setting['category_ruleid'],'name="show_html_ruleid"'); ?> </div> </td> </tr> <tr> <th><?php echo L('create_to_rootdir');?>:</th> <td> <input type='radio' name='setting[create_to_html_root]' value='1' <?php if($setting['create_to_html_root']) echo 'checked';?> > <?php echo L('yes');?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[create_to_html_root]' value='0' <?php if(!$setting['create_to_html_root']) echo 'checked';?> > <?php echo L('no');?> (<?php echo L('create_to_rootdir_tips');?>)</td> </tr> <tr id="tr_domain" style="display:<?php if(!$setting['ishtml']) echo 'none';?>"> <th><?php echo L('domain')?>:</th> <td><input type="text" name="info[url]" id="url" class="input-text" size="50" value=""></td> </tr> </table> </div> <div id="div_setting_3" class="contentList pad-10 hidden"> <table width="100%" class="table_form "> <tr> <th width="200"><?php echo L('available_styles');?>:</th> <td> <?php echo form::select($template_list, $setting['template_list'], 'name="setting[template_list]" id="template_list" onchange="load_file_list(this.value)"', L('please_select'))?> </td> </tr> <tr> <th width="200"><?php echo L('category_index_tpl')?>:</th> <td id="category_template"> </td> </tr> <tr> <th width="200"><?php echo L('category_list_tpl')?>:</th> <td id="list_template"> </td> </tr> <tr> <th width="200"><?php echo L('content_tpl')?>:</th> <td id="show_template"> </td> </tr> </table> </div> <div id="div_setting_4" class="contentList pad-10 hidden"> <table width="100%" class="table_form "> <tr> <th width="200"><?php echo L('meta_title');?></th> <td><input name='setting[meta_title]' type='text' id='meta_title' value='<?php echo $setting['meta_title'];?>' size='60' maxlength='60'></td> </tr> <tr> <th ><?php echo L('meta_keywords');?></th> <td><textarea name='setting[meta_keywords]' id='meta_keywords' style="width:90%;height:40px"><?php echo $setting['meta_keywords'];?></textarea></td> </tr> <tr> <th ><strong><?php echo L('meta_description');?></th> <td><textarea name='setting[meta_description]' id='meta_description' style="width:90%;height:50px"><?php echo $setting['meta_description'];?></textarea></td> </tr> </table> </div> <div id="div_setting_5" class="contentList pad-10 hidden"> <table width="100%" > <tr> <th width="200"><?php echo L('role_private')?>:</th> <td> <table width="100%" class="table-list"> <thead> <tr> <th align="left"><?php echo L('role_name');?></th><th><?php echo L('view');?></th><th><?php echo L('add');?></th><th><?php echo L('edit');?></th><th><?php echo L('delete');?></th><th><?php echo L('listorder');?></th><th><?php echo L('push');?></th><th><?php echo L('move');?></th> </tr> </thead> <tbody> <?php $roles = getcache('role','commons'); foreach($roles as $roleid=> $rolrname) { $disabled = $roleid==1 ? 'disabled' : ''; ?> <tr> <td><?php echo $rolrname?></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="init,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="add,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="edit,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="delete,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="listorder,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="push,<?php echo $roleid;?>" ></td> <td align="center"><input type="checkbox" name="priv_roleid[]" <?php echo $disabled;?> value="move,<?php echo $roleid;?>" ></td> </tr> <?php }?> </tbody> </table> </td> </tr> <tr><td colspan=2><hr style="border:1px dotted #F2F2F2;"></td> </tr> <tr> <th width="200"><?php echo L('group_private')?>:</th> <td> <table width="100%" class="table-list"> <thead> <tr> <th align="left"><?php echo L('group_name');?></th><th><?php echo L('allow_vistor');?></th><th><?php echo L('allow_contribute');?></th> </tr> </thead> <tbody> <?php $group_cache = getcache('grouplist','member'); foreach($group_cache as $_key=>$_value) { if($_value['groupid']==1) continue; ?> <tr> <td><?php echo $_value['name'];?></td> <td align="center"><input type="checkbox" name="priv_groupid[]" value="visit,<?php echo $_value['groupid'];?>" ></td> <td align="center"><input type="checkbox" name="priv_groupid[]" value="add,<?php echo $_value['groupid'];?>" ></td> </tr> <?php }?> </tbody> </table> </td> </tr> </table> </div> <div id="div_setting_6" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="200"><?php echo L('contribute_add_point');?></th> <td><input name='setting[presentpoint]' type='text' value='1' size='5' maxlength='5' style='text-align:center'> <?php echo L('contribute_add_point_tips');?></td> </tr> <tr> <th ><?php echo L('default_readpoint');?></th> <td><input name='setting[defaultchargepoint]' type='text' value='0' size='4' maxlength='4' style='text-align:center'> <select name="setting[paytype]"><option value="0"><?php echo L('readpoint');?></option><option value="1"><?php echo L('money');?></option></select> <?php echo L('readpoint_tips');?></td> </tr> <tr> <th><?php echo L('repeatchargedays');?></th> <td> <input name='setting[repeatchargedays]' type='text' value='1' size='4' maxlength='4' style='text-align:center'> <?php echo L('repeat_tips');?>&nbsp;&nbsp; <font color="red"><?php echo L('repeat_tips2');?></font></td> </tr> </table> </div> <div class="bk15"></div> <input name="catid" type="hidden" value="<?php echo $catid;?>"> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button"> </form> </div> </div> <!--table_form_off--> </div> <script language="JavaScript"> <!-- window.top.$('#display_center_id').css('display','none'); function SwapTab(name,cls_show,cls_hide,cnt,cur){ for(i=1;i<=cnt;i++){ if(i==cur){ $('#div_'+name+'_'+i).show(); $('#tab_'+name+'_'+i).attr('class',cls_show); }else{ $('#div_'+name+'_'+i).hide(); $('#tab_'+name+'_'+i).attr('class',cls_hide); } } } function change_tpl(modelid) { if(modelid) { $.getJSON('?m=admin&c=category&a=public_change_tpl&modelid='+modelid, function(data){$('#template_list').val(data.template_list);$('#category_template').html(data.category_template);$('#list_template').html(data.list_template);$('#show_template').html(data.show_template);}); } } function load_file_list(id) { if(id=='') return false; $.getJSON('?m=admin&c=category&a=public_tpl_file_list&style='+id+'&catid=<?php echo $parentid?>', function(data){$('#category_template').html(data.category_template);$('#list_template').html(data.list_template);$('#show_template').html(data.show_template);}); } <?php if($modelid) echo "change_tpl($modelid)";?> //--> </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_validator = true; include $this->admin_tpl('header');?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#username").formValidator({onshow:"<?php echo L('input').L('username')?>",onfocus:"<?php echo L('username').L('between_2_to_20')?>"}).inputValidator({min:2,max:20,onerror:"<?php echo L('username').L('between_2_to_20')?>"}).ajaxValidator({ type : "get", url : "", data :"m=admin&c=admin_manage&a=public_checkname_ajx", datatype : "html", async:'false', success : function(data){ if( data == "1" ) { return true; } else { return false; } }, buttons: $("#dosubmit"), onerror : "<?php echo L('user_already_exist')?>", onwait : "<?php echo L('connecting_please_wait')?>" }); $("#password").formValidator({onshow:"<?php echo L('input').L('password')?>",onfocus:"<?php echo L('password').L('between_6_to_20')?>"}).inputValidator({min:6,max:20,onerror:"<?php echo L('password').L('between_6_to_20')?>"}); $("#pwdconfirm").formValidator({onshow:"<?php echo L('input').L('cofirmpwd')?>",onfocus:"<?php echo L('input').L('passwords_not_match')?>",oncorrect:"<?php echo L('passwords_match')?>"}).compareValidator({desid:"password",operateor:"=",onerror:"<?php echo L('input').L('passwords_not_match')?>"}); $("#email").formValidator({onshow:"<?php echo L('input').L('email')?>",onfocus:"<?php echo L('email').L('format_incorrect')?>",oncorrect:"<?php echo L('email').L('format_right')?>"}).regexValidator({regexp:"email",datatype:"enum",onerror:"<?php echo L('email').L('format_incorrect')?>"}); }) //--> </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=admin&c=admin_manage&a=add" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td width="80"><?php echo L('username')?></td> <td><input type="test" name="info[username]" class="input-text" id="username"></input></td> </tr> <tr> <td><?php echo L('password')?></td> <td><input type="password" name="info[password]" class="input-text" id="password" value=""></input></td> </tr> <tr> <td><?php echo L('cofirmpwd')?></td> <td><input type="password" name="info[pwdconfirm]" class="input-text" id="pwdconfirm" value=""></input></td> </tr> <tr> <td><?php echo L('email')?></td> <td> <input type="text" name="info[email]" value="" class="input-text" id="email" size="30"></input> </td> </tr> <tr> <td><?php echo L('realname')?></td> <td> <input type="text" name="info[realname]" value="" class="input-text" id="realname"></input> </td> </tr> <tr> <td><?php echo L('userinrole')?></td> <td> <select name="info[roleid]"> <?php foreach($roles as $role) { ?> <option value="<?php echo $role['roleid']?>" <?php echo (($role['roleid']==$roleid) ? 'selected' : '')?>><?php echo $role['rolename']?></option> <?php } ?> </select> </td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button"> </form> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <script type="text/javascript"> <!-- $(function(){ SwapTab('setting','on','',5,<?php echo $_GET['tab'] ? $_GET['tab'] : '1'?>); $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#js_path").formValidator({onshow:"<?php echo L('setting_input').L('setting_js_path')?>",onfocus:"<?php echo L('setting_js_path').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_js_path').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_js_path').L('setting_end_with_x')?>"}); $("#css_path").formValidator({onshow:"<?php echo L('setting_input').L('setting_css_path')?>",onfocus:"<?php echo L('setting_css_path').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_css_path').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_css_path').L('setting_end_with_x')?>"}); $("#img_path").formValidator({onshow:"<?php echo L('setting_input').L('setting_img_path')?>",onfocus:"<?php echo L('setting_img_path').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_img_path').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_img_path').L('setting_end_with_x')?>"}); $("#upload_url").formValidator({onshow:"<?php echo L('setting_input').L('setting_upload_url')?>",onfocus:"<?php echo L('setting_upload_url').L('setting_end_with_x')?>"}).inputValidator({onerror:"<?php echo L('setting_upload_url').L('setting_input_error')?>"}).regexValidator({regexp:"(.+)\/$",onerror:"<?php echo L('setting_upload_url').L('setting_end_with_x')?>"}); $("#errorlog_size").formValidator({onshow:"<?php echo L('setting_errorlog_hint')?>",onfocus:"<?php echo L('setting_input').L('setting_error_log_size')?>"}).inputValidator({onerror:"<?php echo L('setting_error_log_size').L('setting_input_error')?>"}).regexValidator({regexp:"num",datatype:"enum",onerror:"<?php echo L('setting_errorlog_type')?>"}); $("#phpsso_api_url").formValidator({onshow:"<?php echo L('setting_phpsso_type')?>",onfocus:"<?php echo L('setting_phpsso_type')?>",tipcss:{width:'300px'},empty:false}).inputValidator({onerror:"<?php echo L('setting_phpsso_type')?>"}).regexValidator({regexp:"http:\/\/(.+)[^/]$",onerror:"<?php echo L('setting_phpsso_type')?>"}); $("#phpsso_appid").formValidator({onshow:"<?php echo L('input').L('setting_phpsso_appid')?>",onfocus:"<?php echo L('input').L('setting_phpsso_appid')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('setting_phpsso_appid').L('must_be_number')?>"}); $("#phpsso_version").formValidator({onshow:"<?php echo L('input').L('setting_phpsso_version')?>",onfocus:"<?php echo L('input').L('setting_phpsso_version')?>"}).regexValidator({regexp:"^\\d{1,8}$",onerror:"<?php echo L('setting_phpsso_version').L('must_be_number')?>"}); $("#phpsso_auth_key").formValidator({onshow:"<?php echo L('input').L('setting_phpsso_auth_key')?>",onfocus:"<?php echo L('input').L('setting_phpsso_auth_key')?>"}).regexValidator({regexp:"^\\w{32}$",onerror:"<?php echo L('setting_phpsso_auth_key').L('must_be_32_w')?>"}); }) //--> </script> <form action="?m=admin&c=setting&a=save" method="post" id="myform"> <div class="pad-10"> <div class="col-tab"> <ul class="tabBut cu-li"> <li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',5,1);"><?php echo L('setting_basic_cfg')?></li> <li id="tab_setting_2" onclick="SwapTab('setting','on','',5,2);"><?php echo L('setting_safe_cfg')?></li> <li id="tab_setting_3" onclick="SwapTab('setting','on','',5,3);"><?php echo L('setting_sso_cfg')?></li> <li id="tab_setting_4" onclick="SwapTab('setting','on','',5,4);"><?php echo L('setting_mail_cfg')?></li> <li id="tab_setting_5" onclick="SwapTab('setting','on','',5,5);"><?php echo L('setting_connect')?></li> </ul> <div id="div_setting_1" class="contentList pad-10"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('setting_admin_email')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[admin_email]" id="admin_email" size="30" value="<?php echo $admin_email?>"/></td> </tr> </table> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('setting_gzip')?></th> <td class="y-bg"> <input name="setconfig[gzip]" value="1" type="radio" <?php echo ($gzip=='1') ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input name="setconfig[gzip]" value="0" type="radio" <?php echo ($gzip=='0') ? ' checked' : ''?>> <?php echo L('setting_no')?></td> </tr> <tr> <th width="120"><?php echo L('setting_attachment_stat')?></th> <td class="y-bg"> <input name="setconfig[attachment_stat]" value="1" type="radio" <?php echo ($attachment_stat=='1') ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input name="setconfig[attachment_stat]" value="0" type="radio" <?php echo ($attachment_stat=='0') ? ' checked' : ''?>> <?php echo L('setting_no')?>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo L('setting_attachment_stat_desc')?></td> </tr> <tr> <th width="120"><?php echo L('setting_js_path')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[js_path]" id="js_path" size="50" value="<?php echo JS_PATH?>" /></td> </tr> <tr> <th width="120"><?php echo L('setting_css_path')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[css_path]" id="css_path" size="50" value="<?php echo CSS_PATH?>"/></td> </tr> <tr> <th width="120"><?php echo L('setting_img_path')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[img_path]" id="img_path" size="50" value="<?php echo IMG_PATH?>" /></td> </tr> <tr> <th width="120"><?php echo L('setting_upload_url')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[upload_url]" id="upload_url" size="50" value="<?php echo $upload_url?>" /></td> </tr> </table> </div> <div id="div_setting_2" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('setting_admin_log')?></th> <td class="y-bg"> <input name="setconfig[admin_log]" value="1" type="radio" <?php echo ($admin_log=='1') ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input name="setconfig[admin_log]" value="0" type="radio" <?php echo ($admin_log=='0') ? ' checked' : ''?>> <?php echo L('setting_no')?> </td> </tr> <tr> <th width="120"><?php echo L('setting_error_log')?></th> <td class="y-bg"> <input name="setconfig[errorlog]" value="1" type="radio" <?php echo ($errorlog=='1') ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input name="setconfig[errorlog]" value="0" type="radio" <?php echo ($errorlog=='0') ? ' checked' : ''?>> <?php echo L('setting_no')?> </td> </tr> <tr> <th><?php echo L('setting_error_log_size')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[errorlog_size]" id="errorlog_size" size="5" value="<?php echo $errorlog_size?>"/> MB</td> </tr> <tr> <th><?php echo L('setting_maxloginfailedtimes')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[maxloginfailedtimes]" id="maxloginfailedtimes" size="10" value="<?php echo $maxloginfailedtimes?>"/></td> </tr> <tr> <th><?php echo L('setting_minrefreshtime')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[minrefreshtime]" id="minrefreshtime" size="10" value="<?php echo $minrefreshtime?>"/> <?php echo L('miao')?></td> </tr> </table> </div> <div id="div_setting_3" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('setting_phpsso')?></th> <td class="y-bg"> <input name="setconfig[phpsso]" value="1" type="radio" <?php echo ($phpsso=='1') ? ' checked' : ''?>> <?php echo L('setting_yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input name="setconfig[phpsso]" value="0" type="radio" <?php echo ($phpsso=='0') ? ' checked' : ''?>> <?php echo L('setting_no')?></td> </tr> <tr> <th><?php echo L('setting_phpsso_appid')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[phpsso_appid]" id="phpsso_appid" size="30" value="<?php echo $phpsso_appid ?>"/></td> </tr> <tr> <th><?php echo L('setting_phpsso_phpsso_api_url')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[phpsso_api_url]" id="phpsso_api_url" size="50" value="<?php echo $phpsso_api_url ?>"/></td> </tr> <tr> <th><?php echo L('setting_phpsso_auth_key')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[phpsso_auth_key]" id="phpsso_auth_key" size="50" value="<?php echo $phpsso_auth_key ?>"/></td> </tr> <tr> <th><?php echo L('setting_phpsso_version')?></th> <td class="y-bg"><input type="text" class="input-text" name="setconfig[phpsso_version]" id="phpsso_version" size="2" value="<?php echo $phpsso_version ?>"/></td> </tr> </table> </div> <div id="div_setting_4" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('mail_type')?></th> <td class="y-bg"> <input name="setting[mail_type]" checkbox="mail_type" value="1" onclick="showsmtp(this)" type="radio" <?php echo $mail_type==1 ? ' checked' : ''?>> <?php echo L('mail_type_smtp')?> <input name="setting[mail_type]" checkbox="mail_type" value="0" onclick="showsmtp(this)" type="radio" <?php echo $mail_type==0 ? ' checked' : ''?> <?php if(substr(strtolower(PHP_OS), 0, 3) == 'win') echo 'disabled'; ?>/> <?php echo L('mail_type_mail')?> </td> </tr> <tbody id="smtpcfg" style="<?php if($mail_type == 0) echo 'display:none'?>"> <tr> <th><?php echo L('mail_server')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[mail_server]" id="mail_server" size="30" value="<?php echo $mail_server?>"/></td> </tr> <tr> <th><?php echo L('mail_port')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[mail_port]" id="mail_port" size="30" value="<?php echo $mail_port?>"/></td> </tr> <tr> <th><?php echo L('mail_from')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[mail_from]" id="mail_from" size="30" value="<?php echo $mail_from?>"/></td> </tr> <tr> <th><?php echo L('mail_auth')?></th> <td class="y-bg"> <input name="setting[mail_auth]" id="mail_auth" value="1" type="radio" <?php echo $mail_auth==1 ? ' checked' : ''?>> <?php echo L('mail_auth_open')?> <input name="setting[mail_auth]" id="mail_auth" value="0" type="radio" <?php echo $mail_auth==0 ? ' checked' : ''?>> <?php echo L('mail_auth_close')?></td> </tr> <tr> <th><?php echo L('mail_user')?></th> <td class="y-bg"><input type="text" class="input-text" name="setting[mail_user]" id="mail_user" size="30" value="<?php echo $mail_user?>"/></td> </tr> <tr> <th><?php echo L('mail_password')?></th> <td class="y-bg"><input type="password" class="input-text" name="setting[mail_password]" id="mail_password" size="30" value="<?php echo $mail_password?>"/></td> </tr> </tbody> <tr> <th><?php echo L('mail_test')?></th> <td class="y-bg"><input type="text" class="input-text" name="mail_to" id="mail_to" size="30" value=""/> <input type="button" class="button" onClick="javascript:test_mail();" value="<?php echo L('mail_test_send')?>"></td> </tr> </table> </div> <div id="div_setting_5" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('setting_snda_enable')?></th> <td class="y-bg"> APP key <input type="text" class="input-text" name="setconfig[snda_akey]" id="snda_akey" size="20" value="<?php echo $snda_akey ?>"/> APP secret key <input type="text" class="input-text" name="setconfig[snda_skey]" id="snda_skey" size="40" value="<?php echo $snda_skey ?>"/> <a href="http://code.snda.com/index/oauth" target="_blank"><?php echo L('click_register')?></a> </td> </tr> <tr> <th><?php echo L('setting_connect_sina')?></th> <td class="y-bg"> App key <input type="text" class="input-text" name="setconfig[sina_akey]" id="sina_akey" size="20" value="<?php echo $sina_akey ?>"/> App secret key <input type="text" class="input-text" name="setconfig[sina_skey]" id="sina_skey" size="40" value="<?php echo $sina_skey ?>"/> <a href="http://open.t.sina.com.cn/wiki/index.php/<?php echo L('connect_micro')?>" target="_blank"><?php echo L('click_register')?></a> </td> </tr> <tr> <th><?php echo L('setting_connect_qq')?></th> <td class="y-bg"> App key <input type="text" class="input-text" name="setconfig[qq_akey]" id="qq_akey" size="20" value="<?php echo $qq_akey ?>"/> App secret key <input type="text" class="input-text" name="setconfig[qq_skey]" id="qq_skey" size="40" value="<?php echo $qq_skey ?>"/> <a href="http://open.t.qq.com/" target="_blank"><?php echo L('click_register')?></a> </td> </tr> </table> </div> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button"> </div> </div> </form> </body> <script type="text/javascript"> function SwapTab(name,cls_show,cls_hide,cnt,cur){ for(i=1;i<=cnt;i++){ if(i==cur){ $('#div_'+name+'_'+i).show(); $('#tab_'+name+'_'+i).attr('class',cls_show); }else{ $('#div_'+name+'_'+i).hide(); $('#tab_'+name+'_'+i).attr('class',cls_hide); } } } function showsmtp(obj,hiddenid){ hiddenid = hiddenid ? hiddenid : 'smtpcfg'; var status = $(obj).val(); if(status == 1) $("#"+hiddenid).show(); else $("#"+hiddenid).hide(); } function test_mail() { var mail_type = $('input[checkbox=mail_type][checked]').val(); $.post('?m=admin&c=setting&a=public_test_mail&mail_to='+$('#mail_to').val(),{mail_type:mail_type,mail_server:$('#mail_server').val(),mail_port:$('#mail_port').val(),mail_user:$('#mail_user').val(),mail_password:$('#mail_password').val(),mail_auth:$('#mail_auth').val(),mail_auth:$('#mail_auth').val(),mail_from:$('#mail_from').val()}, function(data){ alert(data); }); } </script> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="myform" id="myform" action="?m=admin&c=copyfrom&a=listorder" method="post"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="55" align="center"><?php echo L('listorder');?></th> <th><?php echo L('copyfrom_name');?></th> <th ><?php echo L('copyfrom_url')?></th> <th ><?php echo L('copyfrom_logo')?></th> <th width="120"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php foreach($datas as $r) { ?> <tr> <td align="center"><input type="text" name="listorders[<?php echo $r['id']?>]" value="<?php echo $r['listorder']?>" size="3" class='input-text-c'></td> <td align="center"><?php echo $r['sitename']?></td> <td align="center"><?php echo $r['siteurl']?></td> <td align="center"><?php if($r['thumb']) {?><img src="<?php echo $r['thumb']?>"><?php }?></td> <td align="center"><a href="javascript:edit('<?php echo $r['id']?>','<?php echo new_addslashes($r['sitename'])?>')"><?php echo L('edit');?></a> | <a href="javascript:;" onclick="data_delete(this,'<?php echo $r['id']?>','<?php echo L('confirm',array('message'=>new_addslashes($r['sitename'])));?>')"><?php echo L('delete')?></a> </td> </tr> <?php } ?> </tbody> </table> <div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </div> <div id="pages"><?php echo $pages?></div> </div> </form></div> </body> </html> <script type="text/javascript"> <!-- function edit(id, name) { window.top.art.dialog({id:'edit'}).close(); window.top.art.dialog({title:'<?php echo L('edit');?>《'+name+'》',id:'edit',iframe:'?m=admin&c=copyfrom&a=edit&id='+id,width:'580',height:'240'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } function data_delete(obj,id,name){ window.top.art.dialog({content:name, fixed:true, style:'confirm', id:'data_delete'}, function(){ $.get('?m=admin&c=copyfrom&a=delete&id='+id+'&pc_hash='+pc_hash,function(data){ if(data) { $(obj).parent().parent().fadeOut("slow"); } }) }, function(){}); }; //--> </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header'); ?> <form name="myform" action="?m=admin&c=position&a=public_item" method="post"> <input type="hidden" value="<?php echo $posid?>" name="posid"> <div class="pad_10"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="10%" align="left"><input type="checkbox" value="" id="check_box" onclick="selectall('items[]');"></th> <th width="10%" align="left"><?php echo L('listorder');?></th> <th width="10%" align="left">ID</th> <th width="" align="left"><?php echo L('title');?></th> <th width="15%"><?php echo L('catname');?></th> <th width="15%"><?php echo L('inputtime')?></th> <th width="15%"><?php echo L('posid_operation');?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td width="10%"> <input type="checkbox" name="items[]" value="<?php echo $info['id'],'-',$info['modelid']?>" id="items" boxid="items"> </td> <td width="10%"> <input name='listorders[<?php echo $info['catid'],'-',$info['id']?>]' type='text' size='3' value='<?php echo $info['listorder']?>' class="input-text-c"> </td> <td width="10%" align="left"><?php echo $info['id']?></td> <td width="" align="left"><?php echo $info['title']?> <?php if($info['thumb']!='') {echo '<img src="'.IMG_PATH.'icon/small_img.gif">'; }?></td> <td width="15%" align="center"><?php echo $info['catname']?></td> <td width="15%" align="center"><?php echo date('Y-m-d H:i:s',$info['inputtime'])?></td> <td width="15%" align="center"><a href="<?php echo $info['url']?>" target="_blank"><?php echo L('posid_item_view')?></a> | <a onclick="javascript:openwinx('?m=content&c=content&a=edit&catid=<?php echo $info['catid']?>&id=<?php echo $info['id']?>','')" href="javascript:;"><?php echo L('posid_item_edit');?></a> | <a href="javascript:item_manage(<?php echo $info['id']?>,<?php echo $info['posid']?>, <?php echo $info['modelid']?>,'<?php echo $info['title']?>')"><?php echo L('posid_item_manage')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="button" class="button" value="<?php echo L('listorder')?>" onclick="myform.action='?m=admin&c=position&a=public_item_listorder';myform.submit();"/> <input type="submit" class="button" name="dosubmit" value="<?php echo L('posid_item_remove')?>" /> </div></div> <div id="pages"> <?php echo $pages?></div> </div> </div> </form> </body> </html> <script type="text/javascript"> function item_manage(id,posid, modelid, name) { window.top.art.dialog({title:'<?php echo L('edit')?>--'+name, id:'edit', iframe:'?m=admin&c=position&a=public_item_manage&id='+id+'&posid='+posid+'&modelid='+modelid ,width:'550px',height:'430px'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe; var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_header = true; $show_scroll = true; include $this->admin_tpl('header'); ?> <body scroll="no"> <div style="padding:6px 3px"> <div class="col-2 col-left mr6" style="width:140px"> <h6><img src="<?php echo IMG_PATH?>icon/sitemap-application-blue.png" width="16" height="16" /> <?php echo L('site_select');?></h6> <ul class="content role-memu" id="site_list"> <?php foreach($sites_list as $n=>$r) {?> <li><a href="?m=admin&c=role&a=setting_cat_priv&siteid=<?php echo $r['siteid']?>&roleid=<?php echo $roleid?>&op=1" target="role"><span><img src="<?php echo IMG_PATH?>icon/gear_disable.png" width="16" height="16" /><?php echo L('sys_setting');?></span><em><?php echo $r['name']?></em></a></li> <?php } ?> </ul> </div> <div class="col-2 col-auto"> <div class="content" style="padding:1px"> <iframe name="role" id="role" src="?m=admin&c=role&a=role_priv&pc_hash=<?php echo $_SESSION['pc_hash']?>" frameborder="false" scrolling="auto" style="overflow-x:hidden;border:none" width="100%" height="483" allowtransparency="true"></iframe> </div> </div> </div> </body> </html> <script type="text/javascript"> $("#site_list li").click( function(){$(this).addClass("on").siblings().removeClass('on')} ); </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <div class="pad_10"> <div class="table-list"> <xmp><?php echo $structure?></xmp> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="myform" id="myform" action="?m=admin&c=badword&a=delete" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('badid[]');"></th> <th ><?php echo L('badword_name')?></th> <th ><?php echo L('badword_replacename')?></th> <th width="80"><?php echo L('badword_level')?></th> <th width="120"><?php echo L('inputtime')?></th> <th width="120"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center"> <input type="checkbox" name="badid[]" value="<?php echo $info['badid']?>"> </td> <td align="center"><span class="<?php echo $info['style']?>"><?php echo $info['badword']?></span> </td> <td align="center"><?php echo $info['replaceword']?></td> <td align="center"><?php echo $level[$info['level']]?></td> <td align="center"><?php echo $info['lastusetime'] ? date('Y-m-d H:i', $info['lastusetime']):''?></td> <td align="center"><a href="javascript:edit(<?php echo $info['badid']?>, '<?php echo new_addslashes($info['badword'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=admin&c=badword&a=delete&badid=<?php echo $info['badid']?>', '<?php echo L('badword_confirm_del')?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"> <a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input type="submit" name="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('badword_confom_del')?>')" /> </div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> </body> </html> <script type="text/javascript"> function edit(id, name) { window.top.art.dialog({id:'edit'}).close(); window.top.art.dialog({title:'<?php echo L('badword_edit')?> '+name+' ',id:'edit',iframe:'?m=admin&c=badword&a=edit&badid='+id,width:'450',height:'180'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } function checkuid() { var ids=''; $("input[name='badid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:'<?php echo L('badword_pleasechose')?>',lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#sitename").formValidator({onshow:"<?php echo L('input').L('mirrors_name')?>",onfocus:"<?php echo L('mirrors_name').L('downserver_not_empty')?>"}).inputValidator({min:1,max:999,onerror:"<?php echo L('downserver_name').L('downserver_not_empty')?>"}); $("#siteurl").formValidator({onshow:"<?php echo L('mirror_address')?>",onfocus:"<?php echo L('mirror_address')?>"}).inputValidator({onerror:"<?php echo L('downserver_error')?>"}).regexValidator({regexp:"([a-zA-Z]+):\/\/(.+)[^\/]$",onerror:"<?php echo L('downserver_error')?>"}); }) //--> </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=admin&c=downservers&a=edit" method="post" id="myform"> <input type="hidden" name="id" value="<?php echo $id?>"></input> <table width="100%" class="table_form"> <tr> <td width="80"><?php echo L('mirrors_name')?></td> <td><input type="text" name="info[sitename]" class="input-text" value="<?php echo $sitename?>" id="sitename"></input></td> </tr> <tr> <td width="80"><?php echo L('mirror_address')?></td> <td><input type="text" name="info[siteurl]" class="input-text" value="<?php echo $siteurl?>" id="siteurl" size="40"></input></td> </tr> <tr> <td><?php echo L('site_select')?></td> <td><?php echo form::select($sitelist,$siteid,'name="info[siteid]"',$default)?></td> </tr> </table> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header');?> <form name="myform" action="?m=admin&c=position&a=listorder" method="post"> <div class="pad_10"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="10%" align="left"><?php echo L('listorder');?></th> <th width="5%" align="left">ID</th> <th width="15%"><?php echo L('posid_name');?></th> <th width="15%"><?php echo L('posid_catid');?></th> <th width="15%"><?php echo L('posid_modelid');?></th> <th width="20%"><?php echo L('posid_operation');?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td width="10%"> <input name='listorders[<?php echo $info['posid']?>]' type='text' size='2' value='<?php echo $info['listorder']?>' class="input-text-c"> </td> <td width="5%" align="left"><?php echo $info['posid']?></td> <td width="15%" align="center"><?php echo $info['name']?></td> <td width="15%" align="center"><?php echo $info['catid'] ? $category[$info['catid']]['catname'] : L('posid_all')?></td> <td width="15%" align="center"><?php echo $info['modelid'] ? $model[$info['modelid']]['name'] : L('posid_all')?></td> <td width="20%" align="center"> <a href="?m=admin&c=position&a=public_item&posid=<?php echo $info['posid']?>&menuid=<?php echo $_GET['menuid']?>"><?php echo L('posid_item_manage')?></a> | <a href="javascript:edit(<?php echo $info['posid']?>, '<?php echo new_addslashes($info['name'])?>')"><?php echo L('edit')?></a> | <?php if($info['siteid']=='0' && $_SESSION['roleid'] != 1) {?> <font color="#ccc"><?php echo L('delete')?></font> <?php } else {?> <a href="javascript:confirmurl('?m=admin&c=position&a=delete&posid=<?php echo $info['posid']?>', '<?php echo L('posid_del_cofirm')?>')"><?php echo L('delete')?></a> <?php } ?> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </div> <div id="pages"> <?php echo $pages?></div> </div> </div> </form> </body> <a href="javascript:edit(<?php echo $v['siteid']?>, '<?php echo $v['name']?>')"> </html> <script type="text/javascript"> <!-- window.top.$('#display_center_id').css('display','none'); function edit(id, name) { window.top.art.dialog({title:'<?php echo L('edit')?>--'+name, id:'edit', iframe:'?m=admin&c=position&a=edit&posid='+id ,width:'500px',height:'360px'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe; var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } //--> </script>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class copyfrom extends admin { private $db; public $siteid; function __construct() { $this->db = pc_base::load_model('copyfrom_model'); pc_base::load_sys_class('form', '', 0); parent::__construct(); $this->siteid = $this->get_siteid(); } /** * 来源管理列表 */ public function init () { $datas = array(); $datas = $this->db->listinfo(array('siteid'=>$this->siteid),'listorder ASC',$_GET['page']); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=copyfrom&a=add\', title:\''.L('add_copyfrom').'\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_copyfrom')); $this->public_cache(); include $this->admin_tpl('copyfrom_list'); } /** * 添加来源 */ public function add() { if(isset($_POST['dosubmit'])) { $_POST['info'] = $this->check($_POST['info']); $this->db->insert($_POST['info']); showmessage(L('add_success'), '', '', 'add'); } else { $show_header = $show_validator = ''; include $this->admin_tpl('copyfrom_add'); } } /** * 管理来源 */ public function edit() { if(isset($_POST['dosubmit'])) { $id = intval($_POST['id']); $_POST['info'] = $this->check($_POST['info']); $this->db->update($_POST['info'],array('id'=>$id)); showmessage(L('update_success'), '', '', 'edit'); } else { $show_header = $show_validator = ''; $id = intval($_GET['id']); if (!$id) showmessage(L('illegal_action')); $r = $this->db->get_one(array('id'=>$id, 'siteid'=>$this->siteid)); if (empty($r)) showmessage(L('illegal_action')); extract($r); include $this->admin_tpl('copyfrom_edit'); } } /** * 删除来源 */ public function delete() { $_GET['id'] = intval($_GET['id']); if (!$_GET['id']) showmessage(L('illegal_action')); $this->db->delete(array('id'=>$_GET['id'], 'siteid'=>$this->siteid)); exit('1'); } /** * 检查POST数据 * @param array $data 前台POST数据 * @return array $data */ private function check($data = array()) { if (!is_array($data) || empty($data)) return array(); if (!preg_match('/^((http|https):\/\/)?([^\/]+)/i', $data['siteurl'])) showmessage(L('input').L('copyfrom_url')); if (empty($data['sitename'])) showmessage(L('input').L('copyfrom_name')); if ($data['thumb'] && !preg_match('/^((http|https):\/\/)?([^\/]+)/i', $data['thumb'])) showmessage(L('copyfrom_logo').L('format_incorrect')); $data['siteid'] = $this->siteid; return $data; } /** * 排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $id => $listorder) { $this->db->update(array('listorder'=>$listorder),array('id'=>$id)); } showmessage(L('operation_success'),HTTP_REFERER); } else { showmessage(L('operation_failure')); } } /** * 生成缓存 */ public function public_cache() { $infos = $this->db->select('','*','','listorder DESC','','id'); setcache('copyfrom', $infos, 'admin'); return true; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class release_point extends admin { private $db; public $ssl = 0; public function __construct() { parent::__construct(); $this->db = pc_base::load_model('release_point_model'); if (function_exists('ftp_ssl_connect')) { $this->ssl = 1; } } public function init() { $list = $this->db->select(); $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=release_point&a=add\', title:\''.L('release_point_add').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('release_point_add')); include $this->admin_tpl('release_point_list'); } public function add() { if (isset($_POST['dosubmit'])) { $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : showmessage(L('release_point_name').L('empty')); $host = isset($_POST['host']) && trim($_POST['host']) ? trim($_POST['host']) : showmessage(L('server_address').L('empty')); $port = isset($_POST['port']) && intval($_POST['port']) ? intval($_POST['port']) : showmessage(L('server_port').L('empty')); $username = isset($_POST['username']) && trim($_POST['username']) ? trim($_POST['username']) : showmessage(L('username').L('empty')); $password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('password').L('empty')); $path = isset($_POST['path']) && trim($_POST['path']) ? trim($_POST['path']) : showmessage(L('path').L('empty')); $pasv = isset($_POST['pasv']) && trim($_POST['pasv']) ? trim($_POST['pasv']) : 0; $ssl = isset($_POST['ssl']) && trim($_POST['ssl']) ? trim($_POST['ssl']) : 0; if ($this->db->get_one(array("name"=>$name))) { showmessage(L('release_point_name').L('exists')); } if ($this->db->insert(array('name'=>$name,'host'=>$host,'port'=>$port,'username'=>$username, 'password'=>$password, 'path'=>$path, 'pasv'=>$pasv, 'ssl'=>$ssl))) { showmessage(L('operation_success'), '', '', 'add'); } else { showmessage(L('operation_failure')); } } $show_header = $show_validator = true; include $this->admin_tpl('release_point_add'); } public function edit() { $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : showmessage(L('illegal_parameters'), HTTP_REFERER); if ($data = $this->db->get_one(array('id'=>$id))) { if (isset($_POST['dosubmit'])) { $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : showmessage(L('release_point_name').L('empty')); $host = isset($_POST['host']) && trim($_POST['host']) ? trim($_POST['host']) : showmessage(L('server_address').L('empty')); $port = isset($_POST['port']) && intval($_POST['port']) ? intval($_POST['port']) : showmessage(L('server_port').L('empty')); $username = isset($_POST['username']) && trim($_POST['username']) ? trim($_POST['username']) : showmessage(L('username').L('empty')); $password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('password').L('empty')); $path = isset($_POST['path']) && trim($_POST['path']) ? trim($_POST['path']) : showmessage(L('path').L('empty')); $pasv = isset($_POST['pasv']) && trim($_POST['pasv']) ? trim($_POST['pasv']) : 0; $ssl = isset($_POST['ssl']) && trim($_POST['ssl']) ? trim($_POST['ssl']) : 0; if ($data['name'] != $name && $this->db->get_one(array("name"=>$name))) { showmessage(L('release_point_name').L('exists')); } if ($this->db->update(array('name'=>$name,'host'=>$host,'port'=>$port,'username'=>$username, 'password'=>$password, 'path'=>$path, 'pasv'=>$pasv, 'ssl'=>$ssl), array('id'=>$id))) { showmessage(L('operation_success'), '', '', 'edit'); } else { showmessage(L('operation_failure')); } } $show_header = $show_validator = true; include $this->admin_tpl('release_point_edit'); } else { showmessage(L('notfound'), HTTP_REFERER); } } public function public_name() { $name = isset($_GET['name']) && trim($_GET['name']) ? (pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['name'])) : trim($_GET['name'])) : exit('0'); $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : ''; $data = array(); if ($id) { $data = $this->db->get_one(array('id'=>$id), 'name'); if (!empty($data) && $data['name'] == $name) { exit('1'); } } if ($this->db->get_one(array('name'=>$name), 'id')) { exit('0'); } else { exit('1'); } } public function del() { $id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : showmessage(L('illegal_parameters'), HTTP_REFERER); if ($this->db->get_one(array('id'=>$id))) { if ($this->db->delete(array('id'=>$id))) { showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } else { showmessage(L('notfound'), HTTP_REFERER); } } public function public_test_ftp() { $host = isset($_GET['host']) && trim($_GET['host']) ? trim($_GET['host']) : exit('0'); $port = isset($_GET['port']) && intval($_GET['port']) ? intval($_GET['port']) : exit('0'); $username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit('0'); $password = isset($_GET['password']) && trim($_GET['password']) ? trim($_GET['password']) : exit('0'); $pasv = isset($_GET['pasv']) && trim($_GET['pasv']) ? trim($_GET['pasv']) : 0; $ssl = isset($_GET['ssl']) && trim($_GET['ssl']) ? trim($_GET['ssl']) : 0; $ftp = pc_base::load_sys_class('ftps'); if ($ftp->connect($host, $username, $password, $port, $pasv, $ssl, 25)) { if ($ftp->link_time > 15) { exit(L('ftp_connection_a_long_time')); } exit('1'); } else { exit(L('can_ftp_server_connections')); } } }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class menu extends admin { function __construct() { parent::__construct(); $this->db = pc_base::load_model('menu_model'); } function init () { $tree = pc_base::load_sys_class('tree'); $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ '); $tree->nbsp = '&nbsp;&nbsp;&nbsp;'; $userid = $_SESSION['userid']; $admin_username = param::get_cookie('admin_username'); $table_name = $this->db->table_name; $result = $this->db->select('','*','','listorder ASC,id DESC'); $array = array(); foreach($result as $r) { $r['cname'] = L($r['name']); $r['str_manage'] = '<a href="?m=admin&c=menu&a=add&parentid='.$r['id'].'&menuid='.$_GET['menuid'].'">'.L('add_submenu').'</a> | <a href="?m=admin&c=menu&a=edit&id='.$r['id'].'&menuid='.$_GET['menuid'].'">'.L('modify').'</a> | <a href="javascript:confirmurl(\'?m=admin&c=menu&a=delete&id='.$r['id'].'&menuid='.$_GET['menuid'].'\',\''.L('confirm',array('message'=>$r['cname'])).'\')">'.L('delete').'</a> '; $array[] = $r; } $str = "<tr> <td align='center'><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input-text-c'></td> <td align='center'>\$id</td> <td >\$spacer\$cname</td> <td align='center'>\$str_manage</td> </tr>"; $tree->init($array); $categorys = $tree->get_tree(0, $str); include $this->admin_tpl('menu'); } function add() { if(isset($_POST['dosubmit'])) { $this->db->insert($_POST['info']); //开发过程中用于自动创建语言包 $file = PC_PATH.'languages'.DIRECTORY_SEPARATOR.'zh-cn'.DIRECTORY_SEPARATOR.'system_menu.lang.php'; if(file_exists($file)) { $content = file_get_contents($file); $content = substr($content,0,-2); $key = $_POST['info']['name']; $data = $content."\$LANG['$key'] = '$_POST[language]';\r\n?>"; file_put_contents($file,$data); } else { $key = $_POST['info']['name']; $data = "<?php\r\n\$LANG['$key'] = '$_POST[language]';\r\n?>"; file_put_contents($file,$data); } //结束 showmessage(L('add_success')); } else { $show_validator = ''; $tree = pc_base::load_sys_class('tree'); $result = $this->db->select(); $array = array(); foreach($result as $r) { $r['cname'] = L($r['name']); $r['selected'] = $r['id'] == $_GET['parentid'] ? 'selected' : ''; $array[] = $r; } $str = "<option value='\$id' \$selected>\$spacer \$cname</option>"; $tree->init($array); $select_categorys = $tree->get_tree(0, $str); include $this->admin_tpl('menu'); } } function delete() { $_GET['id'] = intval($_GET['id']); $this->db->delete(array('id'=>$_GET['id'])); showmessage(L('operation_success')); } function edit() { if(isset($_POST['dosubmit'])) { $id = intval($_POST['id']); //print_r($_POST['info']);exit; $this->db->update($_POST['info'],array('id'=>$id)); //修改语言文件 $file = PC_PATH.'languages'.DIRECTORY_SEPARATOR.'zh-cn'.DIRECTORY_SEPARATOR.'system_menu.lang.php'; require $file; $key = $_POST['info']['name']; if(!isset($LANG[$key])) { $content = file_get_contents($file); $content = substr($content,0,-2); $data = $content."\$LANG['$key'] = '$_POST[language]';\r\n?>"; file_put_contents($file,$data); } elseif(isset($LANG[$key]) && $LANG[$key]!=$_POST['language']) { $content = file_get_contents($file); $content = str_replace($LANG[$key],$_POST['language'],$content); file_put_contents($file,$content); } //结束语言文件修改 showmessage(L('operation_success')); } else { $show_validator = $array = $r = ''; $tree = pc_base::load_sys_class('tree'); $id = intval($_GET['id']); $r = $this->db->get_one(array('id'=>$id)); if($r) extract($r); $result = $this->db->select(); foreach($result as $r) { $r['cname'] = L($r['name']); $r['selected'] = $r['id'] == $parentid ? 'selected' : ''; $array[] = $r; } $str = "<option value='\$id' \$selected>\$spacer \$cname</option>"; $tree->init($array); $select_categorys = $tree->get_tree(0, $str); include $this->admin_tpl('menu'); } } /** * 排序 */ function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $id => $listorder) { $this->db->update(array('listorder'=>$listorder),array('id'=>$id)); } showmessage(L('operation_success')); } else { showmessage(L('operation_failure')); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin', 'admin', 0); class site extends admin { private $db; public function __construct() { $this->db = pc_base::load_model('site_model'); parent::__construct(); } public function init() { $total = $this->db->count(); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $pagesize = 20; $offset = ($page - 1) * $pagesize; $list = $this->db->select('', '*', $offset.','.$pagesize); $pages = pages($total, $page, $pagesize); $show_dialog = true; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=site&a=add\', title:\''.L('add_site').'\', width:\'700\', height:\'500\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_site')); include $this->admin_tpl('site_list'); } public function add() { header("Cache-control: private"); if (isset($_GET['show_header'])) $show_header = 1; if (isset($_POST['dosubmit'])) { $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : showmessage(L('site_name').L('empty')); $dirname = isset($_POST['dirname']) && trim($_POST['dirname']) ? strtolower(trim($_POST['dirname'])) : showmessage(L('site_dirname').L('empty')); $domain = isset($_POST['domain']) && trim($_POST['domain']) ? trim($_POST['domain']) : ''; $site_title = isset($_POST['site_title']) && trim($_POST['site_title']) ? trim($_POST['site_title']) : ''; $keywords = isset($_POST['keywords']) && trim($_POST['keywords']) ? trim($_POST['keywords']) : ''; $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : ''; $release_point = isset($_POST['release_point']) ? $_POST['release_point'] : ''; $template = isset($_POST['template']) && !empty($_POST['template']) ? $_POST['template'] : showmessage(L('please_select_a_style')); $default_style = isset($_POST['default_style']) && !empty($_POST['default_style']) ? $_POST['default_style'] : showmessage(L('please_choose_the_default_style')); if ($this->db->get_one(array('name'=>$name), 'siteid')) { showmessage(L('site_name').L('exists')); } if (!preg_match('/^\\w+$/i', $dirname)) { showmessage(L('site_dirname').L('site_dirname_err_msg')); } if ($this->db->get_one(array('dirname'=>$dirname), 'siteid')) { showmessage(L('site_dirname').L('exists')); } if (!empty($domain) && !preg_match('/http:\/\/(.+)\/$/i', $domain)) { showmessage(L('site_domain').L('site_domain_ex2')); } if (!empty($domain) && $this->db->get_one(array('domain'=>$domain), 'siteid')) { showmessage(L('site_domain').L('exists')); } if (!empty($release_point) && is_array($release_point)) { if (count($release_point) > 4) { showmessage(L('release_point_configuration').L('most_choose_four')); } $s = ''; foreach ($release_point as $key=>$val) { if($val) $s.= $s ? ",$val" : $val; } $release_point = $s; unset($s); } else { $release_point = ''; } if (!empty($template) && is_array($template)) { $template = implode(',', $template); } else { $template = ''; } $_POST['setting']['watermark_img'] = IMG_PATH.'water/'.$_POST['setting']['watermark_img']; $setting = trim(array2string($_POST['setting'])); if ($this->db->insert(array('name'=>$name,'dirname'=>$dirname, 'domain'=>$domain, 'site_title'=>$site_title, 'keywords'=>$keywords, 'description'=>$description, 'release_point'=>$release_point, 'template'=>$template,'setting'=>$setting, 'default_style'=>$default_style))) { $class_site = pc_base::load_app_class('sites'); $class_site->set_cache(); showmessage(L('operation_success'), '?m=admin&c=site&a=init', '', 'add'); } else { showmessage(L('operation_failure')); } } else { $release_point_db = pc_base::load_model('release_point_model'); $release_point_list = $release_point_db->select('', 'id, name'); $show_validator = $show_scroll = $show_header = true; $template_list = template_list(); include $this->admin_tpl('site_add'); } } public function del() { $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); if($siteid==1) showmessage(L('operation_failure'), HTTP_REFERER); if ($this->db->get_one(array('siteid'=>$siteid))) { if ($this->db->delete(array('siteid'=>$siteid))) { $class_site = pc_base::load_app_class('sites'); $class_site->set_cache(); showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } else { showmessage(L('notfound'), HTTP_REFERER); } } public function edit() { $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); if ($data = $this->db->get_one(array('siteid'=>$siteid))) { if (isset($_POST['dosubmit'])) { $name = isset($_POST['name']) && trim($_POST['name']) ? trim($_POST['name']) : showmessage(L('site_name').L('empty')); $dirname = isset($_POST['dirname']) && trim($_POST['dirname']) ? strtolower(trim($_POST['dirname'])) : ($siteid == 1 ? '' :showmessage(L('site_dirname').L('empty'))); $domain = isset($_POST['domain']) && trim($_POST['domain']) ? trim($_POST['domain']) : ''; $site_title = isset($_POST['site_title']) && trim($_POST['site_title']) ? trim($_POST['site_title']) : ''; $keywords = isset($_POST['keywords']) && trim($_POST['keywords']) ? trim($_POST['keywords']) : ''; $description = isset($_POST['description']) && trim($_POST['description']) ? trim($_POST['description']) : ''; $release_point = isset($_POST['release_point']) ? $_POST['release_point'] : ''; $template = isset($_POST['template']) && !empty($_POST['template']) ? $_POST['template'] : showmessage(L('please_select_a_style')); $default_style = isset($_POST['default_style']) && !empty($_POST['default_style']) ? $_POST['default_style'] : showmessage(L('please_choose_the_default_style')); if ($data['name'] != $name && $this->db->get_one(array('name'=>$name), 'siteid')) { showmessage(L('site_name').L('exists')); } if ($siteid != 1) { if (!preg_match('/^\\w+$/i', $dirname)) { showmessage(L('site_dirname').L('site_dirname_err_msg')); } if ($data['dirname'] != $dirname && $this->db->get_one(array('dirname'=>$dirname), 'siteid')) { showmessage(L('site_dirname').L('exists')); } } if (!empty($domain) && !preg_match('/http:\/\/(.+)\/$/i', $domain)) { showmessage(L('site_domain').L('site_domain_ex2')); } if (!empty($domain) && $data['domain'] != $domain && $this->db->get_one(array('domain'=>$domain), 'siteid')) { showmessage(L('site_domain').L('exists')); } if (!empty($release_point) && is_array($release_point)) { if (count($release_point) > 4) { showmessage(L('release_point_configuration').L('most_choose_four')); } $s = ''; foreach ($release_point as $key=>$val) { if($val) $s.= $s ? ",$val" : $val; } $release_point = $s; unset($s); } else { $release_point = ''; } if (!empty($template) && is_array($template)) { $template = implode(',', $template); } else { $template = ''; } $_POST['setting']['watermark_img'] = 'statics/images/water/'.$_POST['setting']['watermark_img']; $setting = trim(array2string($_POST['setting'])); $sql = array('name'=>$name,'dirname'=>$dirname, 'domain'=>$domain, 'site_title'=>$site_title, 'keywords'=>$keywords, 'description'=>$description, 'release_point'=>$release_point, 'template'=>$template, 'setting'=>$setting, 'default_style'=>$default_style); if ($siteid == 1) unset($sql['dirname']); if ($this->db->update($sql, array('siteid'=>$siteid))) { $class_site = pc_base::load_app_class('sites'); $class_site->set_cache(); showmessage(L('operation_success'), '', '', 'edit'); } else { showmessage(L('operation_failure')); } } else { $show_validator = true; $show_header = true; $show_scroll = true; $template_list = template_list(); $setting = string2array($data['setting']); $setting['watermark_img'] = str_replace('statics/images/water/','',$setting['watermark_img']); $release_point_db = pc_base::load_model('release_point_model'); $release_point_list = $release_point_db->select('', 'id, name'); include $this->admin_tpl('site_edit'); } } else { showmessage(L('notfound'), HTTP_REFERER); } } public function public_name() { $name = isset($_GET['name']) && trim($_GET['name']) ? (pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['name'])) : trim($_GET['name'])) : exit('0'); $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : ''; $data = array(); if ($siteid) { $data = $this->db->get_one(array('siteid'=>$siteid), 'name'); if (!empty($data) && $data['name'] == $name) { exit('1'); } } if ($this->db->get_one(array('name'=>$name), 'siteid')) { exit('0'); } else { exit('1'); } } public function public_dirname() { $dirname = isset($_GET['dirname']) && trim($_GET['dirname']) ? (pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['dirname'])) : trim($_GET['dirname'])) : exit('0'); $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : ''; $data = array(); if ($siteid) { $data = $this->db->get_one(array('siteid'=>$siteid), 'dirname'); if (!empty($data) && $data['dirname'] == $dirname) { exit('1'); } } if ($this->db->get_one(array('dirname'=>$dirname), 'siteid')) { exit('0'); } else { exit('1'); } } private function check_gd() { if(!function_exists('imagepng') && !function_exists('imagejpeg') && !function_exists('imagegif')) { $gd = L('gd_unsupport'); } else { $gd = L('gd_support'); } return $gd; } }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form', '', 0); class downservers extends admin { private $db; function __construct() { parent::__construct(); $this->db = pc_base::load_model('downservers_model'); $this->sites = pc_base::load_app_class('sites'); } public function init() { if(isset($_POST['dosubmit'])) { $info['siteurl'] = trim($_POST['info']['siteurl']); $info['sitename'] = trim($_POST['info']['sitename']); $info['siteid'] = intval($_POST['info']['siteid']); if(empty($info['sitename'])) showmessage(L('downserver_not_empty'), HTTP_REFERER); if(empty($info['siteurl']) || !preg_match('/(\w+):\/\/(.+)[^\/]$/i', $info['siteurl'])) showmessage(L('downserver_error'), HTTP_REFERER); $insert_id = $this->db->insert($info,true); if($insert_id){ $this->_set_cache(); showmessage(L('operation_success'), HTTP_REFERER); } } else { $infos = $sitelist = array(); $current_siteid = get_siteid(); $where = "`siteid`='$current_siteid' or `siteid`=''"; $sitelists = $this->sites->get_list(); if($_SESSION['roleid'] == '1') { foreach($sitelists as $key=>$v) $sitelist[$key] = $v['name']; $default = L('all_site'); } else { $sitelist[$current_siteid] = $sitelists[$current_siteid]['name']; $default = ''; } $page = $_GET['page'] ? $_GET['page'] : '1'; $infos = $this->db->listinfo($where, 'listorder DESC,id DESC', $page, $pagesize = 20); $pages = $this->db->pages; include $this->admin_tpl('downservers_list'); } } public function edit() { if(isset($_POST['dosubmit'])) { $info['siteurl'] = trim($_POST['info']['siteurl']); $info['sitename'] = trim($_POST['info']['sitename']); $info['siteid'] = intval($_POST['info']['siteid']); if(empty($info['sitename'])) showmessage(L('downserver_not_empty'), HTTP_REFERER); if(empty($info['siteurl']) || !preg_match('/(\w+):\/\/(.+)[^\/]$/i', $info['siteurl'])) showmessage(L('downserver_error'), HTTP_REFERER); $id = intval(trim($_POST['id'])); $this->_set_cache(); $this->db->update($info,array('id'=>$id)); showmessage(L('operation_success'), '', '', 'edit'); } else { $info = $sitelist = array(); $default = ''; $sitelists = $this->sites->get_list(); if($_SESSION['roleid'] == '1') { foreach($sitelists as $key=>$v) $sitelist[$key] = $v['name']; $default = L('all_site'); } else { $current_siteid = self::get_siteid(); $sitelist[$current_siteid] = $sitelists[$current_siteid]['name']; $default = ''; } $info = $this->db->get_one(array('id'=>$_GET['id'])); extract($info); $show_validator = true; $show_header = true; include $this->admin_tpl('downservers_edit'); } } public function delete() { $id = intval($_GET['id']); $this->db->delete(array('id'=>$id)); $this->_set_cache(); showmessage(L('downserver_del_success'), HTTP_REFERER); } /** * 排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $id => $listorder) { $this->db->update(array('listorder'=>$listorder),array('id'=>$id)); } showmessage(L('operation_success'), HTTP_REFERER); } else { showmessage(L('operation_failure'), HTTP_REFERER); } } private function _set_cache() { $infos = $this->db->select(); foreach ($infos as $info){ $servers[$info['id']] = $info; } setcache('downservers', $servers,'commons'); return $infos; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class index extends admin { public function __construct() { parent::__construct(); $this->db = pc_base::load_model('admin_model'); $this->menu_db = pc_base::load_model('menu_model'); $this->panel_db = pc_base::load_model('admin_panel_model'); } public function init () { $userid = $_SESSION['userid']; $admin_username = param::get_cookie('admin_username'); $roles = getcache('role','commons'); $rolename = $roles[$_SESSION['roleid']]; $site = pc_base::load_app_class('sites'); $sitelist = $site->get_list($_SESSION['roleid']); $currentsite = $this->get_siteinfo(param::get_cookie('siteid')); /*管理员收藏栏*/ $adminpanel = $this->panel_db->select(array('userid'=>$userid), "*",20 , 'datetime'); include $this->admin_tpl('index'); } public function login() { if(isset($_GET['dosubmit'])) { //不为口令卡验证 if (!isset($_GET['card'])) { $username = isset($_POST['username']) ? trim($_POST['username']) : showmessage(L('nameerror'),HTTP_REFERER); $code = isset($_POST['code']) && trim($_POST['code']) ? trim($_POST['code']) : showmessage(L('input_code'), HTTP_REFERER); if ($_SESSION['code'] != strtolower($code)) { showmessage(L('code_error'), HTTP_REFERER); } } else { //口令卡验证 if (!isset($_SESSION['card_verif']) || $_SESSION['card_verif'] != 1) { showmessage(L('your_password_card_is_not_validate'), '?m=admin&c=index&a=public_card'); } $username = $_SESSION['card_username'] ? $_SESSION['card_username'] : showmessage(L('nameerror'),HTTP_REFERER); } //密码错误剩余重试次数 $this->times_db = pc_base::load_model('times_model'); $rtime = $this->times_db->get_one(array('username'=>$username,'isadmin'=>1)); $maxloginfailedtimes = getcache('common','commons'); $maxloginfailedtimes = (int)$maxloginfailedtimes['maxloginfailedtimes']; if($rtime['times'] > $maxloginfailedtimes) { $minute = 60-floor((SYS_TIME-$rtime['logintime'])/60); showmessage(L('wait_1_hour',array('minute'=>$minute))); } //查询帐号 $r = $this->db->get_one(array('username'=>$username)); if(!$r) showmessage(L('user_not_exist'),'?m=admin&c=index&a=login'); $password = md5(md5(trim((!isset($_GET['card']) ? $_POST['password'] : $_SESSION['card_password']))).$r['encrypt']); if($r['password'] != $password) { $ip = ip(); if($rtime && $rtime['times'] < $maxloginfailedtimes) { $times = $maxloginfailedtimes-intval($rtime['times']); $this->times_db->update(array('ip'=>$ip,'isadmin'=>1,'times'=>'+=1'),array('username'=>$username)); } else { $this->times_db->delete(array('username'=>$username,'isadmin'=>1)); $this->times_db->insert(array('username'=>$username,'ip'=>$ip,'isadmin'=>1,'logintime'=>SYS_TIME,'times'=>1)); $times = $maxloginfailedtimes; } showmessage(L('password_error',array('times'=>$times)),'?m=admin&c=index&a=login',3000); } $this->times_db->delete(array('username'=>$username)); //查看是否使用口令卡 if (!isset($_GET['card']) && $r['card'] && pc_base::load_config('system', 'safe_card') == 1) { $_SESSION['card_username'] = $username; $_SESSION['card_password'] = $_POST['password']; header("location:?m=admin&c=index&a=public_card"); exit; } elseif (isset($_GET['card']) && pc_base::load_config('system', 'safe_card') == 1 && $r['card']) {//对口令卡进行验证 isset($_SESSION['card_username']) ? $_SESSION['card_username'] = '' : ''; isset($_SESSION['card_password']) ? $_SESSION['card_password'] = '' : ''; isset($_SESSION['card_password']) ? $_SESSION['card_verif'] = '' : ''; } $this->db->update(array('lastloginip'=>ip(),'lastlogintime'=>SYS_TIME),array('userid'=>$r['userid'])); $_SESSION['userid'] = $r['userid']; $_SESSION['roleid'] = $r['roleid']; $_SESSION['pc_hash'] = random(6,'abcdefghigklmnopqrstuvwxwyABCDEFGHIGKLMNOPQRSTUVWXWY0123456789'); $_SESSION['lock_screen'] = 0; $default_siteid = self::return_siteid(); $cookie_time = SYS_TIME+86400*30; if(!$r['lang']) $r['lang'] = 'zh-cn'; param::set_cookie('admin_username',$username,$cookie_time); param::set_cookie('siteid', $default_siteid,$cookie_time); param::set_cookie('userid', $r['userid'],$cookie_time); param::set_cookie('admin_email', $r['email'],$cookie_time); param::set_cookie('sys_lang', $r['lang'],$cookie_time); showmessage(L('login_success'),'?m=admin&c=index'); } else { pc_base::load_sys_class('form', '', 0); include $this->admin_tpl('login'); } } public function public_card() { $username = $_SESSION['card_username'] ? $_SESSION['card_username'] : showmessage(L('nameerror'),HTTP_REFERER); $r = $this->db->get_one(array('username'=>$username)); if(!$r) showmessage(L('user_not_exist'),'?m=admin&c=index&a=login'); if (isset($_GET['dosubmit'])) { pc_base::load_app_class('card', 'admin', 0); $result = card::verification($r['card'], $_POST['code'], $_POST['rand']); $_SESSION['card_verif'] = 1; header("location:?m=admin&c=index&a=login&dosubmit=1&card=1"); exit; } pc_base::load_app_class('card', 'admin', 0); $rand = card::authe_rand($r['card']); include $this->admin_tpl('login_card'); } public function public_logout() { $_SESSION['userid'] = 0; $_SESSION['roleid'] = 0; param::set_cookie('admin_username',''); param::set_cookie('userid',0); //退出phpsso $phpsso_api_url = pc_base::load_config('system', 'phpsso_api_url'); $phpsso_logout = '<script type="text/javascript" src="'.$phpsso_api_url.'/api.php?op=logout" reload="1"></script>'; showmessage(L('logout_success').$phpsso_logout,'?m=admin&c=index&a=login'); } //左侧菜单 public function public_menu_left() { $menuid = intval($_GET['menuid']); $datas = admin::admin_menu($menuid); if (isset($_GET['parentid']) && $parentid = intval($_GET['parentid']) ? intval($_GET['parentid']) : 10) { foreach($datas as $_value) { if($parentid==$_value['id']) { echo '<li id="_M'.$_value['id'].'" class="on top_menu"><a href="javascript:_M('.$_value['id'].',\'?m='.$_value['m'].'&c='.$_value['c'].'&a='.$_value['a'].'\')" hidefocus="true" style="outline:none;">'.L($_value['name']).'</a></li>'; } else { echo '<li id="_M'.$_value['id'].'" class="top_menu"><a href="javascript:_M('.$_value['id'].',\'?m='.$_value['m'].'&c='.$_value['c'].'&a='.$_value['a'].'\')" hidefocus="true" style="outline:none;">'.L($_value['name']).'</a></li>'; } } } else { include $this->admin_tpl('left'); } } //当前位置 public function public_current_pos() { echo admin::current_pos($_GET['menuid']); exit; } /** * 设置站点ID COOKIE */ public function public_set_siteid() { $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : exit('0'); param::set_cookie('siteid', $siteid); exit('1'); } public function public_ajax_add_panel() { $menuid = isset($_POST['menuid']) ? $_POST['menuid'] : exit('0'); $menuarr = $this->menu_db->get_one(array('id'=>$menuid)); $url = '?m='.$menuarr['m'].'&c='.$menuarr['c'].'&a='.$menuarr['a'].'&'.$menuarr['data']; $data = array('menuid'=>$menuid, 'userid'=>$_SESSION['userid'], 'name'=>$menuarr['name'], 'url'=>$url, 'datetime'=>SYS_TIME); $this->panel_db->insert($data, '', 1); $panelarr = $this->panel_db->listinfo(array('userid'=>$_SESSION['userid']), "datetime"); foreach($panelarr as $v) { echo "<span><a onclick='paneladdclass(this);' target='right' href='".$v['url'].'&menuid='.$v['menuid']."&pc_hash=".$_SESSION['pc_hash']."'>".L($v['name'])."</a> <a class='panel-delete' href='javascript:delete_panel(".$v['menuid'].");'></a></span>"; } exit; } public function public_ajax_delete_panel() { $menuid = isset($_POST['menuid']) ? $_POST['menuid'] : exit('0'); $this->panel_db->delete(array('menuid'=>$menuid, 'userid'=>$_SESSION['userid'])); $panelarr = $this->panel_db->listinfo(array('userid'=>$_SESSION['userid']), "datetime"); foreach($panelarr as $v) { echo "<span><a onclick='paneladdclass(this);' target='right' href='".$v['url']."&pc_hash=".$_SESSION['pc_hash']."'>".L($v['name'])."</a> <a class='panel-delete' href='javascript:delete_panel(".$v['menuid'].");'></a></span>"; } exit; } public function public_main() { pc_base::load_app_func('global'); pc_base::load_app_func('admin'); define('PC_VERSION', pc_base::load_config('version','pc_version')); define('PC_RELEASE', pc_base::load_config('version','pc_release')); $admin_username = param::get_cookie('admin_username'); $roles = getcache('role','commons'); $userid = $_SESSION['userid']; $rolename = $roles[$_SESSION['roleid']]; $r = $this->db->get_one(array('userid'=>$userid)); $logintime = $r['lastlogintime']; $loginip = $r['lastloginip']; $sysinfo = get_sysinfo(); $sysinfo['mysqlv'] = mysql_get_server_info(); $show_header = $show_pc_hash = 1; /*检测框架目录可写性*/ $pc_writeable = is_writable(PC_PATH.'base.php'); $common_cache = getcache('common','commons'); $logsize_warning = errorlog_size() > $common_cache['errorlog_size'] ? '1' : '0'; $adminpanel = $this->panel_db->select(array('userid'=>$userid), '*',20 , 'datetime'); $product_copyright = base64_decode('5LiK5rW355ub5aSn572R57uc5Y+R5bGV5pyJ6ZmQ5YWs5Y+4'); $architecture = base64_decode('546L5Y+C5Yqg'); $programmer = base64_decode('546L5Y+C5Yqg44CB546L6ZOB5oiQ44CB6ZmI5a2m5pe644CB6ZmI6bmP44CB546L5a6Y5bqG44CB5byg5bqG44CB54aK55Sf5Y2O44CB5ZCV5a2Y55m9'); $designer = base64_decode('6JGj6aOe6b6Z44CB5byg5LqM5by6'); ob_start(); include $this->admin_tpl('main'); $data = ob_get_contents(); ob_end_clean(); system_information($data); } /** * 维持 session 登陆状态 */ public function public_session_life() { $userid = $_SESSION['userid']; return true; } /** * 锁屏 */ public function public_lock_screen() { $_SESSION['lock_screen'] = 1; } public function public_login_screenlock() { if(empty($_GET['lock_password'])) showmessage(L('password_can_not_be_empty')); //密码错误剩余重试次数 $this->times_db = pc_base::load_model('times_model'); $username = param::get_cookie('admin_username'); $maxloginfailedtimes = getcache('common','commons'); $maxloginfailedtimes = (int)$maxloginfailedtimes['maxloginfailedtimes']; $rtime = $this->times_db->get_one(array('username'=>$username,'isadmin'=>1)); if($rtime['times'] > $maxloginfailedtimes-1) { $minute = 60-floor((SYS_TIME-$rtime['logintime'])/60); exit('3'); } //查询帐号 $r = $this->db->get_one(array('userid'=>$_SESSION['userid'])); $password = md5(md5($_GET['lock_password']).$r['encrypt']); if($r['password'] != $password) { $ip = ip(); if($rtime && $rtime['times']<$maxloginfailedtimes) { $times = $maxloginfailedtimes-intval($rtime['times']); $this->times_db->update(array('ip'=>$ip,'isadmin'=>1,'times'=>'+=1'),array('username'=>$username)); } else { $this->times_db->insert(array('username'=>$username,'ip'=>$ip,'isadmin'=>1,'logintime'=>SYS_TIME,'times'=>1)); $times = $maxloginfailedtimes; } exit('2|'.$times);//密码错误 } $this->times_db->delete(array('username'=>$username)); $_SESSION['lock_screen'] = 0; exit('1'); } //后台站点地图 public function public_map() { $array = admin::admin_menu(0); $menu = array(); foreach ($array as $k=>$v) { $menu[$v['id']] = $v; $menu[$v['id']]['childmenus'] = admin::admin_menu($v['id']); } $show_header = true; include $this->admin_tpl('map'); } /** * * 读取盛大接扣获取appid和secretkey */ public function public_snda_status() { //引入盛大接口 if(!strstr(pc_base::load_config('snda','snda_status'), '|')) { $this->site_db = pc_base::load_model('site_model'); $uuid_arr = $this->site_db->get_one(array('siteid'=>1), 'uuid'); $uuid = $uuid_arr['uuid']; $snda_check_url = "http://open.sdo.com/phpcms?cmsid=".$uuid."&sitedomain=".$_SERVER['SERVER_NAME']; $snda_res_json = @file_get_contents($snda_check_url); $snda_res = json_decode($snda_res_json, 1); if(!isset($snda_res[err]) && !empty($snda_res['appid'])) { $appid = $snda_res['appid']; $secretkey = $snda_res['secretkey']; set_config(array('snda_status'=>$appid.'|'.$secretkey), 'snda'); } } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); //定义在后台 define('IN_ADMIN',true); class plugin_op { private $db,$db_var; public function __construct(){ $this->db_var = pc_base::load_model('plugin_var_model'); $this->db = pc_base::load_model('plugin_var_model'); } /** * 插件后台模板加载 */ public function plugin_tpl($file,$identification) { return PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.'admin'.DIRECTORY_SEPARATOR.$file.'.tpl.php'; } /** * 获取插件自定义变量信息 * @param $pluginid 插件id */ public function getpluginvar($pluginid){ if(empty($pluginid)) return flase; if($info_var = $this->db_var->select(array('pluginid'=>$pluginid))) { foreach ($info_var as $var) { $pluginvar[$var['fieldname']] = $var['value']; } } return $pluginvar; } /** * 获取插件配置 * @param $pluginid 插件id */ function getplugincfg($pluginid) { $info = $this->db->get_one(array('pluginid'=>$pluginid)); return $info; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); //定义在后台 define('IN_ADMIN',true); class admin_op { public function __construct() { $this->db = pc_base::load_model('admin_model'); } /* * 修改密码 */ public function edit_password($userid, $password){ $userid = intval($userid); if($userid < 1) return false; if(!is_password($password)) { showmessage(L('pwd_incorrect')); return false; } $passwordinfo = password($password); return $this->db->update($passwordinfo,array('userid'=>$userid)); } /* * 检查用户名重名 */ public function checkname($username) { $username = trim($username); if ($this->db->get_one(array('username'=>$username),'userid')){ return false; } return true; } } ?>
PHP
<?php /** * 站点对外接口 * @author chenzhouyu * */ class sites { //数据库连接 private $db; public function __construct() { $this->db = pc_base::load_model('site_model'); } /** * 获取站点列表 * @param string $roleid 角色ID 留空为获取所有站点列表 */ public function get_list($roleid='') { $roleid = intval($roleid); if(empty($roleid)) { if ($data = getcache('sitelist', 'commons')) { return $data; } else { $this->set_cache(); return $this->db->select(); } } else { $site_arr = $this->get_role_siteid($roleid); $sql = "`siteid` in($site_arr)"; return $this->db->select($sql); } } /** * 按ID获取站点信息 * @param integer $siteid 站点ID号 */ public function get_by_id($siteid) { return siteinfo($siteid); } /** * 设置站点缓存 */ public function set_cache() { $list = $this->db->select(); $data = array(); foreach ($list as $key=>$val) { $data[$val['siteid']] = $val; $data[$val['siteid']]['url'] = $val['domain'] ? $val['domain'] : pc_base::load_config('system', 'web_path').$val['dirname'].'/'; } setcache('sitelist', $data, 'commons'); } /** * PC标签中调用站点列表 */ public function pc_tag_list() { $list = $this->db->select('', 'siteid,name'); $sitelist = array(''=>L('please_select_a_site', '', 'admin')); foreach ($list as $k=>$v) { $sitelist[$v['siteid']] = $v['name']; } return $sitelist; } /** * 按角色ID获取站点列表 * @param string $roleid 角色ID */ public function get_role_siteid($roleid) { $roleid = intval($roleid); if($roleid == 1) { $sitelists = $this->get_list(); foreach($sitelists as $v) { $sitelist[] = $v['siteid']; } } else { $sitelist = getcache('role_siteid', 'commons'); $sitelist = $sitelist[$roleid]; } if(is_array($sitelist)) { $siteid = implode(',',array_unique($sitelist)); return $siteid; } else { showmessage(L('no_site_permissions'),'?m=admin&c=index&a=login'); } } }
PHP
<?php /** * * 更新缓存类 * */ defined('IN_PHPCMS') or exit('No permission resources.'); class cache_api { private $db; public function __construct() { $this->db = ''; $this->siteid = get_siteid(); } /** * 更新缓存 * @param string $model 方法名 * @param string $param 参数 */ public function cache($model = '', $param = '') { if (file_exists(PC_PATH.'model'.DIRECTORY_SEPARATOR.$model.'_model.class.php')) { $this->db = pc_base::load_model($model.'_model'); if ($param) { $this->$model($param); } else { $this->$model(); } } else { $this->$model(); } } /** * 更新站点缓存方法 */ public function cache_site() { $site = pc_base::load_app_class('sites', 'admin'); $site->set_cache(); } /** * 更新栏目缓存方法 */ public function category() { $categorys = array(); $models = getcache('model','commons'); foreach ($models as $modelid=>$model) { $datas = $this->db->select(array('modelid'=>$modelid),'catid,type,items',10000); $array = array(); foreach ($datas as $r) { if($r['type']==0) $array[$r['catid']] = $r['items']; } setcache('category_items_'.$modelid, $array,'commons'); } $array = array(); $categorys = $this->db->select('`module`=\'content\'','catid,siteid',20000,'listorder ASC'); foreach ($categorys as $r) { $array[$r['catid']] = $r['siteid']; } setcache('category_content',$array,'commons'); $categorys = $this->categorys = array(); $this->categorys = $this->db->select(array('siteid'=>$this->siteid, 'module'=>'content'),'*',10000,'listorder ASC'); foreach($this->categorys as $r) { unset($r['module']); $setting = string2array($r['setting']); $r['create_to_html_root'] = $setting['create_to_html_root']; $r['ishtml'] = $setting['ishtml']; $r['content_ishtml'] = $setting['content_ishtml']; $r['category_ruleid'] = $setting['category_ruleid']; $r['show_ruleid'] = $setting['show_ruleid']; $r['workflowid'] = $setting['workflowid']; $r['isdomain'] = '0'; if(!preg_match('/^(http|https):\/\//', $r['url'])) { $r['url'] = siteurl($r['siteid']).$r['url']; } elseif ($r['ishtml']) { $r['isdomain'] = '1'; } $categorys[$r['catid']] = $r; } setcache('category_content_'.$this->siteid,$categorys,'commons'); return true; } /** * 更新下载服务器缓存方法 */ public function downservers () { $infos = $this->db->select(); foreach ($infos as $info){ $servers[$info['id']] = $info; } setcache('downservers', $servers,'commons'); return $infos; } /** * 更新敏感词缓存方法 */ public function badword() { $infos = $this->db->select('','badid,badword','','badid ASC'); setcache('badword', $infos, 'commons'); return true; } /** * 更新ip禁止缓存方法 */ public function ipbanned() { $infos = $this->db->select('', '`ip`,`expires`', '', 'ipbannedid desc'); setcache('ipbanned', $infos, 'commons'); return true; } /** * 更新关联链接缓存方法 */ public function keylink() { $infos = $this->db->select('','word,url','','keylinkid ASC'); $datas = $rs = array(); foreach($infos as $r) { $rs[0] = $r['word']; $rs[1] = $r['url']; $datas[] = $rs; } setcache('keylink', $datas, 'commons'); return true; } /** * 更新联动菜单缓存方法 */ public function linkage() { $infos = $this->db->select(array('keyid'=>0)); foreach ($infos as $r) { $linkageid = intval($r['linkageid']); $r = $this->db->get_one(array('linkageid'=>$linkageid),'name,siteid,style'); $info['title'] = $r['name']; $info['style'] = $r['style']; $info['siteid'] = $r['siteid']; $info['data'] = $this->submenulist($linkageid); setcache($linkageid, $info,'linkage'); } return true; } /** * 子菜单列表 * @param intval $keyid 菜单id */ public function submenulist($keyid=0) { $keyid = intval($keyid); $datas = array(); $where = ($keyid > 0) ? array('keyid'=>$keyid) : ''; $result = $this->db->select($where,'*','','listorder ,linkageid'); foreach($result as $r) { $datas[$r['linkageid']] = $r; } return $datas; } /** * 更新推荐位缓存方法 */ public function position () { $infos = $this->db->select('','*',1000,'listorder DESC'); foreach ($infos as $info){ $positions[$info['posid']] = $info; } setcache('position', $positions,'commons'); return $infos; } /** * 更新投票配置 */ public function vote_setting() { $m_db = pc_base::load_model('module_model'); $data = $m_db->select(array('module'=>'vote')); $setting = string2array($data[0]['setting']); setcache('vote', $setting, 'commons'); } /** * 更新友情链接配置 */ public function link_setting() { $m_db = pc_base::load_model('module_model'); $data = $m_db->select(array('module'=>'link')); $setting = string2array($data[0]['setting']); setcache('link', $setting, 'commons'); } /** * 更新管理员角色缓存方法 */ public function admin_role() { $infos = $this->db->select(array('disabled'=>'0'), $data = '`roleid`,`rolename`', '', 'roleid ASC'); foreach ($infos as $info){ $role[$info['roleid']] = $info['rolename']; } $this->cache_siteid($role); setcache('role', $role,'commons'); return $infos; } /** * 更新管理员角色缓存方法 */ public function cache_siteid($role) { $priv_db = pc_base::load_model('admin_role_priv_model'); $sitelist = array(); foreach($role as $n=>$r) { $sitelists = $priv_db->select(array('roleid'=>$n),'siteid', '', 'siteid'); foreach($sitelists as $site) { foreach($site as $v){ $sitelist[$n][] = intval($v); } } } $sitelist = @array_map("array_unique", $sitelist); setcache('role_siteid', $sitelist,'commons'); return $sitelist; } /** * 更新url规则缓存方法 */ public function urlrule() { $datas = $this->db->select('','*','','','','urlruleid'); $basic_data = array(); foreach($datas as $roleid=>$r) { $basic_data[$roleid] = $r['urlrule'];; } setcache('urlrules_detail',$datas,'commons'); setcache('urlrules',$basic_data,'commons'); } /** * 更新模块缓存方法 */ public function module() { $modules = array(); $modules = $this->db->select(array('disabled'=>0), '*', '', '', '', 'module'); setcache('modules', $modules, 'commons'); return true; } /** * 更新模型缓存方法 */ public function sitemodel() { define('MODEL_PATH', PC_PATH.'modules'.DIRECTORY_SEPARATOR.'content'.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR); define('CACHE_MODEL_PATH', PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR); require MODEL_PATH.'fields.inc.php'; //更新内容模型类:表单生成、入库、更新、输出 $classtypes = array('form','input','update','output'); foreach($classtypes as $classtype) { $cache_data = file_get_contents(MODEL_PATH.'content_'.$classtype.'.class.php'); $cache_data = str_replace('}?>','',$cache_data); foreach($fields as $field=>$fieldvalue) { if(file_exists(MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php')) { $cache_data .= file_get_contents(MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php'); } } $cache_data .= "\r\n } \r\n?>"; file_put_contents(CACHE_MODEL_PATH.'content_'.$classtype.'.class.php',$cache_data); chmod(CACHE_MODEL_PATH.'content_'.$classtype.'.class.php',0777); } //更新模型数据缓存 $model_array = array(); $datas = $this->db->select(array('type'=>0)); foreach ($datas as $r) { $model_array[$r['modelid']] = $r; $this->sitemodel_field($r['modelid']); } setcache('model', $model_array, 'commons'); return true; } /** * 更新模型字段缓存方法 */ public function sitemodel_field($modelid) { $field_array = array(); $db = pc_base::load_model('sitemodel_field_model'); $fields = $db->select(array('modelid'=>$modelid,'disabled'=>0),'*',100,'listorder ASC'); foreach($fields as $_value) { $setting = string2array($_value['setting']); $_value = array_merge($_value,$setting); $field_array[$_value['field']] = $_value; } setcache('model_field_'.$modelid,$field_array,'model'); return true; } /** * 更新类别缓存方法 */ public function type($param = '') { $datas = array(); $result_datas = $this->db->select(array('siteid'=>get_siteid(),'module'=>$param),'*',1000,'listorder ASC,typeid ASC'); foreach($result_datas as $_key=>$_value) { $datas[$_value['typeid']] = $_value; } if ($param=='search') { $this->search_type(); } else { setcache('type_'.$param, $datas, 'commons'); } return true; } /** * 更新工作流缓存方法 */ public function workflow() { $datas = array(); $workflow_datas = $this->db->select(array('siteid'=>get_siteid()),'*',1000); foreach($workflow_datas as $_k=>$_v) { $datas[$_v['workflowid']] = $_v; } setcache('workflow_'.get_siteid(),$datas,'commons'); return true; } /** * 更新数据源缓存方法 */ public function dbsource() { $db = pc_base::load_model('dbsource_model'); $list = $db->select(); $data = array(); if ($list) { foreach ($list as $val) { $data[$val['name']] = array('hostname'=>$val['host'].':'.$val['port'], 'database' =>$val['dbname'] , 'db_tablepre'=>$val['dbtablepre'], 'username' =>$val['username'],'password' => $val['password'],'charset'=>$val['charset'],'debug'=>0,'pconnect'=>0,'autoconnect'=>0); } } else { return false; } return setcache('dbsource', $data, 'commons'); } /** * 更新会员组缓存方法 */ public function member_group() { $grouplist = $this->db->listinfo('', '', 1, 100, 'groupid'); setcache('grouplist', $grouplist,'member'); return true; } /** * 更新会员配置缓存方法 */ public function member_setting() { $this->db = pc_base::load_model('module_model'); $member_setting = $this->db->get_one(array('module'=>'member'), 'setting'); $member_setting = string2array($member_setting['setting']); setcache('member_setting', $member_setting, 'member'); return true; } /** * 更新会员模型缓存方法 */ public function membermodel() { define('MEMBER_MODEL_PATH',PC_PATH.'modules'.DIRECTORY_SEPARATOR.'member'.DIRECTORY_SEPARATOR.'fields'.DIRECTORY_SEPARATOR); //模型缓存路径 define('MEMBER_CACHE_MODEL_PATH',PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR); $sitemodel_db = pc_base::load_model('sitemodel_model'); $data = $sitemodel_db->select(array('type'=>2), "*", 1000, 'sort', '', 'modelid'); setcache('member_model', $data, 'commons'); require MEMBER_MODEL_PATH.'fields.inc.php'; //更新内容模型类:表单生成、入库、更新、输出 $classtypes = array('form','input','update','output'); foreach($classtypes as $classtype) { $cache_data = file_get_contents(MEMBER_MODEL_PATH.'member_'.$classtype.'.class.php'); $cache_data = str_replace('}?>','',$cache_data); foreach($fields as $field=>$fieldvalue) { if(file_exists(MEMBER_MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php')) { $cache_data .= file_get_contents(MEMBER_MODEL_PATH.$field.DIRECTORY_SEPARATOR.$classtype.'.inc.php'); } } $cache_data .= "\r\n } \r\n?>"; file_put_contents(MEMBER_CACHE_MODEL_PATH.'member_'.$classtype.'.class.php',$cache_data); chmod(MEMBER_CACHE_MODEL_PATH.'member_'.$classtype.'.class.php',0777); } return true; } /** * 更新会员模型字段缓存方法 */ public function member_model_field() { $member_model = getcache('member_model', 'commons'); $this->db = pc_base::load_model('sitemodel_field_model'); foreach ($member_model as $modelid => $m) { $field_array = array(); $fields = $this->db->select(array('modelid'=>$modelid,'disabled'=>0),'*',100,'listorder ASC'); foreach($fields as $_value) { $setting = string2array($_value['setting']); $_value = array_merge($_value,$setting); $field_array[$_value['field']] = $_value; } setcache('model_field_'.$modelid,$field_array,'model'); } return true; } /** * 更新搜索配置缓存方法 */ public function search_setting() { $this->db = pc_base::load_model('module_model'); $setting = $this->db->get_one(array('module'=>'search'), 'setting'); $setting = string2array($setting['setting']); setcache('search', $setting, 'search'); return true; } /** * 更新搜索类型缓存方法 */ public function search_type() { $sitelist = getcache('sitelist','commons'); foreach ($sitelist as $siteid=>$_v) { $datas = $search_model = array(); $result_datas = $result_datas2 = $this->db->select(array('siteid'=>$siteid,'module'=>'search'),'*',1000,'listorder ASC'); foreach($result_datas as $_key=>$_value) { if(!$_value['modelid']) continue; $datas[$_value['modelid']] = $_value['typeid']; $search_model[$_value['modelid']]['typeid'] = $_value['typeid']; $search_model[$_value['modelid']]['name'] = $_value['name']; $search_model[$_value['modelid']]['sort'] = $_value['listorder']; } setcache('type_model_'.$siteid,$datas,'search'); $datas = array(); foreach($result_datas2 as $_key=>$_value) { if($_value['modelid']) continue; $datas[$_value['typedir']] = $_value['typeid']; $search_model[$_value['typedir']]['typeid'] = $_value['typeid']; $search_model[$_value['typedir']]['name'] = $_value['name']; } setcache('type_module_'.$siteid,$datas,'search'); //搜索header头中使用类型缓存 setcache('search_model_'.$siteid,$search_model,'search'); } return true; } /** * 更新专题缓存方法 */ public function special() { $specials = array(); $result = $this->db->select(array('disabled'=>0), '`id`, `siteid`, `title`, `url`, `thumb`, `banner`, `ishtml`', '', '`listorder` DESC, `id` DESC'); foreach($result as $r) { $specials[$r['id']] = $r; } setcache('special', $specials, 'commons'); return true; } /** * 更新网站配置方法 */ public function setting() { $this->db = pc_base::load_model('module_model'); $result = $this->db->get_one(array('module'=>'admin')); $setting = string2array($result['setting']); setcache('common', $setting,'commons'); return true; } /** * 更新数据源模型缓存方法 */ public function database() { $module = $M = array(); $M = getcache('modules', 'commons'); if (is_array($M)) { foreach ($M as $key => $m) { if (file_exists(PC_PATH.'modules'.DIRECTORY_SEPARATOR.$key.DIRECTORY_SEPARATOR.'classes'.DIRECTORY_SEPARATOR.$key.'_tag.class.php') && !in_array($key, array('message', 'block'))) { $module[$key] = $m['name']; } } } $filepath = CACHE_PATH.'configs/'; $module = "<?php\nreturn ".var_export($module, true).";\n?>"; return $file_size = pc_base::load_config('system','lock_ex') ? file_put_contents($filepath.'modules.php', $module, LOCK_EX) : file_put_contents($filepath.'modules.php', $module); } /** * 根据数据库记录更新缓存 */ public function cache2database() { $cache = pc_base::load_model('cache_model'); if (!isset($_GET['pages']) && empty($_GET['pages'])) { $r = $cache->get_one(array(), 'COUNT(*) AS num'); if ($r['num']) { $total = $r['num']; $pages = ceil($total/20); } else { $pages = 1; } } else { $pages = intval($_GET['pages']); } $currpage = max(intval($_GET['currpage']), 1); $offset = ($currpage-1)*20; $result = $cache->select(array(), '*', $offset.', 20', 'filename ASC'); if (is_array($result) && !empty($result)) { foreach ($result as $re) { if (!file_exists(CACHE_PATH.$re['path'].$re['filename'])) { $filesize = pc_base::load_config('system','lock_ex') ? file_put_contents(CACHE_PATH.$re['path'].$re['filename'], $re['data'], LOCK_EX) : file_put_contents(CACHE_PATH.$re['path'].$re['filename'], $re['data']); } else { continue; } } } $currpage++; if ($currpage>$pages) { return true; } else { echo '<script type="text/javascript">window.parent.addtext("<li>'.L('part_cache_success').($currpage-1).'/'.$pages.'..........</li>");</script>'; showmessage(L('part_cache_success'), '?m=admin&c=cache_all&a=init&page='.$_GET['page'].'&currpage='.$currpage.'&pages='.$pages.'&dosubmit=1',0); } } /** * 更新删除缓存文件方法 */ public function del_file() { $path = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_template'.DIRECTORY_SEPARATOR; $files = glob($path.'*'); pc_base::load_sys_func('dir'); if (is_array($files)) { foreach ($files as $f) { $dir = basename($f); if (!in_array($dir, array('block', 'dbsource'))) { dir_delete($path.$dir); } } } $path = PHPCMS_PATH.'caches'.DIRECTORY_SEPARATOR.'caches_tpl_data'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR; $files = glob($path.'*'); if (is_array($files)) { foreach ($files as $f) { $dir = basename($f); @unlink($path.$dir); } } return true; } /** * 更新来源缓存方法 */ public function copyfrom() { $infos = $this->db->select('','*','','listorder DESC','','id'); setcache('copyfrom', $infos, 'admin'); return true; } }
PHP
<?php /** * position_api.class.php 推荐至推荐位接口类 * * @copyright (C) 2005-2010 PHPCMS * @license http://www.phpcms.cn/license/ * @lastmodify 2010-8-3 */ defined('IN_PHPCMS') or exit('No permission resources.'); class push_api { private $db, $pos_data; //数据调用属性 public function __construct() { $this->db = pc_base::load_model('position_model'); //加载数据模型 } /** * 推荐位推送修改接口 * 适合在文章发布、修改时调用 * @param int $id 推荐文章ID * @param int $modelid 模型ID * @param array $posid 推送到的推荐位ID * @param array $data 推送数据 * @param int $expiration 过期时间设置 * @param int $undel 是否判断推荐位去除情况 * @param string $model 调取的数据模型 * 调用方式 * $push = pc_base::load_app_class('push_api','admin'); * $push->position_update(323, 25, 45, array(20,21), array('title'=>'文章标题','thumb'=>'缩略图路径','inputtime'='时间戳')); */ public function position_update($id, $modelid, $catid, $posid, $data, $expiration, $undel = 0, $model = 'content_model') { $arr = $param = array(); $id = intval($id); if($id == '0') return false; $modelid = intval($modelid); $data['inputtime'] = $data['inputtime'] ? $data['inputtime'] : SYS_TIME; //组装属性参数 $arr['modelid'] = $modelid; $arr['catid'] = $catid; $arr['posid'] = $posid; $arr['dosubmit'] = '1'; //组装数据 $param[0] = $data; $param[0]['id'] = $id; if ($undel==0) $pos_info = $this->position_del($catid, $id, $posid); return $this->position_list($param, $arr, $expiration, $model) ? true : false; } /** * 推荐位删除计算 * Enter description here ... * @param int $catid 栏目ID * @param int $id 文章id * @param array $input_posid 传入推荐位数组 */ private function position_del($catid,$id,$input_posid) { $array = array(); $pos_data = pc_base::load_model('position_data_model'); //查找已存在推荐位 $r = $pos_data->select(array('id'=>$id,'catid'=>$catid),'posid'); if(!$r) return false; foreach ($r as $v) $array[] = $v['posid']; //差集计算,需要删除的推荐 $real_posid = implode(',', array_diff($array,$input_posid)); if (!$real_posid) return false; $sql = "`catid`='$catid' AND `id`='$id' AND `posid` IN ($real_posid)"; return $pos_data->delete($sql) ? true : false; } /** * 判断文章是否被推荐 * @param $id * @param $modelid */ private function content_pos($id, $modelid) { $id = intval($id); $modelid = intval($modelid); if ($id && $modelid) { $db_data = pc_base::load_model('position_data_model'); $this->db_content = pc_base::load_model('content_model'); $MODEL = getcache('model','commons'); $this->db_content->table_name = $this->db_content->db_tablepre.$MODEL[$modelid]['tablename']; $posids = $db_data->get_one(array('id'=>$id,'modelid'=>$modelid)) ? 1 : 0; if ($posids==0) $this->db_content->update(array('posids'=>$posids),array('id'=>$id)); } return true; } /** * 接口处理方法 * @param array $param 属性 请求时,为模型、栏目数组。提交添加为二维信息数据 。例:array(1=>array('title'=>'多发发送方法', ....)) * @param array $arr 参数 表单数据,只在请求添加时传递。 例:array('modelid'=>1, 'catid'=>12); * @param int $expiration 过期时间设置 * @param string $model 调取的数据库型名称 */ public function position_list($param = array(), $arr = array(), $expiration = 0, $model = 'content_model') { if ($arr['dosubmit']) { if (!$model) { $model = 'content_model'; } else { $model = $model; } $db = pc_base::load_model($model); $modelid = intval($arr['modelid']); $catid = intval($arr['catid']); $expiration = intval($expiration)>SYS_TIME ? intval($expiration) : 0; $db->set_model($modelid); $info = $r = array(); $pos_data = pc_base::load_model('position_data_model'); $position_info = getcache('position', 'commons'); $fulltext_array = getcache('model_field_'.$modelid,'model'); if (is_array($arr['posid']) && !empty($arr['posid']) && is_array($param) && !empty($param)) { foreach ($arr['posid'] as $pid) { $ext = $func_char = ''; $r = $this->db->get_one(array('posid'=>$pid), 'extention'); //检查推荐位是否启用了扩展字段 $ext = $r['extention'] ? $r['extention'] : ''; if ($ext) { $ext = str_replace(array('\'', '"', ' '), '', $ext); $func_char = strpos($ext, '('); if ($func_char) { $func_name = $param_k = $param_arr = ''; $func_name = substr($ext, 0, $func_char); $param_k = substr($ext, $func_char+1, strrpos($ext, ')')-($func_char+1)); $param_arr = explode(',', $param_k); } } foreach ($param as $d) { $info['id'] = $info['listorder'] = $d['id']; $info['catid'] = $catid; $info['posid'] = $pid; $info['module'] = $model == 'yp_content_model' ? 'yp' : 'content'; $info['modelid'] = $modelid; $fields_arr = $fields_value = ''; foreach($fulltext_array AS $key=>$value){ $fields_arr[] = '{'.$key.'}'; $fields_value[] = $d[$key]; if($value['isposition']) { if ($d[$key]) $info['data'][$key] = $d[$key]; } } if ($ext) { if ($func_name) { foreach ($param_arr as $k => $v) { $c_func_name = $c_param = $c_param_arr = $c_func_char = ''; $c_func_char = strpos($v, '('); if ($c_func_char) { $c_func_name = substr($v, 0, $c_func_char); $c_param = substr($v, $c_func_char+1, strrpos($v, ')')-($c_func_char+1)); $c_param_arr = explode(',', $c_param); $param_arr[$k] = call_user_func_array($c_func_name, $c_param_arr); } else { $param_arr[$k] = str_replace($fields_arr, $fields_value, $v); } } $info['extention'] = call_user_func_array($func_name, $param_arr); } else { $info['extention'] = $d[$ext]; } } //颜色选择为隐藏域 在这里进行取值 $info['data']['style'] = $d['style']; $info['thumb'] = $info['data']['thumb'] ? 1 : 0; $info['siteid'] = get_siteid(); $info['data'] = array2string($info['data']); $info['expiration'] = $expiration; if ($r = $pos_data->get_one(array('id'=>$d['id'], 'posid'=>$pid, 'catid'=>$info['catid']))) { if($r['synedit'] == '0') $pos_data->update($info, array('id'=>$d['id'], 'posid'=>$pid, 'catid'=>$info['catid'])); } else { $pos_data->insert($info); } $db->update(array('posids'=>1), array('id'=>$d['id'])); unset($info); } $maxnum = $position_info[$pid]['maxnum']+4; $r = $pos_data->select(array('catid'=>$catid, 'posid'=>$pid), 'id, listorder', $maxnum.',1', 'listorder DESC, id DESC'); if ($r && $position_info[$pid]['maxnum']) { $listorder = $r[0]['listorder']; $where = '`catid`='.$catid.' AND `posid`='.$pid.' AND `listorder`<'.$listorder; $result = $pos_data->select($where, 'id, modelid'); foreach ($result as $r) { $pos_data->delete(array('id'=>$r['id'], 'posid'=>$pid, 'catid'=>$catid)); $this->content_pos($r['id'], $r['modelid']); } } } } return true; } else { $infos = $info = array(); $where = '1'; $siteid = get_siteid(); $category = getcache('category_content_'.$siteid,'commons'); $positions = getcache('position', 'commons'); if(!empty($positions)) { foreach ($positions as $pid => $p) { if ($p['catid']) $catids = array_keys((array)subcat($p['catid'], 0, 1)); if (($p['siteid']==0 || $p['siteid']==$siteid) && ($p['modelid']==0 || $p['modelid']==$param['modelid']) && ($p['catid']==0 || in_array($param['catid'], $catids))) { $info[$pid] = $p['name']; } } return array( 'posid' => array('name'=>L('position'), 'htmltype'=>'checkbox', 'defaultvalue'=>'', 'data'=>$info, 'validator'=>array('min'=>1)), ); } } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); //定义在后台 define('IN_ADMIN',true); class role_op { public function __construct() { $this->db = pc_base::load_model('admin_role_model'); $this->priv_db = pc_base::load_model('admin_role_priv_model'); } /** * 获取角色中文名称 * @param int $roleid 角色ID */ public function get_rolename($roleid) { $roleid = intval($roleid); $search_field = '`roleid`,`rolename`'; $info = $this->db->get_one(array('roleid'=>$roleid),$search_field); return $info; } /** * 检查角色名称重复 * @param $name 角色组名称 */ public function checkname($name) { $info = $this->db->get_one(array('rolename'=>$name),'roleid'); if($info[roleid]){ return true; } return false; } /** * 获取菜单表信息 * @param int $menuid 菜单ID * @param int $menu_info 菜单数据 */ public function get_menuinfo($menuid,$menu_info) { $menuid = intval($menuid); unset($menu_info[$menuid][id]); return $menu_info[$menuid]; } /** * 检查指定菜单是否有权限 * @param array $data menu表中数组 * @param int $roleid 需要检查的角色ID */ public function is_checked($data,$roleid,$siteid,$priv_data) { $priv_arr = array('m','c','a','data'); if($data['m'] == '') return false; foreach($data as $key=>$value){ if(!in_array($key,$priv_arr)) unset($data[$key]); } $data['roleid'] = $roleid; $data['siteid'] = $siteid; $info = in_array($data, $priv_data); if($info){ return true; } else { return false; } } /** * 是否为设置状态 */ public function is_setting($siteid,$roleid) { $siteid = intval($siteid); $roleid = intval($roleid); $sqls = "`siteid`='$siteid' AND `roleid` = '$roleid' AND `m` != ''"; $result = $this->priv_db->get_one($sqls); return $result ? true : false; } /** * 获取菜单深度 * @param $id * @param $array * @param $i */ public function get_level($id,$array=array(),$i=0) { foreach($array as $n=>$value){ if($value['id'] == $id) { if($value['parentid']== '0') return $i; $i++; return $this->get_level($value['parentid'],$array,$i); } } } } ?>
PHP
<?php /** * position_api.class.php 模块安装接口类 * * @copyright (C) 2005-2010 PHPCMS * @license http://www.phpcms.cn/license/ * @lastmodify 2010-8-31 */ defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_sys_func('dir'); class module_api { private $db, $m_db, $installdir, $uninstaldir, $module, $isall; public $error_msg = ''; public function __construct() { $this->db = pc_base::load_model('module_model'); } /** * 模块安装 * @param string $module 模块名 */ public function install($module = '') { define('INSTALL', true); if ($module) $this->module = $module; $this->installdir = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR; $this->check(); $models = @require($this->installdir.'model.php'); if (!is_array($models) || empty($models)) { $models = array('module'); } if (!in_array('module', $models)) { array_unshift($models, 'module'); } if (is_array($models) && !empty($models)) { foreach ($models as $m) { $this->m_db = pc_base::load_model($m.'_model'); $sql = file_get_contents($this->installdir.$m.'.sql'); $this->sql_execute($sql); } } if (file_exists($this->installdir.'extention.inc.php')) { $menu_db = pc_base::load_model('menu_model'); @include ($this->installdir.'extention.inc.php'); if(!defined('INSTALL_MODULE')) { $file = PC_PATH.'languages'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'lang').DIRECTORY_SEPARATOR.'system_menu.lang.php'; if(file_exists($file)) { $content = file_get_contents($file); $content = substr($content,0,-2); $data = ''; foreach ($language as $key => $l) { if (L($key, '', 'system_menu')==L('no_language').'['.$key.']') { $data .= "\$LANG['".$key."'] = '".$l."';\r\n"; } } $data = $content.$data."?>"; file_put_contents($file,$data); } else { foreach ($language as $key =>$l) { if (L($key, '', 'system_menu')==L('no_language').'['.$key.']') { $data .= "\$LANG['".$key."'] = '".$l."';\r\n"; } } $data = "<?"."php\r\n\$data?>"; file_put_contents($file,$data); } } } if(!defined('INSTALL_MODULE')) { if (file_exists($this->installdir.'languages'.DIRECTORY_SEPARATOR)) { dir_copy($this->installdir.'languages'.DIRECTORY_SEPARATOR, PC_PATH.'languages'.DIRECTORY_SEPARATOR); } if(file_exists($this->installdir.'templates'.DIRECTORY_SEPARATOR)) { dir_copy($this->installdir.'templates'.DIRECTORY_SEPARATOR, PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR); if (file_exists($this->installdir.'templates'.DIRECTORY_SEPARATOR.'name.inc.php')) { $keyid = 'templates|'.pc_base::load_config('system', 'tpl_name').'|'.$this->module; $file_explan[$keyid] = include $this->installdir.'templates'.DIRECTORY_SEPARATOR.'name.inc.php'; $templatepath = PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR; if (file_exists($templatepath.'config.php')) { $style_info = include $templatepath.'config.php'; $style_info['file_explan'] = array_merge($style_info['file_explan'], $file_explan); @file_put_contents($templatepath.'config.php', '<?php return '.var_export($style_info, true).';?>'); } unlink(PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR.'name.inc.php'); } } } return true; } /** * 检查安装目录 * @param string $module 模块名 */ public function check($module = '') { define('INSTALL', true); if ($module) $this->module = $module; if(!$this->module) { $this->error_msg = L('no_module'); return false; } if(!defined('INSTALL_MODULE')) { if (dir_create(PC_PATH.'languages'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'lang').DIRECTORY_SEPARATOR.'test_create_dir')) { sleep(1); dir_delete(PC_PATH.'languages'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'lang').DIRECTORY_SEPARATOR.'test_create_dir'); } else { $this->error_msg = L('lang_dir_no_write'); return false; } } $r = $this->db->get_one(array('module'=>$this->module)); if ($r) { $this->error_msg = L('this_module_installed'); return false; } if (!$this->installdir) { $this->installdir = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR; } if (!is_dir($this->installdir)) { $this->error_msg = L('install_dir_no_exist'); return false; } if (!file_exists($this->installdir.'module.sql')) { $this->error_msg = L('module_sql_no_exist'); return false; } $models = @require($this->installdir.'model.php'); if (is_array($models) && !empty($models)) { foreach ($models as $m) { if (!file_exists(PC_PATH.'model'.DIRECTORY_SEPARATOR.$m.'_model.class.php')) { $this->error_msg = $m.L('model_clas_no_exist'); return false; } if (!file_exists($this->installdir.$m.'.sql')) { $this->error_msg = $m.L('sql_no_exist'); return false; } } } return true; } /** * 模块卸载 * @param string $module 模块名 */ public function uninstall($module) { define('UNINSTALL', true); if (!$module) { $this->error_msg = L('illegal_parameters'); return false; } $this->module = $module; $this->uninstalldir = PC_PATH.'modules'.DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR.'uninstall'.DIRECTORY_SEPARATOR; if (!is_dir($this->uninstalldir)) { $this->error_msg = L('uninstall_dir_no_exist'); return false; } if (file_exists($this->uninstalldir.'model.php')) { $models = @require($this->uninstalldir.'model.php'); if (is_array($models) && !empty($models)) { foreach ($models as $m) { if (!file_exists($this->uninstalldir.$m.'.sql')) { $this->error_msg = $this->module.DIRECTORY_SEPARATOR.'uninstall'.DIRECTORY_SEPARATOR.$m.L('sql_no_exist'); return false; } } } } if (file_exists($this->uninstalldir.'extention.inc.php')) { @include ($this->uninstalldir.'extention.inc.php'); } if (is_array($models) && !empty($models)) { foreach ($models as $m) { $this->m_db = pc_base::load_model($m.'_model'); $sql = file_get_contents($this->uninstalldir.$m.'.sql'); $this->sql_execute($sql); } } if (file_exists(PC_PATH.'languages'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'lang').DIRECTORY_SEPARATOR.$this->module.'.lang.php')) { @unlink(PC_PATH.'languages'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'lang').DIRECTORY_SEPARATOR.$this->module.'.lang.php'); } if (is_dir(PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR.$this->module)) { @dir_delete(PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR.$this->module); } $templatepath = PC_PATH.'templates'.DIRECTORY_SEPARATOR.pc_base::load_config('system', 'tpl_name').DIRECTORY_SEPARATOR; if (file_exists($templatepath.'config.php')) { $keyid = 'templates|'.pc_base::load_config('system', 'tpl_name').'|'.$this->module; $style_info = include $templatepath.'config.php'; unset($style_info['file_explan'][$keyid]); @file_put_contents($templatepath.'config.php', '<?php return '.var_export($style_info, true).';?>'); } $menu_db = pc_base::load_model('menu_model'); $menu_db->delete(array('m'=>$this->module)); $this->db->delete(array('module'=>$this->module)); return true; } /** * 执行mysql.sql文件,创建数据表等 * @param string $sql sql语句 */ private function sql_execute($sql) { $sqls = $this->sql_split($sql); if (is_array($sqls)) { foreach ($sqls as $sql) { if (trim($sql) != '') { $this->m_db->query($sql); } } } else { $this->m_db->query($sqls); } return true; } /** * 处理sql语句,执行替换前缀都功能。 * @param string $sql 原始的sql,将一些大众的部分替换成私有的 */ private function sql_split($sql) { $dbcharset = $GLOBALS['dbcharset']; if (!$dbcharset) { $dbcharset = pc_base::load_config('database','default'); $dbcharset = $dbcharset['charset']; } if($this->m_db->version() > '4.1' && $dbcharset) { $sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "ENGINE=\\1 DEFAULT CHARSET=".$dbcharset, $sql); } if($this->m_db->db_tablepre != "phpcms_") $sql = str_replace("phpcms_", $this->m_db->db_tablepre, $sql); $sql = str_replace(array("\r", '2010-9-05'), array("\n", date('Y-m-d')), $sql); $ret = array(); $num = 0; $queriesarray = explode(";\n", trim($sql)); unset($sql); foreach ($queriesarray as $query) { $ret[$num] = ''; $queries = explode("\n", trim($query)); $queries = array_filter($queries); foreach ($queries as $query) { $str1 = substr($query, 0, 1); if($str1 != '#' && $str1 != '-') $ret[$num] .= $query; } $num++; } return $ret; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); $session_storage = 'session_'.pc_base::load_config('system','session_storage'); pc_base::load_sys_class($session_storage); if(param::get_cookie('sys_lang')) { define('SYS_STYLE',param::get_cookie('sys_lang')); } else { define('SYS_STYLE','zh-cn'); } //定义在后台 define('IN_ADMIN',true); class admin { public $userid; public $username; public function __construct() { self::check_admin(); self::check_priv(); pc_base::load_app_func('global','admin'); if (!module_exists(ROUTE_M)) showmessage(L('module_not_exists')); self::manage_log(); self::check_ip(); self::lock_screen(); self::check_hash(); } /** * 判断用户是否已经登陆 */ final public function check_admin() { if(ROUTE_M =='admin' && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'public_card'))) { return true; } else { if(!isset($_SESSION['userid']) || !isset($_SESSION['roleid']) || !$_SESSION['userid'] || !$_SESSION['roleid']) showmessage(L('admin_login'),'?m=admin&c=index&a=login'); } } /** * 加载后台模板 * @param string $file 文件名 * @param string $m 模型名 */ final public static function admin_tpl($file, $m = '') { $m = empty($m) ? ROUTE_M : $m; if(empty($m)) return false; return PC_PATH.'modules'.DIRECTORY_SEPARATOR.$m.DIRECTORY_SEPARATOR.'templates'.DIRECTORY_SEPARATOR.$file.'.tpl.php'; } /** * 按父ID查找菜单子项 * @param integer $parentid 父菜单ID * @param integer $with_self 是否包括他自己 */ final public static function admin_menu($parentid, $with_self = 0) { $parentid = intval($parentid); $menudb = pc_base::load_model('menu_model'); $result =$menudb->select(array('parentid'=>$parentid,'display'=>1),'*',1000,'listorder ASC'); if($with_self) { $result2[] = $menudb->get_one(array('id'=>$parentid)); $result = array_merge($result2,$result); } //权限检查 if($_SESSION['roleid'] == 1) return $result; $array = array(); $privdb = pc_base::load_model('admin_role_priv_model'); $siteid = param::get_cookie('siteid'); foreach($result as $v) { $action = $v['a']; if(preg_match('/^public_/',$action)) { $array[] = $v; } else { if(preg_match('/^ajax_([a-z]+)_/',$action,$_match)) $action = $_match[1]; $r = $privdb->get_one(array('m'=>$v['m'],'c'=>$v['c'],'a'=>$action,'roleid'=>$_SESSION['roleid'],'siteid'=>$siteid)); if($r) $array[] = $v; } } return $array; } /** * 获取菜单 头部菜单导航 * * @param $parentid 菜单id */ final public static function submenu($parentid = '', $big_menu = false) { if(empty($parentid)) { $menudb = pc_base::load_model('menu_model'); $r = $menudb->get_one(array('m'=>ROUTE_M,'c'=>ROUTE_C,'a'=>ROUTE_A)); $parentid = $_GET['menuid'] = $r['id']; } $array = self::admin_menu($parentid,1); $numbers = count($array); if($numbers==1 && !$big_menu) return ''; $string = ''; $pc_hash = $_SESSION['pc_hash']; foreach($array as $_value) { if (!isset($_GET['s'])) { $classname = ROUTE_M == $_value['m'] && ROUTE_C == $_value['c'] && ROUTE_A == $_value['a'] ? 'class="on"' : ''; } else { $_s = !empty($_value['data']) ? str_replace('=', '', strstr($_value['data'], '=')) : ''; $classname = ROUTE_M == $_value['m'] && ROUTE_C == $_value['c'] && ROUTE_A == $_value['a'] && $_GET['s'] == $_s ? 'class="on"' : ''; } if($_value['parentid'] == 0 || $_value['m']=='') continue; if($classname) { $string .= "<a href='javascript:;' $classname><em>".L($_value['name'])."</em></a><span>|</span>"; } else { $string .= "<a href='?m=".$_value['m']."&c=".$_value['c']."&a=".$_value['a']."&menuid=$parentid&pc_hash=$pc_hash".'&'.$_value['data']."' $classname><em>".L($_value['name'])."</em></a><span>|</span>"; } } $string = substr($string,0,-14); return $string; } /** * 当前位置 * * @param $id 菜单id */ final public static function current_pos($id) { $menudb = pc_base::load_model('menu_model'); $r =$menudb->get_one(array('id'=>$id),'id,name,parentid'); $str = ''; if($r['parentid']) { $str = self::current_pos($r['parentid']); } return $str.L($r['name']).' > '; } /** * 获取当前的站点ID */ final public static function get_siteid() { return get_siteid(); } /** * 获取当前站点信息 * @param integer $siteid 站点ID号,为空时取当前站点的信息 * @return array */ final public static function get_siteinfo($siteid = '') { if ($siteid == '') $siteid = self::get_siteid(); if (empty($siteid)) return false; $sites = pc_base::load_app_class('sites', 'admin'); return $sites->get_by_id($siteid); } final public static function return_siteid() { $sites = pc_base::load_app_class('sites', 'admin'); $siteid = explode(',',$sites->get_role_siteid($_SESSION['roleid'])); return current($siteid); } /** * 权限判断 */ final public function check_priv() { if(ROUTE_M =='admin' && ROUTE_C =='index' && in_array(ROUTE_A, array('login', 'init', 'public_card'))) return true; if($_SESSION['roleid'] == 1) return true; $siteid = param::get_cookie('siteid'); $action = ROUTE_A; $privdb = pc_base::load_model('admin_role_priv_model'); if(preg_match('/^public_/',ROUTE_A)) return true; if(preg_match('/^ajax_([a-z]+)_/',ROUTE_A,$_match)) { $action = $_match[1]; } $r =$privdb->get_one(array('m'=>ROUTE_M,'c'=>ROUTE_C,'a'=>$action,'roleid'=>$_SESSION['roleid'],'siteid'=>$siteid)); if(!$r) showmessage('您没有权限操作该项','blank'); } /** * * 记录日志 */ final private function manage_log() { //判断是否记录 $setconfig = pc_base::load_config('system'); extract($setconfig); if($admin_log==1){ $action = ROUTE_A; if($action == '' || strchr($action,'public') || $action == 'init' || $action=='public_current_pos') { return false; }else { $ip = ip(); $log = pc_base::load_model('log_model'); $username = param::get_cookie('admin_username'); $userid = isset($_SESSION['userid']) ? $_SESSION['userid'] : ''; $time = date('Y-m-d H-i-s',SYS_TIME); $url = '?m='.ROUTE_M.'&c='.ROUTE_C.'&a='.ROUTE_A; $log->insert(array('module'=>ROUTE_M,'username'=>$username,'userid'=>$userid,'action'=>ROUTE_C, 'querystring'=>$url,'time'=>$time,'ip'=>$ip)); } } } /** * * 后台IP禁止判断 ... */ final private function check_ip(){ $this->ipbanned = pc_base::load_model('ipbanned_model'); $this->ipbanned->check_ip(); } /** * 检查锁屏状态 */ final private function lock_screen() { if(isset($_SESSION['lock_screen']) && $_SESSION['lock_screen']==1) { if(preg_match('/^public_/', ROUTE_A) || (ROUTE_M == 'content' && ROUTE_C == 'create_html') || (ROUTE_M == 'release') || (ROUTE_A == 'login') || (ROUTE_M == 'search' && ROUTE_C == 'search_admin' && ROUTE_A=='createindex')) return true; showmessage(L('admin_login'),'?m=admin&c=index&a=login'); } } /** * 检查hash值,验证用户数据安全性 */ final private function check_hash() { if(preg_match('/^public_/', ROUTE_A) || ROUTE_M =='admin' && ROUTE_C =='index' || in_array(ROUTE_A, array('login'))) { return true; } if(isset($_GET['pc_hash']) && $_SESSION['pc_hash'] != '' && ($_SESSION['pc_hash'] == $_GET['pc_hash'])) { return true; } elseif(isset($_POST['pc_hash']) && $_SESSION['pc_hash'] != '' && ($_SESSION['pc_hash'] == $_POST['pc_hash'])) { return true; } else { showmessage(L('hash_check_false'),HTTP_REFERER); } } }
PHP
<?php class card { static $server_url = 'http://safe.phpcms.cn/index.php'; /** * 到远程服务器上去取KEY */ public static function get_key() { return self::_get_data('?op=key'); } /** * 卡片的显示地址 * @param $sn 口令卡编号 */ public static function get_pic($sn) { $key = self::get_key(); return self::$server_url.'?op=card&key='.urlencode($key).'&code='.urlencode(sys_auth("sn=$sn", 'ENCODE', $key)); } /** * 申请新的卡片 * @return 返回卡片的sn */ public static function creat_card() { $key = self::get_key(); return self::_get_data('?op=creat_card&key='.urlencode($key)); } /** * 解除口令卡绑定 * @param string $sn 口令卡编号 */ public static function remove_card($sn) { $key = self::get_key(); return self::_get_data('?op=remove&key='.urlencode($key).'&code='.urlencode(sys_auth("sn=$sn", 'ENCODE', $key))); } /** * 请求口令验证码 * @param string $sn 口令卡编号 */ public static function authe_rand($sn) { $key = self::get_key(); $data = self::_get_data('?op=authe_request&key='.urlencode($key).'&code='.urlencode(sys_auth("sn=$sn", 'ENCODE', $key))); return array('rand'=>$data,'url'=>self::$server_url.'?op=show_rand&key='.urlencode($key).'&code='.urlencode(sys_auth("rand=$data", 'ENCODE', $key))); } /** * 验证动态口令 * @param string $sn 口令卡编号 * @param string $code 用户输入口令 * @param string $rand 随机码 */ public static function verification($sn, $code, $rand) { $key = self::get_key(); return self::_get_data('?op=verification&key='.urlencode($key).'&code='.urlencode(sys_auth("sn=$sn&code=$code&rand=$rand", 'ENCODE', $key)), 'index.php?m=admin&c=index&a=public_card'); } /** * 请求远程数据 * @param string $url 需要请求的地址。 * @param string $backurl 返回地址 */ private static function _get_data($url, $backurl = '') { if ($data = @file_get_contents(self::$server_url.$url)) { $data = json_decode($data, true); //如果系统是GBK的系统,把UTF8转码为GBK if (pc_base::load_config('system', 'charset') == 'gbk') { $data = array_iconv($data, 'utf-8', 'gbk'); } if ($data['status'] != 1) { showmessage($data['msg'], $backurl); } else { return $data['msg']; } } else { showmessage(L('your_server_it_may_not_have_access_to').self::$server_url.L('_please_check_the_server_configuration')); } } }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class role_cat { //数据库连接 static $db; private static function _connect() { self::$db = pc_base::load_model('category_priv_model'); } /** * 获取角色配置权限 * @param integer $roleid 角色ID * @param integer $siteid 站点ID */ public static function get_roleid($roleid, $siteid) { if (empty(self::$db)) { self::_connect(); } if ($data = self::$db->select("`roleid` = '$roleid' AND `is_admin` = '1' AND `siteid` IN ('$siteid') ")) { $priv = array(); foreach ($data as $k=>$v) { $priv[$v['catid']][$v['action']] = true; } return $priv; } else { return false; } } /** * 获取站点栏目列表 * @param integer $siteid 站点ID * @return array() 返回为数组 */ public static function get_category($siteid) { $category = getcache('category_content_'.$siteid, 'commons'); foreach ($category as $k=>$v) { if (!in_array($v['type'], array(0,1))) unset($category[$k]); } return $category; } /** * 更新数据库信息 * @param integer $roleid 角色ID * @param integer $siteid 站点ID * @param array $data 需要更新的数据 */ public static function updata_priv($roleid, $siteid, $data) { if (empty(self::$db)) { self::_connect(); } //删除该角色当前的权限 self::$db->delete(array('roleid'=>$roleid, 'siteid'=>$siteid, 'is_admin'=>1)); foreach ($data as $k=>$v) { if (is_array($v) && !empty($v[0])) { foreach ($v as $key=>$val) { self::$db->insert(array('siteid'=>$siteid, 'catid'=>$k, 'is_admin'=>1, 'roleid'=>$roleid, 'action'=>$val)); } } } } }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); set_time_limit(0); class linkage extends admin { private $db; function __construct() { parent::__construct(); $this->db = pc_base::load_model('linkage_model'); $this->sites = pc_base::load_app_class('sites'); pc_base::load_sys_class('form', '', 0); $this->childnode = array(); } /** * 联动菜单列表 */ public function init() { $where = array('keyid'=>0); $infos = $this->db->select($where); $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=linkage&a=add\', title:\''.L('linkage_add').'\', width:\'500\', height:\'220\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('linkage_add')); include $this->admin_tpl('linkage_list'); } /** * 添加联动菜单 */ function add() { if(isset($_POST['dosubmit'])) { $info = array(); $info['name'] = isset($_POST['info']['name']) && trim($_POST['info']['name']) ? trim($_POST['info']['name']) : showmessage(L('linkage_not_empty')); $info['description'] = trim($_POST['info']['description']); $info['style'] = trim(intval($_POST['info']['style'])); $info['siteid'] = trim(intval($_POST['info']['siteid'])); $this->db->insert($info); $insert_id = $this->db->insert_id(); if($insert_id){ showmessage(L('operation_success'), '', '', 'add'); } } else { $show_header = true; $show_validator = true; $sitelist = $this->sites->get_list(); foreach($sitelist as $siteid=>$v) { $sitelist[$siteid] = $v['name']; } include $this->admin_tpl('linkage_add'); } } /** * 编辑联动菜单 */ public function edit() { if(isset($_POST['dosubmit'])) { $info = array(); $linkageid = intval($_POST['linkageid']); $info['name'] = isset($_POST['info']['name']) && trim($_POST['info']['name']) ? trim($_POST['info']['name']) : showmessage(L('linkage_not_empty')); $info['description'] = trim($_POST['info']['description']); $info['style'] = trim(intval($_POST['info']['style'])); $info['siteid'] = trim(intval($_POST['info']['siteid'])); if($_POST['info']['keyid']) $info['keyid'] = trim($_POST['info']['keyid']); if($_POST['info']['parentid']) $info['parentid'] = trim($_POST['info']['parentid']); $this->db->update($info,array('linkageid'=>$linkageid)); $id = $info['keyid'] ? $info['keyid'] : $linkageid; showmessage(L('operation_success'), '', '', 'edit'); } else { $linkageid = intval($_GET['linkageid']); $info = $this->db->get_one(array('linkageid'=>$linkageid)); extract($info); $sitelist = $this->sites->get_list(); foreach($sitelist as $id=>$v) { $sitelist[$id] = $v['name']; } $show_header = true; $show_validator = true; include $this->admin_tpl('linkage_edit'); } } /** * 删除菜单 */ public function delete() { $linkageid = intval($_GET['linkageid']); $keyid = intval($_GET['keyid']); $this->_get_childnode($linkageid); if(is_array($this->childnode)){ foreach($this->childnode as $linkageid_tmp) { $this->db->delete(array('linkageid' => $linkageid_tmp)); } } $this->db->delete(array('keyid' => $linkageid)); $id = $keyid ? $keyid : $linkageid; if(!$keyid)$this->_dlecache($linkageid); showmessage(L('operation_success')); } public function public_cache() { $linkageid = intval($_GET['linkageid']); $this->_cache($linkageid); showmessage(L('operation_success')); } /** * 菜单排序 */ public function public_listorder() { if(!is_array($_POST['listorders'])) return FALSE; foreach($_POST['listorders'] as $linkageid=>$value) { $value = intval($value); $this->db->update(array('listorder'=>$value),array('linkageid'=>$linkageid)); } $id = intval($_POST['keyid']); showmessage(L('operation_success'),'?m=admin&c=linkage&a=init'); } /** * 管理联动菜单子菜单 */ public function public_manage_submenu() { $keyid = isset($_GET['keyid']) && trim($_GET['keyid']) ? trim($_GET['keyid']) : showmessage(L('linkage_parameter_error')); $tree = pc_base::load_sys_class('tree'); $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ '); $tree->nbsp = '&nbsp;&nbsp;&nbsp;'; $sum = $this->db->count(array('keyid'=>$keyid)); $sql_parentid = $_GET['parentid'] ? trim($_GET['parentid']) : 0; $where = $sum > 40 ? array('keyid'=>$keyid,'parentid'=>$sql_parentid) : array('keyid'=>$keyid); $result = $this->db->select($where,'*','','listorder ,linkageid'); foreach($result as $areaid => $area){ $areas[$area['linkageid']] = array('id'=>$area['linkageid'],'parentid'=>$area['parentid'],'name'=>$area['name'],'listorder'=>$area['listorder'],'style'=>$area['style'],'mod'=>$mod,'file'=>$file,'keyid'=>$keyid,'description'=>$area['description']); $areas[$area['linkageid']]['str_manage'] = ($sum > 40 && $this->_is_last_node($area['keyid'],$area['linkageid'])) ? '<a href="?m=admin&c=linkage&a=public_manage_submenu&keyid='.$area['keyid'].'&parentid='.$area['linkageid'].'">'.L('linkage_manage_submenu').'</a> | ' : ''; $areas[$area['linkageid']]['str_manage'] .= '<a href="javascript:void(0);" onclick="add(\''.$keyid.'\',\''.new_addslashes($area['name']).'\',\''.$area['linkageid'].'\')">'.L('linkage_add_submenu').'</a> | <a href="javascript:void(0);" onclick="edit(\''.$area['linkageid'].'\',\''.$area['name'].'\',\''.$area['parentid'].'\')">'.L('edit').'</a> | <a href="javascript:confirmurl(\'?m=admin&c=linkage&a=delete&linkageid='.$area['linkageid'].'&keyid='.$area['keyid'].'\', \''.L('linkage_is_del').'\')">'.L('delete').'</a> '; } $str = "<tr> <td align='center' width='80'><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input-text-c'></td> <td align='center' width='100'>\$id</td> <td>\$spacer\$name</td> <td >\$description</td> <td align='center'>\$str_manage</td> </tr>"; $tree->init($areas); $submenu = $tree->get_tree($sql_parentid, $str); $big_menu =array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=linkage&a=public_sub_add&keyid='.$keyid.'\', title:\''.L('linkage_add').'\', width:\'500\', height:\'430\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('linkage_add')); include $this->admin_tpl('linkage_submenu'); } /** * 子菜单添加 */ public function public_sub_add() { if(isset($_POST['dosubmit'])) { $info = array(); $info['keyid'] = isset($_POST['keyid']) && trim($_POST['keyid']) ? trim(intval($_POST['keyid'])) : showmessage(L('linkage_parameter_error')); $name = isset($_POST['info']['name']) && trim($_POST['info']['name']) ? trim($_POST['info']['name']) : showmessage(L('linkage_parameter_error')); $info['description'] = trim($_POST['info']['description']); $info['style'] = trim($_POST['info']['style']); $info['parentid'] = trim($_POST['info']['parentid']); $names = explode("\n", trim($name)); foreach($names as $name) { $name = trim($name); if(!$name) continue; $info['name'] = $name; $this->db->insert($info); } if($this->db->insert_id()){ showmessage(L('operation_success'), '', '', 'add'); } } else { $keyid = $_GET['keyid']; $linkageid = $_GET['linkageid']; $list = form::select_linkage($keyid,'0','info[parentid]', 'parentid', L('cat_empty'), $linkageid); $show_validator = true; include $this->admin_tpl('linkage_sub_add'); } } public function ajax_getlist() { $keyid = intval($_GET['keyid']); $datas = getcache($keyid,'linkage'); $infos = $datas['data']; $where_id = isset($_GET['parentid']) ? $_GET['parentid'] : intval($infos[$_GET['linkageid']]['parentid']); $parent_menu_name = ($where_id==0) ? $datas['title'] :$infos[$where_id]['name']; foreach($infos AS $k=>$v) { if($v['parentid'] == $where_id) { $s[]=iconv('gb2312','utf-8',$v['linkageid'].','.$v['name'].','.$v['parentid'].','.$parent_menu_name); } } if(count($s)>0) { $jsonstr = json_encode($s); echo $_GET['callback'].'(',$jsonstr,')'; exit; } else { echo $_GET['callback'].'()';exit; } } /** * 生成联动菜单缓存 * @param init $linkageid */ private function _cache($linkageid) { $linkageid = intval($linkageid); $info = array(); $r = $this->db->get_one(array('linkageid'=>$linkageid),'name,siteid,style,keyid'); $info['title'] = $r['name']; $info['style'] = $r['style']; $info['siteid'] = $r['siteid']; $info['data'] = $this->submenulist($linkageid); setcache($linkageid, $info,'linkage'); return $info; } /** * 删除联动菜单缓存文件 * @param init $linkageid */ private function _dlecache($linkageid) { return delcache($linkageid,'linkage'); } /** * 子菜单列表 * @param unknown_type $keyid */ private function submenulist($keyid=0) { $keyid = intval($keyid); $datas = array(); $where = ($keyid > 0) ? array('keyid'=>$keyid) : ''; $result = $this->db->select($where,'*','','listorder ,linkageid'); if(is_array($result)) { foreach($result as $r) { $arrchildid = $r['arrchildid'] = $this->get_arrchildid($r['linkageid'],$result); $child = $r['child'] = is_numeric($arrchildid) ? 0 : 1; $this->db->update(array('child'=>$child,'arrchildid'=>$arrchildid),array('linkageid'=>$r['linkageid'])); $datas[$r['linkageid']] = $r; } } return $datas; } /** * 获取所属站点 * @param unknown_type $keyid */ private function _get_belong_siteid($keyid) { $keyid = intval($keyid); $info = $this->db->get_one(array('linkageid'=>$keyid)); return $info ? $info['siteid'] : false; } /** * 获取联动菜单子节点 * @param int $linkageid */ private function _get_childnode($linkageid) { $where = array('parentid'=>$linkageid); $this->childnode[] = intval($linkageid); $result = $this->db->select($where); if($result) { foreach($result as $r) { $this->_get_childnode($r['linkageid']); } } } private function _is_last_node($keyid,$linkageid) { $result = $this->db->count(array('keyid'=>$keyid,'parentid'=>$linkageid)); return $result ? true : false; } /** * 返回菜单ID */ public function public_get_list() { $where = array('keyid'=>0); $infos = $this->db->select($where); include $this->admin_tpl('linkage_get_list'); } /** * 获取子菜单ID列表 * @param $linkageid 联动菜单id * @param $linkageinfo */ private function get_arrchildid($linkageid,$linkageinfo) { $arrchildid = $linkageid; if(is_array($linkageinfo)) { foreach($linkageinfo as $linkage) { if($linkage['parentid'] && $linkage['linkageid'] != $linkageid && $linkage['parentid']== $linkageid) { $arrchildid .= ','.$this->get_arrchildid($linkage['linkageid'],$linkageinfo); } } } return $arrchildid; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_app_func('admin'); class admin_manage extends admin { private $db,$role_db; function __construct() { parent::__construct(); $this->db = pc_base::load_model('admin_model'); $this->role_db = pc_base::load_model('admin_role_model'); $this->op = pc_base::load_app_class('admin_op'); } /** * 管理员管理列表 */ public function init() { $userid = $_SESSION['userid']; $admin_username = param::get_cookie('admin_username'); $page = $_GET['page'] ? intval($_GET['page']) : '1'; $infos = $this->db->listinfo('', '', $page, 20); $pages = $this->db->pages; $roles = getcache('role','commons'); include $this->admin_tpl('admin_list'); } /** * 添加管理员 */ public function add() { if(isset($_POST['dosubmit'])) { $info = array(); if(!$this->op->checkname($_POST['info']['username'])){ showmessage(L('admin_already_exists')); } $info = checkuserinfo($_POST['info']); if(!checkpasswd($info['password'])){ showmessage(L('pwd_incorrect')); } $passwordinfo = password($info['password']); $info['password'] = $passwordinfo['password']; $info['encrypt'] = $passwordinfo['encrypt']; $admin_fields = array('username', 'email', 'password', 'encrypt','roleid','realname'); foreach ($info as $k=>$value) { if (!in_array($k, $admin_fields)){ unset($info[$k]); } } $this->db->insert($info); if($this->db->insert_id()){ showmessage(L('operation_success'),'?m=admin&c=admin_manage'); } } else { $roles = $this->role_db->select(array('disabled'=>'0')); include $this->admin_tpl('admin_add'); } } /** * 修改管理员 */ public function edit() { if(isset($_POST['dosubmit'])) { $memberinfo = $info = array(); $info = checkuserinfo($_POST['info']); if(isset($info['password']) && !empty($info['password'])) { $this->op->edit_password($info['userid'], $info['password']); } $userid = $info['userid']; $admin_fields = array('username', 'email', 'roleid','realname'); foreach ($info as $k=>$value) { if (!in_array($k, $admin_fields)){ unset($info[$k]); } } $this->db->update($info,array('userid'=>$userid)); showmessage(L('operation_success'),'','','edit'); } else { $info = $this->db->get_one(array('userid'=>$_GET['userid'])); extract($info); $roles = $this->role_db->select(array('disabled'=>'0')); $show_header = true; include $this->admin_tpl('admin_edit'); } } /** * 删除管理员 */ public function delete() { $userid = intval($_GET['userid']); if($userid == '1') showmessage(L('this_object_not_del'), HTTP_REFERER); $this->db->delete(array('userid'=>$userid)); showmessage(L('admin_cancel_succ')); } /** * 更新管理员状态 */ public function lock(){ $userid = intval($_GET['userid']); $disabled = intval($_GET['disabled']); $this->db->update(array('disabled'=>$disabled),array('userid'=>$userid)); showmessage(L('operation_success'),'?m=admin&c=admin_manage'); } /** * 管理员自助修改密码 */ public function public_edit_pwd() { $userid = $_SESSION['userid']; if(isset($_POST['dosubmit'])) { $r = $this->db->get_one(array('userid'=>$userid),'password,encrypt'); if ( password($_POST['old_password'],$r['encrypt']) !== $r['password'] ) showmessage(L('old_password_wrong'),HTTP_REFERER); if(isset($_POST['new_password']) && !empty($_POST['new_password'])) { $this->op->edit_password($userid, $_POST['new_password']); } showmessage(L('password_edit_succ_logout'),'?m=admin&c=index&a=public_logout'); } else { $info = $this->db->get_one(array('userid'=>$userid)); extract($info); include $this->admin_tpl('admin_edit_pwd'); } } /* * 编辑用户信息 */ public function public_edit_info() { $userid = $_SESSION['userid']; if(isset($_POST['dosubmit'])) { $admin_fields = array('email','realname','lang'); $info = array(); $info = $_POST['info']; if(trim($info['lang'])=='') $info['lang'] = 'zh-cn'; foreach ($info as $k=>$value) { if (!in_array($k, $admin_fields)){ unset($info[$k]); } } $this->db->update($info,array('userid'=>$userid)); param::set_cookie('sys_lang', $info['lang'],SYS_TIME+86400*30); showmessage(L('operation_success'),HTTP_REFERER); } else { $info = $this->db->get_one(array('userid'=>$userid)); extract($info); $lang_dirs = glob(PC_PATH.'languages/*'); $dir_array = array(); foreach($lang_dirs as $dirs) { $dir_array[] = str_replace(PC_PATH.'languages/','',$dirs); } include $this->admin_tpl('admin_edit_info'); } } /** * 异步检测用户名 */ function public_checkname_ajx() { $username = isset($_GET['username']) && trim($_GET['username']) ? trim($_GET['username']) : exit(0); if ($this->db->get_one(array('username'=>$username),'userid')){ exit('0'); } exit('1'); } /** * 异步检测密码 */ function public_password_ajx() { $userid = $_SESSION['userid']; $r = array(); $r = $this->db->get_one(array('userid'=>$userid),'password,encrypt'); if ( password($_GET['old_password'],$r['encrypt']) == $r['password'] ) { exit('1'); } exit('0'); } /** * 异步检测emial合法性 */ function public_email_ajx() { $email = $_GET['email']; if ($this->db->get_one(array('email'=>$email),'userid')){ exit('0'); } exit('1'); } //电子口令卡 function card() { if (pc_base::load_config('system', 'safe_card') != 1) { showmessage(L('your_website_opened_the_card_no_password')); } $userid = isset($_GET['userid']) && intval($_GET['userid']) ? intval($_GET['userid']) : showmessage(L('user_id_cannot_be_empty')); $data = array(); if ($data = $this->db->get_one(array('userid'=>$userid), '`card`,`username`')) { $pic_url = ''; if ($data['card']) { pc_base::load_app_class('card', 'admin', 0); $pic_url = card::get_pic($data['card']); } $show_header = true; include $this->admin_tpl('admin_card'); } else { showmessage(L('users_were_not_found')); } } //绑定电子口令卡 function creat_card() { if (pc_base::load_config('system', 'safe_card') != 1) { showmessage(L('your_website_opened_the_card_no_password')); } $userid = isset($_GET['userid']) && intval($_GET['userid']) ? intval($_GET['userid']) : showmessage(L('user_id_cannot_be_empty')); $data = $card = ''; if ($data = $this->db->get_one(array('userid'=>$userid), '`card`,`username`')) { if (empty($data['card'])) { pc_base::load_app_class('card', 'admin', 0); $card = card::creat_card(); if ($this->db->update(array('card'=>$card), array('userid'=>$userid))) { showmessage(L('password_card_application_success'), '?m=admin&c=admin_manage&a=card&userid='.$userid); } else { showmessage(L('a_card_with_a_local_database_please_contact_the_system_administrators')); } } else { showmessage(L('please_lift_the_password_card_binding'),HTTP_REFERER); } } else { showmessage(L('users_were_not_found')); } } //解除口令卡绑定 function remove_card() { if (pc_base::load_config('system', 'safe_card') != 1) { showmessage(L('your_website_opened_the_card_no_password')); } $userid = isset($_GET['userid']) && intval($_GET['userid']) ? intval($_GET['userid']) : showmessage(L('user_id_cannot_be_empty')); $data = $result = ''; if ($data = $this->db->get_one(array('userid'=>$userid), '`card`,`username`,`userid`')) { pc_base::load_app_class('card', 'admin', 0); if ($result = card::remove_card($data['card'])) { $this->db->update(array('card'=>''), array('userid'=>$userid)); showmessage(L('the_binding_success'), '?m=admin&c=admin_manage&a=card&userid='.$userid); } } else { showmessage(L('users_were_not_found')); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form', '', 0); class googlesitemap extends admin { function __construct() { parent::__construct(); $this->header = "<\x3Fxml version=\"1.0\" encoding=\"UTF-8\"\x3F>\n\t<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"; $this->charset = "UTF-8"; $this->footer = "\t</urlset>\n"; $this->baidunews_footer = "</document>"; $this->items = array(); $this->baidunew_items = array(); //生成栏目级别选项 $this->siteid = $this->get_siteid(); $this->categorys = getcache('category_content_'.$this->siteid,'commons'); } function add_item2($new_item) { $this->items[] = $new_item; } function build( $file_name = null ) { $map = $this->header . "\n"; foreach ($this->items AS $item){ $map .= "\t\t<url>\n\t\t\t<loc>$item[loc]</loc>\n"; $map .= "\t\t\t<lastmod>$item[lastmod]</lastmod>\n"; $map .= "\t\t\t<changefreq>$item[changefreq]</changefreq>\n"; $map .= "\t\t\t<priority>$item[priority]</priority>\n"; $map .= "\t\t</url>\n\n"; } $map .= $this->footer . "\n"; if (!is_null($file_name)){ return file_put_contents($file_name, $map); } else { return $map; } } function google_sitemap_item($loc, $lastmod = '', $changefreq = '', $priority = '') { $data = array(); $data['loc'] = $loc; $data['lastmod'] = $lastmod; $data['changefreq'] = $changefreq; $data['priority'] = $priority; return $data; } /** * * 百度新闻数组 组成 * @param $title * @param $link * @param $description * @param $text * @param $image * @param $keywords * @param $category * @param $author * @param $source * @param $pubDate */ function baidunews_item($title, $link = '', $description = '',$text = '',$image = '', $keywords = '',$category = '',$author = '',$source='',$pubDate='') { $data = array(); $data['title'] = $title; $data['link'] = $link; $data['description'] = $description; $data['text'] = $text; $data['image'] = $image; $data['keywords'] = $keywords; $data['category'] = $category; $data['author'] = $author; $data['source'] = $source; $data['pubDate'] = $pubDate; return $data; } function add_baidunews_item($new_item){ $this->baidunew_items[] = $new_item; } function baidunews_build( $file_name = null ,$this_domain,$email,$time) { //百度头部 $this->baidunews = ''; $this->baidunews = "<?xml version=\"1.0\" encoding=\"".CHARSET."\" ?>\n"; $this->baidunews .= "<document>\n"; $this->baidunews .= "<webSite>".$this_domain."</webSite>\n"; $this->baidunews .= "<webMaster>".$email."</webMaster>\n"; $this->baidunews .= "<updatePeri>".$time."</updatePeri>\n"; foreach ($this->baidunew_items AS $item){ $this->baidunews .= "<item>\n"; $this->baidunews .= "<title>".$item['title']."</title>\n"; $this->baidunews .= "<link>".$item['link']."</link>\n"; $this->baidunews .= "<description>".$item['description'] ."</description>\n"; $this->baidunews .= "<text>".$item['text']."</text>\n"; $this->baidunews .= "<image>".$item['image']."</image>\n"; $this->baidunews .= "<keywords>".$item['keywords']."</keywords>\n"; $this->baidunews .= "<category>".$item['category']."</category>\n"; $this->baidunews .= "<author>".$item['author']."</author>\n"; $this->baidunews .= "<source>".$item['source']."</source>\n"; $this->baidunews .= "<pubDate>".$item['pubDate']."</pubDate>\n"; $this->baidunews .= "</item>\n"; } $this->baidunews .= $this->baidunews_footer . "\n"; if (!is_null($file_name)){ return file_put_contents($file_name, $this->baidunews); } else { return $this->baidunews; } } /** * * Enter 生成google sitemap, 百度新闻协议 */ function set () { $hits_db = pc_base::load_model('hits_model'); $dosubmit = isset($_POST['dosubmit']) ? $_POST['dosubmit'] : $_GET['dosubmit']; //读站点缓存 $siteid = $this->siteid; $sitecache = getcache('sitelist','commons'); //根据当前站点,取得文件存放路径 $systemconfig = pc_base::load_config('system'); $html_root = substr($systemconfig['html_root'], 1); //判断当前站点目录,是PHPCMS则把文件写到根目录下, 不是则写到分站目录下.(分站目录用由静态文件路经html_root和分站目录dirname组成) if($siteid==1){ $dir = PHPCMS_PATH; }else { $dir = PHPCMS_PATH.$html_root.DIRECTORY_SEPARATOR.$sitecache[$siteid]['dirname'].DIRECTORY_SEPARATOR; } //模型缓存 $modelcache = getcache('model','commons'); //获取当前站点域名,下面生成URL时会用到. $this_domain = substr($sitecache[$siteid]['domain'], 0,strlen($sitecache[$siteid]['domain'])-1); if($dosubmit) { //生成百度新闻 if($_POST['mark']) { $baidunum = $_POST['baidunum'] ? intval($_POST['baidunum']) : 20; if($_POST['catids']=="")showmessage(L('choose_category'), HTTP_REFERER); $catids = $_POST['catids']; $catid_cache = $this->categorys;//栏目缓存 $this->content_db = pc_base::load_model('content_model'); foreach ($catids as $catid) { $modelid = $catid_cache[$catid]['modelid'];//根据栏目ID查出modelid 进而确定表名,并结合栏目ID:catid 检索出对应栏目下的新闻条数 $this->content_db->set_model($modelid); $result = $this->content_db->select(array('catid'=>$catid,'status'=>99), '*', $limit = "0,$baidunum", 'id desc'); //重设表前缀,for循环时用来查,文章正文 $this->content_db->table_name = $this->content_db->table_name.'_data'; foreach ($result as $arr){ //把每一条数据都装入数组中 extract($arr); if(!preg_match('/^(http|https):\/\//', $url)){ $url = $this_domain.$url; } if($thumb != ""){ if(!preg_match('/^(http|https):\/\//', $thumb)){ $thumb = $this_domain.$thumb; } } //取当前新闻模型 附属表 取 新闻正文 $url = htmlspecialchars($url); $description = htmlspecialchars(strip_tags($description)); //根据本条ID,从对应tablename_data取出正文内容 $content_arr = $this->content_db->get_one(array('id'=>$id),'content'); $content = htmlspecialchars(strip_tags($content_arr['content'])); //组合数据 $smi = $this->baidunews_item($title,$url,$description,$content,$thumb, $keywords,$category,$author,$source,date('Y-m-d', $inputtime));//推荐文件 $this->add_baidunews_item($smi); } } $baidunews_file = $dir.'baidunews.xml'; @mkdir($dir,0777,true); $this->baidunews_build($baidunews_file,$this_domain,$_POST['email'],$_POST['time']); } //生成网站地图 $content_priority = $_POST['content_priority']; $content_changefreq = $_POST['content_changefreq']; $num = $_POST['num'] ? intval($_POST['num']) : 100; $today = date('Y-m-d'); $domain = $this_domain; //生成地图头部 -第一条 $smi = $this->google_sitemap_item($domain, $today, 'daily', '1.0'); $this->add_item2($smi); $this->content_db = pc_base::load_model('content_model'); //只提取该站点的模型.再循环取数据,生成站点地图. $modelcache = getcache('model','commons'); $new_model = array(); foreach ($modelcache as $modelid => $mod){ if($mod['siteid']==$siteid){ $new_model[$modelid]['modelid'] = $modelid; $new_model[$modelid]['name'] = $mod['name']; } } foreach($new_model as $modelid=>$m) {//每个模块取出num条数据 $this->content_db->set_model($modelid);// 或者 $this->conetnt_db->set_model($modelid); $result = $this->content_db->select(array('status'=>99), '*', $limit = "0,$num", $order = 'inputtime desc'); foreach ($result as $arr){ if(substr($arr['url'],0,1)=='/'){ $url = htmlspecialchars(strip_tags($domain.$arr['url'])); }else { $url = htmlspecialchars(strip_tags($arr['url'])); } $hit_r = $hits_db->get_one(array('hitsid'=>'c-'.$modelid.'-'.$arr['id'])); if($hit_r['views']>1000) $content_priority = 0.9; $smi = $this->google_sitemap_item($url, $today, $content_changefreq, $content_priority);//推荐文件 $this->add_item2($smi); } } $sm_file = $dir.'sitemaps.xml'; if($this->build($sm_file)){ showmessage(L('create_success'), HTTP_REFERER); } } else { $tree = pc_base::load_sys_class('tree'); $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ '); $tree->nbsp = '&nbsp;&nbsp;&nbsp;'; $categorys = array(); foreach($this->categorys as $catid=>$r) { if($this->siteid != $r['siteid'] || $r['type']) continue; if($modelid && $modelid != $r['modelid']) continue; $r['disabled'] = $r['child'] ? 'disabled' : ''; $categorys[$catid] = $r; } $str = "<option value='\$catid' \$selected \$disabled>\$spacer \$catname</option>"; $tree->init($categorys); $string .= $tree->get_tree(0, $str); include $this->admin_tpl('googlesitemap'); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form', '', 0); class position extends admin { private $db, $db_data, $db_content; function __construct() { parent::__construct(); $this->db = pc_base::load_model('position_model'); $this->db_data = pc_base::load_model('position_data_model'); $this->db_content = pc_base::load_model('content_model'); $this->sites = pc_base::load_app_class('sites'); } public function init() { $infos = array(); $where = ''; $current_siteid = self::get_siteid(); $category = getcache('category_content_'.$current_siteid,'commons'); $model = getcache('model','commons'); $where = "`siteid`='$current_siteid' OR `siteid`='0'"; $page = $_GET['page'] ? $_GET['page'] : '1'; $infos = $this->db->listinfo($where, $order = 'listorder DESC,posid DESC', $page, $pagesize = 20); $pages = $this->db->pages; $show_dialog = true; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=position&a=add\', title:\''.L('posid_add').'\', width:\'500\', height:\'360\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('posid_add')); include $this->admin_tpl('position_list'); } /** * 推荐位添加 */ public function add() { if(isset($_POST['dosubmit'])) { if(!is_array($_POST['info']) || empty($_POST['info']['name'])){ showmessage(L('operation_failure')); } $_POST['info']['siteid'] = intval($_POST['info']['modelid']) ? get_siteid() : 0; $_POST['info']['listorder'] = intval($_POST['info']['listorder']); $_POST['info']['maxnum'] = intval($_POST['info']['maxnum']); $insert_id = $this->db->insert($_POST['info'],true); $this->_set_cache(); if($insert_id){ showmessage(L('operation_success'), '', '', 'add'); } } else { pc_base::load_sys_class('form'); $this->sitemodel_db = pc_base::load_model('sitemodel_model'); $sitemodel = $sitemodel = array(); $sitemodel = getcache('model','commons'); foreach($sitemodel as $value){ if($value['siteid'] == get_siteid())$modelinfo[$value['modelid']]=$value['name']; } $show_header = $show_validator = true; include $this->admin_tpl('position_add'); } } /** * 推荐位编辑 */ public function edit() { if(isset($_POST['dosubmit'])) { $_POST['posid'] = intval($_POST['posid']); if(!is_array($_POST['info']) || empty($_POST['info']['name'])){ showmessage(L('operation_failure')); } $_POST['info']['siteid'] = intval($_POST['info']['modelid']) ? get_siteid() : 0; $_POST['info']['listorder'] = intval($_POST['info']['listorder']); $_POST['info']['maxnum'] = intval($_POST['info']['maxnum']); $this->db->update($_POST['info'],array('posid'=>$_POST['posid'])); $this->_set_cache(); showmessage(L('operation_success'), '', '', 'edit'); } else { $info = $this->db->get_one(array('posid'=>$_GET['posid'])); extract($info); pc_base::load_sys_class('form'); $this->sitemodel_db = pc_base::load_model('sitemodel_model'); $sitemodel = $sitemodel = array(); $sitemodel = getcache('model','commons'); foreach($sitemodel as $value){ if($value['siteid'] == get_siteid())$modelinfo[$value['modelid']]=$value['name']; } $show_validator = $show_header = $show_scroll = true; include $this->admin_tpl('position_edit'); } } /** * 推荐位删除 */ public function delete() { $posid = intval($_GET['posid']); $this->db->delete(array('posid'=>$posid)); $this->_set_cache(); showmessage(L('posid_del_success'),'?m=admin&c=position'); } /** * 推荐位排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $posid => $listorder) { $this->db->update(array('listorder'=>$listorder),array('posid'=>$posid)); } $this->_set_cache(); showmessage(L('operation_success'),'?m=admin&c=position'); } else { showmessage(L('operation_failure'),'?m=admin&c=position'); } } /** * 推荐位文章统计 * @param $posid 推荐位ID */ public function content_count($posid) { $posid = intval($posid); $where = array('posid'=>$posid); $infos = $this->db_data->get_one($where, $data = 'count(*) as count'); return $infos['count']; } /** * 推荐位文章列表 */ public function public_item() { if(isset($_POST['dosubmit'])) { $items = count($_POST['items']) > 0 ? $_POST['items'] : showmessage(L('posid_select_to_remove'),HTTP_REFERER); if(is_array($items)) { $sql = array(); foreach ($items as $item) { $_v = explode('-', $item); $sql['id'] = $_v[0]; $sql['modelid']= $_v[1]; $sql['posid'] = intval($_POST['posid']); $this->db_data->delete($sql); $this->content_pos($sql['id'],$sql['modelid']); } } showmessage(L('operation_success'),HTTP_REFERER); } else { $posid = intval($_GET['posid']); $MODEL = getcache('model','commons'); $siteid = $this->get_siteid(); $CATEGORY = getcache('category_content_'.$siteid,'commons'); $page = $_GET['page'] ? $_GET['page'] : '1'; $pos_arr = $this->db_data->listinfo(array('posid'=>$posid,'siteid'=>$siteid),'listorder DESC', $page, $pagesize = 20); $pages = $this->db_data->pages; $infos = array(); foreach ($pos_arr as $_k => $_v) { $r = string2array($_v['data']); $r['catname'] = $CATEGORY[$_v['catid']]['catname']; $r['modelid'] = $_v['modelid']; $r['posid'] = $_v['posid']; $r['id'] = $_v['id']; $r['listorder'] = $_v['listorder']; $r['catid'] = $_v['catid']; $r['url'] = go($_v['catid'], $_v['id']); $key = $r['modelid'].'-'.$r['id']; $infos[$key] = $r; } $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=position&a=add\', title:\''.L('posid_add').'\', width:\'500\', height:\'300\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('posid_add')); include $this->admin_tpl('position_items'); } } /** * 推荐位文章管理 */ public function public_item_manage() { if(isset($_POST['dosubmit'])) { $posid = intval($_POST['posid']); $modelid = intval($_POST['modelid']); $id= intval($_POST['id']); $pos_arr = $this->db_data->get_one(array('id'=>$id,'posid'=>$posid,'modelid'=>$modelid)); $array = string2array($pos_arr['data']); $array['inputtime'] = strtotime($_POST['info']['inputtime']); $array['title'] = trim($_POST['info']['title']); $array['thumb'] = trim($_POST['info']['thumb']); $array['description'] = trim($_POST['info']['description']); $thumb = $_POST['info']['thumb'] ? 1 : 0; $array = array('data'=>array2string($array),'synedit'=>intval($_POST['synedit']),'thumb'=>$thumb); $this->db_data->update($array,array('id'=>$id,'posid'=>$posid,'modelid'=>$modelid)); showmessage(L('operation_success'),'','','edit'); } else { $posid = intval($_GET['posid']); $modelid = intval($_GET['modelid']); $id = intval($_GET['id']); if($posid == 0 || $modelid == 0) showmessage(L('linkage_parameter_error'), HTTP_REFERER); $pos_arr = $this->db_data->get_one(array('id'=>$id,'posid'=>$posid,'modelid'=>$modelid)); extract(string2array($pos_arr['data'])); $synedit = $pos_arr['synedit']; $show_validator = true; $show_header = true; include $this->admin_tpl('position_item_manage'); } } /** * 推荐位文章排序 */ public function public_item_listorder() { if(isset($_POST['posid'])) { foreach($_POST['listorders'] as $_k => $listorder) { $pos = array(); $pos = explode('-', $_k); $this->db_data->update(array('listorder'=>$listorder),array('id'=>$pos[1],'catid'=>$pos[0],'posid'=>$_POST['posid'])); } showmessage(L('operation_success'),HTTP_REFERER); } else { showmessage(L('operation_failure'),HTTP_REFERER); } } /** * 推荐位添加栏目加载 */ public function public_category_load() { $modelid = intval($_GET['modelid']); pc_base::load_sys_class('form'); $category = form::select_category('','','name="info[catid]"',L('please_select_parent_category'),$modelid); echo $category; } private function _set_cache() { $infos = $this->db->select('','*',1000,'listorder DESC'); $positions = array(); foreach ($infos as $info){ $positions[$info['posid']] = $info; } setcache('position', $positions,'commons'); return $infos; } private function content_pos($id,$modelid) { $id = intval($id); $modelid = intval($modelid); $MODEL = getcache('model','commons'); $this->db_content->table_name = $this->db_content->db_tablepre.$MODEL[$modelid]['tablename']; $posids = $this->db_data->get_one(array('id'=>$id,'modelid'=>$modelid)) ? 1 : 0; return $this->db_content->update(array('posids'=>$posids),array('id'=>$id)); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form','',0); class urlrule extends admin { function __construct() { parent::__construct(); $this->db = pc_base::load_model('urlrule_model'); $this->module_db = pc_base::load_model('module_model'); } function init () { $page = intval($_GET['page']); $infos = $this->db->listinfo('','',$page); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=urlrule&a=add\', title:\''.L('add_urlrule').'\', width:\'750\', height:\'300\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_urlrule')); $this->public_cache_urlrule(); include $this->admin_tpl('urlrule_list'); } function add() { if(isset($_POST['dosubmit'])) { $this->db->insert($_POST['info']); $this->public_cache_urlrule(); showmessage(L('add_success'),'','','add'); } else { $show_validator = $show_header = ''; $modules_arr = $this->module_db->select('','module,name'); $modules = array(); foreach ($modules_arr as $r) { $modules[$r['module']] = $r['name']; } include $this->admin_tpl('urlrule_add'); } } function delete() { $_GET['urlruleid'] = intval($_GET['urlruleid']); $this->db->delete(array('urlruleid'=>$_GET['urlruleid'])); $this->public_cache_urlrule(); showmessage(L('operation_success'),HTTP_REFERER); } function edit() { if(isset($_POST['dosubmit'])) { $urlruleid = intval($_POST['urlruleid']); $this->db->update($_POST['info'],array('urlruleid'=>$urlruleid)); $this->public_cache_urlrule(); showmessage(L('update_success'),'','','edit'); } else { $show_validator = $show_header = ''; $urlruleid = $_GET['urlruleid']; $r = $this->db->get_one(array('urlruleid'=>$urlruleid)); extract($r); $modules_arr = $this->module_db->select('','module,name'); $modules = array(); foreach ($modules_arr as $r) { $modules[$r['module']] = $r['name']; } include $this->admin_tpl('urlrule_edit'); } } /** * 更新URL规则 */ public function public_cache_urlrule() { $datas = $this->db->select('','*','','','','urlruleid'); $basic_data = array(); foreach($datas as $roleid=>$r) { $basic_data[$roleid] = $r['urlrule'];; } setcache('urlrules_detail',$datas,'commons'); setcache('urlrules',$basic_data,'commons'); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class phpsso extends admin { function __construct() { parent::__construct(); } function menu() { } function public_menu_left() { $setting = pc_base::load_config('system'); include $this->admin_tpl('phpsso'); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form', '', 0); class role extends admin { private $db, $priv_db; function __construct() { parent::__construct(); $this->db = pc_base::load_model('admin_role_model'); $this->priv_db = pc_base::load_model('admin_role_priv_model'); $this->op = pc_base::load_app_class('role_op'); } /** * 角色管理列表 */ public function init() { $infos = $this->db->select($where = '', $data = '*', $limit = '', $order = 'listorder DESC, roleid DESC', $group = ''); include $this->admin_tpl('role_list'); } /** * 添加角色 */ public function add() { if(isset($_POST['dosubmit'])) { if(!is_array($_POST['info']) || empty($_POST['info']['rolename'])){ showmessage(L('operation_failure')); } if($this->op->checkname($_POST['info']['rolename'])){ showmessage(L('role_duplicate')); } $insert_id = $this->db->insert($_POST['info'],true); $this->_cache(); if($insert_id){ showmessage(L('operation_success'),'?m=admin&c=role&a=init'); } } else { include $this->admin_tpl('role_add'); } } /** * 编辑角色 */ public function edit() { if(isset($_POST['dosubmit'])) { $_POST['roleid'] = intval($_POST['roleid']); if(!is_array($_POST['info']) || empty($_POST['info']['rolename'])){ showmessage(L('operation_failure')); } $this->db->update($_POST['info'],array('roleid'=>$_POST['roleid'])); $this->_cache(); showmessage(L('operation_success'),'?m=admin&c=role'); } else { $info = $this->db->get_one(array('roleid'=>$_GET['roleid'])); extract($info); include $this->admin_tpl('role_edit'); } } /** * 删除角色 */ public function delete() { $roleid = intval($_GET['roleid']); if($roleid == '1') showmessage(L('this_object_not_del'), HTTP_REFERER); $this->db->delete(array('roleid'=>$roleid)); $this->priv_db->delete(array('roleid'=>$roleid)); $this->_cache(); showmessage(L('role_del_success')); } /** * 更新角色排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $roleid => $listorder) { $this->db->update(array('listorder'=>$listorder),array('roleid'=>$roleid)); } showmessage(L('operation_success')); } else { showmessage(L('operation_failure')); } } /** * 角色权限设置 */ public function role_priv() { $this->menu_db = pc_base::load_model('menu_model'); $siteid = $siteid ? $siteid : self::get_siteid(); if(isset($_POST['dosubmit'])){ if (is_array($_POST['menuid']) && count($_POST['menuid']) > 0) { $this->priv_db->delete(array('roleid'=>$_POST['roleid'],'siteid'=>$_POST['siteid'])); $menuinfo = $this->menu_db->select('','`id`,`m`,`c`,`a`,`data`'); foreach ($menuinfo as $_v) $menu_info[$_v[id]] = $_v; foreach($_POST['menuid'] as $menuid){ $info = array(); $info = $this->op->get_menuinfo(intval($menuid),$menu_info); $info['roleid'] = $_POST['roleid']; $info['siteid'] = $_POST['siteid']; $this->priv_db->insert($info); } } else { $this->priv_db->delete(array('roleid'=>$_POST['roleid'],'siteid'=>$_POST['siteid'])); } $this->_cache(); showmessage(L('operation_success'), HTTP_REFERER); } else { $siteid = intval($_GET['siteid']); $roleid = intval($_GET['roleid']); if ($siteid) { $menu = pc_base::load_sys_class('tree'); $menu->icon = array('│ ','├─ ','└─ '); $menu->nbsp = '&nbsp;&nbsp;&nbsp;'; $result = $this->menu_db->select(); $priv_data = $this->priv_db->select(); //获取权限表数据 $modules = 'admin,announce,vote,system'; foreach ($result as $n=>$t) { $result[$n]['cname'] = L($t['name'],'',$modules); $result[$n]['checked'] = ($this->op->is_checked($t,$_GET['roleid'],$siteid, $priv_data))? ' checked' : ''; $result[$n]['level'] = $this->op->get_level($t['id'],$result); $result[$n]['parentid_node'] = ($t['parentid'])? ' class="child-of-node-'.$t['parentid'].'"' : ''; } $str = "<tr id='node-\$id' \$parentid_node> <td style='padding-left:30px;'>\$spacer<input type='checkbox' name='menuid[]' value='\$id' level='\$level' \$checked onclick='javascript:checknode(this);'> \$cname</td> </tr>"; $menu->init($result); $categorys = $menu->get_tree(0, $str); } $show_header = true; $show_scroll = true; include $this->admin_tpl('role_priv'); } } public function priv_setting() { $sites = pc_base::load_app_class('sites', 'admin'); $sites_list = $sites->get_list(); $roleid = intval($_GET['roleid']); include $this->admin_tpl('role_priv_setting'); } /** * 更新角色状态 */ public function change_status(){ $roleid = intval($_GET['roleid']); $disabled = intval($_GET['disabled']); $this->db->update(array('disabled'=>$disabled),array('roleid'=>$roleid)); $this->_cache(); showmessage(L('operation_success'),'?m=admin&c=role'); } /** * 成员管理 */ public function member_manage() { $this->admin_db = pc_base::load_model('admin_model'); $roleid = intval($_GET['roleid']); $roles = getcache('role','commons'); $infos = $this->admin_db->select(array('roleid'=>$roleid)); include $this->admin_tpl('admin_list'); } /** * 设置栏目权限 */ public function setting_cat_priv() { $roleid = isset($_GET['roleid']) && intval($_GET['roleid']) ? intval($_GET['roleid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); $op = isset($_GET['op']) && intval($_GET['op']) ? intval($_GET['op']) : ''; switch ($op) { case 1: $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); pc_base::load_app_class('role_cat', '', 0); $category = role_cat::get_category($siteid); //获取角色当前权限设置 $priv = role_cat::get_roleid($roleid, $siteid); //加载tree $tree = pc_base::load_sys_class('tree'); $categorys = array(); foreach ($category as $k=>$v) { if ($v['type'] == 1) { $v['disabled'] = 'disabled'; $v['init_check'] = ''; $v['add_check'] = ''; $v['delete_check'] = ''; $v['listorder_check'] = ''; $v['push_check'] = ''; $v['move_check'] = ''; } else { $v['disabled'] = ''; $v['add_check'] = isset($priv[$v['catid']]['add']) ? 'checked' : ''; $v['delete_check'] = isset($priv[$v['catid']]['delete']) ? 'checked' : ''; $v['listorder_check'] = isset($priv[$v['catid']]['listorder']) ? 'checked' : ''; $v['push_check'] = isset($priv[$v['catid']]['push']) ? 'checked' : ''; $v['move_check'] = isset($priv[$v['catid']]['remove']) ? 'checked' : ''; $v['edit_check'] = isset($priv[$v['catid']]['edit']) ? 'checked' : ''; } $v['init_check'] = isset($priv[$v['catid']]['init']) ? 'checked' : ''; $category[$k] = $v; } $show_header = true; $str = "<tr> <td align='center'><input type='checkbox' value='1' onclick='select_all(\$catid, this)' ></td> <td>\$spacer\$catname</td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$init_check value='init' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$add_check value='add' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$edit_check value='edit' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$delete_check value='delete' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$listorder_check value='listorder' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$push_check value='push' ></td> <td align='center'><input type='checkbox' name='priv[\$catid][]' \$disabled \$move_check value='remove' ></td> </tr>"; $tree->init($category); $categorys = $tree->get_tree(0, $str); include $this->admin_tpl('role_cat_priv_list'); break; case 2: $siteid = isset($_GET['siteid']) && intval($_GET['siteid']) ? intval($_GET['siteid']) : showmessage(L('illegal_parameters'), HTTP_REFERER); pc_base::load_app_class('role_cat', '', 0); role_cat::updata_priv($roleid, $siteid, $_POST['priv']); showmessage(L('operation_success'),'?m=admin&c=role&a=init', '', 'edit'); break; default: $sites = pc_base::load_app_class('sites', 'admin'); $sites_list = $sites->get_list(); include $this->admin_tpl('role_cat_priv'); break; } } /** * 角色缓存 */ private function _cache() { $infos = $this->db->select(array('disabled'=>'0'), $data = '`roleid`,`rolename`', '', 'roleid ASC'); $role = array(); foreach ($infos as $info){ $role[$info['roleid']] = $info['rolename']; } $this->_cache_siteid($role); setcache('role', $role,'commons'); return $infos; } /** * 缓存站点数据 */ private function _cache_siteid($role) { $sitelist = array(); foreach($role as $n=>$r) { $sitelists = $this->priv_db->select(array('roleid'=>$n),'siteid', '', 'siteid'); foreach($sitelists as $site) { foreach($site as $v){ $sitelist[$n][] = intval($v); } } } if(is_array($sitelist)) { $sitelist = @array_map("array_unique", $sitelist); setcache('role_siteid', $sitelist,'commons'); } return $sitelist; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class category extends admin { private $db; public $siteid; function __construct() { parent::__construct(); $this->db = pc_base::load_model('category_model'); $this->siteid = $this->get_siteid(); } /** * 管理栏目 */ public function init () { $show_pc_hash = ''; $tree = pc_base::load_sys_class('tree'); $models = getcache('model','commons'); $sitelist = getcache('sitelist','commons'); $category_items = array(); foreach ($models as $modelid=>$model) { $category_items[$modelid] = getcache('category_items_'.$modelid,'commons'); } $tree->icon = array('&nbsp;&nbsp;&nbsp;│ ','&nbsp;&nbsp;&nbsp;├─ ','&nbsp;&nbsp;&nbsp;└─ '); $tree->nbsp = '&nbsp;&nbsp;&nbsp;'; $categorys = array(); //读取缓存 $result = getcache('category_content_'.$this->siteid,'commons'); $show_detail = count($result) < 500 ? 1 : 0; $parentid = $_GET['parentid'] ? $_GET['parentid'] : 0; $html_root = pc_base::load_config('system','html_root'); $types = array(0 => L('category_type_system'),1 => L('category_type_page'),2 => L('category_type_link')); if(!empty($result)) { foreach($result as $r) { $r['modelname'] = $models[$r['modelid']]['name']; $r['str_manage'] = ''; if(!$show_detail) { if($r['parentid']!=$parentid) continue; $r['parentid'] = 0; $r['str_manage'] .= '<a href="?m=admin&c=category&a=init&parentid='.$r['catid'].'&menuid='.$_GET['menuid'].'&s='.$r['type'].'&pc_hash='.$_SESSION['pc_hash'].'">'.L('manage_sub_category').'</a> | '; } $r['str_manage'] .= '<a href="?m=admin&c=category&a=add&parentid='.$r['catid'].'&menuid='.$_GET['menuid'].'&s='.$r['type'].'&pc_hash='.$_SESSION['pc_hash'].'">'.L('add_sub_category').'</a> | '; $r['str_manage'] .= '<a href="?m=admin&c=category&a=edit&catid='.$r['catid'].'&menuid='.$_GET['menuid'].'&type='.$r['type'].'&pc_hash='.$_SESSION['pc_hash'].'">'.L('edit').'</a> | <a href="javascript:confirmurl(\'?m=admin&c=category&a=delete&catid='.$r['catid'].'&menuid='.$_GET['menuid'].'\',\''.L('confirm',array('message'=>addslashes($r['catname']))).'\')">'.L('delete').'</a> '; $r['typename'] = $types[$r['type']]; $r['display_icon'] = $r['ismenu'] ? '' : ' <img src ="'.IMG_PATH.'icon/gear_disable.png" title="'.L('not_display_in_menu').'">'; if($r['type'] || $r['child']) { $r['items'] = ''; } else { $r['items'] = $category_items[$r['modelid']][$r['catid']]; } $r['help'] = ''; $setting = string2array($r['setting']); if($r['url']) { if(preg_match('/^(http|https):\/\//', $r['url'])) { $catdir = $r['catdir']; $prefix = $r['sethtml'] ? '' : $html_root; if($this->siteid==1) { $catdir = $prefix.'/'.$r['parentdir'].$catdir; } else { $catdir = $prefix.'/'.$sitelist[$this->siteid]['dirname'].$html_root.'/'.$catdir; } if($r['type']==0 && $setting['ishtml'] && strpos($r['url'], '?')===false && substr_count($r['url'],'/')<4) $r['help'] = '<img src="'.IMG_PATH.'icon/help.png" title="'.L('tips_domain').$r['url'].'&#10;'.L('directory_binding').'&#10;'.$catdir.'/">'; } else { $r['url'] = substr($sitelist[$this->siteid]['domain'],0,-1).$r['url']; } $r['url'] = "<a href='$r[url]' target='_blank'>".L('vistor')."</a>"; } else { $r['url'] = "<a href='?m=admin&c=category&a=public_cache&menuid=43&module=admin'><font color='red'>".L('update_backup')."</font></a>"; } $categorys[$r['catid']] = $r; } } $str = "<tr> <td align='center'><input name='listorders[\$id]' type='text' size='3' value='\$listorder' class='input-text-c'></td> <td align='center'>\$id</td> <td >\$spacer\$catname\$display_icon</td> <td>\$typename</td> <td>\$modelname</td> <td align='center'>\$items</td> <td align='center'>\$url</td> <td align='center'>\$help</td> <td align='center' >\$str_manage</td> </tr>"; $tree->init($categorys); $categorys = $tree->get_tree(0, $str); include $this->admin_tpl('category_manage'); } /** * 添加栏目 */ public function add() { if(isset($_POST['dosubmit'])) { pc_base::load_sys_func('iconv'); $_POST['info']['type'] = intval($_POST['type']); if(isset($_POST['batch_add']) && empty($_POST['batch_add'])) { if($_POST['info']['catname']=='') showmessage(L('input_catname')); if($_POST['info']['type']!=2) { if($_POST['info']['catdir']=='') showmessage(L('input_dirname')); if(!$this->public_check_catdir(0,$_POST['info']['catdir'])) showmessage(L('catname_have_exists')); } } $_POST['info']['siteid'] = $this->siteid; $_POST['info']['module'] = 'content'; $setting = $_POST['setting']; if($_POST['info']['type']!=2) { //栏目生成静态配置 if($setting['ishtml']) { $setting['category_ruleid'] = $_POST['category_html_ruleid']; } else { $setting['category_ruleid'] = $_POST['category_php_ruleid']; $_POST['info']['url'] = ''; } } //内容生成静态配置 if($setting['content_ishtml']) { $setting['show_ruleid'] = $_POST['show_html_ruleid']; } else { $setting['show_ruleid'] = $_POST['show_php_ruleid']; } if($setting['repeatchargedays']<1) $setting['repeatchargedays'] = 1; $_POST['info']['sethtml'] = $setting['create_to_html_root']; $_POST['info']['setting'] = array2string($setting); $end_str = $old_end = '<script type="text/javascript">window.top.art.dialog({id:"test"}).close();window.top.art.dialog({id:"test",content:\'<h2>'.L("add_success").'</h2><span style="fotn-size:16px;">'.L("following_operation").'</span><br /><ul style="fotn-size:14px;"><li><a href="?m=admin&c=category&a=public_cache&menuid=43&module=admin" target="right" onclick="window.top.art.dialog({id:\\\'test\\\'}).close()">'.L("following_operation_1").'</a></li><li><a href="'.HTTP_REFERER.'" target="right" onclick="window.top.art.dialog({id:\\\'test\\\'}).close()">'.L("following_operation_2").'</a></li></ul>\',width:"400",height:"200"});</script>'; if(!isset($_POST['batch_add']) || empty($_POST['batch_add'])) { $catname = CHARSET == 'gbk' ? $_POST['info']['catname'] : iconv('utf-8','gbk',$_POST['info']['catname']); $letters = gbk_to_pinyin($catname); $_POST['info']['letter'] = strtolower(implode('', $letters)); $catid = $this->db->insert($_POST['info'], true); $this->update_priv($catid, $_POST['priv_roleid']); $this->update_priv($catid, $_POST['priv_groupid'],0); } else { $end_str = ''; $batch_adds = explode("\n", $_POST['batch_add']); foreach ($batch_adds as $_v) { if(trim($_v)=='') continue; $names = explode('|', $_v); $catname = $names[0]; $_POST['info']['catname'] = $names[0]; $letters = gbk_to_pinyin($catname); $_POST['info']['letter'] = strtolower(implode('', $letters)); $_POST['info']['catdir'] = trim($names[1]) ? trim($names[1]) : trim($_POST['info']['letter']); if(!$this->public_check_catdir(0,$_POST['info']['catdir'])) { $end_str .= $end_str ? ','.$_POST['info']['catname'].'('.$_POST['info']['catdir'].')' : $_POST['info']['catname'].'('.$_POST['info']['catdir'].')'; continue; } $catid = $this->db->insert($_POST['info'], true); $this->update_priv($catid, $_POST['priv_roleid']); $this->update_priv($catid, $_POST['priv_groupid'],0); } $end_str = $end_str ? L('follow_catname_have_exists').$end_str : $old_end; } $this->cache(); showmessage(L('add_success').$end_str); } else { //获取站点模板信息 pc_base::load_app_func('global'); $template_list = template_list($this->siteid, 0); foreach ($template_list as $k=>$v) { $template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname']; unset($template_list[$k]); } $show_validator = ''; if(isset($_GET['parentid'])) { $parentid = $_GET['parentid']; $r = $this->db->get_one(array('catid'=>$parentid)); if($r) extract($r,EXTR_SKIP); $setting = string2array($setting); } pc_base::load_sys_class('form','',0); $type = $_GET['s']; if($type==0) { $exists_model = false; $models = getcache('model','commons'); foreach($models as $_m) { if($this->siteid == $_m['siteid']) { $exists_model = true; break; } } if(!$exists_model) showmessage(L('please_add_model'),'?m=content&c=sitemodel&a=init&menuid=59',5000); include $this->admin_tpl('category_add'); } elseif ($type==1) { include $this->admin_tpl('category_page_add'); } else { include $this->admin_tpl('category_link'); } } } /** * 修改栏目 */ public function edit() { if(isset($_POST['dosubmit'])) { pc_base::load_sys_func('iconv'); $catid = 0; $catid = intval($_POST['catid']); $setting = $_POST['setting']; //栏目生成静态配置 if($_POST['type'] != 2) { if($setting['ishtml']) { $setting['category_ruleid'] = $_POST['category_html_ruleid']; } else { $setting['category_ruleid'] = $_POST['category_php_ruleid']; $_POST['info']['url'] = ''; } } //内容生成静态配置 if($setting['content_ishtml']) { $setting['show_ruleid'] = $_POST['show_html_ruleid']; } else { $setting['show_ruleid'] = $_POST['show_php_ruleid']; } if($setting['repeatchargedays']<1) $setting['repeatchargedays'] = 1; $_POST['info']['sethtml'] = $setting['create_to_html_root']; $_POST['info']['setting'] = array2string($setting); $_POST['info']['module'] = 'content'; $catname = CHARSET == 'gbk' ? $_POST['info']['catname'] : iconv('utf-8','gbk',$_POST['info']['catname']); $letters = gbk_to_pinyin($catname); $_POST['info']['letter'] = strtolower(implode('', $letters)); //应用权限设置到子栏目 if($_POST['priv_child']) { $arrchildid = $this->db->get_one(array('catid'=>$catid), 'arrchildid'); if(!empty($arrchildid['arrchildid'])) { $arrchildid_arr = explode(',', $arrchildid['arrchildid']); if(!empty($arrchildid_arr)) { foreach ($arrchildid_arr as $arr_v) { $this->update_priv($arr_v, $_POST['priv_groupid'], 0); } } } } $this->db->update($_POST['info'],array('catid'=>$catid,'siteid'=>$this->siteid)); $this->update_priv($catid, $_POST['priv_roleid']); $this->update_priv($catid, $_POST['priv_groupid'],0); $this->cache(); //更新附件状态 if($_POST['info']['image'] && pc_base::load_config('system','attachment_stat')) { $this->attachment_db = pc_base::load_model('attachment_model'); $this->attachment_db->api_update($_POST['info']['image'],'catid-'.$catid,1); } showmessage(L('operation_success').'<script type="text/javascript">window.top.art.dialog({id:"test"}).close();window.top.art.dialog({id:"test",content:\'<h2>'.L("operation_success").'</h2><span style="fotn-size:16px;">'.L("edit_following_operation").'</span><br /><ul style="fotn-size:14px;"><li><a href="?m=admin&c=category&a=public_cache&menuid=43&module=admin" target="right" onclick="window.top.art.dialog({id:\\\'test\\\'}).close()">'.L("following_operation_1").'</a></li></ul>\',width:"400",height:"200"});</script>','?m=admin&c=category&a=init&module=admin&menuid=43'); } else { //获取站点模板信息 pc_base::load_app_func('global'); $template_list = template_list($this->siteid, 0); foreach ($template_list as $k=>$v) { $template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname']; unset($template_list[$k]); } $show_validator = $catid = $r = ''; $catid = intval($_GET['catid']); pc_base::load_sys_class('form','',0); $r = $this->db->get_one(array('catid'=>$catid)); if($r) extract($r); $setting = string2array($setting); $this->priv_db = pc_base::load_model('category_priv_model'); $this->privs = $this->priv_db->select(array('catid'=>$catid)); $type = $_GET['type']; if($type==0) { include $this->admin_tpl('category_edit'); } elseif ($type==1) { include $this->admin_tpl('category_page_edit'); } else { include $this->admin_tpl('category_link'); } } } /** * 排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $id => $listorder) { $this->db->update(array('listorder'=>$listorder),array('catid'=>$id)); } $this->cache(); showmessage(L('operation_success'),HTTP_REFERER); } else { showmessage(L('operation_failure')); } } /** * 删除栏目 */ public function delete() { $catid = intval($_GET['catid']); $categorys = getcache('category_content_'.$this->siteid,'commons'); $modelid = $categorys[$catid]['modelid']; $items = getcache('category_items_'.$modelid,'commons'); if($items[$catid]) showmessage(L('category_does_not_allow_delete')); $this->delete_child($catid); $this->db->delete(array('catid'=>$catid)); $this->cache(); showmessage(L('operation_success'),HTTP_REFERER); } /** * 递归删除栏目 * @param $catid 要删除的栏目id */ private function delete_child($catid) { $catid = intval($catid); if (empty($catid)) return false; $r = $this->db->get_one(array('parentid'=>$catid)); if($r) { $this->delete_child($r['catid']); $this->db->delete(array('catid'=>$r['catid'])); } return true; } /** * 更新缓存 */ public function cache() { $categorys = array(); $models = getcache('model','commons'); foreach ($models as $modelid=>$model) { $datas = $this->db->select(array('modelid'=>$modelid),'catid,type,items',10000); $array = array(); foreach ($datas as $r) { if($r['type']==0) $array[$r['catid']] = $r['items']; } setcache('category_items_'.$modelid, $array,'commons'); } $array = array(); $categorys = $this->db->select('`module`=\'content\'','catid,siteid',20000,'listorder ASC'); foreach ($categorys as $r) { $array[$r['catid']] = $r['siteid']; } setcache('category_content',$array,'commons'); $categorys = $this->categorys = array(); $this->categorys = $this->db->select(array('siteid'=>$this->siteid, 'module'=>'content'),'*',10000,'listorder ASC'); foreach($this->categorys as $r) { unset($r['module']); $setting = string2array($r['setting']); $r['create_to_html_root'] = $setting['create_to_html_root']; $r['ishtml'] = $setting['ishtml']; $r['content_ishtml'] = $setting['content_ishtml']; $r['category_ruleid'] = $setting['category_ruleid']; $r['show_ruleid'] = $setting['show_ruleid']; $r['workflowid'] = $setting['workflowid']; $r['isdomain'] = '0'; if(!preg_match('/^(http|https):\/\//', $r['url'])) { $r['url'] = siteurl($r['siteid']).$r['url']; } elseif ($r['ishtml']) { $r['isdomain'] = '1'; } $categorys[$r['catid']] = $r; } setcache('category_content_'.$this->siteid,$categorys,'commons'); return true; } /** * 更新缓存并修复栏目 */ public function public_cache() { $this->repair(); $this->cache(); showmessage(L('operation_success'),'?m=admin&c=category&a=init&module=admin&menuid=43'); } /** * 修复栏目数据 */ private function repair() { pc_base::load_sys_func('iconv'); @set_time_limit(600); $html_root = pc_base::load_config('system','html_root'); $this->categorys = $categorys = array(); $this->categorys = $categorys = $this->db->select(array('siteid'=>$this->siteid,'module'=>'content'), '*', '', 'listorder ASC, catid ASC', '', 'catid'); $this->get_categorys($categorys); if(is_array($this->categorys)) { foreach($this->categorys as $catid => $cat) { if($cat['type'] == 2) continue; $arrparentid = $this->get_arrparentid($catid); $setting = string2array($cat['setting']); $arrchildid = $this->get_arrchildid($catid); $child = is_numeric($arrchildid) ? 0 : 1; if($categorys[$catid]['arrparentid']!=$arrparentid || $categorys[$catid]['arrchildid']!=$arrchildid || $categorys[$catid]['child']!=$child) $this->db->update(array('arrparentid'=>$arrparentid,'arrchildid'=>$arrchildid,'child'=>$child),array('catid'=>$catid)); $parentdir = $this->get_parentdir($catid); $catname = $cat['catname']; $letters = gbk_to_pinyin($catname); $letter = strtolower(implode('', $letters)); $listorder = $cat['listorder'] ? $cat['listorder'] : $catid; $this->sethtml = $setting['create_to_html_root']; //检查是否生成到根目录 $this->get_sethtml($catid); $sethtml = $this->sethtml ? 1 : 0; if($setting['ishtml']) { //生成静态时 $url = $this->update_url($catid); if(!preg_match('/^(http|https):\/\//i', $url)) { $url = $sethtml ? '/'.$url : $html_root.'/'.$url; } } else { //不生成静态时 $url = $this->update_url($catid); $url = APP_PATH.$url; } if($cat['url']!=$url) $this->db->update(array('url'=>$url), array('catid'=>$catid)); if($categorys[$catid]['parentdir']!=$parentdir || $categorys[$catid]['sethtml']!=$sethtml || $categorys[$catid]['letter']!=$letter || $categorys[$catid]['listorder']!=$listorder) $this->db->update(array('parentdir'=>$parentdir,'sethtml'=>$sethtml,'letter'=>$letter,'listorder'=>$listorder), array('catid'=>$catid)); } } //删除在非正常显示的栏目 foreach($this->categorys as $catid => $cat) { if($cat['parentid'] != 0 && !isset($this->categorys[$cat['parentid']])) { $this->db->delete(array('catid'=>$catid)); } } return true; } /** * 获取父栏目是否生成到根目录 */ private function get_sethtml($catid) { foreach($this->categorys as $id => $cat) { if($catid==$id) { $parentid = $cat['parentid']; if($this->categorys[$parentid]['sethtml']) { $this->sethtml = 1; } if($parentid) { $this->get_sethtml($parentid); } } } } /** * 找出子目录列表 * @param array $categorys */ private function get_categorys($categorys = array()) { if (is_array($categorys) && !empty($categorys)) { foreach ($categorys as $catid => $c) { $this->categorys[$catid] = $c; $result = array(); foreach ($this->categorys as $_k=>$_v) { if($_v['parentid']) $result[] = $_v; } $this->get_categorys($r); } } return true; } /** * 更新栏目链接地址 */ private function update_url($catid) { $catid = intval($catid); if (!$catid) return false; $url = pc_base::load_app_class('url', 'content'); //调用URL实例 return $url->category_url($catid); } /** * * 获取父栏目ID列表 * @param integer $catid 栏目ID * @param array $arrparentid 父目录ID * @param integer $n 查找的层次 */ private function get_arrparentid($catid, $arrparentid = '', $n = 1) { if($n > 5 || !is_array($this->categorys) || !isset($this->categorys[$catid])) return false; $parentid = $this->categorys[$catid]['parentid']; $arrparentid = $arrparentid ? $parentid.','.$arrparentid : $parentid; if($parentid) { $arrparentid = $this->get_arrparentid($parentid, $arrparentid, ++$n); } else { $this->categorys[$catid]['arrparentid'] = $arrparentid; } $parentid = $this->categorys[$catid]['parentid']; return $arrparentid; } /** * * 获取子栏目ID列表 * @param $catid 栏目ID */ private function get_arrchildid($catid) { $arrchildid = $catid; if(is_array($this->categorys)) { foreach($this->categorys as $id => $cat) { if($cat['parentid'] && $id != $catid && $cat['parentid']==$catid) { $arrchildid .= ','.$this->get_arrchildid($id); } } } return $arrchildid; } /** * 获取父栏目路径 * @param $catid */ function get_parentdir($catid) { if($this->categorys[$catid]['parentid']==0) return ''; $r = $this->categorys[$catid]; $setting = string2array($r['setting']); $url = $r['url']; $arrparentid = $r['arrparentid']; unset($r); if (strpos($url, '://')===false) { if ($setting['creat_to_html_root']) { return ''; } else { $arrparentid = explode(',', $arrparentid); $arrcatdir = array(); foreach($arrparentid as $id) { if($id==0) continue; $arrcatdir[] = $this->categorys[$id]['catdir']; } return implode('/', $arrcatdir).'/'; } } else { if ($setting['create_to_html_root']) { if (preg_match('/^((http|https):\/\/)?([^\/]+)/i', $url, $matches)) { $url = $matches[0].'/'; $rs = $this->db->get_one(array('url'=>$url), '`parentdir`,`catid`'); if ($catid == $rs['catid']) return ''; else return $rs['parentdir']; } else { return ''; } } else { $arrparentid = explode(',', $arrparentid); $arrcatdir = array(); krsort($arrparentid); foreach ($arrparentid as $id) { if ($id==0) continue; $arrcatdir[] = $this->categorys[$id]['catdir']; if ($this->categorys[$id]['parentdir'] == '') break; } krsort($arrcatdir); return implode('/', $arrcatdir).'/'; } } } /** * 检查目录是否存在 * @param $return_method 返回方法 * @param $catdir 目录 */ public function public_check_catdir($return_method = 1,$catdir = '') { $old_dir = ''; $catdir = $catdir ? $catdir : $_GET['catdir']; $parentid = intval($_GET['parentid']); $old_dir = $_GET['old_dir']; $r = $this->db->get_one(array('siteid'=>$this->siteid,'module'=>'content','catdir'=>$catdir,'parentid'=>$parentid)); if($r && $old_dir != $r['catdir']) { //目录存在 if($return_method) { exit('0'); } else { return false; } } else { if($return_method) { exit('1'); } else { return true; } } } /** * 更新权限 * @param $catid * @param $priv_datas * @param $is_admin */ private function update_priv($catid,$priv_datas,$is_admin = 1) { $this->priv_db = pc_base::load_model('category_priv_model'); $this->priv_db->delete(array('catid'=>$catid,'is_admin'=>$is_admin)); if(is_array($priv_datas) && !empty($priv_datas)) { foreach ($priv_datas as $r) { $r = explode(',', $r); $action = $r[0]; $roleid = $r[1]; $this->priv_db->insert(array('catid'=>$catid,'roleid'=>$roleid,'is_admin'=>$is_admin,'action'=>$action,'siteid'=>$this->siteid)); } } } /** * 检查栏目权限 * @param $action 动作 * @param $roleid 角色 * @param $is_admin 是否为管理组 */ private function check_category_priv($action,$roleid,$is_admin = 1) { $checked = ''; foreach ($this->privs as $priv) { if($priv['is_admin']==$is_admin && $priv['roleid']==$roleid && $priv['action']==$action) $checked = 'checked'; } return $checked; } /** * 重新统计栏目信息数量 */ public function count_items() { $this->content_db = pc_base::load_model('content_model'); $result = getcache('category_content_'.$this->siteid,'commons'); foreach($result as $r) { if($r['type'] == 0) { $modelid = $r['modelid']; $this->content_db->set_model($modelid); $number = $this->content_db->count(array('catid'=>$r['catid'])); $this->db->update(array('items'=>$number),array('catid'=>$r['catid'])); } } showmessage(L('operation_success'),HTTP_REFERER); } /** * json方式加载模板 */ public function public_tpl_file_list() { $style = isset($_GET['style']) && trim($_GET['style']) ? trim($_GET['style']) : exit(0); $catid = isset($_GET['catid']) && intval($_GET['catid']) ? intval($_GET['catid']) : 0; $batch_str = isset($_GET['batch_str']) ? '['.$catid.']' : ''; if ($catid) { $cat = getcache('category_content_'.$this->siteid,'commons'); $cat = $cat[$catid]; $cat['setting'] = string2array($cat['setting']); } pc_base::load_sys_class('form','',0); if($_GET['type']==1) { $html = array('page_template'=>form::select_template($style, 'content',(isset($cat['setting']['page_template']) && !empty($cat['setting']['page_template']) ? $cat['setting']['page_template'] : 'category'),'name="setting'.$batch_str.'[page_template]"','page')); } else { $html = array('category_template'=> form::select_template($style, 'content',(isset($cat['setting']['category_template']) && !empty($cat['setting']['category_template']) ? $cat['setting']['category_template'] : 'category'),'name="setting'.$batch_str.'[category_template]"','category'), 'list_template'=>form::select_template($style, 'content',(isset($cat['setting']['list_template']) && !empty($cat['setting']['list_template']) ? $cat['setting']['list_template'] : 'list'),'name="setting'.$batch_str.'[list_template]"','list'), 'show_template'=>form::select_template($style, 'content',(isset($cat['setting']['show_template']) && !empty($cat['setting']['show_template']) ? $cat['setting']['show_template'] : 'show'),'name="setting'.$batch_str.'[show_template]"','show') ); } if ($_GET['module']) { unset($html); if ($_GET['templates']) { $templates = explode('|', $_GET['templates']); if ($_GET['id']) $id = explode('|', $_GET['id']); if (is_array($templates)) { foreach ($templates as $k => $tem) { $t = $tem.'_template'; if ($id[$k]=='') $id[$k] = $tem; $html[$t] = form::select_template($style, $_GET['module'], $id[$k], 'name="'.$_GET['name'].'['.$t.']" id="'.$t.'"', $tem); } } } } if (CHARSET == 'gbk') { $html = array_iconv($html, 'gbk', 'utf-8'); } echo json_encode($html); } /** * 快速进入搜索 */ public function public_ajax_search() { if($_GET['catname']) { if(preg_match('/([a-z]+)/i',$_GET['catname'])) { $field = 'letter'; $catname = strtolower(trim($_GET['catname'])); } else { $field = 'catname'; $catname = trim($_GET['catname']); if (CHARSET == 'gbk') $catname = iconv('utf-8','gbk',$catname); } $result = $this->db->select("$field LIKE('$catname%') AND siteid='$this->siteid' AND child=0",'catid,type,catname,letter',10); if (CHARSET == 'gbk') { $result = array_iconv($result, 'gbk', 'utf-8'); } echo json_encode($result); } } /** * json方式读取风格列表,推送部分调用 */ public function public_change_tpl() { pc_base::load_sys_class('form','',0); $models = getcache('model','commons'); $modelid = intval($_GET['modelid']); if($_GET['modelid']) { $style = $models[$modelid]['default_style']; $category_template = $models[$modelid]['category_template']; $list_template = $models[$modelid]['list_template']; $show_template = $models[$modelid]['show_template']; $html = array( 'template_list'=> $style, 'category_template'=> form::select_template($style, 'content',$category_template,'name="setting[category_template]"','category'), 'list_template'=>form::select_template($style, 'content',$list_template,'name="setting[list_template]"','list'), 'show_template'=>form::select_template($style, 'content',$show_template,'name="setting[show_template]"','show') ); if (CHARSET == 'gbk') { $html = array_iconv($html, 'gbk', 'utf-8'); } echo json_encode($html); } } /** * 批量修改 */ public function batch_edit() { $categorys = getcache('category_content_'.$this->siteid,'commons'); if(isset($_POST['dosubmit'])) { pc_base::load_sys_func('iconv'); $catid = intval($_POST['catid']); $post_setting = $_POST['setting']; //栏目生成静态配置 $infos = $info = array(); $infos = $_POST['info']; if(empty($infos)) showmessage(L('operation_success')); $this->attachment_db = pc_base::load_model('attachment_model'); foreach ($infos as $catid=>$info) { $setting = string2array($categorys[$catid]['setting']); if($_POST['type'] != 2) { if($post_setting[$catid]['ishtml']) { $setting['category_ruleid'] = $_POST['category_html_ruleid'][$catid]; } else { $setting['category_ruleid'] = $_POST['category_php_ruleid'][$catid]; $info['url'] = ''; } } foreach($post_setting[$catid] as $_k=>$_setting) { $setting[$_k] = $_setting; } //内容生成静态配置 if($post_setting[$catid]['content_ishtml']) { $setting['show_ruleid'] = $_POST['show_html_ruleid'][$catid]; } else { $setting['show_ruleid'] = $_POST['show_php_ruleid'][$catid]; } if($setting['repeatchargedays']<1) $setting['repeatchargedays'] = 1; $info['sethtml'] = $post_setting[$catid]['create_to_html_root']; $info['setting'] = array2string($setting); $info['module'] = 'content'; $catname = CHARSET == 'gbk' ? $info['catname'] : iconv('utf-8','gbk',$info['catname']); $letters = gbk_to_pinyin($catname); $info['letter'] = strtolower(implode('', $letters)); $this->db->update($info,array('catid'=>$catid,'siteid'=>$this->siteid)); //更新附件状态 if($info['image'] && pc_base::load_config('system','attachment_stat')) { $this->attachment_db->api_update($info['image'],'catid-'.$catid,1); } } $this->public_cache(); showmessage(L('operation_success'),'?m=admin&c=category&a=init&module=admin&menuid=43'); } else { if(isset($_POST['catids'])) { //获取站点模板信息 pc_base::load_app_func('global'); $template_list = template_list($this->siteid, 0); foreach ($template_list as $k=>$v) { $template_list[$v['dirname']] = $v['name'] ? $v['name'] : $v['dirname']; unset($template_list[$k]); } $show_validator = $show_header = ''; $catid = intval($_GET['catid']); $type = $_POST['type'] ? intval($_POST['type']) : 0; pc_base::load_sys_class('form','',0); if(empty($_POST['catids'])) showmessage(L('illegal_parameters')); $batch_array = $workflows = array(); foreach ($categorys as $catid=>$cat) { if($cat['type']==$type && in_array($catid, $_POST['catids'])) { $batch_array[$catid] = $cat; } } if(empty($batch_array)) showmessage(L('please_select_category')); $workflows = getcache('workflow_'.$this->siteid,'commons'); if($workflows) { $workflows_datas = array(); foreach($workflows as $_k=>$_v) { $workflows_datas[$_v['workflowid']] = $_v['workname']; } } if($type==1) { include $this->admin_tpl('category_batch_edit_page'); } else { include $this->admin_tpl('category_batch_edit'); } } else { $type = isset($_GET['select_type']) ? intval($_GET['select_type']) : 0; $tree = pc_base::load_sys_class('tree'); $tree->icon = array('&nbsp;&nbsp;│ ','&nbsp;&nbsp;├─ ','&nbsp;&nbsp;└─ '); $tree->nbsp = '&nbsp;&nbsp;'; $category = array(); foreach($categorys as $catid=>$r) { if($this->siteid != $r['siteid'] || ($r['type']==2 && $r['child']==0)) continue; $category[$catid] = $r; } $str = "<option value='\$catid' \$selected>\$spacer \$catname</option>"; $tree->init($category); $string .= $tree->get_tree(0, $str); include $this->admin_tpl('category_batch_select'); } } } } ?>
PHP
<?php /** * 模板风格列表 * @param integer $siteid 站点ID,获取单个站点可使用的模板风格列表 * @param integer $disable 是否显示停用的{1:是,0:否} */ function template_list($siteid = '', $disable = 0) { $list = glob(PC_PATH.'templates'.DIRECTORY_SEPARATOR.'*', GLOB_ONLYDIR); $arr = $template = array(); if ($siteid) { $site = pc_base::load_app_class('sites','admin'); $info = $site->get_by_id($siteid); if($info['template']) $template = explode(',', $info['template']); } foreach ($list as $key=>$v) { $dirname = basename($v); if ($siteid && !in_array($dirname, $template)) continue; if (file_exists($v.DIRECTORY_SEPARATOR.'config.php')) { $arr[$key] = include $v.DIRECTORY_SEPARATOR.'config.php'; if (!$disable && isset($arr[$key]['disable']) && $arr[$key]['disable'] == 1) { unset($arr[$key]); continue; } } else { $arr[$key]['name'] = $dirname; } $arr[$key]['dirname']=$dirname; } return $arr; } /** * 设置config文件 * @param $config 配属信息 * @param $filename 要配置的文件名称 */ function set_config($config, $filename="system") { $configfile = CACHE_PATH.'configs'.DIRECTORY_SEPARATOR.$filename.'.php'; if(!is_writable($configfile)) showmessage('Please chmod '.$configfile.' to 0777 !'); $pattern = $replacement = array(); foreach($config as $k=>$v) { if(in_array($k,array('js_path','css_path','img_path','attachment_stat','admin_log','gzip','errorlog','phpsso','phpsso_appid','phpsso_api_url','phpsso_auth_key','phpsso_version','connect_enable', 'upload_url','sina_akey', 'sina_skey', 'snda_enable', 'snda_status', 'snda_akey', 'snda_skey', 'qq_akey', 'qq_skey'))) { $v = trim($v); $configs[$k] = $v; $pattern[$k] = "/'".$k."'\s*=>\s*([']?)[^']*([']?)(\s*),/is"; $replacement[$k] = "'".$k."' => \${1}".$v."\${2}\${3},"; } } $str = file_get_contents($configfile); $str = preg_replace($pattern, $replacement, $str); return pc_base::load_config('system','lock_ex') ? file_put_contents($configfile, $str, LOCK_EX) : file_put_contents($configfile, $str); } /** * 获取系统信息 */ function get_sysinfo() { $sys_info['os'] = PHP_OS; $sys_info['zlib'] = function_exists('gzclose');//zlib $sys_info['safe_mode'] = (boolean) ini_get('safe_mode');//safe_mode = Off $sys_info['safe_mode_gid'] = (boolean) ini_get('safe_mode_gid');//safe_mode_gid = Off $sys_info['timezone'] = function_exists("date_default_timezone_get") ? date_default_timezone_get() : L('no_setting'); $sys_info['socket'] = function_exists('fsockopen') ; $sys_info['web_server'] = $_SERVER['SERVER_SOFTWARE']; $sys_info['phpv'] = phpversion(); $sys_info['fileupload'] = @ini_get('file_uploads') ? ini_get('upload_max_filesize') :'unknown'; return $sys_info; } /** * 检查目录可写性 * @param $dir 目录路径 */ function dir_writeable($dir) { $writeable = 0; if(is_dir($dir)) { if($fp = @fopen("$dir/chkdir.test", 'w')) { @fclose($fp); @unlink("$dir/chkdir.test"); $writeable = 1; } else { $writeable = 0; } } return $writeable; } /** * 返回错误日志大小,单位MB */ function errorlog_size() { $logfile = CACHE_PATH.'error_log.php'; if(file_exists($logfile)) { return $logsize = pc_base::load_config('system','errorlog') ? round(filesize($logfile) / 1048576 * 100) / 100 : 0; } return 0; } ?>
PHP
<?php /** * 检查管理员名称 * @param array $data 管理员数据 */ function checkuserinfo($data) { if(!is_array($data)){ showmessage(L('parameters_error'));return false; } elseif (!is_username($data['username'])){ showmessage(L('username_illegal'));return false; } elseif (empty($data['email']) || !is_email($data['email'])){ showmessage(L('email_illegal'));return false; } elseif (empty($data['roleid'])){ return false; } return $data; } /** * 检查管理员密码合法性 * @param string $password 密码 */ function checkpasswd($password){ if (!is_password($password)){ return false; } return true; } function system_information($data) { $update = pc_base::load_sys_class('update'); $notice_url = $update->notice(); $string = base64_decode('PHNjcmlwdCB0eXBlPSJ0ZXh0L2phdmFzY3JpcHQiPiQoIiNtYWluX2ZyYW1laWQiKS5yZW1vdmVDbGFzcygiZGlzcGxheSIpOzwvc2NyaXB0PjxkaXYgaWQ9InBocGNtc19ub3RpY2UiPjwvZGl2PjxzY3JpcHQgdHlwZT0idGV4dC9qYXZhc2NyaXB0IiBzcmM9Ik5PVElDRV9VUkwiPjwvc2NyaXB0Pg=='); echo $data.str_replace('NOTICE_URL',$notice_url,$string); } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class keylink extends admin { function __construct() { $this->db = pc_base::load_model('keylink_model'); parent::__construct(); } function init () { $page = $_GET['page'] ? intval($_GET['page']) : '1'; $infos = $this->db->listinfo('','keylinkid DESC',$page ,'20'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=admin&c=keylink&a=add\', title:\''.L('add_keylink').'\', width:\'450\', height:\'130\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_keylink')); include $this->admin_tpl('keylink_list'); } /** * 验证数据有效性 */ public function public_name() { $word = isset($_GET['word']) && trim($_GET['word']) ? (CHARSET == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['word'])) : trim($_GET['word'])) : exit('0'); //修改检测 $keylinkid = isset($_GET['keylinkid']) && intval($_GET['keylinkid']) ? intval($_GET['keylinkid']) : ''; $data = array(); if ($keylinkid) { $data = $this->db->get_one(array('keylinkid'=>$keylinkid), 'word'); if (!empty($data) && $data['word'] == $word) { exit('1'); } } //添加检测 if ($this->db->get_one(array('word'=>$word), 'keylinkid')) { exit('0'); } else { exit('1'); } } /** * 关联词添加 */ function add() { if(isset($_POST['dosubmit'])){ if(empty($_POST['info']['word']) || empty($_POST['info']['url']))return false; $this->db->insert($_POST['info']); $this->public_cache_file();//更新缓存 showmessage(L('operation_success'),'?m=admin&c=keylink&a=add','', 'add'); }else{ $show_validator = $show_scroll = $show_header = true; include $this->admin_tpl('keylink_add'); } } /** * 关联词修改 */ function edit() { if(isset($_POST['dosubmit'])){ $keylinkid = intval($_GET['keylinkid']); if(empty($_POST['info']['word']) || empty($_POST['info']['url']))return false; $this->db->update($_POST['info'],array('keylinkid'=>$keylinkid)); $this->public_cache_file();//更新缓存 showmessage(L('operation_success'),'?m=admin&c=keylink&a=edit','', 'edit'); }else{ $show_validator = $show_scroll = $show_header = true; $info = $this->db->get_one(array('keylinkid'=>$_GET['keylinkid'])); if(!$info) showmessage(L('specified_word_not_exist')); extract($info); include $this->admin_tpl('keylink_edit'); } } /** * 关联词删除 */ function delete() { if(is_array($_POST['keylinkid'])){ foreach($_POST['keylinkid'] as $keylinkid_arr) { $this->db->delete(array('keylinkid'=>$keylinkid_arr)); } $this->public_cache_file();//更新缓存 showmessage(L('operation_success'),'?m=admin&c=keylink'); } else { $keylinkid = intval($_GET['keylinkid']); if($keylinkid < 1) return false; $result = $this->db->delete(array('keylinkid'=>$keylinkid)); $this->public_cache_file();//更新缓存 if($result){ showmessage(L('operation_success'),'?m=admin&c=keylink'); }else { showmessage(L("operation_failure"),'?m=admin&c=keylink'); } } } /** * 生成缓存 */ public function public_cache_file() { $infos = $this->db->select('','word,url','','keylinkid ASC'); $datas = $rs = array(); foreach($infos as $r) { $rs[0] = $r['word']; $rs[1] = $r['url']; $datas[] = $rs; } setcache('keylink', $datas, 'commons'); return true; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class log extends admin { function __construct() { parent::__construct(); $this->db = pc_base::load_model('log_model'); pc_base::load_sys_class('form'); $admin_username = param::get_cookie('admin_username');//管理员COOKIE $userid = $_SESSION['userid'];//登陆USERID  } function init () { $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where = '',$order = 'logid DESC',$page, $pages = '13'); $pages = $this->db->pages; //模块数组 $module_arr = array(); $modules = getcache('modules','commons'); $default = L('open_module'); foreach($modules as $module=>$m) $module_arr[$m['module']] = $m['module']; include $this->admin_tpl('log_list'); } /** * 操作日志删除 包含批量删除 单个删除 */ function delete() { $week = intval($_GET['week']); if($week){ $where = ''; $start = SYS_TIME - $week*7*24*3600; $d = date("Y-m-d",$start); //$end = strtotime($end_time); //$where .= "AND `message_time` >= '$start' AND `message_time` <= '$end' "; $where .= "`time` <= '$d'"; $this->db->delete($where); showmessage(L('operation_success'),'?m=admin&c=log'); } else { return false; } } /** * 日志搜索 */ public function search_log() { $where = ''; extract($_GET['search']); if($username){ $where .= $where ? " AND username='$username'" : " username='$username'"; } if ($module){ $where .= $where ? " AND module='$module'" : " module='$module'"; } if($start_time && $end_time) { $start = $start_time; $end = $end_time; $where .= "AND `time` >= '$start' AND `time` <= '$end' "; } $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where,$order = 'logid DESC',$page, $pages = '12'); $pages = $this->db->pages; //模块数组 $module_arr = array(); $modules = getcache('modules','commons'); $default = $module ? $module : L('open_module');//未设定则显示 不限模块 ,设定则显示指定的 foreach($modules as $module=>$m) $module_arr[$m['module']] = $m['module']; include $this->admin_tpl('log_search_list'); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class module extends admin { private $db; public function __construct() { $this->db = pc_base::load_model('module_model'); parent::__construct(); } public function init() { $dirs = $module = $dirs_arr = $directory = array(); $dirs = glob(PC_PATH.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'*'); foreach ($dirs as $d) { if (is_dir($d)) { $d = basename($d); $dirs_arr[] = $d; } } define('INSTALL', true); $modules = $this->db->select('', '*', '', '', '', 'module'); $total = count($dirs_arr); $dirs_arr = array_chunk($dirs_arr, 20, true); $page = max(intval($_GET['page']), 1); $pages = pages($total, $page, 20); $directory = $dirs_arr[intval($page-1)]; include $this->admin_tpl('module_list'); } /** * 模块安装 */ public function install() { $this->module = $_POST['module'] ? $_POST['module'] : $_GET['module']; $module_api = pc_base::load_app_class('module_api'); if (!$module_api->check($this->module)) showmessage($module_api->error_msg, 'blank'); if ($_POST['dosubmit']) { if ($module_api->install()) showmessage(L('success_module_install').L('update_cache'), '?m=admin&c=module&a=cache&pc_hash='.$_SESSION['pc_hash']); else showmesage($module_api->error_msg, HTTP_REFERER); } else { include PC_PATH.'modules'.DIRECTORY_SEPARATOR.$this->module.DIRECTORY_SEPARATOR.'install'.DIRECTORY_SEPARATOR.'config.inc.php'; include $this->admin_tpl('module_config'); } } /** * 模块卸载 */ public function uninstall() { if(!isset($_GET['module']) || empty($_GET['module'])) showmessage(L('illegal_parameters')); $module_api = pc_base::load_app_class('module_api'); if(!$module_api->uninstall($_GET['module'])) showmessage($module_api->error_msg, 'blank'); else showmessage(L('uninstall_success'), '?m=admin&c=module&a=cache&pc_hash='.$_SESSION['pc_hash']); } /** * 更新模块缓存 */ public function cache() { echo '<script type="text/javascript">parent.right.location.href = \'?m=admin&c=cache_all&a=init&pc_hash='.$_SESSION['pc_hash'].'\';window.top.art.dialog({id:\'install\'}).close();</script>'; //showmessage(L('update_cache').L('success'), '', '', 'install'); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form', '', 0); pc_base::load_sys_func('plugin'); class plugin extends admin { private $db,$db_var; function __construct() { parent::__construct(); $this->db = pc_base::load_model('plugin_model'); $this->db_var = pc_base::load_model('plugin_var_model'); pc_base::load_app_func('global'); } /** * 应用配置信息 */ public function init() { $show_validator = true; $show_dialog = true; if($pluginfo = $this->db->select('','*','','disable DESC,listorder DESC')) { foreach ($pluginfo as $_k=>$_r) { if(file_exists(PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$_r['dir'].DIRECTORY_SEPARATOR.$_r['dir'].'.class.php')){ $pluginfo[$_k]['url'] = 'plugin.php?id='.$_r['dir']; } else { $pluginfo[$_k]['url'] = ''; } $pluginfo[$_k]['dir'] = $_r['dir'].'/'; } } include $this->admin_tpl('plugin_list'); } /** * 应用导入\安装 */ public function import() { if(!isset($_GET['dir'])) { $plugnum = 1; $installsdir = array(); if($installs_pluginfo = $this->db->select()) { foreach ($installs_pluginfo as $_r) { $installsdir[] = $_r['dir']; } } $pluginsdir = dir(PC_PATH.'plugin'); while (false !== ($entry = $pluginsdir->read())) { $config_file = ''; $plugin_data = array(); if(!in_array($entry, array('.', '..')) && is_dir(PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$entry) && !in_array($entry, $installsdir) && !$this->db->get_one(array('identification'=>$entry))) { $config_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$entry.DIRECTORY_SEPARATOR.'plugin_'.$entry.'.cfg.php'; if(file_exists($config_file)) { $plugin_data = @require($config_file); $pluginfo[$plugnum]['name'] = $plugin_data['plugin']['name']; $pluginfo[$plugnum]['version'] = $plugin_data['plugin']['version']; $pluginfo[$plugnum]['copyright'] = $plugin_data['plugin']['copyright']; $pluginfo[$plugnum]['dir'] = $entry; $plugnum++; } } } include $this->admin_tpl('plugin_list_import'); } else { $dir = trim($_GET['dir']); $license = 0; $config_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.'plugin_'.$dir.'.cfg.php'; if(file_exists($config_file)) { $plugin_data = @require($config_file); $license = ($plugin_data['license'] == '' || !isset($plugin_data['license'])) ? 0 : 1; } if(empty($_GET['license']) && $license) { $submit_url = '?m=admin&c=plugin&a=import&dir='.$dir.'&license=1&pc_hash='. $_SESSION['pc_hash'].'&menuid='.$_GET['menuid']; } else { $submit_url = '?m=admin&c=plugin&a=install&dir='.$dir.'&pc_hash='. $_SESSION['pc_hash'].'&menuid='.$_GET['menuid']; } $show_header = 0; include $this->admin_tpl('plugin_import_confirm'); } } /** * 应用删除程序 */ public function delete() { if(isset($_POST['dosubmit'])) { $pluginid = intval($_POST['pluginid']); $plugin_data = $this->db->get_one(array('pluginid'=>$pluginid)); $op_status = FALSE; $dir = $plugin_data['dir']; $config_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.'plugin_'.$dir.'.cfg.php'; if(file_exists($config_file)) { $plugin_data = @require($config_file); } $filename = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$plugin_data['plugin']['uninstallfile']; if(file_exists($filename)) { @include_once $filename; } else { showmessage(L('plugin_lacks_uninstall_file','','plugin'),HTTP_REFERER); } if($op_status) { $this->db->delete(array('pluginid'=>$pluginid)); $this->db_var->delete(array('pluginid'=>$pluginid)); delcache($dir,'plugins'); delcache($dir.'_var','plugins'); $this->set_hook_cache(); if($plugin_data['plugin']['iframe']) { pc_base::load_sys_func('dir'); if(!dir_delete(PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir)) { showmessage(L('plugin_uninstall_success_no_delete','','plugin'),'?m=admin&c=plugin'); } } showmessage(L('plugin_uninstall_success','','plugin'),'?m=admin&c=plugin'); } else { showmessage(L('plugin_uninstall_fail','','plugin'),'?m=admin&c=plugin'); } } else { $show_header = 0; $pluginid = intval($_GET['pluginid']); $plugin_data = $this->db->get_one(array('pluginid'=>$pluginid)); include $this->admin_tpl('plugin_delete_confirm'); } } /** * 应用安装 */ public function install() { $op_status = FALSE; $dir = trim($_GET['dir']); $config_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.'plugin_'.$dir.'.cfg.php'; if(file_exists($config_file)) { $plugin_data = @require($config_file); } else { showmessage(L('plugin_config_not_exist','','plugin')); } $app_status = app_validity_check($plugin_data['appid']); if($app_status != 2){ $app_msg = $app_status == '' ? L('plugin_not_exist_or_pending','','plugin') : ($app_status == 0 || $app_status == 1 ? L('plugin_developing','','plugin') : L('plugin_be_locked','','plugin')); showmessage($app_msg); } if($plugin_data['version'] && $plugin_data['version']!=pc_base::load_config('version', 'pc_version')) { showmessage(L('plugin_incompatible','','plugin')); } if($plugin_data['dir'] == '' || $plugin_data['identification'] == '' || $plugin_data['identification']!=$plugin_data['dir']) { showmessage(L('plugin_lack_of_necessary_configuration_items','','plugin')); } if(!pluginkey_check($plugin_data['identification'])) { showmessage(L('plugin_illegal_id','','plugin')); } if(is_array($plugin_data['plugin_var'])) { foreach($plugin_data['plugin_var'] as $config) { if(!pluginkey_check($config['fieldname'])) { showmessage(L('plugin_illegal_variable','','plugin')); } } } if($this->db->get_one(array('identification'=>$plugin_data['identification']))) { showmessage(L('plugin_duplication_name','','plugin')); }; $filename = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$dir.DIRECTORY_SEPARATOR.$plugin_data['plugin']['installfile']; if(file_exists($filename)) { @include_once $filename; } if($op_status) { //向插件表中插入数据 $plugin = array('name'=>new_addslashes($plugin_data['plugin']['name']),'identification'=>$plugin_data['identification'],'appid'=>$plugin_data['appid'],'description'=>new_addslashes($plugin_data['plugin']['description']),'dir'=>$plugin_data['dir'],'copyright'=>new_addslashes($plugin_data['plugin']['copyright']),'setting'=>array2string($plugin_data['plugin']['setting']),'iframe'=>array2string($plugin_data['plugin']['iframe']),'version'=>$plugin_data['plugin']['version'],'disable'=>'0'); $pluginid = $this->db->insert($plugin,TRUE); //向插件变量表中插入数据 if(is_array($plugin_data['plugin_var'])) { foreach($plugin_data['plugin_var'] as $config) { $plugin_var = array(); $plugin_var['pluginid'] = $pluginid; foreach($config as $_k => $_v) { if(!in_array($_k, array('title','description','fieldname','fieldtype','setting','listorder','value','formattribute'))) continue; if($_k == 'setting') $_v = array2string($_v); $plugin_var[$_k] = $_v; } $this->db_var->insert($plugin_var); } } plugin_install_stat($plugin_data['appid']); setcache($plugin_data['identification'], $plugin,'plugins'); $this->set_var_cache($pluginid); showmessage(L('plugin_install_success','','plugin'),'?m=admin&c=plugin'); } else { showmessage(L('plugin_install_fail','','plugin'),'?m=admin&c=plugin'); } } /** * 应用升级 */ public function upgrade() { //TODO } /** * 应用排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $pluginid => $listorder) { $this->db->update(array('listorder'=>$listorder),array('pluginid'=>$pluginid)); } $this->set_hook_cache(); showmessage(L('operation_success'),'?m=admin&c=plugin'); } else { showmessage(L('operation_failure'),'?m=admin&c=plugin'); } } /** * 应用中心 * Enter description here ... */ public function appcenter() { $data = array(); $p = intval($_GET[p]) ? intval($_GET[p]) : 1; $s = 8; $data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_applist&s='.$s.'&p='.$p); $data = array_iconv(json_decode($data, true),'utf-8',CHARSET); $recommed_data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_recommed_applist&s=5&p=1'); $recommed_data = array_iconv(json_decode($recommed_data, true),'utf-8',CHARSET); $focus_data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_app_focus&num=3'); $focus_data = array_iconv(json_decode($focus_data, true),'utf-8',CHARSET); $pages = $data['pages']; $pre_page = $p <= 1 ? 1 : $p - 1; $next_page = $p >= $pages ? $pages : $p + 1; $pages = '<a class="a1">'.$data['total'].L('plugin_item','','plugin').'</a> <a href="?m=admin&c=plugin&a=appcenter&p=1">'.L('plugin_firstpage').'</a> <a href="?m=admin&c=plugin&a=appcenter&p='.$pre_page.'">'.L('plugin_prepage').'</a> <a href="?m=admin&c=plugin&a=appcenter&p='.$next_page.'">'.L('plugin_nextpage').'</a> <a href="?m=admin&c=plugin&a=appcenter&p='.$pages.'">'.L('plugin_lastpage').'</a>'; $show_header = 1; include $this->admin_tpl('plugin_appcenter'); } /** * 显示应用详情 */ public function appcenter_detail() { $data = array(); $id = intval($_GET['id']); $data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_detail_byappid&id='.$id); $data = array_iconv(json_decode($data, true),'utf-8',CHARSET); extract($data); if($appname) { include $this->admin_tpl('plugin_appcenter_detail'); } else { showmessage(L('plugin_not_exist_or_pending','','plugin')); } } /** * 在线安装 */ public function install_online() { $data = array(); $id = intval($_GET['id']); $data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_detail_byappid&id='.$id); $data = array_iconv(json_decode($data, true),'utf-8',CHARSET); //如果为iframe类型应用,无需下载压缩包,之间创建插件文件夹 if(!empty($data['iframe'])) { $appdirname = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$data['appenname']; if(!file_exists($appdirname)) { if(!mkdir($appdirname)) { showmessage(L('plugin_mkdir_fail', '', 'plugin')); } else { //创建安装、配置文件 $installdata = <<<EOF <?php defined('IN_PHPCMS') or exit('No permission resources.'); \$op_status = TRUE; ?> EOF; $uninstallres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'uninstall.php', $installdata); $installres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'install.php', $installdata); $cfgdata = <<<EOF <?php return array ( 'identification' => '$data[appenname]', 'dir' => '$data[appenname]', 'appid' => '$data[id]', 'plugin'=> array( 'version' => '1.0', 'name' => '$data[appname]', 'copyright' => 'phpcms team', 'description' =>'$data[description]', 'installfile' => 'install.php', 'uninstallfile' => 'uninstall.php', 'iframe' => array('width'=>'960','height'=>'640','url'=>'$data[iframe]'), ), 'plugin_var'=> array( array('title'=>'宽度','description'=>'','fieldname'=>'width','fieldtype'=>'text','value'=>'960','formattribute'=>'style="width:50px"','listorder'=>'1',), array('title'=>'高度','description'=>'','fieldname'=>'height','fieldtype'=>'text','value'=>'640','formattribute'=>'style="width:50px"','listorder'=>'2',), ), ); ?> EOF; $cfgres = @file_put_contents($appdirname.DIRECTORY_SEPARATOR.'plugin_'.$data['appenname'].'.cfg.php', $cfgdata); //检查配置文件是否写入成功 if($installres*$uninstallres*$cfgres > 0) { showmessage(L('plugin_configure_success', '', 'plugin'), 'index.php?m=admin&c=plugin&a=import&dir='.$data['appenname']); } else { showmessage(L('plugin_install_fail', '', 'plugin')); } } } else { showmessage(L('plugin_allready_exists', '', 'plugin')); } } else { //远程压缩包地址 $upgradezip_url = $data['downurl']; if(empty($upgradezip_url)) { showmessage(L('download_fail', '', 'plugin'), 'index.php?m=admin&c=plugin&a=appcenter'); } //创建缓存文件夹 if(!file_exists(CACHE_PATH.'caches_open')) { @mkdir(CACHE_PATH.'caches_open'); } //保存到本地地址 $upgradezip_path = CACHE_PATH.'caches_open'.DIRECTORY_SEPARATOR.$data['id'].'.zip'; //解压路径 $upgradezip_source_path = CACHE_PATH.'caches_open'.DIRECTORY_SEPARATOR.$data['id']; //下载压缩包 @file_put_contents($upgradezip_path, @file_get_contents($upgradezip_url)); //解压缩 pc_base::load_app_class('pclzip', 'upgrade', 0); $archive = new PclZip($upgradezip_path); if($archive->extract(PCLZIP_OPT_PATH, $upgradezip_source_path, PCLZIP_OPT_REPLACE_NEWER) == 0) { die("Error : ".$archive->errorInfo(true)); } //删除压缩包 @unlink($upgradezip_path); //拷贝gbk/upload文件夹到根目录 $copy_from = $upgradezip_source_path.DIRECTORY_SEPARATOR.CHARSET; //动态程序路径 $copy_to_pcpath = PC_PATH.'plugin'; //静态程序路径 $copy_to_staticspath = PHPCMS_PATH.'statics'.DIRECTORY_SEPARATOR.'plugin'; //应用文件夹名称 $appdirname = $data['appenname']; $this->copyfailnum = 0; $this->copydir($copy_from.DIRECTORY_SEPARATOR.'phpcms'.DIRECTORY_SEPARATOR.'plugin', $copy_to_pcpath, $_GET['cover']); $this->copydir($copy_from.DIRECTORY_SEPARATOR.'statics'.DIRECTORY_SEPARATOR.'plugin', $copy_to_staticspath, $_GET['cover']); $this->deletedir($copy_from); //检查文件操作权限,是否复制成功 if($this->copyfailnum > 0) { showmessage(L('download_fail', '', 'plugin'), 'index.php?m=admin&c=plugin&a=appcenter'); } else { showmessage(L('download_success', '', 'plugin'), 'index.php?m=admin&c=plugin&a=import&dir='.$appdirname); } } } /** * 异步方式调用详情 * Enter description here ... */ public function public_appcenter_ajx_detail() { $id = intval($_GET['id']); $data = file_get_contents('http://open.phpcms.cn/index.php?m=open&c=api&a=get_detail_byappid&id='.$id); //$data = json_decode($data, true); echo $_GET['jsoncallback'].'(',$data,')'; exit; } /** * 配置应用. */ public function config() { if(isset($_POST['dosubmit'])) { $pluginid = intval($_POST['pluginid']); foreach ($_POST['info'] as $_k => $_v) { $this->db_var->update(array('value'=>$_v),array('pluginid'=>$pluginid,'fieldname'=>$_k)); } $this->set_var_cache($pluginid); showmessage(L('operation_success'),HTTP_REFERER); } else { $pluginid = intval($_GET['pluginid']); $plugin_menus = array(); $info = $this->db->get_one(array('pluginid'=>$pluginid)); extract($info); if(!isset($_GET['module'])) { $plugin_menus[] =array('name'=>L('plugin_desc','','plugin'),'url'=>'','status'=>'1'); if($disable){ if($info_var = $this->db_var->select(array('pluginid'=>$pluginid),'*','','listorder ASC,id DESC')) { $plugin_menus[] =array('name'=>L('plugin_config','','plugin'),'url'=>'','status'=>'0'); $form = $this->creatconfigform($info_var); } $meun_total = count($plugin_menus);; $setting = string2array($setting); if(is_array($setting)) { foreach($setting as $m) { $plugin_menus[] = array('name'=>$m['menu'],'extend'=>1,'url'=>$m['name']); $mods[] = $m['name']; } } } include $this->admin_tpl('plugin_setting'); } else { define('PLUGIN_ID', $identification); $plugin_module = trim($_GET['module']); $plugin_admin_path = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$identification.DIRECTORY_SEPARATOR.'plugin_admin.class.php'; if (file_exists($plugin_admin_path)) { include $plugin_admin_path; $plugin_admin = new plugin_admin($pluginid); call_user_func(array($plugin_admin, $plugin_module)); } } } } /** * 开启/关闭插件 * Enter description here ... */ public function status() { $disable = intval($_GET['disable']); $pluginid = intval($_GET['pluginid']); $this->db->update(array('disable'=>$disable),array('pluginid'=>$pluginid)); $this->set_cache($pluginid); showmessage(L('operation_success'),HTTP_REFERER); } /** * 设置字段缓存 * @param int $pluginid */ private function set_var_cache($pluginid) { if($info = $this->db_var->select(array('pluginid'=>$pluginid))) { $plugin_data = $this->db->get_one(array('pluginid'=>$pluginid)); foreach ($info as $_value) { $plugin_vars[$_value['fieldname']] = $_value['value']; } setcache($plugin_data['identification'].'_var', $plugin_vars,'plugins'); } } /** * 设置缓存 * @param int $pluginid */ private function set_cache($pluginid) { if($info = $this->db->get_one(array('pluginid'=>$pluginid))) { setcache($info['identification'], $info,'plugins'); } $this->set_hook_cache(); } /** * 设置hook缓存 */ function set_hook_cache() { if($info = $this->db->select(array('disable'=>1),'*','','listorder DESC')) { foreach($info as $i) { $id = $i['identification']; $hook_file = PC_PATH.'plugin'.DIRECTORY_SEPARATOR.$id.DIRECTORY_SEPARATOR.'hook.class.php'; if(file_exists($hook_file)) { $hook[$i['appid']] = $i['identification']; } } } setcache('hook',$hook,'plugins'); } /** * 创建配置表单 * @param array $data */ private function creatconfigform($data) { if(!is_array($data) || empty($data)) return false; foreach ($data as $r) { $form .= '<tr><th width="120">'.$r['title'].'</th><td class="y-bg">'.$this->creatfield($r).'</td></tr>'; } return $form; } /** * 创建配置表单字段 * @param array $data */ private function creatfield($data) { extract($data); $fielda_array = array('text','radio','checkbox','select','datetime','textarea'); if(in_array($fieldtype, $fielda_array)) { if($fieldtype == 'text') { return '<input type="text" name="info['.$fieldname.']" id="'.$fieldname.'" value="'.$value.'" class="input-text" '.$formattribute.' > '.' '.$description; } elseif($fieldtype == 'checkbox') { return form::checkbox(string2array($setting),$value,"name='info[$fieldname]' $formattribute",'',$fieldname).' '.$description; } elseif($fieldtype == 'radio') { return form::radio(string2array($setting),$value,"name='info[$fieldname]' $formattribute",'',$fieldname).' '.$description; } elseif($fieldtype == 'select') { return form::select(string2array($setting),$value,"name='info[$fieldname]' $formattribute",'',$fieldname).' '.$description; } elseif($fieldtype == 'datetime') { return form::date("info[$fieldname]",$value,$isdatetime,1).' '.$description; } elseif($fieldtype == 'textarea') { return '<textarea name="info['.$fieldname.']" id="'.$fieldname.'" '.$formattribute.'>'.$value.'</textarea>'.' '.$description; } } } /** * 执行SQL * @param string $sql 要执行的sql语句 */ private function _sql_execute($sql) { $sqls = $this->_sql_split($sql); if(is_array($sqls)) { foreach($sqls as $sql) { if(trim($sql) != '') { $this->db->query($sql); } } } else { $this->db->query($sqls); } return true; } /** * 分割SQL语句 * @param string $sql 要执行的sql语句 */ private function _sql_split($sql) { $database = pc_base::load_config('database'); $db_charset = $database['default']['charset']; if($this->db->version() > '4.1' && $db_charset) { $sql = preg_replace("/TYPE=(InnoDB|MyISAM|MEMORY)( DEFAULT CHARSET=[^; ]+)?/", "ENGINE=\\1 DEFAULT CHARSET=".$db_charset,$sql); } $sql = str_replace("\r", "\n", $sql); $ret = array(); $num = 0; $queriesarray = explode(";\n", trim($sql)); unset($sql); foreach($queriesarray as $query) { $ret[$num] = ''; $queries = explode("\n", trim($query)); $queries = array_filter($queries); foreach($queries as $query) { $str1 = substr($query, 0, 1); if($str1 != '#' && $str1 != '-') $ret[$num] .= $query; } $num++; } return($ret); } private function copydir($dirfrom, $dirto, $cover='') { //如果遇到同名文件无法复制,则直接退出 if(is_file($dirto)){ die(L('have_no_pri').$dirto); } //如果目录不存在,则建立之 if(!file_exists($dirto)){ mkdir($dirto); } $handle = opendir($dirfrom); //打开当前目录 //循环读取文件 while(false !== ($file = readdir($handle))) { if($file != '.' && $file != '..'){ //排除"."和"." //生成源文件名 $filefrom = $dirfrom.DIRECTORY_SEPARATOR.$file; //生成目标文件名 $fileto = $dirto.DIRECTORY_SEPARATOR.$file; if(is_dir($filefrom)){ //如果是子目录,则进行递归操作 $this->copydir($filefrom, $fileto, $cover); } else { //如果是文件,则直接用copy函数复制 if(!empty($cover)) { if(!copy($filefrom, $fileto)) { $this->copyfailnum++; echo L('copy').$filefrom.L('to').$fileto.L('failed')."<br />"; } } else { if(fileext($fileto) == 'html' && file_exists($fileto)) { } else { if(!copy($filefrom, $fileto)) { $this->copyfailnum++; echo L('copy').$filefrom.L('to').$fileto.L('failed')."<br />"; } } } } } } } private function deletedir($dirname){ $result = false; if(! is_dir($dirname)){ echo " $dirname is not a dir!"; exit(0); } $handle = opendir($dirname); //打开目录 while(($file = readdir($handle)) !== false) { if($file != '.' && $file != '..'){ //排除"."和"." $dir = $dirname.DIRECTORY_SEPARATOR.$file; //$dir是目录时递归调用deletedir,是文件则直接删除 is_dir($dir) ? $this->deletedir($dir) : unlink($dir); } } closedir($handle); $result = rmdir($dirname) ? true : false; return $result; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class cache_all extends admin { private $cache_api; public function init() { if (isset($_POST['dosubmit']) || isset($_GET['dosubmit'])) { $page = $_GET['page'] ? intval($_GET['page']) : 0; $modules = array( array('name' => L('module'), 'function' => 'module'), array('name' => L('sites'), 'mod' => 'admin', 'file' => 'sites', 'function' => 'set_cache'), array('name' => L('category'), 'function' => 'category'), array('name' => L('downservers'), 'function' => 'downservers'), array('name' => L('badword_name'), 'function' => 'badword'), array('name' => L('ipbanned'), 'function' => 'ipbanned'), array('name' => L('keylink'), 'function' => 'keylink'), array('name' => L('linkage'), 'function' => 'linkage'), array('name' => L('position'), 'function' => 'position'), array('name' => L('admin_role'), 'function' => 'admin_role'), array('name' => L('urlrule'), 'function' => 'urlrule'), array('name' => L('sitemodel'), 'function' => 'sitemodel'), array('name' => L('type'), 'function' => 'type', 'param' => 'content'), array('name' => L('workflow'), 'function' => 'workflow'), array('name' => L('dbsource'), 'function' => 'dbsource'), array('name' => L('member_setting'), 'function' => 'member_setting'), array('name' => L('member_group'), 'function' => 'member_group'), array('name' => L('membermodel'), 'function' => 'membermodel'), array('name' => L('member_model_field'), 'function' => 'member_model_field'), array('name' => L('search_type'), 'function' => 'type', 'param' => 'search'), array('name' => L('search_setting'), 'function' => 'search_setting'), array('name' => L('update_vote_setting'), 'function' => 'vote_setting'), array('name' => L('update_link_setting'), 'function' => 'link_setting'), array('name' => L('special'), 'function' => 'special'), array('name' => L('setting'), 'function' => 'setting'), array('name' => L('database'), 'function' => 'database'), array('name' => L('update_formguide_model'), 'mod' => 'formguide', 'file' => 'formguide', 'function' => 'public_cache'), array('name' => L('cache_file'), 'function' => 'cache2database'), array('name' => L('cache_copyfrom'), 'function' => 'copyfrom'), array('name' => L('clear_files'), 'function' => 'del_file'), ); $this->cache_api = pc_base::load_app_class('cache_api', 'admin'); $m = $modules[$page]; if ($m['mod'] && $m['function']) { if ($m['file'] == '') $m['file'] = $m['function']; $M = getcache('modules', 'commons'); if (in_array($m['mod'], array_keys($M))) { $cache = pc_base::load_app_class($m['file'], $m['mod']); $cache->$m['function'](); } } else if($m['target']=='iframe') { echo '<script type="text/javascript">window.parent.frames["hidden"].location="index.php?'.$m['link'].'";</script>'; } else { $this->cache_api->cache($m['function'], $m['param']); } $page++; if (!empty($modules[$page])) { echo '<script type="text/javascript">window.parent.addtext("<li>'.L('update').$m['name'].L('cache_file_success').'..........</li>");</script>'; showmessage(L('update').$m['name'].L('cache_file_success'), '?m=admin&c=cache_all&page='.$page.'&dosubmit=1&pc_hash='.$_SESSION['pc_hash'], 0); } else { echo '<script type="text/javascript">window.parent.addtext("<li>'.L('update').$m['name'].L('site_cache_success').'..........</li>")</script>'; showmessage(L('update').$m['name'].L('site_cache_success'), 'blank'); } } else { include $this->admin_tpl('cache_all'); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form','',0); class search_type extends admin { function __construct() { parent::__construct(); $this->db = pc_base::load_model('type_model'); $this->siteid = $this->get_siteid(); $this->model = getcache('model','commons'); $this->yp_model = getcache('yp_model','model'); $this->module_db = pc_base::load_model('module_model'); } public function init () { $datas = array(); $page = isset($_GET['page']) && trim($_GET['page']) ? intval($_GET['page']) : 1; $result_datas = $this->db->listinfo(array('siteid'=>$this->siteid,'module'=>'search'),'listorder ASC', $page); $pages = $this->db->pages; foreach($result_datas as $r) { $r['modelname'] = $this->model[$r['modelid']]['name']; $datas[] = $r; } $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=search&c=search_type&a=add\', title:\''.L('add_search_type').'\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_search_type')); $this->cache(); include $this->admin_tpl('type_list'); } public function add() { if(isset($_POST['dosubmit'])) { $_POST['info']['siteid'] = $this->siteid; $_POST['info']['module'] = 'search'; if($_POST['module']=='content') { $_POST['info']['modelid'] = intval($_POST['info']['modelid']); $_POST['info']['typedir'] = $_POST['module']; } elseif($_POST['module']=='yp') { $_POST['info']['modelid'] = intval($_POST['info']['yp_modelid']); $_POST['info']['typedir'] = $_POST['module']; } else { $_POST['info']['typedir'] = $_POST['module']; $_POST['info']['modelid'] = 0; } //删除黄页模型变量无该字段 unset($_POST['info']['yp_modelid']); $this->db->insert($_POST['info']); showmessage(L('add_success'), '', '', 'add'); } else { $show_header = $show_validator = ''; foreach($this->model as $_key=>$_value) { if($_value['siteid']!=$this->siteid) continue; $model_data[$_key] = $_value['name']; } foreach($this->yp_model as $_key=>$_value) { if($_value['siteid']!=$this->siteid) continue; $yp_model_data[$_key] = $_value['name']; } $module_data = array('special' => L('special'),'content' => L('content').L('module'),'yp'=>L('yp')); include $this->admin_tpl('type_add'); } } public function edit() { if(isset($_POST['dosubmit'])) { $typeid = intval($_POST['typeid']); if($_POST['module']=='content') { $_POST['info']['modelid'] = intval($_POST['info']['modelid']); } elseif($_POST['module']=='yp') { $_POST['info']['modelid'] = intval($_POST['info']['yp_modelid']); $_POST['info']['typedir'] = $_POST['module']; } else { $_POST['info']['typedir'] = $_POST['typedir']; $_POST['info']['modelid'] = 0; } //删除黄页模型变量无该字段 unset($_POST['info']['yp_modelid']); $this->db->update($_POST['info'],array('typeid'=>$typeid)); showmessage(L('update_success'), '', '', 'edit'); } else { $show_header = $show_validator = ''; $typeid = intval($_GET['typeid']); foreach($this->model as $_key=>$_value) { if($_value['siteid']!=$this->siteid) continue; $model_data[$_key] = $_value['name']; } foreach($this->yp_model as $_key=>$_value) { if($_value['siteid']!=$this->siteid) continue; $yp_model_data[$_key] = $_value['name']; } $module_data = array('special' => L('special'),'content' => L('content').L('module'),'yp'=>L('yp')); $r = $this->db->get_one(array('typeid'=>$typeid)); extract($r); include $this->admin_tpl('type_edit'); } } public function delete() { $_GET['typeid'] = intval($_GET['typeid']); $this->db->delete(array('typeid'=>$_GET['typeid'])); showmessage(L('operation_success'), HTTP_REFERER); } /** * 排序 */ public function listorder() { if(isset($_POST['dosubmit'])) { foreach($_POST['listorders'] as $id => $listorder) { $this->db->update(array('listorder'=>$listorder),array('typeid'=>$id)); } showmessage(L('operation_success')); } else { showmessage(L('operation_failure')); } } public function cache() { $datas = $search_model = array(); $result_datas = $result_datas2 = $this->db->select(array('siteid'=>$this->siteid,'module'=>'search'),'*',1000,'listorder ASC'); foreach($result_datas as $_key=>$_value) { if(!$_value['modelid']) continue; $datas[$_value['modelid']] = $_value['typeid']; $search_model[$_value['modelid']]['typeid'] = $_value['typeid']; $search_model[$_value['modelid']]['name'] = $_value['name']; $search_model[$_value['modelid']]['sort'] = $_value['listorder']; } setcache('type_model_'.$this->siteid,$datas,'search'); $datas = array(); foreach($result_datas2 as $_key=>$_value) { if($_value['modelid']) continue; $datas[$_value['typedir']] = $_value['typeid']; $search_model[$_value['typedir']]['typeid'] = $_value['typeid']; $search_model[$_value['typedir']]['name'] = $_value['name']; } setcache('type_module_'.$this->siteid,$datas,'search'); //搜索header头中使用类型缓存 setcache('search_model_'.$this->siteid,$search_model,'search'); return true; } } ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#name").formValidator({onshow:"<?php echo L("input").L('type_name')?>",onfocus:"<?php echo L("input").L('type_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('type_name')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('type_name').L('format_incorrect', '','member')?>"}); }) //--> </script> <div class="pad-lr-10"> <form action="?m=search&c=search_type&a=edit" method="post" id="myform"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('select_module_name')?>:</th> <td class="y-bg"><?php if($modelid && $typedir == 'yp') { $module = 'yp'; } elseif($modelid && $typedir != 'yp') { $module = 'content'; } else { $module = $module; } echo form::select($module_data,$module,'name="module" onchange="change_module(this.value)" disabled')?></td> <input name="module" type="hidden" value="<?php echo $module?>"><input name="typedir" type="hidden" value="<?php echo $typedir?>"> </tr> <?php if($modelid && $typedir != 'yp') {?> <tr id="modelid_display"> <th width="120"><?php echo L('select_model_name')?>:</th> <td class="y-bg"><?php echo form::select($model_data,$modelid,'name="info[modelid]"')?></td> </tr> <?php }?> <?php if($modelid && $typedir == 'yp') {?> <tr id="yp_modelid_display"> <th width="120"><?php echo L('select_model_name')?>:</th> <td class="y-bg"><?php echo form::select($yp_model_data,$modelid,'name="info[yp_modelid]"')?></td> </tr> <?php }?> <tr> <th width="120"><?php echo L('type_name')?>:</th> <td class="y-bg"><input type="text" class="input-text" name="info[name]" id="name" size="30" value="<?php echo $name?>"/></td> </tr> <tr> <th><?php echo L('description')?>:</th> <td class="y-bg"><textarea name="info[description]" maxlength="255" style="width:300px;height:60px;"><?php echo $description?></textarea></td> </tr> </table> <div class="bk15"></div> <input type="hidden" name="typeid" value="<?php echo $typeid?>"> <input type="submit" class="dialog" id="dosubmit" name="dosubmit" value="<?php echo L('submit')?>" /> </form> </div> <SCRIPT LANGUAGE="JavaScript"> <!-- function change_module(module) { redirect('?m=search&c=search_type&a=edit&typeid=<?php echo $typeid?>&module='+module+'&pc_hash=<?php echo $_SESSION['pc_hash']?>'); } //--> </SCRIPT> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin');?> <form name="myform" action="?m=search&c=search_type&a=listorder" method="post"> <div class="pad_10"> <div class="table-list"> <div class="explain-col"> <?php echo L('searh_notice')?> </div> <div class="bk10"></div> <table width="100%" cellspacing="0" > <thead> <tr> <th width="55"><?php echo L('sort')?></td> <th width="35">ID</th> <th width="120"><?php echo L('catname')?></th> <th width="80"><?php echo L('modulename')?></th> <th width="80"><?php echo L('modlename')?></th> <th width="*"><?php echo L('catdescription')?></th> <th width="80"><?php echo L('opreration')?></th> </tr> </thead> <tbody> <?php foreach($datas as $r) { ?> <tr> <td align="center"><input type="text" name="listorders[<?php echo $r['typeid']?>]" value="<?php echo $r['listorder']?>" size="3" class='input-text-c'></td> <td align="center"><?php echo $r['typeid']?></td> <td align="center"><?php echo $r['name']?></td> <td align="center"><?php echo $r['modelid'] && $r['typedir'] !='yp' ? L('content_module') : $r['typedir'];?></td> <td align="center"><?php echo $this->model[$r['modelid']]['name'] ? $this->model[$r['modelid']]['name'] : $this->yp_model[$r['modelid']]['name']?></td> <td ><?php echo $r['description']?></td> <td align="center"><a href="javascript:edit('<?php echo $r['typeid']?>','<?php echo $r['name']?>')"><?php echo L('modify')?></a> | <a href="?m=search&c=search_type&a=delete&typeid=<?php echo $r['typeid']?>" onclick="return confirm('<?php echo L('sure_delete', '', 'member')?>')"><?php echo L('delete')?></a> </td> </tr> <?php } ?> </tbody> </table> <div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('listorder')?>" /></div> </div> </div> <div id="pages"><?php echo $pages;?></div> </div> </form> <script type="text/javascript"> <!-- function edit(id, name) { window.top.art.dialog({id:'edit'}).close(); window.top.art.dialog({title:'<?php echo L('edit_cat')?>《'+name+'》',id:'edit',iframe:'?m=search&c=search_type&a=edit&typeid='+id,width:'580',height:'240'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } function data_delete(obj,id,name){ window.top.art.dialog({content:name, fixed:true, style:'confirm', id:'data_delete'}, function(){ $.get('?m=search&c=search_type&a=delete&typeid='+id+'&pc_hash='+pc_hash,function(data){ if(data) { $(obj).parent().parent().fadeOut("slow"); } }) }, function(){}); }; //--> </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <form method="post" action="?m=search&c=search_admin&a=setting"> <div class="pad_10"> <div class="col-tab"> <ul class="tabBut cu-li"> <li id="tab_setting_1" class="on" onclick="SwapTab('setting','on','',2,1);"><?php echo L('basic_setting')?></li> <li id="tab_setting_2" onclick="SwapTab('setting','on','',2,2);"><?php echo L('sphinx_setting')?></li> </ul> <div id="div_setting_1" class="contentList pad-10"> <table width="100%" class="table_form"> <tr> <th width="200"><?php echo L('enable_search')?></th> <td class="y-bg"> <input type='radio' name='setting[fulltextenble]' value='1' <?php if($fulltextenble == 1) {?>checked<?php }?>> <?php echo L('yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[fulltextenble]' value='0' <?php if($fulltextenble == 0) {?>checked<?php }?>> <?php echo L('no')?></td> </tr> <tr> <th width="200"><?php echo L('relationenble')?></th> <td class="y-bg"> <input type='radio' name='setting[relationenble]' value='1' <?php if($relationenble == 1) {?>checked<?php }?>> <?php echo L('yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[relationenble]' value='0' <?php if($relationenble == 0) {?>checked<?php }?>> <?php echo L('no')?> <?php echo L('relationenble_note')?></td> </tr> <tr> <th width="200"><?php echo L('suggestenable')?></th> <td class="y-bg"> <input type='radio' name='setting[suggestenable]' value='1' <?php if($suggestenable == 1) {?>checked<?php }?>> <?php echo L('yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[suggestenable]' value='0' <?php if($suggestenable == 0) {?>checked<?php }?>> <?php echo L('no')?> <?php echo L('suggestenable_note')?></td> </tr> </table> </div> <div id="div_setting_2" class="contentList pad-10 hidden"> <table width="100%" class="table_form"> <tr> <th width="200"><?php echo L('sphinxenable')?></th> <td class="y-bg"> <input type='radio' name='setting[sphinxenable]' value='1' <?php if($sphinxenable == 1) {?>checked<?php }?>> <?php echo L('yes')?>&nbsp;&nbsp;&nbsp;&nbsp; <input type='radio' name='setting[sphinxenable]' value='0' <?php if($sphinxenable == 0) {?>checked<?php }?>> <?php echo L('no')?> </td> </tr> <tr> <th><?php echo L('host')?></th> <td class="y-bg"> <input name="setting[sphinxhost]" id="sphinxhost" value="<?php echo $sphinxhost?>" type="text" class="input-text"></td> </tr> <tr> <th><?php echo L('port')?></th> <td class="y-bg"><input name="setting[sphinxport]" id="sphinxport" value="<?php echo $sphinxport?>" type="text" class="input-text"></td> </tr> <tr> <th></th> <td class="y-bg"><input name="button" type="button" value="<?php echo L('test')?>" class="button" onclick="test_sphinx()"> <span id='testing'></span></td> </tr> </table> </div> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="button"> </div> </form> </body> <script type="text/javascript"> function SwapTab(name,cls_show,cls_hide,cnt,cur){ for(i=1;i<=cnt;i++){ if(i==cur){ $('#div_'+name+'_'+i).show(); $('#tab_'+name+'_'+i).attr('class',cls_show); }else{ $('#div_'+name+'_'+i).hide(); $('#tab_'+name+'_'+i).attr('class',cls_hide); } } } function showsmtp(obj,hiddenid){ hiddenid = hiddenid ? hiddenid : 'smtpcfg'; var status = $(obj).val(); if(status == 1) $("#"+hiddenid).show(); else $("#"+hiddenid).hide(); } function test_sphinx() { $('#testing').html('<?php echo L('testing')?>'); $.post('?m=search&c=search_admin&a=public_test_sphinx',{sphinxhost:$('#sphinxhost').val(),sphinxport:$('#sphinxport').val()}, function(data){ message = ''; if(data == 1) { message = '<?php echo L('testsuccess')?>'; } else if(data == -1) { message = '<?php echo L('hostempty')?>'; } else if(data == -2) { message = '<?php echo L('portempty')?>'; } else { message = data; } $('#testing').html(message); //window.top.art.dialog({content:message,lock:true,width:'200',height:'50'},function(){}); }); } </script> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin');?> <div class="pad-10"> <div class="explain-col"> <form action="" method="get"> <input type="hidden" name="m" value="search"> <input type="hidden" name="c" value="search_admin"> <input type="hidden" name="a" value="createindex"> <input type="hidden" name="menuid" value="909"> <?php echo L('re_index_note');?> <input type="text" name="pagesize" value="100" size="5"> <?php echo L('tiao');?> <input type="submit" name="dosubmit" class="button" value="<?php echo L('confirm_reindex');?>"></form> </div> <script language="JavaScript"> <!-- window.top.$('#display_center_id').css('display','none'); //--> </script>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#name").formValidator({onshow:"<?php echo L("input").L('type_name')?>",onfocus:"<?php echo L("input").L('type_name')?>",oncorrect:"<?php echo L('input_right');?>"}).inputValidator({min:1,onerror:"<?php echo L("input").L('type_name')?>"}).regexValidator({regexp:"ps_username",datatype:"enum",onerror:"<?php echo L('type_name').L('format_incorrect', '','member')?>"}); }) //--> </script> <div class="pad-lr-10"> <form action="?m=search&c=search_type&a=add" method="post" id="myform"> <table width="100%" class="table_form"> <tr> <th width="120"><?php echo L('select_module_name')?>:</th> <td class="y-bg"><?php echo form::select($module_data,$_GET['module'],'name="module" onchange="change_module(this.value)"')?></td> </tr> <?php if($_GET['module'] == 'content') {?> <tr id="modelid_display"> <th width="120"><?php echo L('select_model_name')?>:</th> <td class="y-bg"><?php echo form::select($model_data,'','name="info[modelid]"')?></td> </tr> <?php }?> <?php if($_GET['module'] == 'yp') {?> <tr id="yp_modelid_display"> <th width="120"><?php echo L('select_model_name')?>:</th> <td class="y-bg"><?php echo form::select($yp_model_data,'','name="info[yp_modelid]"')?></td> </tr> <?php }?> <tr> <th width="120"><?php echo L('type_name')?>:</th> <td class="y-bg"><input type="text" class="input-text" name="info[name]" id="name" size="30" /></td> </tr> <tr> <th><?php echo L('description')?>:</th> <td class="y-bg"><textarea name="info[description]" maxlength="255" style="width:300px;height:60px;"></textarea></td> </tr> </table> <div class="bk15"></div> <input type="submit" class="dialog" id="dosubmit" name="dosubmit" value="<?php echo L('submit')?>" /> </form> </div> <SCRIPT LANGUAGE="JavaScript"> <!-- function change_module(module) { redirect('?m=search&c=search_type&a=add&module='+module+'&pc_hash=<?php echo $_SESSION['pc_hash']?>'); } //--> </SCRIPT> </body> </html>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); pc_base::load_sys_class('form','',0); class search_admin extends admin { function __construct() { parent::__construct(); $this->siteid = $this->get_siteid(); $this->db = pc_base::load_model('search_model'); $this->module_db = pc_base::load_model('module_model'); $this->type_db = pc_base::load_model('type_model'); } public function setting() { $siteid = get_siteid(); if(isset($_POST['dosubmit'])) { //合并数据库缓存与新提交缓存 $r = $this->module_db->get_one(array('module'=>'search')); $search_setting = string2array($r['setting']); $search_setting[$siteid] = $_POST['setting']; $setting = array2string($search_setting); setcache('search', $search_setting); $this->module_db->update(array('setting'=>$setting),array('module'=>'search')); showmessage(L('operation_success'),HTTP_REFERER); } else { $r = $this->module_db->get_one(array('module'=>'search')); $setting = string2array($r['setting']); extract($setting[$siteid]); $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=search&c=search_type&a=add\', title:\''.L('add_search_type').'\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_search_type')); include $this->admin_tpl('setting'); } } /** * 创建索引 */ public function createindex() { if(isset($_GET['dosubmit'])) { //重建索引首先清空表所有数据,然后根据搜索类型接口重新全部重建索引 if(!isset($_GET['have_truncate'])) { $db_tablepre = $this->db->db_tablepre; //删除该站点全文索引 $this->db->delete(array('siteid'=>$this->siteid)); $types = $this->type_db->select(array('siteid'=> $this->siteid,'module'=>'search')); setcache('search_types',$types, 'search'); } else{ $types = getcache('search_types', 'search'); } //$key typeid 的索引 $key = isset($_GET['key']) ? intval($_GET['key']) : 0; foreach ($types as $_k=>$_v) { if($key==$_k) { $typeid = $_v['typeid']; if($_v['modelid']) { if ($_v['typedir']!=='yp') { $search_api = pc_base::load_app_class('search_api','content'); } else { $search_api = pc_base::load_app_class('search_api',$_v['typedir']); } if(!isset($_GET['total'])) { $total = $search_api->total($_v['modelid']); } else { $total = intval($_GET['total']); $search_api->set_model($_v['modelid']); } } else { $module = trim($_v['typedir']); $search_api = pc_base::load_app_class('search_api',$module); if(!isset($_GET['total'])) { $total = $search_api->total(); } else { $total = intval($_GET['total']); } } $pagesize = $_GET['pagesize'] ? intval($_GET['pagesize']) : 50; $page = max(intval($_GET['page']), 1); $pages = ceil($total/$pagesize); $datas = $search_api->fulltext_api($pagesize,$page); foreach ($datas as $id=>$r) { $this->db->update_search($typeid ,$id, $r['fulltextcontent'],$r['title'],$r['adddate'], 1); } $page++; if($pages>=$page) showmessage("正在更新 <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total} - 当前第 <font color='red'>{$page}</font> 页","?m=search&c=search_admin&a=createindex&menuid=909&page={$page}&total={$total}&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1"); $key++; showmessage("开始更新: <span style='color:#ff0000;font-size:14px;text-decoration:underline;' >{$_v['name']}</span> - 总数:{$total}条","?m=search&c=search_admin&a=createindex&menuid=909&page=1&key={$key}&pagesize={$pagesize}&have_truncate=1&dosubmit=1"); } } showmessage('全站索引更新完成','blank'); } else { $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=search&c=search_type&a=add\', title:\''.L('add_search_type').'\', width:\'580\', height:\'240\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('add_search_type')); include $this->admin_tpl('createindex'); } } public function public_test_sphinx() { $sphinxhost = !empty($_POST['sphinxhost']) ? $_POST['sphinxhost'] : exit('-1'); $sphinxport = !empty($_POST['sphinxport']) ? intval($_POST['sphinxport']) : exit('-2'); $fp = @fsockopen($sphinxhost, $sphinxport, $errno, $errstr , 2); if (!$fp) { exit($errno.':'.$errstr); } else { exit('1'); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_sys_class('form','',0); pc_base::load_sys_class('format','',0); class index { function __construct() { $this->db = pc_base::load_model('search_model'); $this->content_db = pc_base::load_model('content_model'); } /** * 关键词搜索 */ public function init() { //获取siteid $siteid = isset($_REQUEST['siteid']) && trim($_REQUEST['siteid']) ? intval($_REQUEST['siteid']) : 1; //搜索配置 $search_setting = getcache('search'); $setting = $search_setting[$siteid]; $search_model = getcache('search_model_'.$siteid); $type_module = getcache('type_module_'.$siteid); if(isset($_GET['q'])) { if(trim($_GET['q'])=='') { header('Location: '.APP_PATH.'index.php?m=search');exit; } $typeid = empty($_GET['typeid']) ? 48 : intval($_GET['typeid']); $time = empty($_GET['time']) ? 'all' : trim($_GET['time']); $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $pagesize = 10; $q = safe_replace(trim($_GET['q'])); $q = htmlspecialchars(strip_tags($q)); $q = str_replace('%', '', $q); //过滤'%',用户全文搜索 $search_q = $q; //搜索原内容 //按时间搜索 if($time == 'day') { $search_time = SYS_TIME - 86400; $sql_time = ' AND adddate > '.$search_time; } elseif($time == 'week') { $search_time = SYS_TIME - 604800; $sql_time = ' AND adddate > '.$search_time; } elseif($time == 'month') { $search_time = SYS_TIME - 2592000; $sql_time = ' AND adddate > '.$search_time; } elseif($time == 'year') { $search_time = SYS_TIME - 31536000; $sql_time = ' AND adddate > '.$search_time; } else { $search_time = 0; $sql_time = ''; } if($page==1 && !$setting['sphinxenable']) { //精确搜索 $commend = $this->db->get_one("`typeid` = '$typeid' $sql_time AND `data` like '%$q%'"); } else { $commend = ''; } //如果开启sphinx if($setting['sphinxenable']) { $sphinx = pc_base::load_app_class('search_interface', '', 0); $sphinx = new search_interface(); $offset = $pagesize*($page-1); $res = $sphinx->search($q, array($siteid), array($typeid), array($search_time, SYS_TIME), $offset, $pagesize, '@weight desc'); $totalnums = $res['total']; //如果结果不为空 if(!empty($res['matches'])) { $result = $res['matches']; } } else { pc_base::load_sys_class('segment', '', 0); $segment = new segment(); //分词结果 $segment_q = $segment->get_keyword($segment->split_result($q)); //如果分词结果为空 if(!empty($segment_q)) { $sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND MATCH (`data`) AGAINST ('$segment_q' IN BOOLEAN MODE)"; } else { $sql = "`siteid`= '$siteid' AND `typeid` = '$typeid' $sql_time AND `data` like '%$q%'"; } $result = $this->db->listinfo($sql, 'searchid DESC', $page, 10); } //如果开启相关搜索功能 if($setting['relationenble']) { //如果关键词长度在8-16之间,保存关键词作为relation search $this->keyword_db = pc_base::load_model('search_keyword_model'); if(strlen($q) < 17 && strlen($q) > 5 && !empty($segment_q)) { $res = $this->keyword_db->get_one(array('keyword'=>$q)); if($res) { //关键词搜索数+1 //$this->keyword_db->update(array('searchnums'=>'+=1'), array('keyword'=>$q)); } else { //关键词转换为拼音 pc_base::load_sys_func('iconv'); $pinyin = gbk_to_pinyin($q); if(is_array($pinyin)) { $pinyin = implode('', $pinyin); } $this->keyword_db->insert(array('keyword'=>$q, 'searchnums'=>1, 'data'=>$segment_q, 'pinyin'=>$pinyin)); } } //相关搜索 if(!empty($segment_q)) { $relation_q = str_replace(' ', '%', $segment_q); } else { $relation_q = $q; } $relation = $this->keyword_db->select("MATCH (`data`) AGAINST ('%$relation_q%' IN BOOLEAN MODE)", '*', 10, 'searchnums DESC'); } //如果结果不为空 if(!empty($result) || !empty($commend['id'])) { //开启sphinx后文章id取法不同 if($setting['sphinxenable']) { foreach($result as $_v) { $sids[] = $_v['attrs']['id']; } } else { foreach($result as $_v) { $sids[] = $_v['id']; } } if(!empty($commend['id'])) { $sids[] = $commend['id']; } $sids = array_unique($sids); $where = to_sqls($sids, '', 'id'); //获取模型id $model_type_cache = getcache('type_model_'.$siteid,'search'); $model_type_cache = array_flip($model_type_cache); $modelid = $model_type_cache[$typeid]; //是否读取其他模块接口 if($modelid) { $this->content_db->set_model($modelid); /** * 如果表名为空,则为黄页模型 */ if(empty($this->content_db->model_tablename)) { $this->content_db = pc_base::load_model('yp_content_model'); $this->content_db->set_model($modelid); } if($setting['sphinxenable']) { $data = $this->content_db->listinfo($where, 'id DESC', 1, $pagesize); $pages = pages($totalnums, $page, $pagesize); } else { $data = $this->content_db->select($where, '*'); $pages = $this->db->pages; $totalnums = $this->db->number; } //如果分词结果为空 if(!empty($segment_q)) { $replace = explode(' ', $segment_q); foreach($replace as $replace_arr_v) { $replace_arr[] = '<font color=red>'.$replace_arr_v.'</font>'; } foreach($data as $_k=>$_v) { $data[$_k]['title'] = str_replace($replace, $replace_arr, $_v['title']); $data[$_k]['description'] = str_replace($replace, $replace_arr, $_v['description']); } } else { foreach($data as $_k=>$_v) { $data[$_k]['title'] = str_replace($q, '<font color=red>'.$q.'</font>', $_v['title']); $data[$_k]['description'] = str_replace($q, '<font color=red>'.$q.'</font>', $_v['description']); } } } else { //读取专辑搜索接口 $special_api = pc_base::load_app_class('search_api', 'special'); $data = $special_api->get_search_data($sids); } } $execute_time = execute_time(); $pages = isset($pages) ? $pages : ''; $totalnums = isset($totalnums) ? $totalnums : 0; $data = isset($data) ? $data : ''; include template('search','list'); } else { include template('search','index'); } } public function public_get_suggest_keyword() { $url = $_GET['url'].'&q='.$_GET['q']; $res = @file_get_contents($url); if(CHARSET != 'gbk') { $res = iconv('gbk', CHARSET, $res); } echo $res; } /** * 提示搜索接口 * TODO 暂时未启用,用的是google的接口 */ public function public_suggest_search() { //关键词转换为拼音 pc_base::load_sys_func('iconv'); $pinyin = gbk_to_pinyin($q); if(is_array($pinyin)) { $pinyin = implode('', $pinyin); } $this->keyword_db = pc_base::load_model('search_keyword_model'); $suggest = $this->keyword_db->select("pinyin like '$pinyin%'", '*', 10, 'searchnums DESC'); foreach($suggest as $v) { echo $v['keyword']."\n"; } } } ?>
PHP
<?php /** * 搜索接口 * */ class search_interface { public function __construct() { //初始化sphinx pc_base::load_app_class('sphinxapi', '', 0); $this->cl = new SphinxClient(); $siteid = get_siteid(); $search_setting = getcache('search'); $setting = $search_setting[$siteid]; $mode = SPH_MATCH_EXTENDED2; //匹配模式 $host = $setting['sphinxhost']; //服务ip $port = intval($setting['sphinxport']); //服务端口 $ranker = SPH_RANK_PROXIMITY_BM25; //统计相关度计算模式,仅使用BM25评分计算 $this->cl->SetServer($host, $port); $this->cl->SetConnectTimeout(1); $this->cl->SetArrayResult(true); $this->cl->SetMatchMode($mode); $this->cl->SetRankingMode($ranker); } /** * 搜索 * @param string $q 关键词 类似sql like'%$q%' * @param array $siteids 站点id数组 * @param array $typeids 类型ids 类似sql IN('') * @param array $adddate 时间范围数组 类似sql between start AND end 格式:array('start','end'); * @param int $offset 偏移量 * @param int $limit 匹配项数目限制 类似sql limit $offset, $limit * @param string $orderby 排序字段 类似sql order by $orderby {id:文章id,weight:权重} */ public function search($q, $siteids=array(1), $typeids='', $adddate='', $offset=0, $limit=20, $orderby='@id desc') { if(CHARSET != 'utf-8') { $utf8_q = iconv(CHARSET, 'utf-8', $q); } if($orderby) { //按一种类似SQL的方式将列组合起来,升序或降序排列。 $this->cl->SetSortMode(SPH_SORT_EXTENDED, $orderby); } if($limit) { $this->cl->SetLimits($offset, $limit, ($limit>1000) ? $limit : 1000); } //过滤类型 if($typeids) { $this->cl->SetFilter('typeid', $typeids); } //过滤站点 if($siteids) { $this->cl->SetFilter('siteid', $siteids); } //过滤时间 if($adddate) { $this->cl->SetFilterRange('adddate', $adddate[0], $adddate[1], false); } $res = $this->cl->Query($utf8_q, 'main, delta'); return $res; } }
PHP
<?php /** * sphinx搜索接口类 */ // // $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $ // // // Copyright (c) 2001-2008, Andrew Aksyonoff. All rights reserved. // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License. You should have // received a copy of the GPL license along with this program; if you // did not, you can find it at http://www.gnu.org/ // ///////////////////////////////////////////////////////////////////////////// // PHP version of Sphinx searchd client (PHP API) ///////////////////////////////////////////////////////////////////////////// /// known searchd commands define ( "SEARCHD_COMMAND_SEARCH", 0 ); define ( "SEARCHD_COMMAND_EXCERPT", 1 ); define ( "SEARCHD_COMMAND_UPDATE", 2 ); define ( "SEARCHD_COMMAND_KEYWORDS",3 ); define ( "SEARCHD_COMMAND_PERSIST", 4 ); define ( "SEARCHD_COMMAND_STATUS", 5 ); define ( "SEARCHD_COMMAND_QUERY", 6 ); /// current client-side command implementation versions define ( "VER_COMMAND_SEARCH", 0x116 ); define ( "VER_COMMAND_EXCERPT", 0x100 ); define ( "VER_COMMAND_UPDATE", 0x102 ); define ( "VER_COMMAND_KEYWORDS", 0x100 ); define ( "VER_COMMAND_STATUS", 0x100 ); define ( "VER_COMMAND_QUERY", 0x100 ); /// known searchd status codes define ( "SEARCHD_OK", 0 ); define ( "SEARCHD_ERROR", 1 ); define ( "SEARCHD_RETRY", 2 ); define ( "SEARCHD_WARNING", 3 ); /// known match modes define ( "SPH_MATCH_ALL", 0 ); define ( "SPH_MATCH_ANY", 1 ); define ( "SPH_MATCH_PHRASE", 2 ); define ( "SPH_MATCH_BOOLEAN", 3 ); define ( "SPH_MATCH_EXTENDED", 4 ); define ( "SPH_MATCH_FULLSCAN", 5 ); define ( "SPH_MATCH_EXTENDED2", 6 ); // extended engine V2 (TEMPORARY, WILL BE REMOVED) /// known ranking modes (ext2 only) define ( "SPH_RANK_PROXIMITY_BM25", 0 ); ///< default mode, phrase proximity major factor and BM25 minor one define ( "SPH_RANK_BM25", 1 ); ///< statistical mode, BM25 ranking only (faster but worse quality) define ( "SPH_RANK_NONE", 2 ); ///< no ranking, all matches get a weight of 1 define ( "SPH_RANK_WORDCOUNT", 3 ); ///< simple word-count weighting, rank is a weighted sum of per-field keyword occurence counts define ( "SPH_RANK_PROXIMITY", 4 ); define ( "SPH_RANK_MATCHANY", 5 ); define ( "SPH_RANK_FIELDMASK", 6 ); /// known sort modes define ( "SPH_SORT_RELEVANCE", 0 ); define ( "SPH_SORT_ATTR_DESC", 1 ); define ( "SPH_SORT_ATTR_ASC", 2 ); define ( "SPH_SORT_TIME_SEGMENTS", 3 ); define ( "SPH_SORT_EXTENDED", 4 ); define ( "SPH_SORT_EXPR", 5 ); /// known filter types define ( "SPH_FILTER_VALUES", 0 ); define ( "SPH_FILTER_RANGE", 1 ); define ( "SPH_FILTER_FLOATRANGE", 2 ); /// known attribute types define ( "SPH_ATTR_INTEGER", 1 ); define ( "SPH_ATTR_TIMESTAMP", 2 ); define ( "SPH_ATTR_ORDINAL", 3 ); define ( "SPH_ATTR_BOOL", 4 ); define ( "SPH_ATTR_FLOAT", 5 ); define ( "SPH_ATTR_BIGINT", 6 ); define ( "SPH_ATTR_MULTI", 0x40000000 ); /// known grouping functions define ( "SPH_GROUPBY_DAY", 0 ); define ( "SPH_GROUPBY_WEEK", 1 ); define ( "SPH_GROUPBY_MONTH", 2 ); define ( "SPH_GROUPBY_YEAR", 3 ); define ( "SPH_GROUPBY_ATTR", 4 ); define ( "SPH_GROUPBY_ATTRPAIR", 5 ); // important properties of PHP's integers: // - always signed (one bit short of PHP_INT_SIZE) // - conversion from string to int is saturated // - float is double // - div converts arguments to floats // - mod converts arguments to ints // the packing code below works as follows: // - when we got an int, just pack it // if performance is a problem, this is the branch users should aim for // // - otherwise, we got a number in string form // this might be due to different reasons, but we assume that this is // because it didn't fit into PHP int // // - factor the string into high and low ints for packing // - if we have bcmath, then it is used // - if we don't, we have to do it manually (this is the fun part) // // - x64 branch does factoring using ints // - x32 (ab)uses floats, since we can't fit unsigned 32-bit number into an int // // unpacking routines are pretty much the same. // - return ints if we can // - otherwise format number into a string /// pack 64-bit signed function sphPackI64 ( $v ) { assert ( is_numeric($v) ); // x64 if ( PHP_INT_SIZE>=8 ) { $v = (int)$v; return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); } // x32, int if ( is_int($v) ) return pack ( "NN", $v < 0 ? -1 : 0, $v ); // x32, bcmath if ( function_exists("bcmul") ) { if ( bccomp ( $v, 0 ) == -1 ) $v = bcadd ( "18446744073709551616", $v ); $h = bcdiv ( $v, "4294967296", 0 ); $l = bcmod ( $v, "4294967296" ); return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = abs((float)substr($v, $p)); $hi = abs((float)substr($v, 0, $p)); $m = $lo + $hi*1316134912.0; // (10 ^ 13) % (1 << 32) = 1316134912 $q = floor($m/4294967296.0); $l = $m - ($q*4294967296.0); $h = $hi*2328.0 + $q; // (10 ^ 13) / (1 << 32) = 2328 if ( $v<0 ) { if ( $l==0 ) $h = 4294967296.0 - $h; else { $h = 4294967295.0 - $h; $l = 4294967296.0 - $l; } } return pack ( "NN", $h, $l ); } /// pack 64-bit unsigned function sphPackU64 ( $v ) { assert ( is_numeric($v) ); // x64 if ( PHP_INT_SIZE>=8 ) { assert ( $v>=0 ); // x64, int if ( is_int($v) ) return pack ( "NN", $v>>32, $v&0xFFFFFFFF ); // x64, bcmath if ( function_exists("bcmul") ) { $h = bcdiv ( $v, 4294967296, 0 ); $l = bcmod ( $v, 4294967296 ); return pack ( "NN", $h, $l ); } // x64, no-bcmath $p = max ( 0, strlen($v) - 13 ); $lo = (int)substr ( $v, $p ); $hi = (int)substr ( $v, 0, $p ); $m = $lo + $hi*1316134912; $l = $m % 4294967296; $h = $hi*2328 + (int)($m/4294967296); return pack ( "NN", $h, $l ); } // x32, int if ( is_int($v) ) return pack ( "NN", 0, $v ); // x32, bcmath if ( function_exists("bcmul") ) { $h = bcdiv ( $v, "4294967296", 0 ); $l = bcmod ( $v, "4294967296" ); return pack ( "NN", (float)$h, (float)$l ); // conversion to float is intentional; int would lose 31st bit } // x32, no-bcmath $p = max(0, strlen($v) - 13); $lo = (float)substr($v, $p); $hi = (float)substr($v, 0, $p); $m = $lo + $hi*1316134912.0; $q = floor($m / 4294967296.0); $l = $m - ($q * 4294967296.0); $h = $hi*2328.0 + $q; return pack ( "NN", $h, $l ); } // unpack 64-bit unsigned function sphUnpackU64 ( $v ) { list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); if ( PHP_INT_SIZE>=8 ) { if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again if ( $lo<0 ) $lo += (1<<32); // x64, int if ( $hi<=2147483647 ) return ($hi<<32) + $lo; // x64, bcmath if ( function_exists("bcmul") ) return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); // x64, no-bcmath $C = 100000; $h = ((int)($hi / $C) << 32) + (int)($lo / $C); $l = (($hi % $C) << 32) + ($lo % $C); if ( $l>$C ) { $h += (int)($l / $C); $l = $l % $C; } if ( $h==0 ) return $l; return sprintf ( "%d%05d", $h, $l ); } // x32, int if ( $hi==0 ) { if ( $lo>0 ) return $lo; return sprintf ( "%u", $lo ); } $hi = sprintf ( "%u", $hi ); $lo = sprintf ( "%u", $lo ); // x32, bcmath if ( function_exists("bcmul") ) return bcadd ( $lo, bcmul ( $hi, "4294967296" ) ); // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; $mq = floor($m/10000000.0); $l = $m - $mq*10000000.0; $h = $q*4294967296.0 + $r*429.0 + $mq; $h = sprintf ( "%.0f", $h ); $l = sprintf ( "%07.0f", $l ); if ( $h=="0" ) return sprintf( "%.0f", (float)$l ); return $h . $l; } // unpack 64-bit signed function sphUnpackI64 ( $v ) { list ( $hi, $lo ) = array_values ( unpack ( "N*N*", $v ) ); // x64 if ( PHP_INT_SIZE>=8 ) { if ( $hi<0 ) $hi += (1<<32); // because php 5.2.2 to 5.2.5 is totally fucked up again if ( $lo<0 ) $lo += (1<<32); return ($hi<<32) + $lo; } // x32, int if ( $hi==0 ) { if ( $lo>0 ) return $lo; return sprintf ( "%u", $lo ); } // x32, int elseif ( $hi==-1 ) { if ( $lo<0 ) return $lo; return sprintf ( "%.0f", $lo - 4294967296.0 ); } $neg = ""; $c = 0; if ( $hi<0 ) { $hi = ~$hi; $lo = ~$lo; $c = 1; $neg = "-"; } $hi = sprintf ( "%u", $hi ); $lo = sprintf ( "%u", $lo ); // x32, bcmath if ( function_exists("bcmul") ) return $neg . bcadd ( bcadd ( $lo, bcmul ( $hi, "4294967296" ) ), $c ); // x32, no-bcmath $hi = (float)$hi; $lo = (float)$lo; $q = floor($hi/10000000.0); $r = $hi - $q*10000000.0; $m = $lo + $r*4967296.0; $mq = floor($m/10000000.0); $l = $m - $mq*10000000.0 + $c; $h = $q*4294967296.0 + $r*429.0 + $mq; if ( $l==10000000 ) { $l = 0; $h += 1; } $h = sprintf ( "%.0f", $h ); $l = sprintf ( "%07.0f", $l ); if ( $h=="0" ) return $neg . sprintf( "%.0f", (float)$l ); return $neg . $h . $l; } function sphFixUint ( $value ) { if ( PHP_INT_SIZE>=8 ) { // x64 route, workaround broken unpack() in 5.2.2+ if ( $value<0 ) $value += (1<<32); return $value; } else { // x32 route, workaround php signed/unsigned braindamage return sprintf ( "%u", $value ); } } /// sphinx searchd client class class SphinxClient { var $_host; ///< searchd host (default is "localhost") var $_port; ///< searchd port (default is 9312) var $_offset; ///< how many records to seek from result-set start (default is 0) var $_limit; ///< how many records to return from result-set starting at offset (default is 20) var $_mode; ///< query matching mode (default is SPH_MATCH_ALL) var $_weights; ///< per-field weights (default is 1 for all fields) var $_sort; ///< match sorting mode (default is SPH_SORT_RELEVANCE) var $_sortby; ///< attribute to sort by (defualt is "") var $_min_id; ///< min ID to match (default is 0, which means no limit) var $_max_id; ///< max ID to match (default is 0, which means no limit) var $_filters; ///< search filters var $_groupby; ///< group-by attribute name var $_groupfunc; ///< group-by function (to pre-process group-by attribute value with) var $_groupsort; ///< group-by sorting clause (to sort groups in result set with) var $_groupdistinct;///< group-by count-distinct attribute var $_maxmatches; ///< max matches to retrieve var $_cutoff; ///< cutoff to stop searching at (default is 0) var $_retrycount; ///< distributed retries count var $_retrydelay; ///< distributed retries delay var $_anchor; ///< geographical anchor point var $_indexweights; ///< per-index weights var $_ranker; ///< ranking mode (default is SPH_RANK_PROXIMITY_BM25) var $_maxquerytime; ///< max query time, milliseconds (default is 0, do not limit) var $_fieldweights; ///< per-field-name weights var $_overrides; ///< per-query attribute values overrides var $_select; ///< select-list (attributes or expressions, with optional aliases) var $_error; ///< last error message var $_warning; ///< last warning message var $_connerror; ///< connection error vs remote error flag var $_reqs; ///< requests array for multi-query var $_mbenc; ///< stored mbstring encoding var $_arrayresult; ///< whether $result["matches"] should be a hash or an array var $_timeout; ///< connect timeout ///////////////////////////////////////////////////////////////////////////// // common stuff ///////////////////////////////////////////////////////////////////////////// /// create a new client object and fill defaults function SphinxClient () { // per-client-object settings $this->_host = "localhost"; $this->_port = 9312; $this->_path = false; $this->_socket = false; // per-query settings $this->_offset = 0; $this->_limit = 20; $this->_mode = SPH_MATCH_ALL; $this->_weights = array (); $this->_sort = SPH_SORT_RELEVANCE; $this->_sortby = ""; $this->_min_id = 0; $this->_max_id = 0; $this->_filters = array (); $this->_groupby = ""; $this->_groupfunc = SPH_GROUPBY_DAY; $this->_groupsort = "@group desc"; $this->_groupdistinct= ""; $this->_maxmatches = 1000; $this->_cutoff = 0; $this->_retrycount = 0; $this->_retrydelay = 0; $this->_anchor = array (); $this->_indexweights= array (); $this->_ranker = SPH_RANK_PROXIMITY_BM25; $this->_maxquerytime= 0; $this->_fieldweights= array(); $this->_overrides = array(); $this->_select = "*"; $this->_error = ""; // per-reply fields (for single-query case) $this->_warning = ""; $this->_connerror = false; $this->_reqs = array (); // requests storage (for multi-query case) $this->_mbenc = ""; $this->_arrayresult = false; $this->_timeout = 0; } function __destruct() { if ( $this->_socket !== false ) fclose ( $this->_socket ); } /// get last error message (string) function GetLastError () { return $this->_error; } /// get last warning message (string) function GetLastWarning () { return $this->_warning; } /// get last error flag (to tell network connection errors from searchd errors or broken responses) function IsConnectError() { return $this->_connerror; } /// set searchd host name (string) and port (integer) function SetServer ( $host, $port = 0 ) { assert ( is_string($host) ); if ( $host[0] == '/') { $this->_path = 'unix://' . $host; return; } if ( substr ( $host, 0, 7 )=="unix://" ) { $this->_path = $host; return; } assert ( is_int($port) ); $this->_host = $host; $this->_port = $port; $this->_path = ''; } /// set server connection timeout (0 to remove) function SetConnectTimeout ( $timeout ) { assert ( is_numeric($timeout) ); $this->_timeout = $timeout; } function _Send ( $handle, $data, $length ) { if ( feof($handle) || fwrite ( $handle, $data, $length ) !== $length ) { $this->_error = 'connection unexpectedly closed (timed out?)'; $this->_connerror = true; return false; } return true; } ///////////////////////////////////////////////////////////////////////////// /// enter mbstring workaround mode function _MBPush () { $this->_mbenc = ""; if ( ini_get ( "mbstring.func_overload" ) & 2 ) { $this->_mbenc = mb_internal_encoding(); mb_internal_encoding ( "latin1" ); } } /// leave mbstring workaround mode function _MBPop () { if ( $this->_mbenc ) mb_internal_encoding ( $this->_mbenc ); } /// connect to searchd server function _Connect () { if ( $this->_socket!==false ) { // we are in persistent connection mode, so we have a socket // however, need to check whether it's still alive if ( !@feof ( $this->_socket ) ) return $this->_socket; // force reopen $this->_socket = false; } $errno = 0; $errstr = ""; $this->_connerror = false; if ( $this->_path ) { $host = $this->_path; $port = 0; } else { $host = $this->_host; $port = $this->_port; } if ( $this->_timeout<=0 ) $fp = @fsockopen ( $host, $port, $errno, $errstr ); else $fp = @fsockopen ( $host, $port, $errno, $errstr, $this->_timeout ); if ( !$fp ) { if ( $this->_path ) $location = $this->_path; else $location = "{$this->_host}:{$this->_port}"; $errstr = trim ( $errstr ); $this->_error = "connection to $location failed (errno=$errno, msg=$errstr)"; $this->_connerror = true; return false; } // send my version // this is a subtle part. we must do it before (!) reading back from searchd. // because otherwise under some conditions (reported on FreeBSD for instance) // TCP stack could throttle write-write-read pattern because of Nagle. if ( !$this->_Send ( $fp, pack ( "N", 1 ), 4 ) ) { fclose ( $fp ); $this->_error = "failed to send client protocol version"; return false; } // check version list(,$v) = unpack ( "N*", fread ( $fp, 4 ) ); $v = (int)$v; if ( $v<1 ) { fclose ( $fp ); $this->_error = "expected searchd protocol version 1+, got version '$v'"; return false; } return $fp; } /// get and check response packet from searchd server function _GetResponse ( $fp, $client_ver ) { $response = ""; $len = 0; $header = fread ( $fp, 8 ); if ( strlen($header)==8 ) { list ( $status, $ver, $len ) = array_values ( unpack ( "n2a/Nb", $header ) ); $left = $len; while ( $left>0 && !feof($fp) ) { $chunk = fread ( $fp, $left ); if ( $chunk ) { $response .= $chunk; $left -= strlen($chunk); } } } if ( $this->_socket === false ) fclose ( $fp ); // check response $read = strlen ( $response ); if ( !$response || $read!=$len ) { $this->_error = $len ? "failed to read searchd response (status=$status, ver=$ver, len=$len, read=$read)" : "received zero-sized searchd response"; return false; } // check status if ( $status==SEARCHD_WARNING ) { list(,$wlen) = unpack ( "N*", substr ( $response, 0, 4 ) ); $this->_warning = substr ( $response, 4, $wlen ); return substr ( $response, 4+$wlen ); } if ( $status==SEARCHD_ERROR ) { $this->_error = "searchd error: " . substr ( $response, 4 ); return false; } if ( $status==SEARCHD_RETRY ) { $this->_error = "temporary searchd error: " . substr ( $response, 4 ); return false; } if ( $status!=SEARCHD_OK ) { $this->_error = "unknown status code '$status'"; return false; } // check version if ( $ver<$client_ver ) { $this->_warning = sprintf ( "searchd command v.%d.%d older than client's v.%d.%d, some options might not work", $ver>>8, $ver&0xff, $client_ver>>8, $client_ver&0xff ); } return $response; } ///////////////////////////////////////////////////////////////////////////// // searching ///////////////////////////////////////////////////////////////////////////// /// set offset and count into result set, /// and optionally set max-matches and cutoff limits function SetLimits ( $offset, $limit, $max=0, $cutoff=0 ) { assert ( is_int($offset) ); assert ( is_int($limit) ); assert ( $offset>=0 ); assert ( $limit>0 ); assert ( $max>=0 ); $this->_offset = $offset; $this->_limit = $limit; if ( $max>0 ) $this->_maxmatches = $max; if ( $cutoff>0 ) $this->_cutoff = $cutoff; } /// set maximum query time, in milliseconds, per-index /// integer, 0 means "do not limit" function SetMaxQueryTime ( $max ) { assert ( is_int($max) ); assert ( $max>=0 ); $this->_maxquerytime = $max; } /// set matching mode function SetMatchMode ( $mode ) { assert ( $mode==SPH_MATCH_ALL || $mode==SPH_MATCH_ANY || $mode==SPH_MATCH_PHRASE || $mode==SPH_MATCH_BOOLEAN || $mode==SPH_MATCH_EXTENDED || $mode==SPH_MATCH_FULLSCAN || $mode==SPH_MATCH_EXTENDED2 ); $this->_mode = $mode; } /// set ranking mode function SetRankingMode ( $ranker ) { assert ( $ranker==SPH_RANK_PROXIMITY_BM25 || $ranker==SPH_RANK_BM25 || $ranker==SPH_RANK_NONE || $ranker==SPH_RANK_WORDCOUNT || $ranker==SPH_RANK_PROXIMITY ); $this->_ranker = $ranker; } /// set matches sorting mode function SetSortMode ( $mode, $sortby="" ) { assert ( $mode==SPH_SORT_RELEVANCE || $mode==SPH_SORT_ATTR_DESC || $mode==SPH_SORT_ATTR_ASC || $mode==SPH_SORT_TIME_SEGMENTS || $mode==SPH_SORT_EXTENDED || $mode==SPH_SORT_EXPR ); assert ( is_string($sortby) ); assert ( $mode==SPH_SORT_RELEVANCE || strlen($sortby)>0 ); $this->_sort = $mode; $this->_sortby = $sortby; } /// bind per-field weights by order /// DEPRECATED; use SetFieldWeights() instead function SetWeights ( $weights ) { assert ( is_array($weights) ); foreach ( $weights as $weight ) assert ( is_int($weight) ); $this->_weights = $weights; } /// bind per-field weights by name function SetFieldWeights ( $weights ) { assert ( is_array($weights) ); foreach ( $weights as $name=>$weight ) { assert ( is_string($name) ); assert ( is_int($weight) ); } $this->_fieldweights = $weights; } /// bind per-index weights by name function SetIndexWeights ( $weights ) { assert ( is_array($weights) ); foreach ( $weights as $index=>$weight ) { assert ( is_string($index) ); assert ( is_int($weight) ); } $this->_indexweights = $weights; } /// set IDs range to match /// only match records if document ID is beetwen $min and $max (inclusive) function SetIDRange ( $min, $max ) { assert ( is_numeric($min) ); assert ( is_numeric($max) ); assert ( $min<=$max ); $this->_min_id = $min; $this->_max_id = $max; } /// set values set filter /// only match records where $attribute value is in given set function SetFilter ( $attribute, $values, $exclude=false ) { assert ( is_string($attribute) ); assert ( is_array($values) ); assert ( count($values) ); if ( is_array($values) && count($values) ) { foreach ( $values as $value ) assert ( is_numeric($value) ); $this->_filters[] = array ( "type"=>SPH_FILTER_VALUES, "attr"=>$attribute, "exclude"=>$exclude, "values"=>$values ); } } /// set range filter /// only match records if $attribute value is beetwen $min and $max (inclusive) function SetFilterRange ( $attribute, $min, $max, $exclude=false ) { assert ( is_string($attribute) ); assert ( is_numeric($min) ); assert ( is_numeric($max) ); assert ( $min<=$max ); $this->_filters[] = array ( "type"=>SPH_FILTER_RANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); } /// set float range filter /// only match records if $attribute value is beetwen $min and $max (inclusive) function SetFilterFloatRange ( $attribute, $min, $max, $exclude=false ) { assert ( is_string($attribute) ); assert ( is_float($min) ); assert ( is_float($max) ); assert ( $min<=$max ); $this->_filters[] = array ( "type"=>SPH_FILTER_FLOATRANGE, "attr"=>$attribute, "exclude"=>$exclude, "min"=>$min, "max"=>$max ); } /// setup anchor point for geosphere distance calculations /// required to use @geodist in filters and sorting /// latitude and longitude must be in radians function SetGeoAnchor ( $attrlat, $attrlong, $lat, $long ) { assert ( is_string($attrlat) ); assert ( is_string($attrlong) ); assert ( is_float($lat) ); assert ( is_float($long) ); $this->_anchor = array ( "attrlat"=>$attrlat, "attrlong"=>$attrlong, "lat"=>$lat, "long"=>$long ); } /// set grouping attribute and function function SetGroupBy ( $attribute, $func, $groupsort="@group desc" ) { assert ( is_string($attribute) ); assert ( is_string($groupsort) ); assert ( $func==SPH_GROUPBY_DAY || $func==SPH_GROUPBY_WEEK || $func==SPH_GROUPBY_MONTH || $func==SPH_GROUPBY_YEAR || $func==SPH_GROUPBY_ATTR || $func==SPH_GROUPBY_ATTRPAIR ); $this->_groupby = $attribute; $this->_groupfunc = $func; $this->_groupsort = $groupsort; } /// set count-distinct attribute for group-by queries function SetGroupDistinct ( $attribute ) { assert ( is_string($attribute) ); $this->_groupdistinct = $attribute; } /// set distributed retries count and delay function SetRetries ( $count, $delay=0 ) { assert ( is_int($count) && $count>=0 ); assert ( is_int($delay) && $delay>=0 ); $this->_retrycount = $count; $this->_retrydelay = $delay; } /// set result set format (hash or array; hash by default) /// PHP specific; needed for group-by-MVA result sets that may contain duplicate IDs function SetArrayResult ( $arrayresult ) { assert ( is_bool($arrayresult) ); $this->_arrayresult = $arrayresult; } /// set attribute values override /// there can be only one override per attribute /// $values must be a hash that maps document IDs to attribute values function SetOverride ( $attrname, $attrtype, $values ) { assert ( is_string ( $attrname ) ); assert ( in_array ( $attrtype, array ( SPH_ATTR_INTEGER, SPH_ATTR_TIMESTAMP, SPH_ATTR_BOOL, SPH_ATTR_FLOAT, SPH_ATTR_BIGINT ) ) ); assert ( is_array ( $values ) ); $this->_overrides[$attrname] = array ( "attr"=>$attrname, "type"=>$attrtype, "values"=>$values ); } /// set select-list (attributes or expressions), SQL-like syntax function SetSelect ( $select ) { assert ( is_string ( $select ) ); $this->_select = $select; } ////////////////////////////////////////////////////////////////////////////// /// clear all filters (for multi-queries) function ResetFilters () { $this->_filters = array(); $this->_anchor = array(); } /// clear groupby settings (for multi-queries) function ResetGroupBy () { $this->_groupby = ""; $this->_groupfunc = SPH_GROUPBY_DAY; $this->_groupsort = "@group desc"; $this->_groupdistinct= ""; } /// clear all attribute value overrides (for multi-queries) function ResetOverrides () { $this->_overrides = array (); } ////////////////////////////////////////////////////////////////////////////// /// connect to searchd server, run given search query through given indexes, /// and return the search results function Query ( $query, $index="*", $comment="" ) { assert ( empty($this->_reqs) ); $this->AddQuery ( $query, $index, $comment ); $results = $this->RunQueries (); $this->_reqs = array (); // just in case it failed too early if ( !is_array($results) ) return false; // probably network error; error message should be already filled $this->_error = $results[0]["error"]; $this->_warning = $results[0]["warning"]; if ( $results[0]["status"]==SEARCHD_ERROR ) return false; else return $results[0]; } /// helper to pack floats in network byte order function _PackFloat ( $f ) { $t1 = pack ( "f", $f ); // machine order list(,$t2) = unpack ( "L*", $t1 ); // int in machine order return pack ( "N", $t2 ); } /// add query to multi-query batch /// returns index into results array from RunQueries() call function AddQuery ( $query, $index="*", $comment="" ) { // mbstring workaround $this->_MBPush (); // build request $req = pack ( "NNNNN", $this->_offset, $this->_limit, $this->_mode, $this->_ranker, $this->_sort ); // mode and limits $req .= pack ( "N", strlen($this->_sortby) ) . $this->_sortby; $req .= pack ( "N", strlen($query) ) . $query; // query itself $req .= pack ( "N", count($this->_weights) ); // weights foreach ( $this->_weights as $weight ) $req .= pack ( "N", (int)$weight ); $req .= pack ( "N", strlen($index) ) . $index; // indexes $req .= pack ( "N", 1 ); // id64 range marker $req .= sphPackU64 ( $this->_min_id ) . sphPackU64 ( $this->_max_id ); // id64 range // filters $req .= pack ( "N", count($this->_filters) ); foreach ( $this->_filters as $filter ) { $req .= pack ( "N", strlen($filter["attr"]) ) . $filter["attr"]; $req .= pack ( "N", $filter["type"] ); switch ( $filter["type"] ) { case SPH_FILTER_VALUES: $req .= pack ( "N", count($filter["values"]) ); foreach ( $filter["values"] as $value ) $req .= sphPackI64 ( $value ); break; case SPH_FILTER_RANGE: $req .= sphPackI64 ( $filter["min"] ) . sphPackI64 ( $filter["max"] ); break; case SPH_FILTER_FLOATRANGE: $req .= $this->_PackFloat ( $filter["min"] ) . $this->_PackFloat ( $filter["max"] ); break; default: assert ( 0 && "internal error: unhandled filter type" ); } $req .= pack ( "N", $filter["exclude"] ); } // group-by clause, max-matches count, group-sort clause, cutoff count $req .= pack ( "NN", $this->_groupfunc, strlen($this->_groupby) ) . $this->_groupby; $req .= pack ( "N", $this->_maxmatches ); $req .= pack ( "N", strlen($this->_groupsort) ) . $this->_groupsort; $req .= pack ( "NNN", $this->_cutoff, $this->_retrycount, $this->_retrydelay ); $req .= pack ( "N", strlen($this->_groupdistinct) ) . $this->_groupdistinct; // anchor point if ( empty($this->_anchor) ) { $req .= pack ( "N", 0 ); } else { $a =& $this->_anchor; $req .= pack ( "N", 1 ); $req .= pack ( "N", strlen($a["attrlat"]) ) . $a["attrlat"]; $req .= pack ( "N", strlen($a["attrlong"]) ) . $a["attrlong"]; $req .= $this->_PackFloat ( $a["lat"] ) . $this->_PackFloat ( $a["long"] ); } // per-index weights $req .= pack ( "N", count($this->_indexweights) ); foreach ( $this->_indexweights as $idx=>$weight ) $req .= pack ( "N", strlen($idx) ) . $idx . pack ( "N", $weight ); // max query time $req .= pack ( "N", $this->_maxquerytime ); // per-field weights $req .= pack ( "N", count($this->_fieldweights) ); foreach ( $this->_fieldweights as $field=>$weight ) $req .= pack ( "N", strlen($field) ) . $field . pack ( "N", $weight ); // comment $req .= pack ( "N", strlen($comment) ) . $comment; // attribute overrides $req .= pack ( "N", count($this->_overrides) ); foreach ( $this->_overrides as $key => $entry ) { $req .= pack ( "N", strlen($entry["attr"]) ) . $entry["attr"]; $req .= pack ( "NN", $entry["type"], count($entry["values"]) ); foreach ( $entry["values"] as $id=>$val ) { assert ( is_numeric($id) ); assert ( is_numeric($val) ); $req .= sphPackU64 ( $id ); switch ( $entry["type"] ) { case SPH_ATTR_FLOAT: $req .= $this->_PackFloat ( $val ); break; case SPH_ATTR_BIGINT: $req .= sphPackI64 ( $val ); break; default: $req .= pack ( "N", $val ); break; } } } // select-list $req .= pack ( "N", strlen($this->_select) ) . $this->_select; // mbstring workaround $this->_MBPop (); // store request to requests array $this->_reqs[] = $req; return count($this->_reqs)-1; } /// connect to searchd, run queries batch, and return an array of result sets function RunQueries () { if ( empty($this->_reqs) ) { $this->_error = "no queries defined, issue AddQuery() first"; return false; } // mbstring workaround $this->_MBPush (); if (!( $fp = $this->_Connect() )) { $this->_MBPop (); return false; } // send query, get response $nreqs = count($this->_reqs); $req = join ( "", $this->_reqs ); $len = 4+strlen($req); $req = pack ( "nnNN", SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, $nreqs ) . $req; // add header if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || !( $response = $this->_GetResponse ( $fp, VER_COMMAND_SEARCH ) ) ) { $this->_MBPop (); return false; } // query sent ok; we can reset reqs now $this->_reqs = array (); // parse and return response return $this->_ParseSearchResponse ( $response, $nreqs ); } /// parse and return search query (or queries) response function _ParseSearchResponse ( $response, $nreqs ) { $p = 0; // current position $max = strlen($response); // max position for checks, to protect against broken responses $results = array (); for ( $ires=0; $ires<$nreqs && $p<$max; $ires++ ) { $results[] = array(); $result =& $results[$ires]; $result["error"] = ""; $result["warning"] = ""; // extract status list(,$status) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $result["status"] = $status; if ( $status!=SEARCHD_OK ) { list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $message = substr ( $response, $p, $len ); $p += $len; if ( $status==SEARCHD_WARNING ) { $result["warning"] = $message; } else { $result["error"] = $message; continue; } } // read schema $fields = array (); $attrs = array (); list(,$nfields) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; while ( $nfields-->0 && $p<$max ) { list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $fields[] = substr ( $response, $p, $len ); $p += $len; } $result["fields"] = $fields; list(,$nattrs) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; while ( $nattrs-->0 && $p<$max ) { list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $attr = substr ( $response, $p, $len ); $p += $len; list(,$type) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $attrs[$attr] = $type; } $result["attrs"] = $attrs; // read match count list(,$count) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; list(,$id64) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; // read matches $idx = -1; while ( $count-->0 && $p<$max ) { // index into result array $idx++; // parse document id and weight if ( $id64 ) { $doc = sphUnpackU64 ( substr ( $response, $p, 8 ) ); $p += 8; list(,$weight) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; } else { list ( $doc, $weight ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; $doc = sphFixUint($doc); } $weight = sprintf ( "%u", $weight ); // create match entry if ( $this->_arrayresult ) $result["matches"][$idx] = array ( "id"=>$doc, "weight"=>$weight ); else $result["matches"][$doc]["weight"] = $weight; // parse and create attributes $attrvals = array (); foreach ( $attrs as $attr=>$type ) { // handle 64bit ints if ( $type==SPH_ATTR_BIGINT ) { $attrvals[$attr] = sphUnpackI64 ( substr ( $response, $p, 8 ) ); $p += 8; continue; } // handle floats if ( $type==SPH_ATTR_FLOAT ) { list(,$uval) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; list(,$fval) = unpack ( "f*", pack ( "L", $uval ) ); $attrvals[$attr] = $fval; continue; } // handle everything else as unsigned ints list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; if ( $type & SPH_ATTR_MULTI ) { $attrvals[$attr] = array (); $nvalues = $val; while ( $nvalues-->0 && $p<$max ) { list(,$val) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $attrvals[$attr][] = sphFixUint($val); } } else { $attrvals[$attr] = sphFixUint($val); } } if ( $this->_arrayresult ) $result["matches"][$idx]["attrs"] = $attrvals; else $result["matches"][$doc]["attrs"] = $attrvals; } list ( $total, $total_found, $msecs, $words ) = array_values ( unpack ( "N*N*N*N*", substr ( $response, $p, 16 ) ) ); $result["total"] = sprintf ( "%u", $total ); $result["total_found"] = sprintf ( "%u", $total_found ); $result["time"] = sprintf ( "%.3f", $msecs/1000 ); $p += 16; while ( $words-->0 && $p<$max ) { list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $word = substr ( $response, $p, $len ); $p += $len; list ( $docs, $hits ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; $result["words"][$word] = array ( "docs"=>sprintf ( "%u", $docs ), "hits"=>sprintf ( "%u", $hits ) ); } } $this->_MBPop (); return $results; } ///////////////////////////////////////////////////////////////////////////// // excerpts generation ///////////////////////////////////////////////////////////////////////////// /// connect to searchd server, and generate exceprts (snippets) /// of given documents for given query. returns false on failure, /// an array of snippets on success function BuildExcerpts ( $docs, $index, $words, $opts=array() ) { assert ( is_array($docs) ); assert ( is_string($index) ); assert ( is_string($words) ); assert ( is_array($opts) ); $this->_MBPush (); if (!( $fp = $this->_Connect() )) { $this->_MBPop(); return false; } ///////////////// // fixup options ///////////////// if ( !isset($opts["before_match"]) ) $opts["before_match"] = "<b>"; if ( !isset($opts["after_match"]) ) $opts["after_match"] = "</b>"; if ( !isset($opts["chunk_separator"]) ) $opts["chunk_separator"] = " ... "; if ( !isset($opts["limit"]) ) $opts["limit"] = 256; if ( !isset($opts["around"]) ) $opts["around"] = 5; if ( !isset($opts["exact_phrase"]) ) $opts["exact_phrase"] = false; if ( !isset($opts["single_passage"]) ) $opts["single_passage"] = false; if ( !isset($opts["use_boundaries"]) ) $opts["use_boundaries"] = false; if ( !isset($opts["weight_order"]) ) $opts["weight_order"] = false; ///////////////// // build request ///////////////// // v.1.0 req $flags = 1; // remove spaces if ( $opts["exact_phrase"] ) $flags |= 2; if ( $opts["single_passage"] ) $flags |= 4; if ( $opts["use_boundaries"] ) $flags |= 8; if ( $opts["weight_order"] ) $flags |= 16; $req = pack ( "NN", 0, $flags ); // mode=0, flags=$flags $req .= pack ( "N", strlen($index) ) . $index; // req index $req .= pack ( "N", strlen($words) ) . $words; // req words // options $req .= pack ( "N", strlen($opts["before_match"]) ) . $opts["before_match"]; $req .= pack ( "N", strlen($opts["after_match"]) ) . $opts["after_match"]; $req .= pack ( "N", strlen($opts["chunk_separator"]) ) . $opts["chunk_separator"]; $req .= pack ( "N", (int)$opts["limit"] ); $req .= pack ( "N", (int)$opts["around"] ); // documents $req .= pack ( "N", count($docs) ); foreach ( $docs as $doc ) { assert ( is_string($doc) ); $req .= pack ( "N", strlen($doc) ) . $doc; } //////////////////////////// // send query, get response //////////////////////////// $len = strlen($req); $req = pack ( "nnN", SEARCHD_COMMAND_EXCERPT, VER_COMMAND_EXCERPT, $len ) . $req; // add header if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || !( $response = $this->_GetResponse ( $fp, VER_COMMAND_EXCERPT ) ) ) { $this->_MBPop (); return false; } ////////////////// // parse response ////////////////// $pos = 0; $res = array (); $rlen = strlen($response); for ( $i=0; $i<count($docs); $i++ ) { list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; if ( $pos+$len > $rlen ) { $this->_error = "incomplete reply"; $this->_MBPop (); return false; } $res[] = $len ? substr ( $response, $pos, $len ) : ""; $pos += $len; } $this->_MBPop (); return $res; } ///////////////////////////////////////////////////////////////////////////// // keyword generation ///////////////////////////////////////////////////////////////////////////// /// connect to searchd server, and generate keyword list for a given query /// returns false on failure, /// an array of words on success function BuildKeywords ( $query, $index, $hits ) { assert ( is_string($query) ); assert ( is_string($index) ); assert ( is_bool($hits) ); $this->_MBPush (); if (!( $fp = $this->_Connect() )) { $this->_MBPop(); return false; } ///////////////// // build request ///////////////// // v.1.0 req $req = pack ( "N", strlen($query) ) . $query; // req query $req .= pack ( "N", strlen($index) ) . $index; // req index $req .= pack ( "N", (int)$hits ); //////////////////////////// // send query, get response //////////////////////////// $len = strlen($req); $req = pack ( "nnN", SEARCHD_COMMAND_KEYWORDS, VER_COMMAND_KEYWORDS, $len ) . $req; // add header if ( !( $this->_Send ( $fp, $req, $len+8 ) ) || !( $response = $this->_GetResponse ( $fp, VER_COMMAND_KEYWORDS ) ) ) { $this->_MBPop (); return false; } ////////////////// // parse response ////////////////// $pos = 0; $res = array (); $rlen = strlen($response); list(,$nwords) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; for ( $i=0; $i<$nwords; $i++ ) { list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; $tokenized = $len ? substr ( $response, $pos, $len ) : ""; $pos += $len; list(,$len) = unpack ( "N*", substr ( $response, $pos, 4 ) ); $pos += 4; $normalized = $len ? substr ( $response, $pos, $len ) : ""; $pos += $len; $res[] = array ( "tokenized"=>$tokenized, "normalized"=>$normalized ); if ( $hits ) { list($ndocs,$nhits) = array_values ( unpack ( "N*N*", substr ( $response, $pos, 8 ) ) ); $pos += 8; $res [$i]["docs"] = $ndocs; $res [$i]["hits"] = $nhits; } if ( $pos > $rlen ) { $this->_error = "incomplete reply"; $this->_MBPop (); return false; } } $this->_MBPop (); return $res; } function EscapeString ( $string ) { $from = array ( '\\', '(',')','|','-','!','@','~','"','&', '/', '^', '$', '=' ); $to = array ( '\\\\', '\(','\)','\|','\-','\!','\@','\~','\"', '\&', '\/', '\^', '\$', '\=' ); return str_replace ( $from, $to, $string ); } ///////////////////////////////////////////////////////////////////////////// // attribute updates ///////////////////////////////////////////////////////////////////////////// /// batch update given attributes in given rows in given indexes /// returns amount of updated documents (0 or more) on success, or -1 on failure function UpdateAttributes ( $index, $attrs, $values, $mva=false ) { // verify everything assert ( is_string($index) ); assert ( is_bool($mva) ); assert ( is_array($attrs) ); foreach ( $attrs as $attr ) assert ( is_string($attr) ); assert ( is_array($values) ); foreach ( $values as $id=>$entry ) { assert ( is_numeric($id) ); assert ( is_array($entry) ); assert ( count($entry)==count($attrs) ); foreach ( $entry as $v ) { if ( $mva ) { assert ( is_array($v) ); foreach ( $v as $vv ) assert ( is_int($vv) ); } else assert ( is_int($v) ); } } // build request $req = pack ( "N", strlen($index) ) . $index; $req .= pack ( "N", count($attrs) ); foreach ( $attrs as $attr ) { $req .= pack ( "N", strlen($attr) ) . $attr; $req .= pack ( "N", $mva ? 1 : 0 ); } $req .= pack ( "N", count($values) ); foreach ( $values as $id=>$entry ) { $req .= sphPackU64 ( $id ); foreach ( $entry as $v ) { $req .= pack ( "N", $mva ? count($v) : $v ); if ( $mva ) foreach ( $v as $vv ) $req .= pack ( "N", $vv ); } } // connect, send query, get response if (!( $fp = $this->_Connect() )) return -1; $len = strlen($req); $req = pack ( "nnN", SEARCHD_COMMAND_UPDATE, VER_COMMAND_UPDATE, $len ) . $req; // add header if ( !$this->_Send ( $fp, $req, $len+8 ) ) return -1; if (!( $response = $this->_GetResponse ( $fp, VER_COMMAND_UPDATE ) )) return -1; // parse response list(,$updated) = unpack ( "N*", substr ( $response, 0, 4 ) ); return $updated; } ///////////////////////////////////////////////////////////////////////////// // persistent connections ///////////////////////////////////////////////////////////////////////////// function Open() { if ( $this->_socket !== false ) { $this->_error = 'already connected'; return false; } if ( !$fp = $this->_Connect() ) return false; // command, command version = 0, body length = 4, body = 1 $req = pack ( "nnNN", SEARCHD_COMMAND_PERSIST, 0, 4, 1 ); if ( !$this->_Send ( $fp, $req, 12 ) ) return false; $this->_socket = $fp; return true; } function Close() { if ( $this->_socket === false ) { $this->_error = 'not connected'; return false; } fclose ( $this->_socket ); $this->_socket = false; return true; } ////////////////////////////////////////////////////////////////////////// // status ////////////////////////////////////////////////////////////////////////// function Status () { $this->_MBPush (); if (!( $fp = $this->_Connect() )) { $this->_MBPop(); return false; } $req = pack ( "nnNN", SEARCHD_COMMAND_STATUS, VER_COMMAND_STATUS, 4, 1 ); // len=4, body=1 if ( !( $this->_Send ( $fp, $req, 12 ) ) || !( $response = $this->_GetResponse ( $fp, VER_COMMAND_STATUS ) ) ) { $this->_MBPop (); return false; } $res = substr ( $response, 4 ); // just ignore length, error handling, etc $p = 0; list ( $rows, $cols ) = array_values ( unpack ( "N*N*", substr ( $response, $p, 8 ) ) ); $p += 8; $res = array(); for ( $i=0; $i<$rows; $i++ ) for ( $j=0; $j<$cols; $j++ ) { list(,$len) = unpack ( "N*", substr ( $response, $p, 4 ) ); $p += 4; $res[$i][] = substr ( $response, $p, $len ); $p += $len; } $this->_MBPop (); return $res; } } // // $Id: sphinxapi.php 2055 2009-11-06 23:09:58Z shodan $ //
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('UNINSTALL') or exit('Access Denied'); return array('message','message_data','message_group'); ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('UNINSTALL') or exit('Access Denied'); ?>
PHP
<?php ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#subject").formValidator({onshow:"<?php echo L('input','',admin).L('subject')?>",onfocus:"<?php echo L('input','',admin).L('subject')?>"}).inputValidator({min:1,onerror:"<?php echo L('input','',admin).L('subject')?>"}); $("#content").formValidator({onshow:"<?php echo L('input','',admin).L('content')?>",onfocus:"<?php echo L('input','',admin).L('content')?>"}).inputValidator({min:1,onerror:"<?php echo L('input','',admin).L('content')?>"}); }) //--> </script> <div class="pad_10"> <form action="?m=message&c=message&a=message_send" method="post" name="myform" id="myform"> <table cellpadding="2" cellspacing="1" class="table_form" width="100%"> <tr> <th width="80"><?php echo L('sendto')?>:</th> <td> <input name="info[type]" type="radio" value="1" checked="checked" style="border:0" onclick="$('#groupid').show();$('#roleid').hide()" class="radio_style"> <?php echo L('group')?>&nbsp;&nbsp;&nbsp;&nbsp; </td> </tr> <tr> <th width="80"><?php echo L('group')?>:</th> <td> <select name="info[groupid]" id="groupid"> <?php $i=0; foreach($member_group_infos as $groupid=>$member_group){ $i++; ?> <option value="<?php echo $member_group['groupid'];?>"><?php echo $member_group['name'];?></option> <?php }?> </select> <select name="info[roleid]" id="roleid" style="display:none" > <?php $j=0; foreach($role_infos as $roleid=>$role){ $j++; ?> <option value="<?php echo $role['roleid'];?>"><?php echo $role['rolename'];?></option> <?php }?> </select> </td> </tr> <tr> <th width="80"><?php echo L('subject')?>:</th> <td><input type="text" name="info[subject]" id="subject" size="30" class="input-text"></td> </tr> <tr> <th><?php echo L('content')?>:</th> <td><textarea name="info[content]" id="content" cols="50" rows="6"></textarea></td> </tr> <input type="submit" name="dosubmit" id="dosubmit" class="dialog" value=" <?php echo L('submit')?> "> </table> </form> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="searchform" action="?m=message&c=message&a=search_message&menuid=<?php echo $_GET['menuid'];?>" method="post" > <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td><div class="explain-col"><?php echo L('query_type')?>:<?php echo form::select($trade_status,$status,'name="search[status]"', L('all'))?> <?php echo L('username')?>: <input type="text" value="<?php echo $username;?>" class="input-text" name="search[username]"> <?php echo L('time')?>: <?php echo form::date('search[start_time]',$start_time,'')?> <?php echo L('to')?> <?php echo form::date('search[end_time]',$end_time,'')?> <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit"> </div> </td> </tr> </tbody> </table> </form> <form name="myform" action="?m=message&c=message&a=delete" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('messageid[]');"></th> <th><?php echo L('subject')?></th> <th width="35%" align="center"><?php echo L('content')?></th> <th width="10%" align="center"><?php echo L('fromuserid')?></th> <th width='10%' align="center"><?php echo L('touserid')?></th> <th width="15%" align="center"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="35"><input type="checkbox" name="messageid[]" value="<?php echo $info['messageid']?>"></td> <td><?php echo $info['subject']?></td> <td align="" widht="35%"><?php echo $info['content'];?></td> <td align="center" width="10%"><?php echo $info['send_from_id']?></td> <td align="center" width="10%"><?php echo $info['send_to_id'];?></td> <td align="center" width="15%"><a href='?m=message&c=message&a=delete&messageid=<?php echo $info['messageid']?>' onClick="return confirm('<?php echo L('confirm', array('message' => $info['subject']))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')">&nbsp;&nbsp;</div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> <script type="text/javascript"> function see_all(id, name) { window.top.art.dialog({id:'sell_all'}).close(); window.top.art.dialog({title:'<?php echo L('details');//echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=message&c=message&a=see_all&messageid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'see_all'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'see_all'}).close()}); } function checkuid() { var ids=''; $("input[name='messageid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:"<?php echo L('before_select_operation')?>",lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="myform" action="?m=message&c=message&a=delete_group" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('message_group_id[]');"></th> <th><?php echo L('subject')?></th> <th width="35%" align="center"><?php echo L('content')?></th> <th width="15%" align="center"><?php echo L('sendtime')?></th> <th width='10%' align="center"><?php echo L('status')?></th> <th width="10%" align="center"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="35"><input type="checkbox" name="message_group_id[]" value="<?php echo $info['id']?>"></td> <td><?php echo $info['subject']?></td> <td align="" widht="35%"><?php echo $info['content'];?></td> <td align="center" width="15%"><?php echo date('Y-m-d H:i:s',$info['inputtime']);?></td> <td align="center" width="10%"><?php if($info['status']==1){echo L('show_m');}else {echo '<font color=red>'.L('close').'</font>';}?></td> <td align="center" width="10%"> <a href='?m=message&c=message&a=delete_group&message_group_id=<?php echo $info['id']?>' onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($info['subject'])))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')">&nbsp;&nbsp;</div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> <script type="text/javascript"> function see_all(id, name) { window.top.art.dialog({id:'sell_all'}).close(); window.top.art.dialog({title:'<?php echo L('details');//echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=message&c=message&a=see_all&messageid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'see_all'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'see_all'}).close()}); } function checkuid() { var ids=''; $("input[name='message_group_id[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:"<?php echo L('before_select_operation')?>",lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#subject").formValidator({onshow:"<?php echo L('input','','admin').L('subject')?>",onfocus:"<?php echo L('subject').L('no_empty')?>"}).inputValidator({min:1,max:999,onerror:"<?php echo L('subject').L('no_empty')?>"}); $("#con").formValidator({onshow:"<?php echo L('content').L('no_empty')?>",onfocus:"<?php echo L('content').L('no_empty')?>"}).inputValidator({min:1,max:999,onerror:"<?php echo L('content').L('no_empty')?>"}); $("#tousername").formValidator({onshow:"<?php echo L('input','','admin').L('touserid')?>",onfocus:"<?php echo L('touserid').L('no_empty')?>"}).inputValidator({min:1,onerror:"<?php echo L('input','','admin').L('touserid')?>"}).ajaxValidator({type : "get",url : "",data :"m=message&c=message&a=public_name",datatype : "html",async:'true',success : function(data){if( data == 1 ){return true;}else{return false;}},buttons: $("#dosubmit"),onerror : "<?php echo L('not_myself')?>! ",onwait : "<?php echo L('connecting')?>"}); }) //--> </script> <div class="pad-lr-10"> <form action="?m=message&c=message&a=send_one" method="post" name="myform" id="myform"> <table cellpadding="2" cellspacing="1" class="table_form" width="100%"> <tr> <th width="100"><?php echo L('subject')?>:</th> <td><input type="text" name="info[subject]" id="subject" size="30" class="input-text"></td> </tr> <tr> <th width="100"><?php echo L('touserid')?>:</th> <td><input type="text" name="info[send_to_id]" id="tousername" size="20" class="input-text" value=""></td> </tr> <tr> <th><?php echo L('content')?>:</th> <td><textarea name="info[content]" id="con" cols="50" rows="6"></textarea></td> </tr> <tr> <th></th> <td><input type="submit" name="dosubmit" id="dosubmit" class="button" value=" <?php echo L('submit')?> "></td> </tr> </table> </form> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="myform" action="?m=message&c=message&a=delete_inbox" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('messageid[]');"></th> <th><?php echo L('subject')?></th> <th width="35%" align="center"><?php echo L('content')?></th> <th width="10%" align="center"><?php echo L('message_sender')?></th> <th width='15%' align="center"><?php echo L('send_time')?></th> <th width="15%" align="center"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="35"><input type="checkbox" name="messageid[]" value="<?php echo $info['messageid']?>"></td> <td><?php echo $info['subject']?></td> <td align="" widht="35%"><?php echo $info['content'];?></td> <td align="center" width="10%"><?php echo $info['send_from_id'];?></td> <td align="center" width="15%"><?php echo date("Y-m-d H:i:s",$info['message_time']);?></td> <td align="center" width="15%"><a href='?m=message&c=message&a=delete&messageid=<?php echo $info['messageid']?>' onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($info['subject'])))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')">&nbsp;&nbsp;</div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> <script type="text/javascript"> function see_all(id, name) { window.top.art.dialog({id:'sell_all'}).close(); window.top.art.dialog({title:'<?php echo L('details');//echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=message&c=message&a=see_all&messageid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'see_all'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'see_all'}).close()}); } function checkuid() { var ids=''; $("input[name='messageid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:<?php echo L('select_operations')?>,lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="myform" action="?m=message&c=message&a=delete_outbox" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('messageid[]');"></th> <th><?php echo L('subject')?></th> <th width="35%" align="center"><?php echo L('content')?></th> <th width="10%" align="center"><?php echo L('touserid')?></th> <th width='15%' align="center"><?php echo L('send_time')?></th> <th width="15%" align="center"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="35"><input type="checkbox" name="messageid[]" value="<?php echo $info['messageid']?>"></td> <td><?php echo $info['subject']?></td> <td align="" widht="35%"><?php echo $info['content'];?></td> <td align="center" width="10%"><?php echo $info['send_to_id'];?></td> <td align="center" width="15%"><?php echo date("Y-m-d H:i:s",$info['message_time']);?></td> <td align="center" width="15%"> <a href='?m=message&c=message&a=delete&messageid=<?php echo $info['messageid']?>' onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($info['subject'])))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')">&nbsp;&nbsp;</div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> <script type="text/javascript"> function see_all(id, name) { window.top.art.dialog({id:'sell_all'}).close(); window.top.art.dialog({title:'<?php echo L('details');//echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=message&c=message&a=see_all&messageid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'see_all'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'see_all'}).close()}); } function checkuid() { var ids=''; $("input[name='messageid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:"<?php echo L('before_select_operation')?>",lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); $show_dialog = 1; include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <form name="searchform" action="?m=message&c=message&a=search_message&menuid=<?php echo $_GET['menuid'];?>" method="post" > <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td><div class="explain-col"><?php echo L('query_type')?>:<?php echo form::select($trade_status,$status,'name="search[status]"', L('all'))?> <?php echo L('username')?>: <input type="text" value="" class="input-text" name="search[username]"> <?php echo L('time')?>: <?php echo form::date('search[start_time]','','')?> <?php echo L('to')?> <?php echo form::date('search[end_time]','','')?> <input type="submit" value="<?php echo L('search')?>" class="button" name="dosubmit"> </div> </td> </tr> </tbody> </table> </form> <form name="myform" action="?m=message&c=message&a=delete" method="post" onsubmit="checkuid();return false;"> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="35" align="center"><input type="checkbox" value="" id="check_box" onclick="selectall('messageid[]');"></th> <th><?php echo L('subject')?></th> <th width="35%" align="center"><?php echo L('content')?></th> <th width="10%" align="center"><?php echo L('fromuserid')?></th> <th width='10%' align="center"><?php echo L('touserid')?></th> <th width="15%" align="center"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center" width="35"><input type="checkbox" name="messageid[]" value="<?php echo $info['messageid']?>"></td> <td><?php echo $info['subject']?></td> <td align="" widht="35%"><?php echo $info['content'];?></td> <td align="center" width="10%"><?php echo $info['send_from_id'];?></td> <td align="center" width="10%"><?php echo $info['send_to_id'];?></td> <td align="center" width="15%"> <a href='?m=message&c=message&a=delete&messageid=<?php echo $info['messageid']?>' onClick="return confirm('<?php echo L('confirm', array('message' => new_addslashes($info['subject'])))?>')"><?php echo L('delete')?></a> </td> </tr> <?php } } ?> </tbody> </table> <div class="btn"><a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', true)"><?php echo L('selected_all')?></a>/<a href="#" onClick="javascript:$('input[type=checkbox]').attr('checked', false)"><?php echo L('cancel')?></a> <input name="submit" type="submit" class="button" value="<?php echo L('remove_all_selected')?>" onClick="return confirm('<?php echo L('confirm', array('message' => L('selected')))?>')">&nbsp;&nbsp;</div> <div id="pages"><?php echo $pages?></div> </div> </form> </div> <script type="text/javascript"> function see_all(id, name) { window.top.art.dialog({id:'sell_all'}).close(); window.top.art.dialog({title:'<?php echo L('details');//echo L('edit')?> '+name+' ',id:'edit',iframe:'?m=message&c=message&a=see_all&messageid='+id,width:'700',height:'450'}, function(){var d = window.top.art.dialog({id:'see_all'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'see_all'}).close()}); } function checkuid() { var ids=''; $("input[name='messageid[]']:checked").each(function(i, n){ ids += $(n).val() + ','; }); if(ids=='') { window.top.art.dialog({content:"<?php echo L('before_select_operation')?>",lock:true,width:'200',height:'50',time:1.5},function(){}); return false; } else { myform.submit(); } } </script> </body> </html>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('foreground','member');//加载foreground 应用类. 自动判断是否登陆. pc_base::load_sys_class('format', '', 0); pc_base::load_sys_class('form', '', 0); class index extends foreground { function __construct() { parent::__construct(); $this->message_db = pc_base::load_model('message_model'); $this->message_group_db = pc_base::load_model('message_group_model'); $this->message_data_db = pc_base::load_model('message_data_model'); $this->_username = param::get_cookie('_username'); $this->_userid = param::get_cookie('_userid'); $this->_groupid = get_memberinfo($this->_userid,'groupid'); pc_base::load_app_func('global'); //定义站点ID常量,选择模版使用 $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid(); define("SITEID",$siteid); } public function init() { $page = isset($_GET['page']) ? intval($_GET['page']) : 1; $where = array('send_to_id'=>$this->_username,'replyid'=>'0'); $infos = $this->message_db->listinfo($where,$order = 'messageid DESC',$page, 10); $infos = new_html_special_chars($infos); $pages = $this->message_db->pages; include template('message', 'inbox'); } /** * 发送消息 */ public function send() { if(isset($_POST['dosubmit'])) { $username = $this->_username; $tousername = $_POST['info']['send_to_id']; $subject = new_html_special_chars($_POST['info']['subject']); $content = new_html_special_chars($_POST['info']['content']); $this->message_db->add_message($tousername,$username,$subject,$content,true); showmessage(L('operation_success'),HTTP_REFERER); } else { //判断当前会员,是否可发,短消息. $this->message_db->messagecheck($this->_userid); $show_validator = $show_scroll = $show_header = true; include template('message', 'send'); } } /* *判断收件人是否存在 */ public function public_name() { $username = isset($_GET['username']) && trim($_GET['username']) ? (pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['username'])) : trim($_GET['username'])) : exit('0'); $member_interface = pc_base::load_app_class('member_interface', 'member'); if ($username) { $username = safe_replace($username); //判断收件人不能为自己 if($username == $this->_username){ exit('0'); } $data = $member_interface->get_member_info($username, 2); if ($data!='-1') { exit('1'); } else { exit('0'); } } else { exit('0'); } } /** * 发件箱 */ public function outbox() { $where = array('send_from_id'=>$this->_username,'del_type'=>'0'); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->message_db->listinfo($where,$order = 'messageid DESC',$page, $pages = '8'); $infos = new_html_special_chars($infos); $pages = $this->message_db->pages; include template('message', 'outbox'); } /** * 收件箱 */ public function inbox() { $where = array('send_to_id'=>$this->_username,'folder'=>'inbox'); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->message_db->listinfo($where,$order = 'messageid DESC',$page, $pages = '8'); $infos = new_html_special_chars($infos); if (is_array($infos) && !empty($infos)) { foreach ($infos as $infoid=>$info){ $reply_num = $this->message_db->count(array("replyid"=>$info['messageid'])); $infos[$infoid]['reply_num'] = $reply_num; } } $pages = $this->message_db->pages; include template('message', 'inbox'); } /** * 群发邮件 */ public function group() { //查询自己有权限看的消息 $where = array('typeid'=>1,'groupid'=>$this->_groupid,'status'=>1); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->message_group_db->listinfo($where,$order = 'id DESC',$page, $pages = '8'); $infos = new_html_special_chars($infos); $status = array(); if (is_array($infos) && !empty($infos)) { foreach ($infos as $info){ $d = $this->message_data_db->select(array('userid'=>$this->_userid,'group_message_id'=>$info['id'])); if(!$d){ $status[$info['id']] = 0;//未读 红色 }else { $status[$info['id']] = 1; } } } $pages = $this->message_group_db->pages; include template('message', 'group'); } /** * 删除收件箱-短消息 * @param intval $sid 短消息ID,递归删除(修改状态为outbox) */ public function delete() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['messageid'])){ foreach($_POST['messageid'] as $messageid_arr) { $this->message_db->update(array('folder'=>'outbox'),array('messageid'=>$messageid_arr,'send_to_id'=>$this->_username)); } showmessage(L('operation_success'), HTTP_REFERER); } } } /** * 删除发件箱 - 短消息 * @param intval $sid 短消息ID,递归删除( 修改状态为del_type =1 ) */ public function del_type() { if((!isset($_POST['messageid']) || empty($_POST['messageid']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['messageid'])){ foreach($_POST['messageid'] as $messageid_arr) { $this->message_db->update(array('del_type'=>'1'),array('messageid'=>$messageid_arr,'send_from_id'=>$this->_username)); } showmessage(L('operation_success'), HTTP_REFERER); } } } /** * 查看短消息 */ public function read() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) return false; //查看过修改状态 为 0 $this->message_db->update(array('status'=>'0'),array('messageid'=>$_GET['messageid'])); //查询消息详情 $infos = $this->message_db->get_one(array('messageid'=>$_GET['messageid'])); if($infos['send_from_id']!='SYSTEM') $infos = new_html_special_chars($infos); //查询回复消息 $where = array('replyid'=>$infos['messageid']); $reply_infos = $this->message_db->listinfo($where,$order = 'messageid ASC',$page, $pages = '10'); $show_validator = $show_scroll = $show_header = true; include template('message', 'read'); } /** * 查看自己发的短消息 */ public function read_only() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) return false; //查询消息详情 $infos = $this->message_db->get_one(array('messageid'=>$_GET['messageid'])); $infos = new_html_special_chars($infos); //查询回复消息 $where = array('replyid'=>$infos['messageid']); $reply_infos = $this->message_db->listinfo($where,$order = 'messageid ASC',$page, $pages = '10'); $show_validator = $show_scroll = $show_header = true; include template('message', 'read_only'); } /** * 查看系统短消息 */ public function read_group(){ if((!isset($_GET['group_id']) || empty($_GET['group_id'])) && (!isset($_POST['group_id']) || empty($_POST['group_id']))) return false; //查询消息详情 $infos = $this->message_group_db->get_one(array('id'=>$_GET['group_id'])); $infos = new_html_special_chars($infos); if(!is_array($infos))showmessage(L('message_not_exist'),'blank'); //检查查看表是否有记录,无则向message_data 插入浏览记录 $check = $this->message_data_db->select(array('userid'=>$this->_userid,'group_message_id'=>$_GET['group_id'])); if(!$check){ $this->message_data_db->insert(array('userid'=>$this->_userid,'group_message_id'=>$_GET['group_id'])); } include template('message', 'read_group'); } /** * 回复短消息 */ public function reply() { if(isset($_POST['dosubmit'])) { //判断当前会员,是否可发,短消息. $this->message_db->messagecheck($this->_userid); $_POST['info']['send_from_id'] = $this->_username; $_POST['info']['message_time'] = SYS_TIME; $_POST['info']['status'] = '1'; $_POST['info']['folder'] = 'inbox'; if(empty($_POST['info']['send_to_id'])) { showmessage(L('user_noempty'),HTTP_REFERER); } $messageid = $this->message_db->insert($_POST['info'],true); if(!$messageid) return FALSE; showmessage(L('operation_success'),HTTP_REFERER); } else { $show_validator = $show_scroll = $show_header = true; include template('message', 'send'); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class message extends admin { function __construct() { parent::__construct(); $this->db = pc_base::load_model('message_model'); $this->group_db = pc_base::load_model('message_group_model'); $this->_username = param::get_cookie('admin_username'); $this->_userid = param::get_cookie('userid'); pc_base::load_sys_class('form'); foreach(L('select') as $key=>$value) { $trade_status[$key] = $value; } $this->trade_status = $trade_status; } public function init() { $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where,$order = 'messageid DESC',$page, $pages = '12'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'550\', height:\'300\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); $trade_status = $this->trade_status; include $this->admin_tpl('message_list'); } /** * 群发消息管理 ... */ public function message_group_manage() { $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->group_db->listinfo($where,$order = 'id DESC',$page, $pages = '12'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'550\', height:\'300\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); include $this->admin_tpl('message_group_list'); } /* *判断用户名是否存在 */ public function public_name() { $tousername = isset($_GET['tousername']) && trim($_GET['tousername']) ? (pc_base::load_config('system', 'charset') == 'gbk' ? iconv('utf-8', 'gbk', trim($_GET['tousername'])) : trim($_GET['tousername'])) : exit('0'); //不能发给自己 if($tousername == $this->_username){ exit('0'); } //判断用户名是否存在 $member_interface = pc_base::load_app_class('member_interface', 'member'); if ($tousername) { $data = $member_interface->get_member_info($tousername, 2); if ($data!='-1') { exit('1'); } else { exit('0'); } } else { exit('0'); } } /** * 删除短消息 * @param intval $sid 短消息ID,递归删除 */ public function delete() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['messageid'])){ foreach($_POST['messageid'] as $messageid_arr) { //批量删除友情链接 $this->db->delete(array('messageid'=>$messageid_arr)); } showmessage(L('operation_success'),'?m=message&c=message'); }else{ $messageid = intval($_GET['messageid']); if($messageid < 1) return false; //删除短消息 $result = $this->db->delete(array('messageid'=>$messageid)); if($result) { showmessage(L('operation_success'),'?m=message&c=message'); }else { showmessage(L("operation_failure"),'?m=message&c=message'); } } showmessage(L('operation_success'), HTTP_REFERER); } } /** * 删除系统 短消息 * @param intval $sid 群发短消息ID,递归删除 */ public function delete_group() { if((!isset($_GET['message_group_id']) || empty($_GET['message_group_id'])) && (!isset($_POST['message_group_id']) || empty($_POST['message_group_id']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['message_group_id'])){ foreach($_POST['message_group_id'] as $messageid_arr) { //批量删除系统消息 $this->group_db->delete(array('id'=>$messageid_arr)); } showmessage(L('operation_success'),'?m=message&c=message&a=message_group_manage'); }else{ $group_id = intval($_GET['message_group_id']); if($group_id < 1) return false; //删除短消息 $result = $this->group_db->delete(array('id'=>$group_id)); if($result){ showmessage(L('operation_success'),'?m=message&c=message&a=message_group_manage'); } else { showmessage(L("operation_failure"),'?m=message&c=message&a=message_group_manage'); } } showmessage(L('operation_success'), HTTP_REFERER); } } /** * 管理按组或角色 群发消息 */ public function message_send() { if(isset($_POST['dosubmit'])) { //插入群发表 $group_message = array (); if(empty($_POST['info']['subject'])||empty($_POST['info']['content'])) return false; $group_message['subject'] = $_POST['info']['subject']; $group_message['content'] = $_POST['info']['content']; $group_message['typeid'] = $_POST['info']['type']; $group_message['inputtime'] = SYS_TIME; if($group_message['typeid']==1){ $group_message['groupid'] = $_POST['info']['groupid']; }else { $group_message['groupid'] = $_POST['info']['roleid']; } $result_id = $this->group_db->insert($group_message,true); if(!$result_id){ showmessage(L('mass_failure'),HTTP_REFERER); } showmessage(L('operation_success'),HTTP_REFERER,'', 'add'); } else { $show_validator = $show_scroll = $show_header = true; //LOAD 会员组模型 $member_group = pc_base::load_model('member_group_model'); $member_group_infos = $member_group->select('','*','',$order = 'groupid ASC'); //LOAD 管理员角色模型 $role = pc_base::load_model('admin_role_model'); $role_infos = $role->select('','*','',$order = 'roleid ASC'); include $this->admin_tpl('message_send'); } } /** * 发消息 */ public function send_one() { if(isset($_POST['dosubmit'])) { $username= $this->_username; $tousername =$_POST['info']['send_to_id']; $subject = $_POST['info']['subject']; $content = $_POST['info']['content']; $this->db->add_message($tousername,$username,$subject,$content,true); showmessage(L('operation_success'),HTTP_REFERER); } else { $show_validator = $show_scroll = true; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'550\', height:\'300\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); include $this->admin_tpl('message_send_one'); } } /** * 收件箱 */ public function my_inbox() { $where = array('send_to_id'=>$this->_username,'folder'=>'inbox'); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where,$order = 'messageid DESC',$page, $pages = '12'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'550\', height:\'300\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); $trade_status = $this->trade_status; include $this->admin_tpl('message_inbox_list'); } /** * 删除-收件箱短消息 * @param intval $sid 短消息ID,递归删除 */ public function delete_inbox() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['messageid'])){ foreach($_POST['messageid'] as $messageid_arr) { //批量删除短消息 $this->db->update(array('folder'=>'outbox'),array('messageid'=>$messageid_arr,'send_to_id'=>$this->_username)); } showmessage(L('operation_success'), HTTP_REFERER); }else{ $messageid = intval($_GET['messageid']); if($messageid < 1) return false; //删除单个短消息 $result = $this->db->update(array('folder'=>'outbox'),array('messageid'=>$messageid,'send_to_id'=>$this->_username)); showmessage(L('operation_success'), HTTP_REFERER); } } } /** * 发件箱 */ public function my_outbox() { $where = array('send_from_id'=>$this->_username,'del_type'=>'0'); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where,$order = 'messageid DESC',$page, $pages = '12'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'550\', height:\'350\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); $trade_status = $this->trade_status; include $this->admin_tpl('message_outbox_list'); } /** * 删除-发件箱短消息 * @param intval $sid 短消息ID,递归删除 */ public function delete_outbox() { if((!isset($_GET['messageid']) || empty($_GET['messageid'])) && (!isset($_POST['messageid']) || empty($_POST['messageid']))) { showmessage(L('illegal_parameters'), HTTP_REFERER); } else { if(is_array($_POST['messageid'])){ foreach($_POST['messageid'] as $messageid_arr) { //批量删除短消息 $this->db->update(array('del_type'=>'1'),array('messageid'=>$messageid_arr,'send_from_id'=>$this->_username)); } showmessage(L('operation_success'), HTTP_REFERER); }else{ $messageid = intval($_GET['messageid']); if($messageid < 1) return false; //删除单个短消息 $result = $this->db->update(array('del_type'=>'1'),array('messageid'=>$messageid,'send_from_id'=>$this->_username)); showmessage(L('operation_success'), HTTP_REFERER); } } } /** * 短消息搜索 */ public function search_message() { if(isset($_POST['dosubmit'])){ $where = ''; extract($_POST['search']); if(!$username && !$start_time && !$end_time){ $where = ""; } if($username){ //判断是查询类型,收件还是发件记录 if($status==""){ $where .= $where ? " AND send_from_id='$username' or send_to_id='$username'" : " send_from_id='$username' or send_to_id='$username'"; } else { $where .= $where ? " AND $status='$username'" : " $status='$username'"; } } if($start_time && $end_time) { $start = strtotime($start_time); $end = strtotime($end_time); //$where .= "AND `message_time` >= '$start' AND `message_time` <= '$end' "; $where .= $where ? "AND `message_time` >= '$start' AND `message_time` <= '$end' " : " `message_time` >= '$start' AND `message_time` <= '$end' "; } } $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $infos = $this->db->listinfo($where,$order = 'messageid DESC',$page, $pages = '12'); $pages = $this->db->pages; $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=message&c=message&a=message_send\', title:\''.L('all_send_message').'\', width:\'700\', height:\'450\'}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', L('all_send_message')); $trade_status = $this->trade_status; include $this->admin_tpl('message_search_list'); } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class message_tag { private $message_db; public function __construct() { $this->message_db = pc_base::load_model('message_model'); $this->message_group_db = pc_base::load_model('message_group_model'); $this->message_data_db = pc_base::load_model('message_data_model'); $this->_username = param::get_cookie('_username'); $this->_userid = param::get_cookie('_userid'); $this->_groupid = get_memberinfo($this->_userid,'groupid'); } /** * 检测是否有新邮件 * @param $typeid 分类ID */ public function check_new(){ $where = array('send_to_id'=>$this->_username,'folder'=>'inbox','status'=>'1'); $new_count = $this->message_db->count($where); //检查是否有未查看的新系统短信 //检查该会员所在会员组 的系统公告,再查询message_data表. 是否有记录. 无则加入 未读NUM. $group_num = 0; $group_where = array('typeid'=>'1','groupid'=>$this->_groupid,'status'=>'1'); $group_arr = $this->message_group_db->select($group_where); foreach ($group_arr as $groupid=>$group){ $group_message_id = $group['id']; $where = array('group_message_id'=>$group_message_id,'userid'=>$this->_userid); $result = $this->message_data_db->select($where); if(!$result) $group_num++; } //生成一个新数组,并返回此数组 $new_arr = array(); $new_arr['new_count'] = $new_count; $new_arr['new_group_count'] = $group_num; return $new_arr; } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); return array('message','message_group','message_data'); ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); $parentid = $menu_db->insert(array('name'=>'message', 'parentid'=>29, 'm'=>'message', 'c'=>'message', 'a'=>'init', 'data'=>'', 'listorder'=>0, 'display'=>'1'), true); $menu_db->insert(array('name'=>'send_one', 'parentid'=>$parentid, 'm'=>'message', 'c'=>'message', 'a'=>'send_one', 'data'=>'', 'listorder'=>0, 'display'=>'1')); $menu_db->insert(array('name'=>'delete_message', 'parentid'=>$parentid, 'm'=>'message', 'c'=>'message', 'a'=>'delete', 'data'=>'', 'listorder'=>0, 'display'=>'0')); $menu_db->insert(array('name'=>'message_send', 'parentid'=>$parentid, 'm'=>'message', 'c'=>'message', 'a'=>'message_send', 'data'=>'', 'listorder'=>0, 'display'=>'0')); $menu_db->insert(array('name'=>'message_group_manage', 'parentid'=>$parentid, 'm'=>'message', 'c'=>'message', 'a'=>'message_group_manage', 'data'=>'', 'listorder'=>0, 'display'=>'1')); $language = array('message'=>'短消息', 'send_one'=>'发送消息', 'delete_message'=>'删除短消息', 'message_send'=>'群发短消息', 'message_group_manage'=>'群发短消息管理'); ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); $module = 'message'; $modulename = '短消息'; $introduce = '短消息模块'; $author = 'phpcms Team'; $authorsite = 'http://www.phpcms.cn'; $authoremail = ''; ?>
PHP
INSERT INTO `phpcms_module` VALUES ('message', '短消息', '', '0', '1.0', '', '', '0', '0', '2010-09-06', '2010-09-06');
PHP
<?php $LANG['send_message'] = '发送短消息'; $LANG['all_send_message'] = '群发短消息'; $LANG['message'] = '短消息'; $LANG['send'] = '发送'; $LANG['sendto'] = '发送到'; $LANG['subject'] = '标题'; $LANG['content'] = '内容'; $LANG['setting'] = '配置'; $LANG['touserid'] = '收件人'; $LANG['fromuserid'] = '发件人'; $LANG['send_time'] = '发信时间'; $LANG['reply'] = '回复'; $LANG['is_reply'] = '是否回复'; $LANG['remove_all_selected'] = '删除选中'; $LANG['user_noempty'] = '收件人不能为空'; $LANG['username'] = '用户名'; $LANG['time'] = '时 间'; $LANG['see_info'] = '查看详情'; $LANG['no_empty'] = '不能为空'; $LANG['before_select_operation'] = '请选择再执行操作'; $LANG['no_thisuser'] = '没有此用户'; $LANG['connecting'] = '正在连接,请稍候。'; $LANG['group'] = '按会员组'; $LANG['role'] = '按角色'; $LANG['send_num'] = '每轮发送次数'; $LANG['select']['send_from_id'] = '发件人'; $LANG['select']['send_to_id'] = '收件人'; $LANG['not_myself'] = '禁止给自己或非注册用户发送消息'; $LANG['sendtime'] = '发送时间'; $LANG['show_m'] = '显示'; $LANG['details'] = '查看详情'; $LANG['message_sender'] = '发 信 人'; $LANG['query_type'] = '查询类型'; $LANG['to'] = '至'; $LANG['message_not_exist'] = '短消息不存在'; $LANG['mass_failure'] = '群发失败,请检查!'; ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin'); ?> <div class="pad_10"> <form name="searchform" action="" method="get" > <input type="hidden" value="order" name="m"> <input type="hidden" value="order" name="c"> <input type="hidden" value="init" name="a"> <input type="hidden" value="<?php echo $_GET['menuid']; ?>" name="menuid"> <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td> <div class="explain-col"> 搜索类型:<select name="field"> <option value="oid">清单号</option> <option value="username">会员名</option> <option value="title">清单标题</option> </select> 关键字:<input type="text" name="keywords" value="" /> <input type="submit" name="search" class="button" value="<?php echo L('search')?>" /> </div> </td> </tr> </tbody> </table> </form> <div class="bk10"></div> <div class="table-list"> <div>注:<span style="color:orange;">黄色标题</span> 表示首选清单</div> <form action="" method="get"> <input type="hidden" name="m" value="order" /> <input type="hidden" name="c" value="order" /> <input type="hidden" name="a" id="action" value="delete" /> <table width="100%" cellspacing="0"> <thead> <tr> <th width="50"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th> <th width="50">排序</th> <th>清单号</th> <th>会员名</th> <th>标题</th> <th>备注</th> <th>创建时间</th> <th>最后更新时间</th> <th>相关操作</th> </tr> </thead> <tbody> <?php if(is_array($data)) foreach($data as $v){ ?> <tr> <td width="50" align="center"><input type="checkbox" value="<?php echo $v['id']?>" name="id[]"></td> <td><input type="text" name="listorder[]" value="<?php echo $v['sort']?>" size="5" /></td> <td align="center"><?php echo $v['oid']?></td> <td align="center"><?php echo $v['username']?></td> <td align="center" <?php if($v['selected']==1) echo 'style="color:orange;"'; ?>><?php echo $v['title']?></td> <td align="center"><?php echo $v['note']?></td> <td align="center"><?php echo date('Y-m-d H:i:s', $v['inputtime'])?></td> <td align="center"><?php echo date('Y-m-d H:i:s', $v['updatetime'])?></td> <td align="center"><a href="?m=order&c=order&a=detail_list&oid=<?php echo $v['oid']?>">清单详情</a> | <a href="?m=order&c=order&a=delete&id=<?php echo $v['id']?>" onclick="return confirm('<?php echo htmlspecialchars(new_addslashes(L('confirm', array('message'=>$v['title']))))?>')">删除</a></td> </tr> <?php } ?> </tbody> </table> <div class="btn"> <label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('您确认删除么,该操作无法恢复!')" /> <input type="submit" class="button" name="dosubmit" onclick="$('#action').val('listorder')" value=" 更新排序 " </div> </from> </div> </div> <div id="pages"><?php echo $pages?></div> <script type="text/javascript"> window.top.$('#display_center_id').css('display','none'); </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin'); ?> <style type="text/css"> html{_overflow-y:scroll} </style> <script language="JavaScript" src="<?php echo JS_PATH; ?>jquery.imgpreview.js"></script> <script type="text/javascript"> $(document).ready(function(){ var obj=$("#imgPreview td.img[rel]"); if(obj.length>0) { $('#imgPreview td.img[rel]').imgPreview({ srcAttr: 'rel', imgCSS: { width: 200 } }); } }); </script> <div class="pad_10"> <div class="table-list"> <h3>清单:<?php echo $order['title']; ?> ( <?php echo $order['oid'];?> )</h3> <form action="" method="get"> <input type="hidden" name="m" value="order" /> <input type="hidden" name="c" value="order" /> <input type="hidden" name="a" id="action" value="delete" /> <input type="hidden" name="oid" id="action" value="<?php echo $_GET['oid']; ?>" /> <table width="100%" cellspacing="0" id="imgPreview"> <thead> <tr> <th width="50"><input type="checkbox" value="" id="check_box" onclick="selectall('id[]');"></th> <th>清单号</th> <th>会员名</th> <th>产品名称</th> <th>备注</th> <th>供应商/设计师</th> <th>创建时间</th> <th>最后更新时间</th> <th>相关操作</th> </tr> </thead> <tbody> <?php if(is_array($data)) foreach($data as $v){ ?> <tr> <td width="50" align="center"><input type="checkbox" value="<?php echo $v['id']?>" name="id[]"></td> <td align="center"><?php echo $v['oid']?></td> <td align="center"><?php echo $v['username']?></td> <td align="center" class="img" rel="<?php echo WEB_PATH.$v['thumb']?>"><?php echo $v['producttitle']?></td> <td align="center"><?php echo $v['note']?></td> <td align="center"><?php echo $v['suppliername']?></td> <td align="center"><?php echo date('Y-m-d H:i:s', $v['inputtime'])?></td> <td align="center"><?php echo date('Y-m-d H:i:s', $v['updatetime'])?></td> <td align="center"><a href="?m=order&c=order&a=detail_delete&oid=<?php echo $v['oid']?>&id=<?php echo $v['id']?>" onclick="return confirm('<?php echo htmlspecialchars(new_addslashes(L('confirm', array('message'=>$v['producttitle']))))?>')">删除</a></td> </tr> <?php } ?> </tbody> </table> <div class="btn"> <label for="check_box"><?php echo L('select_all')?>/<?php echo L('cancel')?></label> <input type="submit" class="button" name="dosubmit" value="<?php echo L('delete')?>" onclick="return confirm('您确认删除么,该操作无法恢复!')" /> </div> </from> </div> </div> <div id="pages"><?php echo $pages?></div> </body> </html>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class index { function __construct() { pc_base::load_app_func('global'); $this->order = pc_base::load_model('order_model');//投票标题 $this->username = param::get_cookie('_username'); $this->userid = param::get_cookie('_userid'); $this->ip = ip(); $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid(); define("SITEID",$siteid); if (!$this->userid) { $this->output(false, '您没有权限进行此操作,请您先登录!', APP_PATH.'index.php?m=member&c=index&a=login'); } } /** * 我的清单 * eddy */ public function lists() { $member_model = pc_base::load_model('member_model'); $memberinfo = $member_model->get_one(array('userid' => $this->userid)); $order_model = pc_base::load_model('order_model'); $content_total = $order_model->count('`userid`='.$this->userid); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $pagesize = 12; $offset = ($page - 1) * $pagesize; $order_pages = pages($content_total, $page, $pagesize); $order_data = $order_model->select('`userid`='.$this->userid, '*', $offset.",".$pagesize, 'selected DESC, updatetime DESC'); $SEO['title'] = '我的清单 - 会员中心'; include template('order', 'order'); } /** * 更新 */ public function update() { $in = array_merge($_GET, $_POST); $in = new_addslashes($in); if (!isset($in['id'])) { $this->output(false, '参数不正确!'); } $id = intval($in['id']); if ($in['dosubmit'] == 1) { $order_title = htmlspecialchars(trim($in['title'])); if(empty($order_title)) { $this->output(false, '请输入清单标题!'); } if($this->order->count("`title`='".$order_title."' AND `id`!=".$id) > 0) { $this->output(false, '您已经存在同名的清单标题!'); } $data = array( 'userid' => $this->userid, 'title' => $order_title, 'selected' => (isset($in['selected']) && $in['selected']>0) ? 1 : 0, 'note' => htmlspecialchars(trim($in['note'])), 'inputtime' => time() ); if($this->order->update($data, array('id'=>$id))) { if($data['selected'] == 1) { //更新首选清单 $this->order->update(array('selected' => 0), '`userid`='.$this->userid. ' AND `id`!='.$id); } $this->output(true, '编辑清单成功!'); } else $this->output(false, '编辑清单失败!'); } else { $order = $this->order->get_one(array('id' => $id)); include template('order','update'); } } /** * 删除 */ public function delete() { $in = new_addslashes(array_merge($_GET, $_POST)); if (isset($in['id']) && intval($in['id'])) { $id = intval($in['id']); $order = $this->order->get_one(array('id'=>$id)); if ($this->userid != $order['userid']) { $this->output(false, '抱歉,您没有权限删除此清单!'); } if ($order && $this->order->delete(array('id'=>$id))) { //删除清单详情 $order_detail_model = pc_base::load_model('order_detail_model'); $order_detail_model->delete(array('oid'=>$order['oid'])); //重置首选清单 if($order['selected'] == 1) { $orders = $this->order->select(array('userid'=>$order['userid']), 'id', 1000, 'updatetime DESC'); if ($orders && !empty($orders)) { $this->order->update(array('selected'=>'1'), array('id'=>$orders[0]['id'])); } } } $this->output(true, '删除成功!'); } } /** * 下载 */ public function download() { $in = new_addslashes(array_merge($_GET, $_POST)); if(!class_exists('ZipArchive')) { showmessage('该服务器不支持ZIP压缩,请联系网站管理员!', HTTP_REFERER); } if (isset($_GET['id']) && intval($_GET['id'])) { $orderid = intval($_GET['id']); $order_model = pc_base::load_model('order_model'); $order = $order_model->get_one(array('id'=>$orderid)); $order_detail_model = pc_base::load_model('order_detail_model'); $order_detail_data = $order_detail_model->select(array('oid' => $order['oid'])); $CATEGORYS = getcache('category_content_'.get_siteid(),'commons'); $dirs = array(); $order_detail_titles = array(); foreach($order_detail_data AS &$val) { if ($val['topcatid'] > 0) { //判断是否重名 if (key_exists($val['producttitle'], $order_detail_titles[$val['topcatid']])) { $order_detail_titles[$val['topcatid']][$val['producttitle']]++; $val['producttitle'] = '('.$order_detail_titles[$val['topcatid']][$val['producttitle']].')'.$val['producttitle']; } else { $order_detail_titles[$val['topcatid']][$val['producttitle']] = 1; } if(!in_array($CATEGORYS[$val['topcatid']]['catname'], $dirs)) { $dirs[] = $CATEGORYS[$val['topcatid']]['catname']; } if (!empty($CATEGORYS[$val['topcatid']]['catname'])) { $val['producttitle'] = $CATEGORYS[$val['topcatid']]['catname'].'/'.$val['producttitle']; } } } if (!$order_detail_data) { showmessage('您要下载的清单没有添加产品!', HTTP_REFERER); } $year = date('Y', SYS_TIME); $month = date('m', SYS_TIME); $base_path = realpath(PC_PATH.'../uploadfile/order').'/'; if (!file_exists($base_path.$year)) { @mkdir($base_path.$year, 0775); } if (!file_exists($base_path.$year.'/'.$month)) { @mkdir($base_path.$year.'/'.$month, 0775); } $path = $base_path.$year.'/'.$month.'/'; //判断是否存在此清单压缩文件,如存在则删除 $dir = dir($path); while (false !== ($entry = $dir->read())) { if (strpos($entry, $order['oid'].'.zip')) { @unlink($path.$entry); } } $dir->close(); //创建清单压缩文件 $zip = new ZipArchive(); $filename = $order['oid'].'.zip'; if ($zip->open($path.$filename, ZIPARCHIVE::CREATE)!==TRUE) { showmessage('无法生成下载文件,请联系网站管理员!', HTTP_REFERER); } $zip->addEmptyDir(iconv("UTF-8", "GBK", $order['title'])); foreach($dirs as $dir) { $zip->addEmptyDir(iconv("UTF-8", "GBK", $order['title'].'/'.$dir)); } foreach ($order_detail_data AS $od) { $source = $od['thumb']; $localname = explode('/', $source); $localname = $localname[count($localname)-1]; $localname_ext = substr($localname, strpos($localname, '.')); $localname = iconv("UTF-8", "GBK", $order['title'].'/'.$od['producttitle'].$localname_ext); $zip->addFile($source, $localname); } $zip->close(); /** sleep(10); //延迟10秒 //执行下载 //判断要下载的文件是否存在 $file_path = $path.$filename; if(!file_exists($path.$filename)) { showmessage('对不起,你要下载的文件不存在!', HTTP_REFERER); } $file_size = filesize($file_path); header("Content-type: application/x-zip-compressed"); header("Accept-Ranges: bytes"); header("Accept-Length: $file_size"); header("Content-Disposition: attachment; filename=".$filename); $fp = fopen($file_path,"r"); $buffer_size = 1024; $cur_pos = 0; while(!feof($fp)&&$file_size-$cur_pos>$buffer_size) { $buffer = fread($fp,$buffer_size); echo $buffer; $cur_pos += $buffer_size; } $buffer = fread($fp,$file_size-$cur_pos); echo $buffer; fclose($fp); //unlink($file_path); */ header('Location:'.APP_PATH.'uploadfile/order/'.$year.'/'.$month.'/'.$filename); } else { showmessage('没有您要下载的清单!', HTTP_REFERER); } } /** * 更新备注 */ public function update_note() { $in = array_merge($_GET, $_POST); $in = new_addslashes($in); if (!isset($in['id']) || !intval($in['id'])) { $this->output(false, '参数不正确!'); } $id = intval($in['id']); if ($in['dosubmit'] == 1) { $data = array( 'note' => htmlspecialchars(trim($in['note'])) ); if($this->order->update($data, array('id'=>$id))) { $this->output(true, '编辑清单备注成功!'); } else $this->output(false, '编辑清单备注失败!'); } else { $order = $this->order->get_one(array('id' => $id)); include template('order','update_note'); } } /** * 创建清单 * Enter description here ... */ public function add() { $in = array_merge($_GET, $_POST); $in = new_addslashes($in); if ($in['dosubmit'] == 1) { $order_title = htmlspecialchars(trim($in['title'])); if(empty($order_title)) { $this->output(false, '请输入清单标题!'); } if($this->order->count("`title`='".$order_title."'") > 0) { $this->output(false, '您已经存在同名的清单标题!'); } //如果是第一个清单,默认首选 if (!$this->order->count('`userid`='.$this->userid)) { $in['selected'] = 1; } $data = array( 'userid' => $this->userid, 'title' => $order_title, 'selected' => (isset($in['selected']) && $in['selected']>0) ? 1 : 0, 'note' => htmlspecialchars(trim($in['note'])), 'inputtime' => time() ); if($data = $this->order->add($data)) { if($data['selected'] == 1) { //更新首选清单 $this->order->update(array('selected' => 0), '`userid`='.$this->userid. ' AND `id`!='.$data['id']); } $this->output(true, '添加清单成功!'); } else $this->output(false, '添加清单失败!'); } else { include template('order','add'); } } /** * 设置首选清单 * Enter description here ... * @param unknown_type $code * @param unknown_type $msg */ public function setSelected() { $id = intval($_GET['id']); if ($this->order->count('`userid`='.$this->userid. ' AND `id`='.$id)) { $this->order->update(array('selected' => 0), '`userid`='.$this->userid); $this->order->update(array('selected' => 1), '`id`='.$id); } } /** * 复制给好友 */ public function copy() { $in = array_merge($_GET, $_POST); $in = new_addslashes($in); $SEO = seo(get_siteid()); $id = intval($in['id']); $order = $this->order->get_one(array('id'=>$id)); $member_db = pc_base::load_model('member_model'); if ($in['dosubmit'] == 1) { $member = $member_db->get_one(array('username'=>$in['username']), 'userid,username'); if ($member) { //创建清单 if ($member['userid'] == $this->userid) { $this->output(false, '不能复制给自己!'); } $data = array( 'userid' => $member['userid'], 'title' => $order['title'], 'note' => $order['note'], 'parentid' => $this->userid, 'parentname' => $this->username, 'parentnickname' => param::get_cookie('_nickname'), 'selected' => 0, 'inputtime' => time(), ); if($data = $this->order->add($data)) { //复制清单详细 $order_detail_db = pc_base::load_model('order_detail_model'); $order_details = $order_detail_db->select(array('oid'=>$order['oid'])); foreach ($order_details AS $v) { $v['oid'] = $data['oid']; $v['ordertitle'] = $data['title']; $v['userid'] = $member['userid']; $v['username'] = $member['username']; $v['inputtime'] = time(); unset($v['id']); $order_detail_db->insert($v); } if (isset($in['sendmail']) && $in['sendmail']) { //发送邮件 pc_base::load_sys_func('mail'); $date = date('Y-m-d', time()); $_nickname = param::get_cookie('_nickname'); $rmessage = <<<str 尊敬的{$in['username']}: 您好! 您的好友({$_nickname} <{$this->username}>)给转发了新的清单。<a href="http://www.108wo.com/">立即查看</a> 。 本邮件由系统自动发送,请勿回复! {$SEO['name']} {$date} str; sendmail($in['username'], '来自108wo的清单转发信息', nl2br($rmessage)); } $this->output(true, '操作成功!'); } else $this->output(false, '操作失败!'); } else { $this->output(false, '不存在此会员!'); } } //获取最多的转发的会员 $arruserids = $this->order->select(array('parentid'=>$this->userid), 'userid', 100, 'count(parentid) DESC', 'userid'); $userids = $members = ''; if ($arruserids) { foreach ($arruserids AS $v) { $userids .= $v['userid'].','; } $userids = rtrim($userids, ','); if ($userids) $members = $member_db->select('`userid` IN('.$userids.')', 'userid,username,nickname', '', 'find_in_set(userid,"'.$userids.'")'); } include template('order','copy'); } protected function output($code, $msg, $url='') { $in = array_merge($_GET, $_POST); if($in['ajax']) { die(json_encode(array('code' => $code, 'msg' => $msg))); } else { $forward = !empty($url) ? $url : HTTP_REFERER; showmessage($msg, $forward); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class order extends admin { protected $order_db, $order_detail_db; function __construct() { parent::__construct(); $this->order_db = pc_base::load_model('order_model'); $this->order_detail_db = pc_base::load_model('order_detail_model'); } public function init() { $where = '1'; if (isset($_GET['keywords']) && $_GET['keywords']!='') { if ($_GET['field']=='title' || $_GET['field']=='oid') { $where .= ' AND `'.$_GET['field'].'`="'.mysql_escape_string($_GET['keywords']).'"'; } else { $user_db = pc_base::load_model('member_model'); $user = $user_db->get_one(array('username'=>$_GET['keywords']), 'userid'); if ($user) { $where .= ' AND `userid`="'.mysql_escape_string($user['userid']).'"'; } } } $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $data = $this->order_db->listinfo($where,'id desc', $page, 20); $pages = $this->order_db->pages; $member_model = pc_base::load_model('member_model'); foreach ($data AS &$d) { $memberinfo = $member_model->get_one(array('userid' => $d['userid']), 'username'); $d['username'] = $memberinfo['username']; } include $this->admin_tpl('order_list'); } public function delete() { if($_GET['id']){ if(is_array($_GET['id'])){ $_GET['id'] = implode(',', $_GET['id']); $this->order_db->query("DELETE FROM `".$this->order_db->db_tablepre."order` WHERE `id` in ($_GET[id])"); }else{ $this->order_db->query("DELETE FROM `".$this->order_db->db_tablepre."order` WHERE `id` in ($_GET[id])"); } showmessage('操作成功', '?m=order&c=order&a=init'); }else{ showmessage('参数不正确', '?m=order&c=order&a=init'); } } public function listorder(){ $ids = $_GET['id']; if($ids){ foreach($ids as $n=>$id){ if(!$id)continue; $this->order_db->update('`sort`='.intval($_GET['listorder'][$n]), array('id'=>$id)); } showmessage('更新成功!', '?m=order&c=order&a=init'); }else{ showmessage('参数不正确', '?m=order&c=order&a=init'); } } /** * 清单详情列表 * */ public function detail_list() { $order = $this->order_db->get_one(array('oid'=>$_GET['oid'])); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $data = $this->order_detail_db->listinfo(array('oid'=>$_GET['oid']),'id desc', $page, 20); $pages = $this->order_detail_db->pages; include $this->admin_tpl('order_detail_list'); } /** * 清单详情列表删除 */ public function detail_delete() { if($_GET['id']){ if(is_array($_GET['id'])){ $_GET['id'] = implode(',', $_GET['id']); $this->order_detail_db->query("DELETE FROM `".$this->order_detail_db->db_tablepre."order_detail` WHERE `id` in ($_GET[id])"); }else{ $this->order_detail_db->query("DELETE FROM `".$this->order_detail_db->db_tablepre."order_detail` WHERE `id` in ($_GET[id])"); } showmessage('操作成功', '?m=order&c=order&a=detail_list&oid='.$_GET['oid']); }else{ showmessage('参数不正确', '?m=order&c=order&a=detail_list&oid='.$_GET['oid']); } } /** * 更新缓存 */ public function cache() { $num = 100; if (!isset($_GET['total'])) { $total = $this->order_detail_db->count(); } else { $total = $_GET['total']; } if (!isset($_GET['limit'])) { $limit = 0; } else { $limit = intval($_GET['limit']); } if ($limit > $total) { showmessage('更新完成', APP_PATH.'index.php?m=brand&c=brand'); } $data = $this->order_detail_db->select('', 'id,bid', $limit.','.$num, 'id DESC'); $brand_db = pc_base::load_model('brand_model'); foreach ($data AS $v) { $update_data = array(); if ($v['bid'] > 0) { $brand = $brand_db->get_one(array('id'=>$v['bid']), 'id,parentid,pcompanyname,prealname,pqq,paddress,ptel'); if ($brand) { if ($brand['parentid']!=0) { $brand = $brand_db->get_one(array('id'=>$brand['parentid']), 'id,parentid,pcompanyname,prealname,pqq,paddress,ptel'); } $update_data['companyname'] = $brand['pcompanyname']; $update_data['nickname'] = $brand['prealname']; $update_data['qq'] = $brand['pqq']; $update_data['tel'] = $brand['ptel']; } } else { $update_data['companyname'] = ''; $update_data['nickname'] = ''; $update_data['qq'] = ''; $update_data['tel'] = ''; } if ($update_data) { $this->order_detail_db->update($update_data, array('id'=>$v['id'])); } } if ($limit+$num > $total) { showmessage('更新完成', APP_PATH.'index.php?m=brand&c=brand'); } else { showmessage('已完成'.intval($limit+$num).'/'.$total.'!', APP_PATH.'index.php?m=order&c=order&a=cache&limit='.intval($limit+$num).'&total='.$total.'&menuid='.$_GET['menuid'].'&pc_hash='.$_GET['pc_hash']); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class vote_tag { public function __construct() { $this->subject_db = pc_base::load_model('vote_subject_model'); $this->option_db = pc_base::load_model('vote_option_model'); } /** * 显示 * @param $data */ public function show($data) { $subjectid = $data['subjectid'];//投票ID if($subjectid){ if(is_int($subjectid)) return false; $sql = array('subjectid'=>$subjectid); }else { $sql = ''; } return $this->subject_db->select($sql, '*', $data['limit']); } /** * 其它投票 * @param $data */ public function other_vote($data) { $siteid = $_GET['siteid']; $sql = array('siteid'=>$siteid); return $this->subject_db->select($sql, '*', $data['limit'], $data['order']); } /** * 投票热度排行 * @param $data 传入的数组参数 */ public function hits($data) { $siteid = intval($data['siteid']); $enabled = $data['enabled']?$data['enabled'] : 1;//状态:是否启用 if (empty($siteid)){ $siteid = get_siteid(); } switch ($enabled) { case all://不限 $sql = array('siteid'=>$siteid); break; default://默认按选择项 $sql = array('siteid'=>$siteid,'enabled'=>$enabled); } return $this->subject_db->select($sql, '*', $data['limit'], 'votenumber '.$data['order']); } /** * * 投票列表 * @param $data 数组参数 */ public function lists($data) { $siteid = intval($data['siteid']); $enabled = $data['enabled']?$data['enabled'] : 1;//状态:是否启用 $order = $data['order']?$data['order'] : 'subjectid desc';//状态:是否启用 if (empty($siteid)){ $siteid = get_siteid(); } switch ($enabled) { case all://不限 $sql = array('siteid'=>$siteid); break; default://默认按选择项 $sql = array('siteid'=>$siteid,'enabled'=>$enabled); } return $this->subject_db->select($sql, '*', $data['limit'], $order); } /** * 投票概况 */ public function get_vote($data) { $subjectid = intval($data['subjectid']); if (empty($subjectid)) return false; return $this->subject_db->get_one(array('subjectid'=>$subjectid)); } /** * 计数 */ public function count($data) { if(isset($data['where'])) { $sql = $data['where']; } else { $siteid = intval($data['siteid']); $enabled = $data['enabled']?$data['enabled'] : 1;//状态:是否启用 if (empty($siteid)){ $siteid = get_siteid(); } switch ($enabled) { case all://不限 $sql = array('siteid'=>$siteid); break; default://默认按选择项 $sql = array('siteid'=>$siteid,'enabled'=>$enabled); } return $this->subject_db->count($sql); } } /** * pc 标签调用 */ public function pc_tag() { $sites = pc_base::load_app_class('sites','admin'); $sitelist = $sites->pc_tag_list(); return array( 'action'=>array('lists'=>L('list','', 'comment'),'get_vote'=>L('vote_overview','','vote')), 'lists'=>array( 'siteid'=>array('name'=>L('site_id', '', 'comment'),'htmltype'=>'input_select', 'data'=>$sitelist,'validator'=>array('min'=>1)), 'enabled'=>array('name'=>L('vote_status','','vote'), 'htmltype'=>'select', 'data'=>array('all'=>L('vote_Lockets','','vote'),'1'=>L('vote_use','','vote'), '0'=>L('vote_lock','','vote'))), 'order'=>array('name'=>L('sort', '', 'comment'), 'htmltype'=>'select','data'=>array('subjectid desc'=>L('subjectid_desc', '', 'vote'), 'subjectid asc'=>L('subjectid_asc', '', 'vote'))), ), 'get_vote'=>array( 'subjectid'=>array('name'=>L('vote_voteid','','vote'),'htmltype'=>'input', 'validator'=>array('min'=>1)), ), ); } }
PHP
<?php defined('IN_PHPCMS') or exit('No permission resources.'); class order_detail { function __construct() { pc_base::load_app_func('global'); $this->order_detail = pc_base::load_model('order_detail_model');//投票标题 $this->username = param::get_cookie('_username'); $this->userid = param::get_cookie('_userid'); $this->ip = ip(); $siteid = isset($_GET['siteid']) ? intval($_GET['siteid']) : get_siteid(); define("SITEID",$siteid); if (!$this->userid) { $this->output(false, '您没有权限进行此操作,请您先登录!', APP_PATH.'index.php?m=member&c=index&a=login'); } } public function add() { $in = array_merge($_GET, $_POST); $in = new_addslashes($in); //查询首选清单 $order_model= pc_base::load_model('order_model'); $order = $order_model->get_one('`userid`='.$this->userid.' AND selected=1'); if (!$order) { $this->output(false, '请您先创建清单号!'); } $content_model = pc_base::load_model('content_model'); $content_model->set_model(13); $product = $content_model->get_one('id='.$in['productid']); if (!$product) { $this->output(false, '抱歉,不存在此产品!'); } //栏目 $CATEGORYS = getcache('category_content_'.SITEID,'commons'); $cat = $CATEGORYS[$product['catid']]; $arrparentid = explode(',', $cat['arrparentid']); $topcat = $CATEGORYS[$arrparentid[2]]; //品牌 $top_bid = (empty($product['bids']) ? '' : array_shift(explode(',', $product['bids']))); if ($top_bid) { $brand_db = pc_base::load_model('brand_model'); $brand = $brand_db->get_one(array('id'=>$top_bid)); } if ($brand['userid']) { $member_model = pc_base::load_model('member_model'); $member = $member_model->get_one('userid='.$brand['userid']); $member_model->set_model($member['modelid']); $member_ext = $member_model->get_one(array('userid' => $brand['userid'])); $member = array_merge($member, $member_ext); if ($member['vip'] == 1 && $member['overduedate'] > SYS_TIME) { $member_vip = true; } } //查询此清单已有数据数量 $has_num = $this->order_detail->count(array('oid' => $order['oid'], 'userid' => $this->userid)); if ($has_num > 200) { $this->output(false, '添加失败,每个清单最多200个产品!'); } //检测是否已存在于此清单中 if ($this->order_detail->count(array('oid' => $order['oid'], 'userid' => $this->userid, 'productid' => intval($in['productid'])))) { $this->output(true, '加入清单成功!'); } //插入数据 $data = array( 'oid' => $order['oid'], 'ordertitle' => $order['title'], 'topcatid' => $topcat['catid'], 'catid' => $product['catid'], 'bid' => ($top_bid ? $top_bid : ''), 'userid' => $this->userid, 'username' => $this->username, 'supplierid' => isset($brand['userid']) ? $brand['userid'] : '', 'nickname' => (isset($brand['prealname']) && $member_vip) ? $brand['prealname'] : '', 'suppliername' => (isset($member['username']) && $member_vip) ? $member['username'] : '', 'companyname' => (isset($brand['pcompanyname']) && $member_vip) ? $brand['pcompanyname'] : '', 'qq' => (isset($brand['pqq']) && $member_vip) ? $brand['pqq'] : '', 'tel' => (isset($brand['ptel']) && $member_vip) ? $brand['ptel'] : '', 'productid' => intval($in['productid']), 'producttitle' => $product['title'], 'thumb' => substr($product['thumb'], strpos($product['thumb'], 'uploadfile/')), 'note' => '', 'inputtime' => time() ); //查找上一次添加的产品备注信息 $old_order_detail = $this->order_detail->get_one(array('userid'=>$this->userid, 'productid'=>intval($in['productid'])), 'note'); if ($old_order_detail && $old_order_detail['note']!='') { $data['note'] = $old_order_detail['note']; } if ($insertid = $this->order_detail->insert($data, true)) { //更新加入清单次数 $ordernum = $product['ordernum'] + 1; $monthordernum = (date('Ym', $product['updatetime']) == date('Ym', SYS_TIME)) ? ($product['monthordernum'] + 1) : 1; $sql = array('ordernum'=>$ordernum,'monthordernum'=>$monthordernum,'updatetime'=>SYS_TIME); $content_model->update($sql, array('id'=>$product['id'])); $this->output(true, '加入清单成功!'); } else { $this->output(true, '加入清单失败!'); } } /** * 我的清单 详情 * eddy */ public function lists() { $member_model = pc_base::load_model('member_model'); $memberinfo = $member_model->get_one(array('userid' => $this->userid)); //关联栏目 eddy //$category_model = pc_base::load_model('category_model'); //$memberinfo['category'] = $category_model->get_one(array('userid' => $this->userid)); if (isset($_GET['id']) && intval($_GET['id'])) { $id = intval($_GET['id']); $order_model = pc_base::load_model('order_model'); $order_model->update(array('look'=>1), 'id='.$id); //更新为已读状态 $order = $order_model->get_one('id='.$id); if (!$order) { showmessage("没有此清单~", 'index.php?m=order&c=index&a=lists'); } if ($order['userid'] != $this->userid) { showmessage("抱歉,此清单不是您所创建的~", 'index.php?m=member&c=index&a=order'); } $order_detail_model = pc_base::load_model('order_detail_model'); $where = array('oid' => $order['oid']); /*if(!isset($_GET['topcatid'])) { $cat_db = pc_base::load_model('category_model'); $topcat = $cat_db->get_one(array('parentid'=>TOP_PRODUCT_CATID), 'catid'); $_GET['topcatid'] = $topcat['catid']; }*/ if (isset($_GET['topcatid']) && $_GET['topcatid'] > 0) { $_GET['topcatid'] = intval($_GET['topcatid']); $where['topcatid'] = intval($_GET['topcatid']); } $content_total = $order_detail_model->count($where); $page = isset($_GET['page']) && intval($_GET['page']) ? intval($_GET['page']) : 1; $pagesize = 10; $offset = ($page - 1) * $pagesize; $order_detail_pages = pages($content_total, $page, $pagesize); $order_detail_data = $order_detail_model->select($where, '*', $offset.",".$pagesize, 'updatetime DESC'); //获取顶部分类 $categorys = getcache('category_content_'.SITEID,'commons'); $topcategorys = array(); foreach ($categorys AS $catid=>$cat) { if ($cat['parentid'] == 7) { if($siteid && $cat['siteid']!=$siteid) continue; if (strpos($cat['url'], '://') === false) { $cat['url'] = substr($site['domain'],0,-1).$cat['url']; } $cat['productnum'] = 0; $topcategorys[$catid] = $cat; } } //计算每个分类下的产品数量 $order_detail_data2 = $order_detail_model->select(array('oid' => $order['oid']), '*', "200", 'updatetime DESC'); foreach ($order_detail_data2 AS &$order_detail) { if (isset($topcategorys[$order_detail['topcatid']])) { $topcategorys[$order_detail['topcatid']]['productnum']++; } } $SEO['title'] = '我的清单 - 会员中心'; include template('order', 'order_detail'); } else { showmessage("参数错误~", 'index.php?m=member&c=index&a=order'); } } /** * 更新备注 * Enter description here ... * @param unknown_type $code * @param unknown_type $msg * @param unknown_type $url */ public function update_note() { $in = new_addslashes(array_merge($_GET, $_POST)); $this->order_detail->update(array('note'=> trim($in['note'])), array('id' => intval($in['id']))); $this->output(true, "备注更新成功!"); } /** * 删除 * Enter description here ... */ public function delete() { $in = new_addslashes(array_merge($_GET, $_POST)); if (isset($in['id']) && intval($in['id'])) { $id = intval($in['id']); $this->order_detail->delete(array('id'=>$id)); $this->output(true, '删除成功!'); } } /** * 询价 * Enter description here ... * @param unknown_type $code * @param unknown_type $msg * @param unknown_type $url */ public function update_price() { $in = new_addslashes(array_merge($_GET, $_POST)); if (!isset($in['id'])) { $this->output(false, '参数错误!'); } $id = intval($in['id']); $order_detail = $this->order_detail->get_one(array('id'=>$id)); switch ($order_detail['enquiry']) { case 0: //开始询价 $this->order_detail->update(array('enquiry'=>1, 'enquirytime' => SYS_TIME), array('id'=>$id)); $this->output(true, '询价成功,等待供应商提供价格!'); break; case 1: //回复询价 case 2: if (!isset($in['price'])) { $this->output(false, '您提供的价格数据不规范!'); } $price = floatval($in['price']); $this->order_detail->update(array('enquiry'=>2, 'price'=>$price), array('id'=>$id)); $this->output(true, '价格发送成功!'); break; } } protected function output($code, $msg, $url='') { $in = array_merge($_GET, $_POST); if($in['ajax']) { die(json_encode(array('code' => $code, 'msg' => $msg))); } else { $forward = !empty($url) ? $url : HTTP_REFERER; showmessage($msg, $forward); } } } ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); return array('order'); ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); $module = 'order'; $modulename = '清单管理'; $introduce = '清单管理模块'; $author = 'eddy0909'; $authorsite = '#'; $authoremail = ''; ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <script type="text/javascript"> $(document).ready(function() { $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#name").formValidator({onshow:"请输入分类名称",onfocus:"分类名称不能为空"}).inputValidator({min:1,max:999,onerror:"分类名称不能为空"}); }) </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=brand&c=brand&a=editClass&bid=<?php echo $brand['id']; ?>" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td>当前品牌</td> <td> <?php echo $brand['name']; ?> </td> </tr> <tr> <td>分类名称</td> <td> <input type="text" name="info[name]" value="<?php echo $brand['name']; ?>" class="input-text" id="name" size="30"></input> </td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <script type="text/javascript"> $(document).ready(function() { $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#name").formValidator({onshow:"请输入品牌名称",onfocus:"品牌名称不能为空"}).inputValidator({min:1,max:999,onerror:"品牌名称不能为空"}); $("#child").formValidator({onshow:"多个分类请用 , 隔开",onfocus:"多个分类请用 , 隔开"}); }) </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=brand&c=brand&a=add" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td>品牌名称</td> <td> <input type="text" name="info[name]" value="" class="input-text" id="name" size="30"></input> </td> </tr> <tr> <td>所属栏目</td> <td> <select name="info[catid_1]" id="catid_1"> <?php foreach ($cats AS $v) { echo "<option value='".$v['catid']."'>".$v['catname']."</option>"; } ?> </select> <select name="info[catid_2]" id="catid_2"> <?php foreach ($cats[0]['child'] AS $v) { echo "<option value='".$v['catid']."'>".$v['catname']."</option>"; } ?> </select> </td> </tr> <tr> <td>关联会员</td> <td> <select name="info[userid]"> <?php foreach ($members AS $u) { echo "<option value='".$u['userid']."'>".$u['username']."</option>"; } ?> </select> </td> </tr> <tr> <td>供应商名称</td> <td><input type="text" name="info[pcompanyname]" value="" class="input-text" id="pcompanyname" size="30"></input></td> </tr> <tr> <td>联系人姓名</td> <td><input type="text" name="info[prealname]" value="" class="input-text" id="prealname" size="30"></input></td> </tr> <tr> <td>联系人QQ</td> <td><input type="text" name="info[pqq]" value="" class="input-text" id="pqq" size="30"></input></td> </tr> <tr> <td>联系人电话</td> <td><input type="text" name="info[ptel]" value="" class="input-text" id="ptel" size="30"></input></td> </tr> <tr> <td>营销地址</td> <td><input type="text" name="info[paddress]" value="" class="input-text" id="paddress" size="30"></input></td> </tr> <tr> <td>分类列表</td> <td> <input type="text" name="info[child]" value="" class="input-text" id="child" size="40" /> </td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> </div> </div> <script type="text/javascript"> var cats = <?php echo $cats_json; ?>; $(function(){ $("#catid_1").change(function(){ var catid_1 = this.value; var html=""; for(i in cats) { if(cats[i].catid == catid_1) { for(j in cats[i].child) { html += "<option value='"+cats[i].child[j].catid+"'>"+cats[i].child[j].catname+"</option>"; } $("#catid_2").html(html); } } }); }); </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <script type="text/javascript"> $(document).ready(function() { $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#name").formValidator({onshow:"请输入品牌名称",onfocus:"品牌名称不能为空"}).inputValidator({min:1,max:999,onerror:"品牌名称不能为空"}); $("#child").formValidator({onshow:"多个分类请用 , 隔开",onfocus:"多个分类请用 , 隔开"}); }) </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=brand&c=brand&a=edit&bid=<?php echo $brand['id']; ?>&dosubmit=1" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td>品牌名称</td> <td> <input type="text" name="info[name]" value="<?php echo $brand['name']; ?>" class="input-text" id="name" size="30"></input> </td> </tr> <tr> <td>所属栏目</td> <td> <select name="info[catid_1]" id="catid_1"> <?php foreach ($cats AS $v) { echo "<option value='".$v['catid']."'".($cat_1['catid']==$v['catid'] ? " selected":"").">".$v['catname']."</option>"; } ?> </select> <select name="info[catid_2]" id="catid_2"> <?php foreach ($cats AS $v) { if ($v['catid'] == $cat_1['catid']) { foreach ($v['child'] AS $v2) { echo "<option value='".$v2['catid']."'".($cat_2['catid']==$v2['catid'] ? " selected":"").">".$v2['catname']."</option>"; } } } ?> </select> </td> </tr> <tr> <td>关联会员</td> <td> <select name="info[userid]"> <?php foreach ($members AS $u) { echo "<option value='".$u['userid']."'".($brand['userid']==$u['userid'] ? ' selected':'').">".$u['username']."</option>"; } ?> </select> </td> </tr> <tr> <td>供应商名称</td> <td><input type="text" name="info[pcompanyname]" value="<?php echo $brand['pcompanyname']; ?>" class="input-text" id="pcompanyname" size="30"></input></td> </tr> <tr> <td>联系人姓名</td> <td><input type="text" name="info[prealname]" value="<?php echo $brand['prealname']; ?>" class="input-text" id="prealname" size="30"></input></td> </tr> <tr> <td>联系人QQ</td> <td><input type="text" name="info[pqq]" value="<?php echo $brand['pqq']; ?>" class="input-text" id="pqq" size="30"></input></td> </tr> <tr> <td>联系人电话</td> <td><input type="text" name="info[ptel]" value="<?php echo $brand['ptel']; ?>" class="input-text" id="ptel" size="30"></input></td> </tr> <tr> <td>营销地址</td> <td><input type="text" name="info[paddress]" value="<?php echo $brand['paddress']; ?>" class="input-text" id="paddress" size="30"></input></td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> </div> </div> <script type="text/javascript"> var cats = <?php echo $cats_json; ?>; $(function(){ $("#catid_1").change(function(){ var catid_1 = this.value; var html=""; for(i in cats) { if(cats[i].catid == catid_1) { for(j in cats[i].child) { html += "<option value='"+cats[i].child[j].catid+"'>"+cats[i].child[j].catname+"</option>"; } $("#catid_2").html(html); } } }); }); </script> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <script type="text/javascript"> $(document).ready(function() { $.formValidator.initConfig({autotip:true,formid:"myform",onerror:function(msg){}}); $("#name").formValidator({onshow:"请输入分类名称",onfocus:"分类名称不能为空"}).inputValidator({min:1,max:999,onerror:"分类名称不能为空"}); }) </script> <div class="pad_10"> <div class="common-form"> <form name="myform" action="?m=brand&c=brand&a=addClass&bid=<?php echo $_GET['bid']; ?>" method="post" id="myform"> <table width="100%" class="table_form contentWrap"> <tr> <td>当前品牌</td> <td> <?php echo $brand['name']; ?> </td> </tr> <tr> <td>分类名称</td> <td> <input type="text" name="info[name]" value="" class="input-text" id="name" size="30"></input> </td> </tr> </table> <div class="bk15"></div> <input name="dosubmit" type="submit" value="<?php echo L('submit')?>" class="dialog" id="dosubmit"> </form> </div> </div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin');?> <script type="text/javascript"> var cats = <?php echo $cats_json; ?>; $(function(){ $("#catid_1").change(function(){ var catid_1 = this.value; var html="<option value='all'>全部</option>"; if(catid_1 == 'all') { $("#catid_2").html(html); return ; } for(i in cats) { if(cats[i].catid == catid_1) { for(j in cats[i].child) { html += "<option value='"+cats[i].child[j].catid+"'>"+cats[i].child[j].catname+"</option>"; } $("#catid_2").html(html); } } }); }); </script> <div class="pad_10"> <form name="searchform" action="" method="get" > <input type="hidden" value="brand" name="m"> <input type="hidden" value="brand" name="c"> <input type="hidden" value="init" name="a"> <input type="hidden" value="<?php echo $_GET['menuid']; ?>" name="menuid"> <table width="100%" cellspacing="0" class="search-form"> <tbody> <tr> <td> <div class="explain-col"> 所属栏目:<select name="info[catid_1]" id="catid_1"> <option value="all">全部</option> <?php foreach ($cats AS $v) { echo "<option value='".$v['catid']."' ".($_GET['info']['catid_1']==$v['catid'] ? ' selected':'').">".$v['catname']."</option>"; } ?> </select> <select name="info[catid_2]" id="catid_2"> <option value="all">全部</option> <?php foreach ($cats[0]['child'] AS $v) { echo "<option value='".$v['catid']."' ".($_GET['info']['catid_2']==$v['catid'] ? ' selected':'').">".$v['catname']."</option>"; } ?> </select> 关联会员: <select name="info[userid]"> <?php foreach ($members AS $u) { echo "<option value='".$u['userid']."' ".($_GET['info']['userid']==$u['userid'] ? ' selected':'').">".$u['username']."</option>"; } ?> </select> <input type="submit" name="search" class="button" value="<?php echo L('search')?>" /> </div> </td> </tr> </tbody> </table> </form> <div class="bk10"></div> <div class="table-list"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="6%">ID</th> <th align="left" >名称</th> <th align="left" >所属栏目</th> <th width="15%" align="left" >关联会员</th> <th width="10%" >创建时间</th> <th width="15%" >管理操作</th> </tr> </thead> <tbody> <?php if(is_array($infos)){ foreach($infos as $info){ ?> <tr> <td align="center"><?php echo $info['id']?></td> <td><?php echo ($info['parentid']>0 ? "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" : "").$info['name']?></td> <td><?php echo $info['top_catname']?></td> <td><?php echo $info['username']?></td> <td><?php echo date('Y-m-d H:i', $info['create_time']); ?></td> <td> <?php if ($info['parentid']==0) { ?> <a href="javascript:void(0);" onclick="addClass('<?php echo $info['id']; ?>','<?php echo new_addslashes($info['name']); ?>')">添加分类</a> | <a href="javascript:void(0);" onclick="edit('<?php echo $info['id']?>','<?php echo new_addslashes($info['name'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=brand&c=brand&a=delete&bid=<?php echo $info['id']?>', '确认删除?')"><?php echo L('delete')?></a> <?php } else {?> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="editClass('<?php echo $info['id']?>','<?php echo new_addslashes($info['name'])?>')"><?php echo L('edit')?></a> | <a href="javascript:confirmurl('?m=brand&c=brand&a=delete&bid=<?php echo $info['id']?>', '确认删除?')"><?php echo L('delete')?></a> <?php }?> </td> </tr> <?php } } ?> </tbody> </table> </div> <div id="pages"><?php echo $pages?></div> </div> <script type="text/javascript"> <!-- window.top.$('#display_center_id').css('display','none'); function edit(id, name) { window.top.art.dialog({id:'edit'}).close(); window.top.art.dialog({title:name,id:'edit',iframe:'?m=brand&c=brand&a=edit&bid='+id,width:'500',height:'400'}, function(){var d = window.top.art.dialog({id:'edit'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'edit'}).close()}); } function addClass(id, name) { window.top.art.dialog({id:'addClass'}).close(); window.top.art.dialog({title:name+' 添加分类',id:'addClass',iframe:'?m=brand&c=brand&a=addClass&bid='+id,width:'500',height:'100'}, function(){var d = window.top.art.dialog({id:'addClass'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'addClass'}).close()}); } function editClass(id, name) { window.top.art.dialog({id:'editClass'}).close(); window.top.art.dialog({title:name,id:'editClass',iframe:'?m=brand&c=brand&a=editClass&bid='+id,width:'500',height:'250'}, function(){var d = window.top.art.dialog({id:'editClass'}).data.iframe;d.document.getElementById('dosubmit').click();return false;}, function(){window.top.art.dialog({id:'editClass'}).close()}); } //--> </script> </body> </html>
PHP
<?php /** * 会员前台品牌管理 */ defined('IN_PHPCMS') or exit('No permission resources.'); class index{ private $db; public $siteid; public $memberinfo; /** * 我的品牌 * Enter description here ... */ function __construct() { $this->db = pc_base::load_model('brand_model'); $this->siteid = get_siteid(); //获取当前用户信息 $memberModel = pc_base::load_model('member_model'); $userid = param::get_cookie('_userid'); if (!$userid) { showmessage("您的会话已过期,请重新登录!", "?m=content"); } //验证用户,获取用户信息 $this->memberinfo = $memberModel->get_one(array('userid'=>$userid)); //获取用户模型信息 $memberModel->set_model($this->memberinfo['modelid']); $this->_member_modelinfo = $memberModel->get_one(array('userid'=>$userid)); $this->_member_modelinfo = $this->_member_modelinfo ? $this->_member_modelinfo : array(); $memberModel->set_model(); if(is_array($this->memberinfo)) { $this->memberinfo = array_merge($this->memberinfo, $this->_member_modelinfo); } } /** * 品牌列表 */ public function init() { $in = new_addslashes(array_merge($_GET, $_POST)); $siteid = get_siteid(); $CATEGORYS = getcache('category_content_'.$siteid,'commons'); $total = $this->db->count(array('parentid'=>0, 'userid'=>$this->memberinfo['userid'])); $brands = $this->db->select(array('userid'=>$this->memberinfo['userid']), 'id,name,parentid,top_catname', '', 'sort DESC, parentid ASC'); $memberinfo = $this->memberinfo; $SEO['title'] = '我的品牌 - 会员中心'; include template('brand', 'init'); } /** * 添加品牌 */ public function add() { $memberinfo = $this->memberinfo; $catModel = pc_base::load_model('category_model'); if ($memberinfo['doupload'] != 1) { die('抱歉,您暂时没有权限执行添加操作,请联系管理员开启!'); } if ($_POST['dosubmit'] == 1) { //判断供应商品牌数量 最多添加6个品牌 if ($this->db->count(array('parentid'=>0, 'userid'=>$this->memberinfo['userid'])) > 5) { showmessage('最多添加6个品牌!'); } $catid_1 = intval($_POST['info']['catid_1']); $catid_2 = intval($_POST['info']['catid_2']); $cat_1 = $catModel->get_one(array('catid'=>$catid_1), 'catid,catname'); $cat_2 = $catModel->get_one(array('catid'=>$catid_2), 'catid,catname'); $data = array( 'userid' => $memberinfo['userid'], 'username' => $memberinfo['username'], 'catid' => $catid_2, 'top_catname' => $cat_1['catname'].' > '.$cat_2['catname'], 'name' => $_POST['info']['name'], 'parentid' => 0, 'create_time' => SYS_TIME, 'pcompanyname' => $_POST['info']['pcompanyname'] ? $_POST['info']['pcompanyname']:$memberinfo['companyname'], 'prealname' => $_POST['info']['prealname'] ? $_POST['info']['prealname']:$memberinfo['realname'], 'pqq' => $_POST['info']['pqq'] ? $_POST['info']['pqq']:$memberinfo['qq'], 'ptel' => $_POST['info']['ptel'] ? $_POST['info']['ptel']:$memberinfo['tel'], 'paddress' => $_POST['info']['paddress'] ? $_POST['info']['paddress']:$memberinfo['address'], ); if ($bid = $this->db->insert($data, true)) { $this->db->update(array('sort'=>$bid), 'id='.$bid); //添加子类 if (!empty($_POST['info']['child'])) { $_POST['info']['child'] = str_replace(',', ',', $_POST['info']['child']); $childs = explode(',', $_POST['info']['child']); foreach ($childs as $v) { $data['parentid'] = $bid; $data['name'] = trim($v); $data['sort'] = $bid; $this->db->insert($data); } } showmessage('操作成功!'); } else { showmessage('添加失败!'); } } //栏目 $cats = array(); $first_cats = $catModel->select(array('parentid' => TOP_PRODUCT_CATID, 'ismenu'=>1), 'catid, catname'); foreach ($first_cats AS $v) { $v['child'] = $catModel->select(array('parentid' => $v['catid']), 'catid, catname'); if ($v['child']) { $cats[] = $v; } } $cats_json = json_encode($cats); include template('brand', 'add'); } /** * 添加分类 */ public function addClass() { $memberinfo = $this->memberinfo; if (!intval($_GET['id'])) { showmessage('品牌不存在'); } $brand = $this->db->get_one(array('id'=>intval($_GET['id']))); if ($brand['parentid'] != 0) { showmessage('数据错误!'); } if ($memberinfo['userid'] != $brand['userid']) { showmessage('您没有权限对该品牌进行添加分类操作!'); } if (isset($_POST['info']['name'])) { $catModel = pc_base::load_model('category_model'); $data = array( 'userid' => $brand['userid'], 'username' => $brand['username'], 'catid' => $brand['catid'], 'top_catname' => $brand['top_catname'], 'name' => $_POST['info']['name'], 'parentid' => $brand['id'], 'sort' => $brand['id'], 'create_time' => SYS_TIME ); if ($this->db->insert($data)) { showmessage('操作成功!'); }else { showmessage('添加失败!'); } } include template('brand', 'addClass'); } /** * 编辑品牌 * */ public function edit() { $bid = intval($_GET['id']); $brand = $this->db->get_one('`id`='.$bid); $memberinfo = $this->memberinfo; $catModel = pc_base::load_model('category_model'); if ($_POST['dosubmit']) { $update_data = array( 'name' => $_POST['info']['name'], ); //栏目 /*if ($_POST['info']['catid_2'] != $brand['catid']) { $cat_2 = $catModel->get_one('catid='.$_POST['info']['catid_2'], 'catid,catname,parentid'); $cat_1 = $catModel->get_one('catid='.$cat_2['parentid'], 'catid,catname,parentid'); $update_data['catid'] = $cat_2['catid']; $update_data['top_catname'] = $cat_1['catname'].' > '.$cat_2['catname']; }*/ //会员 if ($brand['userid'] != $_POST['info']['userid']) { $update_data['pcompanyname'] = ($_POST['info']['pcompanyname'] ? $_POST['info']['pcompanyname']:$memberinfo['companyname']); $update_data['prealname'] = ($_POST['info']['prealname'] ? $_POST['info']['prealname']:$memberinfo['realname']); $update_data['pqq'] = ($_POST['info']['pqq'] ? $_POST['info']['pqq']:$memberinfo['qq']); $update_data['ptel'] = ($_POST['info']['ptel'] ? $_POST['info']['ptel']:$memberinfo['tel']); $update_data['paddress'] = ($_POST['info']['paddress'] ? $_POST['info']['paddress']:$memberinfo['address']); } $this->db->update($update_data, array('id'=>$bid)); //更新子分类 unset($update_data['name']); $this->db->update($update_data, array('parentid'=>$bid)); //更新关联产品信息 /*if (isset($cat_2['catid']) && $cat_2['catid']>0) { $this->db->updateRelativeProduct($brand['id'], $cat_2['catid']); }*/ showmessage('操作成功!'); } //栏目 $cats = array(); $first_cats = $catModel->select(array('parentid' => TOP_PRODUCT_CATID, 'ismenu'=>1), 'catid, catname'); foreach ($first_cats AS $v) { $v['child'] = $catModel->select(array('parentid' => $v['catid']), 'catid, catname'); if ($v['child']) { $cats[] = $v; } } $cats_json = json_encode($cats); $cat_2 = $catModel->get_one('catid='.$brand['catid'], 'catid,catname,parentid'); $cat_1 = $catModel->get_one('catid='.$cat_2['parentid'], 'catid,catname,parentid'); include template('brand', 'edit'); } /** * 更新分类 */ public function editClass() { $bid = intval($_GET['id']); $brand = $this->db->get_one('`id`='.$bid); if ($_POST['dosubmit'] == 1) { $this->db->update(array('name'=>$_POST['info']['name']), '`id`='.$bid); showmessage('操作成功!'); } include template('brand', 'editClass'); } /** * 删除品牌 */ public function delete() { $bid = intval($_GET['id']); if ($bid > 0) { $brands = $this->db->select('`id`='.$bid.' OR `parentid`='.$bid, 'id'); $ids = $bid; foreach ($brands AS $v) { $ids .= ','.$v['id']; } if (!empty($ids)) { $content_model = pc_base::load_model('content_model'); $content_model->set_model(13); //只针对产品模型 $content_model->update(array('bids'=>""), '`bids` IN('.$ids.')'); } $this->db->delete("`id`=".$bid." or `parentid`=".$bid); } header('Location:'.APP_PATH.'index.php?m=brand'); } /** * 栏目转换成品牌 */ public function change() { set_time_limit(0); $default_userid = 39; $default_username = '108wo@163.com'; $top_catid = TOP_PRODUCT_CATID; $cat_db = pc_base::load_model('category_model'); $cat_priv_db = pc_base::load_model('category_priv_model'); $content_db = pc_base::load_model('content_model'); $content_db->set_model(13); $brand_db = pc_base::load_model('brand_model'); $hits_db = pc_base::load_model('hits_model'); $tags_content_db = pc_base::load_model('tags_content_model'); $attachment_db = pc_base::load_model('attachment_model'); $attachment_index_db = pc_base::load_model('attachment_index_model'); $user_db = pc_base::load_model('member_model'); //$user_db->set_model(); //10供应商 12设计师 $level1_cats = $cat_db->select('parentid='.$top_catid, 'catid,catname'); foreach ($level1_cats AS $l1) { $level1_catid = $l1['catid']; $level1_catname = $l1['catname']; $level2_cats = $cat_db->select('parentid='.$level1_catid, 'catid,catname'); foreach ($level2_cats AS $l2) { //获取3级栏目 $level3_cats = $cat_db->select('parentid='.$l2['catid'], 'catid,userid,catname'); if ($level3_cats) { foreach ($level3_cats AS $l3) { //创建品牌 if (!$l3['userid']) { $l3['userid'] = $default_userid; } $level3_user = $user_db->get_one(array('userid'=>$l3['userid']), 'userid,username,modelid'); $user_db->set_model($level3_user['modelid']); $level3_user = array_merge($level3_user, $user_db->get_one(array('userid'=>$l3['userid']))); $user_db->set_model(""); $level1_brand = array( 'userid' => ($level3_user['userid'] ? $level3_user['userid'] : ''), 'username' => ($level3_user['username'] ? $level3_user['username'] : ''), 'catid' => $l2['catid'], 'top_catname' => $level1_catname.' > '.$l2['catname'], 'name' => $l3['catname'], 'parentid' => 0, 'sort' => 0, 'pcompanyname' => $level3_user['companyname'], 'prealname' => $level3_user['realname'], 'pqq' => $level3_user['qq'], 'paddress' => $level3_user['address'], 'ptel' => $level3_user['tel'], ); $level1_bid = $this->insertBrand($level1_brand); $level4_cats = $cat_db->select('parentid='.$l3['catid'], 'catid,userid,catname'); if ($level4_cats) { //存在4级栏目 foreach ($level4_cats AS $l4) { //创建分类 $level2_brand = $level1_brand; $level2_brand['name'] = $l4['catname']; $level2_brand['parentid'] = $level1_bid; $level2_brand['sort'] = $level1_id; $level2_bid = $this->insertBrand($level2_brand); //更新内容 $content_list = $content_db->select('catid='.$l4['catid'], 'id,catid'); if ($content_list) { foreach ($content_list AS $c) { $content_db->update(array('catid'=>$l2['catid'], 'bids'=>$level2_bid), 'id='.$c['id']); $hits_db->update(array('catid'=>$l2['catid']), 'hitsid="c-13-'.$c['id'].'"'); $tags_content_db->update(array('catid'=>$l2['catid'], 'contentid='.$c['id'])); //附件关联表 $att = $attachment_index_db->select(array('keyid'=>'c-'.$c['catid'].'-'.$c['id']), 'keyid,aid'); if ($att) { foreach ($att AS $at) { $attachment_index_db->update(array('keyid'=>'c-'.$l2['catid'].'-'.$c['id']), 'keyid="'.$at['keyid'].'"'); } } } } //更新附件表 $attachment_db->update(array('catid'=>$l2['catid']), 'catid='.$l4['catid']); //删除栏目 $cat_db->delete(array('catid'=>$l4['catid'])); $cat_priv_db->delete(array('catid'=>$l4['catid'])); } } else { //没有4级栏目 //更新内容 $content_list = $content_db->select('catid='.$l3['catid'], 'id,catid'); if ($content_list) { foreach ($content_list AS $c) { $content_db->update(array('catid'=>$l2['catid'], 'bids'=>$level1_bid), 'id='.$c['id']); $hits_db->update(array('catid'=>$l2['catid']), 'hitsid="c-13-'.$c['id'].'"'); $tags_content_db->update(array('catid'=>$l2['catid'], 'contentid='.$c['id'])); //附件关联表 $att = $attachment_index_db->select(array('keyid'=>'c-'.$c['catid'].'-'.$c['id']), 'keyid,aid'); if ($att) { foreach ($att AS $at) { $attachment_index_db->update(array('keyid'=>'c-'.$l2['catid'].'-'.$c['id']), 'keyid="'.$at['keyid'].'"'); } } } } } //更新附件表 $attachment_db->update(array('catid'=>$l2['catid']), 'catid='.$l3['catid']); //删除栏目 $cat_db->delete(array('catid'=>$l3['catid'])); $cat_priv_db->delete(array('catid'=>$l3['catid'])); unset($level3_user); } } } } die('over!'); } /** * 添加品牌 */ private function insertBrand($data) { $brand_db = pc_base::load_model('brand_model'); $data['create_time'] = time(); $insert_id = $brand_db->insert($data, true); if ($data['sort'] == 0) { $brand_db->update(array('sort'=>$insert_id), 'id='.$insert_id); } return $insert_id; } /** * 转换清单中的商品 */ public function changeOrderDetail() { set_time_limit(0); $cat_db = pc_base::load_model('category_model'); $cat_priv_db = pc_base::load_model('category_priv_model'); $content_db = pc_base::load_model('content_model'); $content_db->set_model(13); $brand_db = pc_base::load_model('brand_model'); $order_detail_db = pc_base::load_model('order_detail_model'); $order_details = $order_detail_db->select('','id,productid'); foreach ($order_details AS $od) { $product = $content_db->get_one(array('id'=>$od['productid']), 'id,catid,title,bids'); if ($product) { $catid = $product['catid']; if ($product['bids']) { $brand = $brand_db->get_one(array('id'=>$product['bids'])); if ($brand) { if ($brand['parentid']==0) { $bid = $brand['id']; } else { $bid = $brand['parentid']; } $update_data = array( 'catid' => $catid, 'bid' => $bid, 'supplierid' => $brand['userid'], 'suppliername' => $brand['username'], 'companyname' => $brand['pcompanyname'], 'nickname' => $brand['prealname'], 'qq' => $brand['pqq'], 'tel' => $brand['ptel'], ); $order_detail_db->update($update_data, 'id='.$od['id']); } } } } die('OVER'); } }
PHP
<?php /** * 后台品牌管理 */ defined('IN_PHPCMS') or exit('No permission resources.'); pc_base::load_app_class('admin','admin',0); class brand extends admin { private $db; public $siteid; function __construct() { parent::__construct(); $this->db = pc_base::load_model('brand_model'); $this->siteid = $this->get_siteid(); } /** * 品牌管理列表 */ public function init() { $catModel = pc_base::load_model('category_model'); $where = '1'; if (isset($_GET['info']['catid_1']) && $_GET['info']['catid_1']>0) { if (isset($_GET['info']['catid_2']) && $_GET['info']['catid_2']>0) { $where .= ' AND `catid`='.$_GET['info']['catid_2']; } else { $cat_1 = $catModel->get_one("`catid`=".$_GET['info']['catid_1'], 'arrchildid'); $where .= ' AND `catid` IN('.$cat_1['arrchildid'].')'; } } if (isset($_GET['info']['userid']) && $_GET['info']['userid']>0) { $where .= ' AND `userid`='.$_GET['info']['userid']; } $order = 'sort DESC, parentid ASC'; $page = (isset($_GET['page']) && $_GET['page']>0) ? $_GET['page'] : 1; $pagesize = 20; $infos = $this->db->listinfo($where, $order, $page, $pagesize); $pages = $this->db->pages; $memberModel = pc_base::load_model('member_model'); //栏目 $cats = array(); $first_cats = $catModel->select(array('parentid' => TOP_PRODUCT_CATID), 'catid, catname'); foreach ($first_cats AS $v) { $v['child'] = $catModel->select(array('parentid' => $v['catid']), 'catid, catname'); if ($v['child']) { $cats[] = $v; } } if (!$cats) { showmessage('请先添加栏目', WEB_PATH.'/index.php?m=admin&c=category', '', 'add'); } $cats_json = json_encode($cats); //会员 $where = '`groupid`=6 AND `vip`=1 AND `overduedate`>'.SYS_TIME; $members = $memberModel->select($where, 'userid, username', '', 'username ASC'); $big_menu = array('javascript:window.top.art.dialog({id:\'add\',iframe:\'?m=brand&c=brand&a=add\', title:\'添加品牌\', width:\'560\', height:\'400\', lock:true}, function(){var d = window.top.art.dialog({id:\'add\'}).data.iframe;var form = d.document.getElementById(\'dosubmit\');form.click();return false;}, function(){window.top.art.dialog({id:\'add\'}).close()});void(0);', '添加品牌'); include $this->admin_tpl('brand_manage'); } /** * 添加 */ public function add() { $catModel = pc_base::load_model('category_model'); $memberModel = pc_base::load_model('member_model'); if (isset($_POST['info']['name'])) { $catid_1 = intval($_POST['info']['catid_1']); $catid_2 = intval($_POST['info']['catid_2']); $cat_1 = $catModel->get_one(array('catid'=>$catid_1), 'catid,catname'); $cat_2 = $catModel->get_one(array('catid'=>$catid_2), 'catid,catname'); $user = $memberModel->get_one(array('userid'=>$_POST['info']['userid']), 'userid,username,modelid'); $memberModel->set_model($user['modelid']); $user = $memberModel->get_one(array('userid'=>$_POST['info']['userid'])); $data = array( 'userid' => $user['userid'], 'username' => $user['username'], 'catid' => $catid_2, 'top_catname' => $cat_1['catname'].'-'.$cat_2['catname'], 'name' => $_POST['info']['name'], 'parentid' => 0, 'create_time' => SYS_TIME, 'pcompanyname' => $_POST['info']['pcompanyname'] ? $_POST['info']['pcompanyname']:$user['companyname'], 'prealname' => $_POST['info']['prealname'] ? $_POST['info']['prealname']:$user['realname'], 'pqq' => $_POST['info']['pqq'] ? $_POST['info']['pqq']:$user['qq'], 'ptel' => $_POST['info']['ptel'] ? $_POST['info']['ptel']:$user['tel'], 'paddress' => $_POST['info']['paddress'] ? $_POST['info']['paddress']:$user['address'], ); if ($bid = $this->db->insert($data, true)) { $this->db->update(array('sort'=>$bid), 'id='.$bid); //添加子类 if (!empty($_POST['info']['child'])) { $_POST['info']['child'] = str_replace(',', ',', $_POST['info']['child']); $childs = explode(',', $_POST['info']['child']); foreach ($childs as $v) { $data['parentid'] = $bid; $data['name'] = trim($v); $data['sort'] = $bid; $this->db->insert($data); } } showmessage(L('operation_success'), '', '', 'add'); } } //栏目 $cats = array(); $first_cats = $catModel->select(array('parentid' => TOP_PRODUCT_CATID), 'catid, catname'); foreach ($first_cats AS $v) { $v['child'] = $catModel->select(array('parentid' => $v['catid']), 'catid, catname'); if ($v['child']) { $cats[] = $v; } } if (!$cats) { showmessage('请先添加栏目', '/index.php?m=admin&c=category', '', 'add'); } $cats_json = json_encode($cats); //会员 $where = '`groupid`=6 AND `vip`=1 AND `overduedate`>'.SYS_TIME; $members = $memberModel->select($where, 'userid, username', '', 'username ASC'); $show_header = true; $show_validator = true; include $this->admin_tpl('brand_add'); } /** * 添加分类 */ public function addClass() { if (!intval($_GET['bid'])) { showmessage('品牌不存在', '', '', 'add'); } $brand = $this->db->get_one(array('id'=>intval($_GET['bid']))); if (isset($_POST['info']['name'])) { $catModel = pc_base::load_model('category_model'); $data = array( 'userid' => $brand['userid'], 'username' => $brand['username'], 'catid' => $brand['catid'], 'top_catname' => $brand['top_catname'], 'name' => $_POST['info']['name'], 'parentid' => $brand['id'], 'sort' => $brand['id'], 'create_time' => SYS_TIME ); if ($this->db->insert($data)) { showmessage(L('operation_success'), '', '', 'addClass'); } } $show_header = true; $show_validator = true; include $this->admin_tpl('brand_addClass'); } /** * 编辑品牌 * */ public function edit() { $bid = intval($_GET['bid']); $brand = $this->db->get_one('`id`='.$bid); $catModel = pc_base::load_model('category_model'); $memberModel = pc_base::load_model('member_model'); if ($_GET['dosubmit'] && $_POST['info']['name']) { $update_data = array( 'name' => $_POST['info']['name'], ); //栏目 if ($_POST['info']['catid_2'] != $brand['catid']) { $cat_2 = $catModel->get_one('catid='.$_POST['info']['catid_2'], 'catid,catname,parentid'); $cat_1 = $catModel->get_one('catid='.$cat_2['parentid'], 'catid,catname,parentid'); $update_data['catid'] = $cat_2['catid']; $update_data['top_catname'] = $cat_1['catname'].'-'.$cat_2['catname']; } //会员 $user = $memberModel->get_one(array('userid'=>$_POST['info']['userid']), 'userid,username,modelid'); $memberModel->set_model($user['modelid']); $user = array_merge($user,$memberModel->get_one(array('userid'=>$_POST['info']['userid']))); $update_data['userid'] = $user['userid']; $update_data['username'] = $user['username']; $update_data['pcompanyname'] = ($_POST['info']['pcompanyname'] ? $_POST['info']['pcompanyname']:$user['companyname']); $update_data['prealname'] = ($_POST['info']['prealname'] ? $_POST['info']['prealname']:$user['realname']); $update_data['pqq'] = ($_POST['info']['pqq'] ? $_POST['info']['pqq']:$user['qq']); $update_data['ptel'] = ($_POST['info']['ptel'] ? $_POST['info']['ptel']:$user['tel']); $update_data['paddress'] = ($_POST['info']['paddress'] ? $_POST['info']['paddress']:$user['address']); $this->db->update($update_data, array('id'=>$bid)); //更新子分类 unset($update_data['name']); $this->db->update($update_data, array('parentid'=>$bid)); //更新关联产品信息 if (isset($cat_2['catid']) && $cat_2['catid']>0) { $this->db->updateRelativeProduct($brand['id'], $cat_2['catid']); } showmessage('操作成功!', '', '', 'edit'); } //栏目 $cats = array(); $first_cats = $catModel->select(array('parentid' => TOP_PRODUCT_CATID), 'catid, catname'); foreach ($first_cats AS $v) { $v['child'] = $catModel->select(array('parentid' => $v['catid']), 'catid, catname'); if ($v['child']) { $cats[] = $v; } } if (!$cats) { showmessage('请先添加栏目', '/index.php?m=admin&c=category', '', 'add'); } $cats_json = json_encode($cats); //会员 $where = '`groupid`=6 AND `vip`=1 AND `overduedate`>'.SYS_TIME; $members = $memberModel->select($where, 'userid, username', '', 'username ASC'); $cat_2 = $catModel->get_one('catid='.$brand['catid'], 'catid,catname,parentid'); $cat_1 = $catModel->get_one('catid='.$cat_2['parentid'], 'catid,catname,parentid'); $show_header = true; $show_validator = true; include $this->admin_tpl('brand_edit'); } /** * 更新分类 */ public function editClass() { $bid = intval($_GET['bid']); $brand = $this->db->get_one('`id`='.$bid); if (isset($_POST['info']['name']) && !empty($_POST['info']['name'])) { $this->db->update(array('name'=>$_POST['info']['name']), '`id`='.$bid); showmessage('操作成功 !', '', '', 'editClass'); } $show_header = true; $show_validator = true; include $this->admin_tpl('brand_editClass'); } /** * 删除品牌 */ public function delete() { $bid = intval($_GET['bid']); if ($bid > 0) { $brands = $this->db->select('`id`='.$bid.' OR `parentid`='.$bid, 'id'); $ids = $bid; foreach ($brands AS $v) { $ids .= ','.$v['id']; } if (!empty($ids)) { $content_model = pc_base::load_model('content_model'); $content_model->set_model(13); //只针对产品模型 $content_model->update(array('bids'=>""), '`bids` IN('.$ids.')'); } $this->db->delete("`id`=".$bid." or `parentid`=".$bid); showmessage('操作成功!', APP_PATH.'index.php?m=brand&c=brand'); } else { showmessage('操作失败!', APP_PATH.'index.php?m=brand&c=brand'); } } /** * 更新品牌缓存 */ public function cache() { set_time_limit(0); $user_db = pc_base::load_model('member_model'); $cat_db = pc_base::load_model('category_model'); $brands = $this->db->select(); foreach ($brands AS $v) { if ($v['userid']=="") { $this->db->delete('`id`='.$v['id'].' OR `parentid`='.$v['id']); continue; } $update_data = array(); if ($v['userid'] && $v['pcompanyname']=='' && $v['prealname']=='' && $v['ptel']=='' && $v['paddress']=='') { $user = $user_db->get_one(array('userid'=>$v['userid']), 'userid,username,modelid'); $user_db->set_model($user['modelid']); $user = array_merge($user, $user_db->get_one(array('userid'=>$v['userid']))); $user_db->set_model(""); $update_data = array( 'pcompanyname' => $user['companyname'], 'prealname' => $user['realname'], 'pqq' => $user['qq'], 'paddress' => $user['address'], 'ptel' => $user['tel'], ); } if ($v['catid']) { $cat_2 = $cat_db->get_one(array('catid'=>$v['catid']), 'catid,catname,parentid,arrparentid'); $update_data['top_catname'] = $cat_2['catname']; if (count(explode(',', $cat_2['arrparentid'])) == 3) { $cat_1 = $cat_db->get_one(array('catid'=>$cat_2['parentid']), 'catid,catname,arrparentid'); $update_data['top_catname'] = $cat_1['catname'] . ' > ' . $cat_2['catname']; } } if ($update_data) { $this->db->update($update_data, '`id`='.$v['id']); } } showmessage('更新成功!', APP_PATH.'index.php?m=brand&c=brand&a=init'); } }
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); return array('brand'); ?>
PHP
<?php defined('IN_PHPCMS') or exit('Access Denied'); defined('INSTALL') or exit('Access Denied'); $module = 'brand'; $modulename = '品牌管理'; $introduce = '品牌管理模块'; $author = 'eddy0909'; $authorsite = '#'; $authoremail = ''; ?>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header','admin'); ?> <div class="pad-lr-10"> <div class="table-list"> <form action="?m=template&c=style&a=updatename" method="post"> <table width="100%" cellspacing="0"> <thead> <tr> <th width="80"><?php echo L("style_identity")?></th> <th><?php echo L("style_chinese_name")?></th> <th><?php echo L("author")?></th> <th><?php echo L("style_version")?></th> <th><?php echo L("status")?></th> <th width="150"><?php echo L('operations_manage')?></th> </tr> </thead> <tbody> <?php if(is_array($list)): foreach($list as $v): ?> <tr> <td width="80" align="center"><?php echo $v['dirname']?></td> <td align="center"><input type="text" name="name[<?php echo $v['dirname']?>]" value="<?php echo $v['name']?>" /></td> <td align="center"><?php if($v['homepage']) {echo '<a href="'.$v['homepage'].'" target="_blank">';}?><?php echo $v['author']?><?php if($v['homepage']) {echo '</a>';}?></td> <td align="center"><?php echo $v['version']?></td> <td align="center"><?php if($v['disable']){echo L('icon_locked');}else{echo L("icon_unlock");}?></td> <td align="center" width="150"><a href="?m=template&c=style&a=disable&style=<?php echo $v['dirname']?>"><?php if($v['disable']){echo L("enable");}else{echo L('disable');}?></a> | <a href="?m=template&c=file&a=init&style=<?php echo $v['dirname']?>"><?php echo L("detail")?></a> | <a href="?m=template&c=style&a=export&style=<?php echo $v['dirname']?>"><?php echo L('export')?></a></td> </tr> <?php endforeach; endif; ?> </tbody> </table> <div class="btn"><input type="submit" class="button" name="dosubmit" value="<?php echo L('submit')?>" /></div> </form> </div> </div> <div id="pages"><?php echo $pages?></div> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin'); ?> <script type="text/javascript"> <!-- $(function(){ $.formValidator.initConfig({formid:"myform",autotip:true,onerror:function(msg,obj){window.top.art.dialog({content:msg,lock:true,width:'200',height:'50'}, function(){this.close();$(obj).focus();})}}); $("#cache").formValidator({onshow:"<?php echo L("enter_the_cache_input_will_not_be_cached")?>",onfocus:"<?php echo L("enter_the_cache_input_will_not_be_cached")?>",empty:true}).regexValidator({regexp:"num1",datatype:'enum',param:'i',onerror:"<?php echo L("cache_time_can_only_be_positive")?>"}); $("#num").formValidator({onshow:"<?php echo L('input').L("num")?>",onfocus:"<?php echo L('input').L("num")?>",empty:true}).regexValidator({regexp:"num1",datatype:'enum',param:'i',onerror:"<?php echo L('that_shows_only_positive_numbers')?>"}); $("#return").formValidator({onshow:"<?php echo L("please_enter_the_data_returned_value_by_default")?>:data。",onfocus:"<?php echo L("please_enter_the_data_returned_value_by_default")?>:data。",empty:true}); show_action('<?php echo $_GET['action']?>'); }) function show_action(obj) { $('.pc_action_list').hide(); $('#action_'+obj).show(); } //--> </script> <div class="pad-10"> <form action="?m=template&c=file&a=edit_pc_tag&style=<?php echo $this->style?>&dir=<?php echo $dir?>&file=<?php echo urlencode($file)?>&op=<?php echo $op?>&tag_md5=<?php echo $_GET['tag_md5']?>" method="post" id="myform"> <fieldset> <legend><?php echo L("module_configuration")?></legend> <table width="100%" class="table_form"> <tr> <th width="80"><?php echo L("module")?>:</th> <td class="y-bg"><?php echo $op?></td> </tr> <tr> <th width="80"><?php echo L('operation')?>:</th> <td class="y-bg"> <?php if(isset($html['action']) && is_array($html['action'])) { foreach($html['action'] as $key=>$value) { $checked = $_GET['action']==$key ? 'checked' : ''; echo '<label><input type="radio" name="action" onclick="location.href=\'?'.creat_url($key).'\'" '.$checked.' value="'.$key.'"> '.$value."</label>"; } }?></td> </tr> <?php if(isset($html[$_GET['action']]) && is_array($html[$_GET['action']])): foreach($html[$_GET['action']] as $k=>$v): ?> <tr> <th width="80"><?php echo $v['name']?>:</th> <td class="y-bg"><?php echo creat_form($k,$v,$_GET[$k], $op)?></td> </tr> <?php if(isset($v['ajax']['name']) && !empty($v['ajax']['name'])) {?> <tr> <th width="80"><?php echo $v['ajax']['name']?>:<?php if(isset($_GET[$v['ajax']['id']]) && !empty($_GET[$v['ajax']['id']])) echo '<script type="text/javascript">$.get(\'?m=template&c=file&a=public_ajax_get\', { html: \''.$_GET[$k].'\', id:\''.$v['ajax']['id'].'\', value:\''.$_GET[$v['ajax']['id']].'\', action: \''.$v['ajax']['action'].'\', op: \''.$op.'\', style: \'default\'}, function(data) {$(\'#'.$k.'_td\').html(data)});</script>'?></th> <td class="y-bg"><input type="text" size="20" value="<?php echo $_GET[$v['ajax']['id']]?>" id="<?php echo $v['ajax']['id']?>" name="<?php echo $v['ajax']['id']?>" class="input-text"><span id="<?php echo $k?>_td"></span></td> </tr> <?php }?> <?php endforeach;endif;?> </table> </fieldset> <div class="bk15"></div> <fieldset> <legend><?php echo L('vlan')?></legend> <table width="100%" class="table_form"> <tr> <th width="80"><?php echo L("public_allowpageing")?>:</th> <td class="y-bg"><input type="radio" name="page" value="$page"<?php if (isset($_GET['page'])) {echo ' checked';}?> /> <?php echo L("yes")?> <input type="radio" name="page" value=""<?php if (!isset($_GET['page'])) {echo ' checked';}?> /> <?php echo L("no")?></td> </tr> <tr> <th width="80"><?php echo L("num")?>:</th> <td class="y-bg"><input type="text" name="num" id="num" size="30" value="<?php echo $_GET['num']?>" /></td> </tr> <tr> <th width="80"><?php echo L("check")?>:</th> <td class="y-bg"><input type="text" name="return" id="return" size="30" value="<?php echo $_GET['return']?>" /> </td> </tr> <tr> <th width="80"><?php echo L("buffer_time")?>:</th> <td class="y-bg"><input type="text" name="cache" id="cache" size="30" value="<?php echo $_GET['cache']?>" /> </td> </tr> </table> </fieldset> <input type="submit" class="dialog" id="dosubmit" name="dosubmit" value="<?php echo L('submit')?>" /> </div> </form> </body> </html>
PHP
<?php defined('IN_ADMIN') or exit('No permission resources.'); include $this->admin_tpl('header', 'admin'); ?> <style type="text/css"> html{_overflow:hidden} .frmaa{float:left;width:80%; min-width: 870px; _width:870px;} .rraa{float: right; width:230px;} .pt{margin-top: 4px;} </style> <body style="overflow:hidden"> <div class="pad-10" style="padding-bottom:0px"> <div class="col-right"> <h3 class="f14"><?php echo L('common_variables')?></h3> <input type="button" class="button pt" onClick="javascript:insertText('{CSS_PATH}')" value="{CSS_PATH}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{JS_PATH}')" value="{JS_PATH}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{IMG_PATH}')" value="{IMG_PATH}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{APP_PATH}')" value="{APP_PATH}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{get_siteid()}')" value="{get_siteid()}" title="获取站点ID"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{loop $data $n $r}')" value="{loop $data $n $r}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{$r[\'url\']}')" value="{$r['url']}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{$r[\'title\']}')" value="{$r['title']}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{$r[\'thumb\']}')" value="{$r['thumb']}" title="<?php echo L('click_into')?>"/><br /> <input type="button" class="button pt" onClick="javascript:insertText('{strip_tags($r[description])}')" value="{strip_tags($r[description])}" title="<?php echo L('click_into')?>"/><br /> <?php if (is_array($file_t_v[$file_t])) { foreach($file_t_v[$file_t] as $k => $v) {?> <input type="button" class="button pt" onClick="javascript:insertText('<?php echo $k?>')" value="<?php echo $k?>" title="<?php echo $v ? $v :L('click_into')?>"/><br /> <?php } }?> </div> <div class="col-auto"> <form action="?m=template&c=file&a=edit_file&style=<?php echo $this->style?>&dir=<?php echo $dir?>&file=<?php echo $file?>" method="post" name="myform" id="myform"> <textarea name="code" id="code" style="height: 280px;width:96%; visibility:inherit"><?php echo $data?></textarea> <div class="bk10"></div> <input type="text" id="text" value="" /><input type="button" class="button" onClick="fnSearch()" value="<?php echo L('find_code')?>" /> <?php if ($is_write==0){echo '<font color="red">'.L("file_does_not_writable").'</font>';}?> <?php if (module_exists('tag')) {?><input type="button" class="button" onClick="create_tag()" value="<?php echo L('create_tag')?>" /> <input type="button" class="button" onClick="select_tag()" value="<?php echo L('select_tag')?>" /> <?php }?> <BR><input type="submit" id="dosubmit" class="button pt" name="dosubmit" value="<?php echo L('submit')?>" /> </form> </div> </div> <script type="text/javascript"> var oRange; var intCount = 0; var intTotalCount = 100; function fnSearch() { var strBeReplaced; var strReplace; strBeReplaced = $('#text').val(); fnNext(); $('#code').focus(); oRange = document.getElementById('code').createTextRange(); for (i=1; oRange.findText(strBeReplaced)!=false; i++) { if(i==intCount){ oRange.select(); oRange.scrollIntoView(); break; } oRange.collapse(false); } } function create_tag() { window.top.art.dialog({id:'add',iframe:'?m=tag&c=tag&a=add&ac=js', title:"<?php echo L('create_tag')?>", width:'700', height:'500', lock:true}, function(){var d = window.top.art.dialog({id:'add'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'add'}).close()}); } function insertText(text) { $('#code').focus(); var str = document.selection.createRange(); str.text = text; } function call(text) { $('#code').focus(); var str = document.selection.createRange(); var text_lenght = parseInt($('#text_lenght').val()); str.moveStart("character", text_lenght); str.select(); str.text = text; } function GetPoint() { if ($.browser.msie) { rng = event.srcElement.createTextRange(); rng.moveToPoint(event.x,event.y); rng.moveStart("character",-event.srcElement.value.length); var text_lenght = rng.text.length; } else { //alert($('#code').selectionStart); } $('#text_lenght').val(text_lenght); } function select_tag() { window.top.art.dialog({id:'list',iframe:'?m=tag&c=tag&a=lists', title:"<?php echo L('tag_list')?>", width:'700', height:'500', lock:true}, function(){var d = window.top.art.dialog({id:'add'}).data.iframe;var form = d.document.getElementById('dosubmit');form.click();return false;}, function(){window.top.art.dialog({id:'list'}).close()}); } function fnNext(){ if (intCount > 0 && intCount < intTotalCount){ intCount = intCount + 1; } else { intCount = 1 ; } } //--> </SCRIPT> </script> </body> </html>
PHP