<commit_before><?php


// This file is generated by Composer
require_once dirname(__FILE__) . '/../vendor/autoload.php';

class SystemService {

  function getLatestRelese() {
    $client = new \Github\Client();
    $release = null;
    try {
      $release = $client->api('repo')->releases()->latest('churchcrm', 'crm');
    } catch (Exception $e) {

    }

    return $release;
  }

  function getInstalledVersion() {
    $composerFile = file_get_contents(dirname(__FILE__)."/../composer.json");
    $composerJson = json_decode($composerFile, true);
    $version = $composerJson["version"];

    return $version;
  }

  function playbackSQLtoDatabase($fileName) {
    requireUserGroupMembership("bAdmin");
    $query = '';
    $restoreQueries = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    foreach ($restoreQueries as $line) {
      if ($line != '' && strpos($line, '--') === false) {
        $query .= " $line";
        if (substr($query, -1) == ';') {
          $person = RunQuery($query);
          $query = '';
        }
      }
    }
  }

  function restoreDatabaseFromBackup() {
    requireUserGroupMembership("bAdmin");
    $restoreResult = new StdClass();
    global $sUSER, $sPASSWORD, $sDATABASE, $cnInfoCentral, $sGZIPname;
    $file = $_FILES['restoreFile'];
    $restoreResult->file = $file;
    $restoreResult->type = pathinfo($file['name'], PATHINFO_EXTENSION);
    $restoreResult->type2 = pathinfo(substr($file['name'], 0, strlen($file['name']) - 3), PATHINFO_EXTENSION);
    $restoreResult->root = dirname(dirname(__FILE__));
    $restoreResult->backupRoot = "$restoreResult->root/tmp_attach/ChurchCRMBackups";
    $restoreResult->imagesRoot = "Images";
    $restoreResult->headers = array();
    // Delete any old backup files
    exec("rm -rf  $restoreResult->backupRoot");
    exec("mkdir  $restoreResult->backupRoot");
    if ($restoreResult->type == "gz") {
      if ($restoreResult->type2 == "tar") {
        exec("mkdir $restoreResult->backupRoot");
        $restoreResult->uncompressCommand = "tar -zxvf " . $file['tmp_name'] . " --directory $restoreResult->backupRoot";
        exec($restoreResult->uncompressCommand, $rs1, $returnStatus);
        $restoreResult->SQLfile = "$restoreResult->backupRoot/ChurchCRM-Database.sql";
        $this->playbackSQLtoDatabase($restoreResult->SQLfile);
        exec("rm -rf $restoreResult->root/Images/*");
        exec("mv -f $restoreResult->backupRoot/Images/* $restoreResult->root/Images");
      }
      else if ($restoreResult->type2 == "sql") {
        exec("mkdir $restoreResult->backupRoot");
        exec("mv  " . $file['tmp_name'] . " " . $restoreResult->backupRoot . "/" . $file['name']);
        $restoreResult->uncompressCommand = "sGZIPname -d $restoreResult->backupRoot/" . $file['name'];
        exec($restoreResult->uncompressCommand, $rs1, $returnStatus); ;
        $restoreResult->SQLfile = $restoreResult->backupRoot . "/" . substr($file['name'], 0, strlen($file['name']) - 3);
        $this->playbackSQLtoDatabase($restoreResult->SQLfile);
      }
    }
    else if ($restoreResult->type == "sql") {
      $this->playbackSQLtoDatabase($file['tmp_name']);
    }
    exec("rm -rf $restoreResult->backupRoot");
    $restoreResult->UpgradeStatus = $this->checkDatabaseVersion();
    $this->rebuildWithSQL("/mysql/upgrade/rebuild_nav_menus.sql");<commit_msg>underp gzip<commit_after><?php


// This file is generated by Composer
require_once dirname(__FILE__) . '/../vendor/autoload.php';

class SystemService {

  function getLatestRelese() {
    $client = new \Github\Client();
    $release = null;
    try {
      $release = $client->api('repo')->releases()->latest('churchcrm', 'crm');
    } catch (Exception $e) {

    }

    return $release;
  }

  function getInstalledVersion() {
    $composerFile = file_get_contents(dirname(__FILE__)."/../composer.json");
    $composerJson = json_decode($composerFile, true);
    $version = $composerJson["version"];

    return $version;
  }

  function playbackSQLtoDatabase($fileName) {
    requireUserGroupMembership("bAdmin");
    $query = '';
    $restoreQueries = file($fileName, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
    foreach ($restoreQueries as $line) {
      if ($line != '' && strpos($line, '--') === false) {
        $query .= " $line";
        if (substr($query, -1) == ';') {
          $person = RunQuery($query);
          $query = '';
        }
      }
    }
  }

  function restoreDatabaseFromBackup() {
    requireUserGroupMembership("bAdmin");
    $restoreResult = new StdClass();
    global $sUSER, $sPASSWORD, $sDATABASE, $cnInfoCentral, $sGZIPname;
    $file = $_FILES['restoreFile'];
    $restoreResult->file = $file;
    $restoreResult->type = pathinfo($file['name'], PATHINFO_EXTENSION);
    $restoreResult->type2 = pathinfo(substr($file['name'], 0, strlen($file['name']) - 3), PATHINFO_EXTENSION);
    $restoreResult->root = dirname(dirname(__FILE__));
    $restoreResult->backupRoot = "$restoreResult->root/tmp_attach/ChurchCRMBackups";
    $restoreResult->imagesRoot = "Images";
    $restoreResult->headers = array();
    // Delete any old backup files
    exec("rm -rf  $restoreResult->backupRoot");
    exec("mkdir  $restoreResult->backupRoot");
    if ($restoreResult->type == "gz") {
      if ($restoreResult->type2 == "tar") {
        exec("mkdir $restoreResult->backupRoot");
        $restoreResult->uncompressCommand = "tar -zxvf " . $file['tmp_name'] . " --directory $restoreResult->backupRoot";
        exec($restoreResult->uncompressCommand, $rs1, $returnStatus);
        $restoreResult->SQLfile = "$restoreResult->backupRoot/ChurchCRM-Database.sql";
        $this->playbackSQLtoDatabase($restoreResult->SQLfile);
        exec("rm -rf $restoreResult->root/Images/*");
        exec("mv -f $restoreResult->backupRoot/Images/* $restoreResult->root/Images");
      }
      else if ($restoreResult->type2 == "sql") {
        exec("mkdir $restoreResult->backupRoot");
        exec("mv  " . $file['tmp_name'] . " " . $restoreResult->backupRoot . "/" . $file['name']);
        $restoreResult->uncompressCommand = "$sGZIPname -d $restoreResult->backupRoot/" . $file['name'];
        exec($restoreResult->uncompressCommand, $rs1, $returnStatus); ;
        $restoreResult->SQLfile = $restoreResult->backupRoot . "/" . substr($file['name'], 0, strlen($file['name']) - 3);
        $this->playbackSQLtoDatabase($restoreResult->SQLfile);
      }
    }
    else if ($restoreResult->type == "sql") {
      $this->playbackSQLtoDatabase($file['tmp_name']);
    }
    exec("rm -rf $restoreResult->backupRoot");
    $restoreResult->UpgradeStatus = $this->checkDatabaseVersion();
    $this->rebuildWithSQL("/mysql/upgrade/rebuild_nav_menus.sql");
{'fraction_non_alphanumeric': 0.17685557042986763, 'fraction_numerical': 0.0029748624126134165, 'mean_word_length': 3.624484181568088, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 87, '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': '6861811', 'n_tokens_mistral': 2096, 'n_tokens_neox': 2049, 'n_words': 338}