plugin.php 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. <?php
  2. /*
  3. [UCenter] (C)2001-2099 Comsenz Inc.
  4. This is NOT a freeware, use is subject to license terms
  5. $Id: plugin.php 1059 2011-03-01 07:25:09Z monkey $
  6. */
  7. !defined('IN_UC') && exit('Access Denied');
  8. class pluginmodel {
  9. var $db;
  10. var $base;
  11. function __construct(&$base) {
  12. $this->pluginmodel($base);
  13. }
  14. function pluginmodel(&$base) {
  15. $this->base = $base;
  16. $this->db = $base->db;
  17. }
  18. function get_plugins() {
  19. include_once UC_ROOT.'./lib/xml.class.php';
  20. $arr = array();
  21. $dir = UC_ROOT.'./plugin';
  22. $d = opendir($dir);
  23. while($f = readdir($d)) {
  24. if($f != '.' && $f != '..' && $f != '.svn' && is_dir($dir.'/'.$f)) {
  25. $s = file_get_contents($dir.'/'.$f.'/plugin.xml');
  26. $arr1 = xml_unserialize($s);
  27. $arr1['dir'] = $f;
  28. unset($arr1['lang']);
  29. $arr[] = $arr1;
  30. }
  31. }
  32. $arr = $this->orderby_tabindex($arr);
  33. return $arr;
  34. }
  35. function get_plugin($pluginname) {
  36. $f = file_get_contents(UC_ROOT."./plugin/$pluginname/plugin.xml");
  37. include_once UC_ROOT.'./lib/xml.class.php';
  38. return xml_unserialize($f);
  39. }
  40. function get_plugin_by_name($pluginname) {
  41. $dir = UC_ROOT.'./plugin';
  42. $s = file_get_contents($dir.'/'.$pluginname.'/plugin.xml');
  43. return xml_unserialize($s, TRUE);
  44. }
  45. function orderby_tabindex($arr1) {
  46. $arr2 = array();
  47. $t = array();
  48. foreach($arr1 as $k => $v) {
  49. $t[$k] = $v['tabindex'];
  50. }
  51. asort($t);
  52. $arr3 = array();
  53. foreach($t as $k => $v) {
  54. $arr3[$k] = $arr1[$k];
  55. }
  56. return $arr3;
  57. }
  58. function cert_get_file() {
  59. return UC_ROOT.'./data/tmp/ucenter_'.substr(md5(UC_KEY), 0, 16).'.cert';
  60. }
  61. function cert_dump_encode($arr, $life = 0) {
  62. $s = "# UCenter Applications Setting Dump\n".
  63. "# Version: UCenter ".UC_SERVER_VERSION."\n".
  64. "# Time: ".$this->time."\n".
  65. "# Expires: ".($this->time + $life)."\n".
  66. "# From: ".UC_API."\n".
  67. "#\n".
  68. "# This file was BASE64 encoded\n".
  69. "#\n".
  70. "# UCenter Community: http://www.discuz.net\n".
  71. "# Please visit our website for latest news about UCenter\n".
  72. "# --------------------------------------------------------\n\n\n".
  73. wordwrap(base64_encode(serialize($arr)), 50, "\n", 1);
  74. return $s;
  75. }
  76. function cert_dump_decode($certfile) {
  77. $s = @file_get_contents($certfile);
  78. if(empty($s)) {
  79. return array();
  80. }
  81. preg_match("/# Expires: (.*?)\n/", $s, $m);
  82. if(empty($m[1]) || $m[1] < $this->time) {
  83. unlink($certfile);
  84. return array();
  85. }
  86. $s = preg_replace("/(#.*\s+)*/", '', $s);
  87. $arr = daddslashes(unserialize(base64_decode($s)), 1);
  88. return $arr;
  89. }
  90. }
  91. ?>