<?php

@ini_set("track_errors", "1");
@set_magic_quotes_runtime(0);
//error_reporting(0);
$devedit_internal_possible_products = array
(
	// sendstudio
	array(
		'exists'	=> '/../functions/sendstudio_functions.php',
		'record'	=> '/../temp'
	),
	// webedit nx 1.3
	array(
		'exists'	=> '/../classes/class.page.php',
		'include'	=> '/../../session.php',
	)
);

$devedit_internal_found = false;
foreach($devedit_internal_possible_products as $devedit_internal_is_product)
{
	if (!file_exists(dirname(__FILE__) . $devedit_internal_is_product['exists']))
	{
		continue;
	}

	if
	(
		(isset($devedit_internal_is_product['include']))
		&&
		(file_exists(dirname(__FILE__) . $devedit_internal_is_product['include']))
	)
	{
		$devedit_internal_found = true;
		require_once(dirname(__FILE__) . $devedit_internal_is_product['include']);
		break;
	}

	if
	(
		(isset($devedit_internal_is_product['record']))
		&&
		(is_writeable(dirname(__FILE__) . $devedit_internal_is_product['record']))
	)
	{
		$devedit_internal_found = true;
		@ini_set('session.save_handler', 'files');
		@ini_set('session.save_path', dirname(__FILE__) . $devedit_internal_is_product['record']);
		@ini_set('session.gc_probability', 1);
		@ini_set('session.gc_divisor', 100);
		@ini_set('session.gc_maxlifetime', 3600);
		@session_start();
		break;
	}
}

if ($devedit_internal_found===false)
{
	@session_start();
}

/* 
For some reason some servers do not have these defines set which can cause 
strange errors when uploading
*/
$devedit_internal_missing_constants = array
(
	'UPLOAD_ERR_OK'			=> 0,
	'UPLOAD_ERR_INI_SIZE'	=> 1,
	'UPLOAD_ERR_FORM_SIZE'	=> 2,
	'UPLOAD_ERR_PARTIAL'	=> 3,
	'UPLOAD_ERR_NO_FILE'	=> 4,
	'UPLOAD_ERR_NO_TMP_DIR'	=> 6,
	'UPLOAD_ERR_CANT_WRITE'	=> 7,
	'UPLOAD_ERR_EXTENSION'	=> 8
);
foreach($devedit_internal_missing_constants as $devedit_internal_missing_constant=>$devedit_internal_value)
{
	if (!defined($devedit_internal_missing_constant))
	{
		define($devedit_internal_missing_constant, $devedit_internal_value);
	}
}

require_once(dirname(__FILE__).'/valid_files.php');
