Right now i am working on a Codeigniter project in which I am sending a link to the user to update their password, every thing is working according to the plan. Now all I need to know is that how can I extract data from URL that the user is following to update password.
Example:
http://localhost/ciauth/user/password_reset/user#gmail.com/6f1bb1aeba261e92c390ac28d85267767038703e
I want to extract the code after the E-mail ID.
Never mind i have solved it doing
$url_code=$this->uri->segment(4);
This is okay. But it will be better if you implement it with your action function:
public function password_reset($email, $code){
// $email: user#gmail.com
// $code: 6f1bb1aeba261e92c390ac28d85267767038703e
}
Try this, From this you can do extract full url, Place below code to your password_reset() to see your url extraction
echo'<pre>';print_r($this->uri->segment_array());die;
Never mind i have solved it doing
$url_code=$this->uri->segment(4);
Related
I am using RsForm pro on Joomla 3.5. I am working on a form where I submit the data to an API.
RsForm has it's own syntax for posting data. For example:
If I have a text field called requester, I post data using following syntax:
$_POST['form']['requester']
For a drop-down with time values, its:
$_POST['form']['time']['0']
Similarly, I need to post an attachment. But I do not find the syntax to do so on RsForm documentation nor am I able to post a question there since my colleague who owns the credentials to login to RsForm site is on holiday. Hence I post the question here.
Also, it looks like after upload the file is renamed. I would like to add a piece of PHP code which can rename the file and I can store the file name in a variable which I can use in the call to the API.
Any help here would be appreciated, since I need to finish the form as soon as possible.
Thanks,
Pooja
After doing a complete research on this I came up with the following
While creating an attachment you will get an Attributes Tab. To generate a prefix dynamically you can specify the code in between the //<code> and //</code>
For example
//<code>
return $_POST['form']['name_field'];
//</code>
Check this snapshot
If you want to keep the same file name without any prefix than simply do this
//<code>
return '';
//</code>
These files can than be easily linked the way you have said in the comments. For more details you can check this link https://www.rsjoomla.com/support/documentation/rsform-pro/form-fields/file-upload.html
EDIT:
To get the absolute path to your attachments you can use this
$path = JPATH_BASE .'/components/com_rsform/uploads/';
$uploadfile = $path . $_POST['form']['attachment'] ;
I have a textarea in my front-end which accepts the google map code which is an iframe. When I tried to update it, the query fails. The values is not getting inserted into the database. I use text for saving iframe in db. The code I use in model :
function save(){
$data['cmpny_address'] = $this->input->post('cmpny_address');
$data['cmpny_map'] = $this->input->post('cmpny_map');
$this->db->where('id',1);
$this->db->update('contact_us', $data);
}
I have tried sanitizing the input with htmlspecialchars, strip_tags, $this->db->escape etc. I have actually tried all the suggestions from related SO questions. But no luck. Somebody please suggest a way to fix the issue.
EDIT:
It is the <iframe></iframe> that is creating the problem. <p></p> , <h1></h1> gets through without any error.
(Posted on behalf of the OP).
It was a server issue. The support team said "modsecurity was blocking it".
No need to write any htmlspecialcharsand strip_tags Active record automatically handle all those thing.
Use set method to update your data
function save(){
$this->db->set("cmpny_address", $this->input->post('cmpny_address'));
$this->db->set("cmpny_map", $this->input->post('cmpny_map'));
$this->db->where('id',1);
$this->db->update('contact_us');
}
OR
create you data array like
$data=array('cmpny_address'=>$this->input->post('cmpny_address'),'cmpny_map'=>$this->input->post('cmpny_map'));
$this->db->where('id',1);
$this->db->update('contact_us', $data);
UPDATED
To send iframe into post you have to set
$config['global_xss_filtering'] = FALSE;
In your config.php file
I've made it so when you click on a certain link it changes the url to mywebsite.com/page.php#certainusername
How can I make it so when the url contains someone's certain username, an object containing
data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=certainusername"
will change certain username to the username in #?
Check out the parse_url function. You should be able to get the fragment (hashmark thing) from that.
Not sure what kind of change you are talking about... So here are 3 different types of methods to access the "#certainusername"
CSS
:target {
background: yellow;
}
(Source)
PHP
parse_url($url, PHP_URL_FRAGMENT)
// or
parse_url($url)['fragment']
// then do stuff ...
(Source)
JavaScript
window.location.hash
(Source)
For the question, I assume that you're not working with any framework. Given this, I'll give you a simple answer.
Steps:
1 - Get the username out of the URL.
2 - Generate the view dynamically.
Explanation:
1 - I would recommend using a query string of the following format: mywebsite.com/page.php?username=certainusername (instead of using a #)
Then you can use $_GET to obtain the username (Please, read more about the security implications: http://php.net/manual/en/reserved.variables.get.php).
2 - If you're using PHP to generate the HTML code directly, the only thing that you need to do is:
... HTML in here ...
data="http://www.twitch.tv/widgets/live_embed_player.swf?channel=<?php echo $username; ?>"
... more HTML ...
(Assuming that the variable $username contains the username obtained from the URL).
This is a very simple scenario and there are a lot of other things to consider that are out of the scope of the question.
One solution to automatically building navigation for a site is by scanning a folder for documents like this:
foreach(glob('pages/*.pg.php') as $_SITE_NAV_filePath):
$_SITE_NAV_filePath = explode('.pg',pathinfo($_SITE_NAV_filePath,PATHINFO_FILENAME));
$_SITE_NAV_fileName = $_SITE_NAV_filePath[0];
$_SITE_NAV_qv = preg_replace('/([A-Z])/','-$1',$_SITE_NAV_fileName); $_SITE_NAV_qv = trim($_SITE_NAV_qv,'-');
$_SITE_NAV_name = preg_replace('/([A-Z])/',' $1',$_SITE_NAV_fileName);
?>
<li><?=$_SITE_NAV_name?></li>
<?php
endforeach;
This code will turn "AnAwesomePage.pg.php" into a menu item like this :
<li>An Awesome Page</li>
This might be bad practice (?).
Anyway; I don't use this method very often since most of the time the sites have a database, and with that comes better solutions...
But my question is this:
Is there a way to prefix the filename with a integer followed by and underscore (3_AnAwesomePage.pg.php), for sorting order purposes, and pass it somehow to the destination page outside of the querystring and without any async javascript?
I could just explode the filename once again on "_" to get the sort order and store it somewhere, somehow?
This is the code for handeling the page query request:
$_SITE_PAGE['qv'] = $_GET['page'];
if (empty($_SITE_PAGE['qv'])){ $_SITE_PAGE['qv'] = explode('-','Home'); }
else { $_SITE_PAGE['qv'] = explode('-',$_GET['page']); }
$_SITE_PAGE['file'] = 'pages/'.implode($_SITE_PAGE['qv']).'.pg.php';
This code turns "An-Awesome-Page" back into "AnAwesomePage.pg.php" so it's possible to include it with php.
But with a prefix, it's not so easy.
The probliem is; Now there's no way to know what prefix number there was before since it has been stripped away from the query string. So I need to send it somehow along in the "background".
One very bad solution I came up with was to transform the navigation link into a form button and just _POST the prefix interger along with the form. At fist it sounded like a nice solution, but then I realized that once a user refreshes their page, it didn't look very good. And after all, that's not what forms are for either...
Any good solutions out there?
Or some other and better way for dealing with this?
There are two ways to keep that number saved, you can use cookies or php session variables.
But in this case, if user first enter the url in the browser or in a new browser, then he should be taken to default number.
Like you have:
1_first-page.php
2_first-page.php
3_first-page.php
If user enter the url like: domain.com/?page=first-page, you have to take him to 1_first-page.php to any number which you want to be default.
I'm trying to write some code which shares a page on Facebook and twitter.
The problem I'm facing is that the page I'm trying to share has a big query string like:
http://domain.com/see.php?c=3&a=123&v=1
But it seems that Facebook and Twitter don't like that big query string.
I also tried using tiny url with following method in which I passed the URL to a PHP function to get the tiny URL:
var a = $("#Link").val();
I get the correct value of **a**. After that I pass this value to a PHP file:
$.post("ShortLink.php?value="+a
In that PHP file I got the following value:
http://domain.com/see.php?c=3
All the values after 3 is deleted.
Thanks
When POSTing to your ShortLink.php file, you should make sure to URL encode the value of a beforehand. Otherwise you're calling ShortLink.php?value=http://domain.com/see.php?c=3&a=123&v=1, i.e., sending:
value = http://domain.com/see.php?c=3
a = 123
v = 1
What you want is ShortLink.php?value=http%3A%2F%2Fdomain.com%2Fsee.php%3Fc%3D3%26a%3D123%26v%3D1, thus sending:
value = http://domain.com/see.php?c=3&a=123&v=1
This can be achieved via encodeURIComponent():
$.post("ShortLink.php?value=" + encodeURIComponent(a));
See also How do I pass a URL with multiple parameters into a URL? and How to encode a URL in Javascript?.
Why don't u just use an url shortener API for that, like Google url shortener. That way, you can leave your code the way it is, but for site's like Facebook and Twitter, it is nicely short.
Try this:
$.post("ShortLink.php?value=" + escape(a));