<commit_before><?php
  
  define('ROOT', str_replace('\\', '/', dirname(__FILE__)));
    
  define('APPLICATION_PATH', ROOT . '/application');
  define('LIBRARY_PATH',     ROOT . '/library');
  define('FILES_DIR',        ROOT . '/upload'); // place where we will upload project files
  define('CACHE_DIR',        ROOT . '/cache');
  define('THEMES_DIR',       ROOT . '/public/assets/themes');
  define('PLUGINS_DIR',      APPLICATION_PATH . '/plugins');
  define('MODULES_DIR',      APPLICATION_PATH . '/modules');

  // ---------------------------------------------------
  //  Fix some $_SERVER vars (taken from wordpress code)
  // ---------------------------------------------------
  
  // Fix for IIS, which doesn't set REQUEST_URI
  if (!isset($_SERVER['REQUEST_URI']) || trim($_SERVER['REQUEST_URI']) == '') {
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
    
    // Append the query string if it exists and isn't null
    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
      $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    } // if
  } // if

  // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
  if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) {
    $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
  } // if

  // Fix for Dreamhost and other PHP as CGI hosts
  if (strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) {
    unset($_SERVER['PATH_INFO']);
  }
  
  if (trim($_SERVER['PHP_SELF']) == '') {
    $_SERVER['PHP_SELF'] = preg_replace("/(\?.*)?$/",'', $_SERVER["REQUEST_URI"]);
  }

  // ---------------------------------------------------
  //  Check if script is installed
  // ---------------------------------------------------
  
  // If script is not installed config.php will return false. Otherwise it will
  // return NULL. If we get false redirect to install folder
  if (!@include_once(ROOT . '/config/config.php')) {
    print "ProjectPier is not installed. Please redirect your browser to <b><a href=\"./". PUBLIC_FOLDER . "/install\">" . PUBLIC_FOLDER . "/install</a></b> folder and follow installation procedure";
    die();
  } // if

  // ---------------------------------------------------
  //  Init...
  // ---------------------------------------------------
//$_REQUEST['trace']='x';
//$_REQUEST['debug']='x';

  function trace($f, $l = '') {
    if (isset($_REQUEST['trace'])) {
      $i=strpos($f,'dev');
      if ($i) {
        $trace = substr($f,$i+3);
      } else {
        $trace = $f;
      }
      if ($l!='') {
        $trace .= ':' . $l;
      } 
      $trace .= "\r\n";
      file_put_contents('cache/trace.txt', $trace, FILE_APPEND);
    }
  } 
 

  include_once ROOT . '/environment/environment.php';

  // Lets prepare everything for autoloader
  require APPLICATION_PATH . '/functions.php'; // __autoload() function is defined here...
  @include ROOT . '/cache/autoloader.php';

  // Prepare logger... We might need it early...
  if (!Env::isDebugging()) {
    Logger::setSession(new Logger_Session('default'));
    Logger::setBackend(new Logger_Backend_File(CACHE_DIR . '/log.php'));
     
    set_error_handler('__production_error_handler');
    set_exception_handler('__production_exception_handler');
  } // if
  
  register_shutdown_function('__shutdown');
  trace(__FILE__,'connect to database');
  // Connect to database...
  try {
    DB::connect(DB_ADAPTER, array(
      'host'    => DB_HOST,
      'user'    => DB_USER,
      'pass'    => <PASSWORD>,
      'name'    => DB_NAME,
      'persist' => DB_PERSIST
    )); // connect
    if (defined('DB_CHARSET') && trim(DB_CHARSET)) {
      DB::execute("SET NAMES ?", DB_CHARSET);
    } // if
    DB::execute('ROLLBACK');
    DB::execute('UNLOCK TABLES');
    DB::execute('SET AUTOCOMMIT=1');
    DB::execute("SET SQL_MODE=''");
    try {
      DB::execute("SET STORAGE_ENGINE=INNODB");  // try to set to INNODB
    } catch(Exception $e) {
      // don't care if it fails
    }
    //
    //Failed to import file '/home/sharec/public_html/pp088/tmp/Riot.zip' to the file repository (unique file id: a25a6e76db0b741ec4f30d6bbae79db37024c28a)
    // DB::execute('SET SESSION max_allowed_packet=16777216');  // 16 MB
    //  Query failed with message 'SESSION variable max_allowed_packet is read-only. Use SET GLOBAL max_allowed_packet to assign the value'
    // DB::execute('SET GLOBAL max_allowed_packet=16777216');  // 16 MB
    //  Query failed with message 'Access denied; you need the SUPER privilege for this operation'
  } catch(Exception $e) {
    if (Env::isDebugging()) {
      Env::dumpError($e);
    } else {
      Logger::log($e, Logger::FATAL);
      Env::executeAction('error', 'db_connect');
    } // if<commit_msg>commit 71 added missing :<commit_after><?php
  
  define('ROOT', str_replace('\\', '/', dirname(__FILE__)));
    
  define('APPLICATION_PATH', ROOT . '/application');
  define('LIBRARY_PATH',     ROOT . '/library');
  define('FILES_DIR',        ROOT . '/upload'); // place where we will upload project files
  define('CACHE_DIR',        ROOT . '/cache');
  define('THEMES_DIR',       ROOT . '/public/assets/themes');
  define('PLUGINS_DIR',      APPLICATION_PATH . '/plugins');
  define('MODULES_DIR',      APPLICATION_PATH . '/modules');

  // ---------------------------------------------------
  //  Fix some $_SERVER vars (taken from wordpress code)
  // ---------------------------------------------------
  
  // Fix for IIS, which doesn't set REQUEST_URI
  if (!isset($_SERVER['REQUEST_URI']) || trim($_SERVER['REQUEST_URI']) == '') {
    $_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME']; // Does this work under CGI?
    
    // Append the query string if it exists and isn't null
    if (isset($_SERVER['QUERY_STRING']) && !empty($_SERVER['QUERY_STRING'])) {
      $_SERVER['REQUEST_URI'] .= '?' . $_SERVER['QUERY_STRING'];
    } // if
  } // if

  // Fix for PHP as CGI hosts that set SCRIPT_FILENAME to something ending in php.cgi for all requests
  if ( isset($_SERVER['SCRIPT_FILENAME']) && ( strpos($_SERVER['SCRIPT_FILENAME'], 'php.cgi') == strlen($_SERVER['SCRIPT_FILENAME']) - 7 ) ) {
    $_SERVER['SCRIPT_FILENAME'] = $_SERVER['PATH_TRANSLATED'];
  } // if

  // Fix for Dreamhost and other PHP as CGI hosts
  if (strstr($_SERVER['SCRIPT_NAME'], 'php.cgi')) {
    unset($_SERVER['PATH_INFO']);
  }
  
  if (trim($_SERVER['PHP_SELF']) == '') {
    $_SERVER['PHP_SELF'] = preg_replace("/(\?.*)?$/",'', $_SERVER["REQUEST_URI"]);
  }

  // ---------------------------------------------------
  //  Check if script is installed
  // ---------------------------------------------------
  
  // If script is not installed config.php will return false. Otherwise it will
  // return NULL. If we get false redirect to install folder
  if (!@include_once(ROOT . '/config/config.php')) {
    print "ProjectPier is not installed. Please redirect your browser to <b><a href=\"./". PUBLIC_FOLDER . "/install\">" . PUBLIC_FOLDER . "/install</a></b> folder and follow installation procedure";
    die();
  } // if

  // ---------------------------------------------------
  //  Init...
  // ---------------------------------------------------
//$_REQUEST['trace']='x';
//$_REQUEST['debug']='x';

  function trace($f, $l = '') {
    if (isset($_REQUEST['trace'])) {
      $i=strpos($f,'dev');
      if ($i) {
        $trace = substr($f,$i+3);
      } else {
        $trace = $f;
      }
      if ($l!='') {
        $trace .= ':' . $l;
      } 
      $trace .= "\r\n";
      file_put_contents('cache/trace.txt', $trace, FILE_APPEND);
    }
  } 
 

  include_once ROOT . '/environment/environment.php';

  // Lets prepare everything for autoloader
  require APPLICATION_PATH . '/functions.php'; // __autoload() function is defined here...
  @include ROOT . '/cache/autoloader.php';

  // Prepare logger... We might need it early...
  if (!Env::isDebugging()) {
    Logger::setSession(new Logger_Session('default'));
    Logger::setBackend(new Logger_Backend_File(CACHE_DIR . '/log.php'));
     
    set_error_handler('__production_error_handler');
    set_exception_handler('__production_exception_handler');
  } // if
  
  register_shutdown_function('__shutdown');
  trace(__FILE__,'connect to database');
  // Connect to database...
  try {
    DB::connect(DB_ADAPTER, array(
      'host'    => DB_HOST,
      'user'    => DB_USER,
      'pass'    => <PASSWORD>,
      'name'    => DB_NAME,
      'persist' => DB_PERSIST
    )); // connect
    if (defined('DB_CHARSET') && trim(DB_CHARSET)) {
      DB::execute("SET NAMES ? COLLATE ?", DB_CHARSET, 'utf8_unicode_ci');
    } // if
    DB::execute('ROLLBACK');
    DB::execute('UNLOCK TABLES');
    DB::execute('SET AUTOCOMMIT=1');
    DB::execute("SET SQL_MODE=''");
    try {
      DB::execute("SET STORAGE_ENGINE=INNODB");  // try to set to INNODB
    } catch(Exception $e) {
      // don't care if it fails
    }
    //
    //Failed to import file '/home/sharec/public_html/pp088/tmp/Riot.zip' to the file repository (unique file id: a25a6e76db0b741ec4f30d6bbae79db37024c28a)
    // DB::execute('SET SESSION max_allowed_packet=16777216');  // 16 MB
    //  Query failed with message 'SESSION variable max_allowed_packet is read-only. Use SET GLOBAL max_allowed_packet to assign the value'
    // DB::execute('SET GLOBAL max_allowed_packet=16777216');  // 16 MB
    //  Query failed with message 'Access denied; you need the SUPER privilege for this operation'
  } catch(Exception $e) {
    if (Env::isDebugging()) {
      Env::dumpError($e);
    } else {
      Logger::log($e, Logger::FATAL);
      Env::executeAction('error', 'db_connect');
    } // if
{'fraction_non_alphanumeric': 0.22684948327023433, 'fraction_numerical': 0.01012994986186432, 'mean_word_length': 2.398470097357441, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 23, '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': '1281226', 'n_tokens_mistral': 3140, 'n_tokens_neox': 2996, 'n_words': 699}