Pixelpost

Authentic Photoblog Flavour


Go Back   Pixelpost Forum > DEVELOPMENT > Hacks and Modifications

Post Reply
 
Thread Tools
  #1  
Old 11-30-2005, 10:26 AM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Lightbulb install script

I'm working on a script to install parts of new code in an existing code. I call it an install script.

Code:
<?php
function update_file($filename, $search, $replacement, $rowinfo){
	// Let's make sure the file exists and is writable first.
	if (is_writable($filename)) {
	
		// In our example we're opening $filename in append mode.
		// The file pointer is at the bottom of the file hence
		// that's where $somecontent will go when we fwrite() it.
		if (!$handle = fopen($filename, "r+")) {
			$warning .= "Cannot open file ($filename).<br />";
			exit;
		}
	
		// Read the content out the file
		$contents = fread($handle, filesize($filename));
		
		// Replace the content with the new content
		$newcontent = str_replace(stripslashes($search),stripslashes($replacement),$contents);
		
		// Rewind the position of a file pointer. Otherwise the new text wil be placed behind the old text
		rewind($handle);
		
		// Write $somecontent to our opened file.
		if (fwrite($handle, $newcontent) === FALSE) {
			$warning .= "Cannot write to file ($filename).<br />";
			exit;
		}
		
		// Flushes the output to a file, function? I don't know.
		fflush($handle);
		$warning .= "Success, update file ($filename, $rowinfo).<br />";
		
		// Truncates a file to a given length.
		ftruncate($handle, ftell($handle));
		
		// Close file
		fclose($handle);
	
	}else{
		$warning .= "The file $filename is not writable.<br />";
	}
	return $warning;
}

//edit file
$file = "file.php";

//the rownumbers can be different
$rowinfo = '106 (remove row), information about the line';
$search = 'addslashes($code) to replace';
$replacement = 'addsclashes($code)';
echo update_file($file,$search,$replacement,$rowinfo);
?>
But it is not working very well. When the program have to search a code with multiple lines it can't find it', so it won't replace the code.

Does anyone know a solotion, or have made already an install code?
__________________
Northing.nl

Last edited by eon; 11-30-2005 at 10:27 AM. Reason: Notification Type
Reply With Quote
  #2  
Old 11-30-2005, 10:40 AM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
What's the benefit to this, in relation to Pixelpost?

I'm personally against self-modifying code and the like. I don't believe my server is as good a programmer as i am
__________________
touchnothing.net
Reply With Quote
  #3  
Old 11-30-2005, 11:01 AM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
I made a hack on several lines in serveral files. For people who don't want or can't edit there files I want to make a install script. Not everyone knows php.

Of course for the people who like to hack I write a howto or they can read my code.
__________________
Northing.nl
Reply With Quote
  #4  
Old 11-30-2005, 11:04 AM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
The problem face there is that the people who are willing to install a hack, probably have done so already.

So if they've already hacked their file, your hack installer may not work.

By the way, the addon system is exceptionally powerful, i'm yet to find anything that actually requires a hack. What is it your hack does?
__________________
touchnothing.net
Reply With Quote
  #5  
Old 11-30-2005, 11:15 AM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
Instand of pictures you can use just text. Then you can make a thumbnail of the text. You can use this text as an introduction of a serie photo's, for example.

__________________
Northing.nl

Last edited by eon; 11-30-2005 at 11:23 AM. Reason: Add picture
Reply With Quote
  #6  
Old 11-30-2005, 11:59 AM
raminia's Avatar
raminia+ Offline
Team Pixelpost
 
Join Date: Jan 2005
Location: FL, US
Posts: 3,706
Send a message via Yahoo to raminia
cool
__________________
Photoblog: http://pblog.raminia.com Powered by Pixelpost 1.7
Reply With Quote
  #7  
Old 11-30-2005, 12:01 PM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
Ah yes. I'm working on something similar for the "Projects" version of my website.
__________________
touchnothing.net
Reply With Quote
  #8  
Old 11-30-2005, 03:35 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
You can have my source code. No problem.

But how do you distribute large or complex hacks? Just make your own pixelpost is not the solution, and everytime writing a description how to hack is also not the solution.
__________________
Northing.nl

Last edited by eon; 11-30-2005 at 03:39 PM. Reason: typo
Reply With Quote
  #9  
Old 11-30-2005, 03:38 PM
tinyblob's Avatar
tinyblob Offline
team pixelpost
 
Join Date: Nov 2005
Location: scotland
Posts: 523
In my opinion?

Only write addons, if you can't accomplish something that way, and you need to create a hack, it's probably too complex for public release.
__________________
touchnothing.net
Reply With Quote
  #10  
Old 11-30-2005, 03:47 PM
eon's Avatar
eon Offline
pixelpost guru
 
Join Date: Nov 2005
Location: Ned
Posts: 280
Send a message via ICQ to eon
The problem is that pixelpost is not flexible enough. You can use pixelpost only for images. Wouldn't it be nice that you can use pixelpost also for text, video, audio? By just writing an addon for it.

I love Pixelpost for it's structure. But some code in the is not flexible. Take for example the menu of the administrator. That's a static menu.

If you want a can send you de code and you can see by your self if the code is complex. I don't think so.
__________________
Northing.nl
Reply With Quote
Post Reply


Thread Tools




All times are GMT. The time now is 04:51 PM.

Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd. | Style Design: d3 designs