4 * Copyright 2016, Franck Villaume - TrivialDev
6 * This file is a part of FusionForge.
8 * FusionForge is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * FusionForge is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with FusionForge. If not, see <http://www.gnu.org/licenses/>.
22 require dirname(__FILE__).'/../../env.inc.php';
23 require_once $gfcommon.'include/pre.php';
24 require_once $gfcommon.'common/include/utils.php';
26 $res = db_query_params('SELECT assoc_site_id, title, link, onlysw, status_id, rank
27 FROM plugin_globalsearch_assoc_site WHERE enabled=$1 ORDER BY rank', array('t'));
29 if ($res && db_numrows($res)) {
30 while ($arr = db_fetch_array($res)) {
32 $filename = $link.'/export/rss_sfprojects.php?showall=1';
33 $simpleXmlLoadedFile = simplexml_load_file($filename);
34 $res2 = db_query_params('DELETE FROM plugin_globalsearch_assoc_site_project WHERE assoc_site_id=$1', array($arr['assoc_site_id']));
35 if ($simpleXmlLoadedFile !== false) {
36 $xmlObjectsArray = $simpleXmlLoadedFile->channel->item;
37 foreach ($xmlObjectsArray as $key => $xmlObject) {
38 $title = (string)$xmlObject->title;
39 $projectsubLink = (string)$xmlObject->link;
40 if ($projectsubLink[0] == '/') {
41 $projectsubLink = substr($projectsubLink, 1);
43 $projectLink = $link.$projectsubLink;
44 $description = htmlentities((string)$xmlObject->description);
45 $res2 = db_query_params('INSERT INTO plugin_globalsearch_assoc_site_project (assoc_site_id, project_title, project_link, project_description) '.
46 'VALUES ($1, $2, $3, $4)', array($arr['assoc_site_id'], $title, $projectLink, $description));
48 $res2 = db_query_params('UPDATE plugin_globalsearch_assoc_site SET status_id=$1 WHERE assoc_site_id=$2', array(2, $arr['assoc_site_id']));
50 $res2 = db_query_params('UPDATE plugin_globalsearch_assoc_site SET status_id=$1 WHERE assoc_site_id=$2', array(4, $arr['assoc_site_id']));