<?
//***************************************************
// Startpage v1.1 by Matthijs Draijer
//
// Use of this script is free, as long as
// it's not commercial and you don't remove
// my name.
//
//***************************************************
function connect_db() {
include ("config.php");
mysql_pconnect($hostname, $username, $password) OR sess_connect_error();
@mysql_select_db( "$dbName") or sess_select_db();
}
function connect_error() {
echo "Er ging iets niet helemaal goed";
die;
}
function select_db() {
echo "De database is niet te bereiken";
die;
}
function getPoint($dagen = 3) {
include ("config.php");
$Dag = 24*60*60;
$Nu = time();
$WeekGeleden = $Nu - ($dagen*$Dag);
$PageQuery = "SELECT COUNT(*), $cfgLogPage FROM $cfgTableLog WHERE $cfgLogTime > $WeekGeleden GROUP BY $cfgLogPage";
$FindPage = mysql_query($PageQuery);
while($Results = mysql_fetch_array($FindPage)) {
$id = $Results[$cfgLogPage];
$points[$id] = $Results[0];
}
arsort($points);
return $points;
}
function getPages() {
include ("config.php");
$PageQuery = "SELECT $cfgDataID FROM $cfgTableData ORDER BY $cfgDataVisit";
$FindPage = mysql_query($PageQuery);
while($Results = mysql_fetch_array($FindPage)) $pages[] = $Results[$cfgDataID];
return $pages;
}
function getOrder($pages, $points) {
foreach($pages as $page) {
if(!isset($points[$page])) $without_points[] = $page;
}
foreach ($points as $key => $point) {
$with_point[] = $key;
}
return array_merge ($with_point, $without_points);
}
function getOrderAlpha($pages) {
include ("config.php");
foreach ($pages as $page) $Search[] = "$cfgDataID = $page";
$SearchString = implode(' OR ', $Search);
$PageQuery = "SELECT * FROM $cfgTableData WHERE $SearchString ORDER BY $cfgDataTitle";
$FindPage = mysql_query($PageQuery);
while($Results = mysql_fetch_array($FindPage)) $temp[] = $Results[$cfgDataID];
return $temp;
}
function PageTitle($URL) {
include ("config.php");
include ("language_$cfgLanguage.php");
$string = file_get_contents($URL);
if($string != "") {
$string = eregi_replace ("<title>", "<title>", $string);
$string = eregi_replace ("</title>", "</title>", $string);
$begin = strpos($string,"<title>") + 7;
$eind = strpos($string,"</title>");
$verschil = $eind - $begin;
$uitvoer = substr($string, $begin, $verschil);
} else {
$uitvoer = $lngError;
}
if($uitvoer == "") $uitvoer = '<i>$lngEmpty</i>';
return $uitvoer;
}
function showEditForm ($title = '', $url = '', $id = '')
{
include ("config.php");
include ("language_$cfgLanguage.php");
echo "<form method='post' action='$_SERVER[PHP_SELF]'>". NL;
echo "<input type='hidden' name='id' value='$id'>". NL;
echo "<table>". NL;
echo "<tr>". NL;
echo " <td>$lngTitle :</td>". NL;
echo " <td><input type='text' name='title' value='$title' size='40'></td>". NL;
echo "</tr>". NL;
echo "<tr>". NL;
echo " <td>$lngURL :</td>". NL;
echo " <td><input type='text' name='url' value='$url' size='40'></td>". NL;
echo "</tr>". NL;
echo "<tr>". NL;
echo " <td colspan='2'></td>". NL;
echo "</tr>". NL;
echo "<tr>". NL;
echo " <td colspan='2'>". NL;
echo " <table width='100%'>". NL;
echo " <tr>". NL;
echo " <td width='50%' align='center'><input type='submit' name='submit' value='$lngSave'></td>". NL;
echo " <td width='50%' align='center'><input type='submit' name='get_title' value='$lngGetTitle'></td>". NL;
echo " </tr>". NL;
echo " </table>". NL;
echo " </td>". NL;
echo " </tr>". NL;
echo "</table>". NL;
echo "</form>". NL;
}
?>