<commit_before><?php
# This may take a while depending on the system
set_time_limit(500);

# Define some directory/file variables
$frameworkdir   = dirname(__FILE__).'/framework/';
$frameworkzip   = $frameworkdir.'yii.zip';
$installed      = is_file($frameworkdir."yii-master/framework/yiic.php");
$error_msg      = "";

if(isset($_REQUEST["upgrade"])) {

    # function to extract the framework from the Yii zip file
    function extractZip($zipfile,$frameworkdir)
    {
        global $frameworkzip, $frameworkdir;
        
        if(file_exists($zipfile)) {
            $zip = new ZipArchive;
            $files = array();
            if($zip->open($zipfile) === TRUE) {
                for($i = 0; $i < $zip->numFiles; $i++) {
                    $entry = $zip->getNameIndex($i);
                    # Use strpos() to check if the entry name contains the directory we want to extract
                    if (strcmp(substr($entry, 0, strlen("yii-master/framework/")),"yii-master/framework/")==0) {
                        # Add the entry to our array if it is in our desired directory
                        $files[] = $entry;
                    }
                }
                # Feed $files array to extractTo() to get only the files we want
                $success = $zip->extractTo($frameworkdir, $files);
                $zip->close();
                return $success;
            }
        }
        
        return false;
    }
    
    # Encapsulate upgrade in a function call
    function upgradeYii() 
    {
        global $frameworkzip, $frameworkdir;
        
        # Not all Apache instances use .htaccess
        $htaccess = dirname(__FILE__)."/.htaccess";
        $contents = file_get_contents($htaccess);
        $apploc = str_replace("yii-update.php","",$_SERVER["SCRIPT_NAME"]);
        
        # If maintenance mode exists in .htaccess then don't re-add
        if(!stristr($contents,"#maintenance-mode")) {
            $contents .= "\n\n";
            $contents .= "#maintenance-mode\n";
            $contents .= "Redirect 301 ".$apploc."index.php ".$apploc."maintenance.php";
            file_put_contents($htaccess,$contents);
        }
    
        # Check conditions for downloading new Yii framework zip
        if(!file_exists($frameworkzip) or isset($_REQUEST["force-download"]) or (file_exists($frameworkzip) and filemtime($frameworkzip) < strtotime("-1 day"))) {
            # Re-download latest Yii version
            unlink($frameworkzip);
            file_put_contents($frameworkzip, fopen("http://github.com/yiisoft/yii/archive/master.zip","r"));
        }
        
        if(extractZip($frameworkzip,$frameworkdir)) {
            $contents = substr($contents,0,strpos($contents,"\n\n#maintenance-mode"));
            file_put_contents($htaccess,$contents);
            return true;
        }
        
        # If we get here then we weren't supposed to
        return false;
    }

    # Perform the actual function call
    $status = upgradeYii();
    
    # Check status and redirect
    if($status === TRUE and !isset($_REQUEST["remote"])) {
        header("Location: index.php?".(($installed===TRUE)?"upgrade":"install")."=true");
        exit;
    }
    else {
        $error_msg = "Could not upgrade Yii. Please check the code or contact an administrator.";
    }
}
?>


<?php
# Theme name from Jquery UI themes
$theme = "bluebird";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />

    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />

    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <link rel="stylesheet" type="text/css" href="css/form.css" />
    <link rel="stylesheet" type="text/css" href="css/table.css" />

    <title>Yii Framework <?php echo ($installed===TRUE) ? "Upgrade" : "Install"; ?></title>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script><commit_msg>Creates a Framework directory if it doesn't exist<commit_after><?php
# This may take a while depending on the system
set_time_limit(500);

# Define some directory/file variables
$frameworkdir   = dirname(__FILE__).'/framework/';
$frameworkzip   = $frameworkdir.'yii.zip';
$installed      = is_file($frameworkdir."yii-master/framework/yiic.php");
$error_msg      = "";

# Make the directory if it doesn't exist
if(!is_dir($frameworkdir)) {
    mkdir($frameworkdir);
}

# Someone pressed the install/upgrade button
if(isset($_REQUEST["upgrade"])) {

    # function to extract the framework from the Yii zip file
    function extractZip($zipfile,$frameworkdir)
    {
        global $frameworkzip, $frameworkdir;
        
        # If we have the yii framework zip file lets unpack it!
        if(file_exists($zipfile)) {
            
            $zip = new ZipArchive;
            $files = array();
            
            # Open the zip file for extraction
            if($zip->open($zipfile) === TRUE) {
                # Let's iterate through the files and only pull out the ones in the "framework" directory
                # There are other folders which are not used by the system, such as "demos" and "requirements"
                for($i = 0; $i < $zip->numFiles; $i++) {
                    $entry = $zip->getNameIndex($i);
                    if (strcmp(substr($entry, 0, strlen("yii-master/framework/")),"yii-master/framework/")==0) {
                        $files[] = $entry;
                    }
                }
                # Feed $files array to extractTo() to get only the files we want
                $success = $zip->extractTo($frameworkdir, $files);
                $zip->close();
                
                # Return the status of the extraction (true or false)
                return $success;
            }
        }
        # If we got to here, something went wrong so return false
        return false;
    }
    
    # Encapsulate upgrade in a function call
    function upgradeYii() 
    {
        global $frameworkzip, $frameworkdir;
        
        # Not all Apache instances use .htaccess
        $htaccess = dirname(__FILE__)."/.htaccess";
        $contents = file_get_contents($htaccess);
        $apploc = str_replace("yii-update.php","",$_SERVER["SCRIPT_NAME"]);
        
        # If maintenance mode exists in .htaccess then don't re-add
        if(!stristr($contents,"#maintenance-mode")) {
            $contents .= "\n\n";
            $contents .= "#maintenance-mode\n";
            $contents .= "Redirect 301 ".$apploc."index.php ".$apploc."maintenance.php";
            file_put_contents($htaccess,$contents);
        }
    
        # Check conditions for downloading new Yii framework zip
        if(!file_exists($frameworkzip) or isset($_REQUEST["force-download"]) or (file_exists($frameworkzip) and filemtime($frameworkzip) < strtotime("-1 day"))) {
            # Re-download latest Yii version
            unlink($frameworkzip);
            file_put_contents($frameworkzip, fopen("http://github.com/yiisoft/yii/archive/master.zip","r"));
        }
        
        if(extractZip($frameworkzip,$frameworkdir)) {
            $contents = substr($contents,0,strpos($contents,"\n\n#maintenance-mode"));
            file_put_contents($htaccess,$contents);
            return true;
        }
        
        # If we get here then we weren't supposed to
        return false;
    }

    # Perform the actual function call
    $status = upgradeYii();
    
    # Check status and redirect
    if($status === TRUE) {
        header("Location: index.php?".(($installed===TRUE)?"upgrade":"install")."=true");
        exit;
    }
    else {
        # Error message for not completing an install/upgrade
        $error_msg = "Could not upgrade Yii. Please check the code or contact an administrator.";
    }
}
?>


<?php
# Theme name from Jquery UI themes
$theme = "bluebird";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="language" content="en" />

    <!-- blueprint CSS framework -->
    <link rel="stylesheet" type="text/css" href="css/screen.css" media="screen, projection" />
    <link rel="stylesheet" type="text/css" href="css/print.css" media="print" />

    <link rel="stylesheet" type="text/css" href="css/main.css" />
    <link rel="stylesheet" type="text/css" href="css/form.css" />
    <link rel="stylesheet" type="text/css" href="css/table.css" />

    <title>Yii Framework <?php echo ($installed===TRUE) ? "Upgrade" : "Install"; ?></title>

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js" type="text/javascript"></script>
{'fraction_non_alphanumeric': 0.14640252530749973, 'fraction_numerical': 0.005877870904539022, 'mean_word_length': 2.4322002241314906, 'pattern_counts': {'":': 2, '<': 43, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 4}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 7, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5646884', 'n_tokens_mistral': 2755, 'n_tokens_neox': 2613, 'n_words': 643}