Beispiel #1
0
 function __construct($file_path, $reply_to)
 {
     $MPTextFile = $file_path;
     //need to be absolute path for cron to work
     $MPSepString = ".";
     $MPTextToHTML = true;
     $output = MPPrintRandomText($MPTextFile, $MPSepString, $MPTextToHTML);
     $cleaned_text = preg_replace("/&#?[a-z0-9]+;/i", "", $output);
     $cleaned_with_mention = $reply_to . $cleaned_text;
     $this->text .= checkLength($cleaned_with_mention);
     $this->text .= '. #epistle';
     //add a hashtag
 }
function checkCardDetails($cardType, $cardNumber, $cardMonth, $cardYear, $cardVerify)
{
    $errors = array();
    $cardType = strtolower($cardType);
    // card number and verification code depends on card type
    if ($cardType === 'visa') {
        if (!isDigits($cardNumber) || !checkLength($cardNumber, 16) || !((int) $cardNumber[0] === 4)) {
            array_push($errors, "Invalid card number");
        }
        if (!isDigits($cardVerify) || !checkLength($cardVerify, 3)) {
            array_push($errors, "Invalid card verification code");
        }
    } elseif ($cardType === 'mcard') {
        if (!isDigits($cardNumber) || !checkLength($cardNumber, 16) || !((int) $cardNumber[0] === 5)) {
            array_push($errors, "Invalid card number");
        }
        if (!isDigits($cardVerify) || !checkLength($cardVerify, 3)) {
            array_push($errors, "Invalid card verification code");
        }
    } elseif ($cardType === 'amex') {
        if (!isDigits($cardNumber) || !checkLength($cardNumber, 15) || !((int) $cardNumber[0] === 3)) {
            array_push($errors, "Invalid card number");
        }
        if (!isDigits($cardVerify) || !checkLength($cardVerify, 4)) {
            array_push($errors, "Invalid card verification code");
        }
    } else {
        array_push($errors, "Unrecognised card type");
    }
    // card expiry date depends on current date
    $year = (int) date('Y');
    $month = (int) date('n');
    $cardYear = (int) $cardYear;
    $cardMonth = (int) $cardMonth;
    if ($year > $cardYear) {
        array_push($errors, "Card expiry must be in the future");
    } elseif ($year === $cardYear && $month >= $cardMonth) {
        array_push($errors, "Card expiry must be in the future");
    }
    return $errors;
}
<html>
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Sign Up Form</title>
  <link href='http://fonts.googleapis.com/css?family=Nunito:400,300' rel='stylesheet' type='text/css'>
  <link rel="stylesheet" type="text/css" href="themmoi_thanhvien.css" />
</head>
<body>
<?php 
    // kiểm tra trạng thái xem người dùng đã submit form chưa?
    if (isset($_POST["submit"])) {
        // kiểm tra username hoặc pass có rỗng không. hàm được xây dựng bên file functions
        if ($_POST["user"] == "" || $_POST["pass"] == "") {
            $error = "các trường không được để trống";
        } elseif (checkLength($_POST["user"], 4, 16) || checkLength($_POST["pass"], 4, 16)) {
            $error2 = "username hoặc password phải có độ dài từ 4 đến 16 ký tự";
        } else {
            $user = $_POST["user"];
            $pass = md5($_POST["pass"]);
        }
        // kiểm tra quyền truy cập
        if ($_POST["lc"] == "Unselect") {
            $error3 = "bạn phải lựa chọn quyền truy cập";
        } elseif ($_POST["lc"] == "member") {
            $qtc = 1;
        } elseif ($_POST["lc"] == "admin") {
            $qtc = 2;
        }
        //đọc lại comment bên file sủa nếu bạn chưa hiểu chỗ này
        if (mysql_num_rows(mysql_query("SELECT * FROM `thanh_vien` WHERE `tai_khoan` = '{$user}'")) > 0) {
Beispiel #4
0
function validateDiscography($form)
{
    global $db;
    if (!checkEmpty($form['year']) && !checkLength($form['year'], 4)) {
        $msg = str_replace('%field%', _LBL_YEAR, _ALRT_CHECK_LENGTH);
        $show_tab_type = 'DISCG_INFO';
        return $msg;
    }
    if (!checkEmpty($form['year']) && !checkValidYear($form['year'])) {
        $msg = str_replace('field', _LBL_YEAR, _ALRT_VALID_FIELD);
        $show_tab_type = 'DISCG_INFO';
        return $msg;
    }
    if (!checkEmpty($form['album']) && !checkLength($form['album'], 255)) {
        $msg = str_replace('%field%', _LBL_ALBUM, _ALRT_CHECK_LENGTH);
        $show_tab_type = 'DISCG_INFO';
        return $msg;
    }
    if (!checkEmpty($form['label']) && !checkLength($form['label'], 255)) {
        $msg = str_replace('%field%', _LBL_LABEL, _ALRT_CHECK_LENGTH);
        $show_tab_type = 'DISCG_INFO';
        return $msg;
    }
    if (!checkEmpty($form['year'])) {
        if (checkEmpty($form['album'])) {
            $msg = str_replace('field', _LBL_ALBUM, _ALRT_REQUIRED_FIELD);
            $show_tab_type = 'DISCG_INFO';
            return $msg;
        } else {
            if (checkEmpty($form['label'])) {
                $msg = str_replace('field', _LBL_LABEL, _ALRT_REQUIRED_FIELD);
                $show_tab_type = 'DISCG_INFO';
                return $msg;
            }
        }
    }
    if (!checkEmpty($form['album'])) {
        if (checkEmpty($form['year'])) {
            $msg = str_replace('field', _LBL_YEAR, _ALRT_REQUIRED_FIELD);
            $show_tab_type = 'DISCG_INFO';
            return $msg;
        } else {
            if (checkEmpty($form['label'])) {
                $msg = str_replace('field', _LBL_LABEL, _ALRT_REQUIRED_FIELD);
                $show_tab_type = 'DISCG_INFO';
                return $msg;
            }
        }
    }
    if (!checkEmpty($form['label'])) {
        if (checkEmpty($form['year'])) {
            $msg = str_replace('field', _LBL_YEAR, _ALRT_REQUIRED_FIELD);
            $show_tab_type = 'DISCG_INFO';
            return $msg;
        } else {
            if (checkEmpty($form['album'])) {
                $msg = str_replace('field', _LBL_ALBUM, _ALRT_REQUIRED_FIELD);
                $show_tab_type = 'DISCG_INFO';
                return $msg;
            }
        }
    }
    if (isset($form['album_id'])) {
        $discg_select = "SELECT * FROM xebura_ARTIST_DISCOG \r\n\t\t\tWHERE AF_ARTIST_DISCOG_NAME = '" . stripslashes($form['album']) . "'\r\n\t\t\tAND AF_ARTIST_DISCOG_CATEGORY = '" . stripslashes($form['category']) . "' \r\n\t\t\tAND AF_ARTIST_DISCOG_ID != '" . $form['album_id'] . "'\r\n\t\t\tAND AF_ARTIST_ID = '" . $_SESSION['User_Account_Id'] . "'";
    } else {
        $discg_select = "SELECT * FROM xebura_ARTIST_DISCOG \r\n\t\t\tWHERE AF_ARTIST_DISCOG_NAME = '" . stripslashes($form['album']) . "'\r\n\t\t\tAND AF_ARTIST_DISCOG_CATEGORY = '" . stripslashes($form['category']) . "'\r\n\t\t\tAND AF_ARTIST_ID = '" . $_SESSION['User_Account_Id'] . "'";
    }
    if ($db->query_affected_rows($discg_select) > 0) {
        $msg = _CHECK_DUPLICATE_DISCOGRAPHY;
        $show_tab_type = 'DISCG_INFO';
        return $msg;
    }
    return true;
}
/**
 * Check credit card verification code.
 * This provides some rudimentary validation of a credit card number.
 * These checks depend on the card type:
 * - American express ($cardType = 'amex') card verification codes must be 4 digits long.
 * - MasterCard ($cardType = 'mcard') card verification codes must be 3 digits long.
 * - Visa ($cardType = 'visa') card verification codes must be 3 digits long.
 * 
 * @param string $cardType The type of card, one of 'amex', 'mcard', or 'visa'.
 * @param string $cardVerifiy The credit card verification code.
 * @result True if $cardVerify passes some basic checks, false otherwise.
 */
function checkCardVerification($cardType, $cardVerify)
{
    if (!isDigits($cardVerify)) {
        return false;
    }
    switch ($cardType) {
        case 'amex':
            return checkLength($cardVerify, 4);
            break;
        case 'mcard':
        case 'visa':
            return checkLength($cardVerify, 3);
            break;
        default:
            return false;
    }
}
Beispiel #6
0
    echo htmlentities($_POST['Land']);
}
?>
" required></td>
								</tr>
								<tr>
									<td colspan="2" style="height = 50px; border-bottom: solid 2px #060">
									&nbsp;
									</td>
								</tr>								
								<tr>
									<td>E-mail*
									<?php 
if (isset($_POST['action'])) {
    if ($_POST['action'] == "registreer") {
        checkLength(0, 1, $email, $messageMail);
    }
}
if ($email != $BevestigEmail) {
    echo "<p style= 'font-size: 11px; color: red; float: right;'>email komen niet overeen</p>";
    $error = true;
}
?>
									</td>
									<td><input type="email" name="E-mail" placeholder="E-mail" value ="<?php 
if (isset($_POST['E-mail'])) {
    echo htmlentities($_POST['E-mail']);
}
?>
" required></td>
								</tr>
Beispiel #7
0
function validateDownloadFiles($file, $field_name, $allowed_extensions)
{
    //print_r($file1);
    //exit;
    //$find_characters = array('!','@','#','$','%','^','&','*','(',')','+','=','[',']','\\','\'',';','/','{','}','|','"',':','<','>','?');
    $find_characters = array('\\', '/', ':', '*', '?', '"', '<', '>', '|');
    $allowed_extensions = array('aac', 'aif', 'iff', 'm3u', 'mid', 'midi', 'mp3', 'mpa', 'ra', 'ram', 'wav', 'wma', '3gp', 'asf', 'asx', 'avi', 'mov', 'mp4', 'mpg', 'qt', 'rm', 'swf', 'wmv');
    $max_size = ini_get('upload_max_filesize');
    /*if(is_uploaded_file($file['tmp_name']))
    	{
    		$filePath = $file['tmp_name'];
    		$contentType = $file['type'];
    	}
    	else if($file['tmp_name'] != "")
    	{
    		$msg = str_replace('%field%',$field_name,_ALRT_FILE_ERROR);
    		return $msg;
    	}*/
    $filePath = $file['tmp_name'];
    $contentType = strtolower($file['type']);
    $find_dot_pos = strrpos($file['name'], '.');
    $fname = substr($file['name'], 0, $find_dot_pos);
    foreach ($find_characters as $key => $val) {
        if (strpos($fname, $val) !== False) {
            return _ALRT_FILE_NAME_ERROR;
        }
    }
    if (strtolower(substr($max_size, -1)) == 'm') {
        $max_size = substr($max_size, 0, strlen($max_size) - 1);
    }
    $max_size = $max_size * 1000 * 1024;
    if ($file['size'] == 0 || $file['size'] > $max_size) {
        $msg = str_replace('%field%', $field_name, _ALRT_CHECK_MAXSIZE);
        return $msg;
    }
    if (!checkLength($file['name'], 50)) {
        $msg = str_replace('%field%', $field_name, _ALRT_CHECK_LENGTH);
        return $msg;
    }
    if (!preg_match('#\\.(.+)$#', $file['name'], $matches)) {
        return _ALRT_FILE_EXT_ERROR;
    } else {
        if (in_array(strtolower($matches[1]), $allowed_extensions)) {
            return _ALRT_DOWNLOAD_TYPE_ERROR;
        }
    }
    if (strpos('audio', $contentType) || strpos('video', $contentType)) {
        return _ALRT_FILE_UPLOAD_ERROR;
    }
    return true;
}
Beispiel #8
0
        $letter = strtolower($letter);
        if ($letter == 'a' || $letter == 'e' || $letter == 'i' || $letter == 'o' || ($letter = 'u')) {
            $howManyVowels = $howManyVowels++;
        }
        return $howManyVowels >= 4;
    }
}
function multiExplode($splitters, $text)
{
    $texto = str_replace($splitters, $splitters[0], $text);
    return explode($splitters[0], $texto);
}
$text = $_POST['texto'];
$splitters = [',', ' ', '\\n', '\\t', '.', ':', ';'];
$palabras = multiExplode($splitters, $text);
/*$mayus = false;
  $between = 0;
  $vowels = 0;
  $endsin = 0;*/
foreach ($palabras as $word) {
    if (checkEro($word, $success) && checkVowels($word, $howManyVowels) && checkCapitals($word, $capitals) && checkLength($word, $howLong)) {
        echo "<br>{$word} acaba en 'ero'";
        echo ", tiene más de 4 vocales";
        echo ", empieza por may&uacutescula";
        echo " y tiene entre 8 y 10 letras";
    }
}
?>
    </body>
>>>>>>> d08ca635e88c9439c125812d69e09c071049c5c2
</html>