Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- class scp_configs {
- private $configs;
- function updaterCheckFiles($checkme) {
- if($checkme!="|" && !empty($checkme)){
- if(!is_writable($checkme)){
- if(!chmod($checkme, 0777)){
- if (!file_exists($checkme)) {
- return"create";
- }
- }
- else {
- return "none";
- }
- }
- else {
- return "write";
- }
- }
- }
- function updatefile($id) {
- $get_new_file_contents = file_get_contents(WEBCRAFT."/webcraft_load/update.php?version=1&filecontent=".$id);
- $get_new_file_path = file_get_contents(WEBCRAFT."/webcraft_load/update.php?version=1&filepath=".$id);
- if(!empty($get_new_file_contents) && !empty($get_new_file_path) ){
- if(!is_writable($get_new_file_path)){
- if(!chmod($get_new_file_path, 0777)){
- if (!file_exists($get_new_file_path)) {
- $filehandler = fopen($get_new_file_path, "w" );
- fwrite($filehandler, $get_new_file_contents);
- fclose($filehandler);
- }
- }
- }
- else {
- $filehandler = fopen($get_new_file_path, "w" );
- fwrite($filehandler, $get_new_file_contents);
- fclose($filehandler);
- }
- }
- }
- function updateVersion(){
- $get_new_version = file_get_contents(WEBCRAFT."/webcraft_load/update.php?version=1&newversion=1");
- if(!is_writable('./version.php')){
- if(!chmod('./version.php', 0777)){
- if (!file_exists('./version.php')) {
- $filehandler = fopen('./version.php', "w" );
- fwrite($filehandler, "<?php \n $cms_version='".$get_new_version."';");
- fclose($filehandler);
- }
- }
- }
- else {
- $filehandler = fopen('./version.php', "w" );
- fwrite($filehandler, "<?php \n \$cms_version='".$get_new_version."';");
- fclose($filehandler);
- }
- }
- }
- $new_ver = file_get_contents(WEBCRAFT."/webcraft_load/update.php?version=1&filelist=1");
- if(!empty($new_ver)){
- $scp_catche->updaterCheckFiles($filearray);
- echo "New files:<br />";
- $filearray= explode("|", $new_ver);
- foreach($filearray as $filepath){
- if($filepath!=" \n" && !empty($filepath)){
- $filestate = $scp_catche->updaterCheckFiles($filepath);
- if($filestate=="write"){
- echo "<font color='green'>".$filepath." </font> Is writeable<br />";
- }
- if($filestate=="none"){
- echo "<font color='red'>".$filepath."</font> Is NOT writable<br />";
- }
- if($filestate=="create"){
- echo "<font color='orange'>".$filepath."</font> Will be created<br />";
- }
- }
- }
- echo'<form action="" method="post"><input type="submit" class="in-button" value="update" name="update"></form>';
- }
- else{
- echo "no update avalible";
- }
- if($_POST['update']){
- $id=1;
- $last = count($filearray);
- foreach($filearray as $filepath){
- if($filepath!=" \n" && !empty($filepath)){
- $scp_catche->updatefile($id);
- if($id==$last){
- $scp_catche->updateVersion();
- }
- $id++;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement