本文整理汇总了PHP中is_pos_int函数的典型用法代码示例。如果您正苦于以下问题:PHP is_pos_int函数的具体用法?PHP is_pos_int怎么用?PHP is_pos_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了is_pos_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTarget
/**
* Get what type we want
*
* @return int The type of item
*/
protected function getTarget()
{
if (isset($_COOKIE['itemType']) && is_pos_int($_COOKIE['itemType'])) {
return $_COOKIE['itemType'];
}
throw new Exception('No cookies found. Import aborted.');
}
示例2: loopIdArr
/**
* Main loop
*
*/
private function loopIdArr()
{
$this->idArr = explode(" ", $this->idList);
foreach ($this->idArr as $id) {
if (!is_pos_int($id)) {
throw new Exception('Bad id.');
}
$this->checkVisibility($id);
$this->initData($id);
$this->setUrl($id);
$this->addLine();
}
$this->writeCsv();
}
示例3: validateId
/**
* Validate the id we get.
*
* @throws Exception if id is bad
*/
private function validateId()
{
if (!is_pos_int($this->id)) {
throw new Exception('Bad id!');
}
}
示例4: display_message
$sql = "SELECT name FROM team_groups WHERE id = :id";
$visreq = $pdo->prepare($sql);
$visreq->bindParam(':id', $data['visibility']);
$visreq->execute();
$visibility = $visreq->fetchColumn();
} else {
$visibility = $data['visibility'];
}
// Check id is owned by connected user to show read only message if not
if ($data['userid'] != $_SESSION['userid']) {
// Can the user see this experiment which is not his ?
if ($data['visibility'] == 'user') {
display_message('error', _("<strong>Access forbidden:</strong> the visibility setting of this experiment is set to 'owner only'."));
require_once 'inc/footer.php';
exit;
} elseif (is_pos_int($data['visibility'])) {
// the visibility of this experiment is set to a group
// we must check if current user is in this group
$sql = "SELECT DISTINCT userid FROM users2team_groups WHERE groupid = :groupid";
$team_group_req = $pdo->prepare($sql);
$team_group_req->bindParam(':groupid', $data['visibility']);
$team_group_req->execute();
$auth_users_arr = array();
while ($auth_users = $team_group_req->fetch()) {
$auth_users_arr[] = $auth_users['userid'];
}
if (!in_array($_SESSION['userid'], $auth_users_arr)) {
display_message('error', _("<strong>Access forbidden:</strong> you don't have the rights to access this."));
require_once 'inc/footer.php';
exit;
}
示例5: die
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR *
* PURPOSE. See the GNU Affero General Public License for more details. *
* *
* You should have received a copy of the GNU Affero General Public *
* License along with eLabFTW. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
require_once 'inc/common.php';
// Check id is valid and assign it to $id
if (isset($_POST['id']) && is_pos_int($_POST['id'])) {
$id = $_POST['id'];
} else {
die("The id parameter in the URL isn't a valid link ID");
}
// Check item_id is valid and assign it to $item_id
if (isset($_POST['item_id']) && is_pos_int($_POST['item_id'])) {
$item_id = $_POST['item_id'];
} else {
die("The item id parameter in the URL isn't valid!");
}
// Check item_id is owned by connected user
$sql = "SELECT userid_creator FROM experiments WHERE id = " . $item_id;
$req = $bdd->prepare($sql);
$req->execute();
$data = $req->fetch();
if ($data['userid_creator'] == $_SESSION['userid']) {
// SQL for DELETE TAG
$sql = "DELETE FROM experiments_links WHERE id=" . $id;
$req = $bdd->prepare($sql);
$result = $req->execute();
if (!$result) {
示例6: foreach
} else {
echo "<div id='search_count'>" . $count . " results</div>";
}
echo "<div class='search_results_div'>";
// Display results
echo "<hr>";
foreach ($results_id as $id) {
showXP($id, $_SESSION['prefs']['display']);
}
} else {
// no results
$message = "Sorry, I couldn't find anything :(";
echo display_message('error', $message);
}
// DATABASE ADVANCED SEARCH
} elseif (is_pos_int($_REQUEST['type'])) {
// SQL
// the BETWEEN stuff makes the date mandatory, so we switch the $sql with/without date
if (isset($_REQUEST['to']) && !empty($_REQUEST['to'])) {
$sql = "SELECT * FROM items WHERE type = :type AND title LIKE '%{$title}%' AND body LIKE '%{$body}%' AND rating LIKE '%{$rating}%' AND date BETWEEN '{$from}' AND '{$to}'";
} elseif (isset($_REQUEST['from']) && !empty($_REQUEST['from'])) {
$sql = "SELECT * FROM items WHERE type = :type AND title LIKE '%{$title}%' AND body LIKE '%{$body}%' AND rating LIKE '%{$rating}%' AND date BETWEEN '{$from}' AND '991212'";
} else {
// no date input
$sql = "SELECT * FROM items WHERE type = :type AND title LIKE '%{$title}%' AND body LIKE '%{$body}%' AND rating LIKE '%{$rating}%'";
}
$req = $bdd->prepare($sql);
$req->execute(array('type' => $_REQUEST['type']));
$count = $req->rowCount();
if ($count > 0) {
// make array of results id
示例7: die
if (isset($_GET['id']) && !empty($_GET['id']) && is_pos_int($_GET['id'])) {
$id = $_GET['id'];
} else {
die(_("The id parameter is not valid!"));
}
if ($_GET['type'] === 'exp') {
$type = 'experiments';
} elseif ($_GET['type'] === 'db') {
$type = 'items';
} else {
die(_("The type parameter is not valid."));
}
// this function will return the ID of the new experiment
// or 0 if it failed somewhere
$newid = duplicate_item($id, $type);
if (is_pos_int($newid)) {
if ($type === 'experiments') {
$msg_arr[] = _('Experiment successfully duplicated.');
$_SESSION['infos'] = $msg_arr;
header('location: ../experiments.php?mode=edit&id=' . $newid . '');
exit;
} else {
$msg_arr[] = _('Database entry successfully duplicated.');
$_SESSION['infos'] = $msg_arr;
header('location: ../database.php?mode=edit&id=' . $newid . '');
exit;
}
} else {
$msg_arr[] = sprintf(_("There was an unexpected problem! Please %sopen an issue on GitHub%s if you think this is a bug."), "<a href='https://github.com/elabftw/elabftw/issues/'>", "</a>");
$_SESSION['errors'] = $msg_arr;
header('location: ../experiments.php');
示例8: check_visibility
/**
* Check visibility for an experiment.
*
* @param string $input The visibility
* @return string Will return team if the visibility is wrong
*/
function check_visibility($input)
{
$valid_visibility = array('public', 'organization', 'team', 'user');
if (in_array($input, $valid_visibility) || is_pos_int($input)) {
return $input;
}
// default is team
return 'team';
}
示例9: array
</div>
</div>
<?php
// CODE TO IMPORT CSV
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$row = 0;
$inserted = 0;
$column = array();
// open the file
$handle = fopen($_FILES['csvfile']['tmp_name'], 'r');
if ($handle == false) {
die('Could not open the file.');
}
// get what type we want
if (isset($_COOKIE['itemType']) && is_pos_int($_COOKIE['itemType'])) {
$type = $_COOKIE['itemType'];
} else {
die('No cookies found');
}
// loop the lines
while ($data = fgetcsv($handle, 0, ",")) {
$num = count($data);
// get the column names (first line)
if ($row == 0) {
for ($i = 0; $i < $num; $i++) {
$column[] = $data[$i];
}
$row++;
continue;
}
示例10: filter_var
}
if (isset($_GET['filter'])) {
if ($_GET['filter'] != '' && is_pos_int($_GET['filter'])) {
$filter = "AND st.id = '" . $_GET['filter'] . "' ";
}
}
// SQL for showXP
// reminder : order by and sort must be passed to the prepare(), not during execute()
// SEARCH
if (isset($_GET['q'])) {
// if there is a query
$search_type = 'query';
$query = filter_var($_GET['q'], FILTER_SANITIZE_STRING);
$results_arr = search_item('xp', $query, $_SESSION['userid']);
// RELATED
} elseif (isset($_GET['related']) && is_pos_int($_GET['related'])) {
// search for related experiments to DB item id
$search_type = 'related';
$item_id = $_GET['related'];
// search in title date and body
$sql = "SELECT item_id FROM experiments_links\n WHERE link_id = :link_id LIMIT 100";
$req = $pdo->prepare($sql);
$req->execute(array('link_id' => $item_id));
while ($data = $req->fetch()) {
$results_arr[] = $data['item_id'];
}
// TAG SEARCH
} elseif (isset($_GET['tag']) && !empty($_GET['tag'])) {
$search_type = 'tag';
$tag = filter_var($_GET['tag'], FILTER_SANITIZE_STRING);
$sql = "SELECT ex.id, ex.date, ex.title, st.name, ta.item_id\n FROM experiments AS ex, experiments_tags AS ta, status AS st\n WHERE ex.userid = :userid\n AND ta.userid = :userid\n AND ex.status = st.id\n AND st.team = :teamid\n AND ex.id = ta.item_id\n AND ta.tag LIKE :tag\n " . $filter . "\n ORDER BY {$order} {$sort}\n LIMIT 100";
示例11: filter_var
if (isset($_POST['mail_from'])) {
$mail_from = filter_var($_POST['mail_from'], FILTER_SANITIZE_EMAIL);
} else {
$mail_from = '';
}
if (isset($_POST['smtp_address'])) {
$smtp_address = filter_var($_POST['smtp_address'], FILTER_SANITIZE_STRING);
} else {
$smtp_address = '';
}
if (isset($_POST['smtp_encryption'])) {
$smtp_encryption = filter_var($_POST['smtp_encryption'], FILTER_SANITIZE_STRING);
} else {
$smtp_encryption = '';
}
if (isset($_POST['smtp_port']) && is_pos_int($_POST['smtp_port'])) {
$smtp_port = $_POST['smtp_port'];
} else {
$smtp_port = '';
}
if (isset($_POST['smtp_username'])) {
$smtp_username = filter_var($_POST['smtp_username'], FILTER_SANITIZE_STRING);
} else {
$smtp_username = '';
}
if (isset($_POST['smtp_password'])) {
// the password is stored encrypted in the database
$smtp_password = $crypto->encrypt($_POST['smtp_password']);
} else {
$smtp_password = '';
}
示例12: loopIdArr
/**
* Loop on each id and add it to our zip archive
* This could be called the main function.
*
* @throws Exception If the zip failed
*/
private function loopIdArr()
{
$this->idArr = explode(" ", $this->idList);
foreach ($this->idArr as $id) {
if (!is_pos_int($id)) {
throw new Exception('Bad id.');
}
$this->addToZip($id);
}
$this->addJson();
$this->zip->close();
// check if it failed for some reason
if (!is_file($this->filePath)) {
throw new Exception(_('Error making the zip archive!'));
}
}
示例13: die
* *
* You should have received a copy of the GNU Affero General Public *
* License along with eLabFTW. If not, see <http://www.gnu.org/licenses/>. *
* *
********************************************************************************/
require_once '../inc/common.php';
/*
we receive the file in $_FILES['file']. The array looks like that :
name : filename.pdf
type : "application/pdf"
tmp_name "/tmp/phpLzaurte"
error : 0
size 134482
*/
// check the item_id
if (is_pos_int($_GET['item_id'])) {
$item_id = $_GET['item_id'];
} else {
die('Bad ID');
}
// are we uploading for an experiment or a database item ?
if ($_GET['type'] === 'experiments' || $_GET['type'] === 'items') {
$type = $_GET['type'];
} else {
die('Bad type');
}
if ($type === 'experiments') {
// we check that the user owns the experiment before adding things to it
if (!is_owned_by_user($item_id, 'experiments', $_SESSION['userid'])) {
die('Not your experiment');
}
示例14: _
if ($type === 'items') {
$location = 'database';
// check item is in team
if (!item_is_in_team($id, $_SESSION['team_id'])) {
$msg_arr[] = _('This section is out of your reach.');
$errflag = true;
}
} else {
// check we own the experiment
if (!is_owned_by_user($id, 'experiments', $_SESSION['userid'])) {
$msg_arr[] = _('This section is out of your reach.');
$errflag = true;
}
}
// THE RESTORE ACTION
if (isset($_GET['action']) && $_GET['action'] === 'restore' && is_pos_int($_GET['rev_id'])) {
// we don't update if the item is locked
$sql = "SELECT locked FROM " . $type . " WHERE id = :id";
$req = $pdo->prepare($sql);
$req->bindParam(':id', $id, PDO::PARAM_INT);
$req->execute();
$locked = $req->fetch();
if ($locked['locked'] == 1) {
$msg_arr = _('You cannot restore a revision of a locked item!');
$errflag = true;
}
if (!$errflag) {
// get the body of the restored time
$sql = "SELECT body FROM " . $type . "_revisions WHERE id = :rev_id";
$req = $pdo->prepare($sql);
$req->bindParam(':rev_id', $_GET['rev_id'], PDO::PARAM_INT);
示例15: die
<script type="text/javascript" src="js/chemdoodleweb/ChemDoodleWeb-libs.js"></script>
<script type="text/javascript" src="js/chemdoodleweb/ChemDoodleWeb.js"></script>
<!-- these are required by the SketcherCanvas plugin -->
<script type="text/javascript" src="js/chemdoodleweb/sketcher/jquery-ui-1.9.2.custom.min.js"></script>
<script type="text/javascript" src="js/chemdoodleweb/sketcher/ChemDoodleWeb-sketcher.js"></script>
<!-- now all the slickgrid stuff-->
<script type="text/javascript" src="js/chem-editors.js"></script>
<script type="text/javascript" src="js/chem-formatters.js"></script>
<script type="text/javascript" src="js/chemistry-functions.js"></script>
<?php
// ID
if (isset($_GET['regid']) && !empty($_GET['regid']) && is_pos_int($_GET['regid'])) {
$id = $_GET['regid'];
} else {
if (isset($_REQUEST['mode']) && $_REQUEST['mode'] === 'create') {
$id = 0;
} else {
die("The id parameter in the URL isn't a valid registration ID.");
}
}
$parentregno = '';
if ($id > 0) {
$sql = "SELECT reg.cpd_id, reg.regno, reg.no_structure, reg.validated, reg.userid_entrant, reg.userid_registrar, reg.is_salt, \n reg.parent_regid, cpd.name, cpd.cas_number, cpd.pubchem_id,\n cpd.chemspider_id, cpd.notes, cpd.iupac_name, prop.mwt, prop.exact_mass, prop.formula, prop.is_chiral, prop.density, 1d.inchi\n FROM compound_registry AS reg JOIN compounds AS cpd ON reg.cpd_id = cpd.id JOIN compound_properties AS prop\n ON reg.cpd_id = prop.compound_id JOIN 1D_structures AS 1d ON reg.cpd_id = 1d.compound_id WHERE reg.id = :id";
$req = $bdd->prepare($sql);
$req->execute(array('id' => $id));
$reg_data = $req->fetch();
$cpdid = $reg_data['cpd_id'];