/** * repository::_delete() * * { Description } * */ function _delete($file) { $return = lib_delete_file($file); if ($return == '-1') { $this->_set_error('0', '1510'); } else { return; } }
function plug_upload($idclient = '0', $override = false) { global $rep, $cfg_cms, $sess, $s_upload, $db, $cms_db; if (is_array($s_upload) && $override) { $tmp_file = $s_upload; $returncode = $s_upload['returncode']; if ($sess->is_registered('s_upload')) { $sess->unregister('s_upload'); } } else { $tmp_file = lib_get_upload('plug_upload_file'); } //Es wurde keine Datei hochgeladen if (!is_array($tmp_file) || $tmp_file['error'] == '-1' || $tmp_file['error'] == '-2') { if ($tmp_file['code'] >= 1) { //if (lib_test_safemode()) return array('1801', false); if ($tmp_file['code'] == 1) { return array('0708', false); } if ($tmp_file['code'] == 2) { return array('0709', false); } if ($tmp_file['code'] == 3) { return array('0710', false); } if ($tmp_file['code'] == 4) { return array('0711', false); } } else { return array('1604', false); } } if (!($file_content = $rep->_file($tmp_file['copy']))) { lib_delete_file($tmp_file['copy']); if (lib_test_safemode()) { return array('1801', false); } else { return array('1600', false); } } require_once "Archive/Tar.php"; if (false === ($tar = new Archive_Tar($tmp_file['copy']))) { $return = '1615'; if ($tar->_error_message != '') { $error = $tar->_error_message; } return array($return, $error); } elseif ($tar == '-1') { return array('1621', false); } $tmp_plugin = $tar->listContent(); if ($tmp_plugin[0]['filename'] == '' || $tmp_plugin[0]['typeflag'] != 5) { return array('1604', false); } $name = substr($tmp_plugin[0]['filename'], -1) == '/' ? substr($tmp_plugin[0]['filename'], 0, -1) : $tmp_plugin[0]['filename']; $tmp_cmsplug = $tar->extractInString($name . '/' . $name . '.cmsplug'); //todo: 2remove if (empty($tmp_cmsplug)) { $tmp_cmsplug = $tar->extractInString($name . '/' . $name . '.dediplug'); } list($idplug, $xml_array) = $rep->plug_import($tmp_cmsplug, $idclient, $override); if ($idplug == '-1' || $idplug == '-2') { $s_upload = $tmp_file; $s_upload['returncode'] = $idplug; $s_upload['plugversion'] = $xml_array['version']; $s_upload['plugname'] = $xml_array['name']; list($type, $rid, $uid) = explode(":", $xml_array['repository_id']); $s_upload['plugrepid'] = $type . ':' . $rid; $sess->register('s_upload'); return array('1617', false); } elseif ($idplug == '-3') { $s_upload = $tmp_file; $s_upload['returncode'] = $idplug; $s_upload['plugversion'] = $xml_array['version']; $s_upload['plugname'] = $xml_array['name']; list($type, $rid, $uid) = explode(":", $xml_array['repository_id']); $s_upload['plugrepid'] = $type . ':' . $rid; $sess->register('s_upload'); return array('1619', false); } elseif ($idplug == '-4') { lib_delete_file($tmp_file['copy']); return array('1603', false); } elseif (!$idplug || !is_array($xml_array)) { lib_delete_file($tmp_file['copy']); return array('1600', false); } if (!$tar->extract($cfg_cms['cms_path'] . 'plugins/')) { // check error if ($tar->_error_message != '') { $error = $tar->_error_message; } // force delete the plugin plug_delete($idplug, $idclient); return array('1615', $error); } // get the new Plugin data $plugin = $rep->plug_data($idplug, $idclient); // Event fire_event('plug_upload', array('idplug' => $idplug, 'name' => $plugin['name'])); if ($override && $returncode == '-1' || $returncode == '-2') { if ((bool) $plugin['is_install']) { $rep->plug_execute($idplug, 'update', '', 'meta'); if ((bool) $rep->plug_execute($idplug, 'multi_client') && $idclient == '0') { global $client; $sql = "SELECT idclient from " . $cms_db['plug'] . " WHERE source_id='{$idplug}' AND is_install='1'"; $db->query($sql); while ($db->next_record()) { $client = $db->f('idclient'); $rep->plug_execute($idplug, 'update', 'client', 'meta'); // Event fire_event('plug_update_client', array('idplug' => $idplug, 'name' => $plugin['name'])); } } } // Event fire_event('plug_update', array('idplug' => $idplug, 'name' => $plugin['name'])); } elseif ($override && $returncode == '-3') { if ((bool) $plugin['is_install']) { $_recurse = array(); global $client; if ((bool) $rep->plug_execute($idplug, 'multi_client') && $idclient == '0') { $sql = "SELECT idclient from " . $cms_db['plug'] . " WHERE source_id='{$idplug}' AND is_install='1'"; $db->query($sql); while ($db->next_record()) { array_push($_recurse, $db->f('idclient')); // Event fire_event('plug_reinstall_client', array('idplug' => $idplug, 'name' => $plugin['name'])); } } reset($_recurse); foreach ($_recurse as $_k => $_v) { $client = $_v; $rep->plug_execute($idplug, 'uninstall', 'client', 'meta'); } $rep->plug_execute($idplug, 'uninstall', '', 'meta'); $rep->plug_execute($idplug, 'install', '', 'meta'); foreach ($_recurse as $_k => $_v) { $client = $_v; $rep->plug_execute($idplug, 'install', 'client', 'meta'); } } // Event fire_event('plug_reinstall', array('idplug' => $idplug, 'name' => $plugin['name'])); } lib_delete_file($tmp_file['copy']); return array('1612', false); }
function mod_upload($idclient, $override = false, $module = array(NULL), $cmodule = array(NULL), $smodule = array(NULL), $rmodule = array(NULL)) { global $cfg_cms, $db, $cms_db, $rep, $perm, $auth, $sess, $s_upload; if (is_array($s_upload)) { $tmp_file = $s_upload; $returncode = $s_upload['returncode']; if ($sess->is_registered('s_upload')) { $sess->unregister('s_upload'); } } else { $tmp_file = lib_get_upload('mod_upload_file'); } // Es wurde keine Datei hochgeladen if (!is_array($tmp_file) || $tmp_file['error'] == '-1' || $tmp_file['error'] == '-2') { if ($tmp_file['code'] >= 1) { //if (lib_test_safemode()) return array('1801', false); if ($tmp_file['code'] == 1) { return array('0708', false); } if ($tmp_file['code'] == 2) { return array('0709', false); } if ($tmp_file['code'] == 3) { return array('0710', false); } if ($tmp_file['code'] == 4) { return array('0711', false); } } else { return array('0404', false); } } if (($filecontent = $rep->_file($tmp_file['copy'])) == '') { lib_delete_file($tmp_file['copy']); if (lib_test_safemode()) { return '1801'; } else { return '0400'; } } $filecontent = utf8_encode($filecontent); //todo:remove this hack list($idmod, $xml_array) = $rep->mod_import($filecontent, $idclient, $override, $module, $cmodule, $smodule, $rmodule); if ($idmod == '-1' || $idmod == '-2' || $idmod == '-3') { $s_upload = $tmp_file; $s_upload['returncode'] = $idmod; $s_upload['modversion'] = $xml_array['version']; $s_upload['modname'] = $xml_array['name']; list($type, $rid, $uid) = explode(":", $xml_array['repository_id']); $s_upload['modrepid'] = $type . ':' . $rid; $sess->register('s_upload'); if ($idmod == '-3') { return '0419'; } else { return '0417'; } } elseif ($idmod == '-4') { if ($sess->is_registered('s_update')) { $sess->unregister('s_update'); } return '0420'; } elseif ($idmod == '-5') { if ($sess->is_registered('s_update')) { $sess->unregister('s_update'); } return '0421'; } elseif ($idmod == '-6') { if ($sess->is_registered('s_update')) { $sess->unregister('s_update'); } return '0422'; } elseif ($idmod == '-7') { lib_delete_file($tmp_file['copy']); return '0403'; } elseif (!$idmod || !is_array($xml_array)) { lib_delete_file($tmp_file['copy']); return '0400'; } $modul = $rep->mod_data($idmod, $idclient); if ($modul['repository_id']) { $repcount = $rep->mod_count("{$idclient}", $modul['repository_id'], true); } if ($modul['install_sql'] != '' && $idclient >= 1 && $repcount < 1) { $error = $rep->bulk_sql($modul['install_sql']); fire_event('mod_install_sql', array('idmod' => $idmod, 'name' => $modul['name'])); $return = '0409'; } else { $return = '0408'; } lib_delete_file($tmp_file['copy']); // Event fire_event('mod_upload', array('idmod' => $idmod, 'name' => $modul['name'])); return $return; }
function lib_remove_dir($dir) { @chmod($dir, 0777); if (lib_check_dir($dir)) { if (($handle = @opendir($dir)) != false) { while (($filename = @readdir($handle)) != false) { if ($filename == "." || $filename == "..") { continue; } else { clearstatcache(); if (@is_file($dir . "/" . $filename)) { if (lib_delete_file($dir . "/" . $filename) == '-1') { return '-1'; } } else { clearstatcache(); if (@is_dir($dir . "/" . $filename)) { if (lib_remove_dir($dir . "/" . $filename) == '-1') { return '-1'; } } } } } closedir($handle); @rmdir($dir); } } elseif (lib_check_file($dir)) { return lib_delete_dir($dir); } clearstatcache(); if (@is_dir($dir)) { return '-1'; } }