function perform()
 {
     WorkbenchContext::get()->getApexConnection()->setDebugLevels($this->logCategory, $this->logCategoryLevel);
     $executeAnonymousResultWithDebugLog = WorkbenchContext::get()->getApexConnection()->executeAnonymous($this->executeAnonymousBlock);
     ob_start();
     if ($executeAnonymousResultWithDebugLog->executeAnonymousResult->success) {
         if (isset($executeAnonymousResultWithDebugLog->debugLog) && $executeAnonymousResultWithDebugLog->debugLog != "") {
             print "<pre>" . addLinksToIds(htmlspecialchars($executeAnonymousResultWithDebugLog->debugLog, ENT_QUOTES)) . '</pre>';
         } else {
             displayInfo("Execution was successful, but returned no results. Confirm log category and level.");
         }
     } else {
         $error = null;
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->compileProblem)) {
             $error .= "COMPILE ERROR: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->compileProblem;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionMessage)) {
             $error .= "\nEXCEPTION: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionMessage;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionStackTrace)) {
             $error .= "\nSTACKTRACE: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->exceptionStackTrace;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->line)) {
             $error .= "\nLINE: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->line;
         }
         if (isset($executeAnonymousResultWithDebugLog->executeAnonymousResult->column)) {
             $error .= " COLUMN: " . $executeAnonymousResultWithDebugLog->executeAnonymousResult->column;
         }
         displayError($error);
         print '<pre style="color: red;">' . addLinksToIds(htmlspecialchars($executeAnonymousResultWithDebugLog->debugLog, ENT_QUOTES)) . '</pre>';
     }
     $result = ob_get_contents();
     ob_end_clean();
     return $result;
 }
예제 #2
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Create attribute request object
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    // Usage: make($type_uri, $count=1, $required=false, $alias=null)
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname');
    $attribute[] = Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname');
    // Create AX fetch request
    $ax = new Auth_OpenID_AX_FetchRequest();
    // Add attributes to AX fetch request
    foreach ($attribute as $attr) {
        $ax->add($attr);
    }
    $auth_request->addExtension($ax);
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
예제 #3
0
파일: view.php 프로젝트: emteg/beamer
function modulAusgeben($modul, $design, $naechstePosition)
{
    global $flipDot;
    $smarty = new Smarty();
    $templateDir = "./designs/" . $design . "/";
    $smarty->setTemplateDir($templateDir);
    $smarty->assign("modulName", $modul->getName());
    $smarty->assign("naechstePosition", -1);
    if ($modul->getTemplateVar("fontZoom") != 100) {
        $zoom = "&fontZoom=" . $modul->getTemplateVar("fontZoom");
    } else {
        $zoom = "";
    }
    $smarty->assign("url", $_SERVER["PHP_SELF"] . "?modul=" . $modul->getName() . $zoom);
    foreach ($modul->getTemplateVars() as $key => $var) {
        $smarty->assign($key, $var);
    }
    if ($flipDot) {
        echo $modul->getFlipDotOutput();
    } else {
        try {
            $smarty->display(strtolower($modul->getName()) . ".tpl");
        } catch (Exception $e) {
            displayError($e, $modul, $templateDir);
        }
    }
}
예제 #4
0
 public function run_default()
 {
     global $geo_cities, $geo_countries;
     $formData = $_REQUEST["formData"];
     $formData["country_id"] = (int) $formData["country_id"];
     $formData["city_id"] = (int) $formData["city_id"];
     $Q = new UsersExec();
     $Q->limit = $this->app->getCONFIG("users_ipp");
     $Q->start = (int) $_REQUEST["start"];
     if ($formData["sex"]) {
         $Q->where("sex", $formData["sex"]);
     }
     if ($formData["country_id"]) {
         $Q->where("country_id", $formData["country_id"]);
     }
     if ($formData["city_id"]) {
         $Q->where("city_id", $formData["city_id"]);
     }
     if ($formData["age_from"]) {
         $Q->where("age_from", $formData["age_from"]);
     }
     if ($formData["age_to"]) {
         $Q->where("age_to", $formData["age_to"]);
     }
     if ($formData["sex"] || $formData["country_id"] || $formData["city_id"] || $formData["age_from"] || $formData["age_to"]) {
         $title .= "<!--[Sex_familiar_" . (int) $formData["sex"] . "]--> ";
         if ($formData["city_id"]) {
             $title .= "<!--[in]--> " . ($geo_cities[$formData["city_id"]]["name2"] ? $geo_cities[$formData["city_id"]]["name2"] : $geo_cities[$formData["city_id"]]["name"]) . " ";
         } elseif ($formData["country_id"]) {
             $title .= "<!--[in]--> " . $geo_countries[$formData["country_id"]]["name2"] . " ";
         }
         if ($formData["age_from"]) {
             $title .= "<!--[s]--> " . $formData["age_from"];
         }
         if ($formData["age_to"]) {
             $title .= "<!--[do]--> " . $formData["age_to"];
         }
         if ($formData["age_from"] || $formData["age_to"]) {
             $title .= " <!--[let]--> ";
         }
     }
     $link_ar = array();
     $link_ar["CID"] = "main";
     $link_ar["formData[sex]"] = $formData["sex"];
     $link_ar["formData[country_id]"] = $formData["country_id"];
     $link_ar["formData[city_id]"] = $formDat["city_id"];
     $link_ar["formData[age_from]"] = $formData["age_from"];
     $link_ar["formData[age_to]"] = $formData["age_to"];
     $data = $Q->f();
     if ($rws = $data["data"]) {
         foreach ($rws as $rw) {
             $tmp .= $this->displayUser($rw);
         }
     } else {
         $tmp .= displayError("<!--[People_not_found]-->", 0, 1);
     }
     $out = "\n\t\t\t<table class='wide'><tr>\n\t\t\t\t<td class='top'>\n\t\t\t\t\t" . ($title ? "<h1>" . $title . "</h1>" : "") . "\n\t\t\t\t\t<div class='mainpage_photos'>" . $tmp . "</div>\n\t\t\t\t\t" . makePages($this->app->makeLink($link_ar), $Q->start, $Q->limit, $data["data_cnt"]) . "\n\t\t\t\t</td>\n\t\t\t\t<td class='top' style='width:230px;'>" . $this->displayFilter() . "</td>\n\t\t\t</tr></table>\n\t\t";
     $this->data["title"] = $title;
     $this->data["content"] = $out;
 }
예제 #5
0
function displayError(Exception $error)
{
    echo $error->getMessage() . "\n";
    if ($error->getPrevious()) {
        echo ' Underlying error: ';
        displayError($error->getPrevious());
    }
}
예제 #6
0
파일: errorhandler.php 프로젝트: qzio/tinly
function errorHandler($errno, $errstr, $errfile, $errline)
{
    $errortype = array(E_ERROR => "Error", E_WARNING => "Warning", E_PARSE => "Parsing Error", E_NOTICE => "Notice", E_CORE_ERROR => "Core Error", E_CORE_WARNING => "Core Warning", E_COMPILE_ERROR => "Compile Error", E_COMPILE_WARNING => "Compile Warning", E_USER_ERROR => "User Error", E_USER_WARNING => "User Warning", E_USER_NOTICE => "User Notice", E_STRICT => "Runtime Notice");
    // if a function etc, where called with an prefix of @ do nothing
    if (CONFIG::$DEBUG !== false) {
        displayError($errortype[$errno] . ', ' . $errstr, $errfile, $errline);
    }
}
function verify_leader($teamID, $playerID)
{
    $p = mysql_query("SELECT * FROM team_members WHERE fk_team='{$teamID}' AND fk_player='{$playerID}'");
    $r = mysql_fetch_array($p);
    if ($r[level] < 100) {
        displayError("You are not the team leader and are not allowed to challenge other teams.", "mainmenu.php");
        exit;
    }
}
예제 #8
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    $return_to = getReturnTo();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    // add AX request
    if ($_GET['ax'] == 'true') {
        $ax_request = new Auth_OpenID_AX_FetchRequest();
        global $ax_data;
        foreach ($ax_data as $ax_key => $ax_data_ns) {
            // set AX params
            if ($_GET['ax_' . $ax_key] == 'true') {
                $ax_request->add(new Auth_OpenID_AX_AttrInfo($ax_data_ns, 1, true, $ax_key));
            }
        }
        // add extension
        if ($ax_request) {
            $auth_request->addExtension($ax_request);
        }
    }
    // add UI extension request
    if ($_GET['ui'] == 'true') {
        $UI_request = new OpenID_UI_Request();
        // set icon
        if ($_GET['icon'] == 'true') {
            $UI_request->setIcon();
        }
        // set lang
        if ($_GET['lang'] == 'true' && $_GET['pref_lang']) {
            $UI_request->setLang($_GET['pref_lang']);
        }
        // set popup
        if ($_GET['popup'] == 'true') {
            $UI_request->setPopup();
            $return_to .= "popup=true";
        }
        $auth_request->addExtension($UI_request);
    } else {
        if ($_GET['callback'] == "ax") {
            $return_to .= "callback=ax";
        }
    }
    $redirect_url = $auth_request->redirectURL(getTrustRoot(), $return_to);
    if (Auth_OpenID::isFailure($redirect_url)) {
        displayError("Could not redirect to server: " . $redirect_url->message);
    } else {
        // Send redirect.
        header("Location: " . $redirect_url);
    }
}
예제 #9
0
 public function run_overall()
 {
     $msg = $this->app->CHDATA[$this->app->CID]["msg"];
     $type = $this->app->CHDATA[$this->app->CID]["type"];
     if ($type == "signin_required") {
         $tmp = "<strong><!--[Error]-->:</strong> " . $msg . "<br /><a href='" . $this->app->makeLink(array("CID" => "profile", "page" => "signin"), null, 1) . "'><!--[Signin]--></a>&nbsp;|&nbsp;<a href='" . $this->app->makeLink(array("CID" => "profile", "page" => "signup"), null, 1) . "'><!--[Signup]--></a>";
     } else {
         $tmp = "<strong><!--[Error]-->:</strong> " . $msg . "<br /><a href='" . $this->app->makeLink("CID", "main", 1) . "'><!--[Goto_mainpage]--></a>";
     }
     $this->data["content"] = displayError($tmp, 0, 1);
 }
예제 #10
0
function mysqlQuery($query)
{
    try {
        $response = $GLOBALS['MYSQL']->query($query);
    } catch (Exception $e) {
        displayError(array('Query' => $query, 'Exception' => $e->getMessage(), 'Error' => $GLOBALS['MYSQL']->error), true, 'MySQL Exception');
        exit;
    }
    displayError(array('Query' => $query, 'Response' => $response ? 'True' : mysqlError()), true, 'MySQL Query', null, DEBUGGING_MYSQL);
    return $response;
}
function multiplyForLoop($a, $b)
{
    if (validateNumbers($a, $b)) {
        $sum = 0;
        for ($i = 0; $i < $b; $i++) {
            $sum = $sum + $a;
        }
        return $sum;
    } else {
        return displayError($a, $b, 'multiply');
    }
}
예제 #12
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("认证错误,不是有效的OpenID。");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('gender'));
    //'nickname','fullname', 'email', 'dob','gender','postcode','country','language','timezone'
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    /*NOTE:目前还很少有网站要用到PAPE这个功能
       $policy_uris = $_GET['policies'];
    
        $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
        if ($pape_request) {
            $auth_request->addExtension($pape_request);
        }
    	*/
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("不能跳转到: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("不能跳转到: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
    private function result()
    {
        ob_start();
        if ($this->c->errors != null) {
            displayError($this->c->errors);
            ?>
<p/><?php 
        }
        ?>
        <div style="float: left;">
            <?php 
        if (trim($this->c->instResponse) != "") {
            ?>
            <a href="javascript:ddtreemenu.flatten('responseList', 'expand')">Expand All</a> |
            <a href="javascript:ddtreemenu.flatten('responseList', 'contact')">Collapse All</a> |
            <a id="codeViewPortToggler" href="javascript:toggleCodeViewPort();">Show Raw Response</a>

            <div id="responseListContainer" class="results"></div>

            <script type='text/javascript' class='evalable'>convert(<?php 
            echo $this->c->instResponse;
            ?>
);</script>
            <?php 
        }
        ?>
        </div>

        <?php 
        if (isset($this->c->rawResponse)) {
            ?>
        <div id="codeViewPortContainer" style="display: <?php 
            echo trim($this->c->instResponse) != "" ? "none; right:10px;" : "block";
            ?>
;">
            <strong>Raw Response</strong>
            <p id="codeViewPort"><?php 
            echo htmlspecialchars($this->c->rawResponse->header);
            ?>
<br /><?php 
            echo htmlspecialchars($this->c->rawResponse->body);
            ?>
</p>
        </div>
        <?php 
        }
        $result = ob_get_contents();
        ob_end_clean();
        return $result;
    }
예제 #14
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError(_CORE_OID_URL_INVALID);
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname', 'email'), array('fullname', 'dob', 'gender', 'postcode', 'country', 'language', 'timezone'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = isset($_GET['policies']) ? filter_var($_GET['policies'], FILTER_SANITIZE_URL) : NULL;
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            //displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header('Location: ' . $redirect_url);
            exit;
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), FALSE, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError(sprintf(_CORE_OID_REDIRECT_FAILED, $form_html->message));
        } else {
            $page_contents = array("<html><head><title>", _CORE_OID_INPROGRESS, "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
예제 #15
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = $_GET['policies'];
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            $page_contents = array("<html><head><title>", "OpenID transaction in progress", "</title></head>", "<body onload='document.getElementById(\"" . $form_id . "\").submit()'>", $form_html, "</body></html>");
            print implode("\n", $page_contents);
        }
    }
}
예제 #16
0
function openid_try($url)
{
    $store = new Auth_OpenID_MySQLStore(theDb());
    $store->createTables();
    $consumer = new Auth_OpenID_Consumer($store);
    $auth_request = $consumer->begin($url);
    if (!$auth_request) {
        $_SESSION["auth_error"] = "Error: not a valid OpenID.";
        header("Location: ./");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('email'), array('nickname', 'fullname'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Attribute Exchange (Google ignores Simple Registration)
    // See http://code.google.com/apis/accounts/docs/OpenID.html#Parameters for parameters
    $ax = new Auth_OpenID_AX_FetchRequest();
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/contact/email', 2, 1, 'email'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/first', 1, 1, 'firstname'));
    $ax->add(Auth_OpenID_AX_AttrInfo::make('http://axschema.org/namePerson/last', 1, 1, 'lastname'));
    $auth_request->addExtension($ax);
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            die("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
예제 #17
0
파일: try_auth.php 프로젝트: ksecor/civicrm
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        // check for new install, if no, go to index, else goto new-install page
        require_once 'CRM/Core/BAO/UFMatch.php';
        $contactIds = CRM_Core_BAO_UFMatch::getContactIDs();
        if (count($contactIds) > 0) {
            displayError("Authentication error; not a valid OpenID.");
        } else {
            $session =& CRM_Core_Session::singleton();
            $session->set('new_install', true);
            include 'new_install.html';
            exit(1);
        }
    }
    $sreg_request = Auth_OpenID_SRegRequest::build(array('nickname'), array('fullname', 'email'));
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    $policy_uris = null;
    if (isset($_REQUEST['policies'])) {
        $policy_uris = $_REQUEST['policies'];
    }
    $pape_request = new Auth_OpenID_PAPE_Request($policy_uris);
    if ($pape_request) {
        $auth_request->addExtension($pape_request);
    }
    $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
    // If the redirect URL can't be built, display an error
    // message.
    if (Auth_OpenID::isFailure($redirect_url)) {
        displayError("Could not redirect to server: " . $redirect_url->message);
    } else {
        // Send redirect.
        header("Location: " . $redirect_url);
        exit(2);
    }
}
예제 #18
0
function run_try_auth()
{
    global $authSource;
    $openid = $_GET['openid_url'];
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID.");
    }
    $sreg_request = Auth_OpenID_SRegRequest::build($authSource->getRequiredAttributes(), $authSource->getOptionalAttributes());
    if ($sreg_request) {
        $auth_request->addExtension($sreg_request);
    }
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            header("Location: " . $redirect_url);
            // Send redirect.
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->formMarkup(getTrustRoot(), getReturnTo(), FALSE, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated; otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            echo '<html><head><title>OpenID transaction in progress</title></head>
            		<body onload=\'document.getElementById("' . $form_id . '").submit()\'>' . $form_html . '</body></html>';
        }
    }
}
function displayResponse($html)
{
    if ($html) {
        if (getType(getCurrentBalance($html)) === "string") {
            if (getCurrentBalance($html) !== 0) {
                if (getLastOperation($html)) {
                    $json = array("currentBalance" => getCurrentBalance($html), "operations" => getLastOperation($html), "errorCode" => "0", "errorMessage" => "");
                } else {
                    $json = array("currentBalance" => getCurrentBalance($html), "errorCode" => "0", "errorMessage" => "");
                }
            } else {
                $json = displayError(2);
            }
        } else {
            $json = displayError(2);
        }
    } else {
        $json = displayError(1);
    }
    return $json;
}
예제 #20
0
 public function getPageInfo()
 {
     $output = array();
     // Get number and sizes of all pages.
     exec(select_pdfinfo() . ' -f 1 -l 100000 "' . $this->pdf_full_path . '"', $output);
     foreach ($output as $line) {
         if (strpos($line, "Pages:") === 0) {
             $page_number = intval(substr($line, 6));
         } elseif (strpos($line, "Page") === 0 && strpos($line, "size:") !== FALSE) {
             preg_match("/(size: )(\\d+\\.?\\d+)( x )(\\d+\\.?\\d+)( pts)/", $line, $match);
             $page_sizes[] = array(round($this->page_resolution * $match[2] / 72), round($this->page_resolution * $match[4] / 72));
         }
     }
     if (empty($page_number)) {
         displayError('Pdfinfo: malformed PDF.');
     }
     if ($page_number !== count($page_sizes)) {
         displayError('Pdfinfo: malformed PDF.');
     }
     return array('page_number' => $page_number, 'page_sizes' => $page_sizes);
 }
예제 #21
0
function run()
{
    $openid = getOpenIDURL();
    $consumer = getConsumer();
    // Begin the OpenID authentication process.
    $auth_request = $consumer->begin($openid);
    // No auth request means we can't begin OpenID.
    if (!$auth_request) {
        displayError("Authentication error; not a valid OpenID." . "\n OpenID::" . $openid);
    }
    $oauth_req = new Auth_OpenID_OAuthRequest(CONSUMER_KEY);
    $auth_request->addExtension($oauth_req);
    // Redirect the user to the OpenID server for authentication.
    // Store the token for this authentication so we can verify the
    // response.
    // For OpenID 1, send a redirect.  For OpenID 2, use a Javascript
    // form to send a POST request to the server.
    if ($auth_request->shouldSendRedirect()) {
        $redirect_url = $auth_request->redirectURL(getTrustRoot(), getReturnTo());
        // If the redirect URL can't be built, display an error
        // message.
        if (Auth_OpenID::isFailure($redirect_url)) {
            displayError("Could not redirect to server: " . $redirect_url->message);
        } else {
            // Send redirect.
            header("Location: " . $redirect_url);
        }
    } else {
        // Generate form markup and render it.
        $form_id = 'openid_message';
        $form_html = $auth_request->htmlMarkup(getTrustRoot(), getReturnTo(), false, array('id' => $form_id));
        // Display an error if the form markup couldn't be generated;
        // otherwise, render the HTML.
        if (Auth_OpenID::isFailure($form_html)) {
            displayError("Could not redirect to server: " . $form_html->message);
        } else {
            print $form_html;
        }
    }
}
예제 #22
0
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 = '验证被取消。';
        //showmessage('cancel_openid_auth');
    } else {
        if ($response->status == Auth_OpenID_FAILURE) {
            // Authentication failed; display the error message.
            $msg = "OpenID 认证失败: " . $response->message;
        } 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记录到session里,在session超时时间内,由以后的逻辑绑定到已注册的uid上。
                $_SESSION['openid_identifier'] = $response->getDisplayIdentifier();
                $_SESSION['openid_binding'] = time();
                //标记可以绑定了,但在发现是可直接登录用户时在要unset
                if ($response->endpoint->canonicalID) {
                    $_SESSION['xri_canonicalid'] = $response->endpoint->canonicalID;
                }
                $sreg_resp = Auth_OpenID_SRegResponse::fromSuccessResponse($response);
                $_SESSION['openid_sreg'] = $sreg_resp->contents();
                //NOTE:记录SREG到会话
                // echo var_dump($_SESSION['openid_identifier'])."--_SESSION['openid_identifier']<br>";
                // echo var_dump($_SESSION['openid_binding'])."--_SESSION['openid_binding']<br>";
                _OpenID_Action();
                //添加动作
            }
        }
    }
    displayError($msg);
}
function validateWord($data, $fieldName)
{
    global $errorCount;
    if (empty($data)) {
        displayError($fieldName, "This field is \n required");
        $retval = "";
    } else {
        // Only clean up the input if it isn't
        // empty
        $retval = trim($data);
        $retval = stripslashes($retval);
        if (strlen($retval) < 4 || strlen($retval) > 7) {
            displayError($fieldName, "Words must be\n at least four and at most \n seven letters long");
        }
        if (preg_match("/^[a-z]+\$/i", $retval) == 0) {
            displayError($fieldName, "Words must be \n only letters");
        }
    }
    $retval = strtoupper($retval);
    $retval = str_shuffle($retval);
    return $retval;
}
예제 #24
0
/**
 *
 */
function get_document_root($src)
{
    // check for unix servers
    if (file_exists($_SERVER['DOCUMENT_ROOT'] . '/' . $src)) {
        return $_SERVER['DOCUMENT_ROOT'];
    }
    // check from script filename (to get all directories to timthumb location)
    $parts = array_diff(explode('/', $_SERVER['SCRIPT_FILENAME']), explode('/', $_SERVER['DOCUMENT_ROOT']));
    $path = $_SERVER['DOCUMENT_ROOT'];
    foreach ($parts as $part) {
        $path .= '/' . $part;
        if (file_exists($path . '/' . $src)) {
            return $path;
        }
    }
    // the relative paths below are useful if timthumb is moved outside of document root
    // specifically if installed in wordpress themes like mimbo pro:
    // /wp-content/themes/mimbopro/scripts/timthumb.php
    $paths = array(".", "..", "../..", "../../..", "../../../..", "../../../../..");
    foreach ($paths as $path) {
        if (file_exists($path . '/' . $src)) {
            return $path;
        }
    }
    // special check for microsoft servers
    if (!isset($_SERVER['DOCUMENT_ROOT'])) {
        $path = str_replace("/", "\\", $_SERVER['ORIG_PATH_INFO']);
        $path = str_replace($path, "", $_SERVER['SCRIPT_FILENAME']);
        if (file_exists($path . '/' . $src)) {
            return $path;
        }
    }
    displayError('file not found ' . $src);
}
 $over21 = $_POST['over21'];
 $under12 = $_POST['under12'];
 $error_message = "";
 $email_exp = '/^[A-Za-z0-9._%-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}$/';
 if ($_POST['willAttend'] == '') {
     $error_message .= 'Please indicate whether you will attend or not attend.<br />';
 }
 if (!preg_match($email_exp, $email_from)) {
     $error_message .= 'The email address you entered does not appear to be valid.<br />';
 }
 if (strlen($name) < 2) {
     $error_message .= 'The name you entered does not appear to be valid.<br />';
 }
 //If there were any errors, call the function to display errors
 if (strlen($error_message) > 0) {
     displayError($error_message);
 }
 //Construct the email message
 $email_to = "rie1211@gmail.com,josh.d.henry@gmail.com";
 $email_subject = "A wedding guest has made a reservation!";
 $email_message = "Form details below.\n\n";
 $email_message .= "Name: " . clean_string($name) . "\n";
 $email_message .= "Email: " . clean_string($email_from) . "\n";
 $email_message .= "Will attend: " . clean_string($willAttend) . "\n";
 $email_message .= "Total attending: " . clean_string($totalAttending) . "\n";
 $email_message .= "How many over age 21?: " . clean_string($over21) . "\n";
 $email_message .= "How many under age 12?: " . clean_string($under12) . "\n";
 $email_message .= "Questions, comments, or dietary restrictions: " . clean_string($comments) . "\n";
 //Create email headers
 $headers = 'From: ' . $email_from . "\r\n" . 'Reply-To: ' . $email_from . "\r\n" . 'X-Mailer: PHP/' . phpversion();
 //Send email
예제 #26
0
 /**
  * Send HTTP authentification FORM
  *
  * @access public
  */
 function authenticate()
 {
     header('WWW-Authenticate: Basic realm="SQLiteManager"');
     header('HTTP/1.0 401 Unauthorized');
     displayError($GLOBALS['traduct']->get(147));
     exit;
 }
예제 #27
0
<?php

require_once "shared.php";
require_once "session.php";
require_once "controllers/LoginController.php";
$c = new LoginController();
if (isset($_POST['uiLogin']) || !empty($_REQUEST["pw"]) || !empty($_REQUEST["sid"]) || isset($_POST["oauth_Login"]) || isset($_GET["code"]) || isset($_POST["signed_request"])) {
    $c->processRequest();
}
require_once "header.php";
?>

<p>
    <?php 
if (count($c->getErrors()) > 0) {
    displayError($c->getErrors());
}
?>
</p>

<div id="loginBlockContainer">
    <form id="login_form" action="login.php" method="post">
        <?php 
print getCsrfFormTag();
?>
        <input type="hidden" id="startUrl" name="startUrl" value="<?php 
print htmlspecialchars($c->getStartUrl(), ENT_QUOTES);
?>
">
        <div id="login_type_selection" style="text-align: right; <?php 
if ($c->isOAuthRequired()) {
예제 #28
0
/**
 * Does the actual work of PUTting
 * for asyncPUT funcitons and forwarding
 * on to the results page.
 *
 * @param unknown_type $apiCall
 * @param unknown_type $extId
 * @param unknown_type $fieldMap
 * @param unknown_type $csvArray
 */
function putAsync($apiCall, $extId, $fieldMap, $csvArray, $zipFile, $contentType)
{
    $doingZip = isset($zipFile);
    if (!$doingZip && !($fieldMap && $csvArray && WorkbenchContext::get()->getDefaultObject())) {
        displayError("CSV file and field mapping not initialized or object not selected. Upload a new file and map fields.", true, true);
    } else {
        try {
            $job = new JobInfo();
            $job->setObject(WorkbenchContext::get()->getDefaultObject());
            $job->setOpertion($apiCall);
            $job->setContentType(isset($contentType) ? $contentType : ($doingZip ? "ZIP_CSV" : "CSV"));
            $job->setConcurrencyMode(WorkbenchConfig::get()->value("asyncConcurrencyMode"));
            if (WorkbenchConfig::get()->value("assignmentRuleHeader_assignmentRuleId")) {
                $job->setAssignmentRuleId(WorkbenchConfig::get()->value("assignmentRuleHeader_assignmentRuleId"));
            }
            if ($apiCall == "upsert" && isset($extId)) {
                $job->setExternalIdFieldName($extId);
            }
            $job = WorkbenchContext::get()->getAsyncBulkConnection()->createJob($job);
        } catch (Exception $e) {
            displayError($e->getMessage(), true, true);
        }
        if ($job->getId() == null) {
            displayError("No job id found. Aborting Bulk API operation.", true, true);
        }
        if ($doingZip) {
            try {
                WorkbenchContext::get()->getAsyncBulkConnection()->createBatch($job, $zipFile);
            } catch (Exception $e) {
                displayError($e->getMessage(), true, true);
            }
        } else {
            $csvHeader = array_shift($csvArray);
            $results = array();
            while ($csvArray) {
                $sObjects = array();
                $csvArrayBatch = array_splice($csvArray, 0, WorkbenchConfig::get()->value("asyncBatchSize"));
                $asyncCsv = array();
                $asyncCsvHeaderRow = array();
                foreach ($fieldMap as $salesforceField => $fieldMapArray) {
                    if (isset($fieldMapArray['csvField'])) {
                        if (isset($fieldMapArray['relationshipName']) && isset($fieldMapArray['relatedFieldName'])) {
                            $asyncCsvHeaderRow[] = ($fieldMapArray['isPolymorphic'] ? $fieldMapArray['relatedObjectName'] . ":" : "") . $fieldMapArray['relationshipName'] . "." . $fieldMapArray['relatedFieldName'];
                        } else {
                            if (isset($salesforceField)) {
                                $asyncCsvHeaderRow[] = $salesforceField;
                            }
                        }
                    }
                }
                $asyncCsv[] = $asyncCsvHeaderRow;
                for ($row = 0; $row < count($csvArrayBatch); $row++) {
                    //create new row
                    $asyncCsvRow = array();
                    foreach ($fieldMap as $salesforceField => $fieldMapArray) {
                        if (isset($fieldMapArray['csvField'])) {
                            $col = array_search($fieldMapArray['csvField'], $csvHeader);
                            if (isset($salesforceField) && isset($fieldMapArray['csvField'])) {
                                if ($csvArrayBatch[$row][$col] == "" && WorkbenchConfig::get()->value("fieldsToNull")) {
                                    $asyncCsvRow[] = "#N/A";
                                } else {
                                    $asyncCsvRow[] = $csvArrayBatch[$row][$col];
                                }
                            }
                        }
                    }
                    //add row to the array
                    $asyncCsv[] = $asyncCsvRow;
                }
                try {
                    WorkbenchContext::get()->getAsyncBulkConnection()->createBatch($job, convertArrayToCsv($asyncCsv));
                } catch (Exception $e) {
                    displayError($e->getMessage(), true, true);
                }
            }
        }
        try {
            $job = WorkbenchContext::get()->getAsyncBulkConnection()->updateJobState($job->getId(), "Closed");
        } catch (Exception $e) {
            displayError($e->getMessage(), true, true);
        }
        header("Location: asyncStatus.php?jobId=" . $job->getId());
    }
}
예제 #29
0
function k_resize_image($src, $dest = 0, $new_width = 0, $new_height = 0, $zoom_crop = 1, $enforce_max = 0, $quality = 80, $crop_position = 'middle', $check_thumb_exists = 0)
{
    global $FUNCS;
    // check to see if GD function exist
    if (!function_exists('imagecreatetruecolor')) {
        return displayError('GD Library Error: imagecreatetruecolor does not exist - please contact your webhost and ask them to install the GD library');
    }
    if (trim($src) == '') {
        return displayError('Source image not set');
    }
    // get mime type of src
    $mime_type = mime_type($src);
    ini_set('memory_limit', "50M");
    // make sure that the src is gif/jpg/png
    if (!valid_src_mime_type($mime_type)) {
        return displayError("Invalid src mime type: " . $mime_type);
    }
    if (strlen($src) && file_exists($src)) {
        // open the existing image
        $image = open_image($mime_type, $src);
        if ($image === false) {
            return displayError('Unable to open image : ' . $src);
        }
        // Get original width and height
        $width = imagesx($image);
        $height = imagesy($image);
        // generate new w/h if not provided
        if ($new_width && !$new_height) {
            $new_height = $height * ($new_width / $width);
        } elseif ($new_height && !$new_width) {
            $new_width = $width * ($new_height / $height);
        } elseif (!$new_width && !$new_height) {
            $new_width = $width;
            $new_height = $height;
        }
        // If new dimensions cannot exceed certain values
        if ($enforce_max) {
            // the supplied width and height were actually the max permissible values.
            $max_width = $new_width;
            $max_height = $new_height;
            // make the new values the same as that of the source image
            $new_width = $width;
            $new_height = $height;
            // if new dimensions already within bounds (and this not a thumbnail that we are creating), return.
            if ($dest && $new_width <= $max_width && $new_height <= $max_height) {
                return;
            }
            if ($new_width > $max_width) {
                if (!$zoom_crop) {
                    $ratio = (double) ($max_width / $new_width);
                    $new_width = (int) ($new_width * $ratio);
                    $new_height = (int) ($new_height * $ratio);
                } else {
                    $new_width = $max_width;
                }
            }
            // if new height still overshoots maximum value
            if ($new_height > $max_height) {
                if (!$zoom_crop) {
                    $ratio = (double) ($max_height / $new_height);
                    $new_width = (int) ($new_width * $ratio);
                    $new_height = (int) ($new_height * $ratio);
                } else {
                    $new_height = $max_height;
                }
            }
        }
        // Create filename if not provided one (happens only for thumbnails)
        if (!$dest) {
            $path_parts = $FUNCS->pathinfo($src);
            $thumb_name = $path_parts['filename'] . '-' . round($new_width) . 'x' . round($new_height) . '.' . $path_parts['extension'];
            $thumbnail = $path_parts['dirname'] . '/' . $thumb_name;
            if ($check_thumb_exists && file_exists($thumbnail)) {
                return $thumb_name;
            }
        }
        // create a new true color image
        $canvas = imagecreatetruecolor($new_width, $new_height);
        imagealphablending($canvas, false);
        // Create a new transparent color for image
        $color = imagecolorallocatealpha($canvas, 0, 0, 0, 127);
        // Completely fill the background of the new image with allocated color.
        imagefill($canvas, 0, 0, $color);
        // Restore transparency blending
        imagesavealpha($canvas, true);
        if ($zoom_crop) {
            $src_x = $src_y = 0;
            $src_w = $width;
            $src_h = $height;
            $cmp_x = $width / $new_width;
            $cmp_y = $height / $new_height;
            // if new dimensions equal to the original (and this not a thumbnail that we are creating), return.
            if ($dest && $cmp_x == 1 && $cmp_y == 1) {
                return;
            }
            // calculate x or y coordinate and width or height of source
            if ($cmp_x > $cmp_y) {
                $src_w = round($width / $cmp_x * $cmp_y);
                $src_x = round(($width - $width / $cmp_x * $cmp_y) / 2);
            } elseif ($cmp_y > $cmp_x) {
                $src_h = round($height / $cmp_y * $cmp_x);
                $src_y = round(($height - $height / $cmp_y * $cmp_x) / 2);
            }
            switch ($crop_position) {
                case 'top_left':
                    $src_x = 0;
                    $src_y = 0;
                    break;
                case 'top_center':
                    $src_y = 0;
                    break;
                case 'top_right':
                    $src_x *= 2;
                    $src_y = 0;
                    break;
                case 'middle_left':
                    $src_x = 0;
                    break;
                case 'middle':
                    break;
                case 'middle_right':
                    $src_x *= 2;
                    break;
                case 'bottom_left':
                    $src_x = 0;
                    $src_y *= 2;
                    break;
                case 'bottom_center':
                    $src_y *= 2;
                    break;
                case 'bottom_right':
                    $src_x *= 2;
                    $src_y *= 2;
                    break;
            }
            imagecopyresampled($canvas, $image, 0, 0, $src_x, $src_y, $new_width, $new_height, $src_w, $src_h);
        } else {
            // copy and resize part of an image with resampling
            imagecopyresampled($canvas, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height);
        }
        if (!$dest) {
            $dest = $thumbnail;
        }
        // output image to browser based on mime type
        save_image($mime_type, $canvas, $dest, $quality);
        // remove image from memory
        imagedestroy($canvas);
        return $thumb_name;
    } else {
        if (strlen($src)) {
            return displayError("image " . $src . " not found");
        } else {
            return displayError("no source specified");
        }
    }
    return;
}
예제 #30
0
파일: apiMethods.php 프로젝트: nikilster/I
function createActivity($userId, $timezone)
{
    //Check
    if (!parameterExists(APIKeys::$ACTIVITY_NAME) && !parameterExists(APIKeys::$ACTIVITY_DURATION)) {
        displayError("Create Activity: Please supply an activity name and activty duration as part of the request");
    } else {
        if (!parameterExists(APIKeys::$ACTIVITY_NAME)) {
            displayError("Create Activity: Please supply an activity name as part of the request");
        } else {
            if (!parameterExists(APIKeys::$ACTIVITY_DURATION)) {
                displayError("Create Activity: Please supply an activity duration as part of the request");
            }
        }
    }
    //Get values
    $activityName = getParameter(APIKeys::$ACTIVITY_NAME);
    $activityDuration = getParameter(APIKeys::$ACTIVITY_DURATION);
    //Create activity
    $result = APIDb::createActivity($userId, $activityName, $activityDuration, $timezone);
    //Show Response
    response($result);
}