A tumblelog CMS built on AJAX, PHP and MySQL.

util.class.php 20KB

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