Welcome Guest, Not a member yet? Register   Sign In
  validation and input field has text
Posted by: El Forum - 06-01-2008, 04:33 AM - Replies (1)

[eluser]Mitja B.[/eluser]
I have small problem and i do not know if this is possible.

i validate with CI validation. Everything ok and works, but fileds that are not required are not validate. After page is refresh validate fields still havse text in it other fields are empty. Is it possible that even this fields have text even they are not validate.

Redna: &lt;input type="text" name="price_eur" value="&lt;?= $row-&gt;price_eur?&gt;" /><br>
SiMobil: &lt;input type="text" name="price_eur_simobil" /&gt;

SiMobil field lost text after validating.

Thx, hope undesrtand me


  scandinavian letters in mail header
Posted by: El Forum - 06-01-2008, 04:05 AM - No Replies

[eluser]MgM Web[/eluser]
I have been seeing some errors while sending mail using the default CI mail component.
It is possible to encode the body of the mail but not the header, or at least I have not found any good method to do so.

When I send emails with scandinavian letters in the subject field, these letters (æøå) is shown as ??? in my inbox.

Until now I have not found any good fix for this but then i came over "mb_encode_mimeheader()".

I edited the "Email.php" core library file to this:

Code:
function subject($subject)
    {
        $subject = mb_encode_mimeheader($subject); //Added encoding
        
        if (strpos($subject, "\r") !== FALSE OR strpos($subject, "\n") !== FALSE)
        {
            $subject = str_replace(array("\r\n", "\r", "\n"), '', $subject);            
        }

        if (strpos($subject, "\t"))
        {
            $subject = str_replace("\t", ' ', $subject);
        }

        $this->_set_header('Subject', trim($subject));
    }

And now my scandinavian letters are showing as expected. Maybe this can be of help to others with the same problem. Or is there better ways to accomplish this?


  Print XML request
Posted by: El Forum - 06-01-2008, 03:56 AM - Replies (2)

[eluser]Unknown[/eluser]
Hello,

I'm getting some errors durring XML requests, because Codeigniter doesn't send valid XML files with german special characters and because I have somewhere a mistake in my XML request. For that reason I would like to print the XML request file. I didn't find a option for that. Somebody allready worked on such issue?

Yours, Matthias.


  Encryption Key in config file
Posted by: El Forum - 06-01-2008, 02:27 AM - Replies (7)

[eluser]PV-Patrick[/eluser]
I have been searching around on the forums here for about an hour or two in regards to this topic and figured I would just post a topic myself as I couldn't find a 100% answer to my question.

I would like to know how secure keeping your encryption key inside the config.php file is? How is it protected against malicious users that say upload scripts such as c99/100shell and gain access to view/download files within your www directory?

I am going back and forth between SHA1 + salt and the encrypt/encode function with CI + encryption key. Possibly using both for different situations... Anyways, my main question is in regards to the security of that config file and if there are any suggestions on HOW to properly secure it. Thanks in advance and I apologize if this has been covered, I have been looking.


  Hello World problem for beginner
Posted by: El Forum - 06-01-2008, 01:11 AM - Replies (13)

[eluser]Rabbi[/eluser]
After this post
http://ellislab.com/forums/viewthread/81081/

I made a file named "blog.php" in application\controllers\blog.php.

Here is my code, which i have written in the file blog.php

Code:
&lt;?php
class Blog extends Controller {

    function index()
    {
        echo 'Hello World!';
    }
}
?&gt;


  New to programming and trying to understand it all.
Posted by: El Forum - 05-31-2008, 11:22 PM - Replies (9)

[eluser]jjcalleiro[/eluser]
Im running through the first Hello World tutorial here on the site. At the end of the Hello World screencast i add the the following code.

Code:
function Blog() {
    parent::Controller();
}

Its not explained, but i would like to know the purpose of this as i see no difference in the output of the view.

Thanks in advance.


  Numerous Controllers
Posted by: El Forum - 05-31-2008, 06:50 PM - No Replies

[eluser]stuffradio[/eluser]
Edit:
Nevermind I found my answer by looking in the user docs.


  Can CI access directories above webroot ?
Posted by: El Forum - 05-31-2008, 06:23 PM - Replies (2)

[eluser]charlie spider[/eluser]
Proponents of maximum site security recommend placing any directories that you wish to save uploaded files to above the web root.

So for instance, I am running XAMPP on my local system, and in order to follow these recommendations I would like to have a directory named "file_uploads" above the "htdocs" directory where I place the files for any site that is being worked on, like this:

-xampp
--apache
--cgi-bin
--file_uploads
--htdocs
---website_being_worked_on
---another_website_being_worked_on
--perl
--php
--tmp
--etc

So let's say I'm working on a "website_being_worked_on", and I want to display an image, how do I access the directory "file_uploads" from my view file ???

I've tried
../file_uploads/image.jpg
../../file_uploads/image.jpg
../../../file_uploads/image.jpg
../../../../file_uploads/image.jpg
etc, etc
and none of them have worked ?

Is this a CI issue or something to do with PHP itself ?


  yayparser - Yet Another Yaml parser - updated
Posted by: El Forum - 05-31-2008, 04:02 PM - Replies (16)

[eluser]m4rw3r[/eluser]
NOTE: a new version in the Wiki

Had some time to kill, and I thought it would be fun to make a YAML parser (OK, I'll get back to MPTtree soon :red: ).
It relies heavily on regex, and I haven't built it as the YAML specification says, but it supports many parts of the YAML standard.

It is built as a helper, so make a file in your helpers dir and copy and paste:

Code:
&lt;?php
/*
* Created on 2008 May 31
* by Martin Wernstahl <[email protected]>
*/
/*
* Copyright (c) 2008, Martin Wernstahl
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*     * Redistributions of source code must retain the above copyright
*       notice, this list of conditions and the following disclaimer.
*     * Redistributions in binary form must reproduce the above copyright
*       notice, this list of conditions and the following disclaimer in the
*       documentation and/or other materials provided with the distribution.
*     * The name of Martin Wernstahl may not be used to endorse or promote products
*       derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY Martin Wernstahl ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Martin Wernstahl BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
if(!defined('YAYPARSER_key'))
    define('YAYPARSER_key','([^\n\S]*)(?:\?[^\S\n]*)?(\S*?)(?:[^\S]*)?:(?:[^\S\n]*)?');

if(!defined('YAYPARSER_list'))
    define('YAYPARSER_list','([^\n]*?)?-(?:[\s]*?)');

if(!defined('YAYPARSER_multiline'))
    define('YAYPARSER_multiline','(?:(?:\||>)(?:[^\n]*)?\n((?:(?:\1)([^\n\S]+)(?:[^#\n\s][^#\n]*)(?:#.*?)?)(?:\n(?:\1)(?:[^\n\S]+?)(?:[^#\n\s][^#\n]*)(?:#.*?)?)*))');

if(!defined('YAYPARSER_val'))
    define('YAYPARSER_val','([^#\n\s][^#\n]*)');

if(!defined('YAYPARSER_comment'))
    define('YAYPARSER_comment','(?:#.*?)?');

if(!function_exists('yayparser')){
    /**
     * YAYParser - Yet Anoter Yaml Parser.
     *
     * @param $string The string to be processed
     *
     * @return An array which contains data built from the string
     */
    function yayparser($string){
        $ret = array();
        if(!strlen($string))
            return array();
        // try to match single "key: value" first
        $num = preg_match('@^'.YAYPARSER_key.'(?:'.YAYPARSER_multiline.'|'.YAYPARSER_val.')'.YAYPARSER_comment.'(?:(?:\n([\w\W]*))|$)@',$string,$result);
        if($num < 1){
            /* if no found, try to match "key:
             *                                   key: value"
             */
            $num = preg_match('@'.YAYPARSER_key.'(#[^\n]*?)?\n((?:(?:\1)([^\n\S]+?)(?:(?:(?:\?[^\S\n]*)?(?:\S*?)(?:[^\S]*)?:(?:[^\S\n]*)?(?:(?:\||>)(?:[^\S]*)?((?:\1\4(?:[^\n\S]+?)(?:[^#\n\s][^#\n]*)(?:#.*?)?\n)+))|(?:(?:[^#]*?)?))|(?:#[^\n]*?)|(?:-(?:\s*)?(?:[^#\n\s]*)?))(?:#[^\n]*?)?\n)*)([\w\W]*)@',$string,$result);
            if($num){
                $ret[$result[2]] = yayparser($result[4]);
                $ret = $ret + yayparser($result[7]);
                return $ret;
            }
            // try to match all "-listvalue"
            $result = array();
            preg_match_all('@'.YAYPARSER_list.'(?:'.YAYPARSER_multiline.'|'.YAYPARSER_val.')'.YAYPARSER_comment.'\n@',$string,$result);
            foreach($result[4] as $key => $val){
                // do we have a multiline?
                if(!empty($result[2][$key])){
                    // yes
                    $str = explode("\n",$result[2][$key]);
                    $indent_len = strlen($result[1][$key]) + strlen($result[3][$key]);
                    array_walk($str,'YAYPARSER_substr',$indent_len);
                    $ret[$key] = implode("\n",$str);
                }
                else
                    $ret[$key] = $val;
                // if the line is surrounded with [], remove them and split the line into an array
                if($ret[$key][0] == '[' && substr($ret[$key],-1) == ']'){
                    $ret[$key] = explode(',',trim($ret[$key],'[]'));
                }
            }
            return $ret;
        }
        if(strlen($result[3])){
            // we have multiline
            $str = explode("\n",$result[3]);
            $indent_len = strlen($result[1]) + strlen($result[4]);
            array_walk($str,'YAYPARSER_substr',$indent_len);
            $ret[$result[2]] = implode("\n",$str);
        }
        else // normal
            $ret[$result[2]] = trim($result[5]);
        // if the line is surrounded with [], remove them and split the line into an array
        if($ret[$result[2]][0] == '[' && substr($ret[$result[2]],-1) == ']'){
            $ret[$result[2]] = explode(',',trim($ret[$result[2]],'[]'));
        }
        if(isset($result[6]) && strlen($result[6]))
            $ret = $ret + yayparser($result[6]);
        return $ret;
    }
}
if(!function_exists('YAYPARSER_substr')){
    /**
     * A substr wrapper for use with array_walk().
     */
    function YAYPARSER_substr(&$value,&$key,&$len){
        $value = substr($value,$len);
    }
}
?&gt;
Whew, only 121 chars left...


  Javascript issue
Posted by: El Forum - 05-31-2008, 03:47 PM - Replies (5)

[eluser]Nial[/eluser]
In this thread I asked about setting up 'fake' subdomains for users. Here's the .htaccess I wound up with:

Code:
RewriteEngine on

# Prevent infinite loop
rewriteCond $1 !^index.php/user/show/

RewriteCond %1 !^www$ [NC]
RewriteCond %{HTTP_HOST} ^([^.]+)\.database\.com
RewriteCond %1 !^www$ [NC]
RewriteRule (.*) index.php/user/show/%1/$1 [L]

RewriteCond $1 !^(index\.php|images|robots\.txt|css|js|img|uploads|avatars)
RewriteRule ^(.*)$ /index.php/$1 [L]

This works well. Except for when I come to carry out an Ajax query (I use the Mootools library).Basically, I have a function which generates an Ajax request:

Code:
function fetch_latest_entries() {

   new Ajax('fetch', {
    method: 'get',
        onComplete: function() {

        // yadda yadda

        }
    }).request();

}

This works great when I call it from domain.com/account. However, I assign each user on my site their own subdomain, like so: username.domain.com. Within cPanel I've setup *.domain.com to point towards domain.com/user/view/{username}.

When I execute the above function from username.domain.com, Firebug returns the following:

Quote:[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]" nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)" location: "" data: no]

However, when I run the query from domain.com, it works fine. A little snooping around on Google has led me to believe that this is because the XMLHttpRequest considers a subdomain and a domain to be different locations. To solve this I imagine I have to send the request to username.domain.com/fetch rather than domain.com/fetch. But the above .htaccess doesn't allow this.

Any suggestions?


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

Username
  

Password
  





Latest Threads
DataCaster not working
by kenjis
4 hours ago
Can't read a session
by ElTomTom
10 hours ago
Shield Common Code to Det...
by Bosborne
Today, 08:36 AM
How to make nav-link acti...
by Tokioshy
Today, 06:41 AM
Ci4, CLI Spark Run Standa...
by kenjis
Today, 12:54 AM
auth() differs from my lo...
by InsiteFX
Yesterday, 11:20 PM
PostgreSQL application_na...
by Bosborne
Yesterday, 02:05 PM
PHPUnit on Production
by kenjis
Yesterday, 02:34 AM
custom validation dinamic
by ozornick
Yesterday, 12:49 AM
Reading a session variabl...
by kenjis
05-03-2024, 08:29 PM

Forum Statistics
» Members: 86,470
» Latest member: trieubachtung89
» Forum threads: 77,615
» Forum posts: 376,171

Full Statistics

Search Forums

(Advanced Search)


Theme © iAndrew 2016 - Forum software by © MyBB