video controller:json to text file conver and also more action

<?php

class VediodescController extends Controller {

    /**
     * @var string the default layout for the views. Defaults to '//layouts/column2', meaning
     * using two-column layout. See 'protected/views/layouts/column2.php'.
     */
    public $layout = '//layouts/column2';

    /**
     * @return array action filters
     */
    public function filters() {
        return array('accessControl', // perform access control for CRUD operations
        'postOnly + delete', // we only allow deletion via POST request
        );
    }

    /**
     * Specifies the access control rules.
     * This method is used by the 'accessControl' filter.
     * @return array access control rules
     */
    public function accessRules() {
        return array( array('allow', // allow all users to perform 'index' and 'view' actions
        'actions' => array('index', 'view','status_users','deleted_users','user_login','register','getcountry','import'), 'users' => array('*'), ), array('allow', // allow authenticated user to perform 'create' and 'update' actions
        'actions' => array('create', 'update', 'categoryJson', 'languageJson', 'create_lessons', 'lessonsJson','sendMail_reply','admin_srequest','admin_Users'), 'users' => array('*'), ), array('allow', // allow admin user to perform 'admin' and 'delete' actions
        'actions' => array('admin', 'delete', 'status', 'getservice', 'admin_lessons', 'lesson_status', 'update_lessons', 'delete_lesson','getPassword','readjson'), 'users' => array('*'), ),/* array('deny', // deny all users
        'users' => array('*'), ),*/ );
    }

    public function actionStatus($id) {

        $model = $this -> loadModel($id);
        if ($model -> status == '0')
            $model -> status = '1';
        else
            $model -> status = '0';
        $model -> update();

        if (isset($_GET['ajax'])) {

            Yii::app() -> user -> setFlash('success', 'You have successfully updated a record');
            echo "<div class='flash-success'>You have successfully updated a record</div>";
        }

    }

    public function actionReadjson()
    {
            //print_r(Yii::app()->basePath.'/upload.txt');
            echo "<pre>";
        //singamorekaraoke/KARAOKEChannelIntl
        $json=file_get_contents('http://gdata.youtube.com/feeds/api/users/singamorekaraoke/uploads?alt=json&start-index=1&max-results=50', true);
        $json=str_replace('},]',"}]",$json);
        $data = json_decode($json,true);
        $total=$data['feed']['openSearch$totalResults']['$t'];
        //echo "<pre>";
        $startlimit=1;
        $fh = fopen(Yii::app()->basePath."/alllist.txt", "w") or die("Could not open log file.");
        for($i=0;$i<($total/50);$i++)
        {
           
            $json=file_get_contents('http://gdata.youtube.com/feeds/api/users/KARAOKEChannelIntl/uploads?alt=json&start-index='.$startlimit.'&max-results=50', true);
            $json=str_replace('},]',"}]",$json);
            $data = json_decode($json,true);
            foreach($data['feed']['entry'] as $key =>$linkData)
            {
                   
                    fwrite($fh, $linkData['link']['0']['href']."\n") or die("Could not write file!");
                    fwrite($fh,'<br>');
               
               
               
            }
            $startlimit =$startlimit + 50;
        }
        fclose($fh);
        exit;
        //echo "</pre>";
        //print_r( json_last_error());
       
    }

    /**
     * Displays a particular model.
     * @param integer $id the ID of the model to be displayed
     */
    public function actionCategoryJson() {

        $category = $_GET['caption'];

        $criteria = new CDbCriteria;
        $criteria -> condition = "t.caption='" . $category . "'AND t.status=1  AND t.deleted=1";

        $model = Vediodesc::model() -> findAll($criteria);
        $data = Array();
        foreach ($model as $val) {
            $data[] = array("category" => $val -> caption, "language" => $val -> language, "link" => $val -> vedio_link, "title" => $val -> title, "description" => $val -> desc, "thumbnail" =>$val -> thumb, "status" => $val -> status);
        }

        echo json_encode(array("type" => "ok", "result" => array("youtube" => $data)));

    }
   

    public function actionLanguageJson() {

        $language = $_GET['language'];
        //print_r($language);exit;

        $criteria = new CDbCriteria;
        $criteria -> condition = "t.language='" . $language . "' AND t.status=1 AND t.deleted=1";
        $model = Vediodesc::model() -> findAll($criteria);

        $data = Array();
        foreach ($model as $val) {
            $data[] = array("category" => $val -> caption, "language" => $val -> language, "link" => $val -> vedio_link, "title" => $val -> title, "description" => $val -> desc, "thumbnail" => $val -> thumb, "status" => $val -> status);
        }

        echo json_encode(array("type" => "ok", "result" => array("youtube" => $data)));

    }

    public function actionView($id) {
        $this -> render('view', array('model' => $this -> loadModel($id), ));
    }

    /**
     * Creates a new model.
     * If creation is successful, the browser will be redirected to the 'view' page.
     */
    public function actionCreate() {
        $model = new Vediodesc();
        //  $model->unsetAttributes();
        $this->performAjaxValidation($model);
        if (isset($_POST['Vediodesc'])) {

            $model -> attributes = $_POST['Vediodesc'];

           

            $model -> status = 1;
           
            preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $_POST['Vediodesc']['vedio_link'], $matches);
            $id=$matches[0];
               
            $thumb1='http://img.youtube.com/vi/'.$id.'/mqdefault.jpg';
            $model -> thumb =$thumb1;
            $model -> title = $_POST['Vediodesc']['title'];
            $model -> desc = $_POST['Vediodesc']['desc'];
            $model -> save();

            $this -> redirect(array('index', 'id' => $model -> id));
        }

        $this -> render('create', array('model' => $model, ));
    }

   

   

    /**
     * Updates a particular model.
     * If update is successful, the browser will be redirected to the 'view' page.
     * @param integer $id the ID of the model to be updated
     */
    public function actionUpdate($id) {
        $model = $this -> loadModel($id);
           
        if (isset($_POST['Vediodesc'])) {
            $model -> attributes = $_POST['Vediodesc'];
            preg_match("#(?<=v=)[a-zA-Z0-9-]+(?=&)|(?<=v\/)[^&\n]+|(?<=v=)[^&\n]+|(?<=youtu.be/)[^&\n]+#", $_POST['Vediodesc']['vedio_link'], $matches);
            $id=$matches[0];
            $thumb1='http://img.youtube.com/vi/'.$id.'/mqdefault.jpg';
            $model -> thumb =$thumb1;
            $model -> title =$_POST['Vediodesc']['title'];
            $model -> desc = $_POST['Vediodesc']['desc'];
       
            $model -> update();
            $this -> redirect(array('view', 'id' => $model -> id));
        }

        $this -> render('update', array('model' => $model, ));
    }

    public function actionDelete($id) {
        $model=$this -> loadModel($id);
        $model->deleted=0;
        $model->update();
        // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
        if (!isset($_GET['ajax']))
            $this -> redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
    }
   

   
    /**
     * Lists all models.
     */
    public function actionIndex() {
        $dataProvider = new CActiveDataProvider('Vediodesc');
        $this -> render('index', array('dataProvider' => $dataProvider, ));
    }

    /**
     * Manages all models.
     */
    public function actionAdmin() {
        $model = new Vediodesc('search');
        $model -> unsetAttributes();
        // clear any default values
        if (isset($_GET['Vediodesc']))
            $model -> attributes = $_GET['Vediodesc'];

        $this -> render('admin', array('model' => $model, ));
    }
   
   
    public function actionImport(){
         Yii::import('ext.phpexcelreader.JPhpExcelReader');
       
        $model = new Vediodesc('import');
        $this->performAjaxValidation_import($model);
        /*$model->file = $_FILES['Vediodesc']['name']['file'];
            move_uploaded_file($_FILES['Vediodesc']['tmp_name']['file'], Yii::app()->basePath ."/temp/". $model->file);*/
        if (isset($_POST['Vediodesc']['file'])) {
            $model->file = $_FILES['Vediodesc']['name']['file'];
            move_uploaded_file($_FILES['Vediodesc']['tmp_name']['file'], Yii::app()->basePath ."/temp/". $model->file);
            $data = new JPhpExcelReader(Yii::app()->basePath ."/temp/". $model->file);
       
            $sheet=0;
         $rowcount = $data->rowcount($sheet);
   
        $linkarray=CHtml::listData(Vediodesc::model()->findAll(array("condition"=>"status=1 AND deleted=1")),'vedio_link','vedio_link');
        echo "<pre>";
        $matcharray=array();
        foreach($linkarray as $val)
        {
            $matcharray[]=$val;
        }
       
        for ($i = 2; $i <= $rowcount; ++$i)
        {
             if(!in_array($data->val($i,1), $matcharray))
             {
                 $model1 = new Vediodesc();
                 $model1 -> vedio_link=$data->val($i,1);
                 preg_match("/^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=|\&v=)([^#\&\?]{11,11}).*/", $data->val($i,1). '&', $m);
                 $video_id = $m[2];
                 $youtube = 'http://gdata.youtube.com/feeds/api/videos/'.$video_id.'?v=2&alt=json';
                 $ch = curl_init($youtube);
                 curl_setopt($ch, CURLOPT_HEADER, false);
                 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
                 $output = curl_exec($ch);
                 curl_close($ch);
                 $output = json_decode($output,true);
                 if (isset($output['feed'])) {
                    $path = &$output['feed']['entry'];
                     } else {
                    $path = &$output['entry'];
                 }
                 $model1->title= $path['title']['$t'];
                 $model1->desc=$path['media$group']['media$description']['$t'];
                 $model1->caption=$data->val($i,3);
                 $model1->language=$data->val($i,2);
           
                 $model1->thumb='http://img.youtube.com/vi/'.$video_id.'/mqdefault.jpg';
                 if($model1 -> save())
                 {
                
                 }
                 else {
                     echo"<pre>";
                 print_r($model1->getErrors());exit;
                 }
             }
        }   
        array_map('unlink', glob(Yii::app()->basePath ."/temp/*"));
        $this -> redirect(array('admin'));
           
        }
       
        $this -> render('import', array('model' => $model, ));
       
    }
   
   
    /*function get_youtube_info ( $vid, $info ) {
        $youtube = 'http://gdata.youtube.com/feeds/api/videos/'.$vid.'?v=2&alt=json';
        $ch = curl_init($youtube);
        curl_setopt($ch, CURLOPT_HEADER, false);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        $output = curl_exec($ch);
        curl_close($ch);

    //If $assoc = true doesn't work, try:
    //$output = json_decode($output, true);
            $output = json_decode($output,true);
    //echo "<pre>";
//    print_r($output);exit;
    //Add the ['feed'] in if it exists.
    $path = $output['entry'];
    /*    if (isset($output['feed'])) {
            $path = &$output['feed']['entry'];
            } else {
            $path = &$output['entry'];
        }*/

    //set up a switch to return various data bits to return.
   /* switch($info) {
        case 'title':
            $output = $path['title']['$t'];
            break;
        case 'description':
            $output = $path['media$group']['media$description']['$t'];
            break;
        case 'author':
            $output = $path['author'][0]['name'];
            break;
        case 'author_uri':
            $output = $path['author'][0]['uri'];
            break;
        case 'thumbnail_small':
            $output = $path['media$group']['media$thumbnail'][0]['url'];
            break;
        case 'thumbnail_medium':
            $output = $path['media$group']['media$thumbnail'][2]['url'];
            break;
        case 'thumbnail_large':
            $output = $path['media$group']['media$thumbnail'][3]['url'];
            break;
        default:
            return $output;
            break;
    }
    return $output;
}*/



    /**
     * Returns the data model based on the primary key given in the GET variable.
     * If the data model is not found, an HTTP exception will be raised.
     * @param integer $id the ID of the model to be loaded
     * @return Vediodesc the loaded model
* @throws CHttpException     */

    public function loadModel($id) {
        $model = Vediodesc::model() -> findByPk($id);
        if ($model === null)
            throw new CHttpException(404, 'The requested page does not exist.');
        return $model;
    }
   
   
   
    /**********************************************************************this section for song lessons**********************************************/

   
   
   
public function actionCreate_lessons() {
        $model = new MusicLessons();
        //  $model->unsetAttributes();
        $model1 = new MusicLessons('search');
        $this->performAjaxValidation_lessons($model);
        if (isset($_POST['MusicLessons'])) {
           
            $model -> attributes = $_POST['MusicLessons'];
           
            $model -> status = 1;

            // $model->title=$_POST['Vediodesc']['title'];
            // $model->desc=$_POST['Vediodesc']['desc'];
            $model -> save();

            $this -> redirect(array('admin_lessons', 'id' => $model -> l_id));
        }

        $this -> render('create_lessons', array('model' => $model, ));
    }
   
   
    public function actionLessonsJson() {

        //   $language=$_GET['lesson'];
        //print_r($language);exit;

        $criteria = new CDbCriteria;
        $criteria -> condition = "t.deleted= 1 AND t.status=1 AND  t.deleted=1";
        $model = MusicLessons::model() -> findAll($criteria);

        $data = Array();
        foreach ($model as $val) {
            $data[] = array("title" => $val -> title, "description" => $val -> description, "status" => $val -> status);
        }

        echo json_encode(array("type" => "ok", "result" => array("Music Lessons" => $data)));

    }
   
    public function actionUpdate_lessons($id) {
        $model = $this -> loadModel_lessons($id);
        $model1 = new MusicLessons('search');

        if (isset($_POST['MusicLessons'])) {
            $model -> attributes = $_POST['MusicLessons'];

            //$model->desc=$_POST['Vediodesc']['desc'];
            $model -> save();

            $this -> redirect(array('admin_lessons', 'id' => $model -> l_id));
        }

        $this -> render('uptate_lessons', array('model' => $model, ));
    }
   
    public function actionLesson_status($id) {

        $model = $this -> loadModel_lessons($id);
        if ($model -> status == '0')
            $model -> status = '1';
        else
            $model -> status = '0';
        $model -> update();

        if (isset($_GET['ajax'])) {

            Yii::app() -> user -> setFlash('success', 'You have successfully updated a record');
            echo "<div class='flash-success'>You have successfully updated a record</div>";
        }

    }

public function actionDelete_lesson($id) {
        $model=$this -> loadModel_lessons($id);
        $model->deleted=0;
        $model->update();
        // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
        if (!isset($_GET['ajax']))
            $this -> redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
    }

    public function actionAdmin_lessons() {
        $model = new MusicLessons('search');
        $model -> unsetAttributes();
        // clear any default values
        if (isset($_GET['MusicLessons']))
            $model -> attributes = $_GET['MusicLessons'];

        $this -> render('admin_lessons', array('model' => $model, ));
    }
    /**
     * Deletes a particular model.
     * If deletion is successful, the browser will be redirected to the 'admin' page.
     * @param integer $id the ID of the model to be deleted
     */
   
   
    public function loadModel_lessons($id) {
        $model = MusicLessons::model() -> findByPk($id);
        if ($model === null)
            throw new CHttpException(404, 'The requested page does not exist.');
        return $model;
    }





    /*******************************************  this section used for song request ******************************************************************/
   
   
   
   
    public function actionSendMail_reply() {
           
        $SM         = Yii::app()->swiftMailer;
        $content = "<p>Dear ".$_GET['Fname']."</p><p>your request for song ". $_GET['Song']." is under process.</p>";

        $plainTextContent = "This is my Plain Text Content for those with cheap emailclients ;-)\nThis is my second row of text";

        /*mail.sportsbamgame.com,test@sportsbamgame.com,6G4)L05,Rfq&,test.drcsystems,raju4321*/
       
        $mailHost = 'tls://smtp.gmail.com';//mail.sportsbamgame.com//smtp.gmail.com
       
        $mailPort = 465;
       
        $Transport = $SM->smtpTransport($mailHost, $mailPort)->setUsername('test.drcsystems')->setPassword('raju4321');
       
        $Mailer = $SM->mailer($Transport);
// New message
        $Message = $SM -> newMessage('Karaoke')
                     ->  setFrom(array('bharat.131989@gmail.com' => 'Karaoke'))
                     ->  setTo(array($_GET['Email'] => $_GET['Fname']))
                     ->  addPart($content, 'text/html') -> setBody($plainTextContent);

        // Send mail
       
        $result = $Mailer -> send($Message);
       
        $model = new SongRequest();
       
       

            $model ->fname= isset($_GET['Fname'])?$_GET['Fname']:"";
            $model ->lname= isset($_GET['Lname'])?$_GET['Lname']:"";
            $model ->email= isset($_GET['Email'])?$_GET['Email']:"";
            $model ->song= isset($_GET['Song'])?$_GET['Song']:"";
            $model ->movie= isset($_GET['Movie'])?$_GET['Movie']:"";
            if($model -> save())
            {
           
                if($result==1)
                {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'yes')));
                }
                else
                {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'no')));
                }
        }
        else {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'no')));
            }
       
    }

public function actionAdmin_srequest() {
        $model = new SongRequest('search');
        $model -> unsetAttributes();
        // clear any default values
        if (isset($_GET['SongRequest']))
            $model -> attributes = $_GET['SongRequest'];

        $this -> render('admin_srequest', array('model' => $model, ));
    }





/*******************************************  this section used for user registration ******************************************************************/   






public function actionRegister()
{
        $model=new UsersDetails();
        $email=$_REQUEST['email'];
        $model1=UsersDetails::model()->findByAttributes(array('email'=>$email));
        if(isset($model1->email))
        {
            echo json_encode(array("type" => "ok", "result" => array("result" => 'email allreay exist')));
        }
        else {
                $model->firstname=$_REQUEST['firstname'];
                $model->lastname=$_REQUEST['lastname'];
                $model->email=$_REQUEST['email'];
                if($_REQUEST['sign_type']==2)
                    $model->password=$this->passencrypt($_REQUEST['password']);
                $model->country=$_REQUEST['country'];
                $model->status=1;
                $model->deleted=1;
                $model->sign_type=$_REQUEST['sign_type'];
                if($model->save())
                {
                                echo json_encode(array("type" => "ok", "result" => array("result" => 'yes')));
                   
                }
                else
                 {
                                echo json_encode(array("type" => "ok", "result" => array("result" => 'no')));
                       
                }
        }
       
       
       
           
}


public function actionUser_login()
{
        $model=new UsersDetails();
        if(isset($_REQUEST['sign_type']) && $_REQUEST['sign_type']==1)
        {
            $email=$_REQUEST['email'];
            $model1=UsersDetails::model()->findByAttributes(array('email'=>$email));
            if(isset($model1->email))
            {
                if($model1->status==0 ){
                       
                    echo json_encode(array("type" => "ok", "result" => array("result" => 'You may be inactive ,please contact admin')));
                }
                else{
                    if($model1->sign_type==$_REQUEST['sign_type'])
                        echo json_encode(array("type" => "ok", "result" => array("result" => 'login succesfully')));
                    else {
                        echo json_encode(array("type" => "ok", "result" => array("result" => 'you need to login normaly.')));
                    }
                }
            }
            else
            {
                $model->firstname=$_REQUEST['firstname'];
                $model->lastname=$_REQUEST['lastname'];
                $model->email=$_REQUEST['email'];
               
                $model->country=$_REQUEST['country'];
                $model->status=1;
                $model->deleted=1;
                $model->sign_type=$_REQUEST['sign_type'];
                if($model->save())
                {
                                echo json_encode(array("type" => "ok", "result" => array("result" => 'login succesfully')));
                   
                }
                else
                 {
                                echo json_encode(array("type" => "ok", "result" => array("result" => 'login fail')));
                       
                }
            }
           
        }
        else
        {
            $email=$_REQUEST['email'];
            $model1=UsersDetails::model()->findByAttributes(array('email'=>$email,'deleted'=>1));
            if(isset($model1->email) && $_REQUEST['password']==$this->passdecrypt($model1->password))
            {
                if($model1->status==0 ){
                    echo json_encode(array("type" => "ok", "result" => array("result" => 'You may be inactive ,please contact admin')));
                }
                else
               
                        echo json_encode(array("type" => "ok", "result" => array("result" => 'login succesfully')));
                   
                   
            }
            else {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'username or password incorrect')));
            }
        }
       
       
   
}
       
public function actionGetcountry()
    {
        $lang=  UsersDetails::model()->findall();
        $langArray = CHtml::listData($lang,'country','country');   
         //     echo "<pre>";
           //     print_r($langArray);exit;
         $data = Array();
        foreach ($langArray as $key=>$val) {
            $data[] = array("country" =>$val);
        }
   
        echo json_encode(array("type" => "ok", "result" => array("youtube" => $data)));
       
    }   
   
public function actionAdmin_Users() {
        $model = new UsersDetails('search');
        $model -> unsetAttributes();
        // clear any default values
        if (isset($_GET['Usersdetails']))
            $model -> attributes = $_GET['Usersdetails'];

        $this -> render('admin_users', array('model' => $model, ));
    }

public function actionStatus_users($id) {

        $model = UsersDetails::model() -> findByPk($id);
        if ($model -> status == '0')
            $model -> status = '1';
        else
            $model -> status = '0';
        $model -> update();

        if (isset($_GET['ajax'])) {

            Yii::app() -> user -> setFlash('success', 'You have successfully updated a record');
            echo "<div class='flash-success'>You have successfully updated a record</div>";
        }

    }

public function actionDeleted_users($id) {
        $model=UsersDetails::model() -> findByPk($id);
        $model->deleted=0;
        $model->update();
        // if AJAX request (triggered by deletion via admin grid view), we should not redirect the browser
        if (!isset($_GET['ajax']))
            $this -> redirect(isset($_POST['returnUrl']) ? $_POST['returnUrl'] : array('admin'));
    }

public function actionGetPassword()
{
    $email=$_REQUEST['Email'];
    $model=UsersDetails::model()->findByAttributes(array('email'=>$email));
    $result=0;
    if(isset($model))
    {
        if(isset($model->password))
        {
        $pass=$this->passdecrypt($model->password);
       
        $SM         = Yii::app()->swiftMailer;
        $content = "<p>Dear ".$model->firstname.",</p><p>your password is ". $pass." .</p>";

        $plainTextContent = "This is my Plain Text Content for those with cheap emailclients ;-)\nThis is my second row of text";

        $mailHost = 'tls://smtp.gmail.com';
       
        $mailPort = 465;
       
        $Transport = $SM->smtpTransport($mailHost, $mailPort)->setUsername('test.drcsystems')->setPassword('raju4321');
       
        $Mailer = $SM->mailer($Transport);
// New message
        $Message = $SM -> newMessage('Karaoke Forgot password')
                     ->  setFrom(array('bharat.131989@gmail.com' => 'Karaoke'))
                     ->  setTo(array($email => $model->firstname))
                     ->  addPart($content, 'text/html') -> setBody($plainTextContent);

        // Send mail
       
        $result = $Mailer -> send($Message);
        }
        else {
            echo json_encode(array("type" => "ok", "result" => array("result" => 'no password available for this account.')));
        }
       
       
    }
else
    {
        echo json_encode(array("type" => "ok", "result" => array("result" => 'this user is not present')));
    }
    if($result==1)
                {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'mail sent')));
                }
                else
                {
                echo json_encode(array("type" => "ok", "result" => array("result" => 'mail sending failure ! please check yuor email')));
                }
   
}
public static function passencrypt($str, $lngth = 16) {
        $str = substr($str, 0, $lngth);
        $str = str_pad($str, $lngth, " ");
        $retstr = "";
        for ($i = 0; $i < $lngth; $i++) {
            $sch = substr($str, $i, 1);
            $iasc = ord($sch) + 2 * $i + 30;
            if ($iasc > 255)
                $iasc = $iasc - 255;
            $sch = chr($iasc);
            $retstr = $retstr . $sch;
        }
        $retstr = implode("*", unpack('C*', $retstr));
        return $retstr;
    }

    public static function passdecrypt($pass) {
        $retstr = "";
        $string = "";
        $data = explode('*', $pass);
        for ($i = 0; $i < count($data); $i++) {
            if ($data[$i] != '') {
                $string = $string . pack('C*', $data[$i]);
            }
        }
        $str = $string;
        $lngth = strlen($str);
        for ($i = 0; $i < $lngth; $i++) {
            $sch = substr($str, $i, 1);
            $iasc = ord($sch) - 2 * $i - 30;
            if ($iasc <= 0)
                $iasc = 255 + $iasc;
            $sch = chr($iasc);
            $retstr = $retstr . $sch;
        }
        return trim($retstr);
    }

   

    /**
     * Performs the AJAX validation.
     * @param Vediodesc $model the model to be validated
     */
    protected function performAjaxValidation($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'vediodesc-form') {
            echo CActiveForm::validate($model);
            Yii::app() -> end();
        }
    }

    protected function performAjaxValidation_lessons($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'lessons-form') {
            echo CActiveForm::validate($model);
            Yii::app() -> end();
        }
    }
    protected function performAjaxValidation_import($model) {
        if (isset($_POST['ajax']) && $_POST['ajax'] === 'form_import') {
            echo CActiveForm::validate($model);
            Yii::app() -> end();
        }
    }
   

}

Comments