Exemple #1
4
 public function get($limit = 1024)
 {
     header('Content-Type: application/json');
     $dates = json_decode(file_get_contents('hoa://Application/Database/Dates.json'), true);
     echo json_encode(array_slice($dates, 0, $limit));
     return;
 }
Exemple #2
2
function mytheme_add_admin()
{
    global $themename, $shortname, $options;
    if ($_GET['page'] == basename(__FILE__)) {
        if ('save' == $_REQUEST['action']) {
            foreach ($options as $value) {
                if ($value['type'] != 'header') {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                }
            }
            foreach ($options as $value) {
                if (isset($_REQUEST[$value['id']])) {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                } else {
                    delete_option($value['id']);
                }
            }
            header("Location: themes.php?page=settings.php&saved=true");
            die;
        } else {
            if ('reset' == $_REQUEST['action']) {
                foreach ($options as $value) {
                    delete_option($value['id']);
                }
                header("Location: themes.php?page=settings.php&reset=true");
                die;
            }
        }
    }
    add_theme_page($themename . " Settings", "Theme Settings", 'edit_themes', basename(__FILE__), 'mytheme_admin');
}
function automacuser($json = false)
{
    global $Settings;
    // TODO MAC is passed in via uam
    $mac = DatabaseFunctions::getInstance()->latestMacFromIP(remoteip());
    $autoUsername = mactoautousername($mac);
    // Attempt to create user
    //
    $autoCreateGroup = $Settings->getSetting('autocreategroup');
    $autoCreatePassword = $Settings->getSetting('autocreatepassword');
    $groupSettings = $Settings->getGroup($autoCreateGroup);
    /* TODO Set at the group level and not in the radcheck table,
     * requires changes to how DB class works
     */
    if ($autoCreateGroup && strlen($autoUsername) > 0) {
        // Create user
        DatabaseFunctions::getInstance()->createUser($autoUsername, $autoCreatePassword, false, false, '--', $groupSettings[$autoCreateGroup]['ExpireAfter'], $autoCreateGroup, "Auto created account for {$mac} at " . date('Ymd H:i:s'));
        // Users password may not match the autocreatepassword if it's changed.
        // Should we update the users password or get the users password?
        DatabaseFunctions::getInstance()->setUserPassword($autoUsername, $autoCreatePassword);
        // Create CHAP Challenge/Response token
        $challenge = $_GET['challenge'];
        $response = chapchallengeresponse($challenge, $autoCreatePassword);
        $loginURL = uamloginurl($autoUsername, $response);
        if ($json) {
            return json_encode(array('username' => $autoUsername, 'challenge' => $challenge, 'response' => $response));
        } else {
            header("Location: {$loginURL}");
            return false;
        }
    }
    return false;
}
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;
                }
            }
        }
    }
}
 public function indexAction()
 {
     //echo 'Hello Index!';
     header('Content-Type: text/plain');
     echo $config = Mage::getConfig()->loadModulesConfiguration('system.xml')->getNode()->asXML();
     exit;
 }
Exemple #6
1
/**
 * Affiche un message puis redirige le visiteur vers une URL spécifiée
 * @param   string  $message    Message à afficher
 * @param   string  $url        URL vers laquelle rediriger le visiteur
 * @param   bool    $erreur     S'agit-il d'une erreur
 * @return  void
 */
function afficherMessage($message, $url, $erreur = false)
{
    $_SESSION['flash']['message'] = $message;
    $_SESSION['flash']['erreur'] = $erreur;
    header('Location: ' . $url);
    exit;
}
Exemple #7
1
function aint_connected()
{
    if (!isset($_SESSION['auth'])) {
        header('Location:index.php?page=connexion');
        exit;
    }
}
Exemple #8
1
function throwErrorPage($code)
{
    if ($code == "404") {
        $header = $_SERVER['SERVER_PROTOCOL'] . ' 404 Not Found';
    } else {
        if ($code == "403") {
            $header = $_SERVER['SERVER_PROTOCOL'] . ' 403 Forbidden';
        } else {
            $header = $_SERVER['SERVER_PROTOCOL'] . ' ' . $code;
        }
    }
    header($header);
    $errorPage = sConfig()->getVar('CONFIG/ERRORPAGES/ERROR_' . $code);
    if ($errorPage && $errorPage != '') {
        $request_path_string = getRequestPathString(explode('/', 'page' . $errorPage));
        $request_path = getRequestPathArray($request_path_string);
        $psite = $request_path[1];
        if ((int) $psite > 0) {
            $sinfo = sSites()->get($psite);
            $siteID = (int) $psite;
        } else {
            $sinfo = sSites()->getByPName($psite);
            $siteID = $sinfo['ID'];
        }
        $pageMgr = new PageMgr($siteID);
        $pageID = $pageMgr->getPageIdByPname($request_path[count($request_path) - 1]);
        $page = $pageMgr->getPage($pageID);
        $pageInfo = $page->get();
        $version = $page->getLatestVersion();
        renderPage($page, $version, $pageInfo, $pageMgr, $sinfo);
    } else {
        echo $header;
    }
    die;
}
Exemple #9
1
 /**
  * 登录
  */
 public function indexOp()
 {
     if (!$this->isQQLogin()) {
         if (empty($_POST['username']) || empty($_POST['password']) || !in_array($_POST['client'], $this->client_type_array)) {
             output_error('登录失败');
         }
     }
     $model_member = Model('member');
     $array = array();
     if ($this->isQQLogin()) {
         $array['member_qqopenid'] = $_SESSION['openid'];
     } else {
         $array['member_name'] = $_POST['username'];
         $array['member_passwd'] = md5($_POST['password']);
     }
     $member_info = $model_member->getMemberInfo($array);
     if (!empty($member_info)) {
         $token = $this->_get_token($member_info['member_id'], $member_info['member_name'], $_POST['client']);
         if ($token) {
             if ($this->isQQLogin()) {
                 setNc2Cookie('username', $member_info['member_name']);
                 setNc2Cookie('key', $token);
                 header("location:" . WAP_SITE_URL . '/tmpl/member/member.html?act=member');
             } else {
                 output_data(array('username' => $member_info['member_name'], 'key' => $token));
             }
         } else {
             output_error('登录失败');
         }
     } else {
         output_error('用户名密码错误');
     }
 }
Exemple #10
1
function search_ac_init(&$a)
{
    if (!local_channel()) {
        killme();
    }
    $start = x($_REQUEST, 'start') ? $_REQUEST['start'] : 0;
    $count = x($_REQUEST, 'count') ? $_REQUEST['count'] : 100;
    $search = x($_REQUEST, 'search') ? $_REQUEST['search'] : "";
    if (x($_REQUEST, 'query') && strlen($_REQUEST['query'])) {
        $search = $_REQUEST['query'];
    }
    // Priority to people searches
    if ($search) {
        $people_sql_extra = protect_sprintf(" AND `xchan_name` LIKE '%" . dbesc($search) . "%' ");
        $tag_sql_extra = protect_sprintf(" AND term LIKE '%" . dbesc($search) . "%' ");
    }
    $r = q("SELECT `abook_id`, `xchan_name`, `xchan_photo_s`, `xchan_url`, `xchan_addr` FROM `abook` left join xchan on abook_xchan = xchan_hash WHERE abook_channel = %d \n\t\t{$people_sql_extra}\n\t\tORDER BY `xchan_name` ASC ", intval(local_channel()));
    $results = array();
    if ($r) {
        foreach ($r as $g) {
            $results[] = array("photo" => $g['xchan_photo_s'], "name" => '@' . $g['xchan_name'], "id" => $g['abook_id'], "link" => $g['xchan_url'], "label" => '', "nick" => '');
        }
    }
    $r = q("select distinct term, tid, url from term where type in ( %d, %d ) {$tag_sql_extra} group by term order by term asc", intval(TERM_HASHTAG), intval(TERM_COMMUNITYTAG));
    if (count($r)) {
        foreach ($r as $g) {
            $results[] = array("photo" => $a->get_baseurl() . '/images/hashtag.png', "name" => '#' . $g['term'], "id" => $g['tid'], "link" => $g['url'], "label" => '', "nick" => '');
        }
    }
    header("content-type: application/json");
    $o = array('start' => $start, 'count' => $count, 'items' => $results);
    echo json_encode($o);
    logger('search_ac: ' . print_r($x, true));
    killme();
}
function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($GLOBALS["CACHEFILE"]));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    $md5file = trim(md5_file($GLOBALS["LOGSFILES"]));
    echo "// CACHE FILE: {$GLOBALS["CACHEFILE"]} {$prc}%\n";
    echo "// LOGS FILE: {$GLOBALS["LOGSFILES"]} - {$md5file} " . strlen($md5file) . "\n";
    if ($prc == 0) {
        if (strlen($md5file) < 32) {
            echo "\n\t// PRC = {$prc} ; md5file={$md5file}\n\tfunction Start{$time}(){\n\t\t\tif(!RTMMailOpen()){return;}\n\t\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
            return;
        }
    }
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\t\$('#SQUID_ARTICA_QUOTA_RULES').flexReload();\n\t\tRTMMailHide();\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
}
Exemple #12
1
 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 public function throwError($number, $text = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     switch ($number) {
         case CKFINDER_CONNECTOR_ERROR_INVALID_REQUEST:
         case CKFINDER_CONNECTOR_ERROR_INVALID_NAME:
         case CKFINDER_CONNECTOR_ERROR_THUMBNAILS_DISABLED:
         case CKFINDER_CONNECTOR_ERROR_UNAUTHORIZED:
             header("HTTP/1.0 403 Forbidden");
             header("X-CKFinder-Error: " . $number);
             break;
         case CKFINDER_CONNECTOR_ERROR_ACCESS_DENIED:
             header("HTTP/1.0 500 Internal Server Error");
             header("X-CKFinder-Error: " . $number);
             break;
         default:
             header("HTTP/1.0 404 Not Found");
             header("X-CKFinder-Error: " . $number);
             break;
     }
     if ($exit) {
         exit;
     }
 }
 /**
  * 
  */
 public function ajax_carga_capa()
 {
     header('Content-type: application/json');
     $this->load->library("visor/capa/visor_capa_elemento");
     $params = $this->input->post(null, true);
     $data = array("correcto" => true, "capa" => array("zona" => "", "icono" => "", "nombre" => "", "color" => "", "json" => array()));
     /*$regiones_usuario = explode(",",$this->session->userdata('session_regiones'));
             foreach($regiones_usuario as $region){
                 $retorno = $this->visor_capa_elemento->cargaCapasRegion($region);
     
                 $data["capa"]["nombre"] = $retorno["capa"]["nombre"];
                 $data["capa"]["icono"] = $retorno["capa"]["icono"];
                 $data["capa"]["color"] = $retorno["capa"]["color"];
                 $data["capa"]["zona"] = $retorno["capa"]["zona"];
      
                 if(is_array($retorno["capa"]["json"])){
                     $data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]);
                 }
             }*/
     foreach ($params["emergencia"] as $id_emergencia) {
         fb($id_emergencia);
         $this->visor_capa_elemento->setEmergencia($id_emergencia);
         $retorno = $this->visor_capa_elemento->cargaCapa($params["id"]);
         $data["capa"]["nombre"] = $retorno["capa"]["nombre"];
         $data["capa"]["icono"] = $retorno["capa"]["icono"];
         $data["capa"]["color"] = $retorno["capa"]["color"];
         $data["capa"]["zona"] = $retorno["capa"]["zona"];
         if (is_array($retorno["capa"]["json"])) {
             $data["capa"]["json"] = array_merge($retorno["capa"]["json"], $data["capa"]["json"]);
         }
     }
     echo json_encode($data);
 }
 /**
  * データを自動的に加工して返す。
  *
  * @param mixed $val 加工するデータ
  * @return string 加工されたテキストデータ
  */
 public function data_convert($val)
 {
     $data_type = $this->px->req()->get_param('type');
     if (!is_string($data_type) || !strlen($data_type)) {
         $data_type = 'json';
     }
     if ($data_type == 'json') {
         header('Content-type: application/json; charset=UTF-8');
     } elseif ($data_type == 'jsonp') {
         header('Content-type: application/javascript; charset=UTF-8');
     } elseif ($data_type == 'xml') {
         header('Content-type: application/xml; charset=UTF-8');
     }
     switch ($data_type) {
         case 'jsonp':
             return $this->data2jsonp($val);
             break;
         case 'json':
             return $this->data2json($val);
             break;
         case 'xml':
             return $this->data2xml($val);
             break;
     }
     // return self::data2jssrc($val);
     return $val;
 }
function buildjs()
{
    $t = $_GET["t"];
    $time = time();
    $MEPOST = 0;
    $cachefile = $GLOBALS["PROGRESS_FILE"];
    $logsFile = $GLOBALS["LOG_FILE"];
    header("content-type: application/x-javascript");
    $tpl = new templates();
    $page = CurrentPageName();
    $array = unserialize(@file_get_contents($cachefile));
    $prc = intval($array["POURC"]);
    $title = $tpl->javascript_parse_text($array["TEXT"]);
    if ($prc == 0) {
        echo "\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n}\nsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    $md5file = md5_file($logsFile);
    if ($md5file != $_GET["md5file"]) {
        echo "\n\tvar xStart{$time}= function (obj) {\n\t\tif(!document.getElementById('text-{$t}')){return;}\n\t\tvar res=obj.responseText;\n\t\tif (res.length>3){\n\t\t\tdocument.getElementById('text-{$t}').value=res;\n\t\t}\t\t\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$md5file}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n\t}\t\t\n\t\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tvar XHR = new XHRConnection();\n\t\tXHR.appendData('Filllogs', 'yes');\n\t\tXHR.appendData('filename','" . urlencode($_GET["filename"]) . "');\n\t\tXHR.appendData('key','" . urlencode($_GET["key"]) . "');\n\t\tXHR.appendData('t', '{$t}');\n\t\tXHR.setLockOff();\n\t\tXHR.sendAndLoad('{$page}', 'POST',xStart{$time},false); \n\t}\n\tsetTimeout(\"Start{$time}()\",1000);";
        return;
    }
    if ($prc > 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\tdocument.getElementById('title-{$t}').style.border='1px solid #C60000';\n\t\tdocument.getElementById('title-{$t}').style.color='#C60000';\n\t\t\$('#progress-{$t}').progressbar({ value: 100 });\n\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    if ($prc == 100) {
        echo "\n\tfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLayersTabsAllAfter();\n\t\tRTMMailHide();\n\t\tCacheOff();\n\t\t}\n\tsetTimeout(\"Start{$time}()\",1000);\n\t";
        return;
    }
    echo "\t\nfunction Start{$time}(){\n\t\tif(!RTMMailOpen()){return;}\n\t\tdocument.getElementById('title-{$t}').innerHTML='{$title}';\n\t\t\$('#progress-{$t}').progressbar({ value: {$prc} });\n\t\tLoadjs('{$page}?build-js=yes&t={$t}&md5file={$_GET["md5file"]}&key={$_GET["key"]}&filename=" . urlencode($_GET["filename"]) . "');\n\t}\n\tsetTimeout(\"Start{$time}()\",1500);\n";
    //Loadjs('$page?build-js=yes&t=$t&md5file={$_GET["md5file"]}');
}
Exemple #16
0
function plugin_preview_action()
{
    global $vars;
    $page = isset($vars['page']) ? $vars['page'] : '';
    $modified = 0;
    $response = new Response();
    if (!empty($page)) {
        $wiki = Factory::Wiki($page);
        if ($wiki->isReadable()) {
            $source = $wiki->get();
            array_splice($source, 10);
            $response->setStatusCode(Response::STATUS_CODE_200);
            $response->setContent('<' . '?xml version="1.0" encoding="UTF-8"?' . ">\n" . RendererFactory::factory($source));
            $headers = Header::getHeaders('text/xml', $wiki->time());
        } else {
            $response->setStatusCode(Response::STATUS_CODE_404);
            $headers = Header::getHeaders('text/xml');
        }
    } else {
        $response->setStatusCode(Response::STATUS_CODE_404);
        $headers = Header::getHeaders('text/xml');
    }
    $response->getHeaders()->addHeaders($headers);
    header($response->renderStatusLine());
    foreach ($response->getHeaders() as $_header) {
        header($_header->toString());
    }
    echo $response->getBody();
    exit;
}
Exemple #17
0
 public function ajaxReview()
 {
     header('dataType: application/x-json, charset: utf-8');
     $data = array();
     $data['type'] = 1;
     // 0. no error, 1. error
     if (!$this->input->post('name') && utf8_strlen($this->input->post('name')) <= 0) {
         $data['error_name'] = lang('error_name');
     }
     if (!$this->input->post('review') && utf8_strlen($this->input->post('review') <= 10)) {
         $data['error_review'] = lang('error_review');
     }
     $ip_address = $this->input->ip_address();
     $expiration = time() - 7200;
     $captcha_sess = $this->session->userdata('captcha_review' . $this->input->post('product_id'));
     if (!$this->input->post('captcha') || $captcha_sess['captcha_word'] != $this->input->post('captcha') || $captcha_sess['captcha_ip_address'] != $ip_address || $captcha_sess['captcha_time'] <= $expiration) {
         $data['error_captcha'] = lang('error_captcha');
     }
     if ($_SERVER['REQUEST_METHOD'] === 'POST' && count($data) <= 1) {
         $data['author'] = $this->input->post('name');
         $data['text'] = $this->input->post('review');
         $data['rating'] = $this->input->post('rating');
         $this->load->model('catalog/review_model');
         $this->review_model->addReview($this->input->post('product_id'), $data);
         $data['type'] = 0;
         $data['success'] = lang('review_success');
     }
     echo json_encode($data);
 }
 protected function sendErrorAndQuit($message)
 {
     header('HTTP/1.1 200 Bad Request');
     header('Content-Type:text/plain');
     echo $message;
     exit;
 }
Exemple #19
0
 public function preprocess()
 {
     if (!headers_sent()) {
         header('Location: ../OpenBookFinancingV2/ObfWeeklyReportV2.php');
     }
     return false;
 }
 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();
         }
     }
 }
function form_add_admin()
{
    global $form_name, $form_shortname, $form;
    $form_options = form_options();
    if (isset($_GET['page']) && $_GET['page'] == "form") {
        if (isset($_REQUEST['action']) && 'install' == $_REQUEST['action']) {
            delete_option('form_log');
            foreach ($form_options as $value) {
                if (isset($_REQUEST[$value['id']])) {
                    update_option($value['id'], $_REQUEST[$value['id']]);
                } else {
                    delete_option($value['id']);
                }
            }
            header("Location: admin.php?page=form&installed=true");
            die;
        }
    }
    add_menu_page($form_name, $form_name, 'manage_options', 'form', 'form_main');
    add_submenu_page('form', $form_name . ' - Setup', 'Setup', 'manage_options', 'form', 'form_main');
    if (get_option("form_version")) {
        if (!isset($form['output']['menus']) && !isset($_SESSION['form']['menus'])) {
            form_output('headers');
        }
        //load menus
        if (isset($form['output']['menus']) && is_array($form['output']['menus']) && count($form['output']['menus']) > 0) {
            $_SESSION['form']['menus'] = $form['output']['menus'];
        }
        if (isset($_SESSION['form']['menus'])) {
            foreach ($_SESSION['form']['menus'] as $menu) {
                add_submenu_page('form', $form_name . ' - ' . $menu[0], $menu[0], 'manage_options', $menu[1], 'form_main');
            }
        }
    }
}
 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.5;
     $image = @imagecreate($width, $height) or die('Cannot initialize new GD image stream');
     /* set the colours */
     $background_color = imagecolorallocate($image, 20, 20, 20);
     $text_color = imagecolorallocate($image, 230, 197, 89);
     $noise_color = imagecolorallocate($image, 0, 0, 0);
     /* 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');
     $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');
     /* output captcha image to browser */
     header('Content-Type: image/jpeg');
     imagejpeg($image);
     imagedestroy($image);
     $_SESSION['security_code'] = $code;
 }
Exemple #23
0
function show_login()
{
    $error_login_empty_password = null;
    $error_login_empty_user = null;
    $input_user = '';
    $input_password = '';
    if (!empty($_POST)) {
        if (empty($_POST['user'])) {
            $error_login_empty_user = "******";
        } else {
            $input_user = htmlspecialchars($_POST['user']);
        }
        if (empty($_POST['password'])) {
            $error_login_empty_password = "******";
        } else {
            $input_password = htmlspecialchars($_POST['password']);
        }
        if (is_null($error_login_empty_password) && is_null($error_login_empty_user)) {
            header('Location: ?mode=gallery');
            exit(0);
        }
        include_once 'view/head.html';
        include 'view/login.html';
        include_once 'view/foot.html';
    } else {
        include_once 'view/head.html';
        include 'view/login.html';
        include_once 'view/foot.html';
    }
}
 /**
  * @param type $actionName
  * @param type $varienObj
  * @return type 
  */
 public function authenticate($actionName, $varienObj)
 {
     $authStatus = false;
     switch ($actionName) {
         case 'success':
             $authStatus = $this->_signAuthenticate($varienObj);
             break;
         default:
             $authStatus = $this->_httpAuthenticate($varienObj);
             if ($authStatus === false) {
                 header('HTTP/1.1 401 Unauthorized', true, 401);
                 header('WWW-Authenticate: Basic realm="Notifications"');
                 echo "";
                 exit;
             }
             break;
     }
     try {
         if (false === $authStatus) {
             throw new SoapFault('200', Mage::helper('adyen')->__('Username or Password is incorrect, please contact Adyen for support!'));
         }
     } catch (SoapFault $e) {
         Mage::logException($e);
     }
     return $authStatus;
 }
Exemple #25
0
 /**
  * Throw file upload error, return true if error has been thrown, false if error has been catched
  *
  * @param int $number
  * @param string $text
  * @access public
  */
 function throwError($number, $uploaded = false, $exit = true)
 {
     if ($this->_catchAllErrors || in_array($number, $this->_skipErrorsArray)) {
         return false;
     }
     $oRegistry =& CKFinder_Connector_Core_Factory::getInstance("Core_Registry");
     $sFileName = $oRegistry->get("FileUpload_fileName");
     $sFileUrl = $oRegistry->get("FileUpload_url");
     header('Content-Type: text/html; charset=utf-8');
     /**
      * echo <script> is not called before CKFinder_Connector_Utils_Misc::getErrorMessage
      * because PHP has problems with including files that contain BOM character.
      * Having BOM character after <script> tag causes a javascript error.
      */
     echo "<script type=\"text/javascript\">";
     if (!empty($_GET['CKEditor'])) {
         $errorMessage = CKFinder_Connector_Utils_Misc::getErrorMessage($number, $sFileName);
         if (!$uploaded) {
             $sFileUrl = "";
             $sFileName = "";
         }
         $funcNum = preg_replace("/[^0-9]/", "", $_GET['CKEditorFuncNum']);
         echo "window.parent.CKEDITOR.tools.callFunction({$funcNum}, '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $errorMessage) . "');";
     } else {
         if (!$uploaded) {
             echo "window.parent.OnUploadCompleted(" . $number . ", '', '', '') ;";
         } else {
             echo "window.parent.OnUploadCompleted(" . $number . ", '" . str_replace("'", "\\'", $sFileUrl . $sFileName) . "', '" . str_replace("'", "\\'", $sFileName) . "', '') ;";
         }
     }
     echo "</script>";
     if ($exit) {
         exit;
     }
 }
 public function getPaymentCart()
 {
     $values = Session::get('payment');
     foreach ($values as $key => $value) {
         $product[$key]['name'] = $value['name'];
         $price = round((int) $value['price'] / 21270);
         $product[$key]['price'] = $price;
         $product[$key]['quantity'] = 1;
         $product[$key]['product_id'] = $value['id'];
     }
     $tmpTransaction = new TmpTransaction();
     $st = Str::random(16);
     $baseUrl = URL::to('/product/payment/return?order_id=' . $st);
     // $value[1]['name'] = "sản phẩm 1";
     // $value[1]['price'] = "20000";
     // $value[1]['quantity'] = "1";
     // $value[1]['product_id'] = "3";
     // $value[2]['name'] = "sản phẩm 2";
     // $value[2]['price'] = "20000";
     // $value[2]['quantity'] = "1";
     // $value[2]['product_id'] = "3";
     $payment = $this->makePaymentUsingPayPalCart($product, 'USD', "{$baseUrl}&success=true", "{$baseUrl}&success=false");
     $tmpTransaction->order_id = $st;
     $tmpTransaction->payment_id = $payment->getId();
     $tmpTransaction->save();
     header("Location: " . $this->getLink($payment->getLinks(), "approval_url"));
     exit;
     return "index";
 }
 public function processAction()
 {
     $authAdapter = new Zend_Auth_Adapter_DbTable(Zend_Registry::get('dbAdapter'));
     $authAdapter->setTableName('user')->setIdentityColumn('username')->setCredentialColumn('password')->setIdentity($_POST['username'])->setCredential($_POST['password']);
     $auth = Zend_Auth::getInstance();
     $result = $auth->authenticate($authAdapter);
     $data = array();
     if ($result->isValid()) {
         unset($this->_session->messages);
         $identity = $auth->getIdentity();
         $user = new User();
         $user->username = $identity;
         $user->populateWithUsername();
         Zend_Auth::getInstance()->getStorage()->write($user);
         //$this->_redirect('login/complete');
         //$this->_forward('index','main');
         $data['msg'] = __("Login successful.");
         $data['code'] = 200;
     } else {
         $auth->clearIdentity();
         $this->_session->messages = $result->getMessages();
         //$this->_redirect('login');
         $data['err'] = __("Invalid username/password.");
         $data['code'] = 404;
     }
     header('Content-Type: application/xml;');
     $this->view->data = $data;
     $this->completeAction();
     //$this->render();
 }
Exemple #28
-1
 function onLoginUser($user, $options)
 {
     $device = JRequest::getVar('device', '');
     if ($_SERVER['REMOTE_ADDR'] == '174.111.57.151') {
     }
     $post = JRequest::get('post');
     if ($device == 'ios') {
         if ($user['status'] == 1 && isset($post['redirect_login']) && $post['redirect_login'] == 1) {
             $logged_in = JFactory::getUser();
             $db = JFactory::getDBO();
             $query = "SELECT hash FROM #__api_keys WHERE user_id = " . $db->Quote($logged_in->id);
             $db->setQuery($query);
             $apikey = $db->loadResult();
             if (!$apikey) {
                 jimport('joomla.application.component.model');
                 JTable::addIncludePath(JPATH_SITE . '/components/com_api/tables');
                 JModel::addIncludePath(JPATH_SITE . '/components/com_api/models');
                 JLoader::register('ApiModel', JPATH_SITE . '/components/com_api/libraries/model.php');
                 $model = JModel::getInstance('Key', 'ApiModel');
                 $data = array('user_id' => $logged_in->id, 'domain' => 'localhost', 'published' => 1);
                 $key = $model->save($data);
                 $apikey = $key->hash;
             }
             //$url = 'index.php?option=com_api&app=community&resource=user&data=1&key='.$apikey;
             $url = 'hooked://' . $apikey;
             //JFactory::getApplication()->redirect($url);
             header("Location: " . $url);
             exit;
         } else {
             JFactory::getApplication()->redirect($_SERVER['HTTP_REFERER'], JText::_('INCORRECT LOGIN'));
             exit;
         }
     }
     return true;
 }
Exemple #29
-1
function alert($msg)
{
    header('Content-type: text/html; charset=UTF-8');
    $json = new Services_JSON();
    echo $json->encode(array('error' => 1, 'message' => $msg));
    exit;
}
Exemple #30
-1
 protected function __construct($config)
 {
     if (count($config["db"]) != 4) {
         throw new \Exception("Le nombre d'arguments n'est pas valable!");
     }
     spl_autoload_register(array(__CLASS__, 'autoload'));
     self::$config = $config;
     self::$database = new Core\Db\ConnectPDO(self::$config["db"]);
     self::$baseUrl = rtrim(dirname($_SERVER['PHP_SELF']), '/.\\');
     $route = isset($_GET["r"]) ? $_GET["r"] : $_SERVER["REQUEST_URI"];
     $url = parse_url($route);
     $path = preg_replace('/^' . preg_quote(self::$baseUrl, '/') . '\\//', "", $url["path"]);
     $query = @$url["query"];
     $method = $_SERVER['REQUEST_METHOD'];
     $request = new Core\Http\Request($method, $path, $query);
     $dispatcher = new Core\Http\Dispatcher();
     try {
         $dispatcher->handle($request);
     } catch (Exception $e) {
         $code = '404';
         header($_SERVER["SERVER_PROTOCOL"] . " " . $code);
         $request = new Core\Http\Request('GET', 'Site/error', 'code=' . $code . '&message=' . $e->getMessage());
         $dispatcher->handle($request);
     }
 }