function generate_actions_dirs($dir = '') { global $dirs; $arr = array(); if ($dir && substr($dir, strlen($dir) - 1) !== '/') { $dir .= '/'; } if ($dir) { // remove trailing / $pos = strrpos($dir, '/'); $str = $pos === strlen($dir) - 1 ? substr($dir, 0, $pos) : $dir; // get last directory name $pos = strrpos($str, '/'); $str = $pos ? substr($str, $pos + 1) : $str; $arr[] = array('command' => 'mkdir', 'dir' => $str, 'ignore' => true); $arr[] = array('command' => 'chdir', 'dir' => $str); } $arr[] = array('command' => 'exec', 'list' => generate_actions_files($dir)); // create subdirectories $len = strlen($dir); for ($i = 0; $i < count($dirs); $i++) { $str = $dirs[$i]; if (substr($str, 0, $len) === $dir) { if ($len) { $str = substr($str, $len + 1); } $pos = strpos($str, '/'); if ($pos == strlen($str) - 1) { $arr[] = array('command' => 'exec', 'list' => generate_actions_dirs($dirs[$i])); } } } return $arr; }
xs_message($lang['Information'], $str); } $str = ''; if (!$write_local) { // // Generate actions list // $actions = array(); // chdir to template directory $actions[] = array('command' => 'chdir', 'dir' => 'templates'); // create directory with template name $actions[] = array('command' => 'mkdir', 'dir' => $header['template'], 'ignore' => true); // change directory $actions[] = array('command' => 'chdir', 'dir' => $header['template']); // create all directories and upload all files $actions[] = array('command' => 'exec', 'list' => generate_actions_dirs()); $ftp_log = array(); $ftp_error = ''; $res = ftp_myexec($actions); /* echo "<!--\n\n"; echo "\$actions dump:\n\n"; print_r($actions); echo "\n\n\$ftp_log dump:\n\n"; print_r($ftp_log); echo "\n\n -->"; */ // remove temporary files for ($i = 0; $i < sizeof($items); $i++) { if (!empty($items[$i]['tmp'])) { @unlink($items[$i]['tmp']);