コード例 #1
0
function validateForm(&$errors)
{
    global $letter, $word, $mask;
    if ($letter !== null) {
        $letter = getLetter($letter);
    } else {
        return false;
    }
    if (strpos($word, $letter) === false && strpos($errors, $letter) === false) {
        $errors .= $letter;
    } else {
        if (strpos($word, $letter) !== false) {
            $array = str_split($word);
            foreach ($array as $k => $v) {
                if ($v == $letter) {
                    $mask[$k] = $letter;
                }
            }
            return $mask;
        }
    }
    return false;
}
コード例 #2
0
ファイル: functions.php プロジェクト: licailing/licailing
function getFirstWord($val)
{
    #①转为gb2312(中文)编码:utf-8编码:汉字占3个字节;gb2312编码:汉字占2个字节
    $str = iconv("UTF-8", "gb2312", $val);
    $i = 0;
    $key = '';
    while ($i < strlen($str)) {
        #strlen:字节数
        $tmp = bin2hex(substr($str, $i, 1));
        #bin2hex:函数把ASCII字符(二进制数)的字符串转换为十六进制值
        if ($tmp >= 'B0') {
            //高位字节是汉字:汉字的开始 GB2312编码范围:A1A1-FEFE,其中汉字的编码范围为B0A1-F7FE
            $t = getLetter(hexdec(bin2hex(substr($str, $i, 2))));
            #hexdec:十六进制转换为十进制
            $key .= chr($t);
            #string chr ( int $ascii )  --返回指定的字符
            $i += 2;
        } else {
            $key .= substr($str, $i, 1);
            $i++;
        }
    }
    return $key;
}
コード例 #3
0
ファイル: ask.php プロジェクト: paulbellamy/Senior-Project
require_once "dictionary.inc.php";
if (isset($_POST['data']) && $_POST['data']) {
    $data = $_POST['data'];
} else {
    if (isset($_SESSION['data']) && $_SESSION['data']) {
        $data = $_SESSION['data'];
        $_SESSION['data'] = null;
    }
}
if (!$data) {
    // Pick the word/letter
    if ($_SESSION['type'] == "Words") {
        $data = getWord();
    } else {
        if ($_SESSION['type'] == "Letters") {
            $data = getLetter();
        } else {
            if ($_SESSION['type'] == "Sentences") {
                $data = getSentence(rand(1, 6));
            } else {
                if ($_SESSION['type'] == "Koch Method") {
                    $data = getKochSentence($_SESSION['koch_size'], rand(1, 6));
                }
            }
        }
    }
}
?>
<html>
  <head></head>
  <body onLoad="document.getElementById('answer').focus()">
コード例 #4
0
ファイル: xls_export.php プロジェクト: omusico/sugar_work
$type = "Excel";
$file_extension = ".xls";
$objPHPExcel->setActiveSheetIndex(0);
$styleArray = array('fill' => array('type' => PHPExcel_Style_Fill::FILL_SOLID, 'color' => array('rgb' => 'FFFFFF')), 'borders' => array('allborders' => array('style' => PHPExcel_Style_Border::BORDER_THIN, 'color' => array('rgb' => '000000'))), 'wrap' => true, 'indent' => 5);
$boldFont = array('font' => array('name' => 'Arial Cyr', 'size' => '10', 'bold' => true));
$center = array('alignment' => array('horizontal' => PHPExcel_Style_Alignment::HORIZONTAL_CENTER, 'vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER));
$notBoldFont = array('font' => array('name' => 'Arial Cyr', 'size' => '10', 'bold' => false));
$center_vertical = array('alignment' => array('vertical' => PHPExcel_Style_Alignment::VERTICAL_CENTER));
// Get letter
function getLetter($num)
{
    $Abc = array('A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'AA', 'AB', 'AC', 'AD', 'AE', 'AF', 'AG', 'AH', 'AI', 'AJ', 'AK', 'AL', 'AM', 'AN', 'AO', 'AP', 'AQ', 'AR', 'AS', 'AT', 'AU', 'AV', 'AW', 'AX', 'AY', 'AZ', 'BA', 'BB', 'BC', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI', 'BJ', 'BK', 'BL', 'BM', 'BN', 'BO', 'BP', 'BQ', 'BR', 'BS', 'BT', 'BU', 'BV', 'BW', 'BX', 'BY', 'BZ');
    return $Abc[$num - 1];
}
$letter_num = count($sheetData['cols']);
$letter = getLetter($letter_num);
//Adding Columns Names
$columnLetter = 'A';
foreach ($sheetData['cols'] as $colIndex => $colDef) {
    $cl = $columnLetter++;
    $objPHPExcel->getActiveSheet()->getColumnDimension($cl)->setAutoSize(true);
    $objPHPExcel->getActiveSheet()->getCell($cl . '1')->setValue($colDef);
    $objPHPExcel->getActiveSheet()->getStyle('A1:' . $letter . '1')->applyFromArray($styleArray);
    $objPHPExcel->getActiveSheet()->getStyle('A1:' . $letter . '1')->applyFromArray($boldFont);
    $objPHPExcel->getActiveSheet()->getStyle('A1:' . $letter . '1')->applyFromArray($center);
}
$currentRow = 2;
//Adding data rows
foreach ($sheetData['data'] as $rowIndex => $row) {
    $columnLetter = 'A';
    foreach ($row as $colIndex => $colValue) {
コード例 #5
0
        $temp1[$looper] = $userValue + $keyValue;
        if ($temp1[$looper] > 25) {
            $temp1[$looper] -= 26;
        }
        $final = getLetter($temp1[$looper]);
        if ($userValue > $keyValue) {
            $temp2[$looper] = $userValue - $keyValue;
        } else {
            if ($keyValue > $userValue) {
                $temp2[$looper] = $keyValue - $userValue;
                $temp2[$looper] = 26 - $temp2[$looper];
            } else {
                $temp2[$looper] = 0;
            }
        }
        $decrypt = getLetter($temp2[$looper]);
        $newword .= $decrypt;
    }
    echo "<b>The Decrypted Word is: </b>" . strtoupper($newword);
}
?>

	

<td width="25%" valign="top" bgcolor="#999f8e">&nbsp;</td>

</tr>

<!-- ============ FOOTER SECTION ============== -->
<tr><td colspan="3" align="center" height="5" bgcolor="#777d6a" style="bottom:0; padding:5px 0; margin-left:-0.5%; height:20px; width:100%; background:#222222; font-size:0.5em; color:#f0f0f0; ">
コード例 #6
0
$_SESSION['postData'] = $tempCanner;
$DBConnArray = getDBConn();
if (!$DBConnArray['ErrorReturn']['Success']) {
    $_SESSION['returnArray'] = $DBConnArray['ErrorReturn']['ErrorMessage'];
    header("Location: " . $_SERVER['HTTP_REFERER']);
    return;
}
#
# Check for duplicate on users table
#
$sql = "SELECT * FROM users AS u, canners AS c \n\t\tWHERE c.user_id = u.id AND u.email_address = '" . $tempCanner['email_address'] . "';";
$returnArray = getDataSet($DBConnArray, $sql);
$canner_id = 0;
$weekly_price = 0;
if (count($returnArray['DataSet']) > 0) {
    $canner_id = $returnArray['DataSet'][0]['id'];
    $weekly_price = $returnArray['DataSet'][0]['weekly_price'];
}
$_SESSION['entrance']['on'] = true;
$_SESSION['entrance']['email'] = $tempCanner['email_address'];
echo getLetter($canner_id, $weekly_price);
function getLetter($canner_id, $weekly_price)
{
    if ($canner_id < 1) {
        return "<html><head>\n\t\t\t<link rel='stylesheet' href='../css/invitation.css' />\n\t\t\t</head><body>\n\t\t\t<div class=error>\n\t\t\tWe did not recognize your email  address. Sorry.\n\t\t\t</div>\n\t\t\t</body></html>";
    }
    return "<html>\n<head>\n<link rel='stylesheet' href='../css/invitation.css' />\n<title>Dearest Owner</title>\n</head>\n<body>\n<div class=letter>\nDearest owner of these garbage cans!\n\n<p>It comes to our attention that the people in this neighborhood\nhave many things to think about.</p>\n\n<p>Some people  think about  world peace.</p>\n\n<p>Some people think about world hunger.</p>\n\n<p>Some people think about happiness. Some not.</p>\n\n<p>But really, none of them seem to want to spend a lot of time \nthinking about garbage, garbage cans, when to move them out or\nwhen  to move them back in.</p>\n\n<p>And that could be a simple recipe for neighborhood peace.</p>\n\n<p>Enter 'The Caneur'! That's me!</p>\n\n<p>We have a website (please check us out - www.TheCaneur.com).</p>\n\n<p>We take your garbage cans out - you don't have to think about it.\nWe take your garbage cans in - you don't have to think about it.</p>\n\n<p>Every week - rain, heat, snow, or ice.</p>\n\n<p>You go to the website and create an account (takes about 2 minutes\nand you don't give any more information than we can find in a phone\nbook - remember those?)</p>\n\n<p>Please enter my number: <font color=red>[ " . $canner_id . " ]</font> on the signup form under 'canner id'.  \n<br>Also, you need to give us your garbage day.</p>\n\n<p>Then you can go and pay " . $weekly_price . "/week or " . 4 * $weekly_price . "/month through paypal.</p>\n\n<p>If you decide you want to stop - just go to the website and \nsay 'stop'.</p>\n\n<p>I look forward to helping you think about the important things in \nyour life - not your garbage movement, and your garbage cans!</p>\n\n<p>Best of the best!</p>\n\n<p>~your very own Caneur!</p>\n</div>\n</body>\n</html>";
}
?>