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