php - Codeigniter 项目社交点火器

标签 php mysql codeigniter installation social-networking

尝试在xampp服务器上安装socialigniter,它是codeigniter社交网络项目。但是当我开始安装并打开 localhost/socialigniter/install.php 时出现此错误?我不知道这是什么错误,只是页面上的这段文字

{"status":"success","message":"Created files & folders","data":{"base_url":"","hostname":"","username":"","password":"","database":""}}

这是一个install.php页面源

    <?php

// Config File Constants
define('CONFIG_PATH', './application/config/config.php');
define('DATABASE_PATH', './application/config/database.php');
define('ROUTES_PATH', "./application/config/routes.php");
define('SOCIAL_IGNITER_PATH', './application/config/social_igniter.php');

// Proceed with DB Setup?
$proceedWithSetup = isset($_POST["hostname"]);

if ($proceedWithSetup) {

    // Database
    // We should probably clean these, as they could in theory come from anywhere on the web
    $hostname = $_POST["hostname"];
    $username   = $_POST["username"];
    $password   = $_POST["password"];
    $database_name = $_POST["database"];

    // Before we change any files, we should try connecting to the db using the given credentials
    try {
        $db = new PDO('mysql:host=' . $hostname . ';dbname=' . $database_name, $username, $password, array(
            PDO::ATTR_PERSISTENT => true,
            PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8",
            PDO::ATTR_TIMEOUT => 10));
    }
    catch (PDOException $e) {
        // If it went wrong: complain
        header('HTTP/1.0 500 Server Error'); // TODO: Check if this works across most PHP platforms
        echo $e -> getMessage();
        exit;
    }

    // If all's good: woo! Edit the config files
    $database_file = file_get_contents("./application/config/database.php", FILE_USE_INCLUDE_PATH);
    $database_file = str_replace("{INSTALL_DB_HOSTNAME}", $hostname, $database_file);
    $database_file = str_replace("{INSTALL_DB_USERNAME}", $username, $database_file);
    $database_file = str_replace("{INSTALL_DB_PASSWORD}", $password, $database_file);
    $database_file = str_replace("{INSTALL_DB_DATABASE}", $database_name, $database_file);
    file_put_contents(DATABASE_PATH, $database_file);

    // Config
    $config_file    = "./application/config/config.php";
    $encryption_key = sha1(microtime(true).mt_rand(10000,90000));
    $config_current = file_get_contents($config_file, FILE_USE_INCLUDE_PATH);
    $config_current = str_replace("{INSTALL_BASE_URL}", $_POST["base_url"], $config_current);
    $config_current = str_replace("{INSTALL_ENCRYPTION_KEY}", $encryption_key, $config_current);
    file_put_contents(CONFIG_PATH, $config_current);

    // Make Files
    copy("./application/config/routes.php", ROUTES_PATH);
    copy("./application/config/social_igniter.php", SOCIAL_IGNITER_PATH);

    echo json_encode(
        array(
            'status' => 'success',
            'message' => 'Created files & folders',
            'data' => $_POST
        )
    );

} else {
    // Write HTML for setup Forms etc
?>
<!DOCTYPE html>  
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>Install Social-Igniter</title>
    <link rel="stylesheet" type="text/css" href="/css/install.css" />
    <script type="text/javascript" src="/js/jquery.js"></script>
    <script type="text/javascript" src="/js/social.core.js"></script>
    <script type="text/javascript" src="/js/installer/setup.js"></script>
</head>
<body>
<div id="container">
    <div class="content norm_top"></div>    
    <div class="content norm_mid">  
        <div id="welcome" class="content_wrap">
            <img id="logo" src="images/si_logo.png">
            <h1>Install Social-Igniter</h1>
            <p>Welcome and thanks for downloading Social-Igniter, you have taken the first step to setting up your own little corner on the web. Great job!</p>
            <p>Next, we need you to tell us a few things before your site will work properly.</p>
            <div class="clear"></div>
        </div>
        <div class="norm_separator"></div>
        <div class="content_wrap">
        <?php
                // Check all the files we want to write are writable
                $all_writable = true;
                $errors = '<ul>';
                if (!is_writable(CONFIG_PATH))
                {
                    $all_writable = false;
                    $errors .= '<li><code>' . CONFIG_PATH . '</code></li>';
                }
                if (!is_writable(DATABASE_PATH))
                {
                    $all_writable = false;
                    $errors .= '<li><code>' . DATABASE_PATH . '</code></li>';
                }
                if (!is_writable(ROUTES_PATH))
                {
                    $all_writable = false;
                    $errors .= '<li><code>' . ROUTES_PATH . '</code></li>';
                }
                if (!is_writable(SOCIAL_IGNITER_PATH))
                {
                    $all_writable = false;
                    $errors .= '<li><code>' . SOCIAL_IGNITER_PATH . '</code></li>';
                }
                $errors .= '</ul>';

                if (!$all_writable)
                {
                    // Echo error messages
                    echo '<div class="warning"><strong>Oops! SocialIgniter can\'t install itself because it can\'t update some config files.</strong><p>To fix this, the following files must be made writable by PHP or your web server:</p>';

                    echo $errors;

                    echo '<p>The <a href="http://codex.wordpress.org/Changing_File_Permissions">WordPress Codex has a good page on permissions</a>. If you need more help, ask your sysadmin or get in contact with the <a href="https://github.com/socialigniter/socialigniter/">SocialIgniter Developers</a></p><p>Once you\'ve fixed this, try refreshing this page.</p></div>';
                }
                else
                {               
            ?>
            <!-- step 1 -->
            <div id="step_1" class="hide">
            <form name="install_step_1" id="install_step_1" method="POST">
                <h2>Site URL</h2>
                <p><label>Of your website: <input type="text" name="base_url" id="base_url" placeholder="http://example.com/"></label></p>

                <h2>Database Settings</h2>

                <p>If you're on shared hosting, your provider should have sent you MySQL database credentials -- if not, contact them and ask for hostname, username, password and database name required to connect.</p>

                <div id="warning-container"></div>

                <ol>
                    <li><label>The hostname of your database server: <input type="text" id="db_hostname" placeholder="localhost" name="hostname"></label></li>
                    <li><label>The username used to connect to the database: <input type="text" id="db_username" placeholder="root" name="username"></label></li>
                    <li><label>The password used to connect to the database: <input type="password" id="db_password" placeholder="" name="password"></label></li>
                    <li><label>The name of the database you want to connect to: <input type="text" id="db_database" placeholder="social-igniter" name="database"></label></li>
                    <li><button type="submit" id="install_step_1_submit">Create Database tables and Continue</button></li>
                </ol>
            </form>
            </div>
            <!-- step 2 -->
            <div id="step_2" class="hide">
                <h2 id="step_2_title">Creating Database...</h2>     
            </div>
            <!-- step 3 -->
            <div id="step_3" class="hide">
            <form name="install_step_3" id="install_step_3" method="POST">
                <h2>Your Information</h2>
                <p>Enter information for who will be owning or controlling this website</p>
                <table border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td>Name</td>
                      <td>
                        <input type="text" name="name" id="signup_name" placeholder="Joe Smith" value="">
                        <span id="signup_name_error"></span>
                      </td>
                    </tr>
                    <tr>
                      <td>Email</td>
                      <td>
                        <input type="text" name="email" id="signup_email" placeholder="your@email.com" value="">
                        <span id="signup_email_error"></span>
                      </td>
                    </tr>
                    <tr>  
                      <td>Password</td>
                      <td>
                        <input type="password" name="password" id="signup_password" placeholder="********" value="">
                        <span id="signup_password_error"></span>
                      </td>
                    </tr>
                    <tr>  
                      <td>Confirm Password</td>
                      <td>
                        <input type="password" name="password_confirm" id="signup_password_confirm" placeholder="********" value="">
                        <span id="signup_password_confirm_error"></span> 
                      </td>
                    </tr>
                    <tr> 
                      <td colspan="2"><input type="submit" name="submit" value="Signup"></td>
                    </tr>
                </table>    
                <input type="hidden" name="session" value="1">
                <input type="hidden" name="remember" value="1">
            </form>
            </div>
            <!-- step 4 -->
            <div id="step_4" class="hide">
            <form name="install_step_4" id="install_step_4" method="POST">
                <h2>Website Information</h2>
                <p>So people know what website they are visiting :)</p>
                <p>Site Name<br> <input type="text" name="title" id="site_title" placeholder="My Awesome Website" value=""></p>
                <p>Tagline<br> <input type="text" name="tagline" id="site_tagline" placeholder="Where I Post All My Awesome Things" value=""></p>
                <p>Keywords<br> <input type="text" name="keywords" id="site_keywords" placeholder="awesome, things, pictures, videos, poems, watermelons, cats, ninjas" value=""></p> 
                <p>Description<br> <textarea name="description" id="site_description" placeholder="This is my awesome website where I post awesome stuff. Some of my favorite things are ninjas, watermelons, and cats" cols="40" rows="7"></textarea>
                <p><input type="submit" value="Continue"></p>
            </form>
            </div>  
            <!-- step 5 -->
            <div id="step_5" class="hide">
                <h2>Your Site is Now Setup</h2>
                <p>Good job old sport, you're awesome. Now go em get em tiger!</p>
                <h3>Get Started Exploring</h3>
                <p><a id="go_to_website" href=""><img src="application/views/dashboard_default/assets/icons/globe_24.png"> Site</a>
                <p><a id="go_to_dashboard" href=""><img src="application/views/dashboard_default/assets/icons/home_24.png"> Home</a>
                <p><a id="go_to_apps" href=""><img src="application/views/dashboard_default/assets/icons/installer_24.png"> Apps</a>
                <p><a id="go_to_design" href=""><img src="application/views/dashboard_default/assets/icons/colors_24.png"> Design</a>
            </div>
        <?php
            }
        ?>
        </div>
    </div>
    <div class="content norm_bot"></div>
</div>
</body>
</html>
<?php } ?>

最佳答案

确认我刚刚解决了这个问题,并遇到了多个错误,包括你得到的错误。其他评论者不正确,它应该进入安装的下一步。

这个项目的 github 上有一个线程,有人尝试安装,但遇到错误 - 原始开发人员说他全职从事另一个项目,无法维护它。

这个项目中显然有一些很棒的东西,所以如果您调试安装,请再次发布。

关于php - Codeigniter 项目社交点火器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28255950/

相关文章:

MySQL修剪(连接...)

javascript - 如何将 codeigniter 的 CSRF token 传递给 Paypal Express Checkout?

php - VPS 服务器 -> fatal error : Call to undefined function mysqli_init()

java - 如何在 JPA 原生查询中使用 ':'?

codeigniter - 使用codeigniter事件记录获取单个字段输出的值

php - Laravel Eloquent 模型重写静态启动方法

php - Ajax 破坏页面上的 jQuery 脚本

php - 由下拉选择值填充的文本框

javascript - 是否可以更改整个 css 类/js 以及与之相关的任何内容?

python - 邮政数据库。 models.py 没有转化为数据库方案