How can i generate a valid uri from a text string?
There should be a function/method in Kohana , which can do this?
Whats its called and how do i use it
URL::title() combined with URL::site() and Route::url() (in case you use routing)
It sounds like you might be describing the URL helper. Specifically, look at the static title and site methods. Your question is just a little vague, but these sound to me to be close to what you're asking.
Related
Okay. I know this question was a bit confusing, so let me decompose my question a bit further. For example, let's say I have the URL: https://example.com. I have an open GET endpoint at: https://example.com/user/* that will return a specific user's information based on what the contents of the "*" is. Lets say a specific user is at: https://example.com/user/12345. On an HTML page, I would like to put that user's profile contents and some of their hobbies. Again, this is theoretical. I have explored various solutions such as Handlebars.js which can dynamically change values based on the server request. However, this solution does not always work. Take a search engine for example at: https://mysearchengine.com/search?query=dogs. Here, we have a search query for dogs. How do I render all of the results to a HTML document without using a dynamic content module like Handlebars?
This question was particularly difficult to ask, so please do not mark this as "not enough information". I would be more than happy to clarify any questions you may have about the nature of my query. Thank you so much in advance,
Flight Dude.
Just wanted to let y'all know I found my answer: EJS. Thanks!
Let's say I have the word "catheter". A user tries to search on my web app for that word but spells it "cathiter" or "cattiter" instead. How can I use SphinxQL to match the word from my SQL database based on the incorrectly spelled word? What would my query look like? Do I need to enable something in my index on my conf file? From my understanding, enable_star has been deprecated.
Yes, enable_star=0 has been depreciated, but not sure how that relevant!
Anyway sounds like you want the CALL SUGGEST function
http://sphinxsearch.com/blog/2016/10/03/2-3-2-feature-built-in-suggests/
The defuult settings a good place to start...
CALL QSUGGEST('cathiter','yourindex');
... if you dont min_infix_len defined on index, will need that. Alao dict=keywords - for some reason that requirement not mentioned in blog post.
Hey guys! Working on a new Cake app and wondering if there is anyway for me to remove the ID-in-URL routing from Cake. Perhaps by passing the ID in POST somehow? Having the ID passed in as a URL param just seems really shoddy and unsafe. Thanks!
"Shoddy"? It's standard practice and a perfectly fine solution to have ids in the URL. Look at the URL of your question:
http://stackoverflow.com/questions/4638262/removing-id-from-cakephp-url
^^^^^^^
id
Also, there's absolutely nothing unsafe about showing an id in a URL. It's just a number that doesn't mean anything. If a user can do something "bad" only by knowing this id, your app is broken and insecure, not the id-passing mechanism.
Trying to work around this scheme means working around the fundamental principle of the HTML protocol and opens up a whole new can of worms.
Some people prefer using slugs instead of primary key ids. This is the removing-id-from-cakephp-url part of the URL from this page. Take a look at the SluggableBehavior.
However, slugs can change. Hence, having the primary key in your URL is useful if you want to have a permalink. StackOverflow does both so that it can support both permalinking from other sites, as well as for SEO reasons. :)
Regarding security issues, I guess the other answers have already pointed out that there are other ways to make your application secure.
Why do you care? URL-s are optimized for SEO reasons, an ID won't matter if it's ain't too long. If the latter, consider using a shorter one with numbers and letters in them instead, it will be as difficult to guess as a long one with just numbers.
If you are not using GET and you do not supply the params in the URL, your users won't be able to copy-paste the location.
Id like to make a url similar to stackoverflow where the user can type in a textbox and then on refresh a url is created. like the url to this question uses the title i typed in. id like to make that effect on my own site. thanks. I think this may have to incorporate a .htaccess file??
You may notice that the words from the title in the question URL don't affect where the URL goes. The following link goes to the same place: https://stackoverflow.com/questions/6366169/foo-bar-baz
All you need to do is make your server process respond to the URL in the correct way. How you do this will depend on your chosen server architecture and/or programming language. Using .htaccess is unrelated.
maybe this link will help you understand how you can achieve your goal https://docs.djangoproject.com/en/dev/topics/http/urls/ (django)
http://www.phpaddiction.com/tags/axial/url-routing-with-php-part-one/ (php)
other web frameworks operate in similar way
in the given example you can interpret the url http://stackoverflow.com/posts/9701416/edit like this:
if you find "posts" in the url the next part of the url (9701416) is a parameter and the last part is the action so your main controller will load a post with id 9701416 and it will be loaded in edit mode (it doesn't mean there's a sub directory questions with sub directory 6366169 with a file "post")
I'm fairly new on CakePHP and because of so, there are some basic things that I used to do with Zend Framework that I'm beaten up with Cake.
I'm working on a project where I have to pass a named parameter to a controller / action. Setting up the route and passing the parameter is fairly simple, my problem is when the parameter is a urlencoded url.
For example: http://www.cakephp.com/controller/action/http%3A%2F%2Fwww.google.com regardless of the controller and action setup, will throw a 404, but passing /controller/action/http://www.google.com work in some way, the only problem is that it identifies the http as a named parameter. In another way, if I do /controller/action?url=http://www.google.com it will work.
The work around that I had used for this is to pass the value as a base64 encoded string, but it brings some limitations. For instance, if it is an API, there is no way that you can guarantee that the system using the API can encode base64 a string.
Anyway the best solution would be still passing a url encoded string to a named parameter. Question is, why CakePHP does not accept a urlencoded string as a parameter and why does it throws a 404?
Thanks all in advance.
I have added a work around this issue. The previous answer that pointed to a post actually answered why it was happening and one of the solutions. What happens is that the workaround for .htaccess on Apache is a bit dangerous because it will disable a security criteria.
There are 2 ways to work this out via code (and I'm using both):
Send all urls as base64 encoded strings
Accept the urls as named params, but, as you will notice, it converts any http:// to http:/, so is necessary to correctly identify when this happens and only then correct the string.
It is far from being a beautiful solution, but it is definitely a practical one.
I stumbled upon this same problem in Cakephp 4.x
Apparantly you can create a custom route with ** that will disable the default urldecoding. Fixing the problem.
So right now I throw a base64_encode(Security::encrypt($val)) value into the Router::url() function. This will url_encode the params by default so it becomes a valid/working url.
Cakephp then urldecodes by default, which is good. But it does it twice? Causing it to split up the params if there is a / present. Which isn't good.
So in my routes.php I added:
$builder->connect('/orders/callback/**', ['controller' => 'orders', 'action' => 'callback']);
Kinda annoying how this works, but it works now. Works like a charm in 4.x and cost me the entire afternoon. Just leaving this here in case anyone else has this problem. (and for future me).
Source: https://github.com/cakephp/cakephp/issues/4723#issuecomment-56912905