Thursday, July 3, 2014

deleting all files from a folder using php?

 function recursiveDelete($str){
        if(is_file($str)){
            return @unlink($str);
        }
        elseif(is_dir($str)){
            $scan = glob(rtrim($str,'/').'/*');
            foreach($scan as $index=>$path){
                $this->recursiveDelete($path);
            }
            return @rmdir($str);
        }
    }

Cakephp add class in multiple checkbox and select box

$services_arr = array();
    foreach ($state_list as $key => $value) {
        $services_arr[$key]['name'] = $value;
        $services_arr[$key]['value'] = $key;
        $services_arr[$key]['class'] = 'validate[minCheckbox[1]]';
    }

Friday, May 16, 2014

Cakephp Disable Behaviors

$this->Banner->Behaviors->disable('FileUpload');

Cakephp date, month and year dropdown

<div class="form-group">
                                    <label for="QualificationSchool" class="float_left">Date Attended</label>
                                    <?php
                                    echo $this->Form->input('month_val', array('class' => 'form-control left_month_box', 'dateFormat' => 'M', 'monthNames' => true, 'separator' => '&nbsp;', 'type' => 'date', 'label' => false, 'div' => false));
                                    echo $this->Form->input('year_val', array('class' => 'form-control right_year_box', 'dateFormat' => 'Y', 'separator' => '&nbsp;', 'minYear' => date('Y') - 70, 'maxYear' => date('Y', strtotime('+0 years')), 'type' => 'date', 'label' => false, 'div' => false));
                                    ?>
                                </div>

Friday, January 10, 2014

cakephp theme path

App::themePath('Front');

cakephp subdomain htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    # http|https www to non-www
    RewriteCond %{HTTP_HOST} ^www\.(.*)$ [NC]
    RewriteCond %{HTTPS}s ^on(s)|
    RewriteRule ^(.*)$ http%1://domain.com/$1 [R=301,L]

    # redirect all subdomains
    RewriteCond %{HTTP_HOST} !^domain\.(.*)$ [NC]
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ /%{HTTP_HOST}/$1 [NC,L,NS]

    RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
    RewriteRule ^$ app/webroot/    [L]
    RewriteCond %{HTTP_HOST} ^domain\.(.*)$ [NC]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

/public_html/sub1.domain.com/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /

    RewriteCond %{REQUEST_URI} ^/%{HTTP_HOST}
    RewriteRule ^%{HTTP_HOST}(.*)$ /$1

    RewriteCond %{HTTPS} on
    RewriteRule ^$ %{HTTP_HOST}/app/webroot/    [L]
    RewriteCond %{HTTPS} on
    RewriteRule (.*) %{HTTP_HOST}/app/webroot/$1 [L]

    RewriteRule ^$ app/webroot/    [L]
    RewriteRule (.*) app/webroot/$1 [L]
</IfModule>

/public_html/sub1.domain.com/app/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine on
    RewriteBase /
    RewriteRule ^$    webroot/    [L]
    RewriteRule (.*) webroot/$1    [L]
</IfModule>

/public_html/sub1.domain.com/app/webroot/.htaccess

<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{HTTPS} on
    RewriteRule ^(.*)$ %{HTTP_HOST}/index.php [QSA,L]

    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{HTTPS} !on
    RewriteRule ^(.*)$ index.php [QSA,L]
</IfModule>