$length)
{
$length -= strlen($end);
$last = strrpos(substr($string, 0, $length + 1), ' ');
return substr($string, 0, ($last < $length - $allow)? $length: $last) . $end;
}
return $string;
}
function datum_tijd($Var){
$Year = substr($Var, 0, 4);
$Month = substr($Var, 4, 2);
$Day = substr($Var, 6, 2);
$Hour = substr($Var,8,2);
$Minute = substr($Var,10,2);
$Seconds = substr($Var,12,2);
return $Year."-".$Month."-".$Day." ".$Hour.":".$Minute.":".$Seconds;
}
function thumb($File,$Size = 120,$ImgMap,$ThumbMap,$type){
if($type == "image/gif"){
$photo = imagecreatefromgif($ImgMap.'/'.$File);
}elseif($type == "image/pjpeg" or $type == "image/jpeg"){
$photo = imagecreatefromjpeg ($ImgMap.'/'.$File);
}elseif($type == "image/x-png" or $type == "image/png"){
$photo = imagecreatefrompng($ImgMap.'/'.$File);
}else{
echo"Ongeldig type.
";
return;
}
$photo_dimensions_width = imagesx ($photo);
$photo_dimensions_height = imagesy ($photo);
if ($photo_dimensions_width > $Size OR $photo_dimensions_height > $Size) {
if ($photo_dimensions_width == $photo_dimensions_height) {
$thumb_dimensions_width = $Size;
$thumb_dimensions_height = $Size;
}
elseif ($photo_dimensions_width > $photo_dimensions_height) {
$value = $photo_dimensions_width / $Size;
$thumb_dimensions_width = $Size;
$thumb_dimensions_height = round ($photo_dimensions_height / $value);
}
else {
$value = $photo_dimensions_height / $Size;
$thumb_dimensions_height = $Size;
$thumb_dimensions_width = round ($photo_dimensions_width / $value);
}
}
else {
$thumb_dimensions_width = $photo_dimensions_width;
$thumb_dimensions_height = $photo_dimensions_height;
}
$Cut = strrpos($File,'.');
$File = substr($File,0,$Cut);
$create_thumb = imagecreatetruecolor ($thumb_dimensions_width, $thumb_dimensions_height);
imagecopyresampled ($create_thumb, $photo, 0, 0, 0, 0, $thumb_dimensions_width, $thumb_dimensions_height, $photo_dimensions_width, $photo_dimensions_height);
ImageJpeg($create_thumb,$ImgMap.'/'.$ThumbMap.'/'.$File.".jpg",90);
Imagedestroy($photo);
}
?>
» Home » Uitloggen Nieuw bericht. '; if(CheckRight($_SESSION['MyNews_Admin'],2)) echo'» Wijzig bericht. '; if(CheckRight($_SESSION['MyNews_Admin'],4)) echo'» Verwijder bericht. '; if(CheckRight($_SESSION['MyNews_Admin'],8)) echo' » Reactie verwijderen. '; if(CheckRight($_SESSION['MyNews_Admin'],32)) echo' » Admin toevoegen. '; ?> |
".mysql_error();
}
}else{
if(mysql_query("INSERT INTO ".$SqlPrefix."pic (news_id,name,original) VALUES('". session_id() ."','". $FileName ."','".$_FILES['Picture']['name']."')")){
$Disp = $_FILES['Picture']['name']." succesvol toegevoegd.";
}else{
$Disp = "MySql error: ".mysql_error(); } } }else{ $Disp="Foto kon niet geupload worden, mogelijk bestaat de map img/ niet of heeft u te weinig rechten."; } }else{ $Disp="Bestand met incorrecte bestandsnaam of inhoud,".$FileExt." ".$_FILES['Picture']['type']; } }else{ $Disp="Geen foto geselecteerd."; } }else{ if(!empty($_POST['Message']) && !empty($_POST['Title'])){ if(mysql_query("INSERT INTO ".$SqlPrefix."news (title,message,_time) VALUES ('". addslashes($_POST['Title']) ."', '". addslashes($_POST['Message']) ."', '". date("YmdHis") ."')")){ if(mysql_query("UPDATE ".$SqlPrefix."pic SET news_id='". mysql_insert_id() ."' WHERE news_id = '". session_id() ."'")){ echo"Het nieuws bericht is succesvol toegevoegd aan de database. "; unset($_SESSION['Title']); unset($_SESSION['Message']); $Succes=TRUE; }else{ $Disp="MySql error: ".mysql_error(); } }else{ $Disp="MySql error: ".mysql_error(); } } } }elseif(isset($_GET['DelPic'])){ unset($_SESSION['Message']); unset($_SESSION['Title']); $_SESSION['Message'] = $_POST['Message']; $_SESSION['Title'] = $_POST['Title']; $Sql="SELECT name,thumb FROM ".$SqlPrefix."pic WHERE id=".$_GET['DelPic']; if($Result = mysql_query($Sql)){ while($Row = mysql_fetch_assoc($Result)){ if($Row['thumb'] > 0){ unlink($ImgMap.'/'.$ThumbMap.'/'.$Row['thumb']); } unlink($ImgMap.'/'.$Row['name']); if(mysql_query("DELETE FROM ".$SqlPrefix."pic WHERE id=".$_GET['DelPic'])){ $Disp="Plaatje verwijderd. \n"; }else{ $Disp="MySql error: \n".mysql_error(); } } }else{ $Disp="MySql error: \n".mysql_error(); } } if(!isset($Succes)){ if(isset($Disp)){ echo$Disp." "; } ?> } }elseif($_GET['p'] == "ChangeNews" && CheckRight($_SESSION['MyNews_Admin'],2)){ if(!isset($_GET['Changeid'])){ $Sql = "SELECT * FROM ".$SqlPrefix."news ORDER BY _time DESC"; if($Result = mysql_query($Sql)){ while($Row = mysql_fetch_assoc($Result)){ echo"» ". stripslashes($Row['title']) ." \n"; } }else{ $Disp="MySql error: \n".mysql_error(); } }else{ if($_SERVER['REQUEST_METHOD'] == "POST"){ unset($_SESSION['Message']); unset($_SESSION['Title']); $_SESSION['Message'] = $_POST['Message']; $_SESSION['Title'] = $_POST['Title']; if(isset($_POST['AddFile'])){ if(!empty($_FILES['Picture']['tmp_name'])){ $FileName = time() ."-".$_FILES['Picture']['name']; // Toegestaande extensies opvragen $ext = strtolower($ext); $ext = explode(" ", $ext); //Toegestaande types opvragen $type = strtolower($type); $type = explode(" ",$type); $Pos = strrpos(strtolower($_FILES['Picture']['name']),'.'); $FileExt = substr (strtolower($_FILES['Picture']['name']), $Pos+1); foreach($ext as $Value){ if($FileExt == $Value){ $ContrExt = TRUE; } } foreach($type as $Value){ if(strtolower($_FILES['Picture']['type']) == $Value){ $ContrType = TRUE; } } if($ContrType == TRUE && $ContrExt == TRUE){ if(move_uploaded_file($_FILES['Picture']['tmp_name'],"./".$ImgMap."/". $FileName)){ chmod("./".$ImgMap."/".$FileName,0644); if(!empty($_POST['Thumb'])){ thumb(time() .'-'.$_FILES['Picture']['name'],$_POST['Thumb'],$ImgMap,$ThumbMap,$_FILES['Picture']['type']); $File = $FileName; $Cut = strrpos($File,'.'); $File = substr($File,0,$Cut); $File.='.jpg'; if(mysql_query("INSERT INTO ".$SqlPrefix."pic (news_id,name,original,thumb) VALUES('". $_GET['Changeid'] ."','". $FileName ."','".$_FILES['Picture']['name']."','".$File."')")){ $Disp = $_FILES['Picture']['name']." succesvol toegevoegd, en thumb succesvol gemaakt met een maximale grootte van ". $_POST['Thumb']."px"; }else{ $Disp = "MySql error: ".mysql_error(); } }else{ if(mysql_query("INSERT INTO ".$SqlPrefix."pic (news_id,name,original) VALUES('". $_GET['Changeid'] ."','". time()."-". $_FILES['Picture']['name'] ."','".$_FILES['Picture']['name']."')")){ $Disp = $_FILES['Picture']['name']." succesvol toegevoegd."; }else{ $Disp = "MySql error: ".mysql_error(); } } }else{ $Disp="Foto kon niet geupload worden, mogelijk bestaat de map img/ niet of heeft u te weinig rechten."; } }else{ $Disp="Bestand met incorrecte bestandsnaam of inhoud,".$FileExt." ".$_FILES['Picture']['type']; } }else{ $Disp="Geen foto geselecteerd."; } }else{ if(!empty($_POST['Message']) && !empty($_POST['Title'])){ if(mysql_query("UPDATE ".$SqlPrefix."news SET title='". addslashes($_POST['Title']) ."', message='". addslashes($_POST['Message']) ."' WHERE id='".$_GET['Changeid']."'")){ echo"Het nieuws bericht is succesvol opgeslagen. "; unset($_SESSION['Title']); unset($_SESSION['Message']); $Succes=TRUE; }else{ $Disp="MySql error: ".mysql_error(); } } } }elseif(isset($_GET['DelPic'])){ unset($_SESSION['Message']); unset($_SESSION['Title']); $_SESSION['Message'] = $_POST['Message']; $_SESSION['Title'] = $_POST['Title']; $Sql="SELECT name,thumb FROM ".$SqlPrefix."pic WHERE id=".$_GET['DelPic']; if($Result = mysql_query($Sql)){ while($Row = mysql_fetch_assoc($Result)){ if($Row['thumb'] > 0){ unlink($ImgMap.'/'.$ThumbMap.'/'.$Row['thumb']); } unlink($ImgMap.'/'.$Row['name']); if(mysql_query("DELETE FROM ".$SqlPrefix."pic WHERE id=".$_GET['DelPic'])){ $Disp="Plaatje verwijderd. \n"; }else{ $Disp="MySql error: \n".mysql_error(); } } }else{ $Disp="MySql error: \n".mysql_error(); } } if(!isset($Succes)){ if(isset($Disp)){ echo$Disp." "; } $Sql="SELECT * FROM ".$SqlPrefix."news WHERE id='".$_GET['Changeid']."'"; if($Result = mysql_query($Sql)){ while($Row = mysql_fetch_assoc($Result)){ ?> } } } } }elseif($_GET['p'] == "DeleteNews" && CheckRight($_SESSION['MyNews_Admin'],4)){ if(isset($_GET['nid'])){ $Sql = "SELECT COUNT(1) as aantal FROM ".$SqlPrefix."news WHERE id='".$_GET['nid']."'"; if($Result = mysql_query($Sql)){ if(mysql_result($Result,0) > 0){ $SelectPic = "SELECT * FROM ".$SqlPrefix."pic WHERE news_id='".$_GET['nid']."'"; if($ResultPic = mysql_query($SelectPic)){ while($Pic = mysql_fetch_assoc($ResultPic)){ if($Pic['thumb'] > 0){ unlink($ImgMap.'/'.$ThumbMap.'/'.$Pic['thumb']); } unlink($ImgMap.'/'.$Pic['name']); } }else{ echo"MySql error: \n".mysql_error(); } if(mysql_query("DELETE FROM ".$SqlPrefix."pic WHERE news_id='".$_GET['nid']."'")){ echo"Plaatjes verwijderd. \n"; if(mysql_query("DELETE FROM ".$SqlPrefix."news WHERE id='".$_GET['nid']."'")){ if(mysql_query("DELETE FROM ".$SqlPrefix."comments WHERE news_id='".$_GET['nid']."'")){ echo"Nieuws bericht verwijderd. \n"; }else{ echo"MySql error: ".mysql_error(); } }else{ echo"MySql error: ".mysql_error(); } }else{ echo"MySql error: \n".mysql_error(); } }else{ echo"Object niet gevonden. \n"; } }else{ echo"MySql error: \n".mysql_error(); } }else{ $Sql="SELECT * FROM ".$SqlPrefix."news ORDER BY _time ASC"; if($Result = mysql_query($Sql)){ ?> Klik op een titel om het volledige bericht inclusief eventuele foto's te verwijderen van de server. while($Row = mysql_fetch_assoc($Result)){ echo"» ". stripslashes($Row['title']) ." \n"; } }else{ echo"MySql error: \n".mysql_error(); } } }elseif($_GET['p'] == 'DeleteComment' && CheckRight($_SESSION['MyNews_Admin'],8)){ if(!isset($_GET['NewsID'])){ $Sql = "SELECT * FROM ".$SqlPrefix."news ORDER BY id DESC"; if($Result = mysql_query($Sql)){ while($Row = mysql_fetch_assoc($Result)){ ?> } }else{ echo"MySql error: \n".mysql_error(); } }else{ echo"Terug \n"; if(isset($_GET['NewsID']) && isset($_GET['CommentID'])){ mysql_query("DELETE FROM ".$SqlPrefix."comments WHERE id='".$_GET['CommentID']."'"); } $Sql="SELECT * FROM ".$SqlPrefix."comments WHERE news_id='".$_GET['NewsID']."' ORDER BY id DESC"; if($Result = mysql_query($Sql)){ ?>
\n".mysql_error(); } } }elseif($_GET['p'] == 'AddAdmin' && CheckRight($_SESSION['MyNews_Admin'],32)){ if($_SERVER['REQUEST_METHOD'] == 'POST'){ $rights = array_sum($_POST['right']); mysql_query("INSERT INTO ".$SqlPrefix."admins (name,password,email,rights) VALUES ('".$_POST['Name']."','". md5($_POST['Pass']) ."','".$_POST['email']."','".$rights."')"); }else{ ?> } }else{ ?> 404Pagina kon niet gevonden worden.» Terug } }else{ $Updates = file_get_contents("http://jort.myimages.nl/UPDATER/mynews.php"); $Updates = explode(';;',$Updates); $_Vers = explode(';',$Updates[0]); $_Url = explode(';',$Updates[1]); if($_Vers[1] > $Version){ echo"Er is een nieuwere versie van dit script. Versie ".$_Vers[1]." is nu beschikbaar! "; echo"Download de laatste versie: Download"; } } ?> |
|||||||||