freq_list = array ( "always" => GSLAN_11, "hourly" => GSLAN_12, "daily" => GSLAN_13, "weekly" => GSLAN_14, "monthly" => GSLAN_15, "yearly" => GSLAN_16, "never" => LAN_NEVER ); if(isset($_POST['edit'])) { $this -> editSme(); } if(isset($_POST['delete'])) { $this -> deleteSme(); } if(isset($_POST['add_link'])) { $this -> addLink(); } if(isset($_POST['import_links'])) { $this -> importLink(); } if($this -> message) { $mes->addSuccess($this -> message); // echo "
".$this -> message."

"; } if(e_QUERY == "new") { $this -> doForm(); } else if(e_QUERY == "import") { $this -> importSme(); } else if(e_QUERY == "instructions") { $this -> instructions(); } else if(!vartrue($_POST['edit'])) { $this -> showList(); } } function showList() { $mes = e107::getMessage(); $sql = e107::getDb(); $ns = e107::getRender(); $tp = e107::getParser(); $frm = e107::getForm(); $gen = new convert; $count = $sql -> select("gsitemap", "*", "gsitemap_id !=0 ORDER BY gsitemap_order ASC"); if (!$count) { $text = "
".GSLAN_39."

" .$frm->admin_button('import',LAN_YES,'submit')."
"; $mes->addInfo($text); $ns -> tablerender(GSLAN_24, $mes->render()); return; } else { $text = "
"; $glArray = $sql -> db_getList(); foreach($glArray as $row2) { $datestamp = $gen->convert_date($row2['gsitemap_lastmod'], "short"); $rowStyle = (vartrue($rowStyle) == "odd") ? "even" : "odd"; $text .= " "; } } $text .= "
Id ".LAN_NAME." ".LAN_URL." ".GSLAN_27." ".GSLAN_28." ".GSLAN_9." ".LAN_OPTIONS."
".$row2['gsitemap_id'] ." ".$tp->toHTML($row2['gsitemap_name'],"","defs")." ".$row2['gsitemap_url']." ".$datestamp." ".$this->freq_list[($row2['gsitemap_freq'])]." ".$row2['gsitemap_priority'] ."
\n
"; $ns -> tablerender(GSLAN_24, $mes->render(). $text); } function editSme() { $sql = e107::getDb(); $tp = e107::getParser(); $e_idt = array_keys($_POST['edit']); if($sql -> select("gsitemap", "*", "gsitemap_id='".$e_idt[0]."' ")) { $foo = $sql -> db_Fetch(); $foo['gsitemap_name'] = $tp -> toFORM($foo['gsitemap_name']); $foo['gsitemap_url'] = $tp -> toFORM($foo['gsitemap_url']); $this -> doForm($foo); } } function doForm($editArray=FALSE) { $frm = e107::getForm(); $sql = e107::getDb(); $ns = e107::getRender(); $mes = e107::getMessage(); $count = $sql -> select("gsitemap", "*", "gsitemap_id !=0 ORDER BY gsitemap_id ASC"); $text = "
".LAN_NAME." ".$frm->text('gsitemap_name', $editArray['gsitemap_name'], '100', array('class' => 'tbox input-text span3'))."
".LAN_URL." ".$frm->text('gsitemap_url', $editArray['gsitemap_url'], '100', array('class' => 'tbox input-text span3'))."
".GSLAN_10."
".GSLAN_9."
".LAN_ORDER."
".LAN_VISIBILITY." ".r_userclass("gsitemap_active", $editArray['gsitemap_active'], 'off', "nobody,public,guest,member,admin,classes,language")."
"; if(is_array($editArray)) { $text .= $frm->admin_button('add_link',LAN_UPDATE,'update')." "; } else { $text .= $frm->admin_button('add_link',LAN_CREATE,'create'); } $text .= "
"; $ns -> tablerender(GSLAN_29, $mes->render(). $text); } function addLink() { $log = e107::getAdminLog(); $sql = e107::getDb(); $tp = e107::getParser(); $gmap = array( 'gsitemap_name' => $tp->toDB($_POST['gsitemap_name']), 'gsitemap_url' => $tp->toDB($_POST['gsitemap_url']), 'gsitemap_priority' => $_POST['gsitemap_priority'], 'gsitemap_lastmod' => $_POST['gsitemap_lastmod'], 'gsitemap_freq' => $_POST['gsitemap_freq'], 'gsitemap_order' => $_POST['gsitemap_order'], 'gsitemap_active' => $_POST['gsitemap_active'] ); if(isset($_POST['gsitemap_id'])) { $this -> message = $sql -> db_UpdateArray("gsitemap", $gmap, ' WHERE gsitemap_id= '.intval($_POST['gsitemap_id'])) ? LAN_UPDATED : LAN_UPDATED_FAILED; $log->logArrayAll('GSMAP_04',$gmap); } else { $gmap['gsitemap_img'] = $_POST['gsitemap_img']; $gmap['gsitemap_cat'] = $_POST['gsitemap_cat']; $this -> message = ($sql -> db_Insert('gsitemap',$gmap)) ? LAN_CREATED : LAN_CREATED_FAILED; $log->logArrayAll('GSMAP_03',$gmap); } } function deleteSme() { $log = e107::getAdminLog(); $sql = e107::getDb(); $d_idt = array_keys($_POST['delete']); $this -> message = ($sql -> db_Delete("gsitemap", "gsitemap_id='".$d_idt[0]."'")) ? LAN_DELETED : LAN_DELETED_FAILED; $log->log_event('GSMAP_02', $this->message.': '.$d_idt[0], E_LOG_INFORMATIVE,''); } // Import site links function importSme() { global $PLUGINS_DIRECTORY; $ns = e107::getRender(); $sql = e107::getDb(); $sql2 = e107::getDb('sql2'); $frm = e107::getForm(); $mes = e107::getMessage(); $existing = array(); $sql -> select("gsitemap", "*"); while($row = $sql->fetch()) { $existing[] = $row['gsitemap_name']; } $importArray = array(); /* sitelinks ... */ $sql -> select("links", "*", "ORDER BY link_order ASC", "no-where"); $nfArray = $sql -> db_getList(); foreach($nfArray as $row) { if(!in_array($row['link_name'], $existing)) { $importArray[] = array('name' => $row['link_name'], 'url' => $row['link_url'], 'type' => GSLAN_1); } } /* custom pages ... */ $query = "SELECT p.page_id, p.page_title, p.page_sef, p.page_chapter, ch.chapter_sef as chapter_sef, b.chapter_sef as book_sef FROM #page as p LEFT JOIN #page_chapters as ch ON p.page_chapter = ch.chapter_id LEFT JOIN #page_chapters as b ON ch.chapter_parent = b.chapter_id WHERE page_title !='' ORDER BY page_datestamp ASC"; $data = $sql->retrieve($query,true); foreach($data as $row) { if(!in_array($row['page_title'], $existing)) { $route = ($row['page_chapter'] == 0) ? "page/view/other" : "page/view/index"; $importArray[] = array('name' => $row['page_title'], 'url' => e107::getUrl()->create($route, $row, array('full'=>1, 'allow' => 'page_sef,page_title,page_id, chapter_sef, book_sef')), 'type' => "Page"); } } /* forums ... */ if(plugInstalled('forum')) { $sql -> select("forum", "*", "forum_parent!='0' ORDER BY forum_order ASC"); $nfArray = $sql -> db_getList(); foreach($nfArray as $row) { if(!in_array($row['forum_name'], $existing)) { $importArray[] = array('name' => $row['forum_name'], 'url' => e107::getUrl()->create('forum/forum/view', $row['forum_id']), 'type' => "Forum"); } } } /* DEPRECATED content pages ... if(plugInstalled('content')) { $sql -> select("pcontent", "content_id, content_heading", "LEFT(content_parent,1) = '0' ORDER BY content_heading"); $nfArray = $sql -> db_getList(); foreach($nfArray as $row) { $sql2 -> select("pcontent", "content_id, content_heading", "content_parent = '".$row['content_id']."' AND content_refer != 'sa' ORDER BY content_heading"); $nfArray2 = $sql2 -> db_getList(); foreach($nfArray2 as $row2) { if(!$sql -> select("gsitemap", "*", "gsitemap_name='".$row2['content_heading']."' ")) { $importArray[] = array('name' => $row2['content_heading'], 'url' => $PLUGINS_DIRECTORY."content/content.php?content.".$row2['content_id'], 'type' => $row['content_heading']); } } } } */ $text = "
"; foreach($importArray as $ia) { $text .= " "; } $text .= "
".GSLAN_2." ".LAN_TYPE." ".LAN_NAME." ".LAN_URL."
".$ia['type']." ".$ia['name']." ".str_replace(SITEURL,"",$ia['url'])."
".GSLAN_8."   ".GSLAN_9." :    ".GSLAN_10."

". $frm->admin_button('import_links',GSLAN_18,'submit')."
"; $ns -> tablerender(GSLAN_7, $mes->render(). $text); } function importLink() { $sql = e107::getDb(); $tp = e107::getParser(); $log = e107::getAdminLog(); foreach($_POST['importid'] as $import) { list($name, $url, $type) = explode("^", $import); $name = $tp -> toDB($name); $url = $tp -> toDB($url); $sql -> db_Insert("gsitemap", "0, '$name', '$url', '".time()."', '".$_POST['import_freq']."', '".$_POST['import_priority']."', '$type', '0', '', '0' "); } $this -> message = count($_POST['importid'])." link(s) imported."; $log->log_event('GSMAP_01',$this->message, E_LOG_INFORMATIVE,''); } function instructions() { $mes = e107::getMessage(); $ns = e107::getRender(); $LINK_1 = "https://www.google.com/accounts/ServiceLogin?service=sitemaps"; $LINK_2 = "http://www.google.com/support/webmasters/?hl=en"; $srch[0] = "[URL]"; $repl[0] = "".$LINK_1.""; $srch[1] = "[URL2]"; $repl[1] = "
".SITEURL."gsitemap.php
"; $srch[2] = "["; $repl[2] = ""; $srch[3] = "]"; $repl[3] = ""; $text = "".GSLAN_33."