May 4, 2011

PHP Code 'Array' Loop Functions Create Alot of OverHead | CyberSEO Pro | Support Forums

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





Minimum search word length is 3 characters - maximum search word length is 84 characters

Related Topics sp_topicicon
PHP Code 'Array' Loop Functions Create Alot of OverHead
Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 Topic Rating: 0 (0 votes) 
December 5, 2011
7:24 am
Avatar
cyber1
Guest
Guests

Hello Admin,

I’m finding that adding an “array check” function for bad words is creating alot of “overhead” and creating some error or causing PHP scripts to ‘time out’.

For instance the following script “times out” and never inserts a post (CyberSEO complains that there was an ‘error’ and not post was added, but I have no way of knowing what the error is):

Login to see the code.

December 5, 2011
1:28 pm
Avatar
Admin
Forum Posts: 3097
Member Since:
July 2, 2009
sp_userofflinesmall Offline

First of all, your code is not well optimized because it continues to check for all “bad” keywords even if one of them was found (lines 4-8). This is just a wasting of your server resources which is the reason of those “overheads”.

The second thing is that this code runs for every post in the feed, including those that there syndicated already. You can skip these posts using special API function cseo_post_exists() which returns true if post already exists in the database (it uses the selected duplicated check method).

So here is a slightly optimized version of your code which also uses the cseo_post_exists() function to skip all the existing posts (note lines #1, #5 and #6):

Login to see the code.

December 10, 2011
11:18 pm
Avatar
cyber1
Guest
Guests

Hi Admin,

Thank you, thank you thank you for your suggestions!!!

(will keep you posted)

-cyber1

Forum Timezone: Europe/Moscow

Most Users Ever Online: 105

Currently Online:
9 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 81

Freedom: 61

B8europe: 54

saviulisse67: 45

adultdenim: 44

allgoodies: 38

Member Stats:

Guest Posters: 350

Members: 1927

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 2

Topics: 1328

Posts: 6627

Administrators: CyberSEO: 3097