Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

Messages - nend
91
Other software / Re: Shutdown Functions
« on May 10th, 2012, 08:01 PM »
My bad, should of looked at the source instead of the HTML.

My function looks like it is the last thing called.

On a second question I always wondered what would be the proper way to flush the buffer? I have my own method but sometimes it seems like it doesn't work on all host. Then there is allot of people that say one way works and other way doesn't.
92
Other software / Re: Shutdown Functions
« on May 10th, 2012, 06:58 PM »
It looks like I am going to have to search. It seems the footer of the site is getting called after my shutdown function. I need to register my shutdown function after everything that needs to be outputted has been done. I noticed this because I echoed some content in my shutdown function and it popped up right under the copyright but before the closing html.

I still however looking through the sources can't find it. I haven't used a search tool in a while also, I think I have one on this PC but forgot what it was called. Too many applications, lol.
93
Other software / Shutdown Functions
« on May 10th, 2012, 06:30 PM »
I know you guys been remolding SMF so by now you have to be familiar with all the SMF code base.

Is there any registered shutdown functions in SMF? If so where are they located and do they do anything with the output buffer?
94
Off-topic / Re: Bridges between other softwares and Wedge
« on May 9th, 2012, 06:57 AM »
Can we have a bridge for SMF? :eheh: :whistle:
95
Archived fixes / Re: Long cache keys make the cache fail.
« on May 8th, 2012, 02:12 AM »
I found a option, that works. You guys are probably going to call me crazy for doing this, because this is one of the things you planned to strip out of SMF. I ended up making a cache with another MySql database, that was slow though so I went with another option. This option allows keys to be longer than the file cache and is typically safe, so no key conversion required. I ended up using SQLite as the cache and it seems comparable to file caching, with slightly better write performance.

This is the first time I used a SQLite DB, so I probably have it all set up wrong, hopefully not.

I do have a problem with the set up, I am sure I set it up right according to the manual, but I can't get SQLite's auto vacuum going. :whistle:

So the file grows and grows. When data is removed it is deleted but with null, so you have padding. The DB system uses any empty space, but who wants a file that may be grow big without any way to shrink it. Auto vacuum is suppose to return this space to the file system but I can't get it to work.

Code: [Select]
function sicache_setup() {

global $sicacheDB;

if ($sicacheDB = new SQLiteDatabase('./cache/cache')) {
$query = @$sicacheDB->query('SELECT * FROM cache');
if ($query === false) {
@$sicacheDB->queryExec('PRAGMA auto_vacuum = 2');
$sicacheDB->queryExec('CREATE TABLE cache (key text primary key, value text, ttl int);');
}
}
}

function sicache_get($key) {

// sicache_setup();

global $sicache, $sicacheDB;

if ($sicacheDB = new SQLiteDatabase('./cache/cache')) {
$query = @$sicacheDB->query('SELECT * FROM cache WHERE key = \''.sqlite_escape_string($key).'\' LIMIT 1');
if ($query != false) {
$data = $query->fetch();
    if (!isset($sicacheData['sicache_purge']) && $data['ttl'] < time()) {
// Might as well purge the whole thing, only once though and only if needed.
$sicacheDB->queryExec('DELETE FROM cache WHERE ttl < '.time());
$sicacheData['sicache_purge'] = true;
}
return $data['value'];
}
}
}

function sicache_put($key, $value, $ttl) {

global $sicacheDB;

if ($value === null) {
@$sicacheDB->queryExec('DELETE FROM cache WHERE key = \''.sqlite_escape_string($key).'\'');
} elseif ($sicacheDB = new SQLiteDatabase('./cache/cache')) {
$sicacheDB->queryExec('INSERT INTO cache VALUES (\''.sqlite_escape_string($key).'\', \''.sqlite_escape_string($value).'\', '.sqlite_escape_string(time() + $ttl).')');
}
}
96
Bug reports / Re: Pretty URL remarks
« on May 7th, 2012, 12:38 AM »
Quote from Arantor on May 7th, 2012, 12:10 AM
Disk I/O is always slower than using memory caches - always. That's why you have memory caches ;) In any case, writes are physically more intensive to perform than reads, in whatever environment you care to name. It's really about the comparative performance which is almost impossible to test meaningfully.

That's really the thing, if cache level >= 2, cache pretty URL stuff, if not, don't.
I know memory is faster, my comparison was processing vs disk I/O. Processing seems faster than I/O speeds, but can that be the case on all systems, is the processing always going to be faster than disk I/O on every system?

Writes don't always have to be costly though, but the chances of running into a environment like this is rare, on a server even rarer. Most of my setups, on my local devices I always set up the environments where it favors reads more than writes. Reading is what the user cares the most about.

I agree though, the simple solution is usually the best, if there isn't a memory cache available then only process it.
97
Bug reports / Re: Pretty URL remarks
« on May 6th, 2012, 11:56 PM »
You know under different circumstances you might want different settings here. Just because my disk I/O is slow doesn't mean that is the case for every server setup. Who knows what scheduler is being used on my server, if writes are slower than reads than there might be a higher priority on them, sounds like deadline to me, but can't be sure.

Then you have your accelerators, if one of these are installed then caching might not be a bad idea.

Maybe these are things that can be determined during setup. Certain test to determine the best setting on the server the site is on.
98
Bug reports / Re: Pretty URL remarks
« on May 6th, 2012, 11:40 PM »
Quote from Nao on May 6th, 2012, 10:58 PM
So, no file cache then?
I would guess if you had a real memory caching system it would be faster, as for file caching, it is basically useless and DB caching is wasteful.

For me, DB storage I only have 1GB per database. So DB caching for me isn't a option and file caching looks to have no beneficial gain.

I would guess the only benefit you can gain on file caching is if the information is in the DB, other stuff like computing power PHP seems to be able to compute these things faster than a read from a file, well the read isn't the problem, seems like it is the write.
99
Bug reports / Re: Pretty URL remarks
« on May 6th, 2012, 09:29 PM »
Ok, done some testing, will when a cache key exist there is not much difference in speed from no caching at all to caching. It is when the script has to insert a new cache it slows down.

No Caching at all
Code: [Select]
.141
.237
.146
.154
.139
.239
.116
.15
.128
.215

Caching
Code: [Select]
1.186
.352
.134
.153
.346
.244
.312
.133
1.179
.246

As you can see there are spikes, these spikes are caused when a new cache needs to be created. There is basically no gain in caching and no caching is better. :cool:
100
Bug reports / Re: Pretty URL remarks
« on May 6th, 2012, 09:18 PM »
I need to get testing this properly. It looks like that now I disabled the cache it runs a little slower. DB caching works great but it puts too much junk in the DB without any way to properly purge expired URL's. It looks to me though file caching is in the middle.

I need still need to properly test these, benchmarks and such. So everything I am writing is by speculating by feel, no hard stats. It is going to be hard though to get a mean on a grid hosting account, can't force it to stay on one node, too many resource changes at one time.
101
The Pub / Re: The Cookie Law (in the UK at least)
« on May 5th, 2012, 05:57 AM »
Quote from markham on May 4th, 2012, 07:42 PM
I wonder how long it will take for our legislators to discover the "joys" of web bugs and HTML5 local storage both of which can, I understand, be used to track people around the net.
It is like these OSes and Firewalls, "Are you sure you want to do this?", "So and So is requesting such and such, Allow?". Point being, most computers still get infected because most users can care less as to what they agree to. That is what the Anti-Virus is for most may say, unknown to them a Anti-Virus is no magical cure.

The people that really care about the cookie subject I am sure already have the situation sorted in their browser. The people that don't care, are going to accept those prompts without giving it a glance as to what it says.

Useless annoying law, I stand by my claim. ::)
102
Plugins / Re: Random idea for a plugin
« on May 5th, 2012, 05:25 AM »
Quote from Arantor on May 5th, 2012, 03:58 AM
Just occurred to me. We could have a button that says "I'm having a drink" and you press it every time you start a new bottle of beer, and it records roughly how much alcohol you'd had.

Then it attaches a flag to each post written while drunk to say 'I was pissed while writing this' and the alcohol count goes down over time, so as you sober up you can look back and see what you wrote while pissed and others can forgive you if you wrote something stupid while drunk.

* Arantor was a bit drunk while writing this.
Posted: May 5th, 2012, 03:57 AM

* Arantor had tongue firmly in cheek when writing, btw. This is not a serious idea. But it is an idea. Have at it.
Why do I have a feeling we are going to be seeing allot of those flags on this forum from a certain person, :eheheh:
103
Off-topic / Re: HTML5 Upload Progress.
« on May 4th, 2012, 08:49 PM »
Still not taking, contacting support. :whistle:

Max upload size limit I am allowed to set in PHP is 192MB according to the hosting documentation. However no matter what I put in the PHP.ini it isn't taking even after rebooting my web services. I think it was working until I opted in to upgrade to PHP 5.3.

So all my sites with custom PHP.ini files are affected by the PHP upgrade. This turns out to be true because a coppermine site of mine which I increased the limits in PHP.ini is now not allowing big files, which it did before.

Got to love these new grid systems, there are side affects running a grid though. The most pain in the @#$% is that allot of times new files are not available to all nodes instantly.
104
Off-topic / Re: HTML5 Upload Progress.
« on May 4th, 2012, 06:24 PM »
I hate asking for help but I can't figure it out.

Small uploads work fine, big uploads don't.

What is going on when a big upload is uploaded it shows it being uploaded and once it is done the redirect works but no information is collected to add to the database or file is present on the server. The script returns no error either. I am stumped.

My source, I say if you can't post your source then it is not secure, lol.
Code: [Select]
<?php
if (!defined('romz'))
die('Hacking attempt...');

global 
$context;

$subActions = array(
'' => 'manageadd',
'sub' => 'manageadd2',
'edit' => 'manageedit',
'edit2' => 'manageedit2',
'del' => 'managedel'
);

if (isset(
$context['user']) && isset($subActions[$_REQUEST['sa']])) {
         
$context['html'].= $subActions[$_REQUEST['sa']]();
} else {
die('Hacking attempt...');
}

function 
manageadd() {

global $settings$context;

$context['canvas']['head'].= '
<script type="text/javascript">
function sendForm(form) {
if (form.upload.value != \'\') {
document.getElementById(\'progress\').style.display = \'\';
}
var fd = new FormData(form);
var xhr = new XMLHttpRequest();
xhr.upload.addEventListener("progress", uploadProgress, false);
xhr.upload.addEventListener("load", uploadComplete, false);
xhr.open("POST", form.action  = ((/\?/).test(form.action) ? "&" : "?")   (new Date()).getTime(), true);
xhr.send(fd);
}
function uploadProgress(evt) {
var percentComplete = Math.round(evt.loaded * 100 / evt.total);
document.getElementById(\'prog\').value = percentComplete;
document.getElementById(\'percent\').innerHTML = percentComplete "%<br />" evt.loaded " of " evt.total;
}
function uploadComplete(evt) {
window.location = "'
.$settings['url'].'?do=myRoms&sa=files&id='.$_REQUEST['id'].'"
}
function uploadFailed(evt) {
document.getElementById(\'upstatus\').innerHTML = "There was an error attempting to upload the file.";
}
function uploadCanceled(evt) {
document.getElementById(\'upstatus\').innerHTML = "The upload has been canceled by the user or the browser dropped the connection.";
}
</script>
'
;

$request mdb_query("
SELECT *
FROM cat
WHERE romId = '"
.mysql_real_escape_string($_REQUEST['id'])."'
ORDER BY cat.name DESC
LIMIT 50"
);

$data.= '
<form action="'
.$settings['url'].'?do=manrel&sa=sub" method="post" enctype="multipart/form-data" accept-charset="UTF-8">
<strong>Category:</strong><br />
<select name="catId">'
;
while ($cat mysql_fetch_assoc($request)) {
$data.= '
<option value="'
.$cat['id'].'">'.$cat['name'].'</option>';
}
$data.= '
</select><br />
<strong>Name:</strong><br /><input type="text" name="name" size="35"  /><br />
<strong>Description:</strong><br /><textarea name="desc" rows="15" cols="35" ></textarea><br />
<strong>ChangeLog:</strong><br /><textarea name="chglog" rows="15" cols="35" ></textarea><br />
<strong>File Name:</strong> Filename to save file as.<br /><input type="text" name="file" size="35"  /><br />
<strong>Upload File:</strong> Upload a file, if linking then put the link in the URL field below. 110 MB\'s & 3 hours max.<br /><input type="file" name="upload" /><br />
<strong>Link to Url:</strong> Link to a file, if uploading leave this blank.<br /><input type="text" name="url" size="35"  /><br />
<strong>Version:</strong><br /><input type="text" name="ver" size="35"  /><br />
<strong>Release Type:</strong><br />
<select name="relType">
<option value="0">Full</option>
<option value="1">Hot Fix</option>
</select><br />
<strong>Sub Version:</strong> If this release is a hotfix please put in a sub version number.<br /><input type="text" name="subVer" size="35"  /><br />
<strong>MD5 Hash:</strong><br /><input type="text" name="md5" size="35"  /><br />
<strong>Set as Current Release:</strong> <input type="checkbox" name="verUpdate" value="true" checked /><br />
<input type="hidden" name="romId" value="'
.$_REQUEST['id'].'"  />
<input type="button" value="Submit" onclick="sendForm(this.form);" />
</form>
<div id="progress" style="display:none;background-color: rgb(0, 0, 0);opacity: 0.7;-moz-opacity:0.70;filter: alpha(opacity=70);z-index: 20;height: 100%;width: 100%;background-repeat:repeat;position:fixed;top: 0px;left: 0px;">
<div style="border-radius:4px;background-color:#FFFFFF;position:fixed;top:40%;left:40%;border:1px solid;width:250px;height:100px;text-align:center;padding-top:4px;">
<div id="upstatus">Uploading Please Wait</div>
<progress id="prog" value="0" max="100.0"></progress> <span id="percent"></span>
</div>
</div>'
;

return $data;
}

function 
manageadd2() {

global $context$settings;

// These files can be huge.
ini_set('upload_max_filesize''110M'); //110 MB's max
ini_set('post_max_size''120M'); // Which gives 10 MB's left for post
ini_set('max_input_time'10800); // 3 hours
ini_set('max_execution_time'10800);
ini_set('memory_limit''128M');

// Check file
if (!empty($_FILES['upload'])) {
$md5 hash_file('md5'$_FILES['upload']['tmp_name']);
if(isset($_REQUEST['md5']) && $_REQUEST['md5'] != '' && $md5 != $_REQUEST['md5']) {
$context['error'] = '<b>Hash Mismatch.</b><br />Your hash - '.$_REQUEST['md5'].'<br />Generated Hash - '.$md5;
return null;
}
$_REQUEST['md5'] = $md5;
}

$stamp date('Ymd');

mdb_insert(
'roms', array(
'devId' => $context['user']['id'],
'romId' => $_REQUEST['romId'],
'catId' => $_REQUEST['catId'],
'name' => $_REQUEST['name'],
'desc' => $_REQUEST['desc'],
'chglog' => $_REQUEST['chglog'],
'file' => $_REQUEST['file'],
'url' => $_REQUEST['url'],
'ver' => $_REQUEST['ver'],
'subVer' => $_REQUEST['subVer'],
'relType' => $_REQUEST['relType'],
'md5' => $_REQUEST['md5'],
'date' => $stamp
)
);

$newId mysql_insert_id();
if (isset($_REQUEST['verUpdate']) && $_REQUEST['verUpdate'] == 'true') {
mdb_query("UPDATE `rom` SET `verId` = '".mysql_real_escape_string($newId)."',`ver` = '".mysql_real_escape_string($_REQUEST['ver'])."',`subVer` = '".mysql_real_escape_string($_REQUEST['subVer'])."',`date` = '".$stamp."' WHERE `rom`.`id`=".mysql_real_escape_string($_REQUEST['romId'])." LIMIT 1");
mdb_query("UPDATE `cat` SET `verId` = '".mysql_real_escape_string($newId)."',`ver` = '".mysql_real_escape_string($_REQUEST['ver'])."',`subVer` = '".mysql_real_escape_string($_REQUEST['subVer'])."',`date` = '".$stamp."' WHERE `cat`.`id`=".mysql_real_escape_string($_REQUEST['catId'])." LIMIT 1");
}

if (!empty($_FILES['upload'])) { //New JS for upload cuasing problems, seems it leaves uploads always set even if there isn't any, will fix later.
move_uploaded_file ($_FILES['upload']['tmp_name'], $settings['path'].'/f/rom/'.$newId.'.null');
if (file_exists($settings['path'].'/f/rom/'.$newId.'.null')) {mdb_query("UPDATE `roms` SET `url` = '".$settings['url']."f/rom/".$newId.".null' WHERE `roms`.`id`=".$newId." LIMIT 1");}
}

header'Location: '.$settings['url'].'?do=myRoms&sa=files&id='.$_REQUEST['romId']);
}

function 
manageedit() {

global $settings;

$request mdb_query("
SELECT *
FROM roms
WHERE id = '"
.mysql_real_escape_string($_REQUEST['id'])."'
LIMIT 1"
);

$rom mysql_fetch_assoc($request);

$request mdb_query("
SELECT *
FROM cat
WHERE romId = '"
.$rom['romId']."'
ORDER BY cat.name DESC
LIMIT 50"
);

$data.= '
<form action="'
.$settings['url'].'?do=manrel&sa=edit2" method="post" accept-charset="UTF-8">
<strong>Category:</strong><br />
<select name="catId">'
;
while ($cat mysql_fetch_assoc($request)) {
$data.= '
<option value="'
.$cat['id'].'"'.($cat['id'] == $rom['catId'] ? ' selected="selected"' '').'>'.$cat['name'].'</option>';
}
$data.= '
</select><br />
<strong>Name:</strong><br /><input type="text" name="name" size="35" value="'
.$rom['name'].'" /><br />
<strong>Description:</strong><br /><textarea name="desc" rows="15" cols="35" >'
.$rom['desc'].'</textarea><br />
<strong>ChangeLog:</strong><br /><textarea name="chglog" rows="15" cols="35" >'
.$rom['chglog'].'</textarea><br />
<strong>File:</strong> Filename to save file as.<br /><input type="text" name="file" size="35" value="'
.$rom['file'].'" /><br />
<strong>Url:</strong><br /><input type="text" name="url" size="35" value="'
.$rom['url'].'" /><br />
<strong>Version:</strong><br /><input type="text" name="ver" size="35" value="'
.$rom['ver'].'" /><br />
<strong>Release Type:</strong><br />
<select name="relType">
<option value="0"'
.($rom['relType'] == ' selected="selected"' '').'>Full</option>
<option value="1"'
.($rom['relType'] == ' selected="selected"' '').'>Hot Fix</option>
</select><br />
<strong>Sub Version:</strong> If this release is a hotfix please put in a sub version number.<br /><input type="text" name="subVer" value="'
.$rom['subVer'].'" size="35"  /><br />
<strong>MD5 Hash:</strong><br /><input type="text" name="md5" size="35" value="'
.$rom['md5'].'" /><br />
<strong>Update as Current Release:<strong> <input type="checkbox" name="verUpdate" value="true" /><br />
<input type="hidden" name="romId" value="'
.$rom['id'].'" />
<input type="hidden" name="redirect" value="'
.$rom['romId'].'" />
<input type="submit" value="Submit" />
</form>'
;

return $data;
}

function 
manageedit2() {
global $settings;
mdb_query("UPDATE `roms` SET `name` = '".mysql_real_escape_string($_REQUEST['name'])."',`catId` = '".mysql_real_escape_string($_REQUEST['catId'])."',`desc` = '".mysql_real_escape_string($_REQUEST['desc'])."',`chglog` = '".mysql_real_escape_string($_REQUEST['chglog'])."',`file` = '".mysql_real_escape_string($_REQUEST['file'])."',`url` = '".mysql_real_escape_string($_REQUEST['url'])."',`ver` = '".mysql_real_escape_string($_REQUEST['ver'])."',`subVer` = '".mysql_real_escape_string($_REQUEST['subVer'])."',`relType` = '".mysql_real_escape_string($_REQUEST['relType'])."',`md5` = '".mysql_real_escape_string($_REQUEST['md5'])."' WHERE `roms`.`id`=".mysql_real_escape_string($_REQUEST['romId'])." LIMIT 1");

$stamp date('Ymd');
if (isset($_REQUEST['verUpdate']) && $_REQUEST['verUpdate'] == 'true') {
mdb_query("UPDATE `rom` SET `verId` = '".mysql_real_escape_string($_REQUEST['romId'])."',`ver` = '".mysql_real_escape_string($_REQUEST['ver'])."',`subVer` = '".mysql_real_escape_string($_REQUEST['subVer'])."',`date` = '".$stamp."' WHERE `rom`.`id`=".mysql_real_escape_string($_REQUEST['redirect'])." LIMIT 1");
mdb_query("UPDATE `cat` SET `verId` = '".mysql_real_escape_string($_REQUEST['romId'])."',`ver` = '".mysql_real_escape_string($_REQUEST['ver'])."',`subVer` = '".mysql_real_escape_string($_REQUEST['subVer'])."',`date` = '".$stamp."' WHERE `cat`.`id`=".mysql_real_escape_string($_REQUEST['catId'])." LIMIT 1");
}

header'Location: '.$settings['url'].'?do=myRoms&sa=files&id='.$_REQUEST['redirect']);
}

function 
managedel() {

global $settings;

$request mdb_query("
SELECT *
FROM cat
WHERE verId = '"
.mysql_real_escape_string($_REQUEST['id'])."'
ORDER BY date DESC
LIMIT 1"
);

if (mysql_num_rows($request) == 0) {
mdb_query("DELETE FROM `roms` WHERE id = ".mysql_real_escape_string($_REQUEST['id']));
if (file_exists($settings['path'].'/f/rom/'.$_REQUEST['id'].'.null')) {unlink($settings['path'].'/f/rom/'.$_REQUEST['id'].'.null');}
header'Location: '.$settings['url'].'?do=myRoms');
} else {
global $context;
$context['error'] = '<b>Current Release.</b><br />This is the most current release, please add a newer release or promote a older release as current before deleting.';
return null;
}
}
?>

Sorry though about all the source, I just can't figure it out and can't ask anywhere else because there really isn't a place to ask where I am going to get a intelligent answer.

Function with the form is manageadd and manageadd2 saves the information
105
Quote from Arantor on May 2nd, 2012, 01:39 PM
I firmly agree on the no AGPL part. That licence is even worse than GPL.
I am sure once you get down to the business side things will change. I suspect some sneakiness here, especially since it is a one post user. I think it is just someone who wants their hands on your source before you release it, intentions unknown though.

They didn't come to a developer network to post a job, they came to a place where a forum software is known to be in the making.

Worst case scenario they can release the pre-release you sell them as their own.
Quote from Arantor on May 2nd, 2012, 01:39 PM
Quote
It should be possible to use OpenID authentication instead of a password. The main login method should not be OpenID, though. Maybe entering an OpenID URL into the username or password field will trigger OpenID authentication.

OpenID URLs should not be used as real usernames.
Well, SMF 2.0 has that.
SMF only support OpenID 1. SMF in no way supports OpendID 2 standards and currently I see no hurry in fixing the problem at SMF.