コード例 #1
0
 /**
  * Import Layout
  * @access private
  */
 function import_Layout($zipfile)
 {
     $name = $this->_modulexml->name;
     $label = $this->_modulexml->label;
     self::log("Importing {$name} ... STARTED");
     $unzip = new Vtiger_Unzip($zipfile);
     $filelist = $unzip->getList();
     $vtiger6format = false;
     $badFileExtensions = array_diff(vglobal('upload_badext'), ['js']);
     foreach ($filelist as $filename => $fileinfo) {
         if (!$unzip->isdir($filename)) {
             if (strpos($filename, '/') === false) {
                 continue;
             }
             $targetdir = substr($filename, 0, strripos($filename, '/'));
             $targetfile = basename($filename);
             $dounzip = false;
             $fileValidation = true;
             // Case handling for jscalendar
             if (stripos($targetdir, "layouts/{$name}/skins") === 0) {
                 $dounzip = true;
                 $vtiger6format = true;
             } else {
                 if (stripos($targetdir, "layouts/{$name}/modules") === 0) {
                     $vtiger6format = true;
                     $dounzip = true;
                 } else {
                     if (stripos($targetdir, "layouts/{$name}/libraries") === 0) {
                         $vtiger6format = true;
                         $dounzip = true;
                     }
                 }
             }
             if ($dounzip) {
                 // vtiger6 format
                 if ($vtiger6format) {
                     $targetdir = "layouts/{$name}/" . str_replace("layouts/{$name}", "", $targetdir);
                     @mkdir($targetdir, 0755, true);
                 }
                 $filepath = 'zip://' . vglobal('root_directory') . $zipfile . '#' . $filename;
                 $fileInfo = pathinfo($filepath);
                 if (in_array($fileInfo['extension'], $badFileExtensions)) {
                     $fileValidation = false;
                 }
                 // Check for php code injection
                 if (preg_match('/(<\\?php?(.*?))/i', file_get_contents($filepath)) == 1) {
                     $fileValidation = false;
                 }
                 if ($fileValidation) {
                     if ($unzip->unzip($filename, "{$targetdir}/{$targetfile}") !== false) {
                         self::log("Copying file {$filename} ... DONE");
                     } else {
                         self::log("Copying file {$filename} ... FAILED");
                     }
                 } else {
                     self::log("Incorrect file {$filename} ... SKIPPED");
                 }
             } else {
                 self::log("Copying file {$filename} ... SKIPPED");
             }
         }
     }
     if ($unzip) {
         $unzip->close();
     }
     self::register($name, $label);
     self::log("Importing {$name}({$label}) ... DONE");
     return;
 }
コード例 #2
0
 /**
  * Initialize Import
  * @access private
  */
 function initImport($zipfile, $overwrite = true)
 {
     $module = $this->getModuleNameFromZip($zipfile);
     if ($module != null) {
         $unzip = new Vtiger_Unzip($zipfile, $overwrite);
         // Unzip selectively
         $unzip->unzipAllEx(".", array('include' => array('templates', "modules/{$module}", 'cron', 'languages', 'settings/actions', 'settings/views', 'settings/models', 'settings/templates', 'settings/connectors', 'settings/libraries', "{$module}.png", 'updates')), array('templates' => "layouts/vlayout/modules/{$module}", 'cron' => "cron/modules/{$module}", 'settings/actions' => "modules/Settings/{$module}/actions", 'settings/views' => "modules/Settings/{$module}/views", 'settings/models' => "modules/Settings/{$module}/models", 'settings/connectors' => "modules/Settings/{$module}/connectors", 'settings/libraries' => "modules/Settings/{$module}/libraries", 'settings/templates' => "layouts/vlayout/modules/Settings/{$module}", 'images' => "layouts/vlayout/skins/images/{$module}", 'settings' => "modules/Settings", 'updates/files' => ".", 'updates' => "cache/updates"));
         if ($unzip->checkFileExistsInRootFolder("{$module}.png")) {
             $unzip->unzip("{$module}.png", "layouts/vlayout/skins/images/{$module}.png");
         }
         if ($unzip) {
             $unzip->close();
         }
     }
     return $module;
 }
コード例 #3
0
	/**
	 * Initialize Import
	 * @access private
	 */
	function initImport($zipfile, $overwrite = true)
	{
		$module = $this->getModuleNameFromZip($zipfile);
		if ($module != null) {
			$unzip = new Vtiger_Unzip($zipfile, $overwrite);
			// Unzip selectively
			$unzip->unzipAllEx(".", Array(
				// Include only file/folders that need to be extracted
				'include' => Array('templates', "modules/$module", 'cron', 'languages',
					'settings/actions', 'settings/views', 'settings/models', 'settings/templates', 'settings/connectors', 'settings/libraries',
					"$module.png", 'updates', 'layouts'),
				// NOTE: If excludes is not given then by those not mentioned in include are ignored.
				),
				// What files needs to be renamed?
				Array(
				// Templates folder
				'templates' => "layouts/vlayout/modules/$module",
				// Cron folder
				'cron' => "cron/modules/$module",
				// Settings folder
				'settings/actions' => "modules/Settings/$module/actions",
				'settings/views' => "modules/Settings/$module/views",
				'settings/models' => "modules/Settings/$module/models",
				'settings/connectors' => "modules/Settings/$module/connectors",
				'settings/libraries' => "modules/Settings/$module/libraries",
				// Settings templates folder
				'settings/templates' => "layouts/vlayout/modules/Settings/$module",
				//module images
				'images' => "layouts/vlayout/skins/images/$module",
				'settings' => "modules/Settings",
				'updates' => "cache/updates",
				'layouts' => 'layouts'
				)
			);

			if ($unzip->checkFileExistsInRootFolder("$module.png")) {
				$unzip->unzip("$module.png", "layouts/vlayout/skins/images/$module.png");
			}

			if ($unzip)
				$unzip->close();
		}
		return $module;
	}
コード例 #4
0
 /**
  * Import Module
  * @access private
  */
 function import_Language($zipfile)
 {
     $name = $this->_modulexml->name;
     $prefix = $this->_modulexml->prefix;
     $label = $this->_modulexml->label;
     self::log("Importing {$label} [{$prefix}] ... STARTED");
     $unzip = new Vtiger_Unzip($zipfile);
     $filelist = $unzip->getList();
     foreach ($filelist as $filename => $fileinfo) {
         if (!$unzip->isdir($filename)) {
             if (strpos($filename, '/') === false) {
                 continue;
             }
             $targetdir = substr($filename, 0, strripos($filename, '/'));
             $targetfile = basename($filename);
             $prefixparts = split('_', $prefix);
             $dounzip = false;
             if (is_dir($targetdir)) {
                 // Case handling for jscalendar
                 if (stripos($targetdir, 'jscalendar/lang') === 0 && stripos($targetfile, "calendar-" . $prefixparts[0] . ".js") === 0) {
                     if (file_exists("{$targetdir}/calendar-en.js")) {
                         $dounzip = true;
                     }
                 } else {
                     if (stripos($targetdir, 'modules/Emails/language') === 0 && stripos($targetfile, "phpmailer.lang-{$prefix}.php") === 0) {
                         if (file_exists("{$targetdir}/phpmailer.lang-en_us.php")) {
                             $dounzip = true;
                         }
                     } else {
                         if (preg_match("/{$prefix}.lang.js/", $targetfile)) {
                             $corelangfile = "{$targetdir}/en_us.lang.js";
                             if (file_exists($corelangfile)) {
                                 $dounzip = true;
                             }
                         } else {
                             if (preg_match("/{$prefix}.lang.php/", $targetfile)) {
                                 $corelangfile = "{$targetdir}/en_us.lang.php";
                                 if (file_exists($corelangfile)) {
                                     $dounzip = true;
                                 }
                             }
                         }
                     }
                 }
             }
             if ($dounzip) {
                 if ($unzip->unzip($filename, $filename) !== false) {
                     self::log("Copying file {$filename} ... DONE");
                 } else {
                     self::log("Copying file {$filename} ... FAILED");
                 }
             } else {
                 self::log("Copying file {$filename} ... SKIPPED");
             }
         }
     }
     if ($unzip) {
         $unzip->close();
     }
     self::register($prefix, $label, $name);
     self::log("Importing {$label} [{$prefix}] ... DONE");
     return;
 }
コード例 #5
0
ファイル: LayoutImport.php プロジェクト: cin-system/cinrepo
 /**
  * Import Module
  * @access private
  */
 function import_Layout($zipfile)
 {
     $name = $this->_modulexml->name;
     $label = $this->_modulexml->label;
     self::log("Importing {$label} ... STARTED");
     $unzip = new Vtiger_Unzip($zipfile);
     $filelist = $unzip->getList();
     $vtiger6format = false;
     foreach ($filelist as $filename => $fileinfo) {
         if (!$unzip->isdir($filename)) {
             if (strpos($filename, '/') === false) {
                 continue;
             }
             $targetdir = substr($filename, 0, strripos($filename, '/'));
             $targetfile = basename($filename);
             $dounzip = false;
             // Case handling for jscalendar
             if (stripos($targetdir, "layouts/{$label}/skins") === 0) {
                 $dounzip = true;
                 $vtiger6format = true;
             } else {
                 if (stripos($targetdir, "layouts/{$label}/modules") === 0) {
                     $vtiger6format = true;
                     $dounzip = true;
                 }
             }
             if ($dounzip) {
                 // vtiger6 format
                 if ($vtiger6format) {
                     $targetdir = "layouts/{$label}/" . str_replace("layouts/{$label}", "", $targetdir);
                     @mkdir($targetdir, 0777, true);
                 }
                 if ($unzip->unzip($filename, "{$targetdir}/{$targetfile}") !== false) {
                     self::log("Copying file {$filename} ... DONE");
                 } else {
                     self::log("Copying file {$filename} ... FAILED");
                 }
             } else {
                 self::log("Copying file {$filename} ... SKIPPED");
             }
         }
     }
     if ($unzip) {
         $unzip->close();
     }
     self::register($label, $name);
     self::log("Importing {$label} [{$prefix}] ... DONE");
     return;
 }