示例#1
0
 /**
  * Constructor method
  *
  * @access public
  * @return void
  */
 public function __construct()
 {
     $dsn = 'mysql:host=' . Config::DB_HOST;
     $dsn .= ';dbname=' . Config::DB_NAME;
     $dsn .= ';port=' . Config::DB_PORT;
     $this->pdo = new PDO($dsn, Config::DB_USER, Config::DB_PASSWORD, array(PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION));
     $this->pdo->exec('SET NAMES UTF8 COLLATE utf8_general_ci');
     $structure = new NotORM_Structure_Convention('id_%s', 'id_%s', '%s', Config::DB_PREFIX);
     parent::__construct($this->pdo, $structure);
 }
示例#2
0
 /**
  * Check user
  *
  * Check if user exists and if yes, log in him.
  * 
  * @param  $email
  * @param  $password
  * @return boolean
  */
 public function checkUser($email, $password)
 {
     // echo "$email, $password | " . $this->passwordHash($password);
     $userCheck = $this->db->user(array('email' => $email, 'password' => $this->passwordHash($password)))->fetch();
     if ($userCheck) {
         $this->login($userCheck['id']);
         return $userCheck;
     }
     return false;
 }
示例#3
0
 function __construct(NotORM_Structure $structure = null, NotORM_Cache $cache = null)
 {
     $CI =& get_instance();
     $CI->load->database();
     //required to get the db parameters
     //Please set $active_record = FALSE & $db['default']['autoinit'] = FALSE;
     //in case you don't intend to use them, for low resource usage and better performance
     $connection = new PDO("pgsql:dbname={$CI->db->database};host={$CI->db->hostname};port={$CI->db->port}", $CI->db->username, $CI->db->password);
     parent::__construct($connection, $structure, $cache);
 }
示例#4
0
文件: lib.php 项目: aodkrisda/jor5aum
 public static function &getInstance()
 {
     if (!NotORM::$_instance) {
         $pdo = new PDO("mysql:host=" . MYSQL_HOST . ";dbname=" . MYSQL_DB_NAME . ";charset=utf8", MYSQL_DB_USER, MYSQL_DB_PASW);
         $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
         $pdo->setAttribute(PDO::ATTR_CASE, PDO::CASE_LOWER);
         $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC);
         NotORM::$_instance = new NotORM($pdo);
     }
     return NotORM::$_instance;
 }
示例#5
0
 /**
  * Template rendering
  *
  * Uses Twig
  * 
  * @param  string $template Template file name
  * @param  array $data Data passed to template
  * @return void
  */
 public function renderTemplate($template, array $data = array())
 {
     require_once __DIR__ . '/../../vendor/Twig/Autoloader.php';
     Twig_Autoloader::register();
     $templateFolder = __DIR__ . '/../view/';
     $teamplateFile = $templateFolder . $template . ".html.twig";
     $loader = new Twig_Loader_Filesystem($templateFolder);
     $twig = new Twig_Environment($loader, array('cache' => __DIR__ . '/../../cache/', 'debug' => isset($_SERVER['SERVER_NAME']) && preg_match("/localhost/", $_SERVER['SERVER_NAME']) ? true : false));
     // Add link generator $this->linkGenerator() for templates
     $twig = new Twig_Environment($loader);
     $linkGenerator = new Twig_SimpleFunction('link', array($this, "linkGenerator"));
     $twig->addFunction($linkGenerator);
     // Root for links
     $twig->addGlobal('LINK_BASE', LINK_BASE);
     // Category list
     $twig->addGlobal('categoryList', $this->db->category());
     // Flash messages
     $twig->addGlobal('messages', $_SESSION['messages']);
     // User
     $auth = new Auth($this->db);
     if ($auth->isLogged()) {
         $twig->addGlobal('authUser', $auth->userInfo());
     }
     if (!is_file($teamplateFile) && $template == '404') {
         die('404: Not found');
     }
     if (!is_file($teamplateFile)) {
         $this->notFound();
     }
     try {
         // render template
         echo $twig->render($template . ".html.twig", $data);
     } catch (Exception $e) {
         die(__LINE__ . " :: " . $e->getMessage());
     }
     // reset messages
     $_SESSION['messages'] = array();
 }
示例#6
0
<?php

require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=tourepedia1;host=localhost', 'root', 'name');
$db = new NotORM($pdo);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
session_start();
$app->post("/submit", function () use($app, $db) {
    $response = array("planSubmited" => false);
    $user = (array) json_decode($app->request()->getBody());
    if ($db->insta_book()->insert($user)) {
        $response['planSubmited'] = true;
        $to1 = "*****@*****.**";
        $to2 = "*****@*****.**";
        $from = "From: trips@tourepedia.com";
        $subject = "New trip from campus special";
        $body = json_encode($user);
        mail($to1, $subject, $body, $from);
        mail($to2, $subject, $body, $from);
    }
    $response["data"] = $user;
    $app->response()->header('Content-type', 'application/json');
    echo json_encode($response);
});
$app->run();
示例#7
0
文件: list.php 项目: 3ehzad/hafez
<?php

include dirname(__FILE__) . "/config.php";
include dirname(__FILE__) . "/notorm/NotORM.php";
$connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']);
$software = new NotORM($connection);
$sonnets = $software->sonnets();
?>
<html>
  <head>
    <title>
      غزلیات حافظ
    </title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="publisher" href="https://plus.google.com/100862670780242731884"/>
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://hafez.apps.rastasoft.ir/rss.php" />
    <link rel="index" title="Hafez" href="http://hafez.apps.rastasoft.ir/list.php" />
    <link rel="alternate" href="http://hafez.apps.rastasoft.ir" hreflang="fa-ir" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" >
    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
示例#8
0
<?php

require 'vendor/autoload.php';
require 'plugins/NotORM.php';
$app = new \Slim\Slim();
$dbhost = 'iconmercedb.cxcch2tzx4mi.us-west-1.rds.amazonaws.com';
$dbuser = '******';
$dbpass = '******';
$dbname = 'icondb';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO("mysql:host={$dbhost};port=8889;dbname={$dbname}", $dbuser, $dbpass);
$db = new NotORM($pdo);
$app->get('/', function () {
    echo 'ICONMERCE - RESTful Services';
});
$app->get('/users', function () use($app, $db) {
    $users = array();
    foreach ($db->users() as $user) {
        $users[] = array('user_id' => $user['user_id'], 'username' => $user['username'], 'password' => $user['password'], 'email' => $user['email']);
    }
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($users, JSON_FORCE_OBJECT);
});
$app->get("/transactions", function () use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $transactions = array();
    $trans = $db->transactions()->order("date");
    foreach ($trans as $trans) {
        $transactions[] = array('transactionId' => $trans['transactionId'], 'userId' => $trans['userId'], 'isDeposit' => $trans['isDeposit'], 'amount' => $trans['amount'], 'date' => $trans['date'], 'category' => $trans['category']);
    }
<?php

require_once "../vendor/autoload.php";
$dsn = "mysql:dbname=slimtut;host=localhost";
$username = "******";
$password = "******";
$pdo = new PDO($dsn, $username, $password);
$db = new NotORM($pdo);
$app = new Slim(array("MODE" => "development", "TEMPLATES.PATH" => "./templates"));
$app->get("/", function () {
    echo "<h1>Hello Slim World</h1>";
});
$app->get("/books", function () use($app, $db) {
    $books = array();
    foreach ($db->books() as $book) {
        $books[] = array("id" => $book["id"], "title" => $book["title"], "author" => $book["author"], "summary" => $book["summary"]);
    }
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($books);
});
$app->get("/book/:id", function ($id) use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $book = $db->books()->where("id", $id);
    if ($data = $book->fetch()) {
        echo json_encode(array("id" => $data["id"], "title" => $data["title"], "author" => $data["author"], "summary" => $data["summary"]));
    } else {
        echo json_encode(array("status" => false, "message" => "Book ID {$id} does not exist"));
    }
});
$app->post("/book", function () use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
示例#10
0
<?php

require_once 'NotORM.php';
$connection = new PDO('mysql:dbname=homig7y7_main;host=localhost', 'homig7y7_main', 'homigo10450');
$db = new NotORM($connection);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
session_start();
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login');
        }
    };
};
$app->post("/auth/process/admin", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    $email = $array['email'];
    $password = $array['password'];
    $person = $db->admin()->where('email', $email)->where('password', $password);
    $count = count($person);
    if ($count == 1) {
        $_SESSION['user'] = $email;
        $data = array('login_success' => "true", 'login_attempt_by' => $email, 'message' => "Successfull sigin");
    } else {
        $data = array('login_success' => "false", 'login_attempt_by' => $email, 'message' => "please provide correct details");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
示例#11
0
文件: api.php 项目: aodkrisda/mayotin
 public function __construct(array $userSettings = array())
 {
     parent::__construct($userSettings);
     $this->container->singleton('auth', function ($c) {
         return new AppUser();
     });
     $this->container->singleton('orm', function ($c) {
         return NotORM::getInstance();
     });
     $this->container->singleton('session', function ($c) {
         return new Session();
     });
 }
示例#12
0
require 'vendor/autoload.php';
require 'libs/NotORM/NotORM.php';
/* db item */
$server = 'localhost';
$db_name = 'paypal';
$db_user = '******';
$db_pass = '******';
use PayPal\Api\Payment;
/* paypal config*/
$currency = 'USD';
$PayPal_Client_Id = 'ATPZm7k-jA0PuYvl8h_i7OwIU6ZvowFVbMDnyMf2u8xKF6Rf-W7GH-U4nf7FxWR_ys8yucvrK1_vAW6L';
$PayPal_Secret = 'EGcHZFi2ChI-dz__yowD2NneU68RQOld9ukzSp3VtCrHAXe9inBO2Ea2pGGW9eaAaTuzmweDosvz1bBp';
/* db config */
$pdo = new PDO("mysql:host={$server};dbname={$db_name}", $db_user, $db_pass);
$db = new NotORM($pdo);
$app = new \Slim\Slim();
$app->get('/hai/:name', function ($name) {
    echo "hello " . $name;
});
$app->get('/tes', function () use($app, $db) {
    $query = $db->tes;
    foreach ($query as $value) {
        $result[] = array("nama" => $value["nama"], "kota" => $value["kota"]);
    }
    echo json_encode($result);
});
$app->post('/tes', function () use($app, $db) {
    $nama = $app->request->post('nama');
    $kota = $app->request->post('kota');
    $add = $db->tes->insert(array("nama" => $nama, "kota" => $kota));
示例#13
0
<?php

include 'functions.php';
require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=shiningfloor1;host=localhost', 'root', '');
// $pdo = new PDO('mysql:dbname=shiningfloor;host=localhost', 'shiningfloor', 'Shiningfloor');
$db = new NotORM($pdo);
global $db;
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->get('/shiningfloor/info', function () use($app, $db) {
    foreach ($db->products()->where('id >10423') as $p) {
        $a = array('products_id' => $p['id'], 'image_name' => $p['product_img']);
        print_r($a);
        $db->product_images->insert($a);
    }
    $app->response()->header('content-type', 'application/json');
});
$app->run();
示例#14
0
<?php

require 'Slim/Slim.php';
require 'plugins/NotORM.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/* CONFIG */
$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '';
$dbname = 'slim';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);
/* ROUTES */
$app->get('/', function () {
    echo 'Home';
});
$app->get('/users', function () use($app, $db) {
    $users = array();
    foreach ($db->users() as $user) {
        $users[] = array('id' => $user['id'], 'username' => $user['username'], 'email' => $user['email']);
    }
    $app->response()->header("Content-Type", "application/json");
    echo json_encode($users, JSON_FORCE_OBJECT);
});
$app->get('/users/:id', function ($id) use($app, $db) {
    $app->response()->header("Content-Type", "application/json");
    $user = $db->users()->where('id', $id);
    if ($data = $user->fetch()) {
示例#15
0
<?php

require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=shiningfloor;host=localhost', 'shiningfloor', 'Shiningfloor');
$db = new NotORM($pdo);
global $db;
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/*************************************  EMAIL VERIFICATION ***********************************/
$email_html_code1 = '
            <html lang="en"><head>
<meta charset="utf-8">
<title>Make email template</title>
<link rel="shortcut icon" href="images/favicon.png" type="image/png">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="Cache-Control" content="cache">
<meta http-equiv="Pragma" content="cache">
<meta http-equiv="Expires" content="1000">
<style type="text/css">
  @import url(http://fonts.googleapis.com/css?family=Open+Sans);
  body{overflow: hidden}
  img{max-width:600px;outline:none;text-decoration:none;-ms-interpolation-mode:bicubic}
  a{text-decoration:none;border:0;outline:none;color:#bbb}
  a img{border:none}
  p{margin-top: 0;margin-bottom: 0;text-align:left;}
  td,h1,h2,h3{font-family:Helvetica,Arial,sans-serif;font-weight:400}
  td{text-align:center}
  body{-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:none;width:100%;height:100%;color:#37302d;background:#fff;font-size:16px}
  table{border-collapse:collapse!important}
  .headline{color:#fff;font-size:36px}
示例#16
0
<?php

include 'functions.php';
require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=buildcorner;host=localhost', 'root', '');
// $pdo = new PDO('mysql:dbname=shiningfloor;host=localhost', 'shiningfloor', 'Shiningfloor');
$db = new NotORM($pdo);
global $db;
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
require_once 'seller.php';
require_once 'admin.php';
/*************************************  EMAIL VERIFICATION ***********************************/
include 'email_content.php';
$app->post("/shiningfloor/email_verification/:email", function ($email = null) use($app, $db) {
    global $email_html_code1, $email_html_code2;
    $email_fromr = "*****@*****.**";
    $email_subjectr = "Follow link to change password";
    $email_tor = $email;
    $user = $db->users()->where('email', $email);
    $data;
    $count = count($user);
    if ($count == 1) {
        $pwd_update_time = $user->fetch()['pwd_update_time'];
        $send_url = 'http://ankitsilaich.in/shiningfloor-master/main_site/change_pwd.php?';
        $send_url .= 'email=' . $email . '&token=' . md5($email . md5($pwd_update_time));
        //echo $send_url;
        $headers3 = 'From:' . 'Shining Floor' . " " . '<' . '*****@*****.**' . '>' . "\r\n";
        $headers3 .= 'Reply-To: ' . $email_fromr . "\r\n";
        $headers3 .= "MIME-Version: 1.0\r\n";
示例#17
0
<?php

require 'vendor/autoload.php';
//configuração de conexão com banco de dados
$pdo = new PDO('mysql:dbname=slim_helloworld;host:127.0.0.1', 'root', '');
$db = new NotORM($pdo);
//criando uma nova instancia do Slim
$app = new \Slim\Slim(array('MODE' => 'development', 'TEMPLATE.PATH' => './templates'));
//setando o encoding
$app->contentType('text/html; charset=utf-8');
//rota padrão para página não encontrada
$app->notFound(function () use($app) {
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode(array('status' => false, 'message' => 'The resource doesn\'t exist. Check the API docs'));
    //$app->render('404.php');	//template padrão para erro 404
});
//criando uma nova Rota
$app->get('/', function () use($app) {
    $app->view()->setData('title', 'Olá Mundo');
    $app->render('index.php');
    //echo "Hello Slim World";
});
//obtendo todos os livros
$app->get('/books', function () use($app, $db) {
    $books = array();
    foreach ($db->books() as $book) {
        $books[] = array('id' => $book['id'], 'title' => $book['title'], 'author' => $book['author'], 'summary' => utf8_encode($book['summary']));
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($books);
});
示例#18
0
文件: index.php 项目: echmaster/data
<?php

/* Подключение библиотек */
require_once 'Slim/Slim.php';
require_once 'NotORM.php';
/* Инициализация автозагрузчика */
\Slim\Slim::registerAutoloader();
/* Инициализация соединения с БД для NotORM */
$pdo = new PDO('sqlite:rest.db');
$db = new NotORM($pdo);
/* Создание экземпляра класса Slim */
$app = new \Slim\Slim();
/**
*	Роутинг: определение методов, путей и действий
*/
/* Действие по-умолчанию */
$app->get("/", function () {
    echo "Something by default";
});
/* Выборка всех книг */
$app->get("/books/", function () use($app, $db) {
    $books = array();
    foreach ($db->books() as $book) {
        $books[] = array("id" => $book["id"], "title" => $book["title"], "author" => $book["author"], "summary" => $book["summary"]);
    }
    $res = $app->response();
    $res["Content-type"] = "application/json";
    echo json_encode($books);
});
/* Получение книги используя её идентификатор */
$app->get("/book/:id/", function ($id) use($app, $db) {
示例#19
0
<?php

require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=student;host=localhost', 'eagle_eye', 'eaglesword');
$db = new NotORM($pdo);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
session_start();
$app = new \Slim\Slim();
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login');
        }
    };
};
//Get Method to get the data from database
$app->get('/student(/:id)', $authenticate($app), function ($id = null) use($app, $db) {
    if ($id == null) {
        $data = array();
        foreach ($db->student() as $p) {
            $data[] = array('student_id' => $p['student_id'], 'name' => $p['name'], 'birthday' => $p['birthday'], 'sex' => $p['sex'], 'religion' => $p['religion'], 'blood_group' => $p['blood_group'], 'address' => $p['address'], 'phone' => $p['phone'], 'email' => $p['email'], 'father_name' => $p['father_name'], 'mother_name' => $p['mother_name'], 'rollno' => $p['roll'], 'transport_id' => $p['transport_id']);
        }
    } else {
        $data = null;
        if ($p = $db->student()->where('student_id', $id)->fetch()) {
            $data = array('student_id' => $p['student_id'], 'name' => $p['name'], 'birthday' => $p['birthday'], 'sex' => $p['sex'], 'religion' => $p['religion'], 'blood_group' => $p['blood_group'], 'address' => $p['address'], 'phone' => $p['phone'], 'email' => $p['email'], 'father_name' => $p['father_name'], 'mother_name' => $p['mother_name'], 'rollno' => $p['roll'], 'transport_id' => $p['transport_id']);
        }
    }
    $app->response()->header('content-type', 'application/json');
    echo json_encode($data);
示例#20
0
require_once 'vendor/autoload.php';
require 'Orm/NotORM.php';
use Slim\Slim;
// Register autoloader and instantiate Slim
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
// Database Configuration
$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '******';
// $dbname = 'naiemoji';
$dbname = 'testorm';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);
// Home Route
$app->get('/', function () use($app) {
    $app->response->setStatus(200);
    $app->render('../templates/homepage.html');
});
// Register a user
$app->post('/register', function () use($app, $db) {
    $app->response()->header('Content-Type', 'application/json');
    $name = $app->request()->post('name');
    $email = $app->request()->post('email');
    $password = $app->request()->post('password');
    $passwordEncryption = md5($password);
    if ($email === $db->users()->where('email', $email)->fetch('email')) {
        echo json_encode(['message' => 'That email address is already in use. Please use another email address']);
    } else {
示例#21
0
<?php

require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=tourepedia;host=localhost', 'root', '');
$db = new NotORM($pdo);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/**********************************  USER LOGIN SIGNUP CHECKING ******************************/
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login.html');
        }
    };
};
session_start();
$app->post("/auth/process", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    //    print_r($array);
    $email = $array['email'];
    $pwd = md5($array['pwd']);
    $user = $db->users()->where('user_email', $email)->where('user_password', $pwd);
    $count = count($user);
    if ($count == 1) {
        $_SESSION['user'] = $email;
        $data = array("loginStatus" => "success", 'userEmail' => $email);
    } else {
        $data = array("loginStatus" => "login failure");
    }
    $app->response()->header('Content-Type', 'application/json');
示例#22
0
<?php

require_once 'NotORM.php';
$connection = new PDO('mysql:dbname=homig7y7_main;host=localhost', 'homig7y7_main', 'homigo10450');
$db = new NotORM($connection);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
session_start();
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login');
        }
    };
};
$app->post("/auth/process/admin", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    $email = $array['email'];
    $password = $array['password'];
    $person = $db->admin()->where('email', $email)->where('password', $password);
    $count = count($person);
    if ($count == 1) {
        $_SESSION['admin'] = $email;
        $data = array('login_success' => "true", 'login_attempt_by' => $email, 'message' => "Successfull sigin");
    } else {
        $data = array('login_success' => "false", 'login_attempt_by' => $email, 'message' => "please provide correct details");
    }
    $app->response()->header('Content-Type', 'application/json');
    echo json_encode($data);
});
示例#23
0
<?php

/* Require Slim and NotORM */
require 'vendor/autoload.php';
$app = new \Slim\App();
/* Database Configuration */
$dbhost = 'localhost';
$dbuser = '******';
$dbpass = '******';
$dbname = 'car_park';
$dbmethod = 'mysql:dbname=';
$dsn = $dbmethod . $dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);
$app->post('/car', function ($req, $res, $args) use($db) {
    $car = $req->getParsedBody();
    $result = $db->cars->insert($car);
    return $res->write($result['id']);
});
$app->get('/cars', function ($req, $res, $args) use($db) {
    $cars = array();
    foreach ($db->cars() as $car) {
        $cars[] = array('number' => $car['number'], 'region' => $car['region'], 'ticket' => $car['ticket']);
    }
    return $res->withHeader('Content-Type', 'application/json')->write(json_encode($cars));
});
$app->delete('/car/{num}/{region}', function ($req, $res, $args) use($db) {
    $num = $args['num'];
    $region = $args['region'];
    $car = $db->cars()->where(array("number" => $num, "region" => $region));
    if ($car->fetch()) {
示例#24
0
/*
//$_POST['date1']='2015-01-01';
//$_POST['date2']='2015-02-01';
//$_POST['type_id']='4';
//$_POST['user_id']='14';
*/
if (!(isset($_POST['date1']) && isset($_POST['user_id']))) {
    echo "<p style=\"text-align:center;padding-top:45vh;color:#ee0000;font-size:2em\">ไม่สามารถแสดงรายงานออกมาได้</p>";
    exit;
}
$dir = __DIR__ . '/';
require_once $dir . '../rest/NotORM/lib.php';
require_once $dir . '../rest/Twig/Autoloader.php';
Twig_Autoloader::register();
$orm = NotORM::getInstance();
$loader = new Twig_Loader_Filesystem($dir . '/templates/');
$twig = new Twig_Environment($loader, array('__cache' => $dir . '/cache/'));
require_once $dir . 'filters.php';
$lookups = $orm->at()->fetchPairs('id', 'name');
$filter = new Twig_SimpleFilter('lookup_at', function ($id) use($lookups) {
    if (isset($lookups[$id])) {
        return $lookups[$id];
    }
    return '';
});
$twig->addFilter($filter);
$date1 = '';
$date2 = '';
$user_id = '';
$type_id = null;
示例#25
0
文件: list.php 项目: rastasoft/iq
<?php

include dirname(__FILE__) . "/config.php";
include dirname(__FILE__) . "/notorm/NotORM.php";
$connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']);
$software = new NotORM($connection);
$questions = $software->questions();
?>
<html>
  <head>
    <title>
      لیست معماها
    </title>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <link rel="publisher" href="https://plus.google.com/100862670780242731884"/>
    <link rel="alternate" type="application/rss+xml" title="RSS" href="http://iq.apps.rastasoft.ir/rss.php" />
    <link rel="index" title="Hafez" href="http://iq.apps.rastasoft.ir/list.php" />
    <link rel="alternate" href="http://iq.apps.rastasoft.ir" hreflang="fa-ir" />
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" >
    <!-- Bootstrap core CSS -->
    <link href="dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="assets/css/style.css" rel="stylesheet">
    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
      <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
  </head>
  <body>
示例#26
0
文件: slim.php 项目: Tourepedia/v1.1
<?php

require_once 'NotORM.php';
$pdo = new PDO('mysql:dbname=tourepedia1;host=localhost', 'root', 'name');
$db = new NotORM($pdo);
require 'Slim/Slim.php';
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
/**********************************  USER LOGIN SIGNUP CHECKING ******************************/
$authenticate = function ($app) {
    return function () use($app) {
        if (!isset($_SESSION['user'])) {
            $app->redirect('/login.html');
        }
    };
};
session_start();
$app->post("/auth/process", function () use($app, $db) {
    $array = (array) json_decode($app->request()->getBody());
    //    print_r($array);
    $email = $array['email'];
    $pwd = md5($array['pwd']);
    $user = $db->users()->where('user_email', $email)->where('user_password', $pwd);
    $count = count($user);
    if ($count == 1) {
        $_SESSION['user'] = $email;
        $data = array("loginStatus" => "success", 'userEmail' => $email);
    } else {
        $data = array("loginStatus" => "login failure");
    }
    $app->response()->header('Content-Type', 'application/json');
示例#27
0
文件: install.php 项目: rastasoft/iq
<?php

include dirname(__FILE__) . "/config.php";
include dirname(__FILE__) . "/notorm/NotORM.php";
$connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']);
$software = new NotORM($connection);
$files = glob("files/*.t");
foreach ($files as $file) {
    $qid = pathinfo($file, PATHINFO_FILENAME);
    $title = file_get_contents($file);
    $software->questions()->insert_update(array("qid" => $qid), array("title" => $title));
}
$files = glob("files/*.q");
foreach ($files as $file) {
    $qid = pathinfo($file, PATHINFO_FILENAME);
    $question = markup_to_html(file_get_contents($file));
    $software->questions()->insert_update(array("qid" => $qid), array("question" => $question));
}
$files = glob("files/*.a");
foreach ($files as $file) {
    $qid = pathinfo($file, PATHINFO_FILENAME);
    $answer = markup_to_html(file_get_contents($file));
    $software->questions()->insert_update(array("qid" => $qid), array("answer" => $answer));
}
function markup_to_html($markup)
{
    if (preg_match_all('/\\[(.*):(.*)\\]/', $markup, $medias)) {
        foreach ($medias[0] as $index => $pattern) {
            switch ($medias[1][$index]) {
                case 'img':
                    $tag = "<img src=\"files/images/{$medias[2][$index]}\" />";
示例#28
0
$twig->parserExtensions = array(
    new \Slim\Views\TwigExtension(),
);
//$twig->setTemplatesDirectory($templatesPath);

// Database Configuration 
/* ---------------------------------------- */
$dbhost   = 'localhost';
$dbuser   = '******';
$dbpass   = '******';
$dbname   = 'songwriter';
$dbmethod = 'mysql:dbname=';

$dsn = $dbmethod.$dbname;
$pdo = new PDO($dsn, $dbuser, $dbpass);
$db = new NotORM($pdo);




/* ---------------------------------------------------------------------------- */
// Routes
/* ---------------------------------------------------------------------------- */

/* Index page :) */
$app->get('/', function() use($app, $db, $pdo){
    $app->render('header.php', array('name' => 'Nia nia', 'url' => 'niabot.com'));
    $app->render('song-list.php', array('name' => 'Nia nia', 'url' => 'niabot.com'));
    $app->render('footer.php', array('name' => 'Brian Nesbitt', 'url' => 'nesbot.com'));
});
示例#29
0
 public function __construct(array $userSettings = array())
 {
     parent::__construct($userSettings);
     $this->container->singleton('user', function ($c) {
         return new WebUser();
     });
     $this->container->singleton('orm', function ($c) {
         require_once __DIR__ . '/../venders/NotORM/lib.php';
         return NotORM::getInstance();
     });
     $this->container->singleton('session', function ($c) {
         return new WebSession();
     });
 }
示例#30
0
文件: crawler.php 项目: 3ehzad/hafez
<?php

include dirname(__FILE__) . "/config.php";
include dirname(__FILE__) . "/notorm/NotORM.php";
$connection = new PDO("mysql:host={$config['host']};dbname={$config['name']};port={$config['port']}", $config['user'], $config['pass']);
$software = new NotORM($connection);
$sid = (int) $_GET['sid'];
$url = "http://www.1doost.com/hafez/phrase/{$sid}.htm";
$html = file_get_contents($url);
libxml_use_internal_errors(true);
// Yeah if you are so worried about using @ with warnings
$doc = new DomDocument();
$doc->loadHTML($html);
$xpath = new DOMXPath($doc);
$verses = $xpath->query('//*/div[@class="hfzpsBoxHolder"]/div');
$number = 1;
foreach ($verses as $verse) {
    $parts = $verse->getElementsByTagName('div');
    $hemistich_first = $parts->item(0)->nodeValue;
    $hemistich_second = $parts->item(1)->nodeValue;
    $software->verses()->insert(array("sid" => $sid, "number" => $number++, "hemistich_first" => $hemistich_first, "hemistich_second" => $hemistich_second));
}
$phrase = $xpath->query('//*/div[@class="hzPoeamPhraseHolder"]/p')->item(0)->nodeValue;
$software->sonnets()->insert_update(array("sid" => $sid), array("phrase" => $phrase));
$sound = file_get_contents("http://hafez.pichak.net/mp3/{$sid}.mp3");
file_put_contents("sounds/{$sid}.mp3", $sound);
$sid3 = strlen($sid) == 3 ? $sid : (strlen($sid) == 2 ? "0{$sid}" : "00{$sid}");
$image = file_get_contents("http://www.1doost.com/Files/Hafez/png/{$sid3}.png");
file_put_contents("images/{$sid}.png", $image);
print 'done';