Jump to content

Mahngiel

Newly Registered
  • Posts

    1,068
  • Joined

  • Last visited

Posts posted by Mahngiel

  1. class Auth {
        
        private $CI;
        
            function __construct(){
                $this->CI =& get_instance();
                echo 'hook inst';
            }
        
        
            function authenticate()
            {
                echo 'method called';
                    
                $this->CI->session->set_userdata(array('hook' => $_SERVER['php_self']));    
    
                echo $this->session->userdata('logged_in') ? 'logged' : 'not logged';
     
                die('end');
            }     
    }
    

     

    what happens?

  2. I've read studies that show that adding background music to a site results in something like 50% of your users will immediately leave the site.

     

    this includes auto-starting ad vids since you NEVER know where the hell they are!

  3. Just learn by trying to build something.  It's much more practical to learn this way, as you'll go through the headaches of trying to do something and not know how. Through these experiences you'll figure some stuff out -- hopefully.

  4. you need to kill the script too, dude.  Although your "login" script doesn't actually log the user in, and you said this is just for practice... 

     

    my advice is to change

    $this->session->set_userdata(array('logged_in' => $arr));

    to

    $this->session->set_userdata('logged_in' => TRUE);

     

    Then, when your hook is called,

    if( $this->session->userdata('logged_in') )

    will eval to true.

  5. [this list is only in order as they come to mind, not importance]

    1. Debian / Linux Mint : Since the new gnome came out, I transitioned to Mint for it's Cinnamon DE. It's an extremely smooth environment to work AND play in. Being Debian based, it's simple to keep a similar environment to production

     

    2. tmux: The most bad ass terminal emulator on the planet. I couldn't imagine my workflow without it.

     

    3. Firebug: Completely essential if you build any front-end

     

    4. Git(hub): Versioning FTW

     

    5. Dropbox: Helps me keep docs, scripts, dotfiles, graphics, etc sync'd across all my workstations

     

    6. phpStorm: I used to rag on heavy IDEs. Now, I couldn't do without it

     

    7. Bluefish: My favorite light-weight IDE.  It works with SFTP so I can mount a remote server and make quick changes with all the colorization, syntax hilights, and code suggestions one needs.

     

    8. GIMP: I often find the need to make quick changes to a graphic, or to grab a layer from a PSD.

     

    9. LESS: A language, yes, but moreso an important tool for keeping organized CSS and compiling out minified CSS

     

    10. Nano: Once you know how to use it, nothing else matters.

  6. Why would you imagine you'd need to encrypt the config file? If somebody has access to your server files, they wouldn't need to know your encrypt key to access the information that would be encrypted anyway. I think your paranoia has blinded your thought process.

  7. Well, though these issue remain, I have developed a workaround by using cURL() for the downloads and using a hard-copy of the WSDL with these options in the SoapClient constructor

    $this->Client = new SoapClient( "path/to/local.wsdl", array( 'soap_version' => 1.1, 'trace' => TRUE, 'stream_context' => 'context' ) );

     

    Further, had to remove a schema import from the xml.

     

    Am still looking for an answer as to why these changes need to be made.

  8. Issue:  Retrieving data from remote HTTP locations. "failed to open stream: HTTP request failed!"

    Doesn't Work: fopen(), file_get_contents(), SoapClient('[url=]http://remote_wsdl[/url]')

    Works: curl, wget via CLI & exec()

    Tried: Set all ini's to allow_url_fopen = 'On'

    root@OW-WS01:~$ php -v
    PHP 5.3.3-7+squeeze15 with Suhosin-Patch (cli) (built: Mar  4 2013 14:05:25) 
    Copyright (c) 1997-2009 The PHP Group
    Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
        with Suhosin v0.9.32.1, Copyright (c) 2007-2010, by SektionEins GmbH
    
    root@OW-WS01:~# php -i --php-ini /etc/php5/apache2/php.ini | grep 'fopen'
    allow_url_fopen => On => On
    
    root@OW-WS01:~# grep 'fopen' -R /etc/php5/
    /etc/php5/cli/php.ini:; http://php.net/allow-url-fopen
    /etc/php5/cli/php.ini:allow_url_fopen = On
    /etc/php5/apache2/php.ini:; http://php.net/allow-url-fopen
    /etc/php5/apache2/php.ini:allow_url_fopen = On
    
     

    Code Debug:

    ini_set('default_socket_timeout', 10);
    ini_set('display_errors', 1);
    ini_set('error_reporting', E_ALL);
    
    echo 'allow_url_fopen:' .  (ini_get('allow_url_fopen') ? 'TRUE' : 'FALSE') . '<br/>';
    echo 'default_socket_timeout: ' . ini_get('default_socket_timeout') . '<br/>';
    
    $Remote_XML  = "valid_path.xml";
    $todays_XML     = __DIR__ .'/imports/' . date( 'Ymd', time() ) . '.xml';
    
    echo '<hr/><br/> Testing fopen()<br/>';
    
    $from = fopen( $Remote_XML, 'r' );
    $to   = fopen( $todays_XML, 'w+' );
    stream_copy_to_stream( $from, $to );
    
    echo '<hr/><br/> Testing file_get_contents()<br/>';
    
    $fgc = file_get_contents($Remote_XML);
    file_put_contents($todays_XML, $fgc );
    
    echo '<hr/><br/> Testing SoapClient()<br/>';
     
    try{
        $soap = new SoapClient( '/?wsdl', array( 'trace' => TRUE ) );
        $soap->login( 'user', 'pass' );
        echo 'soap passed';
    } catch( SoapFault $e ) {
        var_dump($e);
    }
    
    phpinfo(INFO_CONFIGURATION);
    
    

     

    Results in image format: http://i.imm.io/10Hle.png

     

    So, how do I overcome this? Have sniffed packets and these requests aren't even getting generated.  This code works just dandy on local and on another server, so there's got to be something I haven't figured out yet. Any idea what could be causing this or what to try next?

     

    Thanks

  9.  

    Isn't that the same as:

    $(':input').bind('keyup change input', function() {
      // code here
    });

     

    For the most part yes. I stripped out the unnecessary info to my issue (depending on use, you'd really want some specificity) . Sorry if that lead to confusion.  Also, one wouldn't want to use :input for this, as it attaches the handlers to submit buttons

  10. Aah, yes 'Autofill'.  I appreciate the feedback and useful links, Ignace, truly helpful. 

     

    I added input to my bindings and voila (FF 19.0.2) - autofill selection now fires the in response

     

     

        // super generic, over-compensating object mappage
        $( 'form :input' ).map( function () {
    
            // do something on change
            $( this ).bind( 'keyup change input', function () {
    
            } );
    
        } );
    
  11. SwiftMailer's function to set the recipient's email and name looks like this:

    setTo(<address>, <name>);

     

    This works dandy, unless a recipient has parenthesis (maybe other characters, but for my purpose is irrelevant).

     

    Examples:

    John (Work)

    John (Home)

     

    In my use case, th data in parenthesis is important for the recipient to derive the intent of the email notification. SwiftMailer will truncate any data in parens leaving behind "John " in both scenarios. Esacaping the parens with a backslash John \(Work\) alleviates the parens replacement, but includes an automatic escaping of the escape lol: John \\(Work\\)

     

    Reading into the headers sent with SM, there are several other headers that have parens in them, so I don't believe this is done for that purpose - but I could be wrong.

     

    So my Q is two part:

     

    Is there a way to send parens in the recipient's name? and is there a reason this is done at all?

     

    Cheers

  12. I'm having trouble figuring out how to get models or controllers to interact with one another. In the frameworks I'm used to each model represents a table. It seems like CI suggests the same.

    I imagine this is because you're used to ORM. This isn't so much the case with CI, and I bet $20 you'll really like their db driver.

    // Random Controller
    $this->load->model('poll_model', 'Polls');
    $Poll = $this->Polls->get_poll(array('id'=>3));
    
    // Poll_model
    function get_poll($data = array())
    {    
     // Check for valid data
     if(empty($data) OR !is_associative($data))
     {
       // Invalid data, return FALSE
       return FALSE;
     }
    
     // Retrieve the query from the database
     $query = $this->db->where($data)->get('polls', 1);
    
     // Check if query row exists
     if($query->row())
     {
       // Query row exists, return query row
       return $query->row();
     }
     else
     {
       // Query row doesn't exist, return FALSE
       return FALSE;
     }
    }
    

     

    So here are some tables I have:

    users

    quests

    users_quests

     

    users_quests contains a PK, a FK to users and an FK to quests (and some DATETIMEs). 

     

    I'm in my Quests Controller. index.php/quests/view/5 (5 = pk on users_quests)

     

    What is the smart way to pull all of the users_quests data and the related quests_data.

     

    I know how to do it in pure SQL, and I know how to do it in Yii - I don't get how to do it in CI, automatically anyway. I can write a chained DB statement: pseudo code as 

    $this->db->select('fields')->from('users_quests')->join('quests', 'columns')->where('col=5');

     

    That seems like a ton of stupid code for a simple BELONGS TO.

     

    Joins are always cumbersome, and no different with CI. I would write this:

    // Controller
    $pk = $this->uri_segment(3);
    $this->load->model('quest_model', 'Quests');
    $Data = $this->Quests->name($pk);
    
    // Model
    function name($id) {
     $this->db->select('fields')->from('users_quests')->join('quests', 'quests.user_id = users_quests.user_id')->where('users.user_id = ' . $id)->get();
    }
    

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.