Esempio n. 1
12
 /**
  * Sets the time against which the session is measured. This function also
  * sets the cash_session_id internally as a mechanism for tracking analytics
  * against a consistent id, regardless of PHP session id.
  *
  * @return boolean
  */
 protected function startSession()
 {
     // begin PHP session
     if (!defined('STDIN')) {
         // no session for CLI, suckers
         @session_cache_limiter('nocache');
         $session_length = 3600;
         @ini_set("session.gc_maxlifetime", $session_length);
         @session_start();
     }
     $this->cash_session_timeout = ini_get("session.gc_maxlifetime");
     if (!isset($_SESSION['cash_session_id'])) {
         $modifier_array = array('deedee', 'johnny', 'joey', 'tommy', 'marky');
         $_SESSION['cash_session_id'] = $modifier_array[array_rand($modifier_array)] . '_' . rand(1000, 9999) . substr((string) time(), 4);
     }
     if (isset($_SESSION['cash_last_request_time'])) {
         if ($_SESSION['cash_last_request_time'] + $this->cash_session_timeout < time()) {
             $this->resetSession();
         }
     }
     $_SESSION['cash_last_request_time'] = time();
     if (!isset($GLOBALS['cash_script_store'])) {
         $GLOBALS['cash_script_store'] = array();
     }
     return true;
 }
Esempio n. 2
2
 public static function start($lifetime = 0, $path = '/', $domain = NULL)
 {
     if (!self::$_initialized) {
         if (!is_object(Symphony::Database()) || !Symphony::Database()->connected()) {
             return false;
         }
         $cache = Cache::instance()->read('_session_config');
         if (is_null($cache) || $cache === false) {
             self::create();
             Cache::instance()->write('_session_config', true);
         }
         if (!session_id()) {
             ini_set('session.save_handler', 'user');
             ini_set('session.gc_maxlifetime', $lifetime);
             ini_set('session.gc_probability', '1');
             ini_set('session.gc_divisor', '3');
         }
         session_set_save_handler(array('Session', 'open'), array('Session', 'close'), array('Session', 'read'), array('Session', 'write'), array('Session', 'destroy'), array('Session', 'gc'));
         session_set_cookie_params($lifetime, $path, $domain ? $domain : self::getDomain(), false, false);
         if (strlen(session_id()) == 0) {
             if (headers_sent()) {
                 throw new Exception('Headers already sent. Cannot start session.');
             }
             session_start();
         }
         self::$_initialized = true;
     }
     return session_id();
 }
Esempio n. 3
2
 /**
  * @ignore
  * @param array $options
  */
 public function prepareEnvironment($options = array())
 {
     if (empty($options['skipErrorHandler'])) {
         set_error_handler(array('Ip\\Internal\\ErrorHandler', 'ipErrorHandler'));
     }
     if (empty($options['skipError'])) {
         if (ipConfig()->showErrors()) {
             error_reporting(E_ALL | E_STRICT);
             ini_set('display_errors', '1');
         } else {
             ini_set('display_errors', '0');
         }
     }
     if (empty($options['skipSession'])) {
         if (session_id() == '' && !headers_sent()) {
             //if session hasn't been started yet
             session_name(ipConfig()->get('sessionName'));
             if (!ipConfig()->get('disableHttpOnlySetting')) {
                 ini_set('session.cookie_httponly', 1);
             }
             session_start();
         }
     }
     if (empty($options['skipEncoding'])) {
         mb_internal_encoding(ipConfig()->get('charset'));
     }
     if (empty($options['skipTimezone'])) {
         date_default_timezone_set(ipConfig()->get('timezone'));
         //PHP 5 requires timezone to be set.
     }
 }
Esempio n. 4
1
function permisos($rol, $ruta)
{
    session_start();
    //Si no hay una sesion iniciada, redirige al login
    if (!$_SESSION) {
        header('Location:' . $ruta . 'vistas/login.php');
    } else {
        //Si no existe la variable de sesion del usuario logueado, redirige al login
        if (!isset($_SESSION["rol"])) {
            header('Location:' . $ruta . 'vistas/login.php');
        } else {
            if ($_SESSION["rol"] != $rol && $_SESSION["login_usuario"] != 'test') {
                header('location:' . $ruta . 'vistas/menu.php');
            } else {
                include_once '' . $ruta . 'vistas/headers.php';
                //Escoge el idioma por defecto si no tiene uno el usuario
                if (!$_SESSION["idioma"]) {
                    $includeIdioma = $ruta . "modelo/esp.php";
                    return $includeIdioma;
                } else {
                    $includeIdioma = $ruta . "modelo/" . $_SESSION['idioma'] . ".php";
                    return $includeIdioma;
                }
            }
        }
    }
}
Esempio n. 5
0
 /**
  * Constructor. Starts PHP session handling in our own private store
  *
  * Side-effect: might set a cookie, so must be called before any other output.
  */
 public function __construct()
 {
     $this->typo3tempPath = PATH_site . 'typo3temp/';
     // Start our PHP session early so that hasSession() works
     $sessionSavePath = $this->getSessionSavePath();
     // Register our "save" session handler
     session_set_save_handler(array($this, 'open'), array($this, 'close'), array($this, 'read'), array($this, 'write'), array($this, 'destroy'), array($this, 'gc'));
     session_save_path($sessionSavePath);
     session_name($this->cookieName);
     ini_set('session.cookie_path', GeneralUtility::getIndpEnv('TYPO3_SITE_PATH'));
     // Always call the garbage collector to clean up stale session files
     ini_set('session.gc_probability', 100);
     ini_set('session.gc_divisor', 100);
     ini_set('session.gc_maxlifetime', $this->expireTimeInMinutes * 2 * 60);
     if (\TYPO3\CMS\Core\Utility\PhpOptionsUtility::isSessionAutoStartEnabled()) {
         $sessionCreationError = 'Error: session.auto-start is enabled.<br />';
         $sessionCreationError .= 'The PHP option session.auto-start is enabled. Disable this option in php.ini or .htaccess:<br />';
         $sessionCreationError .= '<pre>php_value session.auto_start Off</pre>';
         throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587485);
     } elseif (defined('SID')) {
         $sessionCreationError = 'Session already started by session_start().<br />';
         $sessionCreationError .= 'Make sure no installed extension is starting a session in its ext_localconf.php or ext_tables.php.';
         throw new \TYPO3\CMS\Install\Exception($sessionCreationError, 1294587486);
     }
     session_start();
 }
Esempio n. 6
0
 public function signIn($userName, $passwordMd5)
 {
     $tempconnect = $this->connector;
     $sql = "SELECT * FROM users WHERE name=? and password=?";
     $stmt = $tempconnect->prepare($sql);
     $stmt->bind_param('ss', $userName, $passwordMd5);
     $stmt->execute();
     //direk deðerleri döndürür
     /*while($stmt->fetch())
       {
           echo $userName. " ". $passwordMd5;
           echo "<br>";
       }*/
     //count döndürür
     while ($satir = $stmt->fetch()) {
         $this->conservative = $satir;
     }
     if ($this->conservative) {
         echo "basarili";
         session_start();
         $_SESSION["login"] = "******";
         $stmt->close();
         echo "<script>window.location.replace('userProfile.php');</script>";
     } else {
         echo "basarisiz";
         $stmt->close();
     }
 }
Esempio n. 7
0
/**
 * Initialize session.
 * @param boolean $keepopen keep session open? The default is
 * 			to close the session after $_SESSION has been populated.
 * @uses $_SESSION
 */
function session_init($keepopen = false)
{
    $settings = new phpVBoxConfigClass();
    // Sessions provided by auth module?
    if (@$settings->auth->capabilities['sessionStart']) {
        call_user_func(array($settings->auth, $settings->auth->capabilities['sessionStart']), $keepopen);
        return;
    }
    // No session support? No login...
    if (@$settings->noAuth || !function_exists('session_start')) {
        global $_SESSION;
        $_SESSION['valid'] = true;
        $_SESSION['authCheckHeartbeat'] = time();
        $_SESSION['admin'] = true;
        return;
    }
    // start session
    session_start();
    // Session is auto-started by PHP?
    if (!ini_get('session.auto_start')) {
        ini_set('session.use_trans_sid', 0);
        ini_set('session.use_only_cookies', 1);
        // Session path
        if (isset($settings->sessionSavePath)) {
            session_save_path($settings->sessionSavePath);
        }
        session_name(isset($settings->session_name) ? $settings->session_name : md5('phpvbx' . $_SERVER['DOCUMENT_ROOT'] . $_SERVER['HTTP_USER_AGENT']));
        session_start();
    }
    if (!$keepopen) {
        session_write_close();
    }
}
 function Gerar()
 {
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     session_write_close();
     $this->titulo = "Software - Detalhe";
     $this->addBanner("http://ieducar.dccobra.com.br/intranet/imagens/nvp_top_intranet.jpg", "http://ieducar.dccobra.com.br/intranet/imagens/nvp_vert_intranet.jpg", "Intranet");
     $this->cod_software = $_GET["cod_software"];
     $tmp_obj = new clsPmicontrolesisSoftware($this->cod_software);
     $registro = $tmp_obj->detalhe();
     if (!$registro) {
         header("location: controlesis_software_lst.php");
         die;
     }
     if ($registro["cod_software"]) {
         $this->addDetalhe(array("Software", "{$registro["cod_software"]}"));
     }
     if ($registro["nm_software"]) {
         $this->addDetalhe(array("Nome Software", "{$registro["nm_software"]}"));
     }
     $this->url_novo = "controlesis_software_cad.php";
     $this->url_editar = "controlesis_software_cad.php?cod_software={$registro["cod_software"]}";
     $this->url_cancelar = "controlesis_software_lst.php";
     $this->largura = "100%";
 }
Esempio n. 9
0
 private static function generateId()
 {
     @session_start();
     $id = session_id();
     session_destroy();
     return $id;
 }
Esempio n. 10
0
function regenerateSession($reload = false)
{
    // This token is used by forms to prevent cross site forgery attempts
    if (!isset($_SESSION['nonce']) || $reload) {
        $_SESSION['nonce'] = md5(microtime(true));
    }
    if (!isset($_SESSION['IPaddress']) || $reload) {
        $_SESSION['IPaddress'] = $_SERVER['REMOTE_ADDR'];
    }
    if (!isset($_SESSION['userAgent']) || $reload) {
        $_SESSION['userAgent'] = $_SERVER['HTTP_USER_AGENT'];
    }
    //$_SESSION['user_id'] = $this->user->getId();
    // Set current session to expire in 1 minute
    $_SESSION['OBSOLETE'] = true;
    $_SESSION['EXPIRES'] = time() + 60;
    // Create new session without destroying the old one
    session_regenerate_id(false);
    // Grab current session ID and close both sessions to allow other scripts to use them
    $newSession = session_id();
    session_write_close();
    // Set session ID to the new one, and start it back up again
    session_id($newSession);
    session_start();
    // Don't want this one to expire
    unset($_SESSION['OBSOLETE']);
    unset($_SESSION['EXPIRES']);
}
Esempio n. 11
0
function setFlash($type, $message)
{
    if (!isSessionStarted()) {
        session_start();
    }
    $_SESSION['flash'][$type] = $message;
}
Esempio n. 12
0
 /**
  * コンストラクタ
  */
 public function __construct()
 {
     if (!self::$session_started) {
         session_start();
         self::$session_started = true;
     }
 }
Esempio n. 13
0
 function __construct()
 {
     parent::__construct();
     session_start();
     $this->load->model('user_model');
     $this->load->helper(array('form'));
 }
Esempio n. 14
0
 /**
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     $this->display_column_left = false;
     $this->display_column_right = false;
     parent::initContent();
     $cart = $this->context->cart;
     $client = $this->context->customer;
     $invoice_address = new Address((int) $cart->id_address_invoice);
     $state = new State((int) $invoice_address->id_state);
     $arreglo_meses = array();
     for ($i = 1; $i <= 12; $i++) {
         $arreglo_meses[] = sprintf("%02s", $i);
     }
     $arreglo_anyos = array();
     $anyo_actual = date("Y", time());
     for ($i = 0; $i < 12; $i++) {
         $arreglo_anyos[] = substr($anyo_actual + $i, -2);
     }
     session_start();
     $arreglo_errores = array();
     if (is_array($_SESSION['errores'])) {
         foreach ($_SESSION['errores'] as $key => $value) {
             $arreglo_errores[$key] = $value;
         }
     }
     unset($_SESSION['errores']);
     $this->context->smarty->assign(array('nbProducts' => $cart->nbProducts(), 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'this_path' => $this->module->getPathUri(), 'this_path_ssl' => Tools::getShopDomainSsl(true, true) . __PS_BASE_URI__ . 'modules/' . $this->module->name . '/', 'nombre' => $client->firstname, 'apellidos' => $client->lastname, 'cp' => $invoice_address->postcode, 'monto' => $cart->getOrderTotal(true, Cart::BOTH), 'email' => $client->email, 'telefono' => $invoice_address->phone, 'celular' => $invoice_address->phone_mobile, 'calleyNumero' => $invoice_address->address1, 'colonia' => '', 'municipio' => $invoice_address->city, 'estado' => $state->name, 'pais' => $invoice_address->country, 'anyos' => $arreglo_anyos, 'meses' => $arreglo_meses, 'errores' => $arreglo_errores));
     $this->setTemplate('payment_execution.tpl');
 }
Esempio n. 15
0
 /**
  * Identical to the parent constructor, except that
  * we start a PHP session to store the user ID and
  * access token if during the course of execution
  * we discover them.
  *
  * @param Array $config the application configuration.
  * @see BaseFacebook::__construct in facebook.php
  */
 public function __construct($config)
 {
     if (!session_id()) {
         session_start();
     }
     parent::__construct($config);
 }
 function CaptchaSecurityImages($width = '120', $height = '40', $characters = '6')
 {
     $code = $this->generateCode($characters);
     /* font size will be 75% of the image height */
     $font_size = $height * 0.85;
     $image = imagecreate($width, $height) or die(__('Cannot initialize new GD image stream', 'formbuilder'));
     /* set the colours */
     $background_color = imagecolorallocate($image, 255, 255, 255);
     $text_color = imagecolorallocate($image, 20, 40, 100);
     $noise_color = imagecolorallocate($image, 100, 120, 180);
     /* generate random dots in background */
     for ($i = 0; $i < $width * $height / 3; $i++) {
         imagefilledellipse($image, mt_rand(0, $width), mt_rand(0, $height), 1, 1, $noise_color);
     }
     /* generate random lines in background */
     for ($i = 0; $i < $width * $height / 150; $i++) {
         imageline($image, mt_rand(0, $width), mt_rand(0, $height), mt_rand(0, $width), mt_rand(0, $height), $noise_color);
     }
     /* create textbox and add text */
     $textbox = imagettfbbox($font_size, 0, $this->font, $code) or die(__('Error in imagettfbbox function', 'formbuilder'));
     $x = ($width - $textbox[4]) / 2;
     $y = ($height - $textbox[5]) / 2;
     imagettftext($image, $font_size, 0, $x, $y, $text_color, $this->font, $code) or die(__('Error in imagettftext function', 'formbuilder'));
     /* output captcha image to browser */
     session_start();
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION['security_code'] = $code;
 }
Esempio n. 17
0
 /**
  * Is called by the base Module class directly after the constructor has been called
  */
 protected function postCreation()
 {
     // set the name for the session cookie. MAKE SURE IT CONTAINS AT LEAST ONE LETTER.
     session_name(md5('APPLICATIONSESSIONKEY') . "COOKIE");
     session_start();
     $this->session =& $_SESSION;
 }
Esempio n. 18
0
function run()
{
    session_start();
    require_once '../civicrm.config.php';
    require_once 'CRM/Core/Config.php';
    $config = CRM_Core_Config::singleton();
    require_once 'Console/Getopt.php';
    $shortOptions = "n:p:k:pre";
    $longOptions = array('name=', 'pass='******'key=', 'prefix=');
    $getopt = new Console_Getopt();
    $args = $getopt->readPHPArgv();
    array_shift($args);
    list($valid, $dontCare) = $getopt->getopt2($args, $shortOptions, $longOptions);
    $vars = array('name' => 'n', 'pass' => 'p', 'key' => 'k', 'prefix' => 'pre');
    foreach ($vars as $var => $short) {
        ${$var} = NULL;
        foreach ($valid as $v) {
            if ($v[0] == $short || $v[0] == "--{$var}") {
                ${$var} = $v[1];
                break;
            }
        }
        if (!${$var}) {
            ${$var} = CRM_Utils_Array::value($var, $_REQUEST);
        }
        $_REQUEST[$var] = ${$var};
    }
    // this does not return on failure
    // require_once 'CRM/Utils/System.php';
    CRM_Utils_System::authenticateScript(TRUE, $name, $pass);
    //log the execution of script
    CRM_Core_Error::debug_log_message('NormalizePhone.php');
    // process all phones
    processPhones($config, $prefix);
}
Esempio n. 19
0
 function __construct()
 {
     if (session_status() == PHP_SESSION_NONE) {
         session_start();
     }
     /* session is started if you don't write this line can't use $_Session  global variable */
 }
Esempio n. 20
0
 function __construct()
 {
     // this is your constructor
     parent::__construct();
     session_start();
     $this->load->model('admin/users_model');
 }
 /**
  * Returns the ID of the user session
  *
  * Automatically starts the session if necessary.
  *
  * @return string  The session ID
  */
 protected function getSessionId()
 {
     if (!session_id()) {
         session_start();
     }
     return session_id();
 }
Esempio n. 22
0
 function iniciarSesion($session_name, $secure)
 {
     // Make sure the session cookie is not accessable via javascript.
     $httpunico = true;
     // Hash algorithm to use for the sessionid. (use hash_algos() to get a list of available hashes.)
     $sesion_hash = 'sha512';
     // Check if hash is available
     if (in_array($sesion_hash, hash_algos())) {
         // Set the has function.
         ini_set('session.hash_function', $sesion_hash);
     }
     // How many bits per character of the hash.
     // The possible values are '4' (0-9, a-f), '5' (0-9, a-v), and '6' (0-9, a-z, A-Z, "-", ",").
     ini_set('session.hash_bits_per_character', 5);
     // Force the session to only use cookies, not URL variables.
     ini_set('session.use_only_cookies', 1);
     // Get session cookie parameters
     $cookieParams = session_get_cookie_params();
     // Set the parameters
     session_set_cookie_params($cookieParams["lifetime"], $cookieParams["path"], $cookieParams["domain"], $secure, $httpunico);
     // Change the session name
     session_name($session_name);
     // Now we cat start the session
     session_start();
     // This line regenerates the session and delete the old one.
     // It also generates a new encryption key in the database.
 }
Esempio n. 23
0
 /**
  * connect to salesforce, get sforceClient
  * @return SforcePartnerClient
  */
 public static function getClient()
 {
     if (self::$_sForceClient == NULL) {
         $sforceClient = new SforcePartnerClient();
         // TODO now only partner client supported.
         $soapClient = $sforceClient->createConnection(self::$wsdlPartner);
         if (PHP_SAPI != 'cli') {
             @session_start();
             if (isset($_SESSION[self::SESSION_KEY])) {
                 $conf = $_SESSION[self::SESSION_KEY];
                 $sforceClient->setEndpoint($conf->location);
                 $sforceClient->setSessionHeader($conf->sessionId);
             } else {
                 $sforceLogin = $sforceClient->login(self::$username, self::$password . self::$securityToken);
                 $conf = new stdClass();
                 $conf->location = $sforceClient->getLocation();
                 $conf->sessionId = $sforceClient->getSessionId();
                 $_SESSION[self::SESSION_KEY] = $conf;
             }
         } else {
             $sforceLogin = $sforceClient->login(self::$username, self::$password . self::$securityToken);
         }
         self::$_sForceClient = $sforceClient;
     }
     return self::$_sForceClient;
 }
Esempio n. 24
0
 public static function set($key, $value)
 {
     if (empty(session_id())) {
         session_start();
     }
     $_SESSION[$key] = $value;
 }
Esempio n. 25
0
 /**
  * Init
  */
 public function start()
 {
     session_name('SESSID');
     if (session_status() === PHP_SESSION_NONE) {
         session_start();
     }
 }
 /**
  * Starts Session and sets the isStarted to true
  *
  * @return void
  */
 public static function startSession()
 {
     if (!SessionHandler::$isStarted) {
         SessionHandler::$isStarted = true;
         session_start();
     }
 }
Esempio n. 27
0
 /**
  * starts the session
  */
 public static function init()
 {
     // if no session exist, start the session
     if (session_id() == '') {
         session_start();
     }
 }
 function Inicializar()
 {
     $retorno = 'Novo';
     @session_start();
     $this->pessoa_logada = $_SESSION['id_pessoa'];
     @session_write_close();
     $this->cod_servidor = $_GET['ref_cod_servidor'];
     $this->ref_cod_instituicao = $_GET['ref_cod_instituicao'];
     $obj_permissoes = new clsPermissoes();
     $obj_permissoes->permissao_cadastra(635, $this->pessoa_logada, 7, 'educar_servidor_lst.php');
     if (is_numeric($this->cod_servidor) && is_numeric($this->ref_cod_instituicao)) {
         $obj = new clsPmieducarServidor($this->cod_servidor, NULL, NULL, NULL, NULL, NULL, NULL, $this->ref_cod_instituicao);
         $registro = $obj->detalhe();
         if ($registro) {
             $this->ref_cod_subnivel = $registro['ref_cod_subnivel'];
             $obj_subnivel = new clsPmieducarSubnivel($this->ref_cod_subnivel);
             $det_subnivel = $obj_subnivel->detalhe();
             if ($det_subnivel) {
                 $this->ref_cod_nivel = $det_subnivel['ref_cod_nivel'];
             }
             if ($this->ref_cod_nivel) {
                 $obj_nivel = new clsPmieducarNivel($this->ref_cod_nivel);
                 $det_nivel = $obj_nivel->detalhe();
                 $this->ref_cod_categoria = $det_nivel['ref_cod_categoria_nivel'];
             }
             $retorno = 'Editar';
         }
     } else {
         echo sprintf('<script>window.parent.fechaExpansivel("%s");</script>', $_GET['div']);
         die;
     }
     return $retorno;
 }
 public function process()
 {
     session_start();
     $mysql = new pokeGOMySQL();
     // check for name being passed in
     if (isset($this->inData['goBack'])) {
         header("location:LoginController.php");
     } else {
         if (isset($this->inData['submitUser'])) {
             header("location:CreateNewUserController.php");
             $this->myNEWUserName = $this->inData['myNEWUserName'];
             $this->myNEWPassword = $this->inData['myNEWPassword'];
             //$this->myNEWCONFIRMPassword = $this->inData['myNEWCONFIRMPassword'];
             //$_SESSION['myNEWCONFIRMPassword'] = $this->inData['myNEWCONFIRMPassword'];
             $_SESSION['myNEWPassword'] = $this->inData['myNEWPassword'];
             $_SESSION['myNEWUserName'] = $this->inData['myNEWUserName'];
             //$this->outData['myNEWCONFIRMPassword'] = $_SESSION['myNEWCONFIRMPassword'];
             $this->outData['myNEWPassword'] = $_SESSION['myNEWPassword'];
             $this->outData['myNEWUserName'] = $_SESSION['myNEWUserName'];
             $this->addUser($mysql);
         } else {
             // initialize a new session array, this is if the page is refreshed
             session_destroy();
             //if the session_destroy does not destroy the session
             //this will force all $_SESSION into a new array
             $_SESSION = array();
         }
     }
 }
Esempio n. 30
0
function nextend_api_auth_flow()
{
    $api_key = NextendRequest::getVar('api_key');
    $api_secret = NextendRequest::getVar('api_secret');
    $redirect_uri = NextendRequest::getVar('redirect_uri');
    if (session_id() == "") {
        @session_start();
    }
    if (!$api_key || !$api_secret || !$redirect_uri) {
        $api_key = isset($_SESSION['api_key']) ? $_SESSION['api_key'] : null;
        $api_secret = isset($_SESSION['api_secret']) ? $_SESSION['api_secret'] : null;
        $redirect_uri = isset($_SESSION['redirect_uri']) ? $_SESSION['redirect_uri'] : null;
    } else {
        $_SESSION['api_key'] = $api_key;
        $_SESSION['api_secret'] = $api_secret;
        $_SESSION['redirect_uri'] = $redirect_uri;
    }
    if ($api_key && $api_secret) {
        require_once dirname(__FILE__) . "/api/Instagram.php";
        $config = array('client_id' => $api_key, 'client_secret' => $api_secret, 'redirect_uri' => $redirect_uri, 'grant_type' => 'authorization_code');
        $instagram = new Instagram($config);
        $accessCode = $instagram->getAccessCode();
        if ($accessCode === null) {
            $instagram->openAuthorizationUrl();
        } else {
            $accessToken = $instagram->getAccessToken();
            unset($_SESSION['api_key']);
            unset($_SESSION['api_secret']);
            unset($_SESSION['redirect_uri']);
            echo '<script type="text/javascript">';
            echo 'window.opener.setToken("' . $accessToken . '");';
            echo '</script>';
        }
    }
}