/*
 *  wordpress-lti - WordPress module to add LTI support
 *  Copyright (C) 2013  Simon Booth, Stephen P Vickers
 *
 *  This program is free software; you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation; either version 2 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License along
 *  with this program; if not, write to the Free Software Foundation, Inc.,
 *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *  Contact: s.p.booth@stir.ac.uk
 *
 *  Version history:
 *    1.0.00  18-Apr-13  Initial release
 */
/** Load WordPress Administration Bootstrap */
require_once dirname(dirname(dirname(dirname(dirname(__FILE__))))) . DIRECTORY_SEPARATOR . 'wp-admin' . DIRECTORY_SEPARATOR . 'admin.php';
// include the library
require_once 'lib.php';
header('Content-type: application/json');
echo '{"Key": "' . lti_get_guid() . '","Secret": "' . LTI_Data_Connector::getRandomString(32) . '"}';
 /**
  * Save the resource link share key to the database.
  *
  * @return boolean True if the share key was successfully saved
  */
 public function save()
 {
     if (empty($this->life)) {
         $this->life = self::DEFAULT_SHARE_KEY_LIFE;
     } else {
         $this->life = max(min($this->life, self::MAX_SHARE_KEY_LIFE), 0);
     }
     $this->expires = time() + $this->life * 60 * 60;
     if (empty($this->id)) {
         if (empty($this->length) || !is_numeric($this->length)) {
             $this->length = self::MAX_SHARE_KEY_LENGTH;
         } else {
             $this->length = max(min($this->length, self::MAX_SHARE_KEY_LENGTH), self::MIN_SHARE_KEY_LENGTH);
         }
         $this->id = LTI_Data_Connector::getRandomString($this->length);
     }
     return $this->data_connector->Resource_Link_Share_Key_save($this);
 }
Example #3
0
function lti_get_guid()
{
    $lti_scope = 3;
    if (isset($_GET['lti_scope'])) {
        $lti_scope = $_GET['lti_scope'];
    }
    $str = strtoupper(LTI_Data_Connector::getRandomString(6));
    return 'WP' . $lti_scope . '-' . $str;
}