How to Delete Cached Web Page by URI in CodeIgniter - codeigniter

I want to clear the cache for a particular page (URL). In Codeigniter, we don't have this option by default. So, how can I achieve it?

Finally, I got the solution for my question.
The URI for which I want to clear the cache is dell-laptops
My entire URL is http://www.domainname.com/dell-laptops
Method to clear the cache for dell-laptops URI is
public function delcach(){
$gurl = $this->input->get('del');
$this->output->delete_cache($gurl);
redirect('/');
}
Now you need to just pass a parameter del .And how it looks like is
http://domainname.com/controllername/delcache?del=dell-laptops
Opening above URL will clear the cache page of dell-laptops
That's it.
Hope this may help others.

Related

CodeIgniter URL Encryption

All Viewers I am New in Codeigniter, I need your guide to done my work, I want to Encrypted full URL like below example.
For example this is my url www.example.com & my controller is home, so full url is www.example.com/home
now I want to encrypted all controller, function like below
www.example.com/5115784bef2514430e7f74d9a71d4142a942efb0f7cc428626bda7633326f9d015fbacc60d93cd6b858f9b6e05c1e56263acb24297cecc720467eb4f222d81e5hdn5B
I can encrypted & decrypted the text well, but I just don't get how can I decrypted from url & make understand which controller or function its called, I want to decrypted everything after base_url.
please don't suggest me about using common controller, because I already know that & anyhow common controller its hide everything so its not required the encryption as I believe.
Waiting for your positive response, hopefully my problem will be solve soon. T.I.A
Well i never encrypt any URL before but you can use a php function url_encode
And "str_replace" function.
the reason for using "str_replace" beacause url_encode only encode special character in URL.
Hope I help some.
Try the code below.
urlencode(str_replace("your_domain.com/YourCOntrollerName/YourMethodName" , "SM5ah52" , yor_domain.com . "YourCOntrollerName/YourMethodName/YOuData"));
If not this. There is an library in CI Framework called Encryption.
You can get help from there Encryption.
Go with URI Routing and define one controller to decode whatever you are passing, and call proper controller / method from it.
You can use URI Routing with regular expressions.
$route["other_controllers/method"] = "other_controllers/method"; //you can add this kind of lines to not to affect other controllers
$route["([a-zA-Z0-9]+)"] = "home/decrypt/$1";
In the home controller, You can
Redirect to the page
Or
Load a view
public function decrypt($token){
//geting the page according to the token from database.
$desired_page = $this->some_model->get_page($token);
//if you want to redirect
redirect($desired_page);
//if you want to load a view
$this->load->view($desired_page);
}

Laravel and redirect->back or something?

I need someway to redirect my app to a previous url.
The problem comes when i make a submit that goes wrong, the redirect->back previous url is someway "overwrited" and i cannot get the previous real url anymore, instead the app makes the submit again.
The only thing that i tried is the redirect back, because i can't find another way to do it :S
So i´m wondering if there is a way to achieve that, redirect the app to a previous url without considering the submit fails and all this stuff.
Thank you.
Yo can try with:
return Redirect::to(URL::previous());
You can store URLs in session and then make Laravel redirect 2 or 3 pages back. Simple example of code to store URL in session:
$links = session->has('links') ? session('links') : []; // Get data from session
array_unshift($links, $_SERVER['REQUEST_URI']); // Add current URI to an array
session(compact('links')); // Save an array to session
And example of code for redirecting:
return redirect(session('links')[2]);

CakePHP session data cleared on paginator sort

My session data is being saved in my form as expected.
However, when I run a sort on any column of my results, my form session values are cleared.
I am calling in my search form through en element as it's used on specific locations of the site.
Does anyone know why pagination is clearing out my session? Is this standard Cake?
The paginator sort elements are simply a link generated by the paginator and won't consider any of your form data. The first thing you need to make sure that you're doing is tell the paginator to include any URL paramters for the current page in the url it generates. Put this anywhere in the view before you call any of the $paginator functions.
$paginator->options(array('url' => $this->passedArgs));
Secondly, make sure that your search parameters are being included in the URL. It sounds like they probably aren't. I just answered another question on the best practices of search result URLs here: CakePHP Search Results Best Practices
I solved this:
CakePHP session ID path or other method to share the results of a url - recommendations welcome

htaccess redirection for #! in urls

I am using ajax to load pages on my website.
Each time a page is loaded I change the url in the browser to
http//www.example.com/old/page/#!/new/page/
by setting it through window.loaction using javascript
Now what I want to do is when someone comes to my website by entering the url
http//www.example.com/old/page/#!/new/page/
he should automatically get redirected to
http//www.example.com/new/page/
This is somewhat that happens on facebook too.
Can someone help me out with the required .htaccess code to achieve the same.
Thanks in advance
I don't think anything past the # symbol in your URL is even visible on the server side. So htaccess, php, etc won't even know the hash is there to begin with. I think in order to pull this off you're going to have to use a client side redirect.
window.onload = function(){
// First we use a regex to check for the #! pattern in the hash
if(window.location.hash.match(/\#\!/i)){
// If we found a match, use substring to remove the #! and do a redirect
window.location = window.location.hash.substring(2);
}
};
This example will redirect the user immediately on page load. Unfortunately doing a redirect in this manner won't help the search engines to reindex your site, but thats just one of the pitfalls of using fancy javascript or hash based URL's.

How to find the non-SEF URL whilst SEF is enabled (Joomla 1.5)?

I know you probably don't get many questions like this...
I am working on a component that I want to be able to deal with the non-SEF URLs whilst SEF is enabled, whether it be the built-in SEF or something like sh404sef.
Does Joomla store the ORIGINAL non-SEF URL anywhere ie. index.php?com=com_fred&view=homepage?
I've found that any SEF activated, changes the JURI::getInstance() value to the SEF equivilant.
I've also found the the $REQUEST['URI'] value does not work on all platforms/servers etc.
Thanks for any help
Get all vars from the GET/POST request into an array. At this point you may also modify the values before generating the URL string.
$getVars = JRequest::get( 'GET' );
If you really need the URL string, you can obtained with:
$newURL = http_build_query($getVars);
Hope it helps!
I came back to this code and tried again but gave me some errors, so I've reworked it partially based on the previous answer I've formulated before with this new one (working nice on Joomla! 3.4.5)
// build the JInput object
$jinput = JFactory::getApplication()->input;
// retrieve the array of values from the request (stored in the application environment) to form the query
$uriQuery = $jinput->getArray();
// build the the query as a string
echo 'index.php?' . JUri::buildQuery($uriQuery);
Joomla! API Docs: JInput - JUri
PREVIOUS ANSWER:
Googling around I found this:
<?php
// "unparse" the Joomla SEF url to get the internal joomla URL
JURI::current();// It's very strange, but without this line at least Joomla 3 fails to fulfill the task
$router =& JSite::getRouter();// get router
$query = $router->parse(JURI::getInstance()); // Get the real joomla query as an array - parse current joomla link
$url = 'index.php?'.JURI::getInstance()->buildQuery($query);
?>
I've tested it with Joomla! 3.4.4 and its working fine! Dunno if it can work with 1.5
You can use JRequest::get(true) to get an array of all the query parameters from the URL. A quick note though, I haven't checked it enough to know if it only returns GET parameters or it does all REQUEST parameters (which I think is more likely). It might, however, help with what you're looking for.
For menu items, it's stored in the 'jos_menu' table, in the 'link' column (but the itemid is not in this string - it's the 'id' column).
For anything else, it's probably not stored in the database, but can normally be worked out pretty easily, especially with core components. It can be a little bit of a pain with third party components, but you can look through the MVC architecture of most components to figure it out.
Otherwise, you could always turn off SEF on your dev site/create a dev site for this.
Is there a specific component that you're curious about?
The link that I posted here:
Joomla URLs: An article doesn't have a pretty URL by itself?
provides a very good "crash course" for URLs in Joomla 1.5
You don't have to do anything special for non-SEF URLs. Even if you have SEF URLs turned on, Joomla will still display the correct page if someone access the site with a non-SEF URL. The portion of your component that handles SEF URLs, the router, only tells Joomla how to use the URL information to determine what to display. When presented with a non-SEF URL Joomla just parses the query string as it normally would.
For any given component, the URL is built like this -
index.php?option=com_name&view=XXXX&id=1111&Itemid=11111
option is the name of the component
view is of course which view to display
id is the id of the particular content item
itemid is the menu item it used to determine module/template assignment

Resources