Welcome Guest, Not a member yet? Register   Sign In
[SOLVED] Codeigniter Form Validation Question
#1

[eluser]riwakawd[/eluser]
I am just not sure on some thing for my form validation. I am trying to use all codeigniter methods rather than create my own I would like to make sure these files are write able

But would like to be able to get codeigniter form validation to pick it up not. Sure on set rules should have and if files writable

If any body can give me some examples would be great

Need to make sure these files are writable.

Code:
$data['config'] = FCPATH . APPPATH . 'config/config.php';
$data['cache'] = FCPATH . APPPATH . 'cache';
$data['logs'] = FCPATH . APPPATH . 'logs';
$data['download'] = FCPATH . APPPATH . 'modules/download';
$data['image'] = FCPATH . APPPATH . 'modules/image';
$data['image_cache'] = FCPATH . APPPATH . 'modules/image/cache';
$data['image_data'] = FCPATH . APPPATH . 'modules/image/catalog';

This is how its is on my view

Code:
<table class="table">
            <thead>
              <tr>
                <td align="left"><b>&lt;?php echo $text_directory; ?&gt;</b></td>
                <td align="left"><b>&lt;?php echo $text_status; ?&gt;</b></td>
              </tr>
            </thead>
            <tbody>
              <tr>
                <td>&lt;?php echo $cache . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($cache)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
              <tr>
                <td>&lt;?php echo $logs . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($logs)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
              <tr>
                <td>&lt;?php echo $download . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($download)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
              <tr>
                <td>&lt;?php echo $image . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($image)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
              <tr>
                <td>&lt;?php echo $image_cache . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($image_cache)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
              <tr>
                <td>&lt;?php echo $image_data . '/'; ?&gt;</td>
                <td>&lt;?php if (is_writable($image_data)) { ?&gt;
                  <span class="text-success">&lt;?php echo $text_writable; ?&gt;</span>
                  &lt;?php } else { ?&gt;
                  <span class="text-danger">&lt;?php echo $text_unwritable; ?&gt;</span>
                  &lt;?php } ?&gt;
                </td>
              </tr>
            </tbody>
          </table>
#2

[eluser]riwakawd[/eluser]
After finding out best way for folder check if have permissions. I spent most of after noon but have had to make custom call back and learned how to write permissions on xampp for folders.

All Working Now


Code:
&lt;?php

class Step2 extends MX_Controller {

public function index() {
  $this->lang->load('install/english', 'english');

  $this->lang->load('install/english', 'english');
  $this->load->library('form_validation');

  $this->form_validation->set_rules('cache', '', 'callback_isWritable');

  if($this->form_validation->run($this) == FALSE) {

  $this->document->setTitle($this->lang->line('heading_step_2'));

  $data['heading_step_2'] = $this->lang->line('heading_step_2');
  $data['heading_step_2_small'] = $this->lang->line('heading_step_2_small');

  $data['text_license'] = $this->lang->line('text_license');
  $data['text_installation'] = $this->lang->line('text_installation');
  $data['text_configuration'] = $this->lang->line('text_configuration');
  $data['text_finished'] = $this->lang->line('text_finished');
  $data['text_install_php'] = $this->lang->line('text_install_php');
  $data['text_install_extension'] = $this->lang->line('text_install_extension');
  $data['text_install_file'] = $this->lang->line('text_install_file');
  $data['text_install_directory'] = $this->lang->line('text_install_directory');
  $data['text_setting'] = $this->lang->line('text_setting');
  $data['text_current'] = $this->lang->line('text_current');
  $data['text_required'] = $this->lang->line('text_required');
  $data['text_extension'] = $this->lang->line('text_extension');
  $data['text_file'] = $this->lang->line('text_file');
  $data['text_directory'] = $this->lang->line('text_directory');
  $data['text_status'] = $this->lang->line('text_status');
  $data['text_on'] = $this->lang->line('text_on');
  $data['text_off'] = $this->lang->line('text_off');
  $data['text_missing'] = $this->lang->line('text_missing');
  $data['text_writable'] = $this->lang->line('text_writable');
  $data['text_unwritable'] = $this->lang->line('text_unwritable');
  $data['text_version'] = $this->lang->line('text_version');
  $data['text_global'] = $this->lang->line('text_global');
  $data['text_magic'] = $this->lang->line('text_magic');
  $data['text_upload'] = $this->lang->line('text_upload');
  $data['text_session'] = $this->lang->line('text_session');
  $data['text_global'] = $this->lang->line('text_global');
  $data['text_mysqli'] = $this->lang->line('text_mysqli');
  $data['text_mysql'] = $this->lang->line('text_mysql');
  $data['text_pgsql'] = $this->lang->line('text_pgsql');
  $data['text_gd'] = $this->lang->line('text_gd');
  $data['text_curl'] = $this->lang->line('text_curl');
  $data['text_mcrypt'] = $this->lang->line('text_mcrypt');
  $data['text_zip'] = $this->lang->line('text_zip');
  $data['text_mbstring'] = $this->lang->line('text_mbstring');

  $data['button_continue'] = $this->lang->line('button_continue');
  $data['button_back'] = $this->lang->line('button_back');

  $data['action'] = $this->url->link('step2');

  $data['php_version'] = phpversion();
  $data['register_globals'] = ini_get('register_globals');
  $data['magic_quotes_gpc'] = ini_get('magic_quotes_gpc');
  $data['file_uploads'] = ini_get('file_uploads');
  $data['session_auto_start'] = ini_get('session_auto_start');

  $data['mysql'] = extension_loaded('mysql');
  $data['mysqli'] = extension_loaded('mysqli');
  $data['pgsql'] = extension_loaded('pgsql');
  $data['gd'] = extension_loaded('gd');
  $data['curl'] = extension_loaded('curl');
  $data['mcrypt_encrypt'] = function_exists('mcrypt_encrypt');
  $data['zlib'] = extension_loaded('zlib');
  $data['iconv'] = function_exists('iconv');
  $data['mbstring'] = extension_loaded('mbstring');

  $data['config'] = FCPATH . APPPATH . 'config/config.php';

  $data['cache'] = FCPATH . APPPATH . 'cache';
  $data['logs'] = FCPATH . APPPATH . 'logs';
  $data['download'] = FCPATH . APPPATH . 'modules/download';
  $data['image'] = FCPATH . APPPATH . 'modules/image';
  $data['image_cache'] = FCPATH . APPPATH . 'modules/image/cache';
  $data['image_data'] = FCPATH . APPPATH . 'modules/image/catalog';

  $data['back'] = $this->url->link('step1');

  $this->response->setOutput($this->load->view('template/step2', $data));

  } else {

  redirect('step3');
  
  }

}

public function isWritable() {
    $folder_cache = FCPATH . APPPATH . 'cache';

    if (is_writable($folder_cache )) {
         return true;
    } else {
      $this->form_validation->set_message('isWritable', 'Cache Folder ' . '<b>' . $folder_cache . '</b>' . ' is not writable');
         return false;
    }    
}
}




Theme © iAndrew 2016 - Forum software by © MyBB