/**
  * @param ServiceLocatorInterface $serviceLocator
  * @return R
  */
 public function createService(ServiceLocatorInterface $serviceLocator)
 {
     $rjhRedbeanService = new R();
     $config = $serviceLocator->get('config');
     $rjhRedbeanConfig = $config['rjhredbean'];
     $connection = $rjhRedbeanConfig['connection'];
     $dsn = $connection['dsn'];
     $user = $connection['user'];
     $password = $connection['password'];
     $rjhRedbeanService->setup($dsn, $user, $password);
     $rjhRedbeanService->freeze($rjhRedbeanConfig['freeze']);
     $rjhRedbeanService->debug($rjhRedbeanConfig['debug']);
     return $rjhRedbeanService;
 }
Esempio n. 2
0
 /**
  * @return int|string
  * @throws \RedBeanPHP\RedException
  */
 function insertUser()
 {
     $users = R::dispense('users');
     $users->fname = 'Abhishek';
     $users->lname = 'Saha';
     return R::store($users);
 }
Esempio n. 3
0
 public function process(array $documents, &$context)
 {
     $doc = $documents[self::URL_MEDIA];
     $dom = self::getDOM($doc);
     $xpath = new DOMXPath($dom);
     //chapter count
     preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Chapters:\']/following-sibling::node()[self::text()]'), $matches);
     $chapterCount = Strings::makeInteger($matches[0][0]);
     //volume count
     preg_match_all('#([0-9]+|Unknown)#', self::getNodeValue($xpath, '//span[text() = \'Volumes:\']/following-sibling::node()[self::text()]'), $matches);
     $volumeCount = Strings::makeInteger($matches[0][0]);
     //serialization
     $serializationMalId = null;
     $serializationName = null;
     $q = $xpath->query('//span[text() = \'Serialization:\']/../a');
     if ($q->length > 0) {
         $node = $q->item(0);
         preg_match('#/magazine/([0-9]+)$#', $node->getAttribute('href'), $matches);
         $serializationMalId = Strings::makeInteger($matches[1]);
         $serializationName = Strings::removeSpaces($q->item(0)->nodeValue);
     }
     $media =& $context->media;
     $media->chapters = $chapterCount;
     $media->volumes = $volumeCount;
     $media->serialization_id = $serializationMalId;
     $media->serialization_name = $serializationName;
     R::store($media);
 }
Esempio n. 4
0
 /**
  * Construct a new database object.
  * @param $settings
  */
 public function __construct($settings)
 {
     $this->database = DatabaseManager::connect($settings["host"], $settings["port"], $settings["user"], $settings["pass"], $settings["name"], isset($settings["utf8"]) ? $settings["utf8"] : true);
     // Debug
     global $settings;
     R::debug($settings["development"]);
 }
Esempio n. 5
0
function getSubscribers($id)
{
    $subs = R::getAll("select * from subscription where category_id='{$id}'");
    if ($subs) {
        return $subs;
    }
}
 /**
  * Test foreign keys with SQLite.
  * 
  * @return void
  */
 public function testForeignKeysWithSQLite()
 {
     $book = R::dispense('book');
     $page = R::dispense('page');
     $cover = R::dispense('cover');
     list($g1, $g2) = R::dispense('genre', 2);
     $g1->name = '1';
     $g2->name = '2';
     $book->ownPage = array($page);
     $book->cover = $cover;
     $book->sharedGenre = array($g1, $g2);
     R::store($book);
     $fkbook = R::getAll('pragma foreign_key_list(book)');
     $fkgenre = R::getAll('pragma foreign_key_list(book_genre)');
     $fkpage = R::getAll('pragma foreign_key_list(page)');
     asrt($fkpage[0]['from'], 'book_id');
     asrt($fkpage[0]['to'], 'id');
     asrt($fkpage[0]['table'], 'book');
     asrt(count($fkgenre), 2);
     if ($fkgenre[0]['from'] == 'book') {
         asrt($fkgenre[0]['to'], 'id');
         asrt($fkgenre[0]['table'], 'book');
     }
     if ($fkgenre[0]['from'] == 'genre') {
         asrt($fkgenre[0]['to'], 'id');
         asrt($fkgenre[0]['table'], 'genre');
     }
     asrt($fkbook[0]['from'], 'cover_id');
     asrt($fkbook[0]['to'], 'id');
     asrt($fkbook[0]['table'], 'cover');
 }
Esempio n. 7
0
function delete_event($id)
{
    $event = R::load('events', $id);
    //reloads our event
    R::trash($event);
    //for one bean
}
Esempio n. 8
0
 function nav_save()
 {
     G2_User::init();
     if (G()->logged_in() && !empty($_POST)) {
         if (!empty($_POST['items']) && !empty($_POST['identity'])) {
             // Delete all current navigation details
             $navitems = R::findAll('navitem', 'identity=:id', ['id' => $_POST['identity']]);
             R::trashAll($navitems);
             foreach ($_POST['items'] as $new_item) {
                 $nav = R::dispense('navitem');
                 $nav->identity = $_POST['identity'];
                 $nav->label = $new_item['label'];
                 $nav->href = !$new_item['href'] ? null : $new_item['href'];
                 $nav->order = $new_item['order'];
                 //@todo parent node support
                 R::store($nav);
             }
             echo json_encode(['success' => true, 'message' => 'Content Saved Successfully']);
         } else {
             echo json_encode(['success' => false, 'message' => 'Data sent not correct']);
         }
     } else {
         echo json_encode(['success' => false, 'message' => 'Not Logged in']);
     }
     die;
 }
Esempio n. 9
0
 function view($args)
 {
     $id = array_shift($args);
     $permission = R::load('permission', $id);
     if (!is_numeric($id) && !$permission->getID()) {
         $this->redirect(PACKAGE_URL);
     }
     $allgroups = R::findAll('group');
     foreach ($allgroups as $key => $group) {
         foreach ($permission->sharedGroup as $group_c) {
             if ($group->id == $group_c->id) {
                 $allgroups[$key]->checked = true;
             }
         }
     }
     //		echo $permission->name;exit;
     $view = new G2_TwigView('pages/view');
     $view->permission = $permission;
     $view->allGroups = $allgroups;
     $form = new G2_FormMagic($view->get_render());
     if ($form->is_posted()) {
         $groups = R::loadAll('group', array_keys($form->data()['groups']));
         $permission->sharedGroup = $groups;
         R::store($permission);
         Admin_Alert::add_message("\"{$permission->name}\" permission was updated");
         $this->redirect(PACKAGE_URL);
     }
     echo $form->parse();
 }
Esempio n. 10
0
function recupWines()
{
    // Récupération sous forme d'un tableau de tous les vins dans la DB au moyen de l'ORM RedBean
    $tabWines = R::findAll('wine');
    // On retourne le tableau "tabWines"
    return $tabWines;
}
Esempio n. 11
0
 public function get_Upload_details($last_upl)
 {
     /*
     		$user_delimiter =$this->sql_user_delimiter(0,0);
     
     		$sql 	=	"SELECT 
     							`pima_upload_id`,
     							`upload_date`,
     							`equipment_serial_number`,
     							`facility_name`,
     							`uploader_name`,
     							COUNT(`pima_test_id`) AS `total_tests`,
     							SUM(CASE WHEN `valid`= '1'    THEN 1 ELSE 0 END) AS `valid_tests`,
     							SUM(CASE WHEN `valid`= '0'    THEN 1 ELSE 0 END) AS `errors`,
     							SUM(CASE WHEN `valid`= '1'  AND  `cd4_count` < 350 THEN 1 ELSE 0 END) AS `failed`,
     							SUM(CASE WHEN `valid`= '1'  AND  `cd4_count` >= 350 THEN 1 ELSE 0 END) AS `passed`
     						FROM `v_pima_uploads_details`
     						WHERE 1 
     						AND `pima_upload_id` > $last_upl 
     						$user_delimiter 
     						GROUP BY `pima_upload_id`
     						ORDER BY `upload_date` DESC
     					";
     */
     $sql = "CALL get_last_upload_details(" . $last_upl . ")";
     return $res = R::getAll($sql);
 }
Esempio n. 12
0
 public function testProcessStatusAndMessagesForEachRow()
 {
     Yii::app()->user->userModel = User::getByUsername('super');
     $import = new Import();
     $serializedData['importRulesType'] = 'ImportModelTestItem';
     $import->serializedData = serialize($serializedData);
     $this->assertTrue($import->save());
     $testTableName = $import->getTempTableName();
     $this->assertTrue(ImportTestHelper::createTempTableByFileNameAndTableName('importTest.csv', $testTableName));
     $count = ImportDatabaseUtil::getCount($testTableName);
     $this->assertEquals(5, $count);
     //Now add import results.
     $resultsUtil = new ImportResultsUtil($import);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(2);
     $rowDataResultsUtil->setStatusToUpdated();
     $rowDataResultsUtil->addMessage('the first message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(3);
     $rowDataResultsUtil->setStatusToCreated();
     $rowDataResultsUtil->addMessage('the second message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $rowDataResultsUtil = new ImportRowDataResultsUtil(4);
     $rowDataResultsUtil->setStatusToError();
     $rowDataResultsUtil->addMessage('the third message');
     $resultsUtil->addRowDataResults($rowDataResultsUtil);
     $resultsUtil->processStatusAndMessagesForEachRow();
     $sql = 'select * from ' . $testTableName . ' where id != 1';
     $tempTableData = R::getAll($sql);
     $compareData = array(array('id' => 2, 'column_0' => 'abc', 'column_1' => '123', 'column_2' => 'a', 'status' => 1, 'serializedmessages' => serialize(array('the first message'))), array('id' => 3, 'column_0' => 'def', 'column_1' => '563', 'column_2' => 'b', 'status' => 2, 'serializedmessages' => serialize(array('the second message'))), array('id' => 4, 'column_0' => 'efg', 'column_1' => '456', 'column_2' => 'a', 'status' => 3, 'serializedmessages' => serialize(array('the third message'))), array('id' => 5, 'column_0' => 'we1s', 'column_1' => null, 'column_2' => 'b', 'status' => null, 'serializedmessages' => null));
     $this->assertEquals($compareData, $tempTableData);
 }
Esempio n. 13
0
    function register($data)
    {
        try {
            include_once 'dbcon.php';
        } catch (Exception $e) {
            ?>
<script type="text/javascript">
alert("Unable to connect to DB, Please contact Administrator");
</script>
<?php 
        }
        $admin->uname = $username;
        $admin->password = $password;
        $admin->sh_name = $shName;
        $admin->full_name = $fullName;
        $admin->desc = $desc;
        $admin->location = $location;
        $admin->address = $address;
        $admin->date_added = $dateAdded;
        $admin->estd_year = $estddate;
        try {
            R::store($admin);
        } catch (Exception $e) {
            ?>
<script type="text/javascript">
			alert("Unable to save to DB, Please contact Administrator");
			</script>
<?php 
        }
    }
Esempio n. 14
0
 protected static function generateCampaignItems($campaign, $pageSize)
 {
     if ($pageSize == null) {
         $pageSize = self::DEFAULT_CAMPAIGNITEMS_TO_CREATE_PAGE_SIZE;
     }
     $contacts = array();
     $quote = DatabaseCompatibilityUtil::getQuote();
     $marketingListMemberTableName = RedBeanModel::getTableName('MarketingListMember');
     $campaignItemTableName = RedBeanModel::getTableName('CampaignItem');
     $sql = "select {$quote}{$marketingListMemberTableName}{$quote}.{$quote}contact_id{$quote} from {$quote}{$marketingListMemberTableName}{$quote}";
     // Not Coding Standard
     $sql .= "left join {$quote}{$campaignItemTableName}{$quote} on ";
     $sql .= "{$quote}{$campaignItemTableName}{$quote}.{$quote}contact_id{$quote} ";
     $sql .= "= {$quote}{$marketingListMemberTableName}{$quote}.{$quote}contact_id{$quote}";
     $sql .= "AND {$quote}{$campaignItemTableName}{$quote}.{$quote}campaign_id{$quote} = " . $campaign->id . " ";
     $sql .= "where {$quote}{$marketingListMemberTableName}{$quote}.{$quote}marketinglist_id{$quote} = " . $campaign->marketingList->id;
     $sql .= " and {$quote}{$campaignItemTableName}{$quote}.{$quote}id{$quote} is null limit " . $pageSize;
     $ids = R::getCol($sql);
     foreach ($ids as $contactId) {
         $contacts[] = Contact::getById((int) $contactId);
     }
     if (!empty($contacts)) {
         //todo: if the return value is false, then we might need to catch that since it didn't go well.
         CampaignItem::registerCampaignItemsByCampaign($campaign, $contacts);
         if (count($ids) < $pageSize) {
             return true;
         }
     } else {
         return true;
     }
     return false;
 }
Esempio n. 15
0
 public function get_pima_controls_reported($user_group_id, $user_filter_used, $from, $to)
 {
     $sql = "CALL get_pima_controls_reported('" . $from . "','" . $to . "'," . $user_group_id . "," . $user_filter_used . ")";
     $res = R::getAll($sql);
     // print_r($res);die();
     return $res;
 }
Esempio n. 16
0
function do_stuff()
{
    /* 26.9|0.0|0.0|31.4|0.00|0.00|0.00|0.00 */
    $result = file_get_contents('http://ourproject.dyndns-server.com:8099/&');
    echo $result;
    $rs = explode('|', $result);
    echo "\n";
    $now = new DateTime();
    $b = R::dispense('timedate');
    $b->time = $now->format('Y-m-d H:i:s');
    $b->T1 = $rs[0];
    $b->T2 = $rs[1];
    $b->T3 = $rs[2];
    $b->T4 = $rs[3];
    $b->V1 = $rs[4];
    $b->V2 = $rs[5];
    $b->V3 = $rs[6];
    $b->V4 = $rs[7];
    R::store($b);
    echo $b->time;
    echo "\n";
    // MySQL datetime format
    sleep(10);
    // wait 20 seconds
    do_stuff();
    // call this function again
}
 public function printLogs()
 {
     $db_query = "SELECT * FROM (\r\n            SELECT ttylog.session, timestamp, ROUND(LENGTH(ttylog)/1024, 2) AS size\r\n            FROM ttylog\r\n            JOIN auth ON ttylog.session = auth.session\r\n            WHERE auth.success = 1\r\n            GROUP BY ttylog.session\r\n            ORDER BY timestamp DESC\r\n            ) s\r\n            WHERE size > " . PLAYBACK_SIZE_IGNORE;
     $rows = R::getAll($db_query);
     if (count($rows)) {
         //We create a skeleton for the table
         $counter = 1;
         echo '<p>The following table displays a list of all the logs recorded by Kippo.
                  Click on column heads to sort data.</p>';
         echo '<table id="Playlog-List" class="tablesorter"><thead>';
         echo '<tr class="dark">';
         echo '<th>ID</th>';
         echo '<th>Timestamp</th>';
         echo '<th>Size</th>';
         echo '<th>Play the log</th>';
         echo '</tr></thead><tbody>';
         //For every row returned from the database we create a new table row with the data as columns
         foreach ($rows as $row) {
             echo '<tr class="light word-break">';
             echo '<td>' . $counter . '</td>';
             echo '<td>' . $row['timestamp'] . '</td>';
             echo '<td>' . $row['size'] . 'kb' . '</td>';
             echo '<td><a href="include/play.php?f=' . $row['session'] . '" target="_blank"><img class="icon" src="images/play.ico"/>Play</a></td>';
             echo '</tr>';
             $counter++;
         }
         //Close tbody and table element, it's ready.
         echo '</tbody></table>';
         echo '<hr /><br />';
     }
 }
Esempio n. 18
0
 public function create_group($name)
 {
     $group = R::dispense('group');
     $group->name = $name;
     R::store($group);
     return $group;
 }
Esempio n. 19
0
 public function update_facilities($id)
 {
     $sql = "SELECT \n\t\t\t\t\t  `facility_id`,\n\t\t\t\t\t  `equipment_id`,\n                      `serial_number`,\n                      `ctc_id_no`\n\t\t\t\tFROM `facility_equipment_request`\n\t\t\t\tWHERE id = {$id}";
     $facilty = R::getAll($sql);
     //print_r($facilty); die();
     /*foreach ($facilty as $key => $val) {
     			$db = $val;
     				$tumepata = implode(',', $db);
     				echo $tumepata;
     		}
             die;*/
     if ($facilty[0]['equipment_id'] == 4) {
         $facility_equipment_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => ' ', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
         $insert = $this->db->insert('facility_equipment', $facility_equipment_registration);
         $asus = $this->db->insert_id();
         $facility_registration = array('id' => NULL, 'facility_equipment_id' => $asus, 'serial_num' => $facilty[0]['serial_number'], 'ctc_id_no' => $facilty[0]['ctc_id_no']);
         //print_r($facility_registration);die;
         $insert = $this->db->insert('facility_pima', $facility_registration);
         // $asus = $this->db->insert_id();
         // $faciility_pima_id = array(
         // 							'facility_equipment_id'    =>   $asus
         // 							);
         // $this->db->where('id', $asus);
         // $this->db->update('facility_pima', $faciility_pima_id);
         //print_r($asus); die();
         return $insert;
     } else {
         $facility_registration = array('id' => NULL, 'facility_id' => $facilty[0]['facility_id'], 'equipment_id' => $facilty[0]['equipment_id'], 'status' => '1', 'deactivation_reason' => '', 'date_added' => NULL, 'date_removed' => NULL, 'serial_number' => $facilty[0]['serial_number']);
         $insert = $this->db->insert('facility_equipment', $facility_registration);
         return $insert;
     }
 }
Esempio n. 20
0
 /**
  * Test tainted.
  * 
  * @return void
  */
 public function testTainted()
 {
     testpack('Original Tainted Tests');
     $redbean = R::$redbean;
     $spoon = $redbean->dispense("spoon");
     asrt($spoon->getMeta("tainted"), TRUE);
     $spoon->dirty = "yes";
     asrt($spoon->getMeta("tainted"), TRUE);
     testpack('Tainted List test');
     $note = R::dispense('note');
     $note->text = 'abc';
     $note->ownNote[] = R::dispense('note')->setAttr('text', 'def');
     $id = R::store($note);
     $note = R::load('note', $id);
     asrt($note->isTainted(), FALSE);
     // Shouldn't affect tainted
     $note->text;
     asrt($note->isTainted(), FALSE);
     $note->ownNote;
     asrt($note->isTainted(), TRUE);
     testpack('Tainted Test Old Value');
     $text = $note->old('text');
     asrt($text, 'abc');
     asrt($note->hasChanged('text'), FALSE);
     $note->text = 'xxx';
     asrt($note->hasChanged('text'), TRUE);
     $text = $note->old('text');
     asrt($text, 'abc');
     testpack('Tainted Non-exist');
     asrt($note->hasChanged('text2'), FALSE);
     testpack('Misc Tainted Tests');
     $bean = R::dispense('bean');
     $bean->hasChanged('prop');
     $bean->old('prop');
 }
Esempio n. 21
0
 public function onPreDispatch()
 {
     $dbms = isset($this->config['dbms']) ? $this->config['dbms'] : 'mysql';
     if ($dbms == 'sqlite') {
         if (!isset($this->config['database'])) {
             throw new \Empathy\MVC\Exception('sqlite database file not supplied.');
         }
         $db = DOC_ROOT . '/' . $this->config['database'];
         if (!file_exists($db)) {
             throw new \Empathy\MVC\Exception('sqlite database file not found.');
         }
         \R::setup('sqlite:' . $db);
     } else {
         if (!defined('DB_SERVER')) {
             throw new \Empathy\MVC\Exception('Database server is not defined in config.');
         }
         if (!$this->isIP(DB_SERVER)) {
             throw new \Empathy\MVC\Exception('Database server must be an IP address.');
         }
         $dsn = $dbms . ':host=' . DB_SERVER . ';dbname=' . DB_NAME . ';';
         if (defined('DB_PORT') && is_numeric(DB_PORT)) {
             $dsn .= 'port=' . DB_PORT . ';';
         }
         \R::setup($dsn, DB_USER, DB_PASS);
     }
 }
Esempio n. 22
0
 public static function enviar()
 {
     global $request;
     $request = R::findAll('request', ' ORDER BY name ');
     $user = R::findAll('user');
     $lista = [];
     $subject = "Lista del super";
     $file = fopen('vistas/email/email.ejs', 'r');
     $content = fread($file, filesize('vistas/email/email.ejs'));
     $message = __($content)->template(array('lista' => $request));
     $header = "From:lista@carrito.esy.es\r\n";
     $header .= "MIME-Version: 1.0\r\n";
     $header .= "Content-type: text/html\r\n";
     foreach ($user as $key => $value) {
         if (isset($value->email) && $value->email != "" && $value->rol == 1) {
             $lista[] = $value->email;
             $to = $value->email;
             $retval = mail($to, $subject, $message, $header);
             if ($retval == true) {
                 echo json_encode($lista);
             } else {
                 echo "Message could not be sent...";
             }
         }
     }
 }
Esempio n. 23
0
function delete_news($id)
{
    $news = R::load('news', $id);
    //reloads our event
    R::trash($news);
    //for one bean
}
 public function init()
 {
     // check if logged in session is valid, if not redir to main page
     if (!isset($_SESSION['loginHash'])) {
         Framework::Redir("site/index");
         die;
     }
     $activeSession = R::findOne('session', ' hash = ? AND ip = ? AND expires > ?', array($_SESSION['loginHash'], $_SERVER['REMOTE_ADDR'], time()));
     if (!$activeSession) {
         unset($_SESSION['loginHash']);
         Framework::Redir("site/index/main/session_expired");
         die;
     }
     $activeSession->expires = time() + SESSION_MAX_AGE * 2;
     R::store($activeSession);
     $this->session = $activeSession;
     $this->user = R::load('user', $this->session->user->getId());
     Framework::TPL()->assign('user_premium', $this->user->hasPremium());
     // check needed rights if any
     foreach ($this->_rights as $r) {
         if (!$this->user->hasRight($r)) {
             Framework::Redir("game/index");
             die;
         }
     }
 }
 public static function getUserExternalSystemIds()
 {
     $columnName = ExternalSystemIdUtil::EXTERNAL_SYSTEM_ID_COLUMN_NAME;
     RedBeanColumnTypeOptimizer::externalIdColumn(User::getTableName('User'), $columnName);
     $sql = 'select ' . $columnName . ' from ' . User::getTableName('User');
     return R::getCol($sql);
 }
Esempio n. 26
0
function _log_focus($openid, $operation, $user_info = NULL)
{
    R::addDatabase('wechat_csc', $GLOBALS['db_wechat_csc_url'], $GLOBALS['db_wechat_csc_user'], $GLOBALS['db_wechat_csc_pass']);
    R::selectDatabase('wechat_csc');
    if (!R::testConnection()) {
        exit('DB failed' . PHP_EOL);
    }
    R::freeze(true);
    try {
        $user = R::getRedBean()->dispense('wxcsc_focus');
        $user->openid = $openid;
        $user->operation = $operation;
        if ($operation == 'focus' && $user_info != NULL) {
            $user->nickname = $user_info['nickname'];
            $user->sex = $user_info['sex'];
            $user->language = $user_info['language'];
            $user->city = $user_info['city'];
            $user->province = $user_info['province'];
            $user->country = $user_info['country'];
        }
        $user_id = R::store($user);
    } catch (Exception $e) {
        header('Content-type:text/json;charset=utf-8');
        echo json_encode(['result' => 'failed', 'error' => 'db error wechat', 'details' => $e->getMessage()]);
        die;
    }
    R::close();
}
Esempio n. 27
0
 public static function clean($f3, $filename)
 {
     $total_filesize = R::getCell('select sum(filesize) as total_filesize from cache');
     $cache_total_filesize_limit = $f3->get("UPLOAD.cache_total_size_limit");
     $cache_total_filesize_limit = PFH_File_helper::convert_filesize_in_bytes($cache_total_filesize_limit);
     if ($total_filesize > $cache_total_filesize_limit) {
         $caches = R::find("cache", "ORDER BY datetime");
         $count = count($caches);
         // 只有一個不刪除
         //if ($count < 2) {
         //    return;
         //}
         foreach ($caches as $key => $cache) {
             //不刪除最後一個
             //if ($key > $count - 1) {
             //    return;
             //}
             if ($cache->path === $filename) {
                 continue;
             }
             //throw new Exception("$key $cache->path");
             //echo $cache->path . "<br />";
             if (is_file($cache->path)) {
                 unlink($cache->path);
             }
             $total_filesize = $total_filesize - $cache->filesize;
             R::trash($cache);
             if ($total_filesize < $cache_total_filesize_limit) {
                 break;
             }
         }
     }
 }
 public function save()
 {
     GUMP::add_validator("unique", function ($field, $input, $param = NULL) {
         $checkExistingUser = R::findOne('user', 'user=?', array($input));
         if ($checkExistingUser == NULL) {
             return FALSE;
         } else {
             return TRUE;
         }
     });
     GUMP::add_validator("strong", function ($field, $input, $param = NULL) {
         return checkPasswordStrength($input);
     });
     $rules = array('reseller_username' => 'required|alpha_numeric|max_len,10|min_len,6|unique', 'reseller_password' => 'required|max_len,10|min_len,7|strong');
     $filters = array('reseller_username' => 'trim|sanitize_string', 'reseller_password' => 'trim|sanitize_string|md5');
     $app = Slim::getInstance();
     $post = $app->request()->post();
     // $app - Slim main app instance
     $postValues = $gump->filter($post, $filters);
     $validated = $gump->validate($gump->filter($postValues, $filters), $rules);
     if ($validated === TRUE) {
         $createUser = R::dispense('user');
         $createUser->user = $postValues['reseller_username'];
         $createUser->user = $postValues['reseller_password'];
     } else {
         $this->setError($gump->get_readable_errors(true));
     }
     if ($this->getError() == "") {
         $this->fails = FALSE;
     } else {
         $this->fails = TRUE;
     }
 }
Esempio n. 29
-1
 static function execute($number = 5)
 {
     if (!is_numeric($number)) {
         throw new Exception('Number must be numeric');
     }
     $callables = R::findAll('queueitem', 'status = "open" ORDER BY id DESC LIMIT ' . $number);
     $c = 0;
     foreach (array_values($callables) as $index => $calleble) {
         $c++;
         if ($calleble->done) {
             $c--;
             continue;
         }
         if ($c >= $number) {
             break;
         }
         $serializer = new Serializer();
         $closure = $serializer->unserialize($calleble->callser);
         ////			$calleble->status = 'busy';
         //			R::store($calleble);
         $closure();
         $calleble->status = 'done';
         $calleble->done = true;
         $calleble->doneat = time();
         R::store($calleble);
     }
     return;
 }
 public function countJobs($terms)
 {
     $terms = splitTerms($terms);
     $terms = implode('|', $terms);
     $jobs = R::findAll('jobs', " status=1 AND (title REGEXP :title OR description REGEXP :description OR perks REGEXP :perks OR how_to_apply REGEXP :how_to_apply OR company_name REGEXP :company_name)", array(':title' => $terms, ':description' => $terms, ':perks' => $terms, ':how_to_apply' => $terms, ':company_name' => $terms));
     return count($jobs);
 }