本文整理汇总了PHP中JArchive::create方法的典型用法代码示例。如果您正苦于以下问题:PHP JArchive::create方法的具体用法?PHP JArchive::create怎么用?PHP JArchive::create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JArchive
的用法示例。
在下文中一共展示了JArchive::create方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: processLanguageFiles
function processLanguageFiles($code = 'en-GB', $method = '', $params = array())
{
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.archive');
$prefix = $code . '.';
$suffix = '.ini';
$missing = array();
$namea = '';
$names = '';
$adminpath = JPATH_ADMINISTRATOR . DS . 'language' . DS . $code . DS;
$refadminpath = JPATH_ADMINISTRATOR . DS . 'language' . DS . 'en-GB' . DS;
$adminfiles = array('com_flexicontent', FLEXI_J16GE ? 'com_flexicontent.sys' : '', 'plg_flexicontent_fields_addressint', 'plg_flexicontent_fields_checkbox', 'plg_flexicontent_fields_checkboximage', 'plg_flexicontent_fields_core', 'plg_flexicontent_fields_date', 'plg_flexicontent_fields_email', 'plg_flexicontent_fields_extendedweblink', 'plg_flexicontent_fields_fcloadmodule', 'plg_flexicontent_fields_fcpagenav', 'plg_flexicontent_fields_file', 'plg_flexicontent_fields_groupmarker', 'plg_flexicontent_fields_image', 'plg_flexicontent_fields_linkslist', 'plg_flexicontent_fields_minigallery', 'plg_flexicontent_fields_phonenumbers', 'plg_flexicontent_fields_radio', 'plg_flexicontent_fields_radioimage', 'plg_flexicontent_fields_relation', 'plg_flexicontent_fields_relation_reverse', 'plg_flexicontent_fields_select', 'plg_flexicontent_fields_selectmultiple', 'plg_flexicontent_fields_shareaudio', 'plg_flexicontent_fields_sharevideo', 'plg_flexicontent_fields_text', 'plg_flexicontent_fields_textarea', 'plg_flexicontent_fields_textselect', 'plg_flexicontent_fields_toolbar', 'plg_flexicontent_fields_weblink', FLEXI_J16GE ? 'plg_finder_flexicontent' : '', FLEXI_J16GE ? 'plg_finder_flexicontent.sys' : '', 'plg_content_flexibreak', 'plg_flexicontent_flexinotify', 'plg_search_flexiadvsearch', 'plg_search_flexisearch', 'plg_system_flexiadvroute', 'plg_system_flexisystem');
$sitepath = JPATH_SITE . DS . 'language' . DS . $code . DS;
$refsitepath = JPATH_SITE . DS . 'language' . DS . 'en-GB' . DS;
$sitefiles = array('com_flexicontent', 'mod_flexiadvsearch', 'mod_flexicontent', 'mod_flexitagcloud', 'mod_flexifilter');
$targetfolder = JPATH_SITE . DS . 'tmp' . DS . $code . "_" . time();
if ($method == 'zip') {
if (count($adminfiles)) {
JFolder::create($targetfolder . DS . 'admin', 0755);
}
if (count($sitefiles)) {
JFolder::create($targetfolder . DS . 'site', 0755);
}
}
foreach ($adminfiles as $file) {
if (!$file) {
continue;
}
if (!JFile::exists($adminpath . $prefix . $file . $suffix)) {
$missing['admin'][] = $file;
if ($method == 'create') {
JFile::copy($refadminpath . 'en-GB.' . $file . $suffix, $adminpath . $prefix . $file . $suffix);
}
} else {
if ($method == 'zip') {
JFile::copy($adminpath . $prefix . $file . $suffix, $targetfolder . DS . 'admin' . DS . $prefix . $file . $suffix);
$namea .= "\n" . ' <filename>' . $prefix . $file . $suffix . '</filename>';
}
}
}
foreach ($sitefiles as $file) {
if (!$file) {
continue;
}
if (!JFile::exists($sitepath . $prefix . $file . $suffix)) {
$missing['site'][] = $file;
if ($method == 'create') {
JFile::copy($refsitepath . 'en-GB.' . $file . $suffix, $sitepath . $prefix . $file . $suffix);
}
} else {
if ($method == 'zip') {
JFile::copy($sitepath . $prefix . $file . $suffix, $targetfolder . DS . 'site' . DS . $prefix . $file . $suffix);
$names .= "\n" . ' <filename>' . $prefix . $file . $suffix . '</filename>';
}
}
}
if ($method == 'zip') {
$mailfrom = @$params['email'] ? $params['email'] : 'emmanuel.danan@gmail.com';
$fromname = @$params['name'] ? $params['name'] : 'Emmanuel Danan';
$website = @$params['web'] ? $params['web'] : 'http://www.flexicontent.org';
// prepare the manifest of the language archive
$date = JFactory::getDate();
$xmlfile = $targetfolder . DS . 'install.xml';
$xml = '<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<install type="language" version="1.5" client="both" method="upgrade">
<name>FLEXIcontent ' . $code . '</name>
<tag>' . $code . '</tag>
<creationDate>' . (FLEXI_J16GE ? $date->format('Y-M-d', $local = true) : $date->toFormat("%Y-%m-%d")) . '</creationDate>
<author>' . $fromname . '</author>
<authorEmail>' . $mailfrom . '</authorEmail>
<authorUrl>' . $website . '</authorUrl>
<copyright>(C) ' . (FLEXI_J16GE ? $date->format('Y', $local = true) : $date->toFormat("%Y")) . ' ' . $fromname . '</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<description>' . $code . ' language pack for FLEXIcontent</description>
<administration>
<files folder="admin">' . $namea . '
</files>
</administration>
<site>
<files folder="site">' . $names . '
</files>
</site>
</install>';
// save xml manifest
JFile::write($xmlfile, $xml);
$fileslist = JFolder::files($targetfolder, '.', true, true, array('.svn', 'CVS', '.DS_Store'));
$archivename = $targetfolder . '.com_flexicontent' . (FLEXI_J16GE ? '.zip' : '.tar.gz');
// Create the archive
echo JText::_('FLEXI_SEND_LANGUAGE_CREATING_ARCHIVE') . "<br>";
if (!FLEXI_J16GE) {
JArchive::create($archivename, $fileslist, 'gz', '', $targetfolder);
} else {
$app = JFactory::getApplication('administrator');
$files = array();
foreach ($fileslist as $i => $filename) {
$files[$i] = array();
$files[$i]['name'] = preg_replace("%^(\\\\|/)%", "", str_replace($targetfolder, "", $filename));
// STRIP PATH for filename inside zip
$files[$i]['data'] = implode('', file($filename));
// READ contents into string, here we use full path
//.........这里部分代码省略.........
示例2: gantryDiagWritableDirectories
$dirsFileName = $dir . DS . "gantry-diagnostics" . DS . "directories.txt";
JFile::write($dirsFileName, gantryDiagWritableDirectories());
$archive_files[] = $dirsFileName;
$phpInfoFileName = $dir . DS . "gantry-diagnostics" . DS . "phpinfo.html";
JFile::write($phpInfoFileName, gantryDiagPHPInfo());
$archive_files[] = $phpInfoFileName;
$phpSettingsFileName = $dir . DS . "gantry-diagnostics" . DS . "phpsettings.txt";
JFile::write($phpSettingsFileName, gantryDiagPHPSettings());
$archive_files[] = $phpSettingsFileName;
$gantryObjectsFileName = $dir . DS . "gantry-diagnostics" . DS . "gantryObjects.html";
JFile::write($gantryObjectsFileName, gantryDiagGantryObjects());
$archive_files[] = $gantryObjectsFileName;
$templateParamsFile = $dir . DS . "gantry-diagnostics" . DS . "params.ini";
JFile::copy($gantry->templatePath . DS . "params.ini", $templateParamsFile);
$archive_files[] = $templateParamsFile;
JArchive::create($zipfilename, $archive_files, "gz", "", $dir);
$fullPath = $zipfilename;
if ($fd = fopen($fullPath, "r")) {
$fsize = filesize($fullPath);
$path_parts = pathinfo($fullPath);
$ext = strtolower($path_parts["extension"]);
switch ($ext) {
case "pdf":
header("Content-type: application/pdf");
// add here more headers for diff. extensions
header("Content-Disposition: attachment; filename=\"" . $path_parts["basename"] . "\"");
// use 'attachment' to force a download
break;
default:
header("Content-type: application/octet-stream");
header("Content-Disposition: filename=\"" . $path_parts["basename"] . "\"");
示例3: process_export
function process_export()
{
global $mainframe;
echo '<h1>Export Design Package</h1>';
$include_chromefiles = JRequest::getVar('include_chromefiles', true);
$include_plugins = JRequest::getVar('include_plugins', array());
$template = JRequest::getVar('template', false);
$design = JRequest::getVar('design', false);
$config =& JFactory::getConfig();
$tmp_path = $config->getValue('config.tmp_path');
$files = array();
// Include Design configuration
$files = array_merge($files, array(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'config' . DS . $design . '.xml'));
// Include Custom configurations
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'config' . DS . $design, 'xml$', false, true));
// Include Chromefiles / HTML folder
if ($include_chromefiles) {
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html', 'php$', true, true, array('index')));
}
// Include Plugins
foreach ($include_plugins as $plugin) {
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'plugins' . DS . $plugin, '', true, true));
}
// Include CSS Files
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'css' . DS . $design, 'css$', true, true));
// Include HTML Files
//$files = array_merge( $files, array(JPATH_SITE.DS.'templates'.DS.$template.DS.'html'.DS.'index'.DS.$design.'.php') );
if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'index' . DS . $design)) {
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'html' . DS . 'index' . DS . $design, 'php$', false, true));
}
// Include Image Files
if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'images' . DS . $design)) {
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'images' . DS . $design, '', true, true));
}
// Include Script Files
if (JFolder::exists(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'scripts' . DS . $design)) {
$files = array_merge($files, JFolder::files(JPATH_SITE . DS . 'templates' . DS . $template . DS . 'scripts' . DS . $design, '', true, true));
}
// Create Achrive for Download
jimport('joomla.filesystem.archive');
$ext = 'tar';
$archive = JArchive::create($tmp_path . DS . 'JYAML_DESIGN_' . $design, $files, $ext, '', JPATH_SITE . DS . 'templates' . DS . $template, true);
if ($archive) {
echo '<p class="on">' . JText::_('YAML EXPORT SUCESSFULLY') . '</p>';
echo '<p><strong><a href="../tmp/JYAML_DESIGN_' . $design . '.' . $ext . '">Download Design Package: JYAML_DESIGN_' . $design . '.' . $ext . '</a></strong></p>';
} else {
echo '<p class="off">' . JText::_('YAML EXPORT FAILD') . '</p>';
}
}
示例4: _parseRequest
function _parseRequest()
{
$folder = $this->getFolder();
$type = JRequest::getVar('type', false, 'post');
if ($type) {
$query = JRequest::getVar('query', false, 'post', 'BASE64');
$start = JRequest::getInt('start', 0);
$num = count(JFolder::files($folder, '.xml$', 1, false));
switch ($type) {
case 'clear':
$this->_db->setQuery("TRUNCATE TABLE `#__rsseo_pages`");
$this->_db->query();
$this->_db->setQuery("TRUNCATE TABLE `#__rsseo_redirects`");
$this->_db->query();
break;
case 'backup':
$buffer = '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
$buffer .= '<query>' . "\n";
$query = $this->decode($query);
if (preg_match('# (\\#__.*?) #is', $query['query'], $matches)) {
$table = trim($matches[1]);
}
$buffer .= $this->addTag('table', $table);
$this->_db->setQuery($query['query']);
$results = $this->_db->loadObjectList();
$buffer .= '<rows>' . "\n";
foreach ($results as $result) {
$buffer .= '<row>' . "\n";
foreach ($result as $key => $value) {
if (isset($query['primary']) && $key == $query['primary']) {
continue;
}
$buffer .= $this->addTag('column', $value, $key);
}
$buffer .= '</row>' . "\n";
}
$buffer .= '</rows>';
$buffer .= '</query>';
JFile::write($folder . DS . 'package' . $num . '.xml', $buffer);
break;
case 'restore':
jimport('joomla.utilities.simplexml');
$file = urldecode(JRequest::getVar('file', false, 'post', ''));
$xml = new JSimpleXML();
$xml->loadFile($file);
$root = $xml->document;
$table = $root->getElementByPath('table')->data();
$rows = $root->getElementByPath('rows')->children();
$table_fields = $name = $data = array();
$fields = $this->_db->getTableFields($table);
foreach ($fields[$table] as $field => $type) {
$table_fields[] = $this->_db->NameQuote($field);
}
foreach ($rows as $row) {
$sql = array();
$columns = $row->children();
foreach ($columns as $column) {
$properties = $column->children();
foreach ($properties as $prop) {
if ($prop->name() == 'name') {
$name[] = $this->_db->NameQuote($prop->data());
}
if ($prop->name() == 'value') {
$data[] = $this->_db->Quote($prop->data());
}
}
}
foreach ($name as $i => $val) {
if (!in_array($val, $table_fields)) {
unset($name[$i]);
unset($data[$i]);
}
}
if (!empty($name) && !empty($data)) {
$this->_db->setQuery("INSERT INTO `" . $table . "` (" . implode(',', $name) . ") VALUES (" . implode(',', $data) . "); ");
$this->_db->query();
unset($name);
unset($data);
}
}
break;
}
}
$pack = JRequest::getInt('pack', 0, 'post');
if ($pack) {
if (rsseoHelper::is16()) {
$adapter = JArchive::getAdapter('zip');
$archivefiles = array();
$xmlfiles = JFolder::files($folder, '.xml$', 1, true);
foreach ($xmlfiles as $xmlfile) {
$data = JFile::read($xmlfile);
$archivefiles[] = array('name' => JFile::getName($xmlfile), 'data' => $data);
}
$adapter->create($folder . DS . 'package.zip', $archivefiles);
} else {
JArchive::create($folder . DS . 'package.tar', JFolder::files($folder, '.xml$', 1, true), 'gz', '', $folder, true, true);
}
}
die;
}
示例5: download
//.........这里部分代码省略.........
$coupon = $db->loadObject();
if ($db->getErrorNum()) {
echo __FUNCTION__.'(): SQL QUERY ERROR:<br/>'.nl2br($db->getErrorMsg());
jexit();
}
if ($coupon) {
$slink_valid_coupon = !$coupon->has_reached_limit && !$coupon->has_expired ;
if ( !$slink_valid_coupon ) {
$query = ' DELETE FROM #__flexicontent_download_coupons WHERE id='. $coupon->id;
$db->setQuery( $query );
$db->query();
}
}
$file_node->coupon = !empty($coupon) ? $coupon : false; // NULL will not be catched by isset()
}
$tree_files = array($file_node);
}
// **************************************************
// Create and Execute SQL query to retrieve file info
// **************************************************
// Create SELECT OR JOIN / AND clauses for checking Access
$access_clauses['select'] = '';
$access_clauses['join'] = '';
$access_clauses['and'] = '';
$using_access = empty($cart_token_matches) && empty($slink_valid_coupon);
if ( $using_access ) {
// note CURRENTLY multi-download feature does not use coupons
$access_clauses = $this->_createFieldItemAccessClause( $get_select_access = true, $include_file = true );
}
// ***************************
// Get file data for all files
// ***************************
$fields_props = array();
$fields_conf = array();
$valid_files = array();
$email_recipients = array();
foreach ($tree_files as $file_node)
{
// Get file variable shortcuts (reforce being int)
$field_id = (int) $file_node->fieldid;
$content_id = (int) $file_node->contentid;
$file_id = (int) $file_node->fileid;
if ( !isset($fields_conf[$field_id]) ) {
$q = 'SELECT attribs, name, field_type FROM #__flexicontent_fields WHERE id = '.(int) $field_id;
$db->setQuery($q);
$fld = $db->loadObject();
$fields_conf[$field_id] = FLEXI_J16GE ? new JRegistry($fld->attribs) : new JParameter($fld->attribs);
$fields_props[$field_id] = $fld;
}
$field_type = $fields_props[$field_id]->field_type;
$lta = FLEXI_J16GE ? 'i' : 'ie';
$query = 'SELECT f.id, f.filename, f.filename_original, f.altname, f.secure, f.url'
. ', i.title as item_title, i.introtext as item_introtext, i.fulltext as item_fulltext, u.email as item_owner_email'
. ', i.access as item_access, '.$lta.'.language as item_language, ie.type_id as item_type_id'
示例6: jdCreateBackup
function jdCreateBackup()
{
$post = JRequest::get('post');
jimport('joomla.filesystem.archive');
jimport('joomla.filesystem.file');
$database =& JFactory::getDBO();
if (preg_match("/\\|\\[|\\]|\\{|\\}|\\+|\\-|\\(|\\)|\\~|\\`|\\!|\\@|\\%|\\^|\\&|\\*|\\.|\\,|\\/|\\?|\\<|\\>|\\;|\\:|\\'|\"|\\||_/", $post['param']['name'])) {
$this->setRedirect('index.php?option=com_jdefender&controller=restore', 'Only numerical and alphabetic characters can be in the name', 'notice');
return;
}
if (!count($post['folder']) and $post['param']['home'] != 1 and !count($post['table'])) {
$this->setRedirect('index.php?option=com_jdefender&controller=restore', 'There is nothing selected to create backup', 'notice');
return;
}
set_time_limit(0);
ignore_user_abort(true);
$jconfig = new JConfig();
$folders = array();
$path = str_replace("\\", '/', JPATH_ROOT);
foreach ($post[folder] as $element) {
$folders[] = substr(str_replace($path, '', $element), 1);
}
//print_r($folders);
if ($post['param']['name'] == '') {
$name = time() . '_noName_' . $post['param']['type'];
} else {
$name = time() . '_' . $post['param']['name'] . '_' . $post['param']['type'];
}
$home = array();
$archive = new JArchive();
if (count($post[table]) > 0) {
set_magic_quotes_runtime(0);
$tables_create = $this->jdTableCreate($post['table']);
//print "<pre>";
//print_r($tables_create);
//print "</pre>";
$fp = fopen('database_backup.sql', "w");
$comments = "/* -------JDefender Backup-------- \n";
$comments .= $post['param']['comments'];
$comments .= " */\n";
//print $comments;
fwrite($fp, $comments);
foreach ($tables_create as $table_name => $fld) {
if ($post['param']['drop'] == '1') {
fwrite($fp, "DROP TABLE IF EXISTS `{$table_name}`;/*jdSePaRaTor*/\n");
}
}
foreach ($tables_create as $table_name => $fld) {
$database->setQuery("SHOW TABLE STATUS FROM `" . $jconfig->db . "` like '" . $table_name . "'");
$auto_inc = $database->loadObjectList();
$auto_inc = number_format($auto_inc[0]->Auto_increment);
//print_r($auto_inc);
if ($post['param']['exist'] == '1') {
fwrite($fp, str_replace("CREATE TABLE", "CREATE TABLE IF NOT EXISTS", $fld));
} else {
fwrite($fp, $fld);
}
if ($post['param']['auto'] == '1') {
fwrite($fp, " AUTO_INCREMENT={$auto_inc}");
}
fwrite($fp, ";/*jdSePaRaTor*/\n");
$sql = "SELECT * FROM " . str_replace($jconfig->dbprefix, "#__", $table_name);
$database->setQuery($sql);
$result = $database->loadAssocList();
foreach ($result as $res) {
//print "<pre>";
//print_r($res);
//print "</pre>";
if (is_array($res)) {
$upper_lim = count($res);
$counter = 1;
$query = "INSERT INTO `{$table_name}` VALUES(";
foreach ($res as $field_name => $field_value) {
if ($counter == $upper_lim) {
if (is_numeric($field_value)) {
$query .= "{$field_value}";
} else {
//$field_value = ereg_replace("\r\n|\n", mysql_escape_string("\r\n"), $field_value);
$field_value = mysql_escape_string($field_value);
$field_value = " '" . str_replace('\\\'', '\'\'', $field_value) . "'";
$query .= $field_value;
}
} else {
if (is_numeric($field_value)) {
$query .= "{$field_value} , ";
} else {
//$field_value = ereg_replace("\r\n|\n", mysql_escape_string("\r\n"), $field_value);
$field_value = mysql_escape_string($field_value);
$field_value = " '" . str_replace('\\\'', '\'\'', $field_value) . "',";
$query .= $field_value;
}
$counter++;
}
}
$query .= ");/*jdSePaRaTor*/\n";
//print "</br>" . $query;
fwrite($fp, $query);
}
}
}
//.........这里部分代码省略.........