Jump to content

Noesis

Members
  • Posts

    5
  • Joined

  • Last visited

Noesis's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. The following piece of POST header details to output to a file in JSON format returns the following error: [/code]$params = array("user" => $enjin_id); $query = http_build_query($params); $contextData = array("method" => "POST", "header" => "Connection: close\r\n" . "Content-Length: " . strlen($query)."\r\n", "content" => $query ); $context = stream_context_create(array ( "http" => $contextData )); $result = file_get_contents($url, FALSE, $context);[/code] error: file_get_contents(): Content-type not specified assuming application/x-www-form-urlencoded Can anyone advise what I need to do to ensure that the process is correctly set, of which I assume I need to declare a MIME type and where it is needed?
  2. Yes I simply want to extract that piece of text from the parent source, but from within a child iframe php page.
  3. Have a situation where I need to retrieve a parent variable but am unable to modify the parent source code. I also want to apply any solution in a cross domain situation but using PHP coding techniques. <div class='userbox'> <div class='avatar'><div class='element_avatar simple medium '><a href="http://thetemplars.enjin.com/profile/2819806" data-minitooltip="Noesis"><img src="http://assets-cloud.enjin.com/users/2819806/avatar/medium.1362825808.png"></a></div></div> <div class='username'><a href='/profile/2819806' class='element_username'>Noesis</a></div> <a class='logout' href='/logout'>Logout</a> </div> The above shows the relevant section of the output source code in javascript and at the moment and I'm unawares to the actual variable names applied in the process as it is the intellectual property rights are owned by someone else. I'm in contact with their support team however in the hope they can help support retrieval of this information to help support their modular use of bolt-on php applications and pages with their forum use. I'm using PHP as my coding platform and believe there could be useful techniques to extract data from the above that doesn't require the preferred method of a listener or simply isn't possible in the case of a java process from the child when cross domains are in use. Ideally the textual part associated with the class "element_username" or the "data-minitooltip" value could be used as per the username displayed on the parent frame. Could anyone advise of useful techniques how I could extract this information with only being able to apply coding changes in the child php code?
  4. Please can people review this code: <!doctype html> <meta http-equiv="Content-type" content="text/html;charset=UTF-8"> <html> <head> <title>Pilot Codex Recording</title> </head> <body> <?php if (isset($_POST['codexsubmit'])) { $run = "running"; print_r($run); // initial database stuff $host = "localhost"; $user = "root"; $pass = "pwd"; $db = "codexdb"; $connection = mysqli_connect($host, $user, $pass); mysqli_select_db($db); // Assign Variables // Pilot id name $pilot_id = $_POST['Pilot']; // consider getting as forum user id or name print_r($pilot_id); // debug if (!(empty($pilot_id))) { // Banner id $banner_id = $_POST['Banner']; // reference date $ref_date = date("Y-m-d"); // MECHS $mech_text = $_POST['mech_textarea']; print_r($mech_text); // debug $lines_count = count(explode("\n", $mech_text)); $lines_array = explode("\n", $mech_text); for ( $l=0; $l<=$lines_count; $l++ ) { $mech_string_raw = ""; $mech_string_raw = $lines_array[$l]; $mech_string = str_replace("\n", "", $mech_raw_string); if (empty($mech_string)) { continue; } if (stripos($mech_string, "Statistics")) { continue; } if (stripos($mech_string, "Matches")) { continue; } // parsing mech stuff $count = 0; $mech_info = ""; $mech_desc = ""; $matches = 0; $win = 0; $loss = 0; $kills = 0; $deaths = 0; $damage = 0; $xp = 0; $time_string = ""; $tmp_string = str_replace(",", "", $mech_string); $tmp_string2 = str_replace("/", "", $tmp_string); $tmp_string3 = str_replace("-", "", $tmp_string2); $tmp_string4 = str_replace("%", "", $tmp_string3); $tmp_string5 = str_replace(" day ", ":", $tmp_string4); $tmp_string6 = str_replace(" days ", ":", $tmp_string5); $count = count(explode(" ", $tmp_string6)); $mech_info = explode(" ", $tmp_string6); $matches = $mech_info[$count-10]; $win = $mech_info[$count-9]; $loss = $mech_info[$count-8]; $kills = $mech_info[$count-6]; $deaths = $mech_info[$count-5]; $damage = $mech_info[$count-3]; $xp = $mech_info[$count-2]; $time_string = $mech_info[$count-1]; $time_count = 0; $time_count = count(explode(":", $time_string)); $time_info = explode(":", $time_string); $time_second = 0; $time_second = $time_info[$time_count-1]; $time_minute = 0; $time_minute = $time_info[$time_count-2]; $time_hour = 0; $time_hour = $time_info[$time_count-3]; $time_day = 0; $time_day=$time_info[$time_count-4]; $total_time = (( $time_second ) + ( $time_minute * 60 ) + ( $time_hour * 3600 ) + ( $time_day * 86400 )); // mech description $text_count = $count - 11; $mech_desc = ""; for ( $x=0; $x<=$text_count; $x++ ) { $mech_desc = $mech_desc + $mech_info[$x] + " "; } $mech_desc = trim($mech_desc); // insert mech stuff $sql_qry = "IF EXISTS (SELECT * FROM pilot_stats_mech WHERE pilot_id = '$pilot_id' AND ref_date = '$ref_date' AND mech_desc = '$mech_desc') " + " THEN " + " UPDATE pilot_stats_mech SET banner_id = '$banner_id', matches = '$matches', win = '$win', loss = '$loss', kills = '$kills', deaths = '$deaths', damage = '$damage', xp = '$xp', total_time = '$total_time' " + " WHERE pilot_id = '$pilot_id' AND ref_date = '$ref_date' AND mech_desc = '$mech_desc' " + " ELSE " + " INSERT INTO pilot_stats_mech (pilot_id, banner_id, ref_date, mech_desc, matches, win, loss, kills, deaths, damage, xp, total_time) " + " VALUES ('$pilot_id', '$banner_id', '$ref_date', '$mech_desc', '$matches', '$win', '$loss', '$kills', '$deaths', '$damage', '$xp', '$total_time') "; print_r($sql_qry); // debug $result = mysqli_query($connection, $sql_qry); } // for $l } // if !empty $pilot_id } else { $not_run = "Not running"; print_r($not_run); } ?> <BR><BR> <form method="post" action="<?php echo $PHP_SELF; ?>"> <fieldset> <BR> <label for="Pilot">Pilot name: </label><input id="Pilot" type="text" name="Pilot"><BR><BR> <label for="Banner">Banner: </label><select id="Banner" name="Banner"> <option>None</option><option>Alpha</option><option>Bravo</option> <option>Delta</option><option>Echo</option><option>Hotel</option> <option>India</option><option>Juliette</option><option>Kilo</option> <option>1st EG</option><option>2nd EG</option><option>3rd EG</option> </select><BR><BR> <label for="mech_textarea">Mech Stats: </label> <textarea rows="3" cols="150" name="mech_textarea"> </textarea><BR><BR> <input type="submit" name="codexsubmit" value="Submit Codex"><BR> </fieldset> </form> </body> </html> The problem I have is that despite debug with the print_r statements when I run the php in a browser it does not appear to do anything other than provide the form. It does not appear to run the php scripting elements. I relatively new to php/html but not to programming. Any assistance with this would be appreciated as I find it frustrating.
×
×
  • 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.