A tumblelog CMS built on AJAX, PHP and MySQL.

functions.php 20KB

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