ConfigAction.class.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <?php
  2. /**
  3. *
  4. * Config(系统配置文件)
  5. */
  6. if(!defined("Ainaphp")) exit("Access Denied");
  7. class ConfigAction extends AdminbaseAction {
  8. protected $dao, $config,$seo_config ,$user_config, $site_config, $mail_config, $attach_config;
  9. function _initialize()
  10. {
  11. parent::_initialize();
  12. $this->dao = M('Config');
  13. $this->assign($this->Config);
  14. }
  15. public function index() {
  16. $this->config = $config = $this->dao->select();
  17. foreach($config as $key=>$r) {
  18. if($r['groupid']==1){
  19. if(APP_LANG){
  20. if($r['lang']==LANG_ID) $this->user_config[$r['varname']]=$r;
  21. }else{
  22. $this->user_config[$r['varname']]=$r;
  23. }
  24. }
  25. if($r['groupid']==2){
  26. if(APP_LANG){
  27. if($r['lang']==LANG_ID) $this->site_config[$r['varname']]=$r;
  28. }else{
  29. $this->site_config[$r['varname']]=$r;
  30. }
  31. }
  32. }
  33. $this->assign('user_config',$this->user_config);
  34. $this->assign('site_config',$this->site_config);
  35. $this->display();
  36. }
  37. public function sys() {
  38. $sysconfig = F("sys.config");
  39. $Urlrule=array();
  40. foreach((array)$this->Urlrule as $key => $r){
  41. $urls=$r['showurlrule'].':::'.$r['listurlrule'];
  42. if(empty($r['ishtml']))$Urlrule[$urls]=L('URL_SHOW_URLRULE').":".$r['showexample'].", ".L('URL_LIST_URLRULE').":".$r['listexample'];
  43. }
  44. $this->assign('Urlrule',$Urlrule);
  45. $this->assign('Lang',F('Lang'));
  46. $this->assign('yesorno',array(0 => L('no'),1 => L('yes')));
  47. $this->assign('openarr',array(0 => L('close_select'),1 => L('open_select')));
  48. $this->assign('enablearr',array(0 => L('disable'),1 => L('enable')));
  49. $this->assign('urlmodelarr',array(0 => L('URL_MODEL0').'(m=module&a=action&id=1)',1 => L('URL_MODEL1').'(index.php/Index_index_id_1)',2 => L('URL_MODEL2').'(Index_index_id_1)'));
  50. $this->assign('readtypearr', array(0=>'readfile',1=> 'redirect'));
  51. $this->assign($sysconfig);
  52. $this->display();
  53. }
  54. public function add() {
  55. $this->display();
  56. }
  57. public function delete() {
  58. $name = MODULE_NAME;
  59. $model = M ( $name );
  60. $id = $_REQUEST ['varname'];
  61. if (isset ( $id )) {
  62. if(false!==$model->where("varname='$id'")->delete()){
  63. if(in_array($name,$this->cache_model)) savecache($name);
  64. $this->success(L('delete_ok'));
  65. }else{
  66. $this->error(L('delete_error').': '.$model->getDbError());
  67. }
  68. }else{
  69. $this->error (L('do_empty'));
  70. }
  71. }
  72. public function insert() {
  73. if(APP_LANG)$_POST['lang']=LANG_ID;
  74. if (false === $this->dao->create ()) {
  75. $this->error ( $this->dao->getError () );
  76. }
  77. $list=$this->dao->add ();
  78. savecache('Config');
  79. if ($list!==false) {
  80. $this->success (L('add_ok'));
  81. }else{
  82. $this->error (L('add_error'));
  83. }
  84. }
  85. public function member() {
  86. if(APP_LANG)$where = ' and lang='.LANG_ID;
  87. $config = $this->dao->where("groupid=3".$where)->select();
  88. $this->assign('member_config',$config);
  89. $this->display();
  90. }
  91. public function attach(){
  92. $this->display();
  93. }
  94. public function mail() {
  95. $this->display();
  96. }
  97. public function dosite() {
  98. if(C('TOKEN_ON') && !$this->dao->autoCheckToken($_POST))$this->error (L('_TOKEN_ERROR_'));
  99. if(APP_LANG && (isset($_POST['site_name']) || isset($_POST['member_emailchecktpl'])))$where = ' and lang='.LANG_ID;
  100. foreach($_POST as $key=>$value){
  101. $data['value']=$value;
  102. $f = $this->dao->where("varname='".$key."'".$where)->save($data);
  103. }
  104. $f = savecache(MODULE_NAME);
  105. if(isset($_POST['HOME_ISHTML']) && $_POST['HOME_ISHTML']=='')@unlink(__ROOT__.'index.html');
  106. if($_POST['DEFAULT_LANG'])routes_cache($_POST['URL_URLRULE']);
  107. if($f){
  108. $this->success(L('do_ok'));
  109. }else{
  110. $this->error (L('do_error'));
  111. }
  112. }
  113. public function testmail(){
  114. $mailto = $_GET['mail_to'];
  115. $message = 'Ainaphp test mail';
  116. $r = sendmail($mailto,$this->Config['site_name'],$message,$_POST);
  117. if($r==true){
  118. $this->ajaxReturn($r,L('mailsed_ok'),1);
  119. }else{
  120. $this->ajaxReturn(0,L('mailsed_error').$r,1);
  121. }
  122. }
  123. }
  124. ?>