admincp_blockxml.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. <?php
  2. /**
  3. * [Discuz!] (C)2001-2099 Comsenz Inc.
  4. * This is NOT a freeware, use is subject to license terms
  5. *
  6. * $Id: admincp_blockxml.php 25246 2011-11-02 03:34:53Z zhangguosheng $
  7. */
  8. if(!defined('IN_DISCUZ') || !defined('IN_ADMINCP')) {
  9. exit('Access Denied');
  10. }
  11. cpheader();
  12. $operation = in_array($operation, array('add', 'edit', 'update', 'delete')) ? $operation : 'list';
  13. $signtypearr = array(array('',cplang('blockxml_signtype_no')), array('MD5',cplang('blockxml_signtype_md5')));
  14. shownav('portal', 'blockxml');
  15. if($operation == 'add') {
  16. if(submitcheck('addsubmit')) {
  17. require_once libfile('function/importdata');
  18. import_block($_GET['xmlurl'], $_GET['clientid'], $_GET['key'], $_GET['signtype'], $_GET['ignoreversion']);
  19. require_once libfile('function/block');
  20. blockclass_cache();
  21. cpmsg('blockxml_xmlurl_add_succeed', 'action=blockxml', 'succeed');
  22. } else {
  23. showsubmenu('blockxml', array(
  24. array('list', 'blockxml', 0),
  25. array('add', 'blockxml&operation=add', 1)
  26. ));
  27. showtips('blockxml_tips');
  28. showformheader('blockxml&operation=add');
  29. showtableheader('blockxml_add');
  30. showsetting('blockxml_xmlurl', 'xmlurl', '', 'text');
  31. showsetting('blockxml_clientid', 'clientid', $blockxml['clientid'], 'text');
  32. showsetting('blockxml_signtype', array('signtype', $signtypearr), $blockxml['signtype'], 'select');
  33. showsetting('blockxml_xmlkey', 'key', $blockxml['key'], 'text');
  34. echo '<tr><td colspan="2"><input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.cplang('blockxml_import_ignore_version').'</label></td></tr>';
  35. showsubmit('addsubmit');
  36. showtablefooter();
  37. showformfooter();
  38. }
  39. } elseif($operation == 'edit' && !empty($_GET['id'])) {
  40. $id = intval($_GET['id']);
  41. if(!($blockxml = C::t('common_block_xml')->fetch($id))) {
  42. cpmsg('blockxml_xmlurl_notfound', '', 'error');
  43. }
  44. if(submitcheck('editsubmit')) {
  45. require_once libfile('function/importdata');
  46. import_block($_GET['xmlurl'], $_GET['clientid'], $_GET['key'], $_GET['signtype'], 1, $id);
  47. require_once libfile('function/block');
  48. blockclass_cache();
  49. cpmsg('blockxml_xmlurl_update_succeed', 'action=blockxml', 'succeed');
  50. } else {
  51. showsubmenu('blockxml', array(
  52. array('list', 'blockxml', 0),
  53. array('add', 'blockxml&operation=add', 1)
  54. ));
  55. showformheader('blockxml&operation=edit&id='.$id);
  56. showtableheader(cplang('blockxml_edit').' - '.$blockxml['name']);
  57. showsetting('blockxml_xmlurl', 'xmlurl', $blockxml['url'], 'text');
  58. showsetting('blockxml_clientid', 'clientid', $blockxml['clientid'], 'text');
  59. showsetting('blockxml_signtype', array('signtype', $signtypearr), $blockxml['signtype'], 'select');
  60. showsetting('blockxml_xmlkey', 'key', $blockxml['key'], 'text');
  61. showtablerow('', '', '<input class="checkbox" type="checkbox" name="ignoreversion" id="ignoreversion" value="1" /><label for="ignoreversion"> '.cplang('blockxml_import_ignore_version').'</label>');
  62. showsubmit('editsubmit');
  63. showtablefooter();
  64. showformfooter();
  65. }
  66. } elseif($operation == 'update' && !empty($_GET['id'])) {
  67. $id = intval($_GET['id']);
  68. if(!($blockxml = C::t('common_block_xml')->fetch($id))) {
  69. cpmsg('blockxml_xmlurl_notfound', '', 'error');
  70. }
  71. require_once libfile('function/importdata');
  72. import_block($blockxml['url'], $blockxml['clientid'], $blockxml['key'], $blockxml['signtype'], 1, $id);
  73. require_once libfile('function/block');
  74. blockclass_cache();
  75. cpmsg('blockxml_xmlurl_update_succeed', 'action=blockxml', 'succeed');
  76. } elseif($operation == 'delete' && !empty($_GET['id'])) {
  77. $id = intval($_GET['id']);
  78. if(!empty($_GET['confirm'])) {
  79. C::t('common_block_xml')->delete($id);
  80. require_once libfile('function/block');
  81. blockclass_cache();
  82. cpmsg('blockxml_xmlurl_delete_succeed', 'action=blockxml', 'succeed');
  83. } else {
  84. cpmsg('blockxml_xmlurl_delete_confirm', 'action=blockxml&operation=delete&id='.$id.'&confirm=yes', 'form');
  85. }
  86. } else {
  87. showsubmenu('blockxml', array(
  88. array('list', 'blockxml', 1),
  89. array('add', 'blockxml&operation=add', 0)
  90. ));
  91. showtableheader('blockxml_list');
  92. showsubtitle(array('blockxml_name', 'blockxml_xmlurl', 'operation'));
  93. foreach(C::t('common_block_xml')->range() as $row) {
  94. showtablerow('', array('class=""', 'class=""', 'class="td28"'), array(
  95. $row['name'],
  96. $row['url'],
  97. "<a href=\"".ADMINSCRIPT."?action=blockxml&operation=update&id=$row[id]\">".cplang('blockxml_update')."</a>&nbsp;&nbsp;".
  98. "<a href=\"".ADMINSCRIPT."?action=blockxml&operation=edit&id=$row[id]\">".cplang('edit')."</a>&nbsp;&nbsp;".
  99. "<a href=\"".ADMINSCRIPT."?action=blockxml&operation=delete&id=$row[id]\">".cplang('delete')."</a>&nbsp;&nbsp;"
  100. ));
  101. }
  102. showtablefooter();
  103. showformfooter();
  104. }
  105. ?>