runescape-exchange-calculator

Gesponsorde koppelingen

PHP script bestanden

  1. runescape-exchange-calculator

« Lees de omschrijving en reacties

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
//laat alle errors zien
ini_set('display_errors',1);
error_reporting(E_ALL);

//layout laden
include("top.php");

//checkt of het formulier in is gevult
if($_SERVER['REQUEST_METHOD'] == "POST" ) {
//checkt of de informatie correct is ingevult

$amount= array();
$amount= $_POST['amount'];
$id= array();
$id= $_POST['id'];
$price = 0;
$price2 = 0;

//Price checken en vermenigvuldigen met het amount
function getprice($id){
$begin = "<b>Market price:</b> ";
$eind = "</span>";
$maximale_delay = 5;
$site = "http://itemdb-rs.runescape.com/viewitem.ws?obj=".$id;
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $site);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_CONNECTTIMEOUT, $maximale_delay);
if(curl_errno($ch))
{

    return 'EVDC';
}
else{
$start = curl_exec($ch);
curl_close($ch);
if(strstr($start,$id)) {
$exploded = explode($begin,$start);
$exploded = explode($eind,$exploded[1]);
$result = str_replace('<br />','',nl2br($exploded[0]));
   return $result;
}
else{
    return "EVID";
}
}
}
function
image($id){
$result = '<img alt="&lsquo;'.$id.'&rsquo;" src="http://itemdb-rs.runescape.com/2669_obj_big.gif?id='.$id.'"></img>';
   return $result;
}

    echo'<h1>Exchange Calculator</h1>';
    for($i=0; $i < count($_POST['amount']); $i++)
  {

   if ($amount[$i]!='' and $id[$i]!=''){
       if (getprice($id[$i])== "EVID"){
   echo 'Het id &lsquo;'.$id[$i].'&rsquo; bestaat niet.<br />';
   }
elseif(getprice($id[$i])== "EVDC"){
       echo 'Het id mag alleen cijfers bevatten.<br />';
   }
else{
   $price = $amount[$i] * getprice($id[$i]);
   $price2 = $price2 + $price;
   echo $amount[$i].'x'.image($id[$i]).'='.$price.'gp<br />';
   }
   }
   }

   echo '<br />Total price = '.$price2.'gp';
}
else{
//het formulier

?>

<h1>Exchange Calculator</h1>
<form id="pricecheckform" name="pricecheckform" method="post" action="<?php echo $_SERVER['PHP_SELF'];?>">
<table width="100%"border="0">
  <tr>
      <td>Amount</td>
    <td>Id</td>
  </tr>
  <tr>
    <td><input type="text" name="amount[]" /></td>
    <td><input type="text" name="id[]" /></td>
  </tr>
  <tr>
    <td><input type="text" name="amount[]" /></td>
    <td><input type="text" name="id[]" /></td>
  </tr>
  <tr>
    <td><input type="text" name="amount[]" /></td>
    <td><input type="text" name="id[]" /></td>
  </tr>
  <tr>
    <td><input type="text" name="amount[]" /></td>
    <td><input type="text" name="id[]" /></td>
  </tr>
  <tr>
    <td><input type="text" name="amount[]" /></td>
    <td><input type="text" name="id[]" /></td>
  </tr>
  <tr>
    <td></td>
    <td><input name="calc" type="submit" value="Calculate" /></td>
  </tr>
</table>
</form>
<?php
}
include("end.php");
?>

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.