<commit_before><?php
	include_once('header.php');
	include_once('config.php');


	function report($tableName,$success){
		$html="<tr><td>$tableName</td><td>";
		if($success){
			$html .= '<font color="green">Success';
		}else{
			$html .= '<font color="red">Failure';
		}
		$html .= "</td></tr>\n";
		return $html;
	}
    echo "<h2>gtd-php installation/upgrade</h2>\n";

    //connect
	$connection = mysql_connect($host, $user, $pass) or die ("unable to connect");

    // get server information for problem reports
    $v="<h3>Installation Info</h3>\n";
    $v.="<ul><li>";
    $v.="php: ".phpversion()."<br>";
    $v.="</li>\n<li>";
    $v.="mysql: ".mysql_get_server_info()."</li></ul>\n";
    echo $v;


    //check if gtd db has been created
    $msg='<font color="red">Unable to select gtd database.<br>Please create the gtd mysql database and rerun this script.';
	mysql_select_db($db) or die ($msg);

    

    //check if we are doing a new install, an upgrade, or are we current
    $tprojects=0;
    $titemstatus=0;
    //echo $db;
    //checking for table itemstatus (new in 0.6)
    $tables = mysql_list_tables($db);
    while (list($temp) = mysql_fetch_array($tables)){
        //echo "<br>";
        //echo $temp;
        if($temp == 'itemstatus'){
            $titemstatus=1;
        }
        if($temp == 'projects'){
            $tprojects=1;
        }
    }
    //echo $tprojects;
    //echo $titemstatus;
    //upgrade, 0 = current, 1 = new install, 2 = upgrade
    if ($tprojects==$titemstatus){
        if($tprojects==1){
            $upgrade=0;
        }else{
            $upgrade=1;
        }
    }else{
        $upgrade=2;
    }
    echo "<br>";
    if ($upgrade==0){
        echo "<h3>No upgrade necessary.</h3>";
    }elseif($upgrade==1){
        echo "<h3>New installation.</h3>";

	$table="<table>\n";
	$table .="<tr>\n<th>Table</th>\n<th>Status</th>\n</tr>";

        //Using heredoc to create tables. last TEST cannot be indented.
	$flag=1;
        $query = <<<TEST
        CREATE TABLE `categories` (
          `categoryId` int(10) unsigned NOT NULL auto_increment,
          `category` text NOT NULL,
          `description` text,
          PRIMARY KEY  (`categoryId`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1;<commit_msg>- new msg for no upgrade path.<commit_after><?php
	include_once('header.php');
	include_once('config.php');


	function report($tableName,$success){
		$html="<tr><td>$tableName</td><td>";
		if($success){
			$html .= '<font color="green">Success';
		}else{
			$html .= '<font color="red">Failure';
		}
		$html .= "</td></tr>\n";
		return $html;
	}
    echo "<h2>gtd-php installation/upgrade</h2>\n";

    //connect
	$connection = mysql_connect($host, $user, $pass) or die ("unable to connect");

    // get server information for problem reports
    $v="<h3>Installation Info</h3>\n";
    $v.="<ul><li>";
    $v.="php: ".phpversion()."<br>";
    $v.="</li>\n<li>";
    $v.="mysql: ".mysql_get_server_info()."</li></ul>\n";
    echo $v;


    //check if gtd db has been created
    $msg='<font color="red">Unable to select gtd database.<br>Please create the gtd mysql database and rerun this script.';
	mysql_select_db($db) or die ($msg);

    

    //check if we are doing a new install, an upgrade, or are we current
    $tprojects=0;
    $titemstatus=0;
    //echo $db;
    //checking for table itemstatus (new in 0.6)
    $tables = mysql_list_tables($db);
    while (list($temp) = mysql_fetch_array($tables)){
        //echo "<br>";
        //echo $temp;
        if($temp == 'itemstatus'){
            $titemstatus=1;
        }
        if($temp == 'projects'){
            $tprojects=1;
        }
    }
    //echo $tprojects;
    //echo $titemstatus;
    //upgrade, 0 = current, 1 = new install, 2 = upgrade
    if ($tprojects==$titemstatus){
        if($tprojects==1){
            $upgrade=0;
        }else{
            $upgrade=1;
        }
    }else{
        $upgrade=2;
    }
    echo "<br>";
    if ($upgrade==0){
        echo "<h3>No database upgrade necessary.</h3>";
        $table .="<p> Just click <a href=\"index.php\">here</a> to begin using the new system.";
        echo $table;
    }elseif($upgrade==1){
        echo "<h3>New installation.</h3>";

	$table="<table>\n";
	$table .="<tr>\n<th>Table</th>\n<th>Status</th>\n</tr>";

        //Using heredoc to create tables. last TEST cannot be indented.
	$flag=1;
        $query = <<<TEST
        CREATE TABLE `categories` (
          `categoryId` int(10) unsigned NOT NULL auto_increment,
          `category` text NOT NULL,
          `description` text,
          PRIMARY KEY  (`categoryId`)
        ) ENGINE=MyISAM DEFAULT CHARSET=latin1 PACK_KEYS=1;
{'fraction_non_alphanumeric': 0.185580204778157, 'fraction_numerical': 0.011945392491467578, 'mean_word_length': 2.5149925037481258, 'pattern_counts': {'":': 0, '<': 82, '<?xml version=': 0, '>': 74, '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': '1814262', 'n_tokens_mistral': 1656, 'n_tokens_neox': 1574, 'n_words': 388}