CActiveForm: Updating password_repeat field doesn't trigger client side compare validation

Link

        $form = $this->beginWidget('CActiveForm',array(
            'id'=>'pass-form',
            'enableAjaxValidation'=>true,
            'clientOptions' => array(
                'validateOnSubmit'=>true,
                //'validationDelay'=>5000,
                'focus'=>'input[type="password"]:first',
                'afterValidateAttribute' => 'js:function(form, attribute, data, hasError) {
                     if (attribute.name == "newPass_repeat") {

                        var settings = $.fn.yiiactiveform.getSettings(form);
                        successCallback = function (messages) {
                            $.each(settings.attributes, function () {
                                if (this.name == "newPass") {
                                    $.fn.yiiactiveform.updateInput(this, messages, form);
                                }
                            });
                        };

                        $.each(settings.attributes, function () {
                            if (this.name == "newPass") {
                                this.status = 2;
                            }
                        });

                        $.fn.yiiactiveform.validate ("#pass-form", successCallback);
                    }
                }'
            )
        ));
  • دوشنبه ۲ ارديبهشت ۹۲

Following are the points to be considered for making safe php application.

Following are the points to be considered for making safe php application.

  1. USE PDO or mysqli
  2. Never trust user inputs. Consider every variable viz $_POST, $_GET, $_COOKIE, $_SESSION, $_SERVER as if they were tainted. Use appropriate filtering measure for these variables.
  3. To avoid XSS attack use php’s builtin functions htmlentities, strip_tags, etc while inserting the user input data into the database.
  4. Disable Register Globals in PHP.INI
  5. Disable “allow_url_fopen” in PHP.INI
  6. Don’t allow user to input more data than required. Validate input to allow max number of characters. Also validate each field for relevant datatypes.
  7. Disable error reporting after Development period. It might give information about database that’ll be useful to hackers.
  8. Use one time token while posting a form. If token exist and matches the form post is valid otherwise invalid.
  9. Use parametrized database queries
  10. Use stored procedures

You can google for each point for more details. HOpe this helps

Resource: http://stackoverflow.com/questions/11839523/secure-against-sql-injection-pdo-mysqli

  • چهارشنبه ۲۷ دی ۹۱

date() [function.date]: It is not safe to rely on the system's timezone settings

فایل php.ini رو باز کنید. عبارت date.timezone رو پیدا کنید. سمی کالن (;) اول آن را بردارید و سپس ناحیه ی زمانی خود را مشخص کنید. به عنوان مثال برای ایران: date.timezone = "Asia/Tehran"

  • جمعه ۳ آذر ۹۱

تنظیم پیش فرض موتور جستجوی فایرفاکس در نوار آدرس برای گوگل

در نوار آدرس تایپ کنید: about:config
در search تایپ کنید: keyword.URL
مقدار https://www.google.com/search?q= را در keyword.URL مقدار دهی کنید(= در آخر است).

  • سه شنبه ۳۰ آبان ۹۱

مدیریت کاربران در ابونتو 12.04

اگر در مدیریت کاربران در این توزیع به مشکل برخوردید:
مسیر فایل کابران /etc/passwd  و فایل گرو ها /etc/group
برای اضافه کردن کابر به یک گروه.
usermod -a -G group-name user-name
نصب ابزار UI که Unity فعلا از آن بی بهره است:
sudo apt-get install gnome-system-tools
دستور اجرای برنامه:
users-admin
  • جمعه ۲۶ آبان ۹۱

The pattern used in Doctrine ORM

Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a  technique for converting data between incompatible type systems in object-orinted programming languages. read more

I found 2 pattern for implementing ORM, one ActiveRecord  and other is Data Mapper + Unit Of Work
For example php-activerecord is a open source ORM uses ActiveRecord, and Doctrind uses Data Mapper + Unit Of Work, Doctrine is also open source.

#Doctrin IRC channel
(02:58:48 PM)
msoa: In wiki quotes "Doctrine 1.x follows the active record pattern for working with data, ", my question is that in Doctrine 2 what is the pattern used?
(03:00:32 PM) ocramius: msoa: data mapper + unit of work
(03:02:59 PM) msoa: ocramius: what's "unit of work"?
(03:04:41 PM) msoa: where i can find an atricle about why Doctine leave the ActiveRecord?
(03:08:35 PM) ocramius: msoa: http://martinfowler.com/eaaCatalog/unitOfWork.html
(03:08:43 PM) ocramius: msoa: http://martinfowler.com/eaaCatalog/dataMapper.html
(03:09:31 PM) ocramius: msoa: that's basically how the JavaEE ORM works too btw. In activerecord, you tend to delegate too much responsibility to your "entity", which instead should be dumb
(03:09:41 PM) ocramius: also, you're forced to extend entities from a base record class
(03:09:53 PM) ocramius: with the data mapper, anything could be an entity
(03:14:17 PM) msoa: ocramius: Thanks a lot


  • جمعه ۱۲ آبان ۹۱

ORM anti-pattern

ORM anti-pattern
  • شنبه ۲۲ مهر ۹۱

اتوماسیون صف های سوخت

تا کی باید هزاران هزار سال عمر این ملت در صف های سوخت جا بماند! دولت الکترونیک کجا جا مانده! این که دیگر یک مشکل عمومی است.
حتما شاهد صف های طولانی مدت سوخت (گاز، بنزین و ...) در دیار خود بوده اید. و احتمالا با خود گفته اید چرا این مشکل را با نرم افزاری که هزینه چندانی هم ندارد(در مقابل عمرهای حدر رفته)، تا حدودی حل نمی کنند.
تقریبا دو سال پیش گذرا در فکرم چیزهایی رد می شد، ولی با خود می گفتم بی خیال حتما الان دارن روش کار می کنند. اما پس از گذشت این چند وقت هم تحرکی دیده نمی شود، حداقل در رسانه های عمومی که خبری نیست.
امروزه اکثر مردم حداقل از یک گوشی ساده برخوردار هستند. پس یک سیستم نوبت دهی جامع پیام کوتاه نباید از لحاظ فرهنگی کار زیادی داشته باشد.
  • شنبه ۱ بهمن ۹۰
موضوعات