function checkExisting() { global $fullPath, $target_dir, $fileName, $fileType, $counter, $file; if (file_exists($fullPath)) { $counter++; $fullPath = $target_dir . $fileName . "_" . $counter . "." . $fileType; checkExisting(); } }
function checkExisting($filePath, $dir, $pathInfo, $size) { global $counter; if (file_exists(ROOT_PATH . $filePath)) { $counter++; $filePath = $dir . $pathInfo['filename'] . $size->suffix . "_" . $counter . "." . $pathInfo['extension']; return checkExisting($filePath, $dir, $pathInfo, $size); } else { return $filePath; } }
function addNav() { global $connection; if (isset($_GET['name']) && isset($_GET['pc'])) { $name = $connection->real_escape_string($_GET['name']); $parCan = $connection->real_escape_string($_GET['pc']); $parId = getCanonId($parCan); //get min id fron navcats and minus 1 $query = "SELECT..."; if ($result = $connection->query($query)) { $row = $result->fetch_assoc(); $newId = (int) $row['navid']; $newId -= 1; } else { return 'false'; } //create canonical name $nameCan = strtolower($name); $nameCan = str_replace(' ', '-', $nameCan); $nameCan = str_replace("'", '', $nameCan); //check for duplicate name if ($exisiting = checkExisting()) { if (in_array($nameCan, $exisiting)) { $i = 1; do { $nameTest = $nameCan . '-' . $i++; } while (in_array($nameTest, $exisiting)); $nameCan = $nameTest; } } $query = "INSERT..."; if (!($result = $connection->query($query))) { return 'false'; } //get rel order and add 1 $query = "SELECT..."; if ($result = $connection->query($query)) { $row = $result->fetch_assoc(); $rel = (int) $row['rel_order']; $rel += 1; } else { return 'false'; } $query = "INSERT INTO..."; if (!($result = $connection->query($query))) { return 'false'; } return $nameCan; } else { return 'false'; } }
public function actionOcteam() { global $urlRequestRoot, $moduleFolder, $cmsFolder, $templateFolder, $sourceFolder, $STARTSCRIPTS; $mcId = $this->moduleComponentId; require_once $sourceFolder . "/" . $moduleFolder . "/oc/oc_common.php"; require_once $sourceFolder . "/" . $moduleFolder . "/oc/oc_form.php"; if (isset($_POST['passwordChangeOption'])) { $userChecked = $_POST['changeUserDetail']; if (empty($userChecked)) { displayerror("InValid Selection"); } else { if ($_POST['passwordChangeOption'] == 'sollamatten') { unset($_SESSION['availability_S']); unset($_SESSION['availability_M']); unset($_SESSION['availability_L']); unset($_SESSION['availability_XL']); unset($_SESSION['availability_XXL']); unset($_SESSION['availability_food_coupon']); unset($_SESSION['availability_extra']); for ($i = 0; $i < count($userChecked); $i++) { if ($userChecked[$i] == 'S' || $userChecked[$i] == 'M' || $userChecked[$i] == 'L' || $userChecked[$i] == 'XL' || $userChecked[$i] == 'XXL' || $userChecked[$i] == 'food_coupon' || $userChecked[$i] == 'extra') { $_SESSION['availability_' . $userChecked[$i]] = 1; } } } else { displayerror("Wrong Password"); } } } if (isset($_SESSION['availability_S'])) { displayinfo("Small Available"); } if (isset($_SESSION['availability_M'])) { displayinfo("Medium Available"); } if (isset($_SESSION['availability_L'])) { displayinfo("Large Available"); } if (isset($_SESSION['availability_XL'])) { displayinfo("XL Available"); } if (isset($_SESSION['availability_XXL'])) { displayinfo("XXL Available"); } if (isset($_SESSION['availability_food_coupon'])) { displayinfo("Food Coupon Available"); } if (isset($_SESSION['availability_extra'])) { displayinfo("Extra Available"); } if (isset($_POST['roll'])) { $roll = escape($_POST['roll']); //changed to use userid instead of rollno $fetchUserRollQuery = "SELECT * FROM `oc_form_reg` WHERE `page_moduleComponentId`={$mcId} AND \n `user_id`='{$roll}'"; $fetchUserRollResult = mysql_query($fetchUserRollQuery); $roll = mysql_fetch_assoc($fetchUserRollResult)['oc_roll_no']; checkExisting($mcId, $roll, 0, $this->userId); $form = <<<FORM <form id="submitFormLatest" action="./+octeam" onsubmit="return submitLatest(this)" method="post"> <input type="hidden" class="rolledValue" name="roll_latest_submit" value="{$roll}" /> <input type="submit" /> </form> FORM; echo $form; echo final_submit(); exit; } if (isset($_POST['roll_latest_submit'])) { $roll = escape($_POST['roll_latest_submit']); checkExisting($mcId, $roll, 1, $this->userId); exit; } $ocDuty = handleDistribution(); return $ocDuty; }