ISPConfig 3 scrpt to regenerate all web-domain or other stuffs

Discussion in 'Plugins/Modules/Addons' started by ollea, Dec 13, 2013.

  1. ollea

    ollea New Member

    Here is a little PHP script to force regeneration of all web-domain virtual host.

    You just need to modify the line 23 ($new['php'] = 'fast-cgi';) with the data you want to update on web-domain.
    For example in lines below the script will change PHP system for all virtual hosts to Fast-CGI.

    This script can be easily adapted to insert sys_datalog for other stuffs like web-domain, etc.

    Hope it will help you.

    Code:
    <?php
    
    $ispconfig_path = '/usr/local/ispconfig';
    
    require_once($ispconfig_path.'/server/lib/config.inc.php');
    require_once($ispconfig_path.'/server/lib/app.inc.php');
    
    // Define table to modify
    $dbtable = 'web_domain';
    
    if ( $records = $app->db->queryAllRecords("SELECT * FROM `".$dbtable."` WHERE `type` = 'vhost'") )
    {
    	foreach ( $records as $record )
    	{
    		// Copy record to new array
    		$new = array();
    		foreach ( $record as $key => $value )
    		{
    			$new[$key] = $value;
    		}
    
    		// Modify data
    		$new['php'] = 'fast-cgi';
    
    		// Create data array
    		$data = array(
    			'old' => $record,
    			'new' => $new
    		);
    
    		// Insert sys_datalog
    		$app->db->query("INSERT INTO `sys_datalog` (`server_id`, `dbtable`, `dbidx`, `action`, `tstamp`, `user`, `data`, `status`) VALUES (".$record['server_id'].", '".$dbtable."', 'domain_id:".$record['domain_id']."', 'u', ".time().", 'admin', '".$app->db->quote(serialize($data))."', 'ok')");
    
    		echo "Modifying $dbtable record : ".print_r($record, true)."\n";
    	}
    }
    
    ?>
    
    Sincerely yours,
     
  2. Croydon

    Croydon ISPConfig Developer ISPConfig Developer

    In my opinion you should NOT do this.
    Use the remoting api!
     

Share This Page