<?php
session_start();
include("./functions.php");
include("./header.php");

$root = $_SERVER['DOCUMENT_ROOT'] . $_SERVER['PHP_SELF'];
//$root = str_replace("control","",$root);
$root = str_replace("/addnewproject_upload.php","",$root);
$rootpath =  $root . "/tmp/";
//echo $rootpath;

if($_REQUEST['submit'] == "NEXT WITH SELECTED") {

	if(isset($_REQUEST['sltart'])) {

		$_SESSION['sltart'] = "";
		$_SESSION['sltart'] = $_REQUEST['sltart'];

		if($_REQUEST['projectnm'] == "") {
			$_REQUEST['projectnm'] = "Unknown";
		}

		foreach($_REQUEST['selt_server'] as $selectedsrv) {
			$res = mysql_query("insert into autoposter_projects (name, server_id) values ('".$_REQUEST['projectnm']."', '$selectedsrv')");
			$pjid .= mysql_insert_id() . ",";
		}

		$pjid = substr($pjid, 0, -1);

		if($_REQUEST['splt_artcl'] == 'yes') {
			redirectTo("wordpress_newproject_spliter.php?selt_pubtype=".$_REQUEST['selt_pubtype']."&pjid={$pjid}&load_meta_profile=".$_REQUEST['load_meta_profile']."&mm=".$_REQUEST['mm']."&dd=".$_REQUEST['dd']."&yy=".$_REQUEST['yy']."&hh=".$_REQUEST['hh']."&mn=".$_REQUEST['mn']."&ss=".$_REQUEST['ss']."&randomize_time=".$_REQUEST['randomize_time']."&enable_x_art_st=".$_REQUEST['enable_x_art_st']."&postxarticle=".$_REQUEST['postxarticle']."&xarticleinxdays=".$_REQUEST['xarticleinxdays']."");
			exit();
		} else {
			redirectTo("wordpress_newproject.php?selt_pubtype=".$_REQUEST['selt_pubtype']."&pjid={$pjid}&load_meta_profile=".$_REQUEST['load_meta_profile']."&mm=".$_REQUEST['mm']."&dd=".$_REQUEST['dd']."&yy=".$_REQUEST['yy']."&hh=".$_REQUEST['hh']."&mn=".$_REQUEST['mn']."&ss=".$_REQUEST['ss']."&randomize_time=".$_REQUEST['randomize_time']."&enable_x_art_st=".$_REQUEST['enable_x_art_st']."&postxarticle=".$_REQUEST['postxarticle']."&xarticleinxdays=".$_REQUEST['xarticleinxdays']."");
			exit();
		}

	} else {
		echo "<br>&nbsp;&nbsp; <b>Please select at least one article...</b>";
	}

} elseif($_REQUEST['submit'] == "NEXT WITHOUT SELECTED") {

	if($_REQUEST['projectnm'] == "") {
		$_REQUEST['projectnm'] = "Unknown";
	}

	if($_REQUEST['xarticle'] == "") {
		$_REQUEST['xarticle'] = "5";
	}

	foreach($_REQUEST['selt_server'] as $selectedsrv) {
		$res = mysql_query("insert into autoposter_projects (name, server_id) values ('".$_REQUEST['projectnm']."', '$selectedsrv')");
		$pjid .= mysql_insert_id() . ",";
	}

    $pjid = substr($pjid, 0, -1);

	redirectTo("wordpress_newproject_withoutupload.php?selt_pubtype=".$_REQUEST['selt_pubtype']."&pjid={$pjid}&xarticle=".$_REQUEST['xarticle']."&load_meta_profile=".$_REQUEST['load_meta_profile']."&mm=".$_REQUEST['mm']."&dd=".$_REQUEST['dd']."&yy=".$_REQUEST['yy']."&hh=".$_REQUEST['hh']."&mn=".$_REQUEST['mn']."&ss=".$_REQUEST['ss']."&randomize_time=".$_REQUEST['randomize_time']."&enable_x_art_st=".$_REQUEST['enable_x_art_st']."&postxarticle=".$_REQUEST['postxarticle']."&xarticleinxdays=".$_REQUEST['xarticleinxdays']."");
	exit();

}

include("./footer.php");
?>