May 4, 2011

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

Avatar

Lost password?
Advanced Search

— Forum Scope —




— Match —





— Forum Options —





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

sp_Related 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

If I change the Array to just 3 words it does complete:

$arrayBadWords = array(‘copyright’,’bad1′,’bad2′,);

Any suggestion as to how this sort of functionality could be improved other than creating fa slow PHP ‘looping’ array?

Regards,
Cyber1

December 5, 2011
1:28 pm
Avatar
CyberSEO
Admin
Forum Posts: 3833
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/Amsterdam

Most Users Ever Online: 541

Currently Online:
5 Guest(s)

Currently Browsing this Page:
1 Guest(s)

Top Posters:

ninja321: 84

s.baryshev.aoasp: 68

Freedom: 61

Pandermos: 49

MediFormatica: 49

B8europe: 47

Member Stats:

Guest Posters: 337

Members: 2777

Moderators: 0

Admins: 1

Forum Stats:

Groups: 1

Forums: 5

Topics: 1592

Posts: 8102

Newest Members:

jimmy.jimmytechsf, leif.nicolaisen.web, rob.bidonenergy, info.wilkens-web, efe966436, air111003-air

Administrators: CyberSEO: 3833