function isString($val) { if (is_string(notNull($val))) { return $val; } var_dump($val); throwError("Not a string"); }
public function getSpecImg($class, $spec, $open, $tooltip) { $on = $open == '1' ? 'on' : 'off'; if ($spec != '') { $comment = notNull($tooltip) ? ' class="tooltip" title="' . $tooltip . '"' : ''; return '<img src="./img/' . $class . '_' . $spec . '_' . $on . '.png"' . $comment . ' />'; } else { return ''; } }
<?php session_start(); define('DB_NAME', 'dream'); define('DB_USER', 'da'); define('DB_PASSWORD', 'dream-admin2015'); include_once '../include/functions.php'; include_once '../include/DBF.php'; $user = "******"; if (notNull($_SESSION) && notNull($_SESSION['user'])) { $user = $_SESSION['user']; } $url = explode("/", currentPage()); $page = $url[sizeof($url) - 1]; $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $sql->beginTransaction(); try { $statement = "INSERT INTO deadlinks (link) VALUES(:link)"; $query = $sql->prepare($statement); $query->execute(array('link' => currentPage())); $sql->commit(); } catch (Exception $e) { $sql->rollBack(); } logWarning($user, 2, $user . " requested a dead link : " . currentPage()); ?> <h1>404</h1> <p>La page que vous avez demandé n'existe pas ou plus</p> <a href="/">Retourner à l'accueil</a>
$myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT * FROM users WHERE login = :login;"); $query->execute(array('login' => $_POST['auth_login'])); $result = $query->fetch(); if (notNull($result)) { $sent_pass = sha1($_POST['auth_pass'] . $result['salt']); $stored_pass = $result['pass']; if ($sent_pass == $stored_pass) { $_SESSION['logged'] = "LOGGED"; $_SESSION['user'] = ucfirst($result['login']); $_SESSION['role'] = $result['role']; $_SESSION['id'] = $result['id']; logSuccess($result['login'], 0, "User " . $result['login'] . " successfully logged in from IP " . get_client_ip()); } else { $_SESSION['logged'] = "NOT_LOGGED"; $_SESSION['user'] = "******"; $_SESSION['role'] = 0; logWarning($result['login'], 0, "User " . $result['login'] . " failed to log from IP " . get_client_ip()); } } } if ($logged) { if (notNull($_POST['auth_from'])) { header('Location:' . $_POST['auth_from']); } else { header('Location:/'); } } else { header('Location:/'); }
$NewRouteId = false; } else { $route_lat = array(0); $route_lng = array(0); $RouteLookup->execute(array(':name' => $route_name, ':distance' => $Row['distance'])); $NewRouteId = $RouteLookup->fetchColumn(); } if ($NewRouteId === false) { $return = $InsertRoute->execute(array(':accountid' => $Row['accountid'], ':name' => notNull($route_name), ':cities' => notNull($route_cities), ':distance' => $Row['distance'], ':elevation' => $Row['elevation_calculated'], ':lats' => notNull($Row['arr_lat']), ':lngs' => notNull($Row['arr_lon']), ':elevations_original' => notNull($Row['arr_alt_original']), ':elevations_corrected' => notNull($Row['arr_alt']), ':startpoint_lat' => reset($route_lat), ':startpoint_lng' => reset($route_lng), ':endpoint_lat' => end($route_lat), ':endpoint_lng' => end($route_lng), ':min_lat' => empty($route_lat) ? 0 : min($route_lat), ':max_lat' => empty($route_lat) ? 0 : max($route_lat), ':min_lng' => empty($route_lng) ? 0 : min($route_lng), ':max_lng' => empty($route_lng) ? 0 : max($route_lng))); $NewRouteId = $PDO->lastInsertId(); } } else { $NewRouteId = 0; } if (!empty($Row['arr_time']) || !empty($Row['arr_dist']) || !empty($Row['arr_heart'])) { $InsertTrackdata->execute(array(':accountid' => $Row['accountid'], ':activityid' => $Row['id'], ':time' => notNull($Row['arr_time']), ':distance' => notNull($Row['arr_dist']), ':pace' => notNull($Row['arr_pace']), ':heartrate' => notNull($Row['arr_heart']), ':cadence' => notNull($Row['arr_cadence']), ':power' => notNull($Row['arr_power']), ':temperature' => notNull($Row['arr_temperature']))); } $UpdateActivity->execute(array(':id' => $Row['id'], ':routeid' => $NewRouteId)); echo '.' . (CLI ? '' : ' '); } echo 'done;' . NL; echo NL; echo 'Time: ' . (microtime(true) - $starttime) . 's' . NL; echo 'Memory peak: ' . memory_get_peak_usage() . 'B' . NL; echo NL; if (CLI) { echo '... call the script again to continue' . NL; } else { echo '... <a href="javascript:location.reload()">reload to continue</a>'; } }
function mustBeEqual($v1, $v2) { if (notNull($v1) != notNull($v2)) { throwError("{$v1} != {$v2}"); } }
<?php session_start(); header('content-type: text/css'); define('DB_NAME', 'dream'); define('DB_USER', 'da'); define('DB_PASSWORD', 'dream-admin2015'); include_once '../include/functions.php'; include_once '../include/DBF.php'; try { $role = 0; if (notNull($_SESSION) && notNull($_SESSION['role'])) { $role = $_SESSION['role']; } $myDB = new DBFactory(); $sql = $myDB->getMysqlConnexionWithPDO(); $query = $sql->prepare("SELECT * FROM menu WHERE lang = :lang AND role <= :role AND parent = :parent ORDER BY `order` ASC"); $query->execute(array('lang' => 'FR', 'role' => $role, 'parent' => '0')); $results = $query->fetchAll(); $navElementsSize = sizeof($results); ?> nav ul li{ width: calc((100% / <?php echo $navElementsSize; ?> ) - 2px); } nav ul li ul{ width: 100%;
$variables->getHtml('./view/auth.php'); } $variables->getHtml('./view/title.php'); $variables->getHtml('./view/header.php'); ?> </header> <nav> <?php $variables->getHtml('./view/nav.php'); ?> </nav> <section id="main_content"> <aside id="recruiting"> <div style="padding: 10px; height: calc(100% - 20px);"> <?php if (notNull($_SESSION) && notNull($_SESSION['logged'])) { $logged = $_SESSION['logged'] != 'NOT_LOGGED'; $membre = $_SESSION['role'] >= 1; $officier = $_SESSION['role'] >= 2; $moderateur = $_SESSION['role'] >= 3; $admin = $_SESSION['role'] >= 4; } if ($logged) { $variables->getHtml('./view/mumble.php'); } else { $variables->getHtml('./view/recruit.php'); } ?> </div> </aside> <aside id="mumble">
function mustHaveMethod($object, $methodName) { $rf = new \ReflectionObject(notNull($object)); notFalse($rf->hasMethod($methodName)); return $rf->getMethod($methodName); }
function roles($query) { $statements = explode(';', $query); $sql = initDB(); $sql->beginTransaction(); $result = ""; $queryResult = null; $return = ""; try { foreach ($statements as $statement) { if (notNull($statement)) { $query = $sql->query($statement); $query->execute(); } } $sql->commit(); logSuccess($_SESSION['user'], 3, $_SESSION['user'] . " updated user roles."); return "Mise à jour effectuée."; } catch (Exception $e) { $sql->rollBack(); logError($_SESSION['user'], 3, $_SESSION['user'] . " tried to update user roles. Server returned : <br />" . $e->getMessage()); return $e->getMessage(); } }