public function totalPrice() { $rItems = $this->recentListItems; $total = 0; foreach ($rItems as $rItem) { $total += $rItem->item->price * $rItem->qty; } return '$' . strVal(number_format($total / 100, 2)); }
public function newVar($value) { global $_; $numVars = count($_->vars); //create a var name equal to var0 if the variable array is empty. //otherwise append the variable name in the last term of the $vars array $varName = "var" . ($numVars == 0 ? strVal(0) : strVal(intval(substr($_->vars[$numVars - 1], 3)) + 1)); $_->setVar($varName, $value); $_->vars[$numVars] = $varName; return $varName; }
function ripByPage($page) { $pathToDetails = 'http://aramestan.e-sanandaj.ir/BurialRequest/DeadSearch?keyword=&firstName=&lastName=&fatherName=&partNo=0&rowNo=&graveNo=&deathDateFrom=&deathDateTo=&bornDateFrom=&bornDateTo=&page=' . $page; $output = scraperwiki::scrape($pathToDetails); $resultingJsonObject = json_decode($output); for ($id = 0; $id <= 9; $id++) { $entry = array('id' => $resultingJsonObject->{'result'}[$id]->{'Id'}, 'fullname' => strVal($resultingJsonObject->{'result'}[$id]->{'DeadFullName'}), 'fathername' => strVal($resultingJsonObject->{'result'}[$id]->{'DeadFatherName'}), 'birthdate' => strVal($resultingJsonObject->{'result'}[$id]->{'BornDate'}), 'deathdate' => strVal($resultingJsonObject->{'result'}[$id]->{'DeathDate'}), 'partno' => strVal($resultingJsonObject->{'result'}[$id]->{'PartNo'}), 'rowno' => strVal($resultingJsonObject->{'result'}[$id]->{'RowNo'}), 'graveno' => strVal($resultingJsonObject->{'result'}[$id]->{'GraveNo'}), 'gender' => strVal($resultingJsonObject->{'result'}[$id]->{'Gender'}), 'identitycode' => strVal($resultingJsonObject->{'result'}[$id]->{'IdentityCode'})); scraperwiki::save_sqlite(array('data'), $entry); $pagecount = $resultingJsonObject->{'PageNumber'}; } }
public function showRollDice($quess = 0) { $message; $rand = mt_rand(1, 20); if (strVal($rand) === $quess) { $message = 'Right'; } else { $message = 'Wrong'; } $data = array('quess' => $quess, 'message' => $message, 'rand' => $rand); return View::make('roll-dice')->with($data); }
/** * Creates a html view for a php object * This method is taken from the great ameos_formidable extension. * * @param mixed $mMixed * @param boolean $bRecursive * @param int $iLevel * @return string */ private static function viewMixed($mMixed, $bRecursive = TRUE, $iLevel = 0) { $sStyle = 'font-family: Verdana; font-size: 9px;'; $sStyleBlack = $sStyle . 'color: black;'; $sStyleRed = $sStyle . 'color: red;'; $sStyleGreen = $sStyle . 'color: green;'; $aBgColors = array('FFFFFF', 'F8F8F8', 'EEEEEE', 'E7E7E7', 'DDDDDD', 'D7D7D7', 'CCCCCC', 'C6C6C6', 'BBBBBB', 'B6B6B6', 'AAAAAA', 'A5A5A5', '999999', '949494', '888888', '848484', '777777', '737373'); if (is_array($mMixed)) { $result = "<table border=1 style='border: 1px solid silver' cellpadding=1 cellspacing=0 bgcolor='#" . $aBgColors[$iLevel] . "'>"; if (!count($mMixed)) { $result .= "<tr><td><span style='" . $sStyleBlack . "'><b>" . htmlspecialchars('EMPTY!') . '</b></span></td></tr>'; } else { while (list($key, $val) = each($mMixed)) { $result .= "<tr><td valign='top'><span style='" . $sStyleBlack . "'>" . htmlspecialchars((string) $key) . "</span></td><td>"; if (is_array($val)) { $result .= self::viewMixed($val, $bRecursive, $iLevel + 1); } else { $result .= "<span style='" . $sStyleRed . "'>" . self::viewMixed($val, $bRecursive, $iLevel + 1) . "<br /></span>"; } $result .= '</td></tr>'; } } $result .= '</table>'; } elseif (is_resource($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>RESOURCE: </span>" . $mMixed; } elseif (is_object($mMixed)) { if ($bRecursive) { $result = "<span style='" . $sStyleGreen . "'>OBJECT (" . get_class($mMixed) . ") : </span>" . self::viewMixed(get_object_vars($mMixed), FALSE, $iLevel + 1); } else { $result = "<span style='" . $sStyleGreen . "'>OBJECT (" . get_class($mMixed) . ") : !RECURSION STOPPED!</span>"; } } elseif (is_bool($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>BOOLEAN: </span>" . ($mMixed ? 'TRUE' : 'FALSE'); } elseif (is_string($mMixed)) { if (empty($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>STRING(0)</span>"; } else { $result = "<span style='" . $sStyleGreen . "'>STRING(" . strlen($mMixed) . '): </span>' . nl2br(htmlspecialchars((string) $mMixed)); } } elseif (is_null($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>!NULL!</span>"; } elseif (is_integer($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>INTEGER: </span>" . $mMixed; } else { $result = "<span style='" . $sStyleGreen . "'>MIXED: </span>" . nl2br(htmlspecialchars(strVal($mMixed))); } return $result; }
CFile::GetFileArray($arFile))); $arFile["THUMBNAIL"] = (isset($arFile["src"]) ? $arFile["src"] : $arFile["THUMBNAIL"]); // for Blog only if ((substr($arFile["CONTENT_TYPE"], 0, 6) == "image/") && empty($arFile["THUMBNAIL"])) { $tmp = array("fileID" => $arFile["ID"], "fileContentType" => $arFile["CONTENT_TYPE"]); __MPF_ImageResizeHandler($tmp); if (!empty($tmp['img_thumb_src'])) $arFile["THUMBNAIL"] = $tmp['img_thumb_src']; if (!empty($tmp['img_source_src'])) { $arFile["~SRC"] = $arFile["SRC"]; $arFile["SRC"] = $tmp['img_source_src']; } } $arParams["FILES"]["VALUE_JS"][strVal($arFile["ID"])] = array( "element_id" => $arFile["ID"], "element_name" => $arFile["ORIGINAL_NAME"], "element_size" => $arFile["FILE_SIZE"], "element_url" => $arFile["URL"], "element_content_type" => $arFile["CONTENT_TYPE"], "element_thumbnail" => $arFile["SRC"], "element_image" => $arFile["THUMBNAIL"], "isImage" => (substr($arFile["CONTENT_TYPE"], 0, 6) == "image/") ); $arParams["FILES"]["VALUE_HTML"][intVal($arFile["ID"])] = ""; if ($b) { if ($arParams["FILES"]["SHOW"] != "N" && !empty($arFile["THUMBNAIL"]))
/** * * Use this for any testing purpose, to print out any var, by calling this->d() * from any child class * * @param type $var * @param type $item * @param type $exit * */ public function d($var, $item = false, $exit = '') { if ($item) { echo '<br />' . $item . '<br />'; } echo '<pre>'; print_r($var); echo '</pre>'; if (!empty($exit)) { if ($exit == 'path' || $exit == 'p') { exit('--- exit from code ' . strVal($this->wtChildPath) . ' --- ' . $this->wtControllerPath); } exit('--- exit from ' . strVal($exit) . ' --- ' . $this->wtControllerPath); } }
<?php $isIE = strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== FALSE; if ($isIE) { header('Content-Type: text/html'); // necessary, since IE will buffer 1K bytes before rendering echo str_repeat('#', 1024); } else { header('Content-Type: application/json'); } header("Cache-control: no-cache"); $last_event_id = $_GET['last_event_id']; $last_event_id = $last_event_id ? (int) $last_event_id : 0; for ($i = 0; $i < 10; ++$i) { ++$last_event_id; $words = strVal($last_event_id); if ($isIE) { echo '<script type="text/javascript">parent.push("' . $words . '")</script>'; } else { $len = dechex(strlen($words)); $data = "{$len}\r\n{$words}\r\n"; echo $data; } ob_flush(); flush(); sleep(1); }
public function priceToReadable($qty = 1) { return '$' . strVal(number_format($this->price * $qty / 100, 2)); }
/** * validate Validateert een enkele variabele * * @param string $p_sVar De naam van de variabele die gevalideerd wordt * @param int $p_nScope De scope waarin de variabele moet zitten * @param int $p_nType Het type dat de variabele moet hebben * @param boolean $p_bMandatory Moet de variabele verplicht aanwezig zijn of mag deze ook leeg zijn * @return int Resultaat van validatie (RESULT_OK, RESULT_EMPTY, RESULT_INVALID) * @throws ValidationException */ public function validate($p_sVar, $p_nScope, $p_nType, $p_bMandatory) { $nResult = self::RESULT_NOT_VALIDATED; if ($this->isValidScope($p_nScope) && $this->isValidType($p_nType)) { $vResult = $this->getValue($p_sVar, $p_nScope); if ($vResult !== null) { // waarde gevonden $nResult = $this->checkType($vResult, $p_nType); } else { // geen waarde gevonden $nResult = self::RESULT_NON_EXISTENT; } } else { throw new ValidationException("Scope (" . $p_nScope . ") or Type (" . $p_nType . ") invalid"); } // controleer het resultaat switch ($nResult) { case self::RESULT_NOT_VALIDATED: $nResult = self::RESULT_INVALID; break; case self::RESULT_NON_EXISTENT: if ($p_bMandatory) { $nResult = self::RESULT_INVALID; } else { // hoeft niet aanwezig te zijn $nResult = self::RESULT_OK; } break; default: if ($p_bMandatory) { // als veld verplicht is mag deze niet leeg zijn if (strlen(strVal($vResult)) == 0) { $nResult = self::RESULT_INVALID; } } else { // als veld niet verplicht is mag deze ook leeg zijn if (strlen(strVal($vResult)) == 0) { $nResult = self::RESULT_OK; } } } return $nResult; }
/** * Adds a "deny" rule to the ACL * * @param Zend_Acl_Role_Interface|string|array $roles * @param Zend_Acl_Resource_Interface|string|array $resources * @param string|array $privileges * @param Zend_Acl_Assert_Interface $assert * @uses Zend_Acl::deny() * @return Zend_Acl Provides a fluent interface */ public function deny($roles = null, $resources = null, $privileges = null, Zend_Acl_Assert_Interface $assert = null) { $this->_getAdapter()->deny($roles, $resources, $privileges, $assert); $roles = is_array($roles) ? $roles : array($roles); $roles = count($roles) == 0 ? array(null) : $roles; foreach ($roles as $k => $v) { $roles[$k] = $v instanceof Zend_Acl_Role_Interface ? $v->getRoleId() : (is_null($v) ? null : strVal($v)); } $resources = is_array($resources) ? $resources : array($resources); $resources = count($resources) == 0 ? array(null) : $resources; foreach ($resources as $k => $v) { $resources[$k] = $v instanceof Zend_Acl_Resource_Interface ? $v->getResourceId() : (is_null($v) ? null : strVal($v)); } foreach ($roles as $role) { foreach ($resources as $resource) { //Zum Cachen freigeben: if ($this->hasCachingAdapter()) { $this->_getCachingAdapter()->change($role, $resource); } //Als ungeladen markieren if ($this->hasLoaded($role, $resource)) { $this->_setUnloaded($role, $resource); } } } return $this; }
while ($arFile) { $arFile = is_array($arFile) ? $arFile : (array_key_exists($arFile, $arRes) ? $arRes[$arFile] : CFile::GetFileArray($arFile)); $arFile["THUMBNAIL"] = isset($arFile["src"]) ? $arFile["src"] : $arFile["THUMBNAIL"]; // for Blog only if (substr($arFile["CONTENT_TYPE"], 0, 6) == "image/" && empty($arFile["THUMBNAIL"])) { $tmp = array("fileID" => $arFile["ID"], "fileContentType" => $arFile["CONTENT_TYPE"]); __MPF_ImageResizeHandler($tmp); if (!empty($tmp['img_thumb_src'])) { $arFile["THUMBNAIL"] = $tmp['img_thumb_src']; } if (!empty($tmp['img_source_src'])) { $arFile["~SRC"] = $arFile["SRC"]; $arFile["SRC"] = $tmp['img_source_src']; } } $arParams["FILES"]["VALUE_JS"][strVal($arFile["ID"])] = array("element_id" => $arFile["ID"], "element_name" => $arFile["ORIGINAL_NAME"], "element_size" => $arFile["FILE_SIZE"], "element_url" => $arFile["URL"], "element_content_type" => $arFile["CONTENT_TYPE"], "element_thumbnail" => $arFile["SRC"], "element_image" => $arFile["THUMBNAIL"], "isImage" => substr($arFile["CONTENT_TYPE"], 0, 6) == "image/"); $arParams["FILES"]["VALUE_HTML"][intVal($arFile["ID"])] = ""; if ($b) { if ($arParams["FILES"]["SHOW"] != "N" && !empty($arFile["THUMBNAIL"])) { ob_start(); ?> <span class="feed-add-photo-block"> <span class="feed-add-img-wrap"<?php echo in_array("UploadImage", $arParams["PARSER"]) || in_array("UploadFile", $arParams["PARSER"]) ? ' title="' . GetMessage("MPF_INSERT_FILE") . '" onclick="' . $arParams["JS_OBJECT_NAME"] . '.insertFile(\'' . $arFile["ID"] . '\');"' : ''; ?> > <img src="<?php echo $arFile["THUMBNAIL"]; ?> " border="0" width="90" height="90" /> </span>
/** * データをExcelシートに書き込む */ public function writeCell(ExcelSheet $objSht, $row, $col, $data) { switch ($data["t"]) { case "n": //数値 $val = floatVal($data["v"]); $fmt = $this->_format["val"]; $type = ExcelFormat::AS_NUMERIC_STRING; break; case "d": //日付 $val = intVal($data["v"]); $fmt = $this->_format["date"]; $type = ExcelFormat::AS_DATE; break; case "b": //真偽値 $val = boolVal($data["v"]); $fmt = $this->_format["val"]; $type = ExcelFormat::AS_NUMERIC_STRING; break; case "t": //文字列 $val = strVal($data["v"]); $fmt = $this->_format["val"]; $type = ExcelFormat::AS_NUMERIC_STRING; break; default: } //書き込む $objSht->write($row, $col, $val, $fmt, $type); return; }
/** * [Describe function...] * * @param [type] $mMixed: ... * @param [type] $bRecursive: ... * @param [type] $iLevel: ... * @return [type] ... */ function _viewMixed($mMixed, $bRecursive = TRUE, $iLevel = 0) { $sStyle = "font-family: Verdana; font-size: 9px;"; $sStyleBlack = $sStyle . "color: black;"; $sStyleRed = $sStyle . "color: red;"; $sStyleGreen = $sStyle . "color: green;"; $aBgColors = array("FFFFFF", "F8F8F8", "EEEEEE", "E7E7E7", "DDDDDD", "D7D7D7", "CCCCCC", "C6C6C6", "BBBBBB", "B6B6B6", "AAAAAA", "A5A5A5", "999999", "949494", "888888", "848484", "777777", "737373"); if (is_array($mMixed)) { $result = "<table border=1 style='border: 1px solid silver' cellpadding=1 cellspacing=0 bgcolor='#" . $aBgColors[$iLevel] . "'>"; if (!count($mMixed)) { $result .= "<tr><td><span style='" . $sStyleBlack . "'><b>" . htmlspecialchars("EMPTY!") . "</b></span></td></tr>"; } else { while (list($key, $val) = each($mMixed)) { $result .= "<tr><td valign='top'><span style='" . $sStyleBlack . "'>" . htmlspecialchars((string) $key) . "</span></td><td>"; if (is_array($val)) { $result .= tx_ameosformidable::_viewMixed($val, $bRecursive, $iLevel + 1); } else { $result .= "<span style='" . $sStyleRed . "'>" . tx_ameosformidable::_viewMixed($val, $bRecursive, $iLevel + 1) . "<br /></span>"; } $result .= "</td></tr>"; } } $result .= "</table>"; } elseif (is_resource($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>RESOURCE: </span>" . $mMixed; } elseif (is_object($mMixed)) { if ($bRecursive) { $result = "<span style='" . $sStyleGreen . "'>OBJECT (" . get_class($mMixed) . ") : </span>" . tx_ameosformidable::_viewMixed(get_object_vars($mMixed), FALSE, $iLevel + 1); } else { $result = "<span style='" . $sStyleGreen . "'>OBJECT (" . get_class($mMixed) . ") : !RECURSION STOPPED!</span>"; // . t3lib_div::view_array(get_object_vars($mMixed), FALSE); } } elseif (is_bool($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>BOOLEAN: </span>" . ($mMixed ? "TRUE" : "FALSE"); } elseif (is_string($mMixed)) { if (empty($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>STRING(0)</span>"; } else { $result = "<span style='" . $sStyleGreen . "'>STRING(" . strlen($mMixed) . "): </span>" . nl2br(htmlspecialchars((string) $mMixed)); } } elseif (is_null($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>!NULL!</span>"; } elseif (is_integer($mMixed)) { $result = "<span style='" . $sStyleGreen . "'>INTEGER: </span>" . $mMixed; } else { $result = "<span style='" . $sStyleGreen . "'>MIXED: </span>" . nl2br(htmlspecialchars(strVal($mMixed))); } return $result; }
} else { echo "error" . $query . "<br>" . mysqli_error($conn); } echo "Connected Successfully!"; ?> <!DOCTYPE html> <html> <body> <p id = "rece"></p> </body> <script type="text/javascript"> window.location.href = "http://localhost/mainpage.html?id=<?php echo strVal($idFinal); ?> "; </script> <html>
/** * set a param as a string * * @return bool * @param int $nr * @param string $value */ public function setString($nr, $value) { if (is_int($nr)) { $this->params[$nr] = "'" . $this->escape(strVal($value)) . "'"; return true; } return false; }
<div class="feed-add-post-form-variants" id="feed-add-post-form-tab"><?php echo $strGratVote; $APPLICATION->ShowViewContent("sonet_blog_form"); ?> <div id="feed-add-post-form-tab-arrow" class="feed-add-post-form-arrow" style="left: 31px;"></div><?php ?> </div><?php ?> </div><?php } $htmlAfterTextarea = ""; if (!empty($arResult["Images"])) { $arFile = reset($arResult["Images"]); $arJSFiles = array(); while ($arFile) { $arJSFiles[strVal($arFile["ID"])] = array("element_id" => $arFile["ID"], "element_name" => $arFile["FILE_NAME"], "element_size" => $arFile["FILE_SIZE"], "element_url" => $arFile["URL"], "element_content_type" => $arFile["CONTENT_TYPE"], "element_thumbnail" => $arFile["SRC"], "element_image" => $arFile["THUMBNAIL"], "isImage" => substr($arFile["CONTENT_TYPE"], 0, 6) == "image/", "del_url" => $arFile["DEL_URL"]); $title = GetMessage("MPF_INSERT_FILE"); $arFile["DEL_URL"] = CUtil::JSEscape($arFile["DEL_URL"]); $htmlAfterTextarea .= <<<HTML <span class="feed-add-photo-block" id="blog-doc{$arFile["ID"]}"> \t<span class="feed-add-img-wrap" title="{$title}"> \t\t<img src="{$arFile["THUMBNAIL"]}" border="0" width="90" height="90" /> \t</span> \t<span class="feed-add-img-title" title="{$title}">{$arFile["NAME"]}</span> \t<span class="feed-add-post-del-but"></span> </span> HTML; $arFile = next($arResult["Images"]); } if ($htmlAfterTextarea !== "") { $arJSFiles = CUtil::PhpToJSObject($arJSFiles);
while ($arFile) { $arFile = is_array($arFile) ? $arFile : (array_key_exists($arFile, $arRes) ? $arRes[$arFile] : CFile::GetFileArray($arFile)); $arFile["THUMBNAIL"] = isset($arFile["src"]) ? $arFile["src"] : $arFile["THUMBNAIL"]; // for Blog only if (substr($arFile["CONTENT_TYPE"], 0, 6) == "image/" && empty($arFile["THUMBNAIL"])) { $tmp = array("fileID" => $arFile["ID"], "fileContentType" => $arFile["CONTENT_TYPE"]); __MPF_ImageResizeHandler($tmp); if (!empty($tmp['img_thumb_src'])) { $arFile["THUMBNAIL"] = $tmp['img_thumb_src']; } if (!empty($tmp['img_source_src'])) { $arFile["~SRC"] = $arFile["SRC"]; $arFile["SRC"] = $tmp['img_source_src']; } } $arParams["FILES"]["VALUE_JS"][strVal($arFile["ID"])] = array("id" => $arFile["ID"], "name" => $arFile["ORIGINAL_NAME"], "size" => $arFile["FILE_SIZE"], "url" => $arFile["URL"], "type" => $arFile["CONTENT_TYPE"], "src" => $arFile["SRC"], "thumbnail" => $arFile["THUMBNAIL"], "isImage" => substr($arFile["CONTENT_TYPE"], 0, 6) == "image/"); $arParams["FILES"]["VALUE_HTML"][intVal($arFile["ID"])] = ""; if ($b) { if ($arParams["FILES"]["SHOW"] != "N" && !empty($arFile["THUMBNAIL"])) { ob_start(); ?> <span class="feed-add-photo-block"> <span class="feed-add-img-wrap"<?php echo in_array("UploadImage", $arParams["PARSER"]) || in_array("UploadFile", $arParams["PARSER"]) ? ' title="' . GetMessage("MPF_INSERT_FILE") . '" onclick="' . $arParams["JS_OBJECT_NAME"] . '.insertFile(\'' . $arFile["ID"] . '\');"' : ''; ?> > <img src="<?php echo $arFile["THUMBNAIL"]; ?> " border="0" width="90" height="90" /> </span>