<?php
session_start();
include ('../config.php');
include ('secureadmin.php');
include 'includes/imageupload.php';
$query = "select * from settings;";
$result = mysql_query($query,$connection) or die(mysql_error());
$info = mysql_fetch_assoc($result);
$oldtitle = $info['title'];
$oldurl = $info['url'];
$oldminwords = $info['minwords'];
$oldmaxwords = $info['maxwords'];
$oldimage = $info['logourl'];
$oldemailopt = $info['emailopt'];
$oldskip = $info['skipqueue'];
$olddistribution = $info['distribution'];
$oldstatcode = $info['statcode'];
$universalid = $info['universalid'];
$oldtemplate = $info['template'];
$oldcomments = $info['comments'];
if ($oldemailopt == 0) {
$each = "checked";
$never = "";
} else {
$each = "";
$never = "checked";
}
if ($oldskip == 0) {
$yes = "";
$no = "checked";
} else {
$yes = "checked";
$no = "";
}
if ($olddistribution == 0) {
$olddistribution = "checked";
} else {
$olddistribution = "";
}
if ($oldcomments == 0) {
$oldcomments = "checked";
} else {
$oldcomments = "";
}
// to delete the logo...
if($_GET['deletelogo'] == "true") {
$sql = "UPDATE `settings` SET logourl = NULL ";
$query = mysql_query($sql);
header('Location: sitesettings.php?update=true');
}
if(isset($_POST['settings'])) {
if (!$image_name) {
$image_name = $oldimage;
}
$title = mysql_real_escape_string($_POST['title']);
$url = $_POST['url'];
$minwords = $_POST['minwords'];
$maxwords = $_POST['maxwords'];
$emailopt = $_POST['emailopt'];
$skipqueue = $_POST['skipqueue'];
$comments = $_POST['comments'];
$distribution = $_POST['distribution'];
$statcode = $_POST['statcode'];
$newtemplate = $_POST['template'];
if ($distribution) {
$distribution = 0;
} else {
$distribution = 1;
}
if ($comments) {
$comments = 0;
} else {
$comments = 1;
}
if ($skipqueue == "no") {
$skipqueue = 0;
} else {
$skipqueue = 1;
}
if ($emailopt == "each") {
$emailopt = 0;
} else {
$emailopt = 1;
}
$sql = "UPDATE `settings` SET title='".$title."', url='".$url."', minwords=".$minwords.", maxwords=".$maxwords.", template='".$newtemplate."', logourl='".$image_name."', comments =".$comments.", emailopt=".$emailopt.", skipqueue=".$skipqueue.", distribution=".$distribution.", statcode='".$statcode."';";
$query = mysql_query($sql);
// Post update to Synergy
$post_data['siteurl'] = $url;
$post_data['sitename'] = $title;
$post_data['universalid'] = $universalid;
$post_data['distribution'] = $distribution;
//traverse array and prepare data for posting (key1=value1)
foreach ( $post_data as $key => $value) {
$post_items[] = $key . '=' . $value;
}
//create the final string to be posted using implode()
$post_string = implode ('&', $post_items);
//create cURL connection
$curl_connection = curl_init('http://www.articlesynergy.com/listener.php');
//set options
curl_setopt($curl_connection, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($curl_connection, CURLOPT_USERAGENT,
"Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)");
curl_setopt($curl_connection, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl_connection, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl_connection, CURLOPT_FOLLOWLOCATION, 0);
//set data to be posted
curl_setopt($curl_connection, CURLOPT_POSTFIELDS, $post_string);
//perform our request
$result = curl_exec($curl_connection);
//close the connection
curl_close($curl_connection);
header('Location: sitesettings.php?update=true');
exit();
}
$metatitle = "Site Settings - Admin Control Panel";
include ('includes/document_head.php');
?>
<div id="wrapper">
<?php include 'includes/topbar.php'?>
<?php include 'includes/sidebar.php'?>
<div class="main_container container_16 clearfix">
<div class="flat_area grid_16">
<h2>Site Settings</h2>
<p>Use this area to modify the settings and options for your directory. Descriptions are provided below each field. </p>
<br/>
<div class="box grid_16 round_all">
<h2>Manage Your Directory's Settings</h2>
<form style="padding-left: 15px;" name="submission" enctype="multipart/form-data" method="POST" action="sitesettings.php">
<b>Directory Title:</b>
<p>Title will display across the site - keep it short for best results.</p>
<input type="text" name="title" style="width: 250px;" value="<?php echo $oldtitle; ?>">
<br/><br/>
<b>Directory URL:</b>
<p>Homepage of this directory. IMPORTANT - URL <u>must</u> be in this exact format: <br/> <b>http://www.example.com</b> or <b>http://example.com</b> (no trailing slashes)</p>
<input type="text" name="url" style="width: 250px;" value="<?php echo $oldurl; ?>">
<br/><br/>
<b>Design Template:</b>
<p>Here you can choose the design/template of your directory. <br/>
To create/edit a template, view the /templates folder in your root install:</p>
<select name="template">
<?php
$temppath = str_replace("/admin", "", getcwd());
$temppath .= "/templates";
$itemHandler=opendir($temppath);
$i=0;
while(($item=readdir($itemHandler)) !== false){
if(substr($item, 0, 1)!="."){
if ($item == $oldtemplate) {
echo "<option SELECTED value=\"$item\">$item</option>";
} else {
echo "<option value=\"$item\">$item</option>";
}
$i++;
}
}?>
</select>
<br/><br/>
<b>Logo Upload:</b>
<p>Upload a logo here. Image should be around 200kb and 300 x 60<br/>
<b>NOTE:</b> looking for an affordable, quality logo? We recommend <a target="_blank" href="http://www.logonerds.com">LogoNerds »</a></p>
<input type="file" name="image">
<br/><br/>
<?php
if ($oldimage)
echo "<b>Current Logo:</b> <br/><img src=\"".$oldurl."/admin/images/logo/".$oldimage."\" \><br/><a href=\"sitesettings.php?deletelogo=true\">Delete this logo</a>";
?>
<br/> <br/>
<b>Enable Comments:</b>
<p>By default, visitors can leave comments on all articles posted to your directory. <br/>
If you would like to turn them off, uncheck the box below: </p>
<input type="checkbox" name="comments" <?php echo $oldcomments; ?>> Comments Enabled</input>
<br/><br/>
<b>Min/Max Words Per Article:</b>
<p>Sets an upper and lower limit on the word count for articles submitted by users</p>
<input type="text" name="minwords" style="width: 100px;" value="<?php echo $oldminwords; ?>"> / <input type="text" name="maxwords" style="width: 100px;" value="<?php echo $oldmaxwords; ?>">
<br/><br/>
<b>Email Admin:</b><br/>
<p>The admin can receive an email each time a new article is submitted</p>
<input type="radio" name="emailopt" value="never" <?php echo $never; ?> > Never<br/>
<input type="radio" name="emailopt" value="each" <?php echo $each; ?> > On Each Article Submission
<br/><br/>
<b>New Articles:</b><br/>
<p>When a user submits an article, do you want to review it first, or make it live immediately?</p>
<input type="radio" name="skipqueue" value="no" <?php echo $no; ?> > Review First<br/>
<input type="radio" name="skipqueue" value="yes" <?php echo $yes; ?> > Publish Immediately
<br/><br/>
<b>Accept Distribution:</b>
<p>Through the ArticleSetup content distribution system, your directory can automatically <br/>accept high-quality articles, pushed right to your directory's queue for free. </p>
<input type="checkbox" name="distribution" <?php echo $olddistribution; ?>> Enabled</input>
<br/><br/>
<b>Stat tracking code:</b>
<p>Paste your stat tracking code below (i.e. Google Analytics, StatCounter, etc.)</p>
<textarea class="mceNoEditor" name="statcode" style="width:350px; height: 150px;"><?php echo stripslashes($oldstatcode); ?></textarea>
<br/><br/>
<div style="clear:both"></div>
<input name="settings" type="hidden" id="settings" />
<button type="submit" id="submitstyle" name="save" class="button_colour round_all"><img height="24" width="24" alt="Bended Arrow Right" src="images/icons/small/white/Bended Arrow Right.png"><span>Update Settings</span></button>
</form>
</div>
</div>
</div>
</div>
<?php include 'includes/closing_items.php'?>