/** * * 读取excel文件时创建Reader * @param string $fileName 要读取的文件的全路径 * @param string $fileType Excel2007,Excel2003XML,OOCalc,SYLK,Gnumeric,CSV */ public function setReader($fileName = '', $fileType = '') { if (is_file($fileName)) { $this->fileName = $fileName; } if (!empty($fileType) && checkType($fileType)) { $this->fileType = $fileType; } //如果不知道文档类型,则使用PHPExcel_IOFactory的createReaderForFile方法创建reader if (empty($this->fileType)) { $this->excelReader = PHPExcel_IOFactory::createReaderForFile($this->fileName); return true; } else { //如果不知道文档类型,则使用PHPExcel_IOFactory的createReader方法创建reader $this->excelReader = PHPExcel_IOFactory::createReader($this->fileType); return true; } }
<?php //include serverinfo include "../php/servinfo.php"; include "../php/dbfunctions.php"; //immediately check which type of call checkType(); //close connection $conn->close(); /*----------------- CORE FUNCTIONS ------------------*/ //check if they are logging in or registering and call appropriate func function checkType() { if (!strcmp("register", $_POST[type])) { registerUser(); } else { if (!strcmp("login", $_POST[type])) { login(); } else { echo "You've arrived at this page in error."; redir("../login.html"); } } } //Registers user in the db function registerUser() { //grab posted values and escape since user input //grabbed from form input "names"
private function _checkOneField(&$value, $schema, $key = '') { // 校验类型 if (!checkType($value, $schema['$type'])) { Log::error('校验数据格式出错:' . $key . ' - ' . $schema['$type']); throw new Exception(); } // 校验约束条件 if (isset($schema['$constraints']) && !$schema['$constraints']($value)) { Log::error('未通过约束条件校验:' . $key); throw new Exception(); } // 如果是对象数组的话 if ($schema['$type'] == Constant::DATA_TYPE_ARRAY_KV) { $this->checkData($value, $schema['$value']); } // 如果是普通数组 if ($schema['$type'] == Constant::DATA_TYPE_ARRAY) { foreach ($value as $arrValue) { if ($schema['$item']['$type'] == Constant::DATA_TYPE_ARRAY_KV) { $this->checkData($arrValue, $schema['$item']['$value']); } else { $this->checkData($arrValue, $schema['$item']); } } } }
public function getConfigByNameType($name, $type) { try { $configOption = parseConfigName($name, $this); // $name parsed correctly // make some vars shorter $section = $configOption['section']; $namevar = $configOption['namevar']; if (isset($this->configtree[$section][$namevar])) { checkType($this->configtree[$section][$namevar], $type); return $this->configtree[$section][$namevar]; } else { throw new exceptionlist("Config does not exists" . apperror(': ' . $name . ':' . __FILE__ . ': ' . __FUNCTION__ . ': ' . __LINE__, $this)); } } catch (exceptionlist $e) { throw $e; } }
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>IMMAGINE - Inserimento</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css"> </head> <body> <?php require_once "config.php"; require_once "functions.php"; if (!isset($_FILES['file'])) { die("FILE NON RICEVUTO"); } $tmp_name = $_FILES['file']["tmp_name"]; $tipo = $_FILES['file']['type']; $name = $_FILES['file']['name']; echo $name; if (!checkType($tipo)) { die("FILE DI TIPO SCONOSCIUTO"); } if (move_uploaded_file($tmp_name, DIR_IMMAGINI . "/" . $name)) { echo "<p>Inserimento effettuato</p>"; } else { echo "<p>Non hai permessi corretti</p>"; } ?> </body> </html>
/** * Sets the new value. * * @param $newValue (mixed) * @public */ function setValue($newValue) { $r = checkType($newValue, $this->getType()); if (!isError($r)) { if ($this->getInitialValue() === null) { $this->initialValue = $newValue; } $this->currentValue = $newValue; } else { return $r; } }
function testCheckType() { $a = checkType(7.324, 'Float'); $this->assertTrue($a->is('TYPE_NOT_RECOGNIZED')); }
} else { // fetch data $x = 0; $kDef->sql = "select id,gambar,substr(deskripsi,1,200) as isi,link,kategori from tbl_foundation where status=1 order by kategori Desc"; $kDef->perPage = REC_PER_PAGE; $kDef->gul = 10; $smarty->assign('paging',$kDef->pageMe()); $sql = $kDef->genSql(); //echo $sql; $result = $kDef->exQ($sql); if(@mysql_num_rows($result)>0){ while($data = mysql_fetch_array ($result,MYSQL_ASSOC)){ $listFoundation[$x]['id'] = $data['id']; $listFoundation[$x]['link'] = $data['link']; $listFoundation[$x]['isi'] = $data['isi']; $kategori = checkType($listM,$data['kategori']-1); if($data['kategori']){ $listFoundation[$x]['kategori'] = $kategori; } else { $listFoundation[$x]['kategori'] = "not Categorized"; } if($data['gambar'] != ""){ $listFoundation[$x]['image'] = PATH_FOUNDATION."/".$data['gambar']; }else { $listFoundation[$x]['image'] = PATH_FOUNDATION."/noPict.jpg"; } $x++; } }else { $smarty->assign("pesan","Belum ada data"); }