Auteur Topic: 3rd Party Manager  (gelezen 33051 keer)

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #30 Gepost op: 15 februari 2009, 11:34:00 »
Citaat van: "grafcom"
Hallo Alex,

heb je dit doorgenomen?

http://www.synology-forum.nl/viewtopic.php?f=83&t=2182

punt 7 en punt 11

Had alleen punt 7 gedaan, toen kreeg ik deze melding in 3rd Party Manager:

Warning: Cannot modify header information - headers already sent by (output started at /usr/syno/synoman/phpsrc/manager/manager.php:1) in /usr/syno/synoman/phpsrc/manager/manager.php on line 6

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #31 Gepost op: 15 februari 2009, 11:38:36 »
Hallo Alex,

plaats de code is in deze post.

Groet,
Grafcom

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #32 Gepost op: 15 februari 2009, 12:07:30 »
manager.php
   <?php
    putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
    
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
    
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
    if(
$user != 'admin'){
        
header("HTTP/1&#46;0 403 Forbidden");
        exit;
    }
    
ini_set('session&#46;use_cookies','0');
    
session_start();
    
/**
    * Setting some "global" Vars
    */
    
$appl_names = array();
    
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
    
$path_phpsrc '/usr/syno/synoman/phpsrc';
    
$backup_dir '/volume1/tmp';
    
$backup_name 'backupSynology';

    
$dh opendir($path_3rdparty);
    while((
$res=readdir($dh))!==false){
       if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
          
$appl_names[&#93; = $res;
       
}
    }
    if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){
       
foreach ($_POST['del'&#93; as $wert){
          
(file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
          
if($res===0){
             continue;
          }
          
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
          
$tt = array();
          
exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt);
          
if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){
             
exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt);
          
}
          if(
count($tt) == 0){
             echo 
'Entry deleted';
          }else{
             echo 
'<pre>'&#46;implode("rn",$tt)&#46;'</pre>';
          
}
          exit;
       }
    }elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && !empty($_POST['type'&#93;) && (!empty($_POST['fname'&#93;) || !empty($_FILES['file'&#93;['name'&#93;[0&#93;))){
       
$att = array();
       
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>';
       
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />';
       
$str '';
       
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn";
       
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn";
       
$str &#46;= 'type = ';
       
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone';
       
$str &#46;= "rn";
       
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn";
       
$_SESSION['appl&#46;cfg'&#93; = $str;
       
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;));
       
for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){
          
if($_FILES['file'&#93;['name'&#93;[$i&#93; == '' || $_FILES['file'&#93;['size'&#93;[$i&#93; == 0){
             
continue;
          }
          
$f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;);
          
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f);
       
}
       if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){
          
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;)));
       
}
       
$_SESSION['appl&#46;att'&#93; = $att;
       
echo $strr;
       echo 
'<pre>'&#46;$str&#46;'</pre>';
       
echo '<br />';
       echo 
'The following files from your upload will be created:<br /><br />';
       foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
          
echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />';
       
}
       echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary files and settings will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>';
    
}elseif(isset($_POST['backup'&#93;)){
       
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){
          
mkdir($backup_dir&#46;'/'&#46;$backup_name);
       
}
       
$t time();
       
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
       
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
       
foreach($appl_names as $wert){
          (
file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
          
if($res===0){
             continue;
          }
          
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
          
exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
          
exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
       
}
       die(
'Data succesfully written to backup directory');
    }elseif(isset(
$_POST['restore'&#93;) && isset($_POST['path'&#93;) && !empty($_POST['path'&#93;)){
       
if(!is_dir($_POST['path'&#93;) || !is_dir($_POST['path'&#93;&#46;'/phpsrc_'&#46;$_POST['time'&#93;) || !is_dir($_POST['path'&#93;&#46;'/3rdparty_'&#46;$_POST['time'&#93;)){
          
die('Data could not be restored because eihter BackupPath was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path');
       }
       
exec('cp -Rf '&#46;$_POST['path'&#93;&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc);
       
exec('cp -Rf '&#46;$_POST['path'&#93;&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty);
       
die('Data succesfully restored');
    }elseif(isset(
$_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){
       
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
       
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
       
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w');
       
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;);
       
fclose($fp);
       foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
          
$fp fopen($wert['path'&#93;,'w');
          
fwrite($fp,$wert['content'&#93;);
          
fclose($fp);
       }
       unset(
$_SESSION);
       
session_destroy();
       echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation successfull: return</a>';
       
exit;
    }else{
       
?>

       <html>
       <head>
       <title>3rd Party Application Manager</title>
       </head>
       <body>
       <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
       <?php
       
/**
       * Build up a table with checkboxes and names of the installed application
       */
       
echo '<font size=10; face="Arial">3rd-Party Manager';
       echo 
'<table border="0">';
       echo 
'<tr><td colspan=2><font size="4">Remove a 3rd-Party application</font></td></tr>';
       foreach (
$appl_names as $wert){
          echo 
'<tr><td><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" /></td><td><input disabled="disabled" type="text" value="'&#46;$wert&#46;'" /></td></tr>';
       
}
       echo 
'<tr colspan="4" style="text-align:center;"><td><input type="submit" name="delete" value="Delete" /></td>';
       echo 
'<td><input type="reset" value="Reset selection" /></td></tr></table>';
       
?>

       </form>
       <?php
       
/**
       * Form for adding a new application by user
       */
       
?>

       <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
       <table border="0">
       <tr><td colspan="3"><font size="4">Create a 3rd-Party application for Diskstation</font></td></tr>
       </th>
       <tr>
       <td>Text for the Link</td><td><input name="Linktext" type="text" size="40" /></td><td></td>
       </tr>
       <tr>
       <td>Text for the Tooltip</td><td><input name="Description" type="text" size="40" /></td>
       </tr>
       <tr>
       <td>Application Directory</td><td><input name="Dir" type="text" size="40" /></td>
       </tr>
       <tr>
       <td>Application Type</td><td><select name="type">
       <option value="embedded" selected="selected">Embedded</option>
       <option value="standalone">Standalone</option>
       </select>
       </td>
       </tr>
       <tr><td>Filename</td><td><input name="fname" type="text" size="40" /></td><td width="340">This is the file that will initially be called by DSM;</br>if this is an uploaded file (see below) please repeat its name here without a path;</br>otherwise enter the file contents below.</td></tr>
       <tr>
       <tr>
       <td colspan=2>Contents of file:</td>
       </tr>
       <td colspan="20"><textarea name="file_content" rows="40" cols="80"></textarea></td>
       </tr>
       <tr><td>File(s) to upload</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
       <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
       <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
       <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
       <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
       <tr>
       <td colspan=2><input type="submit" name="senden" value="Create" />&nbsp;<input type="reset" value="Reset Form" /></td>
       </tr>
       </table>
       </form>
       <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
       <font size="4">Backup / Restore 3rd-Party applications</font></br>
       <select name="time">
       <?php
       $path 
$backup_dir&#46;'/'&#46;$backup_name;
       
$dh opendir($path);
       while((
$res=readdir($dh))!==false){
          if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){
             
$t substr($res,strpos($res,'_')+1);
             
$arr[&#93; = $t;
          
}
       }
       
$arr array_unique($arr);
       
rsort($arr);
       foreach(
$arr as $wert){
          if(!empty(
$wert)){
             echo 
'<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>';
          
}
       }
       
?>

       </select>
       <input type="text" name="path" />
       <input type="submit" name="backup" value="Backup" />&nbsp;&nbsp;<input type="submit" name="restore" value="Restore" />
       </font>
       </form>
       </body>
       </html>
    <?php
    
}
    
?>

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #33 Gepost op: 15 februari 2009, 12:13:56 »
probeer deze eens......

<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
    
header("HTTP/1&#46;0 403 Forbidden");
    exit;
}
ini_set('session&#46;use_cookies','0');
session_start();

$appl_names = array();
// KEINE abschliessenden / bei den Verzeichnissen!!!
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
$path_phpsrc '/usr/syno/synoman/phpsrc';
$backup_dir '/volume1/tmp';
$backup_name 'backupSynology';

$dh opendir($path_3rdparty);
while((
$res=readdir($dh))!==false){
  if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
   
$appl_names[&#93; = $res; 
  

}
natcasesort($appl_names); 

if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){ 
foreach ($_POST['del'&#93; as $wert){ 
  
(file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0); 
if($res===0){ 
   continue; 
  } 
  
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret); 
  
$tt = array(); 
  
exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt); 
  
if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){ 
   
exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt); 
  

  if(
count($tt) == 0){ 
   echo 
'Entry deleted'
  }else{ 
   echo 
'<pre>'&#46;implode("rn",$tt)&#46;'</pre>'; 
  

  exit; 

}elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && ! 

empty($_POST['type'&#93;) && !empty($_POST['fname'&#93;)){ 
$att = array(); 
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>'
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />'; 
$str ''
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn"; 
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn"; 
$str &#46;= 'type = '; 
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone'; 
$str &#46;= "rn"; 
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn"; 
$_SESSION['appl&#46;cfg'&#93; = $str; 
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;)); 

for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){ 
  
if($_FILES['file'&#93;['name'&#93;[$i&#93; == ''){ 
   
continue; 
  } 
  
$f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;); 
  
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f); 

if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){ 
  
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;))); 

$_SESSION['appl&#46;att'&#93; = $att; 

echo $strr
echo 
'<pre>'&#46;$str&#46;'</pre>'; 
echo '<br />'
echo 
'The following files from your upload will be created:<br /><br />'
foreach(
$_SESSION['appl&#46;att'&#93; as $wert){ 
  
echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />'; 

echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary operation will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>'; 
}elseif(isset($_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){ 
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;); 
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;); 
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w'); 
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;); 
fclose($fp); 

foreach(
$_SESSION['appl&#46;att'&#93; as $wert){ 
  
$fp fopen($wert['path'&#93;,'w'); 
  
fwrite($fp,$wert['content'&#93;); 
  
fclose($fp); 

unset(
$_SESSION); 
session_destroy(); 
echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation Successfull</a>'; 
exit; 
}elseif(isset(
$_POST['backup'&#93;)){ 
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){ 
  
mkdir($backup_dir&#46;'/'&#46;$backup_name); 

$t time(); 
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t); 
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t); 
foreach($appl_names as $wert){ 
  (
file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0); 
if($res===0){ 
   continue; 
  } 
  
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret); 
  
exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t); 
  
exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t); 

die(
'Data succesfully written to backup directory'); 
}elseif(isset(
$_POST['restore'&#93;) && isset($_POST['time'&#93;) && !empty($_POST['time'&#93;)){ 
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;) || !is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;)){ 
  
die('Data could not be restored because either Backup Path was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path'); 

exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc); 
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty); 
die('Data succesfully restored'); 
}else{ 
?>

<html>
<head>
<title>3rd Party Application Remover</title>
<style>body,input,textarea,td,option,select{font:11px Verdana}fieldset{border:1px solid #bbb}</style>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
<fieldset><legend>installed 3rd-party-applications / remover</legend><table border="0"><tr>
<?php 
$ii
=0
foreach (
$appl_names as $wert){ 
  echo 
'<td width="120px"><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" />'&#46;$wert&#46;'</td><td>'; 
  
if (++$ii == 0) echo '</td></tr><tr>'

?>

</tr></table>
<input style="margin-left:150px;margin-top:5px;" type="reset" value="reset form" />
<input style="margin-left:320px" type="submit" name="delete" value="remove 3rd-party-apps" />
</fieldset></form>
<form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
<fieldset><legend>create 3rd-party-application</legend>
<span style="padding-right:53px">text for the link:</span> <input size="90" type="text" name="Linktext" /><br/>
<span style="padding-right:20px">description for tooltip:</span> <input size="90" type="text" name="Description" /><br/>
<span style="padding-right:25px">application directory:</span> <input size="90" type="text" name="Dir" /><br/>
<span style="padding-right:51px">application type:</span> <select name="type">
<option value="embedded" selected="selected">embedded</option>
<option value="popup">popup</option></select><br/>
<span style="padding-right:96px">filename:</span><input input size="90" type="text" name="fname" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:83px">file content:</span><textarea name="file_content" rows="10" cols="87"></textarea><br/>
<input style="margin-left:150px" type="reset" value="reset form" /><input style="margin-left:330px" type="submit" name="senden" value="create 3rd-party-app" />
</fieldset>
<fieldset><legend>Backup and Restore 3rd Party Applications</legend>
<fieldset><legend>Backup 3rd Party Applications</legend>
<input type="submit" name="backup" value="Create Backup" />
</fieldset>
<fieldset><legend>Restore 3rd Party Applications</legend>
<span style="padding-right:20px">Select date for restore</span><select name="time">
<?php 
$path 
$backup_dir&#46;'/'&#46;$backup_name; 
$dh opendir($path); 
$arr = array(); 
while((
$res=readdir($dh))!==false){ 
  if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){ 
   
$t substr($res,strpos($res,'_')+1); 
   
$arr[&#93; =intval($t); 
  


$arr array_unique($arr); 
rsort($arr); 
foreach(
$arr as $wert){ 
if(!empty(
$wert) && $wert != 0){ 
   echo 
'<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>'; 


?>

</select>
<input type="submit" name="restore" value="Restore" />
</fieldset>
</fieldset>
</form>
</body>
</html>
<?php 

?>

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #34 Gepost op: 15 februari 2009, 14:58:56 »
Citaat van: "grafcom"
probeer deze eens......

<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
    
header("HTTP/1&#46;0 403 Forbidden");
    exit;
}
ini_set('session&#46;use_cookies','0');
session_start();

$appl_names = array();
// KEINE abschliessenden / bei den Verzeichnissen!!!
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
$path_phpsrc '/usr/syno/synoman/phpsrc';
$backup_dir '/volume1/tmp';
$backup_name 'backupSynology';

$dh opendir($path_3rdparty);
while((
$res=readdir($dh))!==false){
  if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
   
$appl_names[&#93; = $res; 
  

}
natcasesort($appl_names); 

if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){ 
foreach ($_POST['del'&#93; as $wert){ 
  
(file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0); 
if($res===0){ 
   continue; 
  } 
  
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret); 
  
$tt = array(); 
  
exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt); 
  
if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){ 
   
exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt); 
  

  if(
count($tt) == 0){ 
   echo 
'Entry deleted'
  }else{ 
   echo 
'<pre>'&#46;implode("rn",$tt)&#46;'</pre>'; 
  

  exit; 

}elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && ! 

empty($_POST['type'&#93;) && !empty($_POST['fname'&#93;)){ 
$att = array(); 
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>'
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />'; 
$str ''
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn"; 
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn"; 
$str &#46;= 'type = '; 
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone'; 
$str &#46;= "rn"; 
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn"; 
$_SESSION['appl&#46;cfg'&#93; = $str; 
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;)); 

for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){ 
  
if($_FILES['file'&#93;['name'&#93;[$i&#93; == ''){ 
   
continue; 
  } 
  
$f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;); 
  
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f); 

if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){ 
  
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;))); 

$_SESSION['appl&#46;att'&#93; = $att; 

echo $strr
echo 
'<pre>'&#46;$str&#46;'</pre>'; 
echo '<br />'
echo 
'The following files from your upload will be created:<br /><br />'
foreach(
$_SESSION['appl&#46;att'&#93; as $wert){ 
  
echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />'; 

echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary operation will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>'; 
}elseif(isset($_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){ 
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;); 
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;); 
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w'); 
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;); 
fclose($fp); 

foreach(
$_SESSION['appl&#46;att'&#93; as $wert){ 
  
$fp fopen($wert['path'&#93;,'w'); 
  
fwrite($fp,$wert['content'&#93;); 
  
fclose($fp); 

unset(
$_SESSION); 
session_destroy(); 
echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation Successfull</a>'; 
exit; 
}elseif(isset(
$_POST['backup'&#93;)){ 
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){ 
  
mkdir($backup_dir&#46;'/'&#46;$backup_name); 

$t time(); 
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t); 
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t); 
foreach($appl_names as $wert){ 
  (
file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0); 
if($res===0){ 
   continue; 
  } 
  
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret); 
  
exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t); 
  
exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t); 

die(
'Data succesfully written to backup directory'); 
}elseif(isset(
$_POST['restore'&#93;) && isset($_POST['time'&#93;) && !empty($_POST['time'&#93;)){ 
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;) || !is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;)){ 
  
die('Data could not be restored because either Backup Path was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path'); 

exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc); 
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty); 
die('Data succesfully restored'); 
}else{ 
?>

<html>
<head>
<title>3rd Party Application Remover</title>
<style>body,input,textarea,td,option,select{font:11px Verdana}fieldset{border:1px solid #bbb}</style>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
<fieldset><legend>installed 3rd-party-applications / remover</legend><table border="0"><tr>
<?php 
$ii
=0
foreach (
$appl_names as $wert){ 
  echo 
'<td width="120px"><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" />'&#46;$wert&#46;'</td><td>'; 
  
if (++$ii == 0) echo '</td></tr><tr>'

?>

</tr></table>
<input style="margin-left:150px;margin-top:5px;" type="reset" value="reset form" />
<input style="margin-left:320px" type="submit" name="delete" value="remove 3rd-party-apps" />
</fieldset></form>
<form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
<fieldset><legend>create 3rd-party-application</legend>
<span style="padding-right:53px">text for the link:</span> <input size="90" type="text" name="Linktext" /><br/>
<span style="padding-right:20px">description for tooltip:</span> <input size="90" type="text" name="Description" /><br/>
<span style="padding-right:25px">application directory:</span> <input size="90" type="text" name="Dir" /><br/>
<span style="padding-right:51px">application type:</span> <select name="type">
<option value="embedded" selected="selected">embedded</option>
<option value="popup">popup</option></select><br/>
<span style="padding-right:96px">filename:</span><input input size="90" type="text" name="fname" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
<span style="padding-right:83px">file content:</span><textarea name="file_content" rows="10" cols="87"></textarea><br/>
<input style="margin-left:150px" type="reset" value="reset form" /><input style="margin-left:330px" type="submit" name="senden" value="create 3rd-party-app" />
</fieldset>
<fieldset><legend>Backup and Restore 3rd Party Applications</legend>
<fieldset><legend>Backup 3rd Party Applications</legend>
<input type="submit" name="backup" value="Create Backup" />
</fieldset>
<fieldset><legend>Restore 3rd Party Applications</legend>
<span style="padding-right:20px">Select date for restore</span><select name="time">
<?php 
$path 
$backup_dir&#46;'/'&#46;$backup_name; 
$dh opendir($path); 
$arr = array(); 
while((
$res=readdir($dh))!==false){ 
  if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){ 
   
$t substr($res,strpos($res,'_')+1); 
   
$arr[&#93; =intval($t); 
  


$arr array_unique($arr); 
rsort($arr); 
foreach(
$arr as $wert){ 
if(!empty(
$wert) && $wert != 0){ 
   echo 
'<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>'; 


?>

</select>
<input type="submit" name="restore" value="Restore" />
</fieldset>
</fieldset>
</form>
</body>
</html>
<?php 

?>

Zelfde error.

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #35 Gepost op: 15 februari 2009, 15:08:18 »
zie eens een vorige reactie in deze post van wowo. Die kreeg ook zo'n foutmelding en dat had iets te maken met spaties aan het begin van de regels.
Uit de code van je vorige post leek het daar ook op.

Groet,
Grafcom

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #36 Gepost op: 15 februari 2009, 15:13:49 »
Als ik de code op regel 6 met // uitzonder dan krijg ik wel het formulier maar deze foutmelding bovenin:

Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/syno/synoman/phpsrc/manager/manager.php:1) in /usr/syno/synoman/phpsrc/manager/manager.php on line 10

   <?php
    putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
    
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
    
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
    
//if($user != 'admin'){
      //  header("HTTP/1&#46;0 403 Forbidden");
       // exit;
    //}
    
ini_set('session&#46;use_cookies','0');
    
session_start();

    
$appl_names = array();
    
// KEINE abschliessenden / bei den Verzeichnissen!!!
    
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
    
$path_phpsrc '/usr/syno/synoman/phpsrc';
    
$backup_dir '/volume1/tmp';
    
$backup_name 'backupSynology';

    
$dh opendir($path_3rdparty);
    while((
$res=readdir($dh))!==false){
      if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
       
$appl_names[&#93; = $res;
      
}
    }
    
natcasesort($appl_names);

    if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){
    
foreach ($_POST['del'&#93; as $wert){
      
(file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
    
if($res===0){
       continue;
      }
      
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
      
$tt = array();
      
exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt);
      
if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){
       
exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt);
      
}
      if(
count($tt) == 0){
       echo 
'Entry deleted';
      }else{
       echo 
'<pre>'&#46;implode("rn",$tt)&#46;'</pre>';
      
}
      exit;
    }
    }elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && !

    
empty($_POST['type'&#93;) && !empty($_POST['fname'&#93;)){
    
$att = array();
    
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>';
    
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />';
    
$str '';
    
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn";
    
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn";
    
$str &#46;= 'type = ';
    
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone';
    
$str &#46;= "rn";
    
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn";
    
$_SESSION['appl&#46;cfg'&#93; = $str;
    
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;));

    
for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){
      
if($_FILES['file'&#93;['name'&#93;[$i&#93; == ''){
       
continue;
      }
      
$f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;);
      
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f);
    
}
    if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){
      
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;)));
    
}
    
$_SESSION['appl&#46;att'&#93; = $att;

    
echo $strr;
    echo 
'<pre>'&#46;$str&#46;'</pre>';
    
echo '<br />';
    echo 
'The following files from your upload will be created:<br /><br />';
    foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
      
echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />';
    
}
    echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary operation will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>';
    
}elseif(isset($_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){
    
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
    
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
    
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w');
    
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;);
    
fclose($fp);

    foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
      
$fp fopen($wert['path'&#93;,'w');
      
fwrite($fp,$wert['content'&#93;);
      
fclose($fp);
    }
    unset(
$_SESSION);
    
session_destroy();
    echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation Successfull</a>';
    
exit;
    }elseif(isset(
$_POST['backup'&#93;)){
    
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){
      
mkdir($backup_dir&#46;'/'&#46;$backup_name);
    
}
    
$t time();
    
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
    
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
    
foreach($appl_names as $wert){
      (
file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
    
if($res===0){
       continue;
      }
      
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
      
exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
      
exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
    
}
    die(
'Data succesfully written to backup directory');
    }elseif(isset(
$_POST['restore'&#93;) && isset($_POST['time'&#93;) && !empty($_POST['time'&#93;)){
    
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;) || !is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;)){
      
die('Data could not be restored because either Backup Path was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path');
    }
    
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc);
    
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty);
    
die('Data succesfully restored');
    }else{
    
?>

    <html>
    <head>
    <title>3rd Party Application Remover</title>
    <style>body,input,textarea,td,option,select{font:11px Verdana}fieldset{border:1px solid #bbb}</style>
    </head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
    <fieldset><legend>installed 3rd-party-applications / remover</legend><table border="0"><tr>
    <?php
    $ii
=0;
    foreach (
$appl_names as $wert){
      echo 
'<td width="120px"><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" />'&#46;$wert&#46;'</td><td>';
      
if (++$ii == 0) echo '</td></tr><tr>';
    }
    
?>

    </tr></table>
    <input style="margin-left:150px;margin-top:5px;" type="reset" value="reset form" />
    <input style="margin-left:320px" type="submit" name="delete" value="remove 3rd-party-apps" />
    </fieldset></form>
    <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
    <fieldset><legend>create 3rd-party-application</legend>
    <span style="padding-right:53px">text for the link:</span> <input size="90" type="text" name="Linktext" /><br/>
    <span style="padding-right:20px">description for tooltip:</span> <input size="90" type="text" name="Description" /><br/>
    <span style="padding-right:25px">application directory:</span> <input size="90" type="text" name="Dir" /><br/>
    <span style="padding-right:51px">application type:</span> <select name="type">
    <option value="embedded" selected="selected">embedded</option>
    <option value="popup">popup</option></select><br/>
    <span style="padding-right:96px">filename:</span><input input size="90" type="text" name="fname" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:83px">file content:</span><textarea name="file_content" rows="10" cols="87"></textarea><br/>
    <input style="margin-left:150px" type="reset" value="reset form" /><input style="margin-left:330px" type="submit" name="senden" value="create 3rd-party-app" />
    </fieldset>
    <fieldset><legend>Backup and Restore 3rd Party Applications</legend>
    <fieldset><legend>Backup 3rd Party Applications</legend>
    <input type="submit" name="backup" value="Create Backup" />
    </fieldset>
    <fieldset><legend>Restore 3rd Party Applications</legend>
    <span style="padding-right:20px">Select date for restore</span><select name="time">
    <?php
    $path 
$backup_dir&#46;'/'&#46;$backup_name;
    
$dh opendir($path);
    
$arr = array();
    while((
$res=readdir($dh))!==false){
      if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){
       
$t substr($res,strpos($res,'_')+1);
       
$arr[&#93; =intval($t);
      
}
    }
    
$arr array_unique($arr);
    
rsort($arr);
    foreach(
$arr as $wert){
    if(!empty(
$wert) && $wert != 0){
       echo 
'<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>';
    
}
    }
    
?>

    </select>
    <input type="submit" name="restore" value="Restore" />
    </fieldset>
    </fieldset>
    </form>
    </body>
    </html>
    <?php
    
}
    
?>

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #37 Gepost op: 15 februari 2009, 15:18:59 »
Deze melding stond in een post hiervoor

Citaat
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/syno/synoman/phpsrc/manager/manager.php:1) in /usr/syno/synoman/phpsrc/manager/manager.php on line 10

Komt overeen.

En wanneer ik naar je code kijk (vergelijk met het beeld dat ik stuurde) lijkt het alsof er "lege tekens" voor de regels staan. Kun je die weghalen en opnieuw proberen?

Groet,
Grafcom

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #38 Gepost op: 15 februari 2009, 15:52:29 »
Citaat van: "grafcom"
Deze melding stond in een post hiervoor

Citaat
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /usr/syno/synoman/phpsrc/manager/manager.php:1) in /usr/syno/synoman/phpsrc/manager/manager.php on line 10

Komt overeen.

En wanneer ik naar je code kijk (vergelijk met het beeld dat ik stuurde) lijkt het alsof er "lege tekens" voor de regels staan. Kun je die weghalen en opnieuw proberen?

Groet,
Grafcom

Dan krijg ik een leeg frame met "3rd party manager" erboven.

In Notepad++ doe ik de tekst v/d openingspost kopieren en plakken in een nieuw UNIX ANSI PHP document
Daar heb ik dan die gaten voor de regels. Die verwijder ik door in Notepad++ Bewerken/Insprong verkleinen.

Toch gaat het niet goed ergens in de code. Alleen waar is de vraag.

Code die ik overhou in N++

<?php
putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
if(
$user != 'admin'){
header("HTTP/1&#46;0 403 Forbidden");
exit;
}
ini_set('session&#46;use_cookies','0');
session_start();
/**
* Setting some "global" Vars
*/
$appl_names = array();
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
$path_phpsrc '/usr/syno/synoman/phpsrc';
$backup_dir '/volume1/tmp';
$backup_name 'backupSynology';

$dh opendir($path_3rdparty);
while((
$res=readdir($dh))!==false){
   if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
  $appl_names[&#93; = $res;
   
}
}
if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){
   
foreach ($_POST['del'&#93; as $wert){
  (file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
  if($res===0){
 continue;
  }
  preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
  $tt = array();
  exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt);
  if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){
 exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt);
  }
  if(count($tt) == 0){
 echo 'Entry deleted';
  }else{
 echo '<pre>'&#46;implode("rn",$tt)&#46;'</pre>';
  }
  exit;
   }
}elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && !empty($_POST['type'&#93;) && (!empty($_POST['fname'&#93;) || !empty($_FILES['file'&#93;['name'&#93;[0&#93;))){
   
$att = array();
   
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>';
   
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />';
   
$str '';
   
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn";
   
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn";
   
$str &#46;= 'type = ';
   
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone';
   
$str &#46;= "rn";
   
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn";
   
$_SESSION['appl&#46;cfg'&#93; = $str;
   
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;));
   
for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){
  if($_FILES['file'&#93;['name'&#93;[$i&#93; == '' || $_FILES['file'&#93;['size'&#93;[$i&#93; == 0){
 continue;
  }
  $f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;);
  $att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f);
   
}
   if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){
  $att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;)));
   
}
   
$_SESSION['appl&#46;att'&#93; = $att;
   
echo $strr;
   echo 
'<pre>'&#46;$str&#46;'</pre>';
   
echo '<br />';
   echo 
'The following files from your upload will be created:<br /><br />';
   foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
  echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />';
   
}
   echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary files and settings will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>';
}elseif(isset($_POST['backup'&#93;)){
   
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){
  mkdir($backup_dir&#46;'/'&#46;$backup_name);
   
}
   
$t time();
   
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
   
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
   
foreach($appl_names as $wert){
  (file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
  if($res===0){
 continue;
  }
  preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
  exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
  exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
   
}
   die(
'Data succesfully written to backup directory');
}elseif(isset(
$_POST['restore'&#93;) && isset($_POST['path'&#93;) && !empty($_POST['path'&#93;)){
   
if(!is_dir($_POST['path'&#93;) || !is_dir($_POST['path'&#93;&#46;'/phpsrc_'&#46;$_POST['time'&#93;) || !is_dir($_POST['path'&#93;&#46;'/3rdparty_'&#46;$_POST['time'&#93;)){
  die('Data could not be restored because eihter BackupPath was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path');
   }
   
exec('cp -Rf '&#46;$_POST['path'&#93;&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc);
   
exec('cp -Rf '&#46;$_POST['path'&#93;&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty);
   
die('Data succesfully restored');
}elseif(isset(
$_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){
   
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
   
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
   
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w');
   
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;);
   
fclose($fp);
   foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
  $fp fopen($wert['path'&#93;,'w');
  fwrite($fp,$wert['content'&#93;);
  fclose($fp);
   }
   unset(
$_SESSION);
   
session_destroy();
   echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation successfull: return</a>';
   
exit;
}else{
   
?>

   <html>
   <head>
   <title>3rd Party Application Manager</title>
   </head>
   <body>
   <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
   <?php
   
/**
   * Build up a table with checkboxes and names of the installed application
   */
   
echo '<font size=10; face="Arial">3rd-Party Manager';
   echo 
'<table border="0">';
   echo 
'<tr><td colspan=2><font size="4">Remove a 3rd-Party application</font></td></tr>';
   foreach (
$appl_names as $wert){
  echo '<tr><td><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" /></td><td><input disabled="disabled" type="text" value="'&#46;$wert&#46;'" /></td></tr>';
   
}
   echo 
'<tr colspan="4" style="text-align:center;"><td><input type="submit" name="delete" value="Delete" /></td>';
   echo 
'<td><input type="reset" value="Reset selection" /></td></tr></table>';
   
?>

   </form>
   <?php
   
/**
   * Form for adding a new application by user
   */
   
?>

   <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
   <table border="0">
   <tr><td colspan="3"><font size="4">Create a 3rd-Party application for Diskstation</font></td></tr>
   </th>
   <tr>
   <td>Text for the Link</td><td><input name="Linktext" type="text" size="40" /></td><td></td>
   </tr>
   <tr>
   <td>Text for the Tooltip</td><td><input name="Description" type="text" size="40" /></td>
   </tr>
   <tr>
   <td>Application Directory</td><td><input name="Dir" type="text" size="40" /></td>
   </tr>
   <tr>
   <td>Application Type</td><td><select name="type">
   <option value="embedded" selected="selected">Embedded</option>
   <option value="standalone">Standalone</option>
   </select>
   </td>
   </tr>
   <tr><td>Filename</td><td><input name="fname" type="text" size="40" /></td><td width="340">This is the file that will initially be called by DSM;</br>if this is an uploaded file (see below) please repeat its name here without a path;</br>otherwise enter the file contents below.</td></tr>
   <tr>
   <tr>
   <td colspan=2>Contents of file:</td>
   </tr>
   <td colspan="20"><textarea name="file_content" rows="40" cols="80"></textarea></td>
   </tr>
   <tr><td>File(s) to upload</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
   <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
   <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
   <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
   <tr><td>&nbsp;</td><td colspan=2><input name="file[]" type="file" size="40" /></td></tr>
   <tr>
   <td colspan=2><input type="submit" name="senden" value="Create" />&nbsp;<input type="reset" value="Reset Form" /></td>
   </tr>
   </table>
   </form>
   <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
   <font size="4">Backup / Restore 3rd-Party applications</font></br>
   <select name="time">
   <?php
   $path 
$backup_dir&#46;'/'&#46;$backup_name;
   
$dh opendir($path);
   while((
$res=readdir($dh))!==false){
  if($res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){
 $t substr($res,strpos($res,'_')+1);
 $arr[&#93; = $t;
  }
   }
   
$arr array_unique($arr);
   
rsort($arr);
   foreach(
$arr as $wert){
  if(!empty($wert)){
 echo '<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>';
  }
   }
   
?>

   </select>
   <input type="text" name="path" />
   <input type="submit" name="backup" value="Backup" />&nbsp;&nbsp;<input type="submit" name="restore" value="Restore" />
   </font>
   </form>
   </body>
   </html>
<?php
}
?>

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #39 Gepost op: 15 februari 2009, 16:11:10 »
Probeer eens de code die ik poste te plaatsen in "gewoon" Windows kladblok (NIET Wordpad).

Bij opslaan als codering op ANSI laten staan en bij "opslaan als type" Alle bestanden kiezen en vervolgens de naam manager.php kiezen.

Dit zou zonder problemen moeten kunnen.  :mrgreen:

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #40 Gepost op: 15 februari 2009, 16:24:19 »
Citaat van: "grafcom"
Probeer eens de code die ik poste te plaatsen in "gewoon" Windows kladblok (NIET Wordpad).

Bij opslaan als codering op ANSI laten staan en bij "opslaan als type" Alle bestanden kiezen en vervolgens de naam manager.php kiezen.

Dit zou zonder problemen moeten kunnen.  :mrgreen:

Dan krijg ik dus weer dit:

Warning: Cannot modify header information - headers already sent by (output started at /usr/syno/synoman/phpsrc/manager/manager.php:1) in /usr/syno/synoman/phpsrc/manager/manager.php on line 6

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #41 Gepost op: 15 februari 2009, 16:29:20 »
Hallo Alex,

worden dan die lege tekens weer geplaatst?  :shock:

Groet,
Grafcom

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #42 Gepost op: 15 februari 2009, 16:51:28 »
Citaat van: "grafcom"
Hallo Alex,

worden dan die lege tekens weer geplaatst?  :shock:

Groet,
Grafcom

Ja. Kun je me anders jouw origineel eens e-mailen? alex.hendriks.alex@gmail.com

   <?php
    putenv
('HTTP_COOKIE='&#46;$_SERVER['HTTP_COOKIE'&#93;);
    
putenv('REMOTE_ADDR='&#46;$_SERVER['REMOTE_ADDR'&#93;);
    
$user=exec('/usr/syno/synoman/webman/modules/authenticate&#46;cgi');
    if(
$user != 'admin'){
        
header("HTTP/1&#46;0 403 Forbidden");
        exit;
    }
    
ini_set('session&#46;use_cookies','0');
    
session_start();

    
$appl_names = array();
    
// KEINE abschliessenden / bei den Verzeichnissen!!!
    
$path_3rdparty '/usr/syno/synoman/webman/3rdparty';
    
$path_phpsrc '/usr/syno/synoman/phpsrc';
    
$backup_dir '/volume1/tmp';
    
$backup_name 'backupSynology';

    
$dh opendir($path_3rdparty);
    while((
$res=readdir($dh))!==false){
      if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path_3rdparty&#46;'/'&#46;$res)){
       
$appl_names[&#93; = $res;
      
}
    }
    
natcasesort($appl_names);

    if(isset(
$_POST['delete'&#93;) && isset($_POST['del'&#93;) && count($_POST['del'&#93;) > 0){
    
foreach ($_POST['del'&#93; as $wert){
      
(file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
    
if($res===0){
       continue;
      }
      
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
      
$tt = array();
      
exec('rm -r '&#46;$path_3rdparty&#46;'/'&#46;$wert,$tt);
      
if(isset($ret[1&#93;) && is_dir($path_phpsrc&#46;$ret[1&#93;)){
       
exec('rm -r '&#46;$path_phpsrc&#46;$ret[1&#93;,$tt);
      
}
      if(
count($tt) == 0){
       echo 
'Entry deleted';
      }else{
       echo 
'<pre>'&#46;implode("rn",$tt)&#46;'</pre>';
      
}
      exit;
    }
    }elseif(isset(
$_POST['senden'&#93;) && !empty($_POST['Linktext'&#93;) && !empty($_POST['Description'&#93;) && !empty($_POST['Dir'&#93;) && !

    
empty($_POST['type'&#93;) && !empty($_POST['fname'&#93;)){
    
$att = array();
    
$strr '<strong>Please check the data below carefully as after your confirmation application directories will be created with the parameters given<br />*** No operation will be executed <u>before</u> you confirm by clicking below ***</strong>';
    
$strr &#46;= '<br /><br />First the content of <strong>application&#46;cfg</strong> that will be created in <strong>'&#46;$path_3rdparty&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'</strong><br />';
    
$str '';
    
$str &#46;= 'text = '&#46;$_POST['Linktext'&#93;&#46;"rn";
    
$str &#46;= 'description = '&#46;$_POST['Description'&#93;&#46;"rn";
    
$str &#46;= 'type = ';
    
($_POST['type'&#93; == 'embedded') ? $str &#46;= 'embedded' : $str &#46;= 'standalone';
    
$str &#46;= "rn";
    
$str &#46;= 'path = /phpsrc/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;))&#46;"rn";
    
$_SESSION['appl&#46;cfg'&#93; = $str;
    
$_SESSION['appl&#46;dir'&#93; = preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;));

    
for($i=0;$i<count($_FILES['file'&#93;['name'&#93;);$i++){
      
if($_FILES['file'&#93;['name'&#93;[$i&#93; == ''){
       
continue;
      }
      
$f file_get_contents($_FILES['file'&#93;['tmp_name'&#93;[$i&#93;);
      
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/'&#46;$_FILES['file'&#93;['name'&#93;[$i&#93;,'content'=>$f);
    
}
    if(isset(
$_POST['file_content'&#93;) && trim($_POST['file_content'&#93;) != ''){
      
$att[&#93; = array('path'=>$path_phpsrc&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['Dir'&#93;))&#46;'/'&#46;preg_replace('/s+|/+/','',strtolower($_POST['fname'&#93;)),'content'=>str_replace(chr(13),'',stripslashes($_POST['file_content'&#93;)));
    
}
    
$_SESSION['appl&#46;att'&#93; = $att;

    
echo $strr;
    echo 
'<pre>'&#46;$str&#46;'</pre>';
    
echo '<br />';
    echo 
'The following files from your upload will be created:<br /><br />';
    foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
      
echo '<strong>'&#46;$wert['path'&#93;&#46;'</strong><br />';
    
}
    echo 
'<br />By clicking <a href="'&#46;$_SERVER['PHP_SELF'&#93;&#46;'?'&#46;strip_tags(SID)&#46;'">this link</a> all the necessary operation will be written to disk!!!<br />You can abort the operation by <a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">clicking this link</a>';
    
}elseif(isset($_SESSION['appl&#46;cfg'&#93;) && isset($_SESSION['appl&#46;dir'&#93;)){
    
exec('mkdir '&#46;$path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
    
exec('mkdir '&#46;$path_phpsrc&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;);
    
$fp fopen($path_3rdparty&#46;'/'&#46;$_SESSION['appl&#46;dir'&#93;&#46;'/application&#46;cfg','w');
    
fwrite($fp,$_SESSION['appl&#46;cfg'&#93;);
    
fclose($fp);

    foreach(
$_SESSION['appl&#46;att'&#93; as $wert){
      
$fp fopen($wert['path'&#93;,'w');
      
fwrite($fp,$wert['content'&#93;);
      
fclose($fp);
    }
    unset(
$_SESSION);
    
session_destroy();
    echo 
'<a href="https://'&#46;$_SERVER['SERVER_ADDR'&#93;&#46;':5001/webman/index&#46;cgi">Operation Successfull</a>';
    
exit;
    }elseif(isset(
$_POST['backup'&#93;)){
    
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name)){
      
mkdir($backup_dir&#46;'/'&#46;$backup_name);
    
}
    
$t time();
    
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
    
mkdir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
    
foreach($appl_names as $wert){
      (
file_exists($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') ? $res=file_get_contents($path_3rdparty&#46;'/'&#46;$wert&#46;'/application&#46;cfg') :$res=0);
    
if($res===0){
       continue;
      }
      
preg_match('/path&#46;*?=&#46;*?/phpsrc(/&#46;*?)/&#46;*?&#46;[^s&#93;*/i',$res,$ret);
      
exec('cp -R '&#46;$path_3rdparty&#46;'/'&#46;$wert&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$t);
      
exec('cp -R '&#46;$path_phpsrc&#46;$ret[1&#93;&#46;' '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$t);
    
}
    die(
'Data succesfully written to backup directory');
    }elseif(isset(
$_POST['restore'&#93;) && isset($_POST['time'&#93;) && !empty($_POST['time'&#93;)){
    
if(!is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;) || !is_dir($backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;)){
      
die('Data could not be restored because either Backup Path was not given OR the subdirectories (3rdparty phpsrc) do not exist in given path');
    }
    
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/phpsrc_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_phpsrc);
    
exec('cp -Rf '&#46;$backup_dir&#46;'/'&#46;$backup_name&#46;'/3rdparty_'&#46;$_POST['time'&#93;&#46;'/* '&#46;$path_3rdparty);
    
die('Data succesfully restored');
    }else{
    
?>

    <html>
    <head>
    <title>3rd Party Application Remover</title>
    <style>body,input,textarea,td,option,select{font:11px Verdana}fieldset{border:1px solid #bbb}</style>
    </head>
    <body>
    <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post">
    <fieldset><legend>installed 3rd-party-applications / remover</legend><table border="0"><tr>
    <?php
    $ii
=0;
    foreach (
$appl_names as $wert){
      echo 
'<td width="120px"><input type="checkbox" name="del[&#93;" value="'&#46;$wert&#46;'" />'&#46;$wert&#46;'</td><td>';
      
if (++$ii == 0) echo '</td></tr><tr>';
    }
    
?>

    </tr></table>
    <input style="margin-left:150px;margin-top:5px;" type="reset" value="reset form" />
    <input style="margin-left:320px" type="submit" name="delete" value="remove 3rd-party-apps" />
    </fieldset></form>
    <form action="<?php echo $_SERVER['PHP_SELF'&#93;;?>" method="post" enctype="multipart/form-data">
    <fieldset><legend>create 3rd-party-application</legend>
    <span style="padding-right:53px">text for the link:</span> <input size="90" type="text" name="Linktext" /><br/>
    <span style="padding-right:20px">description for tooltip:</span> <input size="90" type="text" name="Description" /><br/>
    <span style="padding-right:25px">application directory:</span> <input size="90" type="text" name="Dir" /><br/>
    <span style="padding-right:51px">application type:</span> <select name="type">
    <option value="embedded" selected="selected">embedded</option>
    <option value="popup">popup</option></select><br/>
    <span style="padding-right:96px">filename:</span><input input size="90" type="text" name="fname" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:86px">upload file:</span><input size=89 type="file" name="file[]" /><br/>
    <span style="padding-right:83px">file content:</span><textarea name="file_content" rows="10" cols="87"></textarea><br/>
    <input style="margin-left:150px" type="reset" value="reset form" /><input style="margin-left:330px" type="submit" name="senden" value="create 3rd-party-app" />
    </fieldset>
    <fieldset><legend>Backup and Restore 3rd Party Applications</legend>
    <fieldset><legend>Backup 3rd Party Applications</legend>
    <input type="submit" name="backup" value="Create Backup" />
    </fieldset>
    <fieldset><legend>Restore 3rd Party Applications</legend>
    <span style="padding-right:20px">Select date for restore</span><select name="time">
    <?php
    $path 
$backup_dir&#46;'/'&#46;$backup_name;
    
$dh opendir($path);
    
$arr = array();
    while((
$res=readdir($dh))!==false){
      if(
$res != '&#46;' && $res != '&#46;&#46;' && is_dir($path&#46;'/'&#46;$res)){
       
$t substr($res,strpos($res,'_')+1);
       
$arr[&#93; =intval($t);
      
}
    }
    
$arr array_unique($arr);
    
rsort($arr);
    foreach(
$arr as $wert){
    if(!empty(
$wert) && $wert != 0){
       echo 
'<option value="'&#46;$wert&#46;'">'&#46;date('d&#46;m&#46;y H:i:s',$wert)&#46;'</option>';
    
}
    }
    
?>

    </select>
    <input type="submit" name="restore" value="Restore" />
    </fieldset>
    </fieldset>
    </form>
    </body>
    </html>
    <?php
    
}
    
?>

Anonymous

  • Gast
Re: 3rd Party Manager
« Reactie #43 Gepost op: 15 februari 2009, 16:55:01 »
Ik heb op http://www.synology-forum.nl/viewtopic.php?f=83&t=2182 punt 8, 9 en 10 niet gedaan. Is dat misschien het probleem?

Offline grafcom

  • MVP
  • *
  • Bedankjes
  • -Gegeven: 1
  • -Ontvangen: 0
  • Berichten: 272
Re: 3rd Party Manager
« Reactie #44 Gepost op: 15 februari 2009, 17:14:40 »
mail verstuurd.

punt 9 en 10 heb ik ook niet gedaan. Punt 8 wel.

Groet,
Grafcom


 

Advanced Power Manager - vreemd gedrag

Gestart door BabyloniaBoard Overige 3rd party packages

Reacties: 2
Gelezen: 3709
Laatste bericht 28 november 2014, 12:47:03
door Babylonia
Geen link in 3rd party applications / geen web interface

Gestart door AnonymousBoard SABnzbd (usenet)

Reacties: 3
Gelezen: 2363
Laatste bericht 23 februari 2010, 11:42:31
door nicov
Virtual Machine manager

Gestart door GuidoGBoard Officiƫle Packages

Reacties: 1
Gelezen: 1719
Laatste bericht 26 augustus 2017, 08:52:58
door dvandonkelaar
Docker: Nginx Reverse Proxy manager

Gestart door Syno_NasjeBoard Docker / Container Manager

Reacties: 16
Gelezen: 6812
Laatste bericht 22 februari 2023, 09:51:02
door vdhoek1972
VERPLAATST: Update SAN Manager Loskoppelen initators

Gestart door BirdyBoard Synology DSM algemeen

Reacties: 0
Gelezen: 734
Laatste bericht 06 augustus 2021, 22:19:02
door Birdy