Example #1
0
 }
 switch (rand(0, 3)) {
     case 0:
         $status = "Pending";
         break;
     case 1:
         $status = "Sent";
         break;
     case 2:
         $status = "Delivered";
         break;
     case 3:
         $status = "Failed";
         break;
 }
 $singleNumber = generateRandomNumber();
 /*
 echo $date;
 echo "<br>";
 echo $chooseMethod; 
 echo "<br>";
 echo $smsContent;
 echo "<br>";
 echo $whatsappContent;
 echo "<br>";
 echo $senderSms;
 echo "<br>";
 echo $senderWhatsapp;
 
 
 echo $singleNumber;
Example #2
0
 function random_file_name($name)
 {
     return "FILE-" . date("Ymd") . "-" . generateRandomNumber(12) . "." . GetExtension($name);
 }
function applicantAttributes($rows)
{
    $row = array();
    $row['alien_number'] = $rows['a_number'];
    $row['first_name'] = $rows['first_name'];
    $row['middle_name'] = $rows['middle_name'];
    $row['last_name'] = $rows['last_name'];
    $row['date_of_birth'] = trim($rows['date_of_birth']);
    $row['address']['in_care_of_name'] = generateRandomNames(1);
    $row['address']['address'] = generateRandomString(5);
    $row['address']['address2'] = generateRandomString(5);
    $row['address']['address2_type'] = "apt";
    $row['address']['city'] = generateRandomString(3);
    $row['address']['state'] = strtoupper(generateRandomString(2));
    $row['address']['zip_code'] = generateRandomNumber(5);
    $row['address']['postal_code'] = generateRandomNumber(5);
    $row['address']['province'] = strtoupper(generateRandomString(4));
    $row['address']['country'] = strtoupper(generateRandomString(4));
    $row['email_address'] = generateRandomString(10);
    $row['daytime_phone_number'] = "1" . generateRandomNumber(9);
    $row['date_of_birth'] = generateRandomDate();
    $row['city_of_birth'] = generateRandomString(7);
    $row['state_of_birth'] = strtoupper(generateRandomString(2));
    $row['country_of_birth'] = strtoupper(generateRandomString(4));
    $row['country_of_citizenship'] = strtoupper(generateRandomString(5));
    $row['country_of_natinoality'] = strtoupper(generateRandomString(4));
    //$row['alien_number'] = "";
    $row['ssn'] = generateRandomNumber(9);
    $row['date_of_arrival'] = generateRandomDate();
    $row['i94'] = generateRandomNumber(9);
    $row['passport_number'] = generateRandomNumber(8);
    $row['travel_document_number'] = generateRandomNumber(6);
    $row['country_of_issuance_of_passport_or_travel_document'] = strtoupper(generateRandomString(4));
    $row['expiration_date_of_passport_or_travel_document'] = generateRandomDate();
    $row['current_non_immigrant_status'] = generateRandomString(7);
    $row['non_immigrant_status_expiration_date'] = generateRandomDate();
    return $row;
}
Example #4
0
 */
function generateRandomNumber($how)
{
    $count = 1;
    // инициализация счётчика
    $exit = '';
    // переменная для сгенерированного числа
    while ($count <= $how) {
        if ($count == 1) {
            // если генерируем первое число в серии, оно будет от 1 до 9
            $exit .= mt_rand(1, 9);
        } else {
            // все последующие генерируются от 0 до 9
            $exit .= mt_rand(0, 9);
            //
        }
        $count++;
    }
    return $exit;
    // возвращаем сгенерированное число
}
function generationAlgebraSymbol()
{
    $letters = "+-";
    // удалены спорные буквы
    $exitCode = "";
    $exitCode .= $letters[mt_rand(0, 1)];
    return $exitCode;
}
print generateRandomNumber(4) . " " . generationAlgebraSymbol() . " " . generateRandomNumber(4);
// пример вызова генерации числа с заданным кол символов
Example #5
0
function parsePlaceholderString($formVars, $placeholderString, $fallbackPlaceholderString)
{
    global $alnum, $alpha, $cntrl, $dash, $digit, $graph, $lower, $print, $punct, $space, $upper, $word, $patternModifiers;
    // defined in 'transtab_unicode_charset.inc.php' and 'transtab_latin1_charset.inc.php'
    if (empty($placeholderString)) {
        $placeholderString = $fallbackPlaceholderString;
    }
    // if, for some odd reason, an empty placeholder string was given, we'll use the placeholder(s) given in '$fallbackPlaceholderString'
    $placeholderPartsArray = preg_split("/[<>]/", $placeholderString);
    // split placeholder string into its individual components
    $convertedPlaceholderArray = array();
    // initialize array variable which will hold the transformed placeholder parts
    foreach ($placeholderPartsArray as $placeholderPart) {
        if (!empty($placeholderPart)) {
            if (preg_match("/:\\w+/", $placeholderPart)) {
                // extract any custom options given within a placeholder:
                if (preg_match("/:\\w+\\[[^][]+\\]:/i", $placeholderPart)) {
                    // the placeholder contains custom options
                    $options = preg_replace("/.*:\\w+(\\[[^][]+\\]):.*/i", "\\1", $placeholderPart);
                } else {
                    $options = "";
                }
                // extract any prefix given within a placeholder:
                if (preg_match("/^[^:]+:\\w+(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    // the placeholder contains a prefix
                    $prefix = preg_replace("/^([^:]+):\\w+(\\[[^][]*\\])?:.*/i", "\\1", $placeholderPart);
                } else {
                    $prefix = "";
                }
                // extract any suffix given within a placeholder:
                if (preg_match("/:\\w+(\\[[^][]*\\])?:[^:]+\$/i", $placeholderPart)) {
                    // the placeholder contains a suffix
                    $suffix = preg_replace("/.*:\\w+(?:\\[[^][]*\\])?:([^:]+)\$/i", "\\1", $placeholderPart);
                } else {
                    $suffix = "";
                }
                // call dedicated functions for the different placeholders (if required):
                // '<:serial:>' placeholder:
                if (preg_match("/:serial:/i", $placeholderPart)) {
                    $convertedPlaceholderArray[] = $prefix . $formVars['serialNo'] . $suffix;
                } elseif (preg_match("/:firstAuthor:/i", $placeholderPart)) {
                    if (!empty($formVars['authorName'])) {
                        $firstAuthor = $prefix;
                        // Call the 'extractAuthorsLastName()' function to extract the last name of a particular author (specified by position):
                        // (see function header for description of required parameters)
                        $firstAuthor .= extractAuthorsLastName("/ *; */", "/ *, */", 1, $formVars['authorName']);
                        $firstAuthor .= $suffix;
                        $convertedPlaceholderArray[] = $firstAuthor;
                    }
                } elseif (preg_match("/:secondAuthor:/i", $placeholderPart)) {
                    if (!empty($formVars['authorName']) and preg_match("/;/", $formVars['authorName'])) {
                        $secondAuthor = $prefix;
                        // Call the 'extractAuthorsLastName()' function to extract the last name of a particular author (specified by position):
                        // (see function header for description of required parameters)
                        $secondAuthor .= extractAuthorsLastName("/ *; */", "/ *, */", 2, $formVars['authorName']);
                        $secondAuthor .= $suffix;
                        $convertedPlaceholderArray[] = $secondAuthor;
                    }
                } elseif (preg_match("/:authors(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['authorName'])) {
                        $authors = $prefix;
                        $authors .= extractDetailsFromAuthors($formVars['authorName'], $options);
                        $authors .= $suffix;
                        $convertedPlaceholderArray[] = $authors;
                    }
                } elseif (preg_match("/:title(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['titleName'])) {
                        $title = $prefix;
                        $title .= extractDetailsFromField("title", $formVars['titleName'], "/[^-{$word}]+/{$patternModifiers}", $options);
                        $title .= $suffix;
                        $convertedPlaceholderArray[] = $title;
                    }
                } elseif (preg_match("/:year(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['yearNo']) and preg_match("/\\d+/i", $formVars['yearNo'])) {
                        $year = $prefix;
                        $year .= extractDetailsFromYear($formVars['yearNo'], $options);
                        $year .= $suffix;
                        $convertedPlaceholderArray[] = $year;
                    }
                } elseif (preg_match("/:publication(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['publicationName'])) {
                        $publication = $prefix;
                        $publication .= extractDetailsFromField("publication", $formVars['publicationName'], "/[^-{$word}]+/{$patternModifiers}", $options);
                        $publication .= $suffix;
                        $convertedPlaceholderArray[] = $publication;
                    }
                } elseif (preg_match("/:abbrevJournal(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['abbrevJournalName'])) {
                        $abbrevJournal = $prefix;
                        $abbrevJournal .= extractDetailsFromField("abbrev_journal", $formVars['abbrevJournalName'], "/[^-{$word}]+/{$patternModifiers}", $options);
                        $abbrevJournal .= $suffix;
                        $convertedPlaceholderArray[] = $abbrevJournal;
                    }
                } elseif (preg_match("/:volume:/i", $placeholderPart)) {
                    if (!empty($formVars['volumeNo'])) {
                        // if the 'volume' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['volumeNo'] . $suffix;
                    }
                } elseif (preg_match("/:issue:/i", $placeholderPart)) {
                    if (!empty($formVars['issueNo'])) {
                        // if the 'issue' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['issueNo'] . $suffix;
                    }
                } elseif (preg_match("/:pages:/i", $placeholderPart)) {
                    if (!empty($formVars['pagesNo'])) {
                        // if the 'pages' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['pagesNo'] . $suffix;
                    }
                } elseif (preg_match("/:startPage:/i", $placeholderPart)) {
                    if (!empty($formVars['pagesNo']) and preg_match("/\\d+/i", $formVars['pagesNo'])) {
                        $startPage = $prefix;
                        $startPage .= preg_replace("/^\\D*?(\\w*\\d+\\w*).*/i", "\\1", $formVars['pagesNo']);
                        // extract starting page
                        $startPage .= $suffix;
                        $convertedPlaceholderArray[] = $startPage;
                    }
                } elseif (preg_match("/:endPage:/i", $placeholderPart)) {
                    if (!empty($formVars['pagesNo']) and preg_match("/\\d+/i", $formVars['pagesNo'])) {
                        $pages = preg_replace("/^\\D*?(\\w*\\d+\\w*)( *[{$dash}]+ *\\w*\\d+\\w*)?.*/i{$patternModifiers}", "\\1\\2", $formVars['pagesNo']);
                        // extract page range (if there's any), otherwise just the first number
                        $endPage = $prefix;
                        $endPage .= extractDetailsFromField("pages", $pages, "/\\D+/", "[-1]");
                        // we'll use this function instead of just grabbing a matched regex pattern since it'll also work when just a number but no range is given (e.g. when startPage = endPage)
                        $endPage .= $suffix;
                        $convertedPlaceholderArray[] = $endPage;
                    }
                } elseif (preg_match("/:keywords(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['keywordsName'])) {
                        $keywords = $prefix;
                        $keywords .= extractDetailsFromField("keywords", $formVars['keywordsName'], "/ *[;,] */", $options);
                        $keywords .= $suffix;
                        $convertedPlaceholderArray[] = $keywords;
                    }
                } elseif (preg_match("/:issn:/i", $placeholderPart)) {
                    if (!empty($formVars['issnName'])) {
                        $convertedPlaceholderArray[] = $prefix . $formVars['issnName'] . $suffix;
                    }
                } elseif (preg_match("/:isbn:/i", $placeholderPart)) {
                    if (!empty($formVars['isbnName'])) {
                        $convertedPlaceholderArray[] = $prefix . $formVars['isbnName'] . $suffix;
                    }
                } elseif (preg_match("/:issn_isbn:/i", $placeholderPart)) {
                    if (!empty($formVars['issnName'])) {
                        // if both, an ISSN and ISBN number are present, the ISSN number will be preferred
                        $convertedPlaceholderArray[] = $prefix . $formVars['issnName'] . $suffix;
                    } elseif (!empty($formVars['isbnName'])) {
                        $convertedPlaceholderArray[] = $prefix . $formVars['isbnName'] . $suffix;
                    }
                } elseif (preg_match("/:area(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['areaName'])) {
                        $area = $prefix;
                        $area .= extractDetailsFromField("area", $formVars['areaName'], "/ *[;,] */", $options);
                        $area .= $suffix;
                        $convertedPlaceholderArray[] = $area;
                    }
                } elseif (preg_match("/:notes(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['notesName'])) {
                        $notes = $prefix;
                        $notes .= extractDetailsFromField("notes", $formVars['notesName'], "/[^-{$word}]+/{$patternModifiers}", $options);
                        $notes .= $suffix;
                        $convertedPlaceholderArray[] = $notes;
                    }
                } elseif (preg_match("/:userKeys(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    if (!empty($formVars['userKeysName'])) {
                        $userKeys = $prefix;
                        $userKeys .= extractDetailsFromField("user_keys", $formVars['userKeysName'], "/ *[;,] */", $options);
                        $userKeys .= $suffix;
                        $convertedPlaceholderArray[] = $userKeys;
                    }
                } elseif (preg_match("/:citeKey:/i", $placeholderPart)) {
                    if (!empty($formVars['citeKeyName'])) {
                        // if the 'cite_key' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['citeKeyName'] . $suffix;
                    }
                } elseif (preg_match("/:doi:/i", $placeholderPart)) {
                    if (!empty($formVars['doiName'])) {
                        // if the 'doi' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['doiName'] . $suffix;
                    }
                } elseif (preg_match("/:recordIdentifier:/i", $placeholderPart)) {
                    if (!empty($formVars['citeKeyName'])) {
                        // if the 'cite_key' field isn't empty
                        $convertedPlaceholderArray[] = $prefix . $formVars['citeKeyName'] . $suffix;
                    } else {
                        $convertedPlaceholderArray[] = $prefix . $formVars['serialNo'] . $suffix;
                    }
                    // otherwise we'll use the record's serial number
                } elseif (preg_match("/:randomNumber(\\[[^][]*\\])?:/i", $placeholderPart)) {
                    $randomString = $prefix;
                    $randomString .= generateRandomNumber($options);
                    $randomString .= $suffix;
                    $convertedPlaceholderArray[] = $randomString;
                }
                // else: un-recognized placeholders will be ignored
            } else {
                $convertedPlaceholderArray[] = $placeholderPart;
                // add part as is to array of transformed placeholder parts
            }
        }
    }
    $convertedPlaceholderString = implode("", $convertedPlaceholderArray);
    // merge transformed placeholder parts
    return $convertedPlaceholderString;
}