金钱,员工,技能和对开源或商业的偏好是中立的.
让我们采取最好的程序员(为了论证)并考虑这个:
整体表现更好:
要么
(我不想要有偏见的答案,只是寻找性能和速度).
我想限制对图像的访问,因此,我将它们放在Web根目录之外,当用户链接到图像时,它将通过用户/传递从我们的数据库进行身份验证,然后(如果经过身份验证)读取图像文件,并使用适当的mime类型输出.
任何图像链接都将是这样的:
<img src="/image.php?id=324fwqrefv35fq5">
Run Code Online (Sandbox Code Playgroud)
其中id是数据库中的imageId.
这听起来像一个好方法,还有 - 这样的代码用于PHP吗?
我将所有图像存储在webroot后面(之前/var/www/),这意味着Web服务器无法为我的图片发回缓存头.我需要添加什么才能使用户的Web缓存工作?目前,每次都被同一个浏览器击中.
我<img>在我的页面上的路径看起来像这样:
<img src="pic.php?u=1134&i=13513&s=0">
Run Code Online (Sandbox Code Playgroud)
编辑:可能是因为" pic.php?u=1134&i=13513&s=0"不是有效的文件名或什么?
// pic.php
<?php
// open the file in a binary mode
$user = $_GET['u'];
$id = $_GET['i'];
$s = $_GET['s'];
if (!isset($user) && !isset($s) && $isset($id))
{
// display a lock!
exit(0);
}
require_once("bootstrap_minimal.php"); //setup db connection, etc
// does this image_id belong to the user?
$stmt = $db->query('SELECT image_id, user_id, file_name, private FROM images WHERE image_id = ?', $id);
$obj = $stmt->fetchObject();
if (is_object($obj))
{
// is …Run Code Online (Sandbox Code Playgroud) Stackoverflow如何做"你赢得了新徽章"窗口?(在屏幕顶部弹出的橙色,我相信当你没有登录时会显示常见问题解答).
有人有代码示例吗?(用按钮关闭窗口?)
我的服务器时间是格林尼治标准时间,每当有人上线时我会做以下事情.
// Set a default timezone
$defaultTimeZone = 'America/Toronto';
// load the user, if they are online...
$onlineUser = new user();
if (isset($_SESSION['user_id']))
{
if ($onlineUser->loadUser($_SESSION['user_id']))
{
$defaultTimeZone = $onlineUser->timeZone;
}
}
// set time zones
date_default_timezone_set($defaultTimeZone);
$db->query("SET SESSION time_zone = '".$defaultTimeZone."'");
Run Code Online (Sandbox Code Playgroud)
所以,我的问题是这样的...每当有人做某事时,它会在用户当地时间存储日期/时间......导致我一大堆问题.
我想要的只是将所有内容存储在GMT中,但让用户在本地时区查看数据并与之交互.
编辑:
以下是我更新用户状态的方法:
public function updateStatus()
{
global $db, $common, $config;
// update the user record
$data = array(
'date_last_active' => new Zend_Db_Expr('NOW()')
);
$db->update('users', $data, 'user_id='.$this->userId);
}
Run Code Online (Sandbox Code Playgroud)
这是我将日期戳变成秒的功能......
public function dateTimeToUnixTime($dateString)
{
if (strlen($dateString) < 10) …Run Code Online (Sandbox Code Playgroud) 我在我的HTML页面点击的图像调用JavaScript函数......但是没有人点击他们,因为他们不看点击的...我怎样才能让他们点击可以不使用的<a href = ""> </a>周围的标签?
这是我的代码的一个例子......
<div id="bvu11" style="margin: 0px 5px; float: left;">
<span id="bviu11">
<img src="/images/icons/favorites_add.png" onclick="favoritesAdd(2,11,'u')">
</span>
</div>
Run Code Online (Sandbox Code Playgroud) 想知道mysql打开,选择和数据的通用输出会更快:
A)编译的C++代码,通过exec()调用(或等效的东西)
要么
B)直接的PHP代码.
鉴于所有代码都在C++和PHP中均等编码.
做了一个测试:这是C++
Document Length: 100000 bytes
Concurrency Level: 2
Time taken for tests: 0.139 seconds
Complete requests: 10
Failed requests: 0
Write errors: 0
Total transferred: 1001550 bytes
HTML transferred: 1000000 bytes
Requests per second: 71.76 [#/sec] (mean)
Time per request: 27.872 [ms] (mean)
Time per request: 13.936 [ms] (mean, across all concurrent requests)
Transfer rate: 7018.29 [Kbytes/sec] received
Run Code Online (Sandbox Code Playgroud)
这是PHP:
Concurrency Level: 2
Time taken for tests: 4.115 seconds
Complete requests: 10
Failed requests: 0
Write …Run Code Online (Sandbox Code Playgroud) 如果我不需要,我不想在每个getRequest-> getParam('x')之后在我的代码中调用Zend过滤器.是否有一种懒惰的方法可以神奇地过滤getRequest中的所有内容?
编辑: 当我说过滤器时,我的意思是,转义标签,清理XSS,并转义任何sql转义字符.
即:
$myVar = $this->getRequest()->getParam('x');
filter the variable, escape sql stuf... etc
Run Code Online (Sandbox Code Playgroud)
标准是什么?你好吗?
我在我的网站上收到以下错误,但是,我不知道我要做什么.我知道我错过了一些东西,然而,我无法弄明白.
你可以在这里看到我想要实现的目标:4.6.4.Zend_Application_Resource_Session
致命错误:在C:\ xampp\htdocs\app\library\Zend\Db\Table\Abstract.php中找到未捕获的异常'Zend_Db_Table_Exception',消息'找不到Zend_Session_SaveHandler_DbTable的适配器':667堆栈跟踪:#0 C:\ xampp\htdocs\app\library\Zend\Db\Table\Abstract.php(652):Zend_Db_Table_Abstract - > _ setupDatabaseAdapter()#1 C:\ xampp\htdocs\app\library\Zend\Session\SaveHandler\DbTable.php(401) :Zend_Db_Table_Abstract - > _ setup()#2 C:\ xampp\htdocs\app\library\Zend\Db\Table\Abstract.php(286):Zend_Session_SaveHandler_DbTable - > _ setup()#3 C:\ xampp\htdocs\verelo\library\Zend\Session\SaveHandler\DbTable.php(205):Zend_Db_Table_Abstract - > __ construct(Array)#4 C:\ xampp\htdocs\app\library\Zend\Application\Resource\Session.php(59):Zend_Session_SaveHandler_DbTable- > __ construct(Array)#5 C:\ xampp\htdocs\app\library\Zend\Application\Resource\ResourceAbstract.php(93):Zend_Application_Resource_Session-> setSaveHandler(Array)#6 C:\ xampp\htdocs\app\library\Zend\Application\Resource\ResourceAbstract.php(72):Ze 第667行的C:\ xampp\htdocs\app\library\Zend\Db\Table\Abstract.php中的nd_Application_R
这是我的config.ini文件:
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
bootstrap.path = APPLICATION_PATH "/Bootstrap.php"
bootstrap.class = "Bootstrap"
resources.db.adapter = "pdo_mysql"
resources.db.params.host = "localhost"
resources.db.params.username = "root"
resources.db.params.password = ""
resources.db.params.dbname = "app"
resources.db.isDefaultTableAdapter = true
resources.frontController.controllerDirectory …Run Code Online (Sandbox Code Playgroud) 刚从一些man文档中完成了这个函数的组合,它需要一个char*并附加一个const char*,如果char*的大小太小,它会将它重新分配给更大的东西并最终附加它.自从我使用c以来已经很长时间了,所以只需要办理登机手续.
// append with realloc
int append(char *orig_str, const char *append_str) {
int result = 0; // fail by default
// is there enough space to append our data?
int req_space = strlen(orig_str) + strlen(append_str);
if (req_space > strlen(orig_str)) {
// just reallocate enough + 4096
int new_size = req_space;
char *new_str = realloc(orig_str, req_space * sizeof(char));
// resize success..
if(new_str != NULL) {
orig_str = new_str;
result = 1; // success
} else {
// the resize failed.. …Run Code Online (Sandbox Code Playgroud) php ×8
javascript ×2
mysql ×2
ajax ×1
apache ×1
c ×1
c# ×1
c++ ×1
caching ×1
click ×1
html ×1
image ×1
performance ×1
sql-server ×1
timezone ×1