Saturday 04th February 2012
 
 
 
 
 
 


 

It should be proper for all plugins over vb.org to be updated shortly to implement this new security check, but anyway, this won’t any time soon by all the wanna be coders out there. So let me help you.

The new anti-CSRF is triggered by a specific constant on top of your script, the vb team selected this way to not break a few hundreds mods.

So on top of your script and before the call of the global.php ( under the define of the THIS_SCRIPT is a good place) add this line.

define('CSRF_PROTECTION', true);

Next step is to edit all your forms in your custom plugin templates to add a specific hidden input. A cool way to do this, is to open your product.xml and do a search for <form and under each of finds to add this line of code.

<input type="hidden" name="securitytoken" value="$bbuserinfo[securitytoken]" />

And you are done! You can make a test after the first step to see this nice error during any Post Request that comes from the scripts you added the first line.

Your submission could not be processed because a security token was missing or mismatched.

If this occurred unexpectedly, please inform the administrator and describe the action you performed before you received this error.

After a little search and if you think as i do you will find out how the new check works in the file includes/init.php lines 399-420.

Note that only Post requests are checked not GET too.

If for some reason you want your script to have this extra check but you also want for some reason to bypass it you must specify on top of your script something like this:

define('CSRF_SKIP_LIST', 'save,update,dosex');

Where each of save, update and dosex are the actions specified by the $_REQUEST['do'] or $_POST['do'] if you prefer that.

Happy Coding as always….

 
Views: 35,142 Tags: ,
 
 

 
 

[C] Implement of strcmp

November 16, 2006 Author: Posted in: Code Tutorials
 

A simple program to understand how to work with strings.

#include <stdio.h>
#include <stdlib.h>
 
int main(void)
{
char name[10] =  {'H','E','L','L','O'}  ;
char name2[10] = {'G','O','O','D','B','Y','E'} ; 
char temp[10] ;     
int i;
 
printf("Name 1 is %s\n",name);
printf("Name 2 is %s\n",name2);
printf("\n");
for(i=0; i<10; i++) {
 
       temp[i]= name[i];
       name[i] = name2[i]; 
       name2[i] = temp[i];
}
 
printf("After The string copy function\n");
printf("\n");   
 
printf("Name 1 is %s\n",name);
printf("Name 2 is %s\n",name2);
 
    system("PAUSE");
    return 0;   
  }
 
Comments Off
Views: 4,139
 
 

 
 

[C] Square, Sum, Product

November 16, 2006 Author: Posted in: Code Tutorials
 

A very simple program written in c which calculates the square, the sum and the product of numbers from 1 to 10. A good functions introduction in c.

#include <stdio.h>
 
int main(void)
{
int x,y=0,g=1;
 
   for (x = 1;x <= 10;x++){ 
      printf("The %1d^2 is=%d \n",x,squ(x));
      y = sum(x,y);
      g = tot(x,g);
 
   }
    printf("The sum of numbers  is %d\n",y);
    printf("The product of numbers  is %d\n",g);
 
system("PAUSE");
  return 0;
}
 
tot(x,g)
int x,g;
{
int total;
 
   total = x * g;
   return(total); 
}
sum(x,y) 
int x,y;
{
int sum;
 
   sum = y + x;
   return(sum); 
}
 
squ(in) 
int in;
{
int square;
 
   square = in * in;
   return(square);
}
 
 
Comments Off
Views: 4,507
 
 

 
 

[C] Magic Number

November 16, 2006 Author: Posted in: Code Tutorials
 

A simple program in c which the program choose one random number from 1-500 and the user has to guess that number. The program notifies user if his guess is too low or too hight and counts all the user tries.

#include <stdio.h>
#include <stdlib.h>
#include <time.h>
 
int main(void) {     
    int magic, guess, counter;
    srand(time(NULL));
 
    magic=(rand()%500)+1;
    counter=0;
 
    do { printf ("Make Your Guess: ");
 
   scanf ( "%d" , &guess);   
         counter++;                       
 
         if ( guess==magic ) {
              printf ( "You have found it after %d trial(s) , " , counter);
              printf ( "%d is the number ! \n" , magic );
              }
         else {
               printf ( "Wrong number , You are ");
               if ( guess > magic)  printf ("Too high... ");
               else  printf ("Too low... ");
               printf ( "You have made %d trial(s) \n" , counter);
               }         
}while (guess!=magic);                         
 
system("PAUSE");
return 0;   
}
 
Comments Off
Views: 4,232
 
 

 
 

[c++] Working with classes

November 16, 2006 Author: Posted in: Code Tutorials
 

This is a good tutorial working with classes in c++. Our program starts and asks the user to enter the coordinates of two points. The program returns the middle point and the distance between the two points.

#include <iostream>
#include <math.h>
using namespace std;
 
class Point
{
      private:
              double x,y;
      public:
             Point() { x=y=0;}
             Point(double a) {x=y=a;}
             Point(double a, double b) {x=a; y=b;}
             void Point::display() { cout <<"("<<x<<","<<y<<")"<<endl; }
             double Point::get_y() {return y;}
             double Point::get_x() {return x;}
};       
 
class Segment
{
      private:
              Point p1,p2,mid;
              double xm,ym,len, tmp1, tmp2;
      public:
             Segment(Point a) { Point p; p1=p; p2=a;}   
             Segment(Point a, Point b) { p1=a; p2=b;}
             void Segment::display()
             {    cout <<"The first point is: ";
                  p1.display();
                  cout <<"The second point is: ";
                  p2.display();
 
             }
             void Segment::middle()
             {
                  xm = (p2.get_x() + p1.get_x())/2;
                  ym = (p2.get_y() + p1.get_y())/2;
                  Point mid(xm,ym);
                  cout <<"To middle point is: ";
                  mid.display();
             }
             void Segment::length()
             {   
                tmp1 = (p2.get_x()-p1.get_x()) * (p2.get_x()-p1.get_x());
                //DEBUG cout <<tmp1<<endl;
                tmp2 = (p2.get_y()-p1.get_y()) * (p2.get_y()-p1.get_y());
                //DEBUG cout <<tmp2<<endl;
                len = sqrt(tmp1 + tmp2);
                cout <<"The distance between these two points is:"<<len<<endl;
             }     
};
 
int main ()
{
    double x1, y1, x2, y2;
 
    //Point p1;
    //p1.display();
    //Point p2(3);
    //p2.display();
    //Point p3(-1,8);
    //p3.display();
    //Point p4(3,6);
    //p4.display();
 
    cout <<"Enter x1:";
    cin >> x1;
    cout <<"Enter y1:";
    cin >> y1;
 
    cout <<"Enter x2:";
    cin >> x2;
    cout <<"Enter y2:";
    cin >> y2;
 
    Point p5(x1,y1);
    Point p6(x2,y2);;
 
    Segment s1(p5,p6);
    s1.display();
    s1.middle();
    s1.length();
 
    system("PAUSE");
    return 0;
}
 
 
Comments Off
Views: 4,593