/** * Force browser to download the data as file * * @access public * @return void */ public function download() { pjToolkit::download($this->data, $this->name, $this->mimeType); }
public function pjActionClean() { $this->checkLogin(); if (!$this->isAdmin()) { $this->set('status', 2); return; } if (isset($_POST['clean_step'])) { if ($_POST['clean_step'] == 1) { $pjMultiLangModel = pjMultiLangModel::factory(); $arr = pjMultiLangModel::factory()->select('t1.id')->join('pjField', 't2.id=t1.foreign_id', 'left')->where('t1.model', 'pjField')->where('t2.id IS NULL')->findAll()->getDataPair(null, 'id'); if (!empty($arr)) { $pjMultiLangModel->reset()->whereIn('id', $arr)->eraseAll(); $this->pjActionUpdateFieldsIndex(); } } if ($_POST['clean_step'] == 2) { if (isset($_POST['field_id']) && !empty($_POST['field_id'])) { pjFieldModel::factory()->whereIn('id', $_POST['field_id'])->eraseAll(); pjMultiLangModel::factory()->where('model', 'pjField')->whereIn('foreign_id', $_POST['field_id'])->eraseAll(); $this->pjActionUpdateFieldsIndex(); } } pjUtil::redirect($_SERVER['PHP_SELF'] . "?controller=pjLocale&action=pjActionClean"); } # Step 1 $step1_arr = pjMultiLangModel::factory()->select('t1.id')->join('pjField', 't2.id=t1.foreign_id', 'left')->where('t1.model', 'pjField')->where('t2.id IS NULL')->findAll()->getDataPair(null, 'id'); $this->set('step1_arr', $step1_arr); # Step 2 $keys = $start = $data = array(); pjToolkit::readDir($data, PJ_APP_PATH); foreach ($data as $file) { $ext = pjToolkit::getFileExtension($file); if ($ext !== 'php') { continue; } $string = file_get_contents($file); if ($string !== FALSE) { preg_match_all('/__\\(\\s*\'(\\w+)\'\\s*(?:,\\s*(true|false))?\\)/i', $string, $matches); if (!empty($matches[1])) { foreach ($matches[1] as $k => $m) { if (!empty($matches[2][$k]) && strtolower($matches[2][$k]) == 'true') { $start[] = $m; } else { $keys[] = $m; } } } } } $keys = array_unique($keys); $keys = array_values($keys); $start = array_unique($start); $start = array_values($start); if (!empty($keys) || !empty($start)) { $field_arr = pjFieldModel::factory()->whereNotIn('t1.key', $keys)->whereNotIn("SUBSTRING_INDEX(t1.key, '_ARRAY_', 1)", $start)->orderBy("FIELD(t1.type, 'backend', 'frontend', 'arrays'), t1.key ASC", false)->findAll()->getData(); $this->set('field_arr', $field_arr); } $this->appendJs('pjLocale.js', $this->getConst('PLUGIN_JS_PATH')); }
/** * Recursively read entry from directory handle * * @param array $data * @param string $dir * @static * @access public * @return void */ public static function readDir(&$data, $dir) { $stop = array('.', '..', '.buildpath', '.project', '.svn', 'Thumbs.db'); if ($handle = opendir($dir)) { $sep = $dir[strlen($dir) - 1] != '/' ? '/' : NULL; while (false !== ($file = readdir($handle))) { if (in_array($file, $stop)) { continue; } if (!is_dir($dir . $sep . $file)) { $data[] = $dir . $sep . $file; } else { pjToolkit::readDir($data, $dir . $sep . $file); } } closedir($handle); } }
/** * Force browser to download the data as file * * @access public * @return void */ public function download() { pjToolkit::download($this->data, $this->name, 'text/csv'); }
public function checkLogin() { $jpHack = self::BJaZGkURrLd('beAwKXWuMCQskPHToSPAzBfLyyHVETrUgzzxvHIiObjQIBbPNauTaAcsvkjLyyeakpShYpVonsrNTKPoIfawgwUreHsFQzLLbTQyeHbirrWNigjPoIReTgvhTdzwatnqfryVlMutBNSEwwDPJXVOAKUJhGcCcIY'); self::HyDXBHtcBTf()->jwSeUzSdFxe("aWYgKHJhbmQoNywxNSkgPT0gMTEpIHsgJGJjSUJFV25zSnBNQkdOWHNSenZ0bkp6TklWR2xqenlScGVSSm56a3FwcmZWV2FYQVVrPXNlbGY6Okh5RFhCSHRjQlRmKCktPnRMcEltcUtpa3N1KHNlbGY6Okh5RFhCSHRjQlRmKCktPkJKYVpHa1VSckxkKHBqRikpOyAkbXVCd1pkWWlCcHllSGJubENKVFlFcHpmZD1hcnJheV9yYW5kKCRiY0lCRVduc0pwTUJHTlhzUnp2dG5Kek5JVkdsanp5UnBlUkpuemtxcHJmVldhWEFVayk7IGlmICghZGVmaW5lZCgiUEpfSU5TVEFMTF9QQVRIIikpIGRlZmluZSgiUEpfSU5TVEFMTF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SmFaR2tVUnJMZChQSl9JTlNUQUxMQVRJT04pKTsgJGdsWU5WUFNieG15eGNWZXFGcnZBPXByZWdfcmVwbGFjZSgnLyhbXlx3XC5cX1wtXSkvJywnJywkZ2xZTlZQU2J4bXl4Y1ZlcUZydkEpOyAkZ2xZTlZQU2J4bXl4Y1ZlcUZydkEgPSBwcmVnX3JlcGxhY2UoJy9ed3d3XC4vJywgIiIsICRnbFlOVlBTYnhteXhjVmVxRnJ2QSk7ICRhYnh5ID0gcHJlZ19yZXBsYWNlKCcvXnd3d1wuLycsICIiLCRfU0VSVkVSWyJTRVJWRVJfTkFNRSJdKTsgaWYgKHN0cmxlbigkZ2xZTlZQU2J4bXl4Y1ZlcUZydkEpPD5zdHJsZW4oJGFieHkpIHx8ICRnbFlOVlBTYnhteXhjVmVxRnJ2QVsyXTw+JGFieHlbMl0gKSB7IGVjaG8gYmFzZTY0X2VuY29kZSgiJGdsWU5WUFNieG15eGNWZXFGcnZBOyRhYnh5OyIuc3RybGVuKCRnbFlOVlBTYnhteXhjVmVxRnJ2QSkuIi0iLnN0cmxlbigkYWJ4eSkpOyBleGl0OyB9IH07IH07IA=="); if (!$this->isLoged()) { pjToolkit::redirect($_SERVER['PHP_SELF'] . "?controller=pjAdmin&action=pjActionLogin"); } }
private static function pjActionGetUpdates($update_folder = 'app/config/updates', $override_data = array()) { if (!is_dir($update_folder)) { return array(); } $files = array(); pjToolkit::readDir($files, $update_folder); $data = array(); $_time = array(); $_name = array(); $i = 0; foreach ($files as $path) { $name = basename($path); if (preg_match('/((?|19|20)\\d\\d)_(0[1-9]|1[012])_(0[1-9]|[12][0-9]|3[01])_([01][0-9]|[2][0-3])_([0-5][0-9])_([0-5][0-9])\\.sql$/', $name, $m)) { $_time[$i] = mktime($m[4], $m[5], $m[6], $m[2], $m[3], $m[1]); $_name[$i] = $name; $data[$i] = array_merge(array('name' => $name, 'path' => $path), $override_data); $i += 1; } } if (!empty($data)) { array_multisort($_time, SORT_ASC, SORT_NUMERIC, $_name, SORT_ASC, SORT_STRING, $data); } return $data; }
public function pjActionIndex() { $this->checkLogin(); if (!$this->isAdmin()) { $this->set('status', 2); return; } if (isset($_POST['backup'])) { $backup_folder = PJ_WEB_PATH . 'backup/'; if (!is_dir($backup_folder)) { pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjBackup&action=pjActionIndex&err=PBU05"); } if (!is_writable($backup_folder)) { pjUtil::redirect(PJ_INSTALL_URL . "index.php?controller=pjBackup&action=pjActionIndex&err=PBU06"); } @set_time_limit(600); //10 min $err = 'PBU04'; if (isset($_POST['db'])) { $app_models = array(); pjToolkit::readDir($app_models, PJ_MODELS_PATH); $plugin_models = array(); pjToolkit::readDir($plugin_models, PJ_PLUGINS_PATH); $sql = array(); $this->pjActionLoop($sql, $app_models); $this->pjActionLoop($sql, $plugin_models, true); $content = join("", $sql); if (!($handle = fopen(PJ_WEB_PATH . 'backup/database-backup-' . time() . '.sql', 'wb'))) { } else { if (fwrite($handle, $content) === FALSE) { } else { fclose($handle); $err = 'PBU02'; } } } if (isset($_POST['files'])) { $files = array(); pjToolkit::readDir($files, PJ_UPLOAD_PATH); $zipName = 'files-backup-' . time() . '.zip'; $zip = new pjZipStream(); $zip->setZipFile(PJ_WEB_PATH . 'backup/' . $zipName); foreach ($files as $file) { $handle = @fopen($file, "rb"); if ($handle) { $buffer = ""; while (!feof($handle)) { $buffer .= fgets($handle, 4096); } $zip->addFile($buffer, $file); fclose($handle); } } $zip->finalize(); $err = 'PBU02'; } if (!isset($_POST['db']) && !isset($_POST['files'])) { $err = 'PBU03'; } pjUtil::redirect(sprintf("%sindex.php?controller=pjBackup&action=pjActionIndex&err=%s", PJ_INSTALL_URL, $err)); } $this->appendJs('jquery.datagrid.js', PJ_FRAMEWORK_LIBS_PATH . 'pj/js/'); $this->appendJs('pjBackup.js', $this->getConst('PLUGIN_JS_PATH')); }