Exemplo n.º 1
0
 /**
  * USED INTERNALLY. Check content file to see if it exists. And if it doesn't, create it. $path contains the file path, $default contains the default text to go in the file if it is new.
  * @param string $name Content area name.
  */
 function ContentCheck($path, $name)
 {
     // If file doesn't exist yet or is of 0 length, create and write something in it.
     if (!file_exists($path) || !filesize($path)) {
         $fh = fopen($path, 'w') or die(NCUtility::Error("Could not write file: " . basename($path) . ". Make sure that this server has read and write permissions to the /nc-cms/content folder."));
         fwrite($fh, $default) or die(NCUtility::Error("Could not write file: " . basename($path) . ". Make sure that this server has read and write permissions to the /nc-cms/content folder."));
         fclose($fh);
     }
     clearstatcache();
     // Clear status cache (so filesize() will do its work again)
 }
Exemplo n.º 2
0
    }
    if ($nc_db_link) {
        mysql_close($nc_db_link);
    }
    // Close connection.
    // Refresh page if no errors were reported.
    if ($output == "") {
        $location = NC_CMS_URL . '/' . basename(__FILE__);
        // Load default installer page.
        header('Location: ' . $location);
    }
} else {
    $output .= '<p>Welcome to the nc-cms MySQL database setup. This script will install the appropriate database tables for use with nc-cms.</p>';
    if ($nc_db_fail) {
        if ($nc_report_error != "") {
            $output .= NCUtility::Error($nc_report_error);
        }
        if ($nc_report_tip != "") {
            $output .= NCUtility::Tip($nc_report_tip);
        }
        $output .= '<p>You may delete this file if you do not plan to use nc-cms\'s database support.</p>';
    } else {
        if ($nc_already_setup) {
            $output .= '<h2><strong>Database Setup Complete!</strong></h2> <p>The required nc-cms tables have already been setup in your database. You may now delete this file if you wish.</p>';
        } else {
            $output .= '<p style="width: 200px; margin: 0 auto; text-align: center;"><span class="button"><a href="?action=install" ><span class="icon icon_setup_database" > Setup MySQL Database</span></a></span></p><br />';
            $output .= '<p>You may delete this file if you do not plan to use nc-cms\'s database support.</p>';
        }
    }
}
?>
Exemplo n.º 3
0
 /**
  * USED INTERNALLY. Checks the validity of the mysql link. Selects the database. Returns the db link, presents any errors if any are found.
  * @param string $name Content area name.
  */
 function DatabaseLink($link, $_database)
 {
     if ($link) {
         if (mysql_select_db($_database, $link)) {
             return $link;
         } else {
             NCUtility::Error("MySQL reported: " . mysql_error());
             exit;
         }
     } else {
         NCUtility::Error("MySQL reported: " . mysql_error());
         exit;
     }
 }
Exemplo n.º 4
0
 /** 
  * Special display function for errors.
  * @param string $message Error message.
  * @param boolean $return True = Return formatted message. False = Echo formatted message.
  * @return string Formatted error message.
  */
 static function Error($message, $return = false)
 {
     NCUtility::Error($message, $return);
 }