source: trunk/inc/shared_sites.inc.php

Last change on this file was 2, checked in by george, 14 years ago
  • Přidáno: Trunk revize 13719.
File size: 2.3 KB
Line 
1<?php
2
3/***************************************************************************
4* Dolphin Smart Community Builder
5* -----------------
6* begin : Mon Mar 23 2006
7* copyright : (C) 2006 BoonEx Group
8* website : http://www.boonex.com/
9* This file is part of Dolphin - Smart Community Builder
10*
11* Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
12* http://creativecommons.org/licenses/by/3.0/
13*
14* Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
15* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16* See the Creative Commons Attribution 3.0 License for more details.
17* You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
18* see license.txt file; if not, write to marketing@boonex.com
19***************************************************************************/
20
21require_once(BX_DIRECTORY_PATH_INC . 'db.inc.php');
22
23define('SHARED_SITES_TABLE', 'sys_shared_sites');
24define('SHARED_SITES_CACHE', 'sys_shared_sites.inc');
25
26function getSitesArray ($sLink) {
27 $sLink = htmlentities(($sLink));
28 if ( file_exists(BX_DIRECTORY_PATH_CACHE . SHARED_SITES_CACHE) && filesize(BX_DIRECTORY_PATH_CACHE . SHARED_SITES_CACHE) )
29 $aSites = unserialize( file_get_contents(BX_DIRECTORY_PATH_CACHE . SHARED_SITES_CACHE) );
30 else {
31 $aSites = array();
32 // cache is empty | load data from DB
33 $sqlQuery = "SELECT * FROM `" . SHARED_SITES_TABLE . "`";
34 $rResult = db_res($sqlQuery);
35 if (mysql_num_rows($rResult) > 0) {
36 while( $aRow = mysql_fetch_assoc($rResult) ) {
37 $aSites[$aRow['Name']] = array(
38 'id' => $aRow['ID'],
39 'url' => $aRow['URL'],
40 'icon' => $aRow['Icon'],
41 );
42 }
43 // write data into cache file
44 $fHandle = fopen(BX_DIRECTORY_PATH_CACHE . SHARED_SITES_CACHE, 'w');
45 fwrite($fHandle, serialize($aSites));
46 fclose($fHandle);
47 }
48 }
49
50 foreach ($aSites as $sKey => $aValue)
51 $aSites[$sKey]['url'] .= $sLink;
52
53 return $aSites;
54}
55
56?>
Note: See TracBrowser for help on using the repository browser.