8 | | require_once( "class.page.php" ); |
9 | | require_once( "globals.php" ); |
10 | | require_once( "class.parser.php" ); |
11 | | require_once( "class.killlist.php" ); |
12 | | require_once( "admin_menu.php" ); |
| 7 | require_once("class.page.php"); |
| 8 | require_once("globals.php"); |
| 9 | require_once("class.parser.php"); |
| 10 | require_once("class.killlist.php"); |
| 11 | require_once("admin_menu.php"); |
17 | | if ( !$_POST['killmail'] ) { |
18 | | $html .= "<b>Killmails in same format as export (Comma Seperated - csv):</b><br>"; |
19 | | $html .= "<form id=postform name=postform class=f_killmail method=post action=\"?a=kill_import_csv\">"; |
20 | | $html .= "<textarea class=killmail id=killmail name=killmail cols=\"55\" rows=\"35\"></textarea><br><br>"; |
21 | | $html .= " <input id=submit name=submit type=submit value=\"Process !\"></input>"; |
22 | | $html .= "</form>"; |
23 | | } else { |
| 16 | if (!$_POST['killmail']) |
| 17 | { |
| 18 | $html .= "<b>Killmails in same format as export (Comma Seperated - csv):</b><br>"; |
| 19 | $html .= "<form id=postform name=postform class=f_killmail method=post action=\"?a=kill_import_csv\">"; |
| 20 | $html .= "<textarea class=killmail id=killmail name=killmail cols=\"55\" rows=\"35\"></textarea><br><br>"; |
| 21 | $html .= " <input id=submit name=submit type=submit value=\"Process !\"></input>"; |
| 22 | $html .= "</form>"; |
| 23 | } |
| 24 | else |
| 25 | { |
| 26 | // Set delimiter |
| 27 | $splitter = ',\n\n'; |
| 28 | $killmail = $_POST['killmail']; |
26 | | // Set delimiter |
27 | | $splitter=',\n\n'; |
28 | | $killmail = $_POST['killmail']; |
29 | | // Replace double quotes with single |
30 | | $killmail = str_replace('""', "'", $killmail); |
31 | | // Replace \ with nothing |
32 | | $killmail = str_replace('\\', "", $killmail); |
33 | | // Explodes to array |
34 | | $getstrings = explode('"', $splitter.$killmail.$splitter); |
35 | | // Set lenght of delimiter |
36 | | $delimlen = strlen($splitter); |
37 | | // Default |
38 | | $instring = 0; |
| 33 | // Replace \ with nothing |
| 34 | $killmail = str_replace('\\', "", $killmail); |
56 | | // Parses killmails one by one. |
57 | | foreach($result as $killmail) { |
58 | | $parser = new Parser( $killmail ); |
59 | | $killid = $parser->parse( true ); |
60 | | // Make response |
61 | | if ( $killid == 0 ) $html .= "Killmail is malformed.<br>"; |
62 | | if ( $killid == -1 ) $html .= "That killmail has already been posted <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>.<br>"; |
63 | | if ( $killid == -2 ) $html .= "You are not authorized to post this killmail.<br>"; |
64 | | if ( $killid >= 1 ) $html .= "Killmail imported succesfully <a href=\"?a=kill_detail&kll_id=".$parser->dupeid_."\">here</a>.<br>"; |
65 | | unset($killid); |
66 | | unset($parser); |
67 | | } |
| 39 | // Set lenght of delimiter |
| 40 | $delimlen = strlen($splitter); |
| 41 | |
| 42 | // Default |
| 43 | $instring = 0; |
| 44 | |
| 45 | // String magic :) |
| 46 | while (list($arg, $val) = each($getstrings)) |
| 47 | { |
| 48 | if ($instring == 1) |
| 49 | { |
| 50 | $result[] = $val; |
| 51 | $instring = 0; |
| 52 | } |
| 53 | else |
| 54 | { |
| 55 | if ((strlen($val) - $delimlen - $delimlen) >= 1) |
| 56 | { |
| 57 | $temparray = split($splitter, substr($val, $delimlen, strlen($val) - $delimlen - $delimlen)); |
| 58 | while (list($iarg, $ival) = each($temparray)) |
| 59 | { |
| 60 | $result[] = trim($ival); |
| 61 | } |
| 62 | } |
| 63 | $instring = 1; |
| 64 | } |
| 65 | } |
| 66 | // Parses killmails one by one. |
| 67 | foreach ($result as $killmail) |
| 68 | { |
| 69 | $parser = new Parser($killmail); |
| 70 | $killid = $parser->parse(false); |
| 71 | // Make response |
| 72 | if ($killid == 0) |
| 73 | { |
| 74 | $html .= "Killmail is malformed.<br>"; |
| 75 | } |
| 76 | elseif ($killid == -1) |
| 77 | { |
| 78 | $html .= "That killmail has already been posted <a href=\"?a=kill_detail&kll_id=" . $parser->dupeid_ . "\">here</a>.<br>"; |
| 79 | } |
| 80 | elseif ($killid == -2) |
| 81 | { |
| 82 | $html .= "You are not authorized to post this killmail.<br>"; |
| 83 | } |
| 84 | elseif ($killid >= 1) |
| 85 | { |
| 86 | $html .= "Killmail imported succesfully <a href=\"?a=kill_detail&kll_id=" . $parser->dupeid_ . "\">here</a>.<br>"; |
| 87 | } |
| 88 | } |