|
dbrown
|
 |
« Reply #30 on: July 25, 2008, 07:19:50 PM » |
|
I got a problem I created a file tree on the master sever with all the slave files. Instead of the php files parsing out, I want them to be downloadable. So I added <Files *.php> ForceType application/octet-stream Header set Content-Disposition attachment </Files> to muh htaccess file. It enables the download, but the fishing php file still got parsed  What gives?
|
|
|
|
|
Logged
|
|
|
|
|
nutballs
|
 |
« Reply #31 on: July 25, 2008, 07:35:13 PM » |
|
what I do is from my control file, I file_get_contents of the the new code file, then reply to the slave with that big ass long string of php, then the slave writes that to file on its end.
no htaccess, pure file system and text responses.
|
|
|
|
|
Logged
|
|
|
|
|
dbrown
|
 |
« Reply #32 on: July 25, 2008, 07:39:01 PM » |
|
how you spitting those php files out without them parsing....?
|
|
|
|
|
Logged
|
|
|
|
|
dbrown
|
 |
« Reply #33 on: July 25, 2008, 08:02:39 PM » |
|
Found a solution that fits my system well. Of course I got to put in some security, but other than that I should be ok with this. Right? <?php
$filename = $_GET['file'];
// required for IE, otherwise Content-disposition is ignored // Who the hell cares though since I am using a nix server to download if(ini_get('zlib.output_compression')) ini_set('zlib.output_compression', 'Off');
$file_extension = strtolower(substr(strrchr($filename,"."),1));
if( $filename == "" ) { exit; } elseif ( ! file_exists( $filename ) ) { echo "error_dne"; exit; }; switch( $file_extension ) { case "pdf": $ctype="application/pdf"; break; case "exe": $ctype="application/octet-stream"; break; case "zip": $ctype="application/zip"; break; case "doc": $ctype="application/msword"; break; case "xls": $ctype="application/vnd.ms-excel"; break; case "ppt": $ctype="application/vnd.ms-powerpoint"; break; case "gif": $ctype="image/gif"; break; case "png": $ctype="image/png"; break; case "jpeg": case "jpg": $ctype="image/jpg"; break; default: $ctype="application/force-download"; } header("Pragma: public"); // required header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Cache-Control: private",false); // required for certain browsers header("Content-Type: $ctype"); // change, added quotes to allow spaces in filenames, by Rajkumar Singh header("Content-Disposition: attachment; filename=\"".basename($filename)."\";" ); header("Content-Transfer-Encoding: binary"); header("Content-Length: ".filesize($filename)); readfile("$filename"); exit();
?>
|
|
|
|
|
Logged
|
|
|
|
|
nutballs
|
 |
« Reply #34 on: July 25, 2008, 08:32:50 PM » |
|
my master controller just does this when it gets a proper GET request from a slave:
echo file_get_contents('code.php');
thats it. nothing more. then my slave just does:
$codefile = '/some/path/to/the/code/file'; $content= getcode(); $filehandle = fopen($codefile, "w+"); fwrite($filehandle,$content); fclose($filehandle);
|
|
|
|
|
Logged
|
|
|
|
|
dbrown
|
 |
« Reply #35 on: July 26, 2008, 12:52:55 PM » |
|
I feel like the more complex my system get the harder it is to write easy code. I have been looking at all the different ways to update slaves. Coding for maximum compatibility is a headache. Lets say the instead of just updating files that are already on the slave, I want to add, delete, or modify folders. If you're on a shared *nix server, a directory created through mkdir() will not be assigned to you, but to the user that your host's server or php process is running under, usually 'nobody', 'apache' or 'httpd'.
In practice, this means that you can create directories, even add files to them, but you can't delete the directory or its contents nor change permissions. That right there just fucked me all up.  I have to change direction. To me, a php ftp based system may be better in the long run. Lets quote the master of nuts and balls So if you got this far, the next steps are just building blocks on the foundation you just built.
until of course you realize your foundation is shit and then start over... What if your master used a ftp based system. Wouldn't it be more flexible with a ftp based master? FTP is one of those things that are pretty standard across all shared hosts. Location:Login:Pass You wouldn't have to worry about all the quirks with PHP4/PHP5, php.ini vars, apache vars, etc
|
|
|
|
|
Logged
|
|
|
|
|
nutballs
|
 |
« Reply #36 on: July 26, 2008, 01:41:58 PM » |
|
all my stuff is dumped into a directory that is 777 so my sites, when they are born, are /rootdirectory/slave.php /rootdirectory/.htaccess /rootdirectory/allmyfiles/ <--this is 777 and everything is dropped there, and since its 777, the web account can create whatever it needs.
|
|
|
|
|
Logged
|
|
|
|
|
dbrown
|
 |
« Reply #37 on: July 26, 2008, 01:45:44 PM » |
|
isnt that awful unsecure?
|
|
|
|
|
Logged
|
|
|
|
|
nutballs
|
 |
« Reply #38 on: July 26, 2008, 01:53:38 PM » |
|
only if you know the directory 
|
|
|
|
|
Logged
|
|
|
|
|
jammaster82
|
 |
« Reply #39 on: July 26, 2008, 04:14:01 PM » |
|
well lets say i did know the directory, i understand 777 is read write and execute for all users but how could someone providing they know the directory write to it, or mess with you? wouldnt they have to have ftp access?
|
|
|
|
|
Logged
|
Of course Big Brother exists, he is the embodiment of the party..... Does he exist in the same way I exist?....... You, do not exist.
|
|
|
|
nutballs
|
 |
« Reply #40 on: July 26, 2008, 04:37:09 PM » |
|
yes they would, usually. there have been http exploits in the past where a user can upload arbitrary code to a server, however, I am pretty sure there is nothing "simple" anymore. But in my case, because of how my system works, if you know the codes, you can upload anything to my server, such as, a file that allows you to browse my server etc. This is not likely, but possible.
so thats why i put this in places where I dont give a shit really.
|
|
|
|
|
Logged
|
|
|
|
perkiset
Olde World Hacker
Administrator
Lifer
   
Online
Posts: 5230
:sniffle: Humor was so much easier before.
|
 |
« Reply #41 on: July 29, 2008, 09:41:09 AM » |
|
I've gotta run for a moment, so this is just a quickie answer: but this is probably in the httpd.conf file:
AddType application/x-httpd-php-source .phps
which means that any file named .phps will get shipped back as source. Do a
ln -s ./myfile.php ./myfile.phps
and if someone requests the file with the phps suffix you will ship back source.
I didn't read the rest of this so I have no idea why in the world you'd want to do that, but php comes with this option as a default.
|
|
|
|
|
Logged
|
If I can't be Mr. Root then I don't want to play.
|
|
|
|
dbrown
|
 |
« Reply #42 on: July 29, 2008, 09:50:24 AM » |
|
I've gotta run for a moment, so this is just a quickie I like quickie's, but the wife dont  answer: but this is probably in the httpd.conf file:
AddType application/x-httpd-php-source .phps
which means that any file named .phps will get shipped back as source. Do a
ln -s ./myfile.php ./myfile.phps
and if someone requests the file with the phps suffix you will ship back source.
I didn't read the rest of this so I have no idea why in the world you'd want to do that, but php comes with this option as a default.
I still needed that even though the main update process is now php ftp. I am really liking the ftp way on the master. I have it done already and am moving on to other features.
|
|
|
|
|
Logged
|
|
|
|
perkiset
Olde World Hacker
Administrator
Lifer
   
Online
Posts: 5230
:sniffle: Humor was so much easier before.
|
 |
« Reply #43 on: July 29, 2008, 10:24:46 AM » |
|
 Sorry DB, now I remember... we're shipping code between master and slave... I do something just a little differently. I load everything up that must be distributed to clients in a DB as a message queue. The reason for this, is that I may do a master update of everything, but I don't want slaves coming to me any more quickly than one-per-minute over the next 48 hours or something. So I'll do my update, then the updated code will be placed into a table with the intended slave as the recipient. Then my timing module will ping <x> slave to come get his updates - which may include a combination of code, content and other instructions (send me back your stats, for example) - and the slave will continue to hit me until he has pulled all of his messages. Each message has a checksum (it's in another column of the table) that the slave must kick back with so that I know that the slave has received the message before I'll delete it from the queue. But the comms method is quite simple - and it's very similar to my AJAX method - it's a serialized array that contains information about what is being sent (this is code/content/instruction) the data itself, the checksum and sometimes other things. The packet is unserialized at the client, executed on and then the checksum is used in the "Is there anything else for me?" question from the slave to the master. Either the answer is yes, with another serialized array, or no at which point comms close.  /p
|
|
|
|
|
Logged
|
If I can't be Mr. Root then I don't want to play.
|
|
|
|
dbrown
|
 |
« Reply #44 on: July 29, 2008, 06:56:31 PM » |
|
I am going to update spider ips via the ping me call home method, but I am using a phpftp "version control" like system for the core application. I have been spending the last 4 hours testing and I think I have it wrapped up. This was my biggest challenge in php yet. Chmoding in phpftp was kinda hard to code. Had a lot of things that I had not learned yet. Here are some of the features the master has Files are placed in a master update tree and I add "site type" configs via CP, now I have site type's/modules. /updatetree/ | /updatetree/scrapersitefiles | /updatetree/bans | each site module has different config settings, keywords, etc stored in the db /updatetree/somedirectorysite | All permissions in the update tree are carried over to the slave up update. If enabled Each type/module can have file exclusions. (for configs and other shat that should never be updated) Each site can be updated via php ftp when a newer file is place in the tree OR manually OR globally OR last update OR check timestamps So I now I can have clouds of sites and update the clouds based on many rules or overwrite them all with something drastically different in one big damn swoop. I will get some screenshots up and maybe it will be easier to understand, but Im lovin it.... 
|
|
|
|
« Last Edit: July 29, 2008, 06:59:16 PM by dbrown »
|
Logged
|
|
|
|
|