Installing secure CodeIgniter with Sparks - codeigniter

Installing Sparks assumes that you are abiding by the default CodeIgniter installation pattern; extracting the application, system, and user guide folders, along with with a index.php and a license file into your web root.
However, many of us pull the application and system folders out of the web root for security reasons and re-route the $system_path and $application_folder variables in the main index.php file.
This separation tends to break Spark installs. In particular, the simple example-spark used in the getsparks installation instructions.
Getting an error:
An Error Was Encountered Cannot find
spark path at
sparks/example-spark/1.0.0/
I maintain the following directory structure:
CISYS
V202
V200
project1_application
project2_application
project3_application
www (public html)
project1
css
js
images
etc
project2
etc
What must I reroute to achieve both security + sparks? Open to suggestions of any sort. How do you set up your installation?

To answer my own question: The solution was in the MY_Loader.php file. By modifying the SPARKPATH variable on line 43, one can reroute the location of all sparks! Cheers!

Related

MAMP/WAMP - Which process is yours to alternate between your online websites (URLs, https, ssl) and local developpment (URLs, https,ssl)

how is it adviced to alternate between online and local development, since you want to modify your websites on local.
Do you systematically change all URLs (by search/replace) in your project code to fit local URL type and sometimes create personal SSL certificate for https, or do you use another solution like localhost aliases, rewrite rules, or online developpement tools?
What could be an automatic solution in order to avoid this fastidious modifications like search/replace sometimes looking quite primitive and time costing since I develop during the few hours left after my main work.
What are the operation modes to facilitate developpment,
Have a nice day,
for all the biginners, here's the thing.
I've created a config.php file which contains constants: one config file for the local project folder and one for the online server folder.
Inside this config file, I've create a constant (constant are then available everywhere in the project) to define the main URL of the project. e.g.:
define('CST_MAIN_URL',http://www.myproject.com); // for the online config.php file
define('CST_MAIN_URL',http://localhost:8888); // for the local config.php file
Thus, each header or redirection can work with that constant, like:
header('location:' . CST_MAIN_URL . 'index.php');
Then, things must have to do with RewriteEngine in your htaccess file, for instance whenever you must modify the behavior of MAMP/WAMP if an interrogation point or a slash provokes you with its malicious resistance. But, unfortunately RegEx expression must be understood as a basic level for mastering those url rewritings.
Hope it'll helps.

How to name api routing on a webhost sub folder

I have always thought the api controllers where not found by physical paths. The reason I ask is I have a website example.com I created a folder example.com/testing and uploaded my project to there. When I ran it I got errors saying that none of the apiControllers could be found. So I changed /api/apiCustomers to /testing/api/apiCustomers. It then worked, well not the actual posting of any new records. It did locate and retrieve all the records from the database though. But it doesn't seem like that is what I would actually need to do? I have a domain with WinHost and the default publish folder is example.com/myApp
AM I looking at this the wrong way?
To handle request where you do not know the root path, you can use (as in ASP.NET) the ~-character like this:
~/api/apiCustomers
~ will then be replaced by the root (i.e. /api/apiCustomers for prod and /testing/api/apiCustomers for your test environment)

CodeIgniter routing issues with subdirectories

I am working on a web app that is located in a child folder of a folder in my htdocs. Like this:
http://localhost/folder/another_folder/index.php
I can force routing to my controllers by getting:
http://localhost/folder/another_folder/index.php/controller
But I cannot get my routes to behave as expected:
$route['auth/login/(:any)/(:any)'] = 'auth/login/$1/$2';
I also tried:
$route['auth/login/(:any)/(:any)'] = 'folder/another_folder/auth/login/$1/$2';
$route['another_folder/login(:any)/(:any)'] = 'auth/login/$1/$2';
And various other permutations. In all cases I get CI 404s or standard 404s. I need a solution that is portable, so when I publish this in the test server where it'll be at on level of subdirectory, and when I publish to production where it'll be root I only need to change one (or fewer!) lines of code. Thanks for your insight!
Configuring base_url in config.php seems to be the trick for this!

With GroceryCrud, how can I put uploads above application root?

I'm using GroceryCRUD to act as a front end for a database containing news releases. Secretaries can go in and add/edit/delete news releases in the database easily now. Only qualified users are able to access the application root via an .htaccess password. The problem with this is that GroceryCRUD uploads assets such as photos are uploaded to the directory /www/approot/assets/uploads/ which is password protected since /approot/ is protected.
My ideal solution would be to set an upload directory outside of the application root which is where I'm running into trouble. By default this is how GroceryCRUD handles uploads:
$this->grocery_crud->set_field_upload('photo1','assets/uploads/');
I've tried changing it to something like this:
$this->grocery_crud->set_field_upload('photo1','/public/assets/uploads/');
I was hoping this / would make the path start from the document root instead of the application root, but it throws this error:
PHP Fatal error: Uncaught exception 'Exception' with message 'It
seems that the folder "/Users/myusername/www/approot//public/assets/uploads/"
for the field name "photo1" doesn't exists.
This seems to suggest that CI or GroceryCRUD just takes the second argument in set_upload field and just concatenates it onto the end of the site URL that is defined. Is there any way around this that doesn't involve creating a user login system?
Try using relative path.
$this->grocery_crud->set_field_upload('photo1','../assets/uploads/');
.. -> Go up one directory
I ended up implementing a login system outlined in this tutorial:
http://net.tutsplus.com/tutorials/php/easy-authentication-with-codeigniter/
It was quite simple to set up and suits my needs. I found ways to give access to the directory using httpd.conf directives but I feel like this was a more viable solution since I don't have direct access to server configuration files.
Maybe in the future GroceryCRUD will allow placement of uploads outside the application folder.

Changing static files directory in MVC3 causes 404

I'm attempting to set up my own directory structure for serving up static files:
\s (statics)
\c (css)
\j (js)
\i (images)
etc ...
The issue is that I'm seeing a 404 for this directory when referencing it. When I inspect the file path, it is pointing to the correct location localhost:port/s/c/style.css, but for some reason it can't find the file.
Is there a way that I can make this path available via my Web.config, or possibly through my Global.asax file via routes? I've heard there are performance penalties associated with using routes, so using the Web.config - or an alternative solution - is preferred.
http://localhost:port/s/c/style.css should work without any problems. It seems that you have specified a wrong filename which is the reason for the 404 error.

Resources