<commit_before><?php
namespace infiniloop\modules\backuprestore\controllers;

use Yii;
use yii\base\Exception;
use yii\web\Controller;
use infiniloop\modules\backuprestore\models\UploadForm;
use yii\data\ArrayDataProvider;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\web\UploadedFile;
use yii\helpers\Html;
use yii\base\ErrorException;
use ZipArchive;

class DefaultController extends Controller {

    public $menu = [];
    public $tables = [];
    public $fp;
    public $file_name;
    public $_path = null;

    //public $layout = '//layout2';

    protected function getPath() {
        if (isset($this->module->path))
            $this->_path = $this->module->path;
        else
            $this->_path = sprintf('%s/%s/', Yii::$app->basePath, $this->module->backupFolder);

        if (!file_exists($this->_path)) {
            mkdir($this->_path);
            chmod($this->_path, '777');
        }
        return $this->_path;
    }

    /**
     * Perform backup in the configured folder. Save a backup for each database configured with a name in this format:
     *      {dbKey}__backup_{db_name}_{timestamp}.zip
     * @param null $dbKey   database configuration key, otherwise uses the module's configured databases value
     * @return object
     */
    public function DoBackup($dbKey = null) {

        $response = (object)[ 'success' => false , 'message' => '', 'backupFiles' => [] ];

        if (!is_writeable($this->path)) {
            $response->message = sprintf('Path <b>%s</b> is not writeable!', $this->path);
            return $response;
        }

        $dbKeys = is_null($dbKey) ? $this->module->databases : [$dbKey];<commit_msg>Update DefaultController.php<commit_after><?php
namespace infiniloop\modules\backuprestore\controllers;

use Yii;
use yii\base\Exception;
use yii\web\Controller;
use infiniloop\modules\backuprestore\models\UploadForm;
use yii\data\ArrayDataProvider;
use yii\web\HttpException;
use yii\web\NotFoundHttpException;
use yii\web\UploadedFile;
use yii\helpers\Html;
use yii\base\ErrorException;
use ZipArchive;

class DefaultController extends Controller {

    public $menu = [];
    public $tables = [];
    public $fp;
    public $file_name;
    public $_path = null;

    //public $layout = '//layout2';

    protected function getPath() {
        if (isset($this->module->path))
            $this->_path = $this->module->path;
        else
            $this->_path = sprintf('%s/%s/', Yii::$app->basePath, $this->module->backupFolder);

        if (!file_exists($this->_path)) {
            $dirMode = 0777;
            mkdir($this->_path, $dirMode, true);
            chmod($this->_path, $dirMode);
        }
        return $this->_path;
    }

    /**
     * Perform backup in the configured folder. Save a backup for each database configured with a name in this format:
     *      {dbKey}__backup_{db_name}_{timestamp}.zip
     * @param null $dbKey   database configuration key, otherwise uses the module's configured databases value
     * @return object
     */
    public function DoBackup($dbKey = null) {

        $response = (object)[ 'success' => false , 'message' => '', 'backupFiles' => [] ];

        if (!is_writeable($this->path)) {
            $response->message = sprintf('Path <b>%s</b> is not writeable!', $this->path);
            return $response;
        }

        $dbKeys = is_null($dbKey) ? $this->module->databases : [$dbKey];
{'fraction_non_alphanumeric': 0.14414414414414414, 'fraction_numerical': 0.0026155187445510027, 'mean_word_length': 2.876126126126126, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7037676', 'n_tokens_mistral': 1046, 'n_tokens_neox': 1022, 'n_words': 248}