Jump to content

lauryn1298

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

lauryn1298's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, I'm working with the curl library of PHP. I'm involved in a project that needs to show the custumers some data of webstites. For getting these contents I use curl and it works very well. Now I have a case I have no idea how to solve, I tried many things but nothing worked until now. The headers are: http://xxxxx/dwr/call/plaincall/ValidacaoCaptchaAction.isValid.dwr POST http://xxxxx/dwr/call/plaincall/ValidacaoCaptchaAction.isValid.dwr HTTP/1.1 Host: www.xxxxx.com User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:14.0) Gecko/20100101 Firefox/14.0.1 Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 Accept-Language: pt-br,pt;q=0.8,en-us;q=0.5,en;q=0.3 Accept-Encoding: gzip, deflate Proxy-Connection: keep-alive Content-Type: text/plain; charset=UTF-8 Referer: http://www.xxxxxx.com/proc_result.jsp?yyyy Content-Length: 358 Cookie: JSESSIONID=E3C8250203F7579DF291025B989B6C37; AWSUSER_ID=awsuser_id1345814954804r436; AWSSESSION_ID=awssession_id1345814954804r436 Proxy-Authorization: Basic a2FkdTpra2FkdQ== Pragma: no-cache Cache-Control: no-cache callCount=1 page=/xxxxxx httpSessionId=E3C8250203F7579DF291025B989B6C37 scriptSessionId=935CD798ADD1713369D651C811E2B80E994 c0-scriptName=ValidationAction c0-methodName=isValid c0-id=0 c0-param0=string:63201 batchId=0 My problem is that I don't know how to treat the Content-Type: text/plain; charset=UTF-8, and post the parameters of Cache-Control: no-cache. For the text/plain I add: curl_setopt($this->request, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/plain')); and I tried to post the parameters as: $fields = array( 'callCount'=>'1', 'page' => $url, 'httpSessionId' => $this->cookie_name, 'scriptSessionId' => md5(rand(111111, 999999)), 'c0-scriptName'=>'ValidationAction', 'c0-methodName'=>'isValid', 'c0-id'=>'0', 'c0-param0'=>'string:'.$code, 'batchId'=>'0'); $fields_string = http_build_query($fields); curl_setopt($this->request, CURLOPT_AUTOREFERER, true); curl_setopt($this->request, CURLOPT_HTTPHEADER, array('Content-Type' => 'text/plain')); curl_setopt($this->request, CURLOPT_URL, $url); curl_setopt($this->request, CURLOPT_RETURNTRANSFER, 1); curl_setopt($this->request, CURLOPT_FOLLOWLOCATION, 1); curl_setopt($this->request, CURLOPT_POST,true); curl_setopt($this->request, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($this->request, CURLOPT_HEADER, 0); curl_setopt($this->request, CURLOPT_REFERER, $first_url); curl_setopt($this->request, CURLOPT_FORBID_REUSE, 1); curl_setopt($this->request, CURLOPT_COOKIEJAR, $cookie); curl_setopt($this->request, CURLOPT_COOKIEFILE,$cookie); curl_setopt($this->request, CURLOPT_COOKIESESSION, true); curl_setopt($this->request, CURLOPT_USERAGENT, USERAGENT); $html = curl_exec($this->request); Any ideas what is wrong? Thanks in advance.
  2. In page1.php I put print_r($_SESSION) at the beginnig, after session_start(); and in page2.php I put print_r($_SESSION) in the last line of the code. To be sure nothing is happening between the 2 pages. I think is something with the global variables, but I don't know where is the problem. What do you mean by logic error? I haven't be grateful for your quick replies, thanks a lot, this problem is getting me crazy!
  3. My source code is very big, but I'll try to summarize. page1.php I have previous files where I saved some values on session. <?php session_start(); include('constants.php'); if (!isset($_SESSION['user'])) { header("Location: ".RELATIVE_PATH."/field_test/login.php"); exit; } else { //Calculate the time passed $previous_date = $_SESSION["last_access"]; $actual_date = date("Y-n-j H:i:s"); $time_pass = (strtotime($actual_date)-strtotime($previous_date)); //Compare the time passes if($time_pass >= 28800) { //If 20 minutes or more session_destroy(); // destroy session //Send to the login user page header("Location: ".RELATIVE_PATH."/field_test/index.php"); //if not, update the date of the session }else { $_SESSION["last_access"] = $actual_date; } } $profile = $_SESSION['profile']; ?> ........ ...... //Start the html code and the form <form action="page2.php" method="POST" name="report_gestion" > <table border="0" width="100%"> <tr> <td > X :</td> <td > <select name='x_axis'> <option label=" " value=""> </option> <option label="Pair of Sockets" value="pair_sockets">Pair of Sockets</option> <option label="Max Phy Rate(Mbps)" value="phy_max">Max Phy Rate(Mbps)</option> <option label="Min Phy Rate(Mbps)" value="phy_min">Min Phy Rate(Mbps)</option> <option label="Avg Phy Rate(Mbps)" value="phy_avg">Avg Phy Rate(Mbps)</option> <option label="Avg Throughput(Mbps)" value="xput_avg">Avg Throughput(Mbps)</option> <option label="Max Throughput(Mbps)" value="xput_max">Max Throughput(Mbps)</option> <option label="Min Throughput(Mbps)" value="xput_min">Min Throughput(Mbps)</option> </select> </td> <td ><input type="checkbox" name="parameters[]" value="hpav" title="HPAV" />HPAV</td> <td ><input type="checkbox" name="parameters[]" value="mx" title="MX" disabled/>MX</td> </tr> <tr> <td colspan="2"> </td> </tr> <tr> <td > Y :</td> <td > <select name='y_axis[]' multiple size= 5 > <option label="Max Phy Rate(Mbps)" value="phy_max">Max Phy Rate(Mbps)</option> <option label="Min Phy Rate(Mbps)" value="phy_min">Min Phy Rate(Mbps)</option> <option label="Avg Phy Rate(Mbps)" value="phy_avg">Avg Phy Rate(Mbps)</option> <option label="Avg TCP Throughput(Mbps)" value="xput_max">Avg TCP Throughput(Mbps)</option> <option label="Max TCP Throughput(Mbps)" value="xput_max2">Max TCP Throughput(Mbps)</option> <option label="Min TCP Throughput(Mbps)" value="xput_min">Min TCP Throughput(Mbps)</option> <option label="Counters" value="sel_primitives">Counters</option> </select> </tr> </td> </table> </form> If I do print_r($_SESSION); in this file I obtain: Array ( [profile] => 1 [last_access] => 2010-3-26 12:34:16 [user] => 1 ); what is correct. Then I send this form to the page2.php <?php //Initialize the session for saving the user session_start(); require_once '../Smarty/libs/Smarty.class.php'; include('../constants.php'); if (!isset($_SESSION['user'])) { header("Location: ".RELATIVE_PATH."/field_test/login.php"); exit; } else { //Calculate the time passed $previous_date = $_SESSION["last_access"]; $actual_date = date("Y-n-j H:i:s"); $time_pass = (strtotime($actual_date)-strtotime($previous_date)); //Compare the time passes if($time_pass >= 28800) { //If 20 minutes or more session_destroy(); // destroy session //Send to the login user page header("Location: ".RELATIVE_PATH."/field_test/index.php"); exit; //if not, update the date of the session }else { $_SESSION["last_access"] = $actual_date; } } $profile = $_SESSION['profile']; //Read the parameters from the form $_SESSION['x_axis_session'] = $_POST['x_axis']; $x_axis_param = $_SESSION['x_axis_session']; $_SESSION['y_axis_session'] = $_POST['y_axis']; $y_axis_param = $_SESSION['y_axis_session']; $_SESSION['parameters_session'] = $_POST['parameters']; $params = $_SESSION['parameters_session']; .... I made different calculation correctly If I do print_r($_SESSION); in this file I obtain: Array ( [profile] => 1 [last_access] => 2010-3-26 12:39:40 [user] => 1 [x_axis_session] => pair_sockets [y_axis_session] => Array ( [0] => phy_max ) [parameters_session] => Array ( [0] => hpav ) ) what is correct. But when I come back to page1.php and I print the session I obtain: Array ( [[profile] => 1 [last_access] => 2010-3-26 12:41:31 [user] => 1[x_axis_session] => [y_axis_session] => [parameters_session] => ) Here is where I have the problem, the variables of the form haven't been saved in the session, I don't know why. I hope the code helps. Let me know if you need more details
  4. Hello, I have a problem passing the values of the form variables between pages when I want to save them in session. I'm using sessions for saving another values that don't come from the form, and all of them are saved in the session correctly. For example I'm saving the user and the profile once the user is logged, and I pass this value through all the pages without any problem. But now I have to save some values of a form, just in case the user wants to come back and see the values that previously had inserted. When I print the session in the page where I'm reading the form variables, all of them are set correctly, but when I go back they are empty, but the ones that I had previously are saved correctly. I was looking for a solution in different forums, I change the name of the variable of the session (at the beginning the name of the session variable and the variable form were the same, and this was giving me problems). I did everything I can think, but the problem is still there. I'm not sure if it's a problem with the global variables.... In my php.ini are off, and I wouldn't like to change this. Many thanks
  5. Hello, I must generate a report as a word document and I also have to embed images, that I have saved in my files system, into this word document, so customer can download this word document into his/her own pc and still can see this images. Generating word document with php is not a problem. But I really get stuck with embedding images into word. I try many ways but they doen't work. I tried doing it with: header("Content-type: application/vnd.ms-word"); header("Content-Disposition: attachment;Filename=".$name_report.".doc"); and after displaying different echo with html code. I put the full path for the images, but I obtain an error. I found some solutions with COM class, but most of my costumers don't use Windows, they use Linux. Any idea or advices will be appreciated. Thanks in advance.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.