当前位置: 首页>>代码示例>>PHP>>正文


PHP respond函数代码示例

本文整理汇总了PHP中respond函数的典型用法代码示例。如果您正苦于以下问题:PHP respond函数的具体用法?PHP respond怎么用?PHP respond使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了respond函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: downloadOutput

function downloadOutput($output)
{
    /* // function for force downloading files
     */
    // Must be fresh start
    if (headers_sent()) {
        die('Headers Sent');
    }
    // Required for some browsers
    if (ini_get('zlib.output_compression')) {
        ini_set('zlib.output_compression', 'Off');
    }
    // CHECK IF THE output EXISTS
    if ($output != '') {
        // Read output to standard out
        header("Pragma: public");
        // required
        header("Expires: 0");
        header("Cache-Control: must-revalidate, post-check=0, pre-check=0");
        header("Cache-Control: private", false);
        // required for certain browsers
        header("Content-Type: application/force-download");
        header("Content-Disposition: attachment; filename=user-result-summary.xls;");
        header("Content-Transfer-Encoding: binary");
        header("Content-Length: " . strlen($output));
        ob_clean();
        flush();
        echo $output;
    } else {
        // Output does not exist, maybe the run failed, or is still running?
        $msg = array();
        $msg['MESSAGE'] = "Error: No resuts was found for your user!";
        respond("NORESULTS", $msg, true);
    }
}
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:35,代码来源:get_all_data_as_tab.php

示例2: testBasic

 public function testBasic()
 {
     $this->expectOutputString('x');
     respond('/', function () {
         echo 'x';
     });
     respond('/something', function () {
         echo 'y';
     });
     dispatch('/');
 }
开发者ID:samdubey,项目名称:ads2,代码行数:11,代码来源:RoutesTest.php

示例3: subscribe

function subscribe($publisher, $path, $callback)
{
    global $subscription_file;
    $key = "{$publisher} {$path}";
    $id = md5($key);
    $subscriptions = file($subscription_file) ?: array();
    $subscriptions = array_map(rtrim, $subscriptions);
    array_push($subscriptions, "{$key} {$callback}");
    $subscriptions = array_unique($subscriptions);
    file_put_contents($subscription_file, join("\n", $subscriptions));
    respond($id);
}
开发者ID:jdmcgee,项目名称:SmartWink,代码行数:12,代码来源:subscribe.php

示例4: sendMails

function sendMails($maildata)
{
    $me = 'ryan@tellmesomethingnice.com';
    $them = $maildata["email"];
    $subjectMe = 'New enquiry';
    $subjectThem = 'Thanks for the enquiry!';
    $messageMe = $maildata["message"];
    $messageThem = 'Hi! Thanks for the enquiry. We will respond as soon as we can!';
    $headersMe = 'From: ' . $me . "\n" . 'Reply-To: ' . $them . "\n" . 'X-Mailer: PHP/' . phpversion();
    $headersThem = 'From: ' . $me . "\n" . 'Reply-To: ' . $me . "\n" . 'X-Mailer: PHP/' . phpversion();
    mail($me, $subjectMe, $messageMe, $headersMe);
    mail($them, $subjectThem, $messageThem, $headersThem);
    respond($maildata);
}
开发者ID:askdesigners,项目名称:tellmesomethingnice,代码行数:14,代码来源:enquiry.php

示例5: generate_slug

function generate_slug($length = 4)
{
    global $db;
    $values = serialize($_POST);
    $length = 4;
    $slug = substr(md5($values . time()), 0, $length);
    $exists = $db->value("\n    SELECT COUNT(id)\n    FROM shift\n    WHERE url_slug = '{$slug}'\n  ");
    if ($length == 32) {
        respond(0, "Could not generate URL slug.");
    }
    if ($exists) {
        return generate_slug($length + 1);
    } else {
        return $slug;
    }
}
开发者ID:kenyattaclark,项目名称:shiftspace,代码行数:16,代码来源:main.php

示例6: consulta

function consulta($tabla, $columnas = array(), $filtros = array(), $singleRecord = false)
{
    $sqlColumnas = empty($columnas) ? '*' : implode(', ', $columnas);
    $sqlFiltros = array();
    foreach ($filtros as $index => $element) {
        array_push($sqlFiltros, $index . ' = ' . quoteDb($element));
    }
    $sqlFiltros = !empty($sqlFiltros) ? 'WHERE ' . implode(' AND ', $sqlFiltros) : '';
    $link = connect();
    $result = mysql_query("SELECT {$sqlColumnas} FROM {$tabla} {$sqlFiltros}", $link) or respond(400, mysql_error());
    $arrayResult = array();
    while ($row = mysql_fetch_assoc($result)) {
        array_push($arrayResult, $row);
    }
    if (!empty($singleRecord) && !empty($arrayResult)) {
        $arrayResult = $arrayResult[0];
    }
    return $arrayResult;
}
开发者ID:reyre8,项目名称:cuam,代码行数:19,代码来源:cuam-lib.php

示例7: resume

 public static function resume()
 {
     function respond($err, $resume = null, $fname = null)
     {
         $data = ['error' => $err, 'resume' => $resume, 'fname' => $fname];
         echo toJSON($data);
     }
     if (!isset($_FILES['file'])) {
         return respond('no file selected');
     }
     switch ($_FILES['file']['error']) {
         case UPLOAD_ERR_OK:
             break;
         case UPLOAD_ERR_FORM_SIZE:
             return respond('max file size exceeded');
         case UPLOAD_ERR_NO_FILE:
             return respond('no file selected');
         case UPLOAD_ERR_INI_SIZE:
             return respond('file too large');
     }
     if ($_FILES['file']['size'] > 10 * 1024 * 1024) {
         return respond('max file size exceeded');
     }
     $filename = $_FILES['file']["name"];
     $ext = pathinfo($filename, PATHINFO_EXTENSION);
     $allowed = array("doc", "docx", "rtf", "pdf");
     if (!in_array($ext, $allowed)) {
         return respond('bad file extension');
     }
     require_once $GLOBALS['dirpre'] . 'includes/S3/s3_config.php';
     $fname = $_FILES['file']["tmp_name"];
     $actualFilename = time() . '.' . $ext;
     $res = $s3->putObjectFile($fname, $bucket, $actualFilename, S3::ACL_PUBLIC_READ);
     if (!$res) {
         return respond('upload failed');
     }
     $link = 'http://' . $bucket . '.s3.amazonaws.com/' . $actualFilename;
     return respond(null, $link, $filename);
 }
开发者ID:davidliuliuliu,项目名称:sublite,代码行数:39,代码来源:S3Controller.php

示例8: setUserReported

function setUserReported($contentOriginTable, $contentID, $isAdmin)
{
    // get the ID of the user who was reported
    $reportedUserID = Database::selectFirst("SELECT user_id FROM " . $contentOriginTable . " WHERE id = " . intval($contentID));
    $reportedUserID = $reportedUserID['user_id'];
    // get the ID of the message thread that the user was reported in
    if ($contentOriginTable == 'messages') {
        $messageID = $contentID;
    } elseif ($contentOriginTable == 'comments') {
        $messageID = Database::selectFirst("SELECT message_id FROM comments WHERE id = " . $contentID);
        $messageID = $messageID['message_id'];
    } else {
        // we can't handle this request
        respond(array('status' => 'bad_request'));
        // prevent IDE warnings
        exit;
    }
    // mark the user as reported and possibly ban them temporarily
    $possibleWriteLockEnd = time() + 3600 * 24 * 5;
    $timesReported = $isAdmin ? 2 : 1;
    Database::update("UPDATE users SET reported_count = reported_count+" . $timesReported . ", write_lock_until = IF(reported_count >= 3, " . intval($possibleWriteLockEnd) . ", write_lock_until), reported_count = IF(reported_count >= 3, 1, reported_count) WHERE id = " . $reportedUserID);
    // send a notice to the violating user
    Database::insert("INSERT INTO subscriptions (message_id, user_id, degree, reasonForBan, counter) VALUES (" . intval($messageID) . ", " . $reportedUserID . ", 3, 1, 1) ON DUPLICATE KEY UPDATE reasonForBan = 1, counter = 1");
}
开发者ID:billpeace,项目名称:Faceless,代码行数:24,代码来源:reports_new.php

示例9: respond

<?php

// Generic response (don't force the trailing slash: this should catch any accidental laziness)
respond('/?', function ($request, $response, $app) {
    // Let's create a session variable, so we know where to redirect back to
    $redirect_to = $request->param('redirect_to');
    // Let's log the user out
    IDMObject::unauthN($redirect_to);
});
// Let's create a success page
respond('/logout-success/?', function ($request, $response, $app) {
    // Display the template
    $app->tpl->assign('show_page', 'logout-success');
    $app->tpl->display('_wrapper.tpl');
});
// Let's create a cute little message page... so that PhoneGap users just see a flashing page
respond('/logout-message/?', function ($request, $response, $app) {
    // Display the template
    $app->tpl->assign('show_page', 'logout-message');
    $app->tpl->display('_wrapper.tpl');
});
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:21,代码来源:logout.php

示例10: respond

respond('POST', '/[i:sgs_id]/[*]', function ($request, $response, $app) {
    $response->deny_to_readonly();
    $sgs_id = $request->param('sgs_id');
    if ('teacher' === $request->param('target')) {
        $action = $request->param('action');
        if ('add-teacher' === $action) {
            $ss_id = $request->param('student_school_id');
            $app->populate('student_school', TeacherCert\Student\School::get($ss_id));
            $app->populate_constituents();
            $app->teacher_model->form($request->params());
            $app->teacher_model->student_gate_system_id = $sgs_id;
            $teacher = new TeacherCert\Student\CooperatingTeacher($app->teacher_model->form());
        } else {
            // update existing teacher
            $teacher_id = $request->param('id');
            $teacher = new TeacherCert\Student\CooperatingTeacher($teacher_id);
            if ('Add Voucher' === $action) {
                $teacher->add_voucher();
            } elseif ('Remove Voucher' === $action) {
                $teacher->remove_voucher();
            } elseif ('Remove Teacher' === $action) {
                $teacher->delete();
            }
        }
        if ($teacher->save()) {
            $_SESSION['successes'][] = 'Your changes have been saved.';
        } else {
            $_SESSION['errors'][] = 'An error occured saving your changes: ' . htmlentities(PSU::db('banner')->ErrorMsg());
        }
        $response->refresh();
    }
    $app->school_model->form($request->params());
    if ($id = $request->param('id')) {
        $action = 'edit';
        $school = TeacherCert\Student\School::get($id);
        // dump the incoming form data back into the School
        $fields = $app->school_model->form();
        // read-only fields
        unset($fields['school_id']);
        foreach ($fields as $key => $value) {
            $school->{$key} = $value;
        }
    } else {
        $action = 'add';
        $school = new TeacherCert\Student\School($app->school_model->form());
        $school->student_gate_system_id = $sgs_id;
    }
    $uri = sprintf("%s/student-school/%d/edit/%d", $GLOBALS['BASE_URL'], $app->student_gate_system->id, $school->id);
    if ($success = $school->save()) {
        if ('edit' === $action) {
            $_SESSION['successes'][] = 'Your changes have been saved.';
        } else {
            $_SESSION['successes'][] = 'The school has been added to this gate system.';
            // need to populate new id into url
            $uri = sprintf("%s/student-school/%d/edit/%d", $GLOBALS['BASE_URL'], $app->student_gate_system->id, $school->id);
        }
        unset($_SESSION['tcert-student-school-save']);
    } else {
        $_SESSION['errors'][] = 'Your changes could not be saved: ' . PSU::db('banner')->ErrorMsg();
        $_SESSION['tcert-student-school-save'] = $app->school_model->form();
        // Operation failed; might need to return the user back to
        // the "add a school" screen.
        if ('edit' !== $action) {
            $uri = sprintf("%s/student-school/%d/add", $GLOBALS['BASE_URL'], $app->student_gate_system->id, $school->id);
        }
    }
    $response->redirect($uri);
});
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:68,代码来源:student-school.php

示例11: session_start

<?php

session_start();
require_once 'funcs.php';
require_once 'db.php';
if (!isset($_SESSION['user']) || !isset($_SESSION['user']['username'])) {
    header('Location: index.php');
    die;
}
$mysqli = dbConnect();
$query = 'SELECT leave_type as title, start_date as start, end_date as end FROM `leaves_taken` WHERE `person_id` = ' . $_SESSION['user']['person_id'] . '';
$result = $mysqli->query($query);
if ($result->num_rows > 0) {
    $data = [];
    while ($row = $result->fetch_assoc()) {
        $data[] = $row;
    }
    respond(false, "got it", $data);
}
?>
	
开发者ID:deepak7514,项目名称:Leave_Application_Management_System,代码行数:20,代码来源:myleaves.php

示例12: init

 */
require_once __DIR__ . '/../base.php';
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    // initialization
    $user = init($_POST);
    // force authentication
    $userID = auth($user['username'], $user['password'], false);
    // check if required parameters are set
    if (isset($_POST['contentType']) && isset($_POST['contentID'])) {
        $contentID = intval(base64_decode(trim($_POST['contentID'])));
        if ($_POST['contentType'] == 'message') {
            $authorID = Database::selectFirst("SELECT user_id FROM messages WHERE id = " . intval($contentID));
            if (isset($authorID['user_id']) && $authorID['user_id'] != $userID) {
                Database::insert("INSERT INTO connections (from_user, type, to_user, time_inserted) VALUES (" . intval($userID) . ", 'block', " . intval($authorID['user_id']) . ", " . time() . ") ON DUPLICATE KEY UPDATE type = VALUES(type)");
            }
            respond(array('status' => 'ok'));
        } elseif ($_POST['contentType'] == 'comment') {
            $authorID = Database::selectFirst("SELECT user_id FROM comments WHERE id = " . intval($contentID));
            if (isset($authorID['user_id']) && $authorID['user_id'] != $userID) {
                Database::insert("INSERT INTO connections (from_user, type, to_user, time_inserted) VALUES (" . intval($userID) . ", 'block', " . intval($authorID['user_id']) . ", " . time() . ") ON DUPLICATE KEY UPDATE type = VALUES(type)");
            }
            respond(array('status' => 'ok'));
        } else {
            respond(array('status' => 'bad_request'));
        }
    } else {
        respond(array('status' => 'bad_request'));
    }
} else {
    respond(array('status' => 'bad_request'));
}
开发者ID:billpeace,项目名称:Faceless,代码行数:31,代码来源:connections_block.php

示例13: handlenode

/**
* Handles the actual XML between the <template/> tags.
*
* Recognises the different tags, access the different functions to process each individual tag. Notes by the original developer: <br/>
* Why isn't this a huge switch statement? Because it has to do more comlicated checking than just string comparison to figure out what it should do. <br/>
* How can I organize this better? Good question.
*
* @todo It seems to me that this function could modelled similarly to the custom tag system. Where there is a seperate function for each tag.
*
* @uses getid()
* @uses getfdate()
* @uses getsize()
* @uses upperkeysarray()
* @uses debugger()
* @uses recursechildren()
* @uses respond()
* @uses botget()
* @uses gender()
* @uses getinput()
* @uses bset()
* @uses insertgossip()
* @uses firstthird()
* @uses firstsecond()
* @uses getthat()
* @uses realchild()
*
* @param mixed $xmlnode               Getting either a string or an array from recursechildren() func.
* @param array $inputstar             If a matched pattern includes *'s then what is covere by the * is found here.
* @param array $thatstar              if a used that contains a star, then what is covered by the * is found here.
* @param array $topicstar             if a used topic contains a star, then what is covered by the * is found here.
*
* @return string                      The bot's response.
*/
function handlenode($xmlnode, $inputstar, $thatstar, $topicstar)
{
    if (!is_array($xmlnode)) {
        return $xmlnode;
    } elseif (strtoupper($xmlnode["tag"]) == "ID") {
        return getid();
    } elseif (strtoupper($xmlnode["tag"]) == "DATE") {
        //		return getfdate(); // deprecated
        $mynode = upperkeysarray($xmlnode["attributes"]);
        // Get the value of an attribute
        $date_format = $mynode["FORMAT"];
        return getfdate($date_format);
    } elseif (strtoupper($xmlnode["tag"]) == "VERSION") {
        return PROGRAMEVERSION;
    } elseif (strtoupper($xmlnode["tag"]) == "SIZE") {
        return getsize();
    } elseif (strtoupper($xmlnode["tag"]) == "STAR") {
        $mynode = upperkeysarray($xmlnode["attributes"]);
        //$starindex=$xmlnode["attributes"]["INDEX"];
        if (!(is_array($mynode) && isset($mynode["INDEX"]))) {
            $mynode["INDEX"] = "";
        }
        $starindex = $mynode["INDEX"];
        if ($starindex == "") {
            $starindex = "1";
        }
        debugger("starindex: {$starindex}", 3);
        //print_r($inputstar);
        return $inputstar[$starindex - 1];
    } elseif (strtoupper($xmlnode["tag"]) == "THATSTAR") {
        $mynode = upperkeysarray($xmlnode["attributes"]);
        //$starindex=$xmlnode["attributes"]["INDEX"];
        if (!(is_array($mynode) && isset($mynode["INDEX"]))) {
            $mynode["INDEX"] = "";
        }
        $starindex = $mynode["INDEX"];
        if ($starindex == "") {
            $starindex = "1";
        }
        debugger("starindex: {$starindex}", 3);
        //print_r($inputstar);
        return $thatstar[$starindex - 1];
    } elseif (strtoupper($xmlnode["tag"]) == "TOPICSTAR") {
        $mynode = upperkeysarray($xmlnode["attributes"]);
        //$starindex=$xmlnode["attributes"]["INDEX"];
        if (!(is_array($mynode) && isset($mynode["INDEX"]))) {
            $mynode["INDEX"] = "";
        }
        $starindex = $mynode['INDEX'];
        if ($starindex == "") {
            $starindex = "1";
        }
        debugger("starindex: {$starindex}", 3);
        //print_r($inputstar);
        return $topicstar[$starindex - 1];
    } elseif (strtoupper($xmlnode["tag"]) == "SRAI") {
        // Build up a new response inside of here (using recursechildren function and then call response with it.
        $newresponse = recursechildren(realchild($xmlnode), $inputstar, $thatstar, $topicstar);
        debugger("newresponts: {$newresponse}", 3);
        return respond($newresponse);
    } elseif (strtoupper($xmlnode["tag"]) == "SR") {
        return respond($inputstar[0]);
    } elseif (strtoupper($xmlnode["tag"]) == "RANDOM") {
        $liarray = array();
        $children = $xmlnode["children"];
        for ($randomc = 0; $randomc < sizeof($children); $randomc++) {
            if (strtoupper($children[$randomc]["tag"]) == "LI") {
//.........这里部分代码省略.........
开发者ID:pradyumnasagar,项目名称:pratechsha,代码行数:101,代码来源:respond_talk.php

示例14: test405Routes

 public function test405Routes()
 {
     $resultArray = array();
     $this->expectOutputString('_');
     respond(function () {
         echo '_';
     });
     respond('GET', null, function () {
         echo 'fail';
     });
     respond(array('GET', 'POST'), null, function () {
         echo 'fail';
     });
     respond(405, function ($a, $b, $c, $d, $methods) use(&$resultArray) {
         $resultArray = $methods;
     });
     dispatch('/sure', 'DELETE');
     $this->assertCount(2, $resultArray);
     $this->assertContains('GET', $resultArray);
     $this->assertContains('POST', $resultArray);
 }
开发者ID:lucatume,项目名称:klein52,代码行数:21,代码来源:RoutesTest.php

示例15: function

    $GLOBALS['TEMPLATES'] = PSU_BASE_DIR . '/app/%CUSTDIR%/templates';
    if (file_exists(PSU_BASE_DIR . '/debug/%CUSTDIR%-debug.php')) {
        include PSU_BASE_DIR . '/debug/%CUSTDIR%-debug.php';
    }
    IDMObject::authN();
    $response->denied = function () use($app) {
        $app->tpl->display('access-denied.tpl');
        // Is it ok to die here, or do we need a way to skip
        // future routes? (For example, if there is a final cleanup
        // routine.)
        die;
    };
    $app->tpl = new \PSU\Template();
    $app->user = PSUPerson::get($_SESSION['wp_id']);
    /**
     * Not all apps need this cool breadcrumb
     * functionality, so delete it if you aren't going to 
     * use it. If you are, then uncomment it.
     *
     * $app->breadcrumbs = new \PSU\Template\Breadcrumbs;
     * $app->breadcrumbs->push( new \PSU\Template\Breadcrumb( 'Home', $app->config->get( '%CUSTDIR', 'base_url' ) . '/' ) );
     */
    $app->tpl->assign('user', $app->user);
    $app->tpl->assign('back_url', $_SERVER['HTTP_REFERER']);
});
//
// Nothing specific requested; show list of gatesystems
//
respond('GET', '/', function ($request, $response, $app) {
    $app->tpl->display('index.tpl');
});
开发者ID:AholibamaSI,项目名称:plymouth-webapp,代码行数:31,代码来源:app-template.php


注:本文中的respond函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。