Location: PHPKode > projects > Backend code/CMS for blizzle.com > v1.x/save.php
<?
require "functions.php";


// BUILD QUERY

if (retLoggedIn()) {
switch ($function) {
	case 'item':
		$query = "INSERT INTO item_headers (itemCategory, itemSegment, itemTitle, itemDescription, itemBody, itemLinks, itemDate, displayname, modpoints, itemDescription_code, itemBody_code) VALUES ('$category', '$segment', '".addslashes($title)."', '".textReplace($description)."','".textReplace($body)."','".str_replace("\n",";",$links)."', NOW(), '".retUserFlag().retUserName()."', ".retModpoints().", '".addslashes($description)."','".addslashes($body)."');";
		break;
	case 'quickie';
		$query = "INSERT INTO item_headers (itemCategory, itemSegment, itemTitle, itemDescription, itemBody, itemLinks, itemDate, displayname, modpoints, itemDescription_code, itemBody_code) VALUES ('$category', '$segment', '".addslashes($title)."', '".textReplace($description)."',NULL,NULL, NOW(), '".retUserFlag().retUserName()."', ".retModpoints().", '".addslashes($description)."',NULL);";
		break;
	case 'edit';
		$query = "SELECT displayname FROM item_headers WHERE itemID = $uid;";
		$result = mysql_query ($query, $link) or die (mysql_error());
		list($displayname) = mysql_fetch_row($result);
		if ((stripNonAN($displayname) == retUserName()) || (retUserFlag() == "@") || (retUserFlag() == "^")) {
			$query = "UPDATE item_headers SET itemCategory='$category', itemSegment='$segment', itemTitle='".addslashes($title)."', itemDescription='".textReplace($description)."', itemBody='".textReplace($body)."', itemLinks='".str_replace("\n",";",$links)."', itemBody_code='".addslashes($body)."', itemDescription_code='".addslashes($description)."' WHERE itemID = $uid;";
		} else {
			$query = null;
		}
		break;
	case 'append';
		if ((strlen($description)) && (strlen($body))) {
			$query = "UPDATE item_headers SET itemDescription = CONCAT(itemDescription,'".textReplace("[hr][b]updated by ".retUserName()."[/b][p]".$description)."'), itemBody = CONCAT(itemBody,'".textReplace("[hr][b]updated by ".retUserName()."[/b][p]".$body)."'), itemBody_code = CONCAT(itemBody_code,'".addslashes("[hr][b]updated by ".retUserName()."[/b][p]".$body)."'), itemDescription_code = CONCAT(itemDescription_code,'".addslashes("[hr][b]updated by ".retUserName()."[/b][p]".$description)."') WHERE itemID = $uid";
		} elseif (strlen($description)) {
			$query = "UPDATE item_headers SET itemDescription = CONCAT(itemDescription,'".textReplace("[hr][b]updated by ".retUserName()."[/b][p]".$description)."'), itemDescription_code = CONCAT(itemDescription_code,'".addslashes("[hr][b]updated by ".retUserName()."[/b][p]".$description)."') WHERE itemID = $uid";
		} elseif (strlen($body)) {
			$query = "UPDATE item_headers SET itemBody = CONCAT(itemBody,'".textReplace("[hr][b]updated by ".retUserName()."[/b][p]".$body)."'), itemBody_code = CONCAT(itemBody_code,'".addslashes("[hr][b]updated by ".retUserName()."[/b][p]".$body)."') WHERE itemID = $uid";
		}
		break;
	case 'modComment';
		$query = "UPDATE comments SET commentBody='".textReplace($body)."', commentLinks='".str_replace("\n",";",$links)."', commentBody_code='".addslashes($body)."' WHERE commentID = $commentID;";
		break;
	case 'release':

	if (strlen($description)) {
		$relname = $description;
	} elseif (strlen($newdescription)) {
		$relname = $newdescription;
		$query3 = "INSERT INTO `descriptions` (`index`, `description`) VALUES ('".textReplace($newdescription)."', '".textReplace($newdescriptionbody)."');";
	}

	if ($relname) {

		$query = "INSERT INTO releases (name, version, link, date, notes, reporting, notes_code) VALUES ('".textReplace($relname)."', '".textReplace($relversion)."', '$rellink', NOW(), '".textReplace($comment)."<p>".textReplace($changes)."', '$reportedby', '".addslashes($comment)."[p]".addslashes($changes)."');";
	if ($onhomepage == "true") {
			$query2 = "INSERT INTO item_headers (itemCategory, itemSegment, itemTitle, itemDescription, itemBody, itemLinks, itemDate, displayname, modpoints, itemDescription_code, itemBody_code) VALUES ('$category', 'releases', '".textReplace("Release: ".$relname." ".$relversion)."', '".createRelease($relname,$relversion,$rellink,$reportedby,textReplace($comment))."','".textReplace($changes)."','', NOW(), '".retUserFlag().retUserName()."', ".retModpoints().", '".createRelease_code($relname,$relversion,$rellink,$reportedby,textReplace($comment))."','".addslashes($changes)."');";
	}

	}
		break;
	case 'addpage';
		if ($aedit == "true") {
			$query = "UPDATE item_subs SET subBody='".textReplace($body)."', subLinks='".str_replace("\n",";",$links)."', subBody_code='".addslashes($body)."' WHERE itemID = $itemID AND subID = $pageID;";
		} else {
			$query = "INSERT INTO item_subs (subID, itemID, subBody, subLinks, subBody_code) VALUES ('$pageID', '$itemID', '".textReplace($body)."', '".str_replace("\n",";",$links)."', '".addslashes($body)."');";
		}
		$return = $itemID;
		break;

	default:
		$query = null;
}


if ($query) {
	$result = mysql_query ($query, $link) or die (mysql_error());
	if (empty($return)) { 
		$return = mysql_insert_id();
	}
	if ($query2) {
		$result = mysql_query ($query2, $link) or die (mysql_error());
		$return2 = mysql_insert_id();
	}
	if ($query3) {
		$result = mysql_query ($query3, $link) or die (mysql_error());
		$return3 = mysql_insert_id();
	}
	if ($another) {
	header("Location: wizard.php?function=addpage&itemID=$return");
	} else {
	addModPoints(2);
	header("Location: wizard.php?function=success"); 
	}
} else {
	header("Location: wizard.php?function=failure"); 
}
}


function createRelease($name,$version,$linkx,$reporting,$comment) {
return "New release!  This is an automated post to announce a new release.  See the <a href=\"http://blizzle.com/releases.php\">releases page</a> for more.<dl><dt><strong>$name $version</strong><dd><i>[desc:$name]</i><dd><p>$comment</dl><ul><ul><li>[$linkx]Download Link[/]<li>Reporting: $reporting </ul><p>click \"read full story\" to view changes.</ul>";
}

function createRelease_code($name,$version,$linkx,$reporting,$comment) {
return textReplace("New release!  This is an automated post to announce a new release.  See the <a href=\"http://blizzle.com/releases.php\">releases page</a> for more.<dl><dt><strong>$name $version</strong><dd><i>[desc:$name]</i><dd><p>$comment</dl><ul><ul><li>[$linkx]Download Link[/]<li>Reporting: $reporting </ul><p>click \"read full story\" to view changes.</ul>");
}

?>
Return current item: Backend code/CMS for blizzle.com