public function testSeqBindPrefix()
 {
     $query_factory = new QueryFactory('sqlite');
     $first = $query_factory->newSelect();
     $this->assertSame('', $first->getSeqBindPrefix());
     $again = $query_factory->newSelect();
     $this->assertSame('_1', $again->getSeqBindPrefix());
 }
 private function tryFindMatchResultFor($hash, $dataValue)
 {
     $descriptionFactory = $this->queryFactory->newDescriptionFactory();
     $contextPage = $dataValue->getContextPage();
     // Exclude the current page from the result match to check whether another
     // page matches the condition and if so then the value can no longer be
     // assigned and is not unique
     $description = $descriptionFactory->newConjunction(array($descriptionFactory->newFromDataValue($dataValue), $descriptionFactory->newValueDescription($contextPage, null, SMW_CMP_NEQ)));
     $query = $this->queryFactory->newQuery($description);
     $query->setLimit(1);
     $dataItems = $this->cachedPropertyValuesPrefetcher->queryPropertyValuesFor($query);
     if (!is_array($dataItems) || $dataItems === array()) {
         // No other assignments were found therefore it is assumed that at
         // the time of the query request, the "contextPage" holds a unique
         // value for the property
         $page = $contextPage;
     } else {
         $page = end($dataItems);
     }
     // Create a linked list so that when the subject is altered or deleted
     // the related uniqueness container can be removed as well
     $blobStore = $this->cachedPropertyValuesPrefetcher->getBlobStore();
     $container = $blobStore->read($this->cachedPropertyValuesPrefetcher->getRootHashFrom($page));
     $container->addToLinkedList($hash);
     $blobStore->save($container);
     return $page;
 }
Пример #3
0
 public function testExtractPrefixesFromQueryNoPrefixes()
 {
     // assumption here is that fixture is of type
     $this->fixture = $this->queryFactory->createInstanceByQueryString('DELETE DATA { GRAPH <http://> { ?s ?p ?o } }');
     $queryParts = $this->fixture->getQueryParts();
     $this->assertFalse(isset($queryParts['prefixes']));
 }
 function setup()
 {
     global $MODULE;
     $this->module = $MODULE;
     parent::setup();
     global $HERMES_TEST_ITEM;
     $this->test_data = $HERMES_TEST_ITEM;
     $this->query = QueryFactory::create($MODULE);
 }
Пример #5
0
 public static function Delete()
 {
     $results = [];
     $test = QueryFactory::Build("delete");
     $test->From("users")->Where(["email", "=", "asd"])->Limit();
     self::testing("Delete");
     $qinfo = DatabaseManager::Query($test);
     self::testQuery($test, true, 1, $qinfo->RowCount());
     $results[count($results)] = $qinfo;
     $qinfo = DatabaseManager::Query($test);
     self::testQuery($test, false, 0, $qinfo->RowCount());
     $results[count($results)] = $qinfo;
     return $results;
 }
Пример #6
0
 public function testExtractQuads()
 {
     // assumption here is that fixture is of type
     $this->fixture = $this->queryFactory->createInstanceByQueryString('PREFIX dc: <http://foo/bar/>
         INSERT DATA {
             Graph <http://saft/test/g1> { <http://saft/test/s1> dc:p1 <http://saft/test/o1>}
             Graph <http://saft/test/g1> {<http://saft/test/s2> <http://test/p2> <http://saft/test/o2>.}
             Graph <http://saft/test/g2> {
                 <http://saft/test/s3> dc:p3 "abc"^^<http://www.w3.org/2001/XMLSchema#string>
             }
         }');
     $queryParts = $this->fixture->getQueryParts();
     $this->assertEqualsArrays(array(array('s' => 'http://saft/test/s1', 'p' => 'http://foo/bar/p1', 'o' => 'http://saft/test/o1', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'uri', 'o_datatype' => null, 'o_lang' => null, 'g' => 'http://saft/test/g1', 'g_type' => 'uri'), array('s' => 'http://saft/test/s2', 'p' => 'http://test/p2', 'o' => 'http://saft/test/o2', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'uri', 'o_datatype' => null, 'o_lang' => null, 'g' => 'http://saft/test/g1', 'g_type' => 'uri'), array('s' => 'http://saft/test/s3', 'p' => 'http://foo/bar/p3', 'o' => 'abc', 's_type' => 'uri', 'p_type' => 'uri', 'o_type' => 'typed-literal', 'o_datatype' => 'http://www.w3.org/2001/XMLSchema#string', 'o_lang' => null, 'g' => 'http://saft/test/g2', 'g_type' => 'uri')), $queryParts['quad_pattern']);
 }
Пример #7
0
function process($curr)
{
    echo $curr["name"] . ": ";
    echo $curr["frequency"] . "<br>";
    //if need to run task
    if (strtotime($curr["frequency"], $curr["lastRun"]) < time()) {
        //run job
        include __DIR__ . '/' . $curr["name"];
        //update last run time
        $ran = QueryFactory::Build('update');
        $ran->Table("schedule")->Set(["lastRun", time()])->Where(["name", '=', $curr["name"]]);
        $success = DatabaseManager::Query($ran);
        //for testing
        if ($success->RowCount() > 0) {
            echo $curr['name'] . " updated";
        } else {
            echo $curr['name'] . " failed";
        }
    }
}
Пример #8
0
 public function testSaveResultCacheEntries()
 {
     $queryObject = $this->queryFactory->createInstanceByQueryString('SELECT ?s ?p ?o FROM <' . $this->testGraph->getUri() . '> WHERE { ?s ?p ?o }');
     $result = array(1, 2, 3);
     $this->fixture->saveResult($queryObject, $result);
     /**
      * check saved references between graph URIs (from query) and a array of query strings
      */
     $this->assertEquals(array($queryObject->getQuery() => $queryObject->getQuery()), $this->fixture->getCache()->load($this->testGraph->getUri()));
     /**
      * check saved references between triple pattern (from query) and a array of query strings
      */
     $this->assertEquals(array($queryObject->getQuery() => $queryObject->getQuery()), $this->fixture->getCache()->load($this->testGraph->getUri() . $this->separator . '*' . $this->separator . '*' . $this->separator . '*'));
     /**
      * check saved references between triple pattern (from query) and a array of query strings
      */
     $sep = $this->separator;
     $this->assertEquals(array('graph_uris' => array($this->testGraph->getUri() => $this->testGraph->getUri()), 'triple_pattern' => array($this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*' => $this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*'), 'result' => $result, 'query' => $queryObject->getQuery()), $this->fixture->getCache()->load($queryObject->getQuery()));
     /**
      * check, that upper query cache container was added to latestQueryCacheContainer during saveResult
      */
     $this->assertEquals(array(array('graph_uris' => array($this->testGraph->getUri() => $this->testGraph->getUri()), 'triple_pattern' => array($this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*' => $this->testGraph->getUri() . $sep . '*' . $sep . '*' . $sep . '*'), 'result' => $result, 'query' => $queryObject->getQuery())), $this->fixture->getLatestQueryCacheContainer());
 }
Пример #9
0
<?php

$name = "users";
$table = new CreateTable($name);
$table->AddColumn('id')->SetAutoIncrement();
$table->AddColumn('email')->MakeVarChar(100)->AddKey('unique');
$table->AddColumn('password')->MakeVarChar(100);
$table->AddColumn('pLevel')->MakeInt()->DefaultValue('1');
$table->AddColumn('created')->MakeInt();
$table->AddColumn('NextAssessment')->MakeInt()->DefaultValue(0);
$table->AddColumn('activated')->MakeBool()->DefaultValue('false');
$table->AddColumn('salt')->MakeVarChar(100)->DefaultValue(bin2hex(mcrypt_create_iv(22, MCRYPT_DEV_URANDOM)));
$table->AddColumn('salt_time')->MakeInt()->DefaultValue(0);
$population = array();
$population[] = QueryFactory::Build("insert")->Into($name)->Set(["email", "*****@*****.**"], ["password", "\$2y\$11\$593EkWGKJ.1dkCN/ivW1OOOf180ijPxRPyaUr7w79fWFJmQUNietK"], ["created", "UNIX_TIMESTAMP()"], ["pLevel", 3], ["activated", 1]);
return [$table, $population];
Пример #10
0
<?php

$name = "schedule";
$table = new CreateTable($name);
$table->AddColumn('id')->SetAutoIncrement();
$table->AddColumn('name')->MakeVarChar(100)->AddKey('unique');
$table->AddColumn('frequency')->MakeVarChar(100);
$table->AddColumn('lastRun')->MakeInt();
$population = array();
$population[] = QueryFactory::Build("insert")->Into($name)->Set(["name", "manageUsers.php"], ["frequency", "+1 minute"], ["lastRun", "UNIX_TIMESTAMP()"]);
$population[] = QueryFactory::Build("insert")->Into($name)->Set(["name", "test.php"], ["frequency", "+3 months"], ["lastRun", "UNIX_TIMESTAMP()"]);
//$population[] = QueryFactory::Build("insert")->Into($name)->Set(["name", "activationTimer.php"], ["frequency", "+12 hours"], ["lastRun", "UNIX_TIMESTAMP()"]);
return [$table, $population];
Пример #11
0
          [^\\w\\s-]       # but char before ID is non-ID char.
        )                 # End host alternatives.
        ([\\w-]{11})      # $1: VIDEO_ID is exactly 11 chars.
        (?=[^\\w-]|$)     # Assert next char is non-ID or EOS.
        (?!               # Assert URL is not pre-linked.
          [?=&+%\\w.-]*    # Allow URL (query) remainder.
          (?:             # Group pre-linked alternatives.
            [\'"][^<>]*>  # Either inside a start tag,
          | </a>          # or inside <a> element text contents.
          )               # End recognized pre-linked alts.
        )                 # End negative lookahead assertion.
        [?=&+%\\w.-]*        # Consume any URL (query) remainder.
        ~ix', $text, $result);
    return $result[1];
}
$select = QueryFactory::Build("select")->Select("id", "title", "content", "created", "viewby")->From("articles");
$info = DatabaseManager::Query($select);
$articles = $info->Result();
// Result returns the result directly if there is only one result
// This compensates for that by wrapping the single result in an array, like multiple articles would be
// This allows for a simpler code base
if ($info->RowCount() < 2) {
    $articles = [$articles];
}
?>
<script>
    var youtubeLinkRegex = /^.*((youtu.be\/)|(v\/)|(\/u\/\w\/)|(embed\/)|(watch\?))\??v?=?([^#\&\?]*).*/;
    $(document).ready(function(){
        var editors = 0;
        var articles = $("#articlesList");
        articles.on('click', '#edit', function (e) {
Пример #12
0
 private function set($name, $enabled)
 {
     //format string
     $str = $this->formatString();
     //update
     $update = QueryFactory::Build('update');
     $update->Table('settings')->Set(['enabled', $enabled])->Where(['name', '=', $name]);
     if (strlen($str) > 2) {
         $update->Table('settings')->Set(['value', $str]);
     }
     $cinfo = DatabaseManager::Query($update);
     if ($cinfo->RowCount() != 1) {
         return "our servers are having issues please try again later";
     }
     return false;
 }
Пример #13
0
    if ($output_format == 'email') {
        unset($_REQUEST['format']);
        header("Location: " . $MODULE->url('email', '/search?' . $QUERY->url_query($_REQUEST)), TRUE, 303);
        exit;
    } else {
        if ($QUERY->has_allowed_criteria($_REQUEST)) {
            $results = $QUERY->search($_REQUEST);
            if (is_null($results)) {
                header("HTTP/1.0 400 Bad request");
                // check for error
                $MESSAGE = $QUERY->error_code ? $QUERY->error_message : $STRINGS['error_query_empty'];
            } else {
                $TITLE = $STRINGS['results_title'];
            }
            // Remember the current query in the session
            QueryFactory::set_session_query($MODULE, $QUERY);
            // Add to search history
            $USER->add_to_search_history($QUERY);
        }
    }
}
// Set up the right-hand blocks
$SIDEBAR = @$QUERY->filter_info['sidebar'];
// Display page to user
header('Content-Type: ' . $MODULE->content_type($output_format));
// look for a formatter
$formatter = $MODULE->new_formatter($output_format);
if (!is_null($formatter)) {
    // clone the query object and run the search with a larger page size
    $large_query = clone $QUERY;
    $criteria = $_REQUEST;
 function new_query_from_defs($criteria_defs = NULL)
 {
     global $MODULE;
     $config = $this->query_config;
     if ($criteria_defs) {
         $config['criteria_defs'] = $criteria_defs;
     }
     return QueryFactory::create($MODULE, $config);
 }
Пример #15
0
function deactivate($id)
{
    $update = QueryFactory::Build('update');
    $update->Table('users')->Set(['activated', -1])->Where(['id', '=', $id]);
    $temp = DatabaseManager::Query($update);
    if ($temp->RowCount() == 1) {
        echo "deactivated " . $id;
    } else {
        echo "failed to deactivate " . $id;
    }
}
Пример #16
0
        $_SESSION[$USER->login . '_TIME'] = time();
    }
}
// Users who can't save data can't use email export
//### FIXME: this is the wrong right to use surely???
if (!$USER->has_right('save_data')) {
    $tmp = array_search('email', $CONF['export_formats']);
    if ($tmp !== FALSE) {
        unset($CONF['export_formats'][$tmp]);
    }
}
// --- Global variables ---
// Main site title
$SITE_TITLE = $MODULE->title . @$CONF['title_suffix'];
// Get the current Query or create a new one
$QUERY = QueryFactory::get_session_query($MODULE);
// Marked records
$MARKED_RECORDS = isset($_SESSION['MARKED_RECORDS']) ? $_SESSION['MARKED_RECORDS'] : new MarkedRecord();
// Record History
// TODO AV - move into user
if (!isset($_SESSION['HISTORY_RECORDS'])) {
    $_SESSION['HISTORY_RECORDS'] = new RecordList($CONF['record_history_size']);
}
// Get session message if there is one
$MESSAGE = NULL;
$MESSAGE_CLASS = 'error-message';
// default class is for errors
if (isset($_SESSION['MESSAGE'])) {
    get_session_message($MESSAGE, $MESSAGE_CLASS);
}
// retrieve the message
Пример #17
0
 public static function updateElement($id, $column, $value)
 {
     $update = QueryFactory::Build("update");
     //new update query
     $update->Table("users")->Where(["id", "=", $id])->Set([$column, $value]);
     //update the query
     $res = DatabaseManager::Query($update);
     // execute the query
     if ($res->RowCount() == 1) {
         return true;
     }
     return false;
 }
Пример #18
0
 function setup()
 {
     global $MODULE;
     $this->query = QueryFactory::create($MODULE);
 }
Пример #19
0
 public function getDataTableRowCount()
 {
     $query = QueryFactory::Build('select');
     $query->Select('id')->From('enrollment_form');
     $enrolCount = DatabaseManager::Query($query);
     $query = QueryFactory::Build('select');
     $query->Select('id')->From('questionnaire_form');
     $questCount = DatabaseManager::Query($query);
     $query = QueryFactory::Build('select');
     $query->Select('id')->From('parq_form');
     $parqCount = DatabaseManager::Query($query);
     /*
     uncomment when assessments are working and done
     $query = QueryFactory::Build('select');
     $query->Select('id')->From('assessment');
     $enrolCount = DatabaseManager::Query($query);
     */
     // add the value for assessments when they are done
     $value_array = array($enrolCount->RowCount(), $questCount->RowCount(), $parqCount->RowCount());
     return $value_array;
 }
Пример #20
0
$array = ["Chairstand" => ["30 Second Chair Stand", "Lower body strength evaluation. Assess strength for climbing stairs, walking, and getting out of a chair, car, or tub. Number of full stands that can be completed in 30 seconds with arms folded across chest. If the arms are pulled away from the chest or you rock back and forward to help you stand that is unacceptable and the test will be stopped at that point. You may rest while siting on the chair and continue if you are still within the 30 seconds.", "ChairStand", "m0APvLqZr5E"], "ArmCurl" => ["Arm Curl", "Assess upper body strength, needed for performing household and other activities involving lifting and carrying things such as groceries, suitcases and grandchildren. Number of bicep curls – lifting the weight from the arm extended up to the shoulder and back down – that can be completed in 30 seconds holding a 5 lb weight (for women) or an 8 lb weight (for men). You may not use the back to help “throw” the weight up. The weight must come up and touch the shoulder and the return to the lowered position should be with control, not just dropping the arm. You may rest in the down position and continue with lifts if you are still within the 30 seconds.", "ArmCurl", "m0APvLqZr5E"], "StepTest" => ["2-Minute Step Test", "Aerobic endurance test. Number of full steps completed in 2 minutes, raising the knee to a point halfway between the kneecap and the hip on each step. If the knee does not come up high enough you will be reminded to lift it higher. If you are testing yourself at home stand in front of a mirror so you can assess the knee height.", "Steptest", "m0APvLqZr5E"], "FootUpAndGo" => ["8 Foot Up and Go", "Assess agility and dynamic balance needed for quick maneuvering such as getting on or off a bus, getting up to attend to something in the kitchen, going to the bathroom, or getting up to answer the phone. Number of seconds it takes to get up out of a chair, walk 8 feet, turn around a cone, and return to the chair and sit down. The entire movement must be in control. You may use your hands to help get up from the chair and to sit back down.", "FootUpandGo", "m0APvLqZr5E"], "unilateralbalancetest" => ["Unilateral Balance Test", "Fall risk evaluation.  Balance test determined by how long you can stand on one foot without moving, or touching the lifted foot back to the ground.  The lifted leg may not be braced against the support leg, lift the lower leg up and to the rear till the knee is at 90 degrees. Not acceptable is excessive movement of arms or body to hold position", "Unilateral", "m0APvLqZr5E"], "FunctionalReach" => ["Functional Reach", "Assess balance in a forward motion. Reach as far forward as you can keep your arm parallel to the yardstick without touching the wall or taking a step forward. Do not overreach and risk falling.", "Functional", "m0APvLqZr5E"]];
?>
<div class="background">
<!-- Accordion -->
    
<?php 
$find = QueryFactory::Build('select');
$find->Select("Chairstand", "ArmCurl", "StepTest", "FootUpAndGo", "leftunilateralbalancetest", "rightunilateralbalancetest", "FunctionalReach")->From('assessments')->Where(['userID', '=', $user->id, "AND"], ['DateCompleted', '=', 0]);
$find->Limit();
$res = DatabaseManager::Query($find);
$result = $res->Result();
$left = $result["leftunilateralbalancetest"];
$right = $result["rightunilateralbalancetest"];
$result["unilateralbalancetest"] = [$left, $right];
unset($result["leftunilateralbalancetest"], $result["rightunilateralbalancetest"]);
$time = QueryFactory::Build('select');
$time->Select("NextAssessment")->From("users")->Where(["id", "=", $user->id])->limit();
$time = DatabaseManager::Query($time);
$time = $time->Result()["NextAssessment"];
//echo $time;
?>


    <h1 class="demoHeaders">Assessments</h1>
	 <?php 
//show next assessment date
if ($time > 0 && $time > time()) {
    echo "<h2>next assessment on " . date("F d, Y", $time) . "</h2>";
}
?>
 
Пример #21
0
 function after_search(&$results, $query, $criteria)
 {
     if ($query->module->name != 'fed') {
         $fed_module = Module::load('fed');
         $criteria = $query->criteria_container->get_qs_key_values();
         // Don't propagate TRILT dates, as it is annoying to get the 2 week date limit if not logged in
         if ($query->module->name == 'trilt') {
             unset($criteria['date'], $criteria['date_start'], $criteria['date_end']);
         }
         $criteria = $this->rewrite_query($criteria, $query);
         if (is_null($criteria)) {
             return;
         }
         //### FIXME: without this, queries for all records don't have 'q=' in them, this needs to be fixed in QueryCriteria class
         $criteria['page'] = 1;
         $fed_query = QueryFactory::create($fed_module);
         $url = $fed_query->url($criteria);
         $criteria_msg = '';
         if (@$criteria['q'] != '') {
             $criteria_msg = " for <b>{$criteria['q']}</b>";
         }
         $msg = "You are currently searching in <b>{$query->module->title}</b>. <a href=\"{$url}\">Search all the BUFVC's collections{$criteria_msg}</a>.";
         $query->filter_info['sidebar'][] = new SidebarBlock('Search All BUFVC', $msg);
     }
 }
Пример #22
0
<?php

$name = basename(__FILE__, ".php");
$table = new CreateTable($name);
$table->AddColumn("id")->SetAutoIncrement();
$table->AddColumn("title")->MakeVarChar(100);
$table->AddColumn("content")->MakeText();
$table->AddColumn("created")->MakeInt();
$table->AddColumn("updated")->MakeInt();
$table->AddColumn("viewby")->MakeTinyInt()->DefaultValue(0);
$info = array();
$insert = QueryFactory::Build("insert");
$info[] = $insert->Into($name)->Set(["title", 'Welcome to Sit and Be Fit "Feel the difference" Project!'], ["content", '<p>Welcome to the Feel the Difference project website. We are reaching' . 'out to adults 55+ and/or those managing chronic conditions with an invitation' . 'to participate in an important research study to determine the effectiveness' . 'of the Sit and Be Fit exercise program</p>' . '<iframe width="100%" height="360" src="https://www.youtube.com/embed/31Ew1ogQqpE" frameborder="0" allowfullscreen></iframe>'], ["created", "UNIX_TIMESTAMP()"], ["viewby", UserLevel::Anon]);
return [$table, $info];
Пример #23
0
 public static function isQuestionnaireComplete($id)
 {
     $select = QueryFactory::Build("select");
     $select->Select('completed')->Table('questionnaire_form')->Where(['userID', '=', $id])->Limit();
     $res = DatabaseManager::Query($select);
     $resultArray = $res->Result();
     if ($res->RowCount() == 1) {
         return $res;
     }
     return false;
 }
Пример #24
0
<?php

$name = "forgotPasswordTimeout";
$table = new CreateTable($name);
$table->AddColumn('id')->SetAutoIncrement();
$table->AddColumn('creationTime')->MakeVarChar(100);
$table->AddColumn('hash')->MakeVarChar(100)->AddKey('unique');
$population = array();
$population[] = QueryFactory::Build("insert")->Into($name)->Set(["id", "0"], ["creationTime", "0"], ["hash", "0"]);
return [$table, $population];
Пример #25
0
// Get Listings class
$classname = $MODULE->listings_class;
$listings = new $classname();
// If we have an incoming command with a channel parameter, then grab it here
// as it can conflict with the normal channel QC
// NOTE AV : the use of the name channel is not ideal - I'd rename it if I was sure
// that it wouldn't break existing interfaces
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    $channel_action = $_POST['channel'];
    unset($_POST['channel']);
    unset($_REQUEST['channel']);
}
// Get the current Listings Query or create a new one
$QUERY = $MODULE->get_session_data('LISTINGS_QUERY');
if (is_null($QUERY)) {
    $QUERY = QueryFactory::create($MODULE, $MODULE->listings_query_config);
}
// a way to retain what channels may have been set in the session
if (!isset($_REQUEST['channel'])) {
    $_REQUEST['channel'] = $QUERY['channel']->get_value();
}
$QUERY->set_criteria_values($_REQUEST);
$listings->process_criteria($QUERY);
// Set up global vars
$TITLE = $listings->title;
$TEMPLATE = 'listings';
$is_logged_in = $USER->has_right('save_data');
if ($is_logged_in && @count($USER->prefs['listings_channels']) == 0) {
    $USER->prefs['listings_channels'] = $QUERY['channel']->get_default();
}
// Get the output format
 static function get_session_query($module, $ignore_module_session = FALSE, $table_name = NULL, $util = NULL)
 {
     // Util for testing only
     if (is_null($util)) {
         $util = new QueryFactoryUtil($module);
     }
     if ($table_name == '') {
         $table_name = $util->get_default_table();
     }
     if ($ignore_module_session) {
         $result = @$_SESSION['QUERY'];
     } else {
         $result = $module->get_session_data('QUERY' . '/' . $table_name);
     }
     if (is_null($result)) {
         $result = QueryFactory::create($module, array('table_name' => $table_name));
     }
     return $result;
 }
 function setup()
 {
     global $MODULE;
     $this->query = QueryFactory::create($MODULE, array('query_class' => $this->query_class_name));
 }
Пример #28
0
         // ************************************************* this block is google's recaptcha *************************************************************************
         //*********************************************** THIS IS FROM GOOGLE RECAPTCHA API ***********************************************************************
         $secret = "6LejtgYTAAAAAMlSC70hXViKkntfBVU2PBdICylx";
         // this is a secret code for reCaptcha connection
         $ip = gethostbyname($_SERVER['SERVER_NAME']);
         // this is how you grab end user's ip
         $captcha = $_POST['g-recaptcha-response'];
         $response = file_get_contents("https://www.google.com/recaptcha/api/siteverify?secret={$secret}&response={$captcha}&remoteip={$ip}");
         $captchaResult = json_decode($response, true);
         //******************************************************************************************************************************************************************************
         if ($captchaResult['success']) {
             $id = UserModel::Register($email, $password);
             // Call to Register function in UserModel, returns true if register is a success
             if ($id) {
                 //*****************   SEND ACTIVATION EMAIL ********************************
                 $userQuery = QueryFactory::Build("select");
                 $userQuery->Select("email", "created")->From("users")->Where(["id", "=", $id])->Limit();
                 $res = DatabaseManager::Query($userQuery);
                 $res = $res->Result();
                 // get result from table
                 $link = sha1($id . $res["email"] . $res["created"]);
                 // get the hash value for the link to send out
                 Mailer::Send("{$email}", "Activation Email", "Please click on the link below to activate your account, http://{$server}/activation.php?id={$id}&link={$link}");
                 $msg = ["Registration successful, please check your email for account activation", 1];
                 unset($_POST);
             }
         } else {
             $msg = ["You are not a human, registration denied! <br>", 0];
         }
     }
 }
Пример #29
0
    if (is_null($ACTIVELIST)) {
        $ACTIVELIST = array();
    }
}
// User does not have permission, or saved querylist is broken
if (@$QUERYLIST == NULL) {
    $QUERYLIST = new QueryList();
    $ACTIVELIST = array();
}
// check for a form POST
if (is_array($_POST) && count($_POST) > 0 && $canSave) {
    // determine post type
    if (isset($_POST['save'])) {
        unset($_POST['save']);
        // create the query with the criteria in the post
        $query = QueryFactory::create($MODULE);
        $query->set_criteria_values($_POST);
        if (!$QUERYLIST->contains($query)) {
            if (count($QUERYLIST) >= $CONF['saved_searches_size']) {
                $MESSAGE = $STRINGS['error_saved_searches_limit'];
                $MESSAGE_CLASS = 'error-message';
            } else {
                $QUERYLIST->add($query);
                // saved searches are 'active' by default
                array_unshift($ACTIVELIST, '1');
                if (count($ACTIVELIST) > count($QUERYLIST)) {
                    array_pop($ACTIVELIST);
                }
                // save the searches
                $USER->save_data('saved_searches', $QUERYLIST);
                $USER->save_data('saved_searches_active', $ACTIVELIST);
Пример #30
0
<?php

require_once "header.php";
$msg = "";
$id = Validator::instance()->sanitize("int", $_GET['id']);
//get the ID from the link to prevent people from inserting their own ID
// ****************************** Activate the user by ID ***********************************************************************
$select = QueryFactory::Build("select");
$select->Select("id", "email", "created", "activated")->From("users")->Where(["id", "=", $id])->Limit();
$res = DatabaseManager::Query($select);
$res = $res->Result();
if ($res["activated"] === 1) {
    $msg = ["Your account is already activated!", 1];
}
$userActivationHash = sha1($res["id"] . $res["email"] . $res["created"]);
// get user hash from database to compare against the link
if ($userActivationHash === $_GET['link']) {
    if (UserModel::updateElement($res["id"], "activated", "1")) {
        // if acctivation is a success
        $msg = ["Account activation successful!", 1];
    } else {
        $msg = ["Your account is already activated!", 0];
    }
} else {
    $msg = ["Invalid link, please try again!", 0];
}
?>


<div class="background">
	<h2><center> Activation </center></h2>