#!/usr/bin/perl -Ilibs

package API::Config;

our $Config = {
    'Website_libs'  => "/var/www/libs",
    'image_uploads' => "/tmp",
    'update_DB'     => 1,
    'update_cache'  => 1, # Always 1, but change at will
    'write_image'   => 1,  # Always 1
    'write_cloud'   => 1, # write_cloud can only be '1' on one server
    'photo'         => {
        'host' => "photo.ecstuning.local",
        'user' => "photoftp",
        'pass' => '3AC#RuWWw5@!ga',
        'path' => "/home/photo/product",
    },
    'cwebpExec' => $ENV{'cwebpApiExec'} || $ENV{'cwebpExec'} || '/usr/local/bin/cwebp',
  	'cycleCountLibs' => '/var/www/cycleCount/libs',
};
	
if ( ($ENV{'HOSTNAME'} && $ENV{'HOSTNAME'} =~ /sandbox/) || ($ENV{'HTTP_HOST'} && $ENV{'HTTP_HOST'} =~ /sandbox/) ) {
    # this points to the root of your workspace. Store variable values here so we don't overwrite each other's settings all the time.
    if(!$ENV{'firstInit'}) {
        use File::Spec;
        my @dirs = split('/',File::Spec->rel2abs( __FILE__ ));
        my $configFileLocation = '/'.$dirs[1].'/'.$dirs[2].'/'.$dirs[3].'/config.h';
        require $configFileLocation if -e $configFileLocation;
        $configFileLocation = '/'.$dirs[1].'/'.$dirs[2].'/'.$dirs[3].'/'.$dirs[4].'/config.h';
        require $configFileLocation if -e $configFileLocation;
    }

    my $firstInit = $ENV{'firstInit'} || 'jrohr';
    my $workspace = $ENV{'workspace'} || 'workspace';
    my $portal = $ENV{'portal'} || 'portal';
    my $www = $ENV{'www'} || 'wwwrules';
    my $cycleCount = $ENV{'cycleCount'} || 'cycleCount';
    my $tms = $ENV{'tms'} || 'tms';

    my $workspacePath = '/home/'.$firstInit.'/'.$workspace;

    $Config->{'Website_libs'} = $workspacePath.'/'.$www.'/libs';
    $Config->{'cycleCountLibs'} = $workspacePath.'/'.$cycleCount.'/libs';
    $Config->{'image_uploads'} =  $workspacePath.'/'.$portal.'/img';
    $Config->{'write_cloud'} = $ENV{'writeCloud'} || 0;
	$Config->{'cycleCountLibs'} = $workspacePath .'/cycleCount/libs';
} elsif ( ($ENV{'HOSTNAME'} && $ENV{'HOSTNAME'} =~ /api2?.ecstuning.com/) || ($ENV{'HTTP_HOST'} && $ENV{'HTTP_HOST'} =~ /api2?.ecstuning.com/) ) {
    $Config->{'Website_libs'} = "/var/www/libs";
    $Config->{'cycleCountLibs'} = "/var/www/cycleCount/libs";
    $Config->{'image_uploads'} = "/tmp";
    $Config->{'write_cloud'} = 1;
}

1;
