403Webshell
Server IP : 210.245.233.93  /  Your IP : 216.73.216.226
Web Server : Apache/2.2.15 (CentOS)
System : Linux webserver2.onesolution.com.hk 2.6.32-754.35.1.el6.x86_64 #1 SMP Sat Nov 7 12:42:14 UTC 2020 x86_64
User : apache ( 48)
PHP Version : 5.3.3
Disable Function : exec, shell_exec, system, passthru, popen, proc_open, pcntl_exec
MySQL : ON  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON  |  Sudo : ON  |  Pkexec : ON
Directory :  /var/www/onesolution.com.hk/onesupport/job/views/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /var/www/onesolution.com.hk/onesupport/job/views/generate_date_list.php
<?php include ('../../inc/configure.php'); ?>


<style type="text/css">
	div.scroll_to_top {
		position: fixed;
		bottom: 0;
		left: 50%;
		color: white;
		padding: 2px 5px 0px 5px;
	}
</style>

<style type="text/css">
	body {
		padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
		padding-bottom: 40px;
	}
	td{
		text-align: center;
	}
</style>


<?php

	$sql = "SELECT * FROM sup_public_holiday WHERE year >= '".date("Y")."' order by holiday_date ASC";
	$parameters = array(0);
	if (!($sth = $dbh->prepare($sql))) {
		throw new Exception("sql prepare statement failure: $sql");
	}
	$sth->setFetchMode(PDO::FETCH_ASSOC);
	if (!$sth->execute($parameters)) {
		throw new Exception("sql execute statement failure: $sql");
	}
	$holiday = $sth->fetchAll();

	$allow_edit_mode = false;
	if (Util::isAdmin()) { // admin
		$allow_edit_mode = true;
	} else {
		if (empty($job['id'])) { // new job
			$allow_edit_mode = true;
		} else {
			if ($job['type'] == 4) { // remote service call
				$allow_edit_mode = true;
			}
		}
	}
	$period      = $_GET["period"];
	$frequency      = $_GET["frequency"];
	$date_from = $_GET["date_from"];
	$date_to   = $_GET["date_to"];
	$selected_week   = $_GET["selected_week"];
	$start_time_weekly   = $_GET["start_time_weekly"];
	$end_time_weekly   = $_GET["end_time_weekly"];
	$start_time_daily   = $_GET["start_time_daily"];
	$end_time_daily   = $_GET["end_time_daily"];
	$whichweek   = $_GET["whichweek"];

	//monthly
	$selected_week_array = explode(',', $selected_week);
	$start_time_array = explode(',', $start_time_weekly);
	$end_time_array = explode(',', $end_time_weekly);

	if(strtotime($date_from) > strtotime($date_to)){
		echo "<div style='color: red;'>Job Date From should be early than Job Date To!</div>";
		exit;
	}

	if(empty($date_from) || empty($date_to)){
		echo "<div style='color: red;'>Job Date From or Job Date To should not be empty!</div>";
		exit;
	}

	if($period == 3 && empty($whichweek)){
		echo "<div style='color: red;'>Which Week should not be empty!</div>";
		exit;
	}


	echo "<table border='1' cellpadding='5' style='text-align: center;'>
			<tr>
			<th><input type='button' id='toggle2' value='All' onClick='available_date()' style='width: 50px;'/></th>
			<th>Date</th>
			<th>Week</th>
			<th>Start Time</th>
			<th>End Time</th>
			</tr>";

	if($period == 1 ){ //daily

		$startTimeStamp = strtotime($date_from);
		$endTimeStamp = strtotime($date_to);

		$timeDiff = abs($endTimeStamp - $startTimeStamp);

		$numberDays = $timeDiff/86400;  // 86400 seconds in one day

		// and you might want to convert to integer
		$numberDays = intval($numberDays);
		$loopnum = floor($numberDays/$frequency)+1;


		echo "<input type=\"hidden\" id=\"totalloop1\" value='".$loopnum."' />";

		for($i = 0; $i<$loopnum; $i++){

			//$enddate = date(strtotime($startdate . "+1 day"));
			$NewDate=Date('Y-m-d', strtotime($date_from ."+".$frequency*$i." days"));

			$NewWeek = date("D", strtotime($NewDate));

			?>
			<tr>
				<td>
					<input type="checkbox" name="arraynum[]" value='<?=$i?>' class="checkall2"/>
				</td>

				<td>
					<?//=$NewDate?>
						<div class="controls" style="padding: 0;margin: 0;" >
							<div class="input-append date-picker">
								<input type="text" id="date_<?=$i?>" name="selected_day[]" value="<?= h(Util::value_to_date_string($NewDate)) ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="Date" <?php foreach($holiday as $holiday_date) if($holiday_date["holiday_date"] == $NewDate || $NewWeek == "Sun") echo "style='color: #FA5858;'"?>/>

									<span class="add-on">
										<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
									</span>

							</div>
						</div>

				</td>

				<td>
					<div id="week_<?=$i?>" >
						<?=$NewWeek?>
					</div>
				</td>

				<td>
					<?php $attribute = 'start_time1'; $label = 'Start Time'; ?>

					<div class="controls" style="padding: 0;margin: 0;">
						<div class="input-append time-picker">
							<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$start_time_daily?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
							<?php if ($allow_edit_mode): ?>
								<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
							<?php endif; ?>
						</div>
					</div>
				</td>

				<td>
					<?php $attribute = 'end_time1'; $label = 'End Time'; ?>

					<div class="controls" style="padding: 0;margin: 0;">
						<div class="input-append time-picker">
							<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$end_time_daily?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
							<?php if ($allow_edit_mode): ?>
								<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
							<?php endif; ?>
						</div>
					</div>
				</td>

			</tr>
		<?php
		}

	}else if($period==2){  //weekly

		$startTimeStamp = strtotime($date_from);
		$endTimeStamp = strtotime($date_to);

		$timeDiff = abs($endTimeStamp - $startTimeStamp);

		$numberweeks = $timeDiff/86400/7;  // 86400 seconds in one day

		// and you might want to convert to integer
		$numberweeks = intval($numberweeks);
		$loopnum = floor($numberweeks/$frequency)+1;


		$countrow = 0;
		for($i = 0; $i<$loopnum; $i++){

			//$enddate = date(strtotime($startdate . "+1 day"));
			$NewDate=Date('Y-m-d', strtotime($date_from ."+".$frequency*$i." week"));
			$NewWeek = date("D", strtotime($NewDate));

			$week = array();
			$week = Job::week();

			for($j = 1; $j <= 7; $j++){
				$adddays = $j-1;
				$NewDate=Date('Y-m-d', strtotime($date_from ."+".$frequency*$i." week +".$adddays." days"));
				$NewWeek = date("D", strtotime($NewDate));
				$NewWeek_num = date("N", strtotime($NewDate));

				//echo $NewDate."(".$NewWeek."),";
				foreach($selected_week_array as $key => $targeweek){
					//echo $targeweek;

					if($NewWeek_num == $targeweek && $NewDate <= $date_to){    //this week equal to the user selected week, that is the target
						?>
						<tr>
							<td>
								<input type="checkbox" name="arraynum[]" value='<?=$countrow?>' class="checkall2"/>

							</td>

							<td>
								<?//=$NewDate?>
								<div class="controls" style="padding: 0;margin: 0;" >
									<div class="input-append date-picker">
										<input type="text" id="date_<?=$countrow?>" name="selected_day[]" value="<?= h(Util::value_to_date_string($NewDate)) ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="Date" <?php foreach($holiday as $holiday_date) if($holiday_date["holiday_date"] == $NewDate || $NewWeek == "Sun") echo "style='color: #FA5858;'"?>/>

									<span class="add-on">
										<i data-time-icon="icon-time" data-date-icon="icon-calendar" "></i>
									</span>

									</div>
								</div>

							</td>

							<td>
								<div id="week_<?=$countrow?>" >
									<?=$NewWeek?>
								</div>
							</td>

							<td>
								<?php $attribute = 'start_time1'; $label = 'Start Time'; ?>

								<div class="controls" style="padding: 0;margin: 0;">
									<div class="input-append time-picker">
										<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$start_time_array[$key]?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
										<?php if ($allow_edit_mode): ?>
											<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
										<?php endif; ?>
									</div>
								</div>
							</td>

							<td>
								<?php $attribute = 'end_time1'; $label = 'End Time'; ?>

								<div class="controls" style="padding: 0;margin: 0;">
									<div class="input-append time-picker">
										<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$end_time_array[$key]?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
										<?php if ($allow_edit_mode): ?>
											<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
										<?php endif; ?>
									</div>
								</div>
							</td>

						</tr>
						<?php
						$countrow++;
					}
				}
			}
		}

		echo "<input type=\"hidden\" id=\"totalloop2\" value='".$countrow."' />";

	}else if($period==3){   //monthly
		$date_from_month = date("n", strtotime($date_from)); //1-12

		$datefrom_year_month_day =  date("Y-m-01", strtotime($date_from));
		$dateto_year_month_day =  date("Y-m-01", strtotime($date_to));
		//$datetime1 = date_create($date_from);
		$datetime1 = date_create($datefrom_year_month_day);
		//$datetime2 = date_create($date_to);
		$datetime2 = date_create($dateto_year_month_day);
		$interval = date_diff($datetime1, $datetime2);
		$numofmonth = $interval->format('%m months');
		$numofyear = $interval->format('%y months');

		$loopnum = $numofyear*12+$numofmonth+1;

		$countrow = 0;

		//testing

		$datefrom_year_month =  date("Y-m", strtotime($date_from));

		for($i = 0; $i < $loopnum; $i++){ //how many month between that period

			for($j = 1; $j <= 7; $j++){
				$adddays = $j-1;

				//$NewDate=Date('Y-m-d', strtotime($date_from ."+".$frequency*$i." month +".($whichweek-1)." week +".$adddays." days"));
				$NewDate=Date('Y-m-d', strtotime($datefrom_year_month."-01" ."+".$frequency*$i." month +".($whichweek-1)." week +".$adddays." days"));


				if($whichweek==5 && date("j", strtotime($NewDate)) <29){
					break;
				}
				$NewWeek = date("D", strtotime($NewDate));
				$NewWeek_num = date("N", strtotime($NewDate));


				if($NewDate > $date_to || $NewDate < $date_from){

				}else{
					//echo $NewDate."(".$NewWeek."),";
					foreach($selected_week_array as $key => $targeweek){
						//echo $targeweek;

						if($NewWeek_num == $targeweek && $NewDate <= $date_to){

						?>

							<tr>
								<td>
									<input type="checkbox" name="arraynum[]" value='<?=$countrow?>' class="checkall2"/>

								</td>

								<td>
									<?//=$NewDate?>
									<div class="controls" style="padding: 0;margin: 0;" >
										<div class="input-append date-picker">
											<input type="text" id="date_<?=$countrow?>" name="selected_day[]" value="<?= h(Util::value_to_date_string($NewDate)) ?>" class="dateISO" data-format="yyyy-MM-dd" placeholder="Date" <?php foreach($holiday as $holiday_date) if($holiday_date["holiday_date"] == $NewDate || $NewWeek == "Sun") echo "style='color: #FA5858;'"?>/>

									<span class="add-on">
										<i data-time-icon="icon-time" data-date-icon="icon-calendar" ></i>
									</span>

										</div>
									</div>

								</td>

								<td>
									<div id="week_<?=$countrow?>" >
										<?=$NewWeek?>
									</div>
								</td>

								<td>
									<?php $attribute = 'start_time1'; $label = 'Start Time'; ?>

									<div class="controls" style="padding: 0;margin: 0;">
										<div class="input-append time-picker">
											<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$start_time_array[$key]?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
											<?php if ($allow_edit_mode): ?>
												<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
											<?php endif; ?>
										</div>
									</div>
								</td>

								<td>
									<?php $attribute = 'end_time1'; $label = 'End Time'; ?>

									<div class="controls" style="padding: 0;margin: 0;">
										<div class="input-append time-picker">
											<input type="text" id="<?=$attribute?>" name="<?=$attribute?>[]" value="<?=$end_time_array[$key]?>" class="time" data-format="hh:mm" placeholder="<?=$label?>"<?=$allow_edit_mode ? '' : ' disabled="disabled"'?> />
											<?php if ($allow_edit_mode): ?>
												<span class="add-on">
							<i data-time-icon="icon-time" data-date-icon="icon-calendar"></i>
						</span>
											<?php endif; ?>
										</div>
									</div>
								</td>

							</tr>
							<?php
							$countrow++;
						}
					}
				}
			}

		}

		echo "<input type=\"hidden\" id=\"totalloop3\" value='".$countrow."' />";
	}else{}
	?>



<?php
	$_SESSION['period'] = $period;
	$_SESSION['customer_id'] = (int)$_GET["customer_id"];

?>


Youez - 2016 - github.com/yon3zu
LinuXploit