Example #1
1
 public function logAppDevice($type, $token)
 {
     $forever = time() + 10 * 365 * 24 * 60 * 60;
     setcookie('device_type', $type, $forever, '/');
     setcookie('device_token', $token, $forever, '/');
     return redirect('auth/login');
 }
Example #2
0
 public static function SetCartId()
 {
     //Если Id корзины не задан
     if (self::$_mCartId == '') {
         // Если в сеансе есть Id корзины, получаем его оттуда
         if (isset($_SESSION['cart_id'])) {
             self::$_mCartId = $_SESSION['cart_id'];
         } elseif (isset($_COOKIE['cart_id'])) {
             self::$_mCartId = $_COOKIE['cart_id'];
             $_SESSION['cart_id'] = self::$_mCartId;
             //регенерируем cookie-файл, чтобы он
             //действовал 7 дней (604800 секунд)
             setcookie('cart_id', self::$_mCartId, time() + 604800);
         } else {
             /* Генерируем id корзины и сохраняем его в элементе класса
                $_mCartId, сеансе и cookie-файле (при последующих вызовах 
                $_mCartId будет получать значение из сеанса) */
             self::$_mCartId = md5(uniqid(rand(), TRUE));
             // Сохраняем id корзины в сеансе
             $_SESSION['cart_id'] = self::$_mCartId;
             // cookie-файл будет действовать 7 дней (604800 секунд)
             setcookie('cart_id', self::$_mCartId, time() + 604800);
         }
     }
 }
function run()
{
    $consumer = getConsumer();
    // Complete the authentication process using the server's
    // response.
    $return_to = getReturnTo();
    $response = $consumer->complete($return_to);
    // Check the response status.
    if ($response->status == Auth_OpenID_CANCEL) {
        // This means the authentication was cancelled.
        $msg = 'Verification cancelled.';
        if (isset($_COOKIE[session_name()])) {
            setcookie(session_name(), '', time() - 42000, '/');
        }
        session_destroy();
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID authentication failed: " . $response->message;
            if (isset($_COOKIE[session_name()])) {
                setcookie(session_name(), '', time() - 42000, '/');
            }
            session_destroy();
        } else {
            if ($response->status == Auth_OpenID_SUCCESS) {
                // This means the authentication succeeded; extract the
                // identity URL and Simple Registration data (if it was
                // returned).
                $openid = $response->getDisplayIdentifier();
                $esc_identity = escape($openid);
                $_SESSION = array();
                $_SESSION['openid'] = $esc_identity;
                if ($response->endpoint->canonicalID) {
                    $escaped_canonicalID = escape($response->endpoint->canonicalID);
                    $success .= '  (XRI CanonicalID: ' . $escaped_canonicalID . ') ';
                    $_SESSION['openid'] = $escaped_canonicalID;
                }
                // AX Process
                $ax_resp = Auth_OpenID_AX_FetchResponse::fromSuccessResponse($response);
                if ($ax_resp) {
                    global $ax_data;
                    foreach ($ax_data as $ax_key => $ax_data_ns) {
                        if ($ax_resp->data[$ax_data_ns][0]) {
                            $_SESSION['ax_' . $ax_key] = $ax_resp->data[$ax_data_ns][0];
                        }
                    }
                }
            }
        }
    }
    if ($_GET["popup"] == "true") {
        include 'close.php';
    } else {
        if ($_GET["callback"] == "ax") {
            header("Location: ./ax_example.php");
        } else {
            header("Location: ./index.php");
        }
    }
}
Example #4
0
 public function setCookies()
 {
     $cookieStr = "un=" . $this->userName;
     $cookieStr .= "&dn=" . $this->displayName;
     $cookieStr .= "&uid=" . $this->uid;
     $cookieExpire = 0;
     if ($this->rememberMe) {
         $cookieExpire = time() + 60 * 60 * 24 * 30;
     }
     $domainName = $_SERVER['SERVER_NAME'];
     if (!$domainName) {
         $domainName = $_SERVER['HTTP_HOST'];
     }
     if ($domainName == 'localhost') {
         $domainName = false;
     }
     setcookie("SymbiotaBase", $cookieStr, $cookieExpire, $GLOBALS["clientRoot"] ? $GLOBALS["clientRoot"] : '/', $domainName, false, true);
     //Set admin cookie
     if ($this->userRights) {
         $cookieStr = '';
         foreach ($this->userRights as $name => $vArr) {
             $vStr = implode(',', $vArr);
             $cookieStr .= $name . ($vStr ? '-' . $vStr : '') . '&';
         }
         setcookie("SymbiotaRights", trim($cookieStr, "&"), $cookieExpire, $GLOBALS["clientRoot"] ? $GLOBALS["clientRoot"] : '/', $domainName, false, true);
     }
 }
Example #5
0
 public function init()
 {
     /** @var Uri $uri */
     $uri = $this->grav['uri'];
     $config = $this->grav['config'];
     $is_admin = false;
     $session_timeout = $config->get('system.session.timeout', 1800);
     $session_path = $config->get('system.session.path', '/' . ltrim($uri->rootUrl(false), '/'));
     // Activate admin if we're inside the admin path.
     if ($config->get('plugins.admin.enabled')) {
         $route = $config->get('plugins.admin.route');
         $base = '/' . trim($route, '/');
         if (substr($uri->route(), 0, strlen($base)) == $base) {
             $session_timeout = $config->get('plugins.admin.session.timeout', 1800);
             $is_admin = true;
         }
     }
     if ($config->get('system.session.enabled') || $is_admin) {
         // Define session service.
         parent::__construct($session_timeout, $session_path);
         $unique_identifier = GRAV_ROOT;
         $this->setName($config->get('system.session.name', 'grav_site') . '-' . substr(md5($unique_identifier), 0, 7) . ($is_admin ? '-admin' : ''));
         $this->start();
         setcookie(session_name(), session_id(), time() + $session_timeout, $session_path);
     }
 }
Example #6
0
 /**
  * 改变外观
  */
 public function run()
 {
     //求得用户的id
     $user_id = UserUtil::getUserId($this->db, $_SESSION['user']['name']);
     //取得用户传入的参数
     $theme = $this->getParameterFromGET('id');
     if ($theme != 'default' && $theme != 'new' && $theme != 'newll') {
         $theme = 'new';
     }
     $this->db->debug = true;
     $sql = 'select count(*) as num from user_setting where user_id=?';
     $sth = $this->db->Prepare($sql);
     $res = $this->db->Execute($sth, array($user_id));
     $rows = $res->FetchRow();
     if ($rows['num']) {
         $sql = 'update user_setting set user_theme=? ' . ' where user_id=?';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($theme, $user_id));
     } else {
         $sql = 'insert into user_setting (user_theme, ' . ' user_id ) values (?, ? ) ';
         $sth = $this->db->Prepare($sql);
         $this->db->Execute($sth, array($theme, $user_id));
     }
     //更新Session设置
     $_SESSION['user']['theme'] = $theme;
     //送cookie
     if ($_COOKIE['user']) {
         $str_user_info = serialize($_SESSION['user']);
         setcookie('user', $str_user_info, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
     }
     setcookie('5abb_cookie_theme', $theme, time() + 60 * 60 * 24 * 365, '/', $global_config_web_domain);
     $this->forward('index.php');
 }
 public function logoutAction()
 {
     if (isset($_COOKIE['anastasia'])) {
         setcookie('anastasia', '', time() - 60 * 60 * 24 * 7, '/');
     }
     parent::logoutAction();
 }
Example #8
0
  function tep_session_start() {
    global $_GET, $_POST, $HTTP_COOKIE_VARS;

    $sane_session_id = true;

    if (isset($_GET[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $_GET[tep_session_name()]) == false) {
        unset($_GET[tep_session_name()]);

        $sane_session_id = false;
      }
    } elseif (isset($_POST[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $_POST[tep_session_name()]) == false) {
        unset($_POST[tep_session_name()]);

        $sane_session_id = false;
      }
    } elseif (isset($HTTP_COOKIE_VARS[tep_session_name()])) {
      if (preg_match('/^[a-zA-Z0-9]+$/', $HTTP_COOKIE_VARS[tep_session_name()]) == false) {
        $session_data = session_get_cookie_params();

        setcookie(tep_session_name(), '', time()-42000, $session_data['path'], $session_data['domain']);

        $sane_session_id = false;
      }
    }

    if ($sane_session_id == false) {
      tep_redirect(tep_href_link(FILENAME_DEFAULT, '', 'NONSSL', false));
    }

    return session_start();
  }
Example #9
0
 function karma_post($post_id, $action = 'get')
 {
     if (!is_numeric($post_id)) {
         return;
     }
     $karma_count = get_post_meta($post_id, $this->option_key, true);
     switch ($action) {
         case 'get':
             if (!$karma_count) {
                 $karma_count = 0;
                 add_post_meta($post_id, $this->option_key, $karma_count, true);
             }
             return $karma_count;
             break;
         case 'update':
             if (isset($_COOKIE[$this->option_key . $post_id])) {
                 return $karma_count;
             }
             $karma_count++;
             update_post_meta($post_id, $this->option_key, $karma_count);
             setcookie($this->option_key . $post_id, $post_id, time() * 20, '/');
             return $karma_count;
             break;
     }
 }
Example #10
0
 function mark()
 {
     $markid = $this->input->getInt('markid');
     $line = "option=com_jotcache&view=main";
     $this->model->resetMark();
     $uri = Juri::getInstance();
     $domain = $uri->toString(array('host'));
     $parts = explode('.', $domain);
     $last = count($parts) - 1;
     if ($last >= 1 && is_numeric($parts[$last]) === false) {
         $domain = $parts[$last - 1] . '.' . $parts[$last];
     }
     switch ($markid) {
         case 0:
             setcookie('jotcachemark', '0', '0', '/', $domain);
             $this->setRedirect('index.php?' . $line . "&filter_mark=", JText::_('JOTCACHE_RS_MSG_RESET'));
             break;
         case 1:
             setcookie('jotcachemark', '1', '0', '/', $domain);
             $this->setRedirect('index.php?' . $line, JText::_('JOTCACHE_RS_MSG_SET'));
             break;
         case 2:
             setcookie('jotcachemark', '2', '0', '/', $domain);
             $this->setRedirect('index.php?' . $line, JText::_('JOTCACHE_RS_MSG_RENEW'));
             break;
         default:
             break;
     }
 }
Example #11
0
function mw_logout()
{
    $cookiesSet = array_keys($_COOKIE);
    for ($x = 0; $x < count($cookiesSet); $x++) {
        setcookie($cookiesSet[$x], "", time() - 1);
    }
}
Example #12
0
 /**
  * 后台登陆控制器
  */
 public function login()
 {
     $arr = array('user_login' => I('user_login'), 'user_pass' => encrypt(I('user_pass'), C('ENCRYPTION_KEY')), 'remember-me' => I('remember-me'));
     //处理下次自动登录
     if ($arr['remember-me'] == 1) {
         $account = $arr['user_login'];
         $ip = get_client_ip(0, true);
         $value = $account . '|' . $ip;
         $value = encrypt($value, C('ENCRYPTION_KEY'));
         @setcookie('remember-me', $value, time() + 7 * 24 * 3600, "/");
     }
     $user = M('user')->where(array('user_login' => $arr['user_login']))->find();
     $userinfo = D('user')->getInfo($user['id']);
     if ($user['user_status'] == 0) {
         $this->error('账号被禁用,请联系管理员...');
     }
     if ($user['user_type'] != '管理员') {
         $this->error('无权限登录...');
     }
     if (!$user || $user['user_pass'] != $arr['user_pass']) {
         $this->error('账号密码错误,请重试...');
     }
     $data = array('id' => $user['id'], 'last_login_ip' => get_client_ip(0, true), 'last_login_time' => date("Y-m-d H:i:s"));
     $result = M('user')->save($data);
     if (!$result) {
         $this->error('登录失败,请重试...');
     }
     session('uid', $user['id']);
     session('username', $userinfo['username']);
     session('last_login_time', $data['last_login_time']);
     session('last_login_ip', $data['last_login_ip']);
     $this->success('登陆成功', U('Index/index'));
 }
Example #13
0
 /**
  * Set Cookie Value
  *
  * @param string $key
  * @param $value
  * @return void
  */
 public function setCookieValue($key, $value, $exp = NULL)
 {
     if ($key) {
         $exp = $exp ? $exp : mktime(0, 0, 0, 12, 32, 2080);
         setcookie('Tx_Nboevents_Reservation_' . $key, serialize($value), $exp, "/");
     }
 }
/**
 * 
 */
function _unsetcookies()
{
    setcookie('username', '', time() - 1);
    setcookie('uniqid', '', time() - 1);
    _session_destroy();
    _location(null, 'index.php');
}
Example #15
0
function pmRestLogin($clientId, $clientSecret, $username, $password)
{
    global $pmServer, $pmWorkspace;
    $postParams = array('grant_type' => 'password', 'scope' => '*', 'client_id' => $clientId, 'client_secret' => $clientSecret, 'username' => $username, 'password' => $password);
    $ch = curl_init("{$pmServer}/{$pmWorkspace}/oauth2/token");
    curl_setopt($ch, CURLOPT_TIMEOUT, 30);
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $postParams);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $oToken = json_decode(curl_exec($ch));
    $httpStatus = curl_getinfo($ch, CURLINFO_HTTP_CODE);
    curl_close($ch);
    if ($httpStatus != 200) {
        print "Error in HTTP status code: {$httpStatus}\n";
        return null;
    } elseif (isset($oToken->error)) {
        print "Error logging into {$pmServer}:\n" . "Error:       {$oToken->error}\n" . "Description: {$oToken->error_description}\n";
    } else {
        //At this point $oToken->access_token can be used to call REST endpoints.
        //If planning to use the access_token later, either save the access_token
        //and refresh_token as cookies or save them to a file in a secure location.
        //If saving them as cookies:
        setcookie("access_token", $oToken->access_token, time() + 3600);
        setcookie("refresh_token", $oToken->refresh_token);
        //refresh token doesn't expire
        setcookie("client_id", $clientId);
        setcookie("client_secret", $clientSecret);
        //If saving to a file:
        //file_put_contents("oauthAccess.json", json_encode($oToken));
    }
    return $oToken;
}
Example #16
0
 function like_post($post_id, $action = 'get')
 {
     if (!is_numeric($post_id)) {
         return;
     }
     switch ($action) {
         case 'get':
             $like_count = get_post_meta($post_id, '_qode-like', true);
             if (!$like_count) {
                 $like_count = 0;
                 add_post_meta($post_id, '_qode-like', $like_count, true);
             }
             return '<span class="qode-like-count">' . $like_count . '</span>';
             break;
         case 'update':
             $like_count = get_post_meta($post_id, '_qode-like', true);
             if (isset($_COOKIE['qode-like_' . $post_id])) {
                 return $like_count;
             }
             $like_count++;
             update_post_meta($post_id, '_qode-like', $like_count);
             setcookie('qode-like_' . $post_id, $post_id, time() * 20, '/');
             return '<span class="qode-like-count">' . $like_count . '</span>';
             break;
     }
 }
Example #17
0
 function logout()
 {
     //echo "here";
     setcookie("logged_in", "", time() - 3600);
     header('Location: ' . $_SERVER['PHP_SELF']);
     exit;
 }
Example #18
0
 public static function end()
 {
     if (self::$checksum == md5(serialize(self::$d))) {
         return;
     }
     if (empty(self::$d)) {
         // session is empty; we can abandon it
         setcookie(self::COOKIE_NAME, '', time() - 3600, '/');
         return;
     }
     if (!self::$sessionModel && !self::$driver) {
         if (isset($GLOBALS['_CONFIG']['cache_driver'])) {
             self::$driver = \jmvc::cache();
         } else {
             self::$sessionModel = new \jmvc\models\Session();
         }
     }
     $key = self::id() ?: self::generate_id();
     if (self::$driver) {
         self::$driver->set($key, self::$d, ONE_DAY);
     } else {
         if (self::$sessionModel) {
             self::$sessionModel->id = $key;
             self::$sessionModel->data = serialize(self::$d);
             self::$sessionModel->save();
         }
     }
 }
Example #19
0
 public static function signOut()
 {
     // clear the cookies
     setcookie('user_id', '', time() - 3600, COOKIE_PATH, COOKIE_DOMAIN);
     setcookie('username', '', time() - 3600, COOKIE_PATH, COOKIE_DOMAIN);
     setcookie('admin', '', time() - 3600, COOKIE_PATH, COOKIE_DOMAIN);
 }
Example #20
0
function login($user, $pass)
{
    $con = new db();
    $conc = $con->c();
    $kcook = intval($_POST["remember"]);
    $q = mysqli_query($conc, "SELECT `id`,`user`,`name`,`email`,`img1`,`img2`,`img3`,`bgcolor` FROM `users` WHERE (`user` = '{$user}' OR `email` ='{$user}') AND pass = '******'");
    if (mysqli_num_rows($q) == 1) {
        $r = mysqli_fetch_array($q);
        setcookie("u", $r[1], time() + 52 * 60 * 60 * 24 * 7);
        $_SESSION["uid"] = $r[0];
        $_SESSION["user"] = $r[1];
        $_SESSION["name"] = $r[2];
        $_SESSION["email"] = $r[3];
        $_SESSION["p"] = $pass;
        $_SESSION["color"] = $r[7];
        $_SESSION["img1"] = $r[4];
        $_SESSION["img2"] = $r[5];
        $_SESSION["img3"] = $r[6];
        $_SESSION["ula"] = md5("{$r['1']} {$pass} {$r['0']}");
        $con->close_db_con($conc);
        if ($kcook == 1) {
            setcookie("u", $r[1], time() + 2 * 60 * 60 * 24 * 7);
            setcookie("p", $pass, time() + 2 * 60 * 60 * 24 * 7);
        }
        return true;
    } else {
        return false;
    }
}
Example #21
0
 public function checkUser()
 {
     if (isset($_REQUEST['code'])) {
         $keys = array();
         $keys['code'] = $_REQUEST['code'];
         $keys['redirect_uri'] = U('public/Widget/displayAddons', array('type' => $_REQUEST['type'], 'addon' => 'Login', 'hook' => 'no_register_display'));
         try {
             $token = $this->_oauth->getAccessToken('code', $keys);
         } catch (OAuthException $e) {
             $token = null;
         }
     } else {
         $keys = array();
         $keys['refresh_token'] = $_REQUEST['code'];
         try {
             $token = $this->_oauth->getAccessToken('token', $keys);
         } catch (OAuthException $e) {
             $token = null;
         }
     }
     if ($token) {
         setcookie('weibojs_' . $this->_oauth->client_id, http_build_query($token));
         $_SESSION['sina']['access_token']['oauth_token'] = $token['access_token'];
         $_SESSION['sina']['access_token']['oauth_token_secret'] = $token['refresh_token'];
         $_SESSION['sina']['expire'] = time() + $token['expires_in'];
         $_SESSION['sina']['uid'] = $token['uid'];
         $_SESSION['open_platform_type'] = 'sina';
         return $token;
     } else {
         return false;
     }
 }
Example #22
0
    $respheaders = null;
    $data = http_request($url, $_SERVER['REQUEST_METHOD'], getallheaders(), $_POST, $respheaders);
    /**
	     * Send response headers to browser
	     */
    headers($respheaders, true);
    return $data;
}
/**
	 * Apply multiple headers
	 */
function headers($headers, $replace = true, $matchers = null)
{
    static $ignores = array('Transfer-Encoding', 'Location');
    if (!is_array($headers)) {
        $headers = explode("\n", $headers);
    }
    foreach ($headers as $h) {
        if (empty($h)) {
            continue;
        }
        if (is_callable($matchers) && !$matchers($h)) {
            continue;
        }
        $parts = explode(':', $h, 2);
        if (count($parts) >= 2) {
            list($name, $value) = $parts;
            if (in_array($name, $ignores)) {
                continue;
            }
Example #23
0
 /**
  * Initialise la session.
  */
 private function sessionStart()
 {
     $dbMgr = DbManager::getInstance();
     //Instancier le gestionnaire
     $db = $dbMgr->getConn('game');
     //Demander la connexion existante
     $db->beginTransaction();
     $this->sessId = $this->getCookieNo();
     if (empty($this->sessId)) {
         $this->sessId = $this->generateSessId();
         setcookie('sessId', $this->sessId, time() + 60 * 60 * 24 * 30);
         //Créer le cookie (expire après 30 jours)
     } elseif (!isset($_COOKIE['sessId'])) {
         fctErrorMSG("Votre navigateur ne supporte pas les cookies, vous devez les accepter pour ce site.");
         die;
     }
     $this->createOrExtendSession();
     $db->commit();
     //Effacer les sessions expirées
     $query = 'DELETE FROM ' . DB_PREFIX . 'session' . ' WHERE expiration < :expiration;';
     $prep = $db->prepare($query);
     $prep->bindValue(':expiration', CURRENT_TIME, PDO::PARAM_INT);
     $prep->executePlus($db, __FILE__, __LINE__);
     $prep->closeCursor();
     $prep = NULL;
 }
  public static function split($testname, $variations = array('control'), $user_id = null) {
    $current_variation = null;
    
    if (isset(self::$_splitTestData[$testname])) {
      // if the test variation was set earlier in the same request, return that
      $current_variation = self::$_splitTestData[$testname];
    } else {
      // allow querystring enabling of features
      if (isset($_REQUEST[$testname]) && in_array($_REQUEST[$testname], $variations)) {
        $current_variation = $_REQUEST[$testname];
      } else if (isset($_COOKIE['split_' . $testname]) && !empty($_COOKIE['split_' . $testname]) && in_array($_COOKIE['split_' . $testname], $variations)) {
        // we've got a variation already set from a previous request
        $current_variation = $_COOKIE['split_' . $testname];
      } else {
        // need to set a variation, use the user id if available
        if ($user_id != null && count($variations) > 0) {
          $current_variation = $variations[($user_id % count($variations))];
        } else {
          $current_variation = $variations[array_rand($variations)];
		    }
      }
      
      // the next two lines should only happen once per request.
      // set (or reset) a short-lived cookie so we don't have to worry about cleaning up old tests
      // when the test code is pulled out, the cookie will expire shortly thereafter
      setcookie('split_' . $testname, $current_variation, time() + (60 * 60 * 24 * 14), '/');
      
      // store the value in case it's needed later in this request
      self::$_splitTestData[$testname] = $current_variation;
    }
    
    // return the current variation
    return $current_variation;
  }
Example #25
0
 public static function set($name, $value, $expiry)
 {
     if (setcookie($name, $value, time() + $expiry)) {
         return true;
     }
     return false;
 }
Example #26
0
 public static function put($name, $value, $expiry)
 {
     if (setcookie($name, $value, time() + $expiry, '/')) {
         return TRUE;
     }
     return FALSE;
 }
/**
 * Set cookie
 *
 * Accepts six parameter, or you can submit an associative 
 * array in the first parameter containing all the values.
 *
 * @access	public
 * @param	mixed
 * @param	string	the value of the cookie
 * @param	string	the number of seconds until expiration
 * @param	string	the cookie domain.  Usually:  .yourdomain.com
 * @param	string	the cookie path
 * @param	string	the cookie prefix
 * @return	void
 */
function set_cookie($name = '', $value = '', $expire = '', $domain = '', $path = '/', $prefix = '')
{
    if (is_array($name)) {
        foreach (array('value', 'expire', 'domain', 'path', 'prefix', 'name') as $item) {
            if (isset($name[$item])) {
                ${$item} = $name[$item];
            }
        }
    }
    // Set the config file options
    $obj =& get_instance();
    if ($prefix == '' and $obj->config->item('cookie_prefix') != '') {
        $obj->config->item('cookie_prefix');
    }
    if ($domain == '' and $obj->config->item('cookie_domain') != '') {
        $obj->config->item('cookie_domain');
    }
    if ($prefix == '/' and $obj->config->item('cookie_path') != '/') {
        $obj->config->item('cookie_path');
    }
    if (!is_numeric($expire)) {
        $expire = time() - 86500;
    } else {
        if ($expire > 0) {
            $expire = time() + $expire;
        } else {
            $expire = 0;
        }
    }
    setcookie($prefix . $name, $value, $expire, $path, $domain, 0);
}
Example #28
0
 function display($dummy1 = false, $dummy2 = false)
 {
     $moduleId = JRequest::getInt('formid');
     if (empty($moduleId)) {
         return;
     }
     if (JRequest::getInt('interval') > 0) {
         setcookie('acymailingSubscriptionState', true, time() + JRequest::getInt('interval'), '/');
     }
     $db = JFactory::getDBO();
     $db->setQuery('SELECT * FROM #__modules WHERE id = ' . intval($moduleId) . ' AND `module` LIKE \'%acymailing%\' LIMIT 1');
     $module = $db->loadObject();
     if (empty($module)) {
         echo 'No module found';
         exit;
     }
     $module->user = substr($module->module, 0, 4) == 'mod_' ? 0 : 1;
     $module->name = $module->user ? $module->title : substr($module->module, 4);
     $module->style = null;
     $module->module = preg_replace('/[^A-Z0-9_\\.-]/i', '', $module->module);
     $params = array();
     if (JRequest::getInt('autofocus', 0)) {
         acymailing_loadMootools();
         $js = "\n\t\t\t\twindow = addEvent('load', function(){\n\t\t\t\t\tthis.focus();\n\t\t\t\t\tvar moduleInputs = document.getElementsByTagName('input');\n\t\t\t\t\tif(moduleInputs){\n\t\t\t\t\t\tvar i = 0;\n\t\t\t\t\t\twhile(moduleInputs[i].disabled == true){\n\t\t\t\t\t\t\ti++;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tif(moduleInputs[i]) moduleInputs[i].focus();\n\t\t\t\t\t}\n\t\t\t\t});";
         $doc = JFactory::getDocument();
         $doc->addScriptDeclaration($js);
     }
     echo JModuleHelper::renderModule($module, $params);
 }
Example #29
0
function adodb_session_regenerate_id()
{
    $conn =& ADODB_Session::_conn();
    if (!$conn) {
        return false;
    }
    $old_id = session_id();
    if (function_exists('session_regenerate_id')) {
        session_regenerate_id();
    } else {
        session_id(md5(uniqid(rand(), true)));
        $ck = session_get_cookie_params();
        setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
        //@session_start();
    }
    $new_id = session_id();
    $ok =& $conn->Execute('UPDATE ' . ADODB_Session::table() . ' SET sesskey=' . $conn->qstr($new_id) . ' WHERE sesskey=' . $conn->qstr($old_id));
    /* it is possible that the update statement fails due to a collision */
    if (!$ok) {
        session_id($old_id);
        if (empty($ck)) {
            $ck = session_get_cookie_params();
        }
        setcookie(session_name(), session_id(), false, $ck['path'], $ck['domain'], $ck['secure']);
        return false;
    }
    return true;
}
Example #30
-1
 /** Construction. This kills the current session if any started, and restart the given session */
 public function __construct($name, $cleanPreviousSession = false)
 {
     if (session_id() == "") {
         // Start a default session and save on the handler
         session_start();
         SessionSwitcher::$sessionArray[] = array('id' => session_id(), 'name' => session_name());
         session_write_close();
     }
     // Please note that there is no start here, session might be already started
     if (session_id() != "") {
         // There was a previous session
         if ($cleanPreviousSession) {
             if (isset($_COOKIE[session_name()])) {
                 setcookie(session_name(), '', time() - 42000, '/');
             }
             session_destroy();
         }
         // Close the session
         session_write_close();
         session_regenerate_id(false);
         $_SESSION = array();
         // Need to generate a new session id
     }
     session_id(md5(SessionSwitcher::$sessionArray[0]['id'] . $name));
     session_name($name);
     session_start();
 }