Forums / Developer / [Solution] to stop DB flood , do u have better ?

[Solution] to stop DB flood , do u have better ?

Author Message

Selmah Maxim

Monday 02 June 2003 5:15:22 am

Hi ..

Try this, click here New Reply, check the the url, check the long number, then click back, then agian New Reply, u will find the is increased with one, this mean new entry, as much you repeat this as much you increase the DB with empty values, which gonna slow down the site !
Also when new visitor try to register, when he just open the register page new record will be added to the DB, also if didn`t register !

The best way i had found to check the db if user have copy or draft in the, if it`s exists, the redirect him to this copy, else create new one.
I hade create new module, and users just with this mudole can submit to the site, so i had put this lines in the module action :

// Find if he have copy in the DB //
$db = eZDb::instance();
$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '15' and
owner_id = '$userID' order by current_version desc limit 1 ");

if($DBCheck[0][id]) // Get the old one//
{
$module->redirectTo( '/content/edit' . '/' . $DBCheck[0][id] . '/' . $DBCheck[0][current_version] );
}
else // create new one//
{
$module->redirectTo( '/content/edit' . '/' . $contentObject->attribute( 'id' ) . '/' . $contentObject->attribute( 'current_version' ) );
}

To stop the user register flood :

$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '4' and published ='0' and modified='0' and status='0'
order by current_version desc limit 1 ");

The user will get the 1st empty record id from the DB ..

so do you have better idea ?

Bård Farstad

Monday 02 June 2003 6:32:22 am

This is a good idea. It's much the same way as we do when a user edits an object.

However this does not work if you want the users to be able to have several drafts of the same class. E.g. I would like to have two drafts of an article.

Mabye we could create a setting for the default behaviour or handle users in a special way.

--bård

Documentation: http://ez.no/doc

Selmah Maxim

Monday 02 June 2003 6:50:56 am

User can have 2 draft, but not if class id is 15, i made this coz i have section where user can submit some data about his work or what ever, and i don`t wanna let him spam this section with his ads, so if submit once he can just modify it, he cann`t submit again, and this is just for user group 12, the resgistered users, editors ,and admin can have drafts.

Now am trying with user register, i cann`t get work :

if ( $module->isCurrentAction( 'Publish' ) )
{
$http =& eZHTTPTool::instance();
$user =& eZUser::currentUser();

$db = eZDb::instance();
$DBCheck =& $db->arrayQuery( "select id , current_version from ezcontentobject where
contentclass_id = '4' and published ='0' and modified='0'
order by current_version desc limit 1 ");
if(count($DBCheck) > 0)
{
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $DBCheck[0][id],
'version' => $DBCheck[0][current_version] ) );
}
else
{
include_once( 'lib/ezutils/classes/ezoperationhandler.php' );
$operationResult = eZOperationHandler::execute( 'content', 'publish', array( 'object_id' => $object->attribute( 'id' ),
'version' => $version->attribute( 'version') ) );
}

it`s not work , coz the $object->attribute( 'id' ) is not equal $DBCheck[0][id] , and don`t know how set the $object->attribute( 'id' ) to $DBCheck[0][id] !

do u have idea about this ?

Selmah Maxim

Monday 02 June 2003 8:36:29 am

didn`t work !!

coz of nodeAssignment value, i cann`t get the Assignment id :( , coz of this the object will take the ObjectID as parentid :(

I cann`t figure out the db map, to huge for me to do it alone :(

I hope in next version will be way to do this, or somthing to clean the DB from unactive records!

eZ debug

Timing: Jan 30 2025 19:43:56
Script start
Timing: Jan 30 2025 19:43:56
Module start 'content'
Timing: Jan 30 2025 19:43:56
Module end 'content'
Timing: Jan 30 2025 19:43:56
Script end

Main resources:

Total runtime0.3182 sec
Peak memory usage8,192.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0074 588.0625370.2734
Module start 'content' 0.00740.0143 958.33591,005.5781
Module end 'content' 0.02170.2964 1,963.91413,897.0391
Script end 0.3182  5,860.9531 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00451.4068200.0002
Check MTime0.00140.4276200.0001
Mysql Total
Database connection0.00070.220310.0007
Mysqli_queries0.221869.68931410.0016
Looping result0.00160.49251390.0000
Template Total0.295993.010.2959
Template load0.00100.305210.0010
Template processing0.294992.683310.2949
Override
Cache load0.00070.210210.0007
Sytem overhead
Fetch class attribute can translate value0.00190.584810.0019
XML
Image XML parsing0.00030.082010.0003
General
dbfile0.00341.0553200.0002
String conversion0.00000.001930.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs