abayomi.zou 发表于 2011-2-9 11:54:57

GODADDY 空间对CI的支持问题

今天把我开发的一个小东西发到godaddy的空间里去了,发现很多问题。一个是.htaccess的问题,不过在网上找到解决办法了。可是后来发现另外一个问题,居然不能找到model,这个是怎么个回事儿。这个代码在我自己的机器跑得还很顺流啊
这是我的view:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<?php header("Content-Type: text/html; charset=gb2312");?>
<title>登录页面</title>
<link rel="stylesheet" type="text/css"
        href="/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="/js/themes/icon.css">
<script type="text/javascript" src="/js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="/js/jquery.easyui.min.js"></script>
<script type="text/javascript">
$(function(){
       
        $('#win').window({
                collapsible:false,
                minimizable:false,
                maximizable:false,
                closable:false
        });
       
        $(document).bind('contextmenu',function(e){
                $('#mm').menu('show', {
                        left: e.pageX,
                        top: e.pageY
                });
                return false;
        });

        $.extend($.fn.validatebox.defaults.rules, {
          minLength: {
                validator: function(value, param){
                    return value.length >= param;
                },
                message: '请输入最少{0}个字符'
          },
          maxLength: {
                validator: function(value, param){
                    return value.length >= param;
                },
                message: '请输入最多{0}个字符'
          }
        });

        $('#username').focus();
});

function submitFF(){
        $('#ff').form('submit', {
                url: '/index.php?user_login',
          onSubmit: function(){
                        return $(this).form('validate');
          },
          success:function(data){
                  if(data=='TRUE'){
                          //$.messager.alert('info','<?php echo $this->session->userdata('name');?>','info');
                          window.location.href='';
                  }else if(data=='FALSE'){
                          $.messager.alert('错误!','用户名或者密码错误','error');
                  }else if(data=='ERROR'){
                          $.messager.alert('错误!','验证码输入错误','error');
                  }else{
                          $.messager.alert('错误!','未知错误!['+data+']','error');
                  }
          }
        });
}
        </script>
</head>
<body class="easyui-layout">

<div region="center" style="overflow: hidden;">
<div id="win" class="easyui-window" title="登录" style="width: 270px; height: 200px;">
<form id="ff" action='/index.php?user_login' method="post">
<table width='80%' border='0' height='100%' style='margin-top: 20px; margin-left: 10px'>
        <tr>
                <td><label for="username">用户名</label></td>
                <td><input class="easyui-validatebox" type="text" name="username"
                        id='username' required="true" validType='minLength' value='zouyj'></input></td>
        </tr>
        <tr>
                <td><label for="password">密码:</label></td>
                <td><input class="easyui-validatebox" type="password" name="password"
                        id='password' validType='minLength' required="true" value='password'></input></td>
        </tr>
        <tr>
                <td><label for="password">验证码</label></td>
                <td><input type="text" name="extraCode"
                        id='extraCode' size='4' maxLength='4'></input>
                        <img src='/index.php?util_extraCode/<?php echo rand(0, hexdec('FFFFFF'));?>' /></td>
        </tr>
        <tr>
                <td colspan='2' style='text-align: right; height: 50px'><a href="#" onclick="submitFF();"
                        class="easyui-linkbutton" icon="icon-ok">登录</a></td>
        </tr>
</table>
</form>

</div>

</div>
<div id="mm" class="easyui-menu" style="width: 120px;">
<div onclick="javascript:window.location.href=''" iconCls='icon-reload'>刷新</div>
<div onclick="$.messager.alert('信息','天正教育帮助','info');" iconCls='icon-help'>帮助</div>
<div onclick='window.close()'>退出</div>
</div>
</body>
</html>



点登录之后,进入的Controllers

<?php

class User extends Controller {

        function __construct()
        {
                parent::Controller();
        }

        function index()
        {
        }
       
        function login(){
                if(strtolower($this->session->userdata('verify_code'))==strtolower($this->input->post("extraCode"))){
                        $this->load->model('Users','user');
                        $user = $this->user->hasUser($this->input->post("username"),$this->input->post("password"));
                        if($user <> false){
                                $this->session->set_userdata($user);
                                echo 'TRUE';
                        }else{
                                echo 'FALSE';
                        }
                }else{
                        echo 'ERROR';
                }
               
        }

}


load的Model

<?php
class Users extends Model {

    function __construct()
    {
      parent::__construct();
    }
   
    function hasUser($username,$password){
            if(isset($username,$password)){
                    $this->load->database();
                   
                    $query = $this->db->query("SELECT code,
                            name, role_id roleId FROM users where code='".$username.
                            "' and password='".md5($password)."'");
                   
                    if ($query->num_rows() > 0){
                            return $query->row_array();
                    }else{
                            return null;
                    }
            }
            return null;
    }
}

Hex 发表于 2011-2-9 12:11:10

先报告下 CI 版本?

abayomi.zou 发表于 2011-2-9 13:19:01

提问的时候是1.73,现在换成2.0了
现在所有的页面都是404错误,包括Index.php
我用了网上写的改.htaccess的那个,也改了config.php:
.htaccess
#Enable mod rewrite
RewriteEngine On
#the location of the root of your site
#if writing for subdirectories, you would enter /subdirectory
RewriteBase /

#Removes access to CodeIgniter system folder by users.
#Additionally this will allow you to create a System.php controller,
#previously this would not have been possible.
#'system' can be replaced if you have renamed your system folder.
RewriteCond %{REQUEST_URI} ^system.*
RewriteRule ^(.*)$ /index.php?/$1

#Checks to see if the user is attempting to access a valid file,
#such as an image or css document, if this isn't true it sends the
#request to index.php
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
#This last condition enables access to the images and css
#folders, and the robots.txt file
#Submitted by Michael Radlmaier (mradlmaier)
# I added this line based on some info from other posts
RewriteCond $1 !^(index.php|images|robots.txt|css)

RewriteRule ^(.*)$ index.php?/$1
config.php
$config['uri_protocol']        = 'QUERY_STRING';

abayomi.zou 发表于 2011-2-9 15:52:34

几乎废了我一天时间,终于搞明白了。
错误是由于我对文件名大小写和routes里面文件名大小写没搞对造成的。
在windows里面,大小写文件名没什么影响,在linux里面可就不行了,折腾死我了,不过好在终于成功了,嘿嘿

Hex 发表于 2011-2-9 22:36:28

回复 4# abayomi.zou


    你要是严格按照手册的规定命名,就不会出错了,手册对于大小写都有明确规定。

bluelomo 发表于 2011-2-10 10:30:32

内个引用名称是不是最好别一样了啊……都用user你不怕搞混了啊……

shuro 发表于 2011-2-12 16:24:02

汗,还能犯这种错误。
页: [1]
查看完整版本: GODADDY 空间对CI的支持问题