op de hosting server van onze site.
Maar als ik dit lokaal wit uitvoeren op mijn windows pc krijg ik de fout melding
Alle haakjes {} en <?>? nagelopen maar niets gevonden.
Wie wil mij helpen?
<?php
jimport('joomla.html.parameter');
jimport('joomla.html.editor');
// no direct access
defined('_JEXEC') or die;
// load the html drawing class
// require_once( $mainframe->getPath( 'front_html' ) );
$mainframe = JFactory::getApplication();
global $database, $my;
global $mosConfig_live_site, $mosConfig_frontend_login, $mosConfig_db;
$menu = $mainframe->get( 'menu' );
$params = new JParameter($ini);
$params->def( 'page_title', 1 );
$params->def( 'header_login', $menu->name );
$params->def( 'header_logout', $menu->name );
$params->def( 'pageclass_sfx', '' );
$params->def( 'back_button', $mainframe->getCfg( 'back_button' ) );
$params->def( 'login', $mosConfig_live_site );
$params->def( 'logout', $mosConfig_live_site );
$params->def( 'login_message', 0 );
$params->def( 'logout_message', 0 );
$params->def( 'description_login', 1 );
$params->def( 'description_logout', 1 );
$params->def( 'description_login_text', _LOGIN_DESCRIPTION );
$params->def( 'description_logout_text', _LOGOUT_DESCRIPTION );
$params->def( 'image_login', 'key.jpg' );
$params->def( 'image_logout', 'key.jpg' );
$params->def( 'image_login_align', 'right' );
$params->def( 'image_logout_align', 'right' );
$params->def( 'registration', $mainframe->getCfg( 'allowUserRegistration' ) );
$option = "com_sdoo";
$user = &JFactory::getUser();
$id = $user->id;
/*
----------------
Bepaal de taak
----------------
*/
if ($_GET["task"] == "saveNew")
{
savePage();
}
else if ($_GET["task"] == "edit")
{
if ($id != 0)
editPage();
}
else if ($_GET["task"] == "delete")
{
if ($id != 0)
delete();
}
else if ($_GET["task"] == "saveEdited")
{
if ($id != 0)
saveEditedPage();
}
else if ($_GET["task"] == "overview")
{
// Alleen voor geregistreerde gebruikers
if ($id != 0){
overview();
}
}
else if ($_GET["task"] == "publish")
{
if ($id != 0){
publish();
}
}
else if ($_GET["task"] == "notifications")
{
if ($id != 0){
notificaties();
}
}
else
{
newPage();
}
function delete()
{
global $id, $my;
$database = &JFactory::getDbo();
// Verwijder stuk
$query = "DELETE FROM #__ingezonden WHERE id = '" . quote_smart($_GET["stukId"]) . "' ";
$database->setQuery( $query );
$database->query();
// Terug naar overzicht
header("Location: index.php?option=com_sdoo&task=overview&Itemid=" . quote_smart($_GET["Itemid"]) . "");
}
function overview()
{
global $id, $user;
$database = &JFactory::getDbo();
$query = "SELECT i.*, c.title as 'categorieName', (SELECT title from #__categories where id = c.parent_id limit 1) as 'sectionName' FROM #__ingezonden i LEFT JOIN #__categories c ON(c.id = i.catId) order by i.publish_up";
$database->setQuery( $query );
$stukken = $database->loadObjectList();
?>
<table><td class="contentheading" width="100%"><span style="width: 50px;"></span>Ingezonden stukken</td></tr>
<tr><td>
<?
?>
<table>
<tr><td><b>Titel</b></td><td><b>Inzend datum</b></td><td><b>Section</b></td><td><b>Categorie</b></td></tr>
<?
for ($i=0;$i<sizeOf($stukken);$i++)
{
echo "<tr><td>" . $stukken[$i]->title . "</td><td>" . date("d-m-Y H:i:s",$stukken[$i]->publish_up) . "</td><td>" . $stukken[$i]->sectionName . "</td><td>" . $stukken[$i]->categorieName . "</td><td><a href=\"index.php?option=com_sdoo&task=edit&stukId=" . $stukken[$i]->id . "&Itemid=" . $_GET["Itemid"] . "\"><img src=\"./components/com_sdoo/edit.png\"></a></td><td><a onclick=\"return confirm('Weet u zeker dat u dit stuk wilt publiceren')\" href=\"index.php?option=com_sdoo&task=publish&stukId=" . $stukken[$i]->id . "&Itemid=" . $_GET["Itemid"] . "\"><img src=\"./components/com_sdoo/publish.png\"></a></td><td><a onclick=\"return confirm('Weet u zeker dat u dit stuk wilt verwijderen')\" href=\"index.php?option=com_sdoo&task=delete&stukId=" . $stukken[$i]->id . "&Itemid=" . $_GET["Itemid"] . "\"><img src=\"./components/com_sdoo/delete.png\"></a></td></tr>";
}
?>
</table>
<?
// Toon link naar notificaties voor admin
if ($user->id != 0)
{
echo "<p><b>Administratie:</b><br />";
echo "<a href='index.php?option=com_sdoo&task=notifications&stukId=" . $stukken[$i]->id . "&Itemid=" . $_GET["Itemid"] . "'>Notificaties instellen</a></p>";
}
?>
</td></tr>
</table>
<?
}
function notificaties()
{
global $id;
$database = &JFactory::getDbo();
$secId = quote_smart($_GET["secId"]);
// Contoleer acties
// verwijderen
$delUserId = quote_smart($_GET["delUserId"]);
if ($delUserId != "")
{
$query = "DELETE FROM #__notificatie WHERE userId = '$delUserId' and secId = '$secId'";
$database->setQuery( $query );
$database->query();
}
// Toevoegen
$addUserId = quote_smart($_GET["addUserId"]);
if ($addUserId != "")
{
$query = "INSERT INTO #__notificatie (secId,userId) VALUES ('$secId','$addUserId') ";
$database->setQuery( $query );
$database->query();
}
?>
<h2>Notificaties ingezonden stukken instellen</h2>
<?
notificationTable("0");
?>
<h2>Notificaties reacties instellen</h2>
<?
notificationTable("1");
}
function notificationTable($secId){
$database = &JFactory::getDbo();
echo "<p /><table><tr><td valign=\"top\" width=\"50%\">";
// Toon box voor adressen
$query = "SELECT id, name, email FROM #__users WHERE id in (select userId from #__notificatie where secId = '$secId')";
$database->setQuery( $query );
$items = $database->loadObjectList();
echo "<table><tr><td><b>Notificatie adressen</b></td></tr>";
for ($i=0;$i<sizeOf($items);$i++)
{
echo "<tr><td><a href='index.php?option=com_sdoo&task=notifications&secId=" . $secId . "&delUserId=" . $items[$i]->id . "'> <img src=\"./components/com_sdoo/delete_small.png\"></a> " . email($items[$i]->name,$items[$i]->email) . "</td></tr>";
}
echo "</table>";
echo "</td><td valign=\"top\" width=\"50%\">";
// Toon box voor nieuwe adressen
$query = "SELECT id, name, email FROM #__users u WHERE id not in (select userId from #__notificatie where secId = '$secId')";
$database->setQuery( $query );
$items = $database->loadObjectList();
echo "<table><tr><td><b>Adressenboek</b></td></tr>";
for ($i=0;$i<sizeOf($items);$i++)
{
echo "<tr><td><a href='index.php?option=com_sdoo&task=notifications&secId=" . $secId . "&addUserId=" . $items[$i]->id . "'> <img src=\"./components/com_sdoo/OK_small.png\"></a> " . email($items[$i]->name,$items[$i]->email) . "</td></tr>";
}
echo "</table>";
echo "</td></tr></table>";
}
function email($name,$email)
{
return htmlspecialchars("$name<$email>");
}
function sections($secId)
{
global $id, $my;
$database = &JFactory::getDbo();
$query = "SELECT #__categories.* FROM #__categories WHERE published = 1 AND level = 1 order by title";
$database->setQuery( $query );
$items = $database->loadObjectList();
echo "<select name=\"section\" id=\"section\" style=\"width:300px;\" onchange=\"setCategories(this)\">";
echo "<option value=\"\">--- Selecteer een sectie ---</option>";
for ($i=0;$i<sizeOf($items);$i++)
{
if ($items[$i]->title != "Uncategorised"){
echo "<option value=\"" . $items[$i]->id . "\"";
if ($items[$i]->id == $secId)
echo " selected";
echo ">" . $items[$i]->title . "</option>";
}
}
?>
</select>
<?
}
function editPage()
{
global $id, $my;
$database = &JFactory::getDbo();
$stukId = quote_smart($_GET["stukId"]);
// Haal pagina gegevens op
$query = "SELECT * FROM #__ingezonden WHERE id = $stukId ";
$database->setQuery( $query );
$items = $database->loadObjectList();
for ($i=0;$i<sizeOf($items);$i++)
{
page($items[$i]->title,$items[$i]->secId,$items[$i]->catId,$items[$i]->introtext,$items[$i]->full_text,"saveEdited&stukId=" . $items[$i]->id);
}
?>
<input type="submit" value="Opslaan" />
<?
// Pagina einde
echo "</td></tr></table></form>";
}
function newPage()
{
page("",0,0,"","","saveNew");
?>
<input type="submit" value="Verstuur naar SDOO" onclick="return confirm('Weet u zeker dat u dit stuk wilt insturen? Wanneer u op OK klikt kunt u dit niet meer bewerken.')" />
</td></tr></table>
</form>
<?
}
function page($titel,$secId,$catId,$introtext,$fulltext,$task)
{
global $id, $my;
$database = &JFactory::getDbo();
// Haal categorien op en zet ze in een array
$query = "SELECT #__categories.* FROM #__categories WHERE published = 1 AND level = 2 order by title";
$database->setQuery( $query );
$items = $database->loadObjectList();
?>
<script>
var categories = new Array();
<?
for ($i=0;$i<sizeOf($items);$i++)
{
echo "categories[$i] = new categorie(" . $items[$i]->id . ",'" . $items[$i]->parent_id . "', '" . $items[$i]->title . "');\n";
}
?>
function categorie(catId,secId,name)
{
this.catId = catId;
this.name = name;
this.secId = secId;
}
function setCategories(dropDownObj)
{
var categoriesObj = document.getElementById("categorie");
// Leeg de dropdownbox
categoriesObj.innerHTML = "";
// Eerste item toevoegen
var opt = document.createElement("option");
opt.text = "--- Selecteer een categorie ---";
categoriesObj.options.add(opt);
// Voeg opties toe
for (i=0;i<categories.length;i++)
{
if (dropDownObj.value == categories[i].secId)
{
var opt = document.createElement("option");
opt.text = categories[i].name;
opt.value = categories[i].catId;
categoriesObj.options.add(opt);
}
}
}
</script>
<form method="post" action="index.php?option=com_sdoo&task=<? echo $task; ?>&Itemid=<? echo $_GET["Itemid"]; ?>">
<h1>Stuk insturen</h1>
<table>
<tr><td>
<br />
<font style='color:red;font-weight:bold;'>Ingezonden artikelen op deze site zijn meer dan welkom.
Echter: artikelen die kwetsend, onnodig grof of beledigend zijn worden niet geplaatst. Verzocht wordt naam en eventueel e-mailadres te vermelden.
</font>
<p>
<b>Titel:</b><br />
Geef een titel voor uw stuk van maximaal 100 karakters.
</p>
<input type="text" name="title" maxlength="100" style="width:300px;" value="<? echo $titel; ?>" />
<p>
<b>Sectie:</b><br />
Selecteer een sectie waaronder uw stuk valt.
<p />
<? sections($secId); ?>
<p>
<b>Categorie:</b><br />
Na het selecteren van een sectie kunt u een categorie kiezen waaronder uw stuk valt.
<p />
<select name="categorie" id="categorie" style="width:300px;">
<?
$query = "SELECT #__categories.* FROM #__categories WHERE published = 1 AND level = 2 AND parent_id = '$secId' order by title";
$database->setQuery( $query );
$items = $database->loadObjectList();
echo "<option value=\"\">--- Selecteer een categorie ---</option>";
for ($i=0;$i<sizeOf($items);$i++)
{
echo "<option value=\"" . $items[$i]->id . "\"";
if ($items[$i]->id == $catId)
echo " selected";
echo ">" . $items[$i]->title . "</option>";
}
?>
</select>
<p>
<b>Intro tekst:</b><br />
Geef een korte into op uw stuk. Dit is niet verplicht.
<p />
<?
$editor = &JFactory::getEditor();
echo $editor->display("introtext", $introtext, 600, 150, 0, 0);
?>
<p>
<b>Tekst:</b><br />
U kunt hier uw stuk plaatsen voor op de website.
<p />
<?
echo $editor->display("fulltext", $fulltext, 600, 150, 0, 0);
?>
<p />
<b>Afbeeldingen:</b><br />
Wanneer u afbeeldingen aan uw stuk wilt toevoegen, kunt u deze insturen naar <a href="mailto:[email protected]">[email protected]</a> vermeld hierbij de titel van het stuk.
<p />
<?
}
function saveEditedPage()
{
$user = &JFactory::getUser();
$id = $user->id;
$database = &JFactory::getDbo();
$id = quote_smart($_GET["stukId"]);
$title = quote_smart($_POST["title"]);
$introtext = quote_smart($_POST["introtext"]);
$fulltext = quote_smart($_POST["fulltext"]);
$catId = quote_smart($_POST["categorie"]);
$secId = quote_smart($_POST["section"]);
$query = "UPDATE #__ingezonden SET title = '$title', introtext = '$introtext', full_text = '$fulltext', catId = '$catId', secId = '$secId' WHERE id = '$id' ";
$database->setQuery( $query );
$database->query();
// Terug naar overzicht
header("Location: index.php?option=com_sdoo&task=overview&Itemid=" . quote_smart($_GET["Itemid"]) . "");
}
function publish()
{
$user = &JFactory::getUser();
$id = $user->id;
$database = &JFactory::getDbo();
$stukId = quote_smart($_GET["stukId"]);
// Haal pagina gegevens op
$query = "SELECT * FROM #__ingezonden WHERE id = $stukId ";
$database->setQuery($query);
$items = $database->loadObjectList();
$date = date("Y-m-d H:i:s",time() - 60 - 3600);
for ($i=0;$i<sizeOf($items);$i++)
{
// Publiseer eerst
$pub_date = date("Y-m-d H:i:s",$items[$i]->publish_up);
$insertQuery = "INSERT INTO #__content (title, introtext, `fulltext`, state, catid, created, created_by, publish_up, publish_down) VALUES ('" . $items[$i]->title . "', '" . quote_smart($items[$i]->introtext) . "', '" . quote_smart($items[$i]->full_text) . "', 1, '" . $items[$i]->catId . "', '" . $pub_date . "', $id, '" . $date . "', '" . date("Y-m-d H:i:s",time() + 30758340) . "') ";
$database->setQuery($insertQuery);
$database->query();
// verwijder oude gegevens
if ($database->getErrorNum() == 0)
{
//file_get_contents("http://sdoo.kevinverhoef.nl/?headline=" . urlencode($items[$i]->title) . "&url=" . urlencode($database->insertid()));
echo "Succesvol toegevoegd!, verwijder handmatig het stuk.";
//delete();
}
else
{
echo "Fout bij het toevoegen van het stuk! Neem contact op met Kevin ([email protected])<br><br>";
echo $database->getErrorMsg();
echo "<br><br>";
echo $insertQuery;
}
echo "end";
}
}
function savePage()
{
// Sla de pagina op
global $my, $id;
$database = &JFactory::getDbo();
$title = quote_smart($_POST["title"]);
$introtext = quote_smart($_POST["introtext"]);
$fulltext = quote_smart($_POST["fulltext"]);
$catId = quote_smart($_POST["categorie"]);
$secId = quote_smart($_POST["section"]);
$date = time();
$query = "INSERT INTO #__ingezonden (title,introtext,full_text,publish_up,catId,secId) VALUES ('$title','$introtext','$fulltext',$date,'$catId','$secId') ";
$database->setQuery( $query );
$database->query();
// Stel beheerders op de hoogte via mail
$query = "SELECT u.email, u.name FROM #__notificatie n INNER JOIN #__users u ON (n.userId = u.id) where secId = '0' ";
$database->setQuery( $query );
$items = $database->loadObjectList();
for ($i=0;$i<sizeOf($items);$i++)
{
$naarwie = $items[$i]->email;
$titel = "SDOO.NL Er is een nieuw ingezonden stuk";
$bericht = "Hallo " . $items[$i]->name . ",\n\n"
. "Er is een nieuw stuk ingezonden op http://www.sdoo.nl.\n\n"
. "Om dit stuk te muteren/publiceren dient u in te loggen en vervolgens naar ingezonden stukken te gaan.";
$headers="From:sdoo<[email protected]>";
mail($naarwie, $titel, $bericht, $headers);
}
// Bedank de gebruiker
?>
<table><td class="contentheading" width="100%"><span style="width: 50px;"></span>Stuk insturen</td></tr>
<tr><td>
Hartelijk dank voor het bijdragen aan de SDOO site. Voordat uw ingezonden stuk op de website geplaatst zal worden, moet dit eerst worden goed gekeurd door de beheerders.
</td></tr>
</table>
<?
}
function quote_smart($value) {
if (get_magic_quotes_gpc()) {
$value = stripslashes($value);
}
if(version_compare(phpversion(),"4.3.0") == "-1") {
return mysql_escape_string($value);
} else {
return mysql_real_escape_string($value);
}
}
?>