<?php
include("header.php");
include("sidebar.php");
if($siteowner != 1 || $aoff != 1){
print"Access Denied"; include("footer.php"); exit();
}
if(!isset($_GET['filename']) && !isset($_POST['upload'])){
?>
<form action="" method="post"
enctype="multipart/form-data">
<label for="file">Filename:</label>
<input type="file" name="file" id="file" />
<br />
<input type="submit" name="upload" value="Submit" />
</form>
<?php
}
if($_POST['upload']){
if ($_FILES["file"]["error"] > 0)
{
echo "Return Code: " . $_FILES["file"]["error"] . "<br />";
}
else
{
if (file_exists("xml/" . $_FILES["file"]["name"]))
{
unlink("xml/" . $_FILES["file"]["name"]);
move_uploaded_file($_FILES["file"]["tmp_name"],
"xml/" . $_FILES["file"]["name"]);
}
else
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"xml/" . $_FILES["file"]["name"]);
}
}
$filename=$_FILES["file"]["name"];
header("Location: testxml.php?filename=".$filename."");
}
if($_GET['filename']){
$filename= asql($_GET['filename']);
$file = 'xml/'.$filename;
$string = file_get_contents($file);
$cid = asql($_POST['campid']);
$name = asql($_POST['oname']);
$req = asql($_POST['req']);
$url = asql($_POST['url']);
$reward = asql($_POST['cash']);
$points = asql($_POST['points']);
if($reward >= "2.00"){
$lock = "1";
}else{
$lock = "0";
}
if($points >= "200"){
$lock = "1";
}else{
$lock = "0";
}
$country = asql($_POST['countries']);
$type = asql($_POST['cat']);
$aff = asql($_GET['aff']);
$times = time();
$fullfile = "xml/".$filename;
function delete_book_id($ids){
global $fullfile;
$data = simplexml_load_file($fullfile);
$data_count = count($data->item);
for($i = 0; $i < $data_count; $i++)
{
//basically what you want to remove
if(($data->item[$i]->id == $ids))
{
unset($data->item[$i]);
}
}
file_put_contents($fullfile, $data->saveXML());
}
if($_POST['add']){
mysql_query("INSERT INTO offers (`id`,`campid`,`name`,`desc`,`url`,`reward`,`points`,`country`,`type`,`locked`,`active`,`aff`,`d_added`) VALUES ('','$cid','$name','$req','$url','$reward','$points','$country','$type','$lock','1','$aff','$times')");
delete_book_id($cid);
header("Location: testxml.php?aff=".$aff."&filename=".$filename."");
}
$xml = new SimpleXMLElement($string);
//Loop trough multiple products
print"<table border='1' bordercolor='#6600FF' style='width='100%' cellpadding='3' cellspacing='3'>
<th>Campaign Name</th><th>Countries</th><th>Rate</th><th>Cash</th><th>Points</th>
<form action='' method='GET'>
<input type='hidden' name='filename' value='".$filename."' />
<select name='aff'>";
if($_GET['aff']){
$affi = asql($_GET['aff']);
print"<option value='".$affi."'>".$affi."</option>";
}else{
print"<option value='0'>Select an Affiliate</option>";
}
$affs=mysql_query("SELECT * FROM `affiliates`");
while($affi=mysql_fetch_array($affs))
{
print"<option value='{$affi['name']}'>{$affi['name']}</option>";
}
print"</select><input type='submit' value='Select Affiliate' /></form>";
foreach($xml->item as $item)
{
$count = count(explode(", ",$item->countries));
if($count >= 5){
$country = "ALL INTL";
}
else{
$country = $item->countries;
}
$rate = number_format((float)$item->rate, 2, '.', '');
$crates = $rate * 0;
$prates = $rate * 45;
$crate = number_format((float)$crates, 2, '.', '');
$prate = number_format((float)$prates, 2, '.', '');
echo'<tr><td><form action="" method="POST"><input type="hidden" name="countries" value="'.$item->countries.'" /><input type="hidden" name="url" value="'.$item->url.'" /><input type="hidden" name="campid" value="'.$item->id.'" /><input type="hidden" name="oname" value="'.$item->name.'" />'.$item->name.'<br /><font color="limegreen" size="2">Incent: '.$item->incent.'</font><br /><select name="req" style="width:200px"><option value ="'.$item->requirements.'">'.$item->requirements.'</option></select>
<select style="width:200px" name="cat" id="cat">';
$cats=mysql_query("SELECT * FROM `offer_cats`");
while($off=mysql_fetch_array($cats)){
$cnames = array($off['name']);
$cnamess = implode(",", $cnames);
$cname = explode(",", $cnamess);
foreach($cname as $category){
echo '<option value="'.$off['id'].'">'.$category.'</option>';
}
}
echo'</select><input type="submit" name="add" value="+" /></td>';
echo '<td>'.$country.'</td>';
echo '<td>'.$item->rate.'</td>';
echo '<td><input type = "text" name="cash" value="'.$crate.'" style = "width:75px" /></td>';
echo '<td><input type = "text" name="points" value="'.$prate.'" style = "width:75px" /></td></form>';
// echo $item->incent;
// echo '<br/>';
}
?>
</tr>
</table>
<?php
}
include("footer.php");
?>