shadiadiph Posted April 28, 2009 Share Posted April 28, 2009 My problem is this. I have a login for I am trying to curl which has an onsubmit=return SignIn_submitForm() in the form line this wouldn't bother me usually but this statement checks tot see if the user and password are empty but then it continues to set the cookie using the document element before submitting how should i do this any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/ Share on other sites More sharing options...
ignace Posted April 28, 2009 Share Posted April 28, 2009 onsubmit="SignIn_SubmitForm(); return true" Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821044 Share on other sites More sharing options...
premiso Posted April 28, 2009 Share Posted April 28, 2009 Sorry for the move, just saw javascript code The login you are trying to login to with cURL, is it your own page? If so, try the fix ignace posted. If not, we would need a bit more information. Does this not work? How does it not work, no cookie being set? If this is your site are you wanting to allow people cURL access? If so, why not create a non-javascript login for that? Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821065 Share on other sites More sharing options...
shadiadiph Posted April 29, 2009 Author Share Posted April 29, 2009 problem is the login submit also sets the cookie if the cookie type is wrong will not let me login no its not my own page i am asking my user to login to their email account its a real pain the two largest providers are easy to curl Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821545 Share on other sites More sharing options...
premiso Posted April 29, 2009 Share Posted April 29, 2009 Do either providers support OpenID? But what you are doing is having the user enter in their email information then going to the site and signing them in and allowing them to browse it from your site like they are logged in? Is that correct? Is there a reason you are doing it this way? Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821546 Share on other sites More sharing options...
shadiadiph Posted April 29, 2009 Author Share Posted April 29, 2009 no I am asking them to invite their contacts this is very frustrating alot of trial and error problem is some of them use javascript which I absolutely hate if its just to validate if info has been enetered its easy to bypass but in some sites I am looking at they use javascript to validate then set the cookie I am a bit lost there Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821555 Share on other sites More sharing options...
premiso Posted April 29, 2009 Share Posted April 29, 2009 no I am asking them to invite their contacts this is very frustrating alot of trial and error problem is some of them use javascript which I absolutely hate if its just to validate if info has been enetered its easy to bypass but in some sites I am looking at they use javascript to validate then set the cookie I am a bit lost there Gotcha, the javascript setting the cookie is the bitch part. I do not think there is a way to bypass this. What is the cookie it is setting? Is it just to test that you have javascript enabled? If so, you may be able to browse the site on your local box and copy the cookie from the file on your local box and mimic that way in your cookies.txt that you are using in the cURL function. You may have to dynamically write it each time, but if it is just a test that should work. Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821573 Share on other sites More sharing options...
shadiadiph Posted April 29, 2009 Author Share Posted April 29, 2009 problem is it sets the cookie using document elementid values easy i know the value of login1 = $login password = $password but for example here is the onsubmit script I have made a cookie named sitename.txt and loginName2.txt and saved them in the same directory as the script problem I have at the moment is it keeps taking me to an error 302 page says click here to login if i click on the link i am logged in directly to the site i have tried pregmating the link in the click here page and following it but it says session expired?? I somehow need to make sure the cookie is correct i think but then i dont get if i click the link it successfullly logs me in if i follow the link in curl it says session expired <script>/*<![CDATA[*/ function SignIn_submitForm() { SignIn_storeLoginName(); var login = SignIn_stringtrim(document.getElementById('login1').value); var pwd = SignIn_stringtrim(document.getElementById('password').value); if(login == '' || pwd == '') { document.getElementById('EmptyUsernamePassWord').style.cssText=''; return false; } else { document.getElementById('EmptyUsernamePassWord').style.cssText='Display:None'; } return true; } function SignIn_storeLoginName() { var expdate=new Date (); expdate.setTime (expdate.getTime()+(365*24*60*60*1000)); // 24 hrs from now SignIn_SetCookie('loginName2',document.mailcom.login1.value,expdate); if(document.mailcom.siteselected) { var sitetype=((document.mailcom.siteselected[0].checked=="1")? "normal":"betaus"); SignIn_SetCookie('sitetype',sitetype,expdate); } return true; } function SignIn_stringtrim(str) { try { return str.replace(/^\s*(\S*(\s+\S+)*)\s*$/, "$1"); } catch(e) { } } function SignIn_SetCookie(name,value,expires,path,sitedomain,secure) { document.cookie=name+"="+escape(value)+ ((expires)? "; expires="+expires.toGMTString():"")+ ((path)? "; path=":"; path=/")+ ((sitedomain)? "; domain="+sitedomain:"; domain=.mail.com")+ ((secure)? "; secure":""); } function SignIn_getCookieVal(offset) { var endstr=document.cookie.indexOf (";", offset); if (endstr==-1) endstr=document.cookie.length; return unescape(document.cookie.substring(offset, endstr)); } function SignIn_GetCookie(name) { var arg=name+"=", alen=arg.length,clen=document.cookie.length, i=0; while (i<clen) { var j=i+alen; if (document.cookie.substring(i,j)==arg) return SignIn_getCookieVal(j); i=document.cookie.indexOf(" ",i)+1; if (i==0) break; } return null; } function SignIn_startup() { try{ (SignIn_GetCookie('sitetype')=="betaus")? document.mailcom.siteselected[1].click():document.mailcom.siteselected[0].click(); if (SignIn_GetCookie('loginName2')) { if (document.mailcom.login.value=="") { document.mailcom.login.value=SignIn_GetCookie('loginName2'); } } } catch(e){} } function SignIn_ToggleText(txtBox, text, toShowDefault) { var trimmedTbVal = SignIn_stringtrim(txtBox.value); var trimmedTxtVal = SignIn_stringtrim(text); if(toShowDefault) { if(trimmedTbVal=='') txtBox.value = trimmedTxtVal; } else { if(trimmedTbVal==trimmedTxtVal) txtBox.value = ''; } } function SignIn_Error() { var qstring = SignIn_GetQueryString(window.location.href,'err'); if(qstring!=null && qstring !='') { try { var SignInErrorArray = new Array(); SignInErrorArray['err_disabled_login'] = 'Invalid username/password'; SignInErrorArray['err_EmptyUserNamePassword'] = 'Username Empty and/or Password Empty'; SignInErrorArray['err_invalid_login'] = 'Invalid username/password.'; SignInErrorArray['err_serverconnect_fail'] = 'Error connecting to Server'; SignInErrorArray['err_suspended_user'] = 'Invalid username/password'; SignInErrorArray['err_wrong_site'] = 'You\'re logging in the wrong site. Please login at http://www.mail.com'; var errorDiv = document.getElementById('warning'); var error = SignInErrorArray[qstring]; if(error !=null) { errorDiv.innerHTML = error; errorDiv.style.display=''; } } catch(e) { } } } function SignIn_GetQueryString(url, key ) { url = unescape(url); var re = new RegExp( "[?&]" + key + "=([^&$]*)", "i" ); var offset = url.search( re ); if ( offset == -1 ) return null; return RegExp.$1; } Quote Link to comment https://forums.phpfreaks.com/topic/155949-curl-on-submit-question/#findComment-821577 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.