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


PHP H::csrf方法代码示例

本文整理汇总了PHP中H::csrf方法的典型用法代码示例。如果您正苦于以下问题:PHP H::csrf方法的具体用法?PHP H::csrf怎么用?PHP H::csrf使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在H的用法示例。


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

示例1: software

 /**
  * Update The Lobby Core (Software)
  */
 public static function software()
 {
     if (\Lobby\Modules::exists("admin")) {
         $admin_previously_installed = true;
     }
     $latest_version = getOption("lobby_latest_version");
     $url = \Lobby\Server::download("lobby", $latest_version);
     $zipFile = L_DIR . "/contents/update/" . $latest_version . ".zip";
     self::zipFile($url, $zipFile);
     // Make the Zip Object
     $zip = new \ZipArchive();
     if ($zip->open($zipFile) != "true") {
         \Lobby::log("Unable to open downloaded Zip File.");
         ser("Error", "Unable to open Zip File.  <a href='update.php'>Try again</a>");
     }
     \Lobby::log("Upgrading Lobby Software From {$zipFile}");
     /**
      * Extract New Version
      */
     $zip->extractTo(L_DIR);
     $zip->close();
     \Lobby\FS::remove($zipFile);
     self::finish_software_update(isset($admin_previously_installed));
     return L_URL . "/admin/about.php?updated=1&oldver={$oldVer}" . \H::csrf("g");
 }
开发者ID:saviobosco,项目名称:lobby,代码行数:28,代码来源:Update.php

示例2: checkDatabaseConnection

 /**
  * Check if the credentials given can be used to establish a
  * connection with the DB server
  */
 public static function checkDatabaseConnection()
 {
     try {
         $db = new \PDO("mysql:dbname=" . self::$database['dbname'] . ";host=" . self::$database['host'] . ";port=" . self::$database['port'], self::$database['username'], self::$database['password'], array(\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION));
         self::$dbh = $db;
         $notable = false;
         $tables = array("options", "data");
         // The Tables of Lobby
         foreach ($tables as $tableName) {
             $results = self::$dbh->prepare("SHOW TABLES LIKE ?");
             $results->execute(array(self::$database['prefix'] . $tableName));
             if (!$results || $results->rowCount() == 0) {
                 $notable = true;
             }
         }
         if (!$notable) {
             /* There are database tables */
             ser("Error", "Lobby Tables with prefix <b>" . self::$database['prefix'] . "</b> exists. Delete (DROP) those tables and <a href='install.php?step=2" . \H::csrf("g") . "'>try again.</a>");
             return false;
         }
     } catch (\PDOException $Exception) {
         ser("Error", "Unable to connect. Make sure that the settings you entered are correct. <cl/><a href='install.php?step=2'>Try Again</a>");
         return false;
     }
 }
开发者ID:saviobosco,项目名称:lobby,代码行数:29,代码来源:Install.php

示例3: ser

    $App = new \Lobby\Apps($_GET['id']);
    if (!$App->exists) {
        ser("Error", "App is not installed");
    }
    $App->enableApp();
    sss("Enabled", "The App <b>{$_GET['id']}</b> is enabled. The author says thanks.<a href='" . $App->info['URL'] . "' class='button green'>Open App</a>");
}
if (H::input("action") == "remove" && H::csrf()) {
    $App = new \Lobby\Apps($_GET['id']);
    if (!$App->exists) {
        ser("Error", "App is not installed");
    }
    $App->removeApp();
    sss("Removed", "The App <b>{$_GET['id']}</b> was successfully removed.");
}
$id = H::input("id");
if ($id != null && H::input("action") == null && H::csrf()) {
    ?>
          <h1>Install App</h1>
          <iframe src="<?php 
    echo L_URL . "/admin/download.php?type=app&id={$id}" . H::csrf("g");
    ?>
" style="border: 0;width: 100%;height: 200px;"></iframe>
        <?php 
}
?>
      </div>
    <div>
  </body>
</html>
开发者ID:saviobosco,项目名称:lobby,代码行数:30,代码来源:install-app.php

示例4:

        ?>
</td>
                  <td><?php 
        echo $data['short_description'];
        ?>
</td>
                  <td style="//text-align:center;">
                    <?php 
        if ($enabled) {
            echo '<a class="button" href="?action=disable&app=' . $app . H::csrf('g') . '">Disable</a>';
        } else {
            echo '<a class="button" href="?action=enable&app=' . $app . H::csrf('g') . '">Enable</a>';
        }
        ?>
                    <a class="button red" href="?action=remove&app=<?php 
        echo $app . H::csrf('g');
        ?>
">Remove</a>
                  </td>
                </tr>
              <?php 
    }
    ?>
            </tbody>
          </table>
        <?php 
}
?>
      </div>
    </div>
  </body>
开发者ID:saviobosco,项目名称:lobby,代码行数:31,代码来源:apps.php

示例5: getOption

<html>
  <head>
    <?php 
\Lobby::doHook("admin.head.begin");
\Lobby::head("Lobby Info");
?>
  </head>
  <body>
    <?php 
\Lobby::doHook("admin.body.begin");
include "{$docRoot}/admin/sidebar.php";
?>
    <div class="workspace">
      <div class="content">
        <?php 
if (isset($_GET['updated']) && H::csrf()) {
    sss("Updated", "Lobby was successfully updated to Version <b>" . getOption("lobby_version") . "</b> from the old " . htmlspecialchars($_GET['oldver']) . " version.");
}
?>
        <h1>About</h1>
        <p>Here is the information about your Lobby install.</p>
        <table border="1" style="margin-top:5px">
          <tbody>
            <tr>
              <td>Version</td>
              <td><?php 
echo getOption("lobby_version");
?>
</td>
            </tr>
            <tr>
开发者ID:saviobosco,项目名称:lobby,代码行数:31,代码来源:about.php

示例6:

                      <td>Your MySQL Password</td>
                    </tr>
                    <tr>
                      <td>Table Prefix</td>
                      <td>
                        <input type="text" name="prefix" value="l_" />
                      </td>
                      <td>Lobby's Table name starts with this value</td>
                    </tr>
                    <tr>
                      <td></td>
                      <td>
                        <button name="submit" style="width:200px;font-size:15px;" class="green">Install Lobby</button>
                      </td>
                      <td></td>
                    </tr>
                  </tbody>
                </table>
                <?php 
            H::csrf(1);
            ?>
              </form>
            <?php 
        }
    }
}
?>
     </div>
  </body>
</html>
开发者ID:saviobosco,项目名称:lobby,代码行数:30,代码来源:install.php

示例7: log

{
    $base = log($size) / log(1024);
    $base = floor($base);
    $suffix = array("", "KB", "MB", "GB", "TB");
    return round(pow(1024, $base - floor($base)), 1) . $suffix[$base];
}
$GLOBALS['last'] = 0;
\Lobby\Update::$progress = function ($resource, $download_size, $downloaded, $upload_size, $uploaded) {
    if ($download_size == 0) {
        $percent = 0;
    } else {
        $percent = round($downloaded / $download_size * 100, 0);
    }
    if ($GLOBALS['last'] != $percent) {
        $GLOBALS['last'] = $percent;
        $rd_size = convertToReadableSize($download_size);
        echo "<script>document.querySelector('.downloadStatus').innerHTML = 'Downloaded {$percent}% of {$rd_size}';</script>";
        flush();
        if ($percent == 100) {
            echo "<p>Installing <b>{$GLOBALS['name']}</b>...</p>";
            flush();
        }
    }
};
if ($type == "app" && \Lobby\Update::app($id)) {
    echo "Installed - The app has been installed. <a target='_parent' href='" . L_URL . "/admin/install-app.php?action=enable&id={$_GET['id']}" . H::csrf("g") . "'>Enable the app</a> to use it.";
} else {
    if ($type == "lobby" && ($redirect = \Lobby\Update::software())) {
        echo "<a target='_parent' href='{$redirect}'>Updated Lobby</a>";
    }
}
开发者ID:saviobosco,项目名称:lobby,代码行数:31,代码来源:download.php

示例8:

<?php

require "../../../../load.php";
if (isset($_POST['appId']) && isset($_POST['key']) && isset($_POST['value']) && H::csrf()) {
    $app = $_POST['appId'];
    $key = $_POST['key'];
    $val = $_POST['value'];
    if (!saveData($key, $val, $app)) {
        echo "bad";
    } else {
        echo "good";
    }
} else {
    echo "fieldsMissing";
}
开发者ID:saviobosco,项目名称:lobby,代码行数:15,代码来源:saveData.php

示例9: elseif

            <div clear></div>
            <a class="button" href="backup-db.php">Export Lobby Database</a>
          </p>
        <?php 
    if (is_writable(L_DIR)) {
        echo '<div clear style="margin-top: 10px;"></div>';
        echo \Lobby::l("/admin/update.php?step=1" . H::csrf("g"), "Setup Lobby Update", "class='button red'");
    }
}
if (isset($_GET['step']) && $_GET['step'] != "" && H::csrf()) {
    $step = $_GET['step'];
    if ($step == 1) {
        ?>
            <p>
              Looks like everything is ok. Hope you backed up Lobby installation & Database.
              <div clear></div>
              You can update now.
            </p>
          <?php 
        echo \Lobby::l("/admin/update.php?step=2" . H::csrf("g"), "Start Update", "clear class='button green'");
    } elseif ($step == 2) {
        $version = getOption("lobby_latest_version");
        echo '<iframe src="' . L_URL . "/admin/download.php?type=lobby&id={$version}" . H::csrf("g") . '" style="border: 0;width: 100%;height: 200px;"></iframe>';
    }
}
?>
      </div>
    </div>
  </body>
</html>
开发者ID:saviobosco,项目名称:lobby,代码行数:30,代码来源:update.php

示例10: urldecode

<?php

require "../../../../load.php";
if (isset($_POST['s7c8csw91']) && isset($_POST['cx74e9c6a45']) && H::csrf()) {
    $AppID = $_POST['s7c8csw91'];
    // App ID
    $AjaxFile = urldecode($_POST['cx74e9c6a45']);
    // Ajax File Location
    $App = new \Lobby\Apps($AppID);
    if ($App->exists && $App->isEnabled()) {
        if ($AjaxFile == "") {
            ser();
        } else {
            $AppClass = $App->run();
            $html = $AppClass->page("/Ajax/{$AjaxFile}");
            if ($html == "auto") {
                $html = $AppClass->inc("/src/Ajax/{$AjaxFile}");
            }
            echo $html;
        }
    }
}
开发者ID:saviobosco,项目名称:lobby,代码行数:22,代码来源:app.php

示例11: array

            \Lobby::log("{$type_of_file} file was not found in location given : {$file}");
        }
    }
    if (isset($css)) {
        $to_replace = array("<?L_URL?>" => L_URL, "<?THEME_URL?>" => THEME_URL);
        if (isset($_GET['APP_URL'])) {
            $to_replace["<?APP_URL?>"] = htmlspecialchars(urldecode($_GET['APP_URL']));
            $to_replace["<?APP_SRC?>"] = htmlspecialchars(urldecode($_GET['APP_SRC']));
        }
        foreach ($to_replace as $from => $to) {
            $content = str_replace($from, $to, $content);
        }
    }
}
if (isset($js)) {
    $content = "lobby.url='" . L_URL . "';lobby.csrf_token = '" . H::csrf("s") . "';" . $content;
    $content = "\$(window).load(function(){" . $content . "});";
}
$merged = $extraContent . $content;
// Add ETag
$etag = hash("md5", $merged);
header("ETag: {$etag}");
// We make it cachable for the browsers
header("Cache-Control: public");
/**
 * Was it already cached before by the browser ? The old etag will be sent by
 * the browsers as HTTP_IF_NONE_MATCH. We interpret it 
 */
$browserTag = isset($_SERVER["HTTP_IF_NONE_MATCH"]) ? $_SERVER["HTTP_IF_NONE_MATCH"] : 501;
if ($browserTag != $etag) {
    echo $merged;
开发者ID:saviobosco,项目名称:lobby,代码行数:31,代码来源:serve.php

示例12: elseif

        ?>
</p>
            <div id="leftpane" style="float:left;margin-right:10px;display:inline-block;width: 200px;text-align:center;">
              <img src="<?php 
        echo $appImage;
        ?>
" height="200" width="200" />
              <a clear="" href="<?php 
        echo $app['app_page'];
        ?>
" target="_blank" class="button">App Page</a>
              <cl/>
              <?php 
        $App = new \Lobby\Apps($_GET['id']);
        if (!$App->exists) {
            echo \Lobby::l("/admin/install-app.php?id={$_GET['id']}" . H::csrf("g"), "Install", "class='button'");
        } elseif (version_compare($App->info['version'], $app['version'])) {
            echo \Lobby::l("/admin/check-updates.php", "Update App", "class='button red'");
        } else {
            echo \Lobby::l($App->info['URL'], "Open App", "class='button green'");
        }
        ?>
              <style>#leftpane .button{width:100%;margin: 5px 0px;}</style>
            </div>
            <div style="display:inline-block;width: 60%;">
              <table>
                <thead>
                  <tr>
                    <td style="width: 10%;">Version</td>
                    <td style="width: 25%;">Category</td>
                    <td style="width: 15%;">Author</td>
开发者ID:anandubajith,项目名称:lobby,代码行数:31,代码来源:lobby-store.php


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