| CARVIEW |
I have a fresh Virtual Dedicated Server for my Codeigniter application.
And i have no experience to configure a VDS so far.
In Simple Control Panel it shows several services are installed already. Like:
Cron Scheduler
Cyrus POP3/IMAP
HTTP Web Server (Apache 2)
MySQL Database
Postfix Mail Server
SSH Remote Login Server
Simple Control Panel
Very Secure FTP Server
Do you think i need anything more to run a CodeIgniter application here in this VDS?
or can start running my application with this?
Also how can i make my server more secure?
Thanks.
]]>Because I seem to be having an issue with a template editing controller I wrote, which uses the ftp class, to connect to make folders, or chmod directorys from 755 to 777, of course this isn’t really possible on a windows server, but my problem below is unrelated to that.
function create()
{
#CREATION OF A NEW TEMPLATE FOLDER, DO FORM VALIDATION
$this->load->library('form_validation');
$this->form_validation->set_rules('new_folder', 'new_folder', 'required|xss_clean');
if ($this->form_validation->run() == FALSE)
{
#VIEW FILE INFORMATION
$data['heading'] = "Create New Theme/Template";
$data['get_dir'] = directory_map('./themes/');
$data['get_dir_temp'] = directory_map('./system/application/views/themes/');
$data['page'] = 'admin/template/create_template';
$this->load->vars($data);
$this->load->view($this->_container);
}
else
{
#FTP CONNECT, TO BEGIN CREATING NEW FOLDER
$config = $this->ftp_one();
$this->ftp->connect($config);
#CREATE DIRECTORYS AND CLOSE FTP CONNECTION
$this->ftp->mkdir($this->input->post('new_folder'), DIR_WRITE_MODE);
$this->ftp->mkdir($this->input->post('new_folder') . '/img', DIR_WRITE_MODE);
$this->ftp->mkdir($this->input->post('new_folder') . '/js', DIR_WRITE_MODE);
$this->ftp->mkdir($this->input->post('new_folder') . '/css', DIR_WRITE_MODE);
$this->ftp->close();
#FTP CONNECT FOR CREATING SECOND THEME FOLDER
$config = $this->ftp_two();
$this->ftp->connect(@$config);
#CREATE DIRECTORYS AND CLOSE FTP CONNECTION
$this->ftp->mkdir($this->input->post('new_folder'), DIR_WRITE_MODE);
$this->ftp->close();
#VIEW FILE INFORMATION
$data['heading'] = "New Template Created!";
$data['page'] = 'admin/template/create_temp_success';
$this->load->vars($data);
$this->load->view($this->_container);
}
}
It seems to be crashing on this line
$this->ftp->mkdir($this->input->post('new_folder') . '/img', DIR_WRITE_MODE);
I don’t actually know whats wrong because all I get is a 500 error.
It makes the first folder which you type into the new_folder field, but won’t create the sub directory’s after that or do anything past that line.
Does anyone have a solution to this?
Next problem I have is I have a read_file, write_file, it seems it can’t read the file at all.
function modify_file_template()
{
#CHECK IF FILE INFORMATION IS IN SEGMENT 5, AND THEME NAME IS IN SEGMENT 4
if($this->uri->segment(4) == '' OR $this->uri->segment(5) == '')
{
echo "Direct Access Not Allowed";
}
else
{
#DO FORM VALIDATION
$this->load->library('form_validation');
$this->form_validation->set_rules('file_contents', 'file_contents', 'required');
if ($this->form_validation->run() == FALSE)
{
#VIEW FILE INFORMATION
$data['heading'] = "Modify File";
$data['get_dir'] = directory_map('./themes/');
$data['get_dir_temp'] = directory_map('./system/application/views/themes/');
foreach($data['get_dir'] as $data['dir'] => $data['dir_value'])
{
$data['get_files'] = directory_map('./themes/' . $this->uri->segment(4) . '/css/', TRUE);
}
foreach($data['get_dir_temp'] as $data['dir_temp'] => $data['dir_value_temp'])
{
$data['get_files_temp'] = directory_map('./system/application/views/themes/' . $this->uri->segment(4) . '/', TRUE);
}
$data['newfilesegment'] = str_replace('_php', '', $this->uri->segment(5));
$data['read_file'] = read_file('./system/application/views/themes/' . $this->uri->segment(4) . '/' . $data['newfilesegment'] . '.php');
$data['page'] = 'admin/template/modify_file_template';
$this->load->vars($data);
$this->load->view($this->_container);
}
else
{
#CONNECT TO FTP, TO BEGIN FILE SAVING PROCEEDURE
$config = $this->ftp_two();
$this->ftp->connect(@$config);
#String replace segment 5, remove _php extension
$data['newfilesegment'] = str_replace('_php', '', $this->uri->segment(5));
#chmod the directory and file selected to writeable (777)
$this->ftp->chmod('/' . $this->uri->segment(4) . '/', DIR_WRITE_MODE);
$this->ftp->chmod('/' . $this->uri->segment(4) . '/' . $data['newfilesegment'] . '.php', DIR_WRITE_MODE);
#SAVE THE FILE AFTER CHANGES ARE MADE (ON SUBMIT)
write_file('./system/application/views/themes/' . $this->uri->segment(4) . '/' . $data['newfilesegment'] . '.php', $this->input->post('file_contents'));
#Saving is complete, now protect the files/directorys via chmod to read/excute mode (755)
$this->ftp->chmod('/' . $this->uri->segment(4) . '/', DIR_READ_MODE);
$this->ftp->chmod('/' . $this->uri->segment(4) . '/' . $data['newfilesegment'] . '.php' , DIR_READ_MODE);
#Now close the ftp connection, and display flash data message of successful file written!
$this->ftp->close();
$msg = $this->lang->line('file_written');
$this->session->set_flashdata('flashmsg', $msg);
#redirect back to the selected template files list
redirect('admin/template/edit_file/' . $this->uri->segment(4));
}
}
}
I tried full server paths to no avail… Any suggestions on getting this to work?
Like I mentioned this code works perfectly on unix/linux servers.
Thanks :)
]]>This new version has been created to be compatible with CodeIgniter versions 1.7 and 2.0
https://bitbucket.org/wiredesignz/codeigniter-modular-extensions-hmvc
Feedback is appreciated.
Note: Controllers must extend the MX_Controller class to use the HMVC design pattern.
]]>
/root
index.php
/system
(other system folders)
/applications
/public
/controllers
//config
/models
/views
etc...
/admincp
/controllers
/config
/models
/views
etc...
you get the idea!
If read up on other tutorials that say you need an index.php in each application folder. so there would be an applications/public/index.php which would have the $application_folder variable set to “applications/public”.
When I go to localhost/admincp, i get a 404 not found error. Could someone please help me with this?
]]>My question is, since CodeIgniter is open-source, am I able to do this legally? I would assume so, since people also sell third-party modules for ExpressionEngine and the code is open-source after all.
I really appreciate any responses. Thanks!
]]>I have an array of elements and I want to validate the whole row of element based on the value of field1. If field1 has no value then myfunc should return TRUE and will skip any validation from the function.
$rules = array(
array(
'field' => 'field1[]',
'rules' => 'required'
), array(
'field' => 'field2[]',
'rules' => 'required|callback_myfunc'
));
function myfunc($field1, ???$field2???){
if($field2=="") return TRUE;
//code extra validations
}
“Fatal error: Call to a member function num_rows() on a non-object in /home/domain/public_html/sub directory/application/models/applicationmodel.php on line 89”..
this my code below, thanks for your help guys [sorry bad eng :D ]
=========================================================================================
{
$this->db->select(‘lang_code, lang_name’);
$this->db->from(‘languages’);
$langQuery = $this->db->get();
$languages = array();
if ($langQuery->num_rows() > 0)
{
foreach ($langQuery->result_array() as $langRow)
{
$languages[] = $langRow;
}
}
return $languages;
}
=========================================================================================
I am new to CodeIgniter, and i am following the tutorials on NET TUTS.
When i am trying to send a email with subject, message and attached file, i just receive a email with only the subject. Here is the code
$name = $this->input->post('name');
$email = $this->input->post('email');
$this->load->library('email');
$this->email->set_newline("\r\n");
$this->email->from('petar.blazevski@gmail.com', 'Petar Blazevski');
$this->email->to($email);
$this->email->subject('Test Newsletter Singup Confirmation');
$this->email->message('You\'ve now singed up, fool!');
$path = $this->config->item('server_root');
$file = $path . '/CodeIgniter/attachments/yourInfo.txt';
$this->email->attach($file);
if($this->email->send()) {
echo 'Email Send!';
} else {
show_error($this->email->print_debugger());
}
and here is my configuration
$config['protocol'] = 'smtp';
$config['smtp_host'] = 'ssl://smtp.gmail.com';
$config['smtp_port'] = 465;
$config['smtp_user'] = 'petar.blazevski@gmail.com';
$config['smtp_pass'] = '*******';
which is in a separate file in the config folder.
I don’t know what am i doing wrong, can someone help me?
I am working on Ubuntu Linux
Did some digging in the error logs:
PHP Fatal error: SUHOSIN - Use of eval is forbidden by configuration in /... path to project ... /system/database/DB.php(118) : eval()‘d code on line 118
The server I have to work on is protected with the Suhosin Extension 0.9.23
I checked the PHP config on the server, indeed it mentions Suhosin, and I see the following:
suhosin.executor.disable_eval = On
I know it’s kinda off-topic as has probably nothing to do with CI, but I got to ask this.\
1. Do you know if setting suhosin.executor.disable_eval = Off is potentially dangerous?
2. Is Suhosin still relevant?
(must say I haven’t encountered many servers with Suhosin installed so far)
Everything else inserts into the database correctly. Just need yyyy-mm-dd to insert now.
I wish to do this in my controller, please take a look at my code and you’ll see where I want to place this code.
My code
public function submit() {
$u = new User();
$u->first_name = $this->input->post('first_name');
$u->last_name = $this->input->post('first_name');
$u->email = $this->input->post('email');
$u->password = $this->input->post('password');
//day
//month
//year
$u->sex = $this->input->post('sex');
$u->save();
$this->load->view('submit_success'); // temporary account area page
}
}