A tumblelog CMS built on AJAX, PHP and MySQL.

util.class.php 26KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760
  1. <?php
  2. if (!defined('entry') || !entry) {
  3. die('Not a valid page');
  4. }
  5. /* ===========================
  6. Sorbet CMS - A PHP based tumblelog CMS forked from Gelato CMS
  7. Sorbet CMS is a free software licensed under the GPL 3.0
  8. =========================== */
  9. class util
  10. {
  11. public function version()
  12. {
  13. return "1.0";
  14. }
  15. public function codeName()
  16. {
  17. return "Strawberry";
  18. }
  19. public function beginsWith($str, $sub)
  20. {
  21. return (strpos($str, $sub) === 0);
  22. }
  23. public function endsWith($str, $sub)
  24. {
  25. return (substr($str, strlen($str) - strlen($sub)) == $sub);
  26. }
  27. public function getFileName($fileUrl)
  28. {
  29. $path = explode('/', $fileUrl);
  30. return $path[count($path)-1];
  31. }
  32. public function isMP3($fileUrl)
  33. {
  34. $util_class = new util();
  35. if ($util_class->endsWith($fileUrl, ".mp3")) {
  36. return true;
  37. } else {
  38. return false;
  39. }
  40. }
  41. public function getMP3File($remoteFileName)
  42. {
  43. $util_class = new util();
  44. if ($util_class->isMP3($remoteFileName)) {
  45. if ($util_class->getFile($remoteFileName)) {
  46. return true;
  47. } else {
  48. return false;
  49. }
  50. } elseif ($util_class->isGoEar($remoteFileName)) {
  51. return true;
  52. } elseif ($util_class->isOdeo($remoteFileName)) {
  53. return true;
  54. } else {
  55. return false;
  56. }
  57. }
  58. public function getGoEarCode($songUrl)
  59. {
  60. $pos = strpos($songUrl, "?v=");
  61. $lon = strlen($songUrl);
  62. $str = substr($songUrl, $pos + 3, $lon);
  63. return $str;
  64. }
  65. public function isGoEar($songUrl)
  66. {
  67. $util_class = new util();
  68. if ($util_class->beginsWith($songUrl, "http://www.goear.com/listen.php?v=") || $util_class->beginsWith($songUrl, "http://goear.com/listen.php?v=")) {
  69. return true;
  70. } else {
  71. return false;
  72. }
  73. }
  74. public function isOdeo($songUrl)
  75. {
  76. $util_class = new util();
  77. if ($util_class->beginsWith($songUrl, "http://odeo.com/audio/") || $util_class->beginsWith($songUrl, "http://www.odeo.com/audio/")) {
  78. return true;
  79. } else {
  80. return false;
  81. }
  82. }
  83. public function getOdeoCode($songUrl)
  84. {
  85. $params = explode("audio/", $songUrl);
  86. $params2 = explode("/", $params[1]);
  87. return $params2[0];
  88. }
  89. public function isImageFile($photoUrl)
  90. {
  91. $util_class = new util();
  92. if ($util_class->endsWith($photoUrl, ".jpg")) {
  93. return true;
  94. } elseif ($util_class->endsWith($photoUrl, ".gif")) {
  95. return true;
  96. } elseif ($util_class->endsWith($photoUrl, ".png")) {
  97. return true;
  98. } else {
  99. return false;
  100. }
  101. }
  102. public function getPhotoFile($remoteFileName)
  103. {
  104. $util_class = new util();
  105. if ($util_class->isImageFile($remoteFileName)) {
  106. if ($util_class->getFile($remoteFileName)) {
  107. return true;
  108. } else {
  109. return false;
  110. }
  111. } else {
  112. return false;
  113. }
  114. }
  115. public function getFile($remoteFileName)
  116. {
  117. $util_class = new util();
  118. $fileName = "../uploads/".$util_class->sanitizeName($util_class->getFileName($remoteFileName));
  119. $str = $util_class->_file_get_contents($remoteFileName);
  120. if (!$handle = fopen($fileName, 'w')) {
  121. //die("no se abrio de escritura");
  122. return false;
  123. }
  124. if (fwrite($handle, $str) === false) {
  125. //die("no se escribio");
  126. return false;
  127. }
  128. fclose($handle);
  129. return true;
  130. }
  131. public function isVimeoVideo($videoUrl)
  132. {
  133. $util_class = new util();
  134. if ($util_class->beginsWith($videoUrl, "http://vimeo.com/") || $util_class->beginsWith($videoUrl, "http://www.vimeo.com/")) {
  135. return true;
  136. } else {
  137. return false;
  138. }
  139. }
  140. public function getVimeoVideoUrl($videoUrl)
  141. {
  142. if (substr_count($videoUrl, "clip:")==1) {
  143. return array_pop(explode("clip:", $videoUrl));
  144. } else {
  145. return array_pop(explode("/", $videoUrl));
  146. }
  147. }
  148. public function isYoutubeVideo($videoUrl)
  149. {
  150. $url = explode("?", $videoUrl);
  151. $util_class = new util();
  152. if (($util_class->beginsWith($url[0], "https://") && $util_class->endsWith($url[0], ".youtube.com/watch")) || $util_class->beginsWith($url[0], "https://youtube.com/watch")) {
  153. return true;
  154. } else {
  155. return false;
  156. }
  157. }
  158. public function getYoutubeVideoUrl($videoUrl)
  159. {
  160. $params = explode("?v=", $videoUrl);
  161. $params2 = explode("&", $params[1]);
  162. return $params2[0];
  163. }
  164. public function isYahooVideo($videoUrl)
  165. {
  166. $util_class = new util();
  167. if ($util_class->beginsWith($videoUrl, "http://video.yahoo.com/watch/") || $util_class->beginsWith($videoUrl, "http://www.video.yahoo.com/watch/")) {
  168. return true;
  169. } else {
  170. return false;
  171. }
  172. }
  173. public function getYahooVideoCode($videoUrl)
  174. {
  175. $params = explode("http://video.yahoo.com/watch/", $videoUrl);
  176. $params2 = explode("/", $params[1]);
  177. $values[0] = $params2[0];
  178. $values[1] = $params2[1];
  179. return $values;
  180. }
  181. public function isGoogleVideoUrl($videoUrl)
  182. {
  183. $util_class = new util();
  184. if ($util_class->beginsWith($videoUrl, "http://video.google.com/videoplay?")) {
  185. return true;
  186. } else {
  187. return false;
  188. }
  189. }
  190. public function getGoogleVideoCode($videoUrl)
  191. {
  192. $params = explode("?docid=", $videoUrl);
  193. $params2 = explode("&", $params[1]);
  194. return $params2[0];
  195. }
  196. public function isMTVVideoUrl($videoUrl)
  197. {
  198. $util_class = new util();
  199. if ($util_class->beginsWith($videoUrl, "http://www.mtvmusic.com/video/?id=") || $util_class->beginsWith($videoUrl, "http://mtvmusic.com/video/?id=")) {
  200. return true;
  201. } else {
  202. return false;
  203. }
  204. }
  205. public function getMTVVideoCode($videoUrl)
  206. {
  207. $params = explode("?id=", $videoUrl);
  208. $params2 = explode("&", $params[1]);
  209. return $params2[0];
  210. }
  211. public function isDailymotionVideo($videoUrl)
  212. {
  213. $util_class = new util();
  214. if ($util_class->beginsWith($videoUrl, "http://www.dailymotion.com/video/") || $util_class->beginsWith($videoUrl, "http://dailymotion.com/video/")) {
  215. return true;
  216. } else {
  217. return false;
  218. }
  219. }
  220. public function getDailymotionVideoUrl($videoUrl)
  221. {
  222. $params = explode("video/", $videoUrl);
  223. $params2 = explode("_", $params[1]);
  224. return $params2[0];
  225. }
  226. public function isSlideSharePresentation($videoUrl)
  227. {
  228. $util_class = new util();
  229. if ($util_class->beginsWith($videoUrl, "[slideshare id=")) {
  230. return true;
  231. } else {
  232. return false;
  233. }
  234. }
  235. public function getSlideSharePresentationCode($videoUrl)
  236. {
  237. $videoUrl = str_replace("[slideshare id=", "", $videoUrl);
  238. $videoUrl = str_replace("&doc=", " ", $videoUrl);
  239. $videoUrl = str_replace("&w=", " ", $videoUrl);
  240. return explode(" ", $videoUrl);
  241. }
  242. public function isVideo($url)
  243. {
  244. $util_class = new util();
  245. if ($util_class->isYoutubeVideo($url)) {
  246. return true;
  247. } elseif ($util_class->isVimeoVideo($url)) {
  248. return true;
  249. } elseif ($util_class->isDailymotionVideo($url)) {
  250. return true;
  251. } elseif ($util_class->isYahooVideo($url)) {
  252. return true;
  253. } elseif ($util_class->isSlideSharePresentation($url)) {
  254. return true;
  255. } elseif ($util_class->isGoogleVideoUrl($url)) {
  256. return true;
  257. } elseif ($util_class->isMTVVideoUrl($url)) {
  258. return true;
  259. } else {
  260. return false;
  261. }
  262. }
  263. public function sendMail($to, $title, $body, $from)
  264. {
  265. $rp = trim($from);
  266. $org = "Sorbet CMS";
  267. $mailer = "Sorbet CMS Mailer";
  268. $head = '';
  269. $head .= "Content-Type: text/html \r\n";
  270. $head .= "Date: ". date('r'). " \r\n";
  271. $head .= "Return-Path: $rp \r\n";
  272. $head .= "From: $from \r\n";
  273. $head .= "Sender: $from \r\n";
  274. $head .= "Reply-To: $from \r\n";
  275. $head .= "Organization: $org \r\n";
  276. $head .= "X-Sender: $from \r\n";
  277. $head .= "X-Priority: 3 \r\n";
  278. $head .= "X-Mailer: $mailer \r\n";
  279. $body = str_replace("\r\n", "\n", $body);
  280. $body = str_replace("\n", "\r\n", $body);
  281. return @mail($to, $title, $body, $head);
  282. }
  283. public function getThemes()
  284. {
  285. $themes_dir = "themes";
  286. $dirs = array();
  287. $path = getcwd();
  288. $dir = (substr(PHP_OS, 0, 3) == 'WIN') ? $path."\\".$themes_dir : $path."/".$themes_dir;
  289. $dir = str_replace("admin\\", "", $dir);
  290. $dir = str_replace("admin/", "", $dir);
  291. $handle = opendir($dir);
  292. $i=0;
  293. while ($filename = readdir($handle)) {
  294. if ($filename != "." && $filename != ".." && $filename != ".svn") {
  295. $dirs[$i]=trim($filename);
  296. $i++;
  297. }
  298. }
  299. closedir($handle);
  300. return $dirs;
  301. }
  302. public function sanitizeName($name)
  303. {
  304. $name = preg_replace('/[\'"]/', '', $name);
  305. $name = preg_replace('/[^a-zA-Z0-9]+/', '-', $name);
  306. $name = trim($name, '-');
  307. $name = strtolower($name);
  308. //HACK: We need to rework the regular expression to allow the dot
  309. $ext = substr($name, strlen($name)-3, strlen($name));
  310. $body = substr($name, 0, strlen($name)-4);
  311. $name = $body.".".$ext;
  312. return $name;
  313. }
  314. public function _file_get_contents($path)
  315. {
  316. $util_class = new util();
  317. // Modified function from:
  318. // http://work.dokoku.net/Anieto2k/_file_get_contents.phps
  319. // http://www.anieto2k.com/2007/02/09/file_get_contents-y-dreamhost/
  320. if (!preg_match('/^http/i', $path)) {
  321. if ($fp = fopen($path, 'r')) {
  322. return fread($fp, 1024);
  323. } else {
  324. return false;
  325. }
  326. } else {
  327. if (extension_loaded('curl') && version_compare($util_class->get_curl_version(), '7.10.5', '>=')) {
  328. $ch = curl_init();
  329. $timeout = 5;
  330. curl_setopt($ch, CURLOPT_URL, $path);
  331. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  332. curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
  333. $file_contents = curl_exec($ch);
  334. curl_close($ch);
  335. if (is_string($file_contents)) {
  336. return $file_contents;
  337. } else {
  338. return false;
  339. }
  340. } else {
  341. $data = parse_url($path);
  342. if (!$data['host'] || $data['scheme'] != "http") {
  343. return false;
  344. }
  345. $f = @fsockopen($data['host'], ($data['port']) ? $data['port'] : 80, $e1, $e2, 3);
  346. if (!$f) {
  347. return false;
  348. }
  349. $q = "GET " . $data['path'] . (isset($data['query'])?'?'.$data['query']:'') . " HTTP/1.1\r\n";
  350. $q .= "Host: " . $data['host'] . "\r\n";
  351. $q .= "Connection: close\r\n";
  352. $q .= "Referer: //www.sorbetcms.net/\r\n\r\n";
  353. $recv = "";
  354. fwrite($f, $q);
  355. while (!feof($f)) {
  356. $recv .= fread($f, 1024);
  357. }
  358. $request = $q;
  359. $response = substr($recv, 0, strpos($recv, "\r\n\r\n"));
  360. $body = substr($recv, strpos($recv, "\r\n\r\n") + 4);
  361. if (preg_match('/http\/1\\.[0|1] ([0-9]{3})/i', $response, $res)) {
  362. if ($res[1][0] != "2") {
  363. return false;
  364. }
  365. } else {
  366. return false;
  367. }
  368. if (preg_match('/transfer-encoding:\s*chunked/i', $response)) {
  369. $tmp_body = $body;
  370. $new = "";
  371. $exit = false;
  372. while (!$exit) {
  373. if (preg_match('/^([0-9a-f]+).*?\r\n/i', $tmp_body, $res)) {
  374. $len = hexdec($res[1]);
  375. if ($len == "0") {
  376. $exit = true;
  377. break;
  378. }
  379. $new .= substr($tmp_body, strlen($res[0]), $len);
  380. $tmp_body = substr($tmp_body, strlen($res[0]) + $len + strlen("\r\n"));
  381. } else {
  382. $exit = true;
  383. }
  384. }
  385. $body = $new;
  386. }
  387. return $body;
  388. }
  389. }
  390. }
  391. public function get_curl_version()
  392. {
  393. $curl = 0;
  394. if (is_array(curl_version())) {
  395. $curl = curl_version();
  396. $curl = $curl['version'];
  397. } else {
  398. $curl = curl_version();
  399. $curl = explode(' ', $curl);
  400. $curl = explode('/', $curl[0]);
  401. $curl = $curl[1];
  402. }
  403. return $curl;
  404. }
  405. public function transform_offset($offset)
  406. {
  407. $sp = strpos($offset, ".")? explode(".", $offset) : false;
  408. if (is_array($sp)) {
  409. $minutes = strval($sp[1]);
  410. $off_h = $sp[0]*3600;
  411. $off_m = (($minutes*60)/100)*60;
  412. $off = $off_h+$off_m;
  413. } else {
  414. $off = ($offset*3600);
  415. }
  416. return $off;
  417. }
  418. public function getLangs()
  419. {
  420. $util_class = new util();
  421. $langs_dir = "languages";
  422. $dirs = array();
  423. $path = getcwd();
  424. $dir = (substr(PHP_OS, 0, 3) == 'WIN') ? $path."\\".$langs_dir : $path."/".$langs_dir;
  425. $dir = str_replace("admin\\", "", $dir);
  426. $dir = str_replace("admin/", "", $dir);
  427. $i=0;
  428. $cls_lang_dir = @ dir($dir);
  429. while (($directory = $cls_lang_dir->read()) !== false) {
  430. if ($directory != "." && $directory != "..") {
  431. $dir2 = (substr(PHP_OS, 0, 3) == 'WIN') ? $path."\\".$langs_dir."\\".$directory : $path."/".$langs_dir."/".$directory;
  432. $dir2 = str_replace("admin\\", "", $dir2);
  433. $dir2 = str_replace("admin/", "", $dir2);
  434. if (is_dir($dir2)) {
  435. $cls_lang_dir2 = @ dir($dir2);
  436. while (($directory2 = $cls_lang_dir2->read()) !== false) {
  437. if ($directory2 != "." && $directory2 != "..") {
  438. if (preg_match('|^\.+$|', $directory2)) {
  439. continue;
  440. }
  441. if (preg_match('|\.mo$|', $directory2)) {
  442. if (!in_array($directory2, $dirs)) {
  443. $dirs[$directory]=$util_class->displayLanguage(trim($directory));
  444. $i++;
  445. }
  446. }
  447. }
  448. }
  449. }
  450. }
  451. }
  452. $dirs = array_unique($dirs);
  453. return $dirs;
  454. }
  455. public function removeBadTags($source, $secure=false)
  456. {
  457. $util_class = new util();
  458. if ($secure) {
  459. $validTags ='<blockquote><code><em><i><strong><b><a>';
  460. } else {
  461. $validTags ='<p><ol><ul><li><a><abbr><acronym><blockquote><code><pre><em><i><strong><b><del><br><span><div><img>';
  462. }
  463. $source = strip_tags($source, $validTags);
  464. return preg_replace_callback('/<(.*?)>/i',
  465. function ($m) {
  466. $util_class = new util();
  467. return"<{$util_class->removeBadAtributes($m[1])}>";
  468. },
  469. $source
  470. );
  471. }
  472. public function removeBadAtributes($sourceTag)
  473. {
  474. $badAtributes = 'javascript:|onclick|ondblclick|onmousedown|onmouseup|onmouseover|onmousemove|onmouseout|onkeypress|onkeydown|onkeyup';
  475. $sourceTag = stripslashes($sourceTag);
  476. $sourceTag = preg_replace("/$badAtributes/i", "niceTry", $sourceTag);
  477. return $sourceTag;
  478. }
  479. public function type2Text($number)
  480. {
  481. $tmpStr = "";
  482. switch ($number) {
  483. case "1":
  484. $tmpStr = "post";
  485. break;
  486. case "2":
  487. $tmpStr = "photo";
  488. break;
  489. case "3":
  490. $tmpStr = "quote";
  491. break;
  492. case "4":
  493. $tmpStr = "url";
  494. break;
  495. case "5":
  496. $tmpStr = "conversation";
  497. break;
  498. case "6":
  499. $tmpStr = "video";
  500. break;
  501. case "7":
  502. $tmpStr = "mp3";
  503. break;
  504. }
  505. return $tmpStr;
  506. }
  507. public function type2Number($string)
  508. {
  509. $tmpStr = "";
  510. switch ($string) {
  511. case "post":
  512. $tmpStr = "1";
  513. break;
  514. case "photo":
  515. $tmpStr = "2";
  516. break;
  517. case "quote":
  518. $tmpStr = "3";
  519. break;
  520. case "url":
  521. $tmpStr = "4";
  522. break;
  523. case "conversation":
  524. $tmpStr = "5";
  525. break;
  526. case "video":
  527. $tmpStr = "6";
  528. break;
  529. case "mp3":
  530. $tmpStr = "7";
  531. break;
  532. }
  533. return $tmpStr;
  534. }
  535. public function trimString($string, $len=50)
  536. {
  537. if ($len>strlen(strip_tags($string)) or $len<1 or strlen(strip_tags($string))<1) {
  538. return strip_tags($string);
  539. }
  540. $string = strip_tags($string);
  541. return (strpos($string, " ", $len))?substr_replace($string, "...", $len):$string;
  542. }
  543. public function displayLanguage($lang)
  544. {
  545. $out = "";
  546. if (strpos($lang, '-')==2) {
  547. $lang = explode('-', $lang);
  548. }
  549. $language = is_array($lang)? $lang[0] : $lang;
  550. switch ($language) {
  551. case 'af': $out = __('Afrikaans'); break;
  552. case 'sq': $out = __('Albanian'); break;
  553. case 'ar': $out = __('Arabic'); break;
  554. case 'eu': $out = __('Basque'); break;
  555. case 'bg': $out = __('Bulgarian'); break;
  556. case 'be': $out = __('Belarusian'); break;
  557. case 'ca': $out = __('Catalan'); break;
  558. case 'zh': $out = __('Chinese'); break;
  559. case 'hr': $out = __('Croatian'); break;
  560. case 'cs': $out = __('Czech'); break;
  561. case 'da': $out = __('Danish'); break;
  562. case 'nl': $out = __('Dutch'); break;
  563. case 'en': $out = __('English'); break;
  564. case 'et': $out = __('Estonian'); break;
  565. case 'fo': $out = __('Faeroese'); break;
  566. case 'fa': $out = __('Farsi'); break;
  567. case 'fi': $out = __('Finnish'); break;
  568. case 'fr': $out = __('French'); break;
  569. case 'gd': $out = __('Gaelic'); break;
  570. case 'de': $out = __('German'); break;
  571. case 'el': $out = __('Greek'); break;
  572. case 'he': $out = __('Hebrew'); break;
  573. case 'hi': $out = __('Hindi'); break;
  574. case 'hu': $out = __('Hungarian'); break;
  575. case 'is': $out = __('Icelandic'); break;
  576. case 'id': $out = __('Indonesian'); break;
  577. case 'it': $out = __('Italian'); break;
  578. case 'ja': $out = __('Japanese'); break;
  579. case 'ko': $out = __('Korean'); break;
  580. case 'lv': $out = __('Latvian'); break;
  581. case 'lt': $out = __('Lithuanian'); break;
  582. case 'mk': $out = __('Macedonian'); break;
  583. case 'ms': $out = __('Malaysian'); break;
  584. case 'mt': $out = __('Maltese'); break;
  585. case 'no': $out = __('Norwegian'); break;
  586. case 'pl': $out = __('Polish'); break;
  587. case 'pt': $out = __('Portuguese'); break;
  588. case 'rm': $out = __('Rhaeto-Romanic'); break;
  589. case 'ro': $out = __('Romanian'); break;
  590. case 'ru': $out = __('Russian'); break;
  591. case 'sz': $out = __('Sami'); break;
  592. case 'sr': $out = __('Serbian'); break;
  593. case 'sk': $out = __('Slovak'); break;
  594. case 'sl': $out = __('Slovenian'); break;
  595. case 'sb': $out = __('Sorbian'); break;
  596. case 'es': $out = __('Spanish'); break;
  597. case 'sx': $out = __('Sutu'); break;
  598. case 'sv': $out = __('Swedish'); break;
  599. case 'th': $out = __('Thai'); break;
  600. case 'ts': $out = __('Tsonga'); break;
  601. case 'tn': $out = __('Tswana'); break;
  602. case 'tr': $out = __('Turkish'); break;
  603. case 'uk': $out = __('Ukrainian'); break;
  604. case 'ur': $out = __('Urdu'); break;
  605. case 've': $out = __('Venda'); break;
  606. case 'vi': $out = __('Vietnamese'); break;
  607. case 'xh': $out = __('Xhosa'); break;
  608. case 'ji': $out = __('Yiddish'); break;
  609. case 'zu': $out = __('Zulu'); break;
  610. default: $out = $language;
  611. }
  612. if (is_array($lang)) {
  613. $country = strtolower($lang[1]);
  614. switch ($country) {
  615. //Aca una lista con los paises. No se como tendr\EDa que hacer para hacer insensible a mayusculas o minusculas: es-MX o es-mx \BF?
  616. case 'sa': $out .= " (". __('Saudi Arabia'). ")"; break;
  617. case 'iq': $out .= " (". __('Iraq'). ")"; break;
  618. case 'eg': $out .= " (". __('Egypt'). ")"; break;
  619. case 'ly': $out .= " (". __('Libya'). ")"; break;
  620. case 'dz': $out .= " (". __('Algeria'). ")"; break;
  621. case 'ma': $out .= " (". __('Morocco'). ")"; break;
  622. case 'tn': $out .= " (". __('Tunisia'). ")"; break;
  623. case 'om': $out .= " (". __('Oman'). ")"; break;
  624. case 'ye': $out .= " (". __('Yemen'). ")"; break;
  625. case 'sy': $out .= " (". __('Syria'). ")"; break;
  626. case 'jo': $out .= " (". __('Jordan'). ")"; break;
  627. case 'lb': $out .= " (". __('Lebanon'). ")"; break;
  628. case 'kw': $out .= " (". __('Kuwait'). ")"; break;
  629. case 'ae': $out .= " (". __('U.A.E.'). ")"; break;
  630. case 'bh': $out .= " (". __('Bahrain'). ")"; break;
  631. case 'qa': $out .= " (". __('Qatar'). ")"; break;
  632. case 'tw': $out .= " (". __('Taiwan'). ")"; break;
  633. case 'cn': $out .= " (". __('PRC'). ")"; break;
  634. case 'hk': $out .= " (". __('Hong Kong SAR'). ")"; break;
  635. case 'sg': $out .= " (". __('Singapore'). ")"; break;
  636. case 'be': $out .= " (". __('Belgium'). ")"; break;
  637. case 'us': $out .= " (". __('United States'). ")"; break;
  638. case 'gb': $out .= " (". __('United Kingdom'). ")"; break;
  639. case 'au': $out .= " (". __('Australia'). ")"; break;
  640. case 'ca': $out .= " (". __('Canada'). ")"; break;
  641. case 'nz': $out .= " (". __('New Zealand'). ")"; break;
  642. case 'ie': $out .= " (". __('Ireland'). ")"; break;
  643. case 'za': $out .= " (". __('South Africa'). ")"; break;
  644. case 'jm': $out .= " (". __('Jamaica'). ")"; break;
  645. case 'bz': $out .= " (". __('Belize'). ")"; break;
  646. case 'tt': $out .= " (". __('Trinidad'). ")"; break;
  647. case 'ch': $out .= " (". __('Switzerland'). ")"; break;
  648. case 'lu': $out .= " (". __('Luxembourg'). ")"; break;
  649. case 'at': $out .= " (". __('Austria'). ")"; break;
  650. case 'li': $out .= " (". __('Liechtenstein'). ")"; break;
  651. case 'br': $out .= " (". __('Brazil'). ")"; break;
  652. case 'pt': $out .= " (". __('Portugal'). ")"; break;
  653. case 'mo': $out .= " (". __('Republic of Moldova'). ")"; break;
  654. case 'sz': $out .= " (". __('Lappish'). ")"; break;
  655. case 'mx': $out .= " (". __('Mexico'). ")"; break;
  656. case 'gt': $out .= " (". __('Guatemala'). ")"; break;
  657. case 'cr': $out .= " (". __('Costa Rica'). ")"; break;
  658. case 'pa': $out .= " (". __('Panama'). ")"; break;
  659. case 'do': $out .= " (". __('Dominican Republic'). ")"; break;
  660. case 've': $out .= " (". __('Venezuela'). ")"; break;
  661. case 'co': $out .= " (". __('Colombia'). ")"; break;
  662. case 'pe': $out .= " (". __('Peru'). ")"; break;
  663. case 'ar': $out .= " (". __('Argentina'). ")"; break;
  664. case 'ec': $out .= " (". __('Ecuador'). ")"; break;
  665. case 'cl': $out .= " (". __('Chile'). ")"; break;
  666. case 'uy': $out .= " (". __('Uruguay'). ")"; break;
  667. case 'py': $out .= " (". __('Paraguay'). ")"; break;
  668. case 'bo': $out .= " (". __('Bolivia'). ")"; break;
  669. case 'sv': $out .= " (". __('El Salvador'). ")"; break;
  670. case 'hn': $out .= " (". __('Honduras'). ")"; break;
  671. case 'ni': $out .= " (". __('Nicaragua'). ")"; break;
  672. case 'pr': $out .= " (". __('Puerto Rico'). ")"; break;
  673. case 'fi': $out .= " (". __('Finland'). ")"; break;
  674. default: $out .= "(".$country.")";
  675. }
  676. }
  677. return $out;
  678. }
  679. public function init_plugins()
  680. {
  681. global $conf;
  682. $actives = json_decode($conf->active_plugins, 1);
  683. $actives = $actives[1];
  684. foreach ((array)$actives as $index => $plugin) {
  685. if (!file_exists(Absolute_Path."plugins/".$plugin)) {
  686. unset($actives[$index]);
  687. continue;
  688. } else {
  689. require_once(Absolute_Path.'plugins/'.$plugin);
  690. }
  691. if (!class_exists($index)) {
  692. continue;
  693. }
  694. $GLOBALS['plugins::$instances'][$index] = new $index;
  695. }
  696. }
  697. }
  698. ?>