Welcome Guest, Not a member yet? Register   Sign In
  Can someone please explain this to me
Posted by: El Forum - 10-12-2007, 06:28 AM - No Replies

[eluser]bosco500[/eluser]
Can someone please explain this code to me? I was browsing through the design on the freakauth_demo, trying to understand the design. This line of code is from menu.php (view)

Code:
<?php $ci_uri = trim($this->uri->uri_string(), '/'); $att = ' id="active"';?>
    <ul id="navlist">
        <li&lt;?= $ci_uri == ''? $att: ''?&gt;>&lt;?=anchor('', 'home')?&gt;</li>
        <li&lt;?= substr($ci_uri, 0, 7) == 'example'? $att: ''?&gt;>&lt;?=anchor('example', 'examples')?&gt;</li>
        <li&lt;?= $ci_uri == $this->config->item('FAL_login_uri')? $att: ''?&gt;>&lt;?=anchor($this->config->item('FAL_login_uri'), 'login')?&gt;</li>
        <li&lt;?= $ci_uri == $this->config->item('FAL_register_uri')? $att: ''?&gt;>&lt;?=anchor($this->config->item('FAL_register_uri'), 'register')?&gt;</li>
        <li&lt;?= $ci_uri == $this->config->item('FAL_forgottenPassword_uri')? $att: ''?&gt;>&lt;?=anchor($this->config->item('FAL_forgottenPassword_uri'), 'forgotten password')?&gt;</li>
        <li&lt;?= $ci_uri == $this->config->item('FAL_changePassword_uri')? $att: ''?&gt;>&lt;?=anchor($this->config->item('FAL_changePassword_uri'), 'change password')?&gt;</li>
        <li&lt;?= substr($ci_uri, 0, 5) == 'admin'? $att: ''?&gt;>&lt;?=anchor('admin', 'admin')?&gt;</li>
    </ul>

Why does every <li> have
Code:
&lt;?= $ci_uri == $this->config->item('FAL_login_uri')? $att: ''?&gt;>&lt;?=anchor($this->config->item('FAL_login_uri'), 'login')?&gt;

I realize that $ci_uri is an object being set, but what is the ? $att: '' for? Also why is substr used?

Thanks for the help!


  Unlimited nested folders in controller
Posted by: El Forum - 10-12-2007, 04:41 AM - No Replies

[eluser]Unknown[/eluser]
NOTE
This intend to modify the CI_router core class (CI 1.5.4),
so if you do not want to, please skip this.


in libraries/Router
CI_class
modify the _validate_segments function
replace line 200 with this code

Code:
if (file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT))

replace line 206 with this code
Code:
if (is_dir(APPPATH.'controllers/'.$this->fetch_directory().$segments[0]))

replace line 215 with this code
Code:
if ( ! file_exists(APPPATH.'controllers/'.$this->fetch_directory().$segments[0].EXT) && !
is_dir(APPPATH.'controllers/'.$this->fetch_directory().$segments[0]))

insert this code after line 218
Code:
$segments = $this->_validate_segments($segments);


finally modify set_directory function to this

Code:
$this->directory .= $dir.'/';

-----------edit
Actually not finally yet, My bad, sorry.
go to system\codeigniter\codeigniter.php

modify this code ~line 216
Code:
////ORIGINAL

call_user_func_array(array(&$CI, $method), array_slice($RTR->rsegments, (($RTR-
>fetch_directory() == '') ? 2 : 3)));    



///// REPLACE WITH THIS

$num_arg = preg_match_all("|/|", $RTR->fetch_directory(), $tmp) + 2;
unset($tmp);
call_user_func_array(array(&$CI, $method), array_slice($RTR->rsegments,$num_arg));


Good luck.


  xml-rpc: blogger api question
Posted by: El Forum - 10-12-2007, 03:49 AM - No Replies

[eluser]gerben[/eluser]
I'd like to add an xml-rpc interface to my system, using the blogger api. There isn't much documentation or discussion about this, but I thought I'd give it a try.

I debug the code using xml-rpc client Ecto on osx, and when I connect the client sends a request for blogger.getUsersBlogs, and my server returns the expected response.

Normally though, after that a request is sent for blogger.getRecentPosts and blogger.getUserInfo, but the client doesn't do this in my case. The progress bar just keeps on spinning forever, but in the console I can see that no further request to the server is sent.

My guess would be that either: something in the first response doesn't meet the client's "expectations", or somethings's wrong with my blogger.getRecentPosts method handling.

Below is my code, based on the example in the CI manual. For testing purposes I've commented out the user-authentication part, and added some dummy-data. any thoughts on what the problem could be are very welcome, because I feel it must be something small and silly.


Code:
function index()
    {
    
    
        $this->load->library('xmlrpc');
        $this->load->library('xmlrpcs');
        
        
        $config['functions']['blogger.getUsersBlogs'] = array('function' => 'Server.getUserBlogs');
        $config['functions']['blogger.getRecentPosts'] = array('function' => 'Server.getRecentPosts');
        $config['functions']['blogger.getUserInfo'] = array('function' => 'Server.getUserInfo');
        
        
        $this->xmlrpcs->initialize($config);
        $this->xmlrpcs->serve();
    }
    
  
    
    
    function getUserInfo($request)
    {
    
            $username = 'smitty';
            $password = 'smitty';
    
            $this->load->library('xmlrpc');
        
            $parameters = $request->output_parameters();
      
            
        
            $response = array(array('nickname'  => array('Smitty','string'),
                                    'userid'    => array('99','int'),
                                    'url'       => array('http://yoursite.com','string'),
                                    'email'     => array('[email protected]','string'),
                                    'lastname'  => array('Smith','string'),
                                    'firstname' => array('John','string')
                                    ),
                             'struct');
    
            return $this->xmlrpc->send_response($response);
            
        

    }
    
    
    function getUserBlogs($request)
    {
    
            $username = 'smitty';
            $password = 'smitty';
    
            $this->load->library('xmlrpc');
        
        
            $response = array(array(
            'isAdmin' => array('1', 'int'),
            'url'  => array('http://yoursite.com','string'),
                                    'blogName'    => array('My Blog','string'),
                                    'blogid'       => array('1','int'),
                                    'xmlrpc' => array('http://www.zomp.nl/server','string')
                                    
                                    ),
                             'struct');
    
            return $this->xmlrpc->send_response($response);
            
        

    }
    
    
    function getRecentPosts($request)
    {
    
            $username = 'smitty';
            $password = 'smitty';
    
            $this->load->library('xmlrpc');
        
        
            $parameters = $request->output_parameters();
        
        
            $response = array(array('link'  => array('http://yoursite.com','string'),
                                    'permaLink'    => array('http://zomp.nl/zomplog','string'),
                                    'userid'       => array('123','int'),
                                    'mt_allow_pings'     => array('0','int'),
                                    'mt_allow_comments'     => array('1','int'),
                                    'description'    => array('bla bla','string'),
                                    'mt_convert_breaks'    => array('__default__','string'),
                                    'postid'    => array('1234','int'),
                                    'mt_excerpt'    => array('lala','string'),
                                    'mt_keywords'    => array('lala','string'),
                                    'title'    => array('This is my post','string'),
                                    'mt_text_more'    => array('lalili','string'),
                                    'dateCreated'  => array('2005-12-13T01:35:00Z','dateTime.iso8601')
                                    ),
                             'struct');
    
            return $this->xmlrpc->send_response($response);
            
        

    }


  Function that checks if a segment key exists ?
Posted by: El Forum - 10-12-2007, 02:12 AM - No Replies

[eluser]starbbs[/eluser]
Call me stupid but i need a function that simply returns the key if this key exists inside the URI class. I cannot seem to fin it. Let me explain:

Code:
/**
*   This returns true, even is the segment does NOT exist. Example:
*
*    $segment = array( 1 => 'cpanel',
*                      2 => 'admin',
*                      3 => 'module',
*                      4 => 'user',
*                      5 => '44');
*/

  // In my code, i use this to get the value:
  $segVal = $this->uri->segment(6, 0);

  // If all goes well, $segVal contains FALSE. but when i do:
  $segVal = (is_numeric($this->uri->segment(6, 0)) ? TRUE : FALSE;

  // Now segVal contains TRUE !

So, i was thinking that there might be a function, in where i can check for a key directly. But i cannot find this function. I created my own function. Maybe someone can think of a faster way:

Code:
// $name = the name of the segment you want to check
    // $return_index = When set to true, it returns the index of $name
    //                 When set to false, it returns $name when found
    // result: when found, the name or it's key, when nothing is found, it returns false
    
    function nsegment($name, $return_index = FALSE )
    {          
       if( in_array( $name, array_values($this->router->segments)))
       {
            foreach($this->router->segments as $segmentidx => $value ) {
                if($name == $value) {
                 if($return_index){
                  return $segmentidx;
                  }else return $value;
                }
            }
       }else
         return FALSE;
    }
     /* $cpanelidx contains '3' */
    $cpanelidx = $this->CI->uri->segmentn('module', TRUE);  
  
    /* $cpanel contains 'module' */
    $cpanel = $this->uri->nsegment('module');

If you have any suggestion for my problem, please reply!

Thnks @


  question about active records / db
Posted by: El Forum - 10-12-2007, 01:54 AM - No Replies

[eluser]Unknown[/eluser]
Hi.

I want to know how do I get the sql string what was generated by active records class.
For example, I have this code:
$this->db->select('*');
$this->db->where('id',3);
$this->db->where('name','test');
$this->db->from('my_table');

$query=$this->db->get();

The class generates something like
"select * from my_table where id=3 and name='test'"

How do I get this sql string ?


Thanks


  best way to create links
Posted by: El Forum - 10-12-2007, 01:13 AM - No Replies

[eluser]charlie spider[/eluser]
Hi everybody, just downloaded ci yesterday. Have only been programming for about 6 months or so using PHP, MySQL and CSS, but want to be able to better reuse code etc.

ci looks great

Just started to develop a new site and wanted to fish for peoples opinions regarding the best way to create links for the site's navigation using ci. i'm totally new to MVC and prefer to do things properly right from the start.

should i create the full link structure first:
ie: <a href="www.mysite.com/index.php">home page</a>
then feed that into an array and pass it to my view page ?

or should i feed the separate pieces into separate arrays (or a multidimensional array) and then assemble the pieces in my view ?

i'm thinking the first way seems to make the most sense.

And secondly, when using the URL Helper, i understand how site_url() works and i understand how auto_link() works, but is there any way to input the text portion for the link. Using my example above:
<a href="www.mysite.com/index.php">home page</a>
How do i input "home page" into site_url() and/or auto_link() ???

if it wasn't midnight already i would prolly just figure this out myself, but i'm tired and want to cut corners and have smart people tell me what's best.

Any ingenious insights into ci and creating links would be greatly appreciated.

Thanks in advance.


  shopping for a scalable php framework
Posted by: El Forum - 10-11-2007, 11:42 PM - No Replies

[eluser]edoornav[/eluser]
Hi,

I am looking for a lightweight php framework in which to build a fast and scalable web application. I've done the tutorials and code igniter seems to be what I'm looking for. My problem is that I'm getting some bad results from simple performance tests. I installed MAMP and ran apache bench on a simple static file containing 'Hello World':

ab -n 1000 -c 5 http://localhost:8888/index.html -> 350 requests per second (my laptop is slow)

Next I ran it on a php file containing '&lt;?php print "hello world" ?&gt;':

ab -n 1000 -c 5 http://localhost:8888/test.php -> 250 requests per second

Next I installed code igniter, and did the blog tutorial up to the point where it just prints "hello world":

ab -n 1000 -c 5 http://localhost:8888/index.php/blog -> 20 requests per second!

Using a view and displaying a single db row gets me down to 15 requests per second. Doing the same thing in a simple script gives me 150 rps.

This seems too high a penalty to pay for MVC. Is this a typical result or might there be something wrong with my configuration? I'm otherwise really impressed with this framework and would definitely use it on a smaller project.

Thanks in advance for any help.

~rvr


  Reset of Validation possible?
Posted by: El Forum - 10-11-2007, 10:51 PM - No Replies

[eluser]esbium[/eluser]
Hey everyone,

I have a form that submits to a controller, gets validated and then inserts the data into the database. All of that works fine. However, once all of that is done, I want to re-display the same form so the user can enter another record. When I do this, the old values from the last submit remain in the form. I do not want to use a redirect here.

I have tried creating a new instance of CI_Validation after a successful submit in hopes that it would reset all the values that were stored in it but that doesn't work.

Basically, the calls to $validation->someFormField return the last value from the submit. I know that this is great when there are errors, but I need to clear them if there are no errors!

Please help and thanks in advance!


  400 Errors
Posted by: El Forum - 10-11-2007, 10:40 PM - No Replies

[eluser]CI Lee[/eluser]
Hey all,

Keep getting a 400 error

Quote:Bad Request

Your browser sent a request that this server could not understand.

This is my .htaccess file
Code:
AddHandler php5-script .php

Options +FollowSymLinks
RewriteEngine on
RewriteCond $1 !^(index\.php|images|css|robots\.txt|favicon\.ico)
RewriteRule ^(.*)$ /index.php?/$1 [L]

Anyone see anything that maybe causing those errors? They are sporadic browser/client independent...

-Lee


  image dowloads on clicking a link?
Posted by: El Forum - 10-11-2007, 06:51 PM - No Replies

[eluser]megabyte[/eluser]
You know when you have a zip file and you attach it to a link it downloads to your computer when you click it.


Is it possible to do this with an image?


Welcome, Guest
You have to register before you can post on our site.

Username
  

Password
  





Latest Threads
AssetConnect - a powerful...
by maniaba
Today, 03:53 AM
twig and view cell
by foxbille
Today, 01:58 AM
Best Way to Implement Aff...
by InsiteFX
Yesterday, 09:58 PM
The pipe operator in PHP ...
by InsiteFX
Yesterday, 04:18 PM
Heads up for users using ...
by FlavioSuar
Yesterday, 11:33 AM
Table (view class) Row ID
by grimpirate
07-03-2025, 11:22 PM
curl + response body
by michalsn
07-03-2025, 10:10 PM
Happy 4th Everyone
by InsiteFX
07-03-2025, 09:31 PM
AbuseIPDB Module
by InsiteFX
07-03-2025, 09:27 PM
tool bar not showing
by Luiz Marin
07-03-2025, 04:46 AM

Forum Statistics
» Members: 154,900
» Latest member: at_saigon_riverside
» Forum threads: 78,441
» Forum posts: 379,731

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB