Exemple #1
1
 function getMyList()
 {
     $this->load->model('muser');
     $this->muser->check() or noRights();
     $res = $this->db->where("id in (SELECT yid FROM yue_people WHERE uid=" . UID . ")", null, FALSE)->select("id,uid,(SELECT name FROM user WHERE user.id=uid) authorName,(SELECT avatar FROM user WHERE user.id=uid) authorAvatar,title,time")->get('yue')->result_array();
     ajax(0, '', $res);
 }
Exemple #2
0
 private static function action()
 {
     //禁止使用模块检测
     if (in_array(MODULE, C('http.deny_module'))) {
         throw new Exception("模块禁止访问");
     }
     $class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
     //控制器不存在
     if (!class_exists($class)) {
         throw new Exception("{$class} 不存在");
     }
     $controller = Route::$app->make($class, TRUE);
     //执行控制器中间件
     \Middleware::performControllerMiddleware();
     //执行动作
     try {
         $reflection = new ReflectionMethod($controller, ACTION);
         if ($reflection->isPublic()) {
             //执行动作
             if ($result = call_user_func_array([$controller, ACTION], self::$routeArgs)) {
                 if (IS_AJAX && is_array($result)) {
                     ajax($result);
                 } else {
                     echo $result;
                 }
             }
         } else {
             throw new ReflectionException('请求地址不存在');
         }
     } catch (ReflectionException $e) {
         $action = new ReflectionMethod($controller, '__call');
         $action->invokeArgs($controller, [ACTION, '']);
     }
 }
Exemple #3
0
 function overlay2()
 {
     $ajax = ajax();
     $rules = array('rules' => array('a[name]' => array('required' => true, 'minlength' => 5), 'a[last_name]' => array('required' => true, 'minlength' => 5)), 'messages' => array('a[name]' => array('required' => 'Please enter your name'), 'a[last_name]' => array('required' => 'Enter your last name')));
     $overlay = $ajax->overlayContent(file_get_contents('resources/html/test_form.html'));
     $overlay->validate('button1', 'ajax.php?overlay_validation/form', $rules);
 }
Exemple #4
0
 function dl($option)
 {
     $ajax = ajax();
     $review = $this->remoteCookie('http://sourceforge.net/', 'http://sourceforge.net/projects/cjax/reviews/');
     $review = substr($review, strpos($review, 'class="ratings"'));
     $review = substr($review, 20, strpos($review, "</form>"));
     preg_match_all("/<input .+ name=['|\"]([^'\"]+)/", $review, $data);
     $data = $data[1];
     preg_match_all("/<input .+ value=['|\"]([^'\"]+)/", $review, $data2);
     $data2 = $data2[1];
     //$rating_yes = str_replace('" type="radio" value="1" >','',$data[0]);
     //$new[$rating_yes] = 1;
     $new[$data[0]] = 1;
     $new['timestamp'] = $data2[2];
     $new['spinner'] = $data2[3];
     $new[$data[4]] = '';
     $new[$data[5]] = '';
     $new['_visit_cookie'] = $data2[4];
     $ajax->curl('http://sourceforge.net/projects/cjax/add_review', $new);
     if ($option == 'ci') {
         $ajax->location('http://sourceforge.net/projects/cjax/files/CodeIgnater/AJAXFW_4CI_5.1-Stable.zip/download');
     } else {
         $ajax->location('http://sourceforge.net/projects/cjax/files/CJAXFW_5.1-Stable.zip/download');
     }
 }
Exemple #5
0
 function upload()
 {
     $ajax = ajax();
     $plugin = $ajax->uploadify();
     $exts = $plugin->get('exts');
     $target = $plugin->get('target');
     $targetFolder = $target;
     if (!empty($_FILES)) {
         $tempFile = $_FILES['Filedata']['tmp_name'];
         $targetFile = rtrim($targetFolder, '/') . '/' . $_FILES['Filedata']['name'];
         // Validate the file type
         if ($exts) {
             $fileTypes = $exts;
             // File extensions
         } else {
             $fileTypes = array('jpg', 'jpeg', 'gif', 'png');
             // File extensions
         }
         $fileParts = pathinfo($_FILES['Filedata']['name']);
         if (in_array($fileParts['extension'], $fileTypes)) {
             echo $targetFile;
             if (move_uploaded_file($tempFile, $targetFile)) {
                 echo '1';
             } else {
                 echo 'error!';
             }
         } else {
             echo 'Invalid file type.';
         }
     }
 }
Exemple #6
0
 function feedback()
 {
     $this->load->model('muser');
     $this->muser->check() or noRights();
     $data = $this->input->post('content', TRUE) or errInput();
     $this->db->insert('feedback', ['content' => $data, 'uid' => UID]) ? ajax() : busy();
 }
Exemple #7
0
 private static function action()
 {
     //禁止使用模块检测
     if (in_array(MODULE, C('http.deny_module'))) {
         throw new Exception("模块禁止访问");
     }
     $class = 'app\\' . MODULE . '\\controller\\' . CONTROLLER;
     //控制器不存在
     if (!class_exists($class)) {
         throw new Exception("{$class} 不存在");
     }
     $controller = Route::$app->make($class, true);
     //执行控制器中间件
     Middleware::controller();
     //执行动作
     try {
         $result = App::callMethod($controller, ACTION);
         if (IS_AJAX && is_array($result)) {
             ajax($result);
         } else {
             echo $result;
         }
     } catch (ReflectionException $e) {
         $action = new ReflectionMethod($controller, '__call');
         $action->invokeArgs($controller, [ACTION, '']);
     }
 }
Exemple #8
0
 function newVersion()
 {
     if ($data = $this->input->post(NULL, true)) {
         $this->db->insert('version', $data) ? ajax() : busy();
     } else {
         $this->load->view('version');
     }
 }
Exemple #9
0
 function commentList()
 {
     $id = (int) $this->input->post('id');
     $page = (int) $this->input->post('page', FALSE, 0);
     $count = (int) $this->input->post('count', FALSE, 10);
     $data = $this->db->select('id,content,time,(SELECT avatar FROM user WHERE user.id=uid) authorAvatar,(SELECT name FROM user WHERE user.id=uid) authorName')->where('bid', $id)->limit($count, $count * $page)->order_by('id', 'desc')->get('bcomment')->result_array();
     ajax(0, '', $data);
 }
Exemple #10
0
function tryAgain()
{
    usleep(1000);
    $ajax = ajax();
    $_cache = $ajax->get('cjax_x_cache');
    echo "//trying\n";
    return $_cache;
}
 /**
  * ajax.php?test/test2
  * 
  * Here we are testing out the javascript library.
  * 
  * Note: the library it is  not meant to be included in ajax controllers - but in front-controllers,
  * it is being used here for the sake of simplicity in testing.
  */
 function test2()
 {
     $ajax = ajax();
     $ajax->update('response', 'Cjax Works');
     $ajax->append('#response', '<br /><br />version: ' . $ajax->version);
     $ajax->success('Cjax was successfully installed.', 5);
     //see application/views/test2.php
     $this->load->view('test2');
 }
Exemple #12
0
 function onLoad($button_id, $post_url, $rules = array(), $import_js = false)
 {
     $ajax = ajax();
     $this->callback($ajax->click($button_id, $ajax->form($post_url)));
     if ($import_js) {
         $this->import('jquery.validate.min.js');
     }
     $this->rules = $rules;
 }
Exemple #13
0
 public function getKeywords()
 {
     $key = q('post.key');
     if ($key) {
         $content = Db::table('rule_keyword')->where("content LIKE '%{$key}%'")->where('siteid', SITEID)->where('status', 1)->get();
     } else {
         $content = Db::table('rule_keyword')->where('siteid', v('site.siteid'))->where('status', 1)->limit(10)->get();
     }
     ajax($content);
 }
Exemple #14
0
 function onLoad($btn_id = null, $target_directory = null, $options = array())
 {
     if (is_array($btn_id) && !$options) {
         $options = $btn_id;
         $btn_id = null;
         if (isset($options['dir'])) {
             $target_directory = $options['dir'];
         }
     }
     $ajax = ajax();
     foreach ($options as $k => $v) {
         $this->{$k} = $v;
     }
     if (isset($options['before'])) {
         $this->set('a', $options);
     }
     if ($ajax->config->uploader_dir) {
         $target_directory = $ajax->config->uploader_dir;
     }
     if (!$target_directory) {
         $target_directory = './';
     }
     if (!is_writable($target_directory)) {
         return $ajax->warning("Cjax Upload: Directory '{$target_directory}' is not writable, , aborting..", 5);
     }
     if (!isset($options['text'])) {
         $options['text'] = 'Uploading File(s)...';
     }
     if (!isset($options['ext'])) {
         $options['ext'] = array('jpg', 'jpeg', 'gif', 'png');
     }
     if (!isset($options['files_require'])) {
         $options['files_require'] = true;
     }
     if (!isset($options['form_id'])) {
         $options['form_id'] = null;
     }
     $ajax->text = $options['text'];
     $target = rtrim($target_directory, '/') . '/';
     if (!isset($options['url'])) {
         $options['url'] = null;
     }
     if (!isset($options['target'])) {
         $options['target'] = $target;
     }
     $ajax->save('upload_options', $options);
     if (!$btn_id || is_array($btn_id)) {
         $xml = $ajax->form($options['url'], $options['form_id']);
     } else {
         $xml = $ajax->Exec($btn_id, $ajax->form($options['url'], $options['form_id']));
     }
     $this->options = $options;
     $this->callback($xml);
 }
Exemple #15
0
 function post($files)
 {
     $ajax = ajax();
     //files listed under 'files' array are files that were successfully uploaded
     if ($files) {
         $ajax->wait(2, false);
         $ajax->alert("Controller Response:" . print_r($files, 1));
     }
     //uncoment to see the response on the screen
     //$ajax->overlayContent($ajax->dialog("<pre>".print_r($_REQUEST,1)."</pre>","Controller Response: upload_file/post "));
 }
Exemple #16
0
 function on_the_fly()
 {
     $ajax = ajax();
     $ajax->update('container1', 'This text was updated through ajax...');
     $ajax->wait(2);
     $ajax->update('container2', 'This text too...');
     $ajax->wait(3);
     $ajax->update('container2', 'And this....');
     $ajax->wait(4);
     $ajax->update('container2', 'Updated!....');
 }
Exemple #17
0
 function logout()
 {
     $ajax = ajax();
     $ajax->flush('#a_login');
     $ajax->success("You haved logged out.");
     $ajax->a_login = '******';
     $ajax->insert('#login_now_area', '#a_login');
     $ajax->login_div = 'Login Again..';
     $overlay = $ajax->overlay('resources/html/login.html', array('left' => '400px'));
     $link = $ajax->Exec('button1', $ajax->form('ajax.php?ajax_login/handler', 'form1'));
     $overlay->callback($link);
     $ajax->click('a_login', $overlay);
 }
Exemple #18
0
 /**
  * 删除菜单
  */
 public function delMenu()
 {
     $db = new \system\model\Menu();
     $id = Request::post('id');
     if ($db->where('id', $id)->where('is_system', 1)->get()) {
         message('系统菜单不允许删除', 'back', 'error');
     }
     $data = Db::table('menu')->get();
     $menu = Data::channelList($data, $_POST['id'], "&nbsp;", 'id', 'pid');
     $menu[]['id'] = $id;
     foreach ($menu as $m) {
         $db->where('id', $m['id'])->delete();
     }
     ajax(['valid' => TRUE, 'message' => '删除成功']);
 }
function upload($pdo)
{
    $error = true;
    if (validRequest()) {
        if (isset($_GET['token'], $_SESSION['token']) && $_GET['token'] == $_SESSION['token']) {
            if (isset($_FILES["file"]) && isset($_POST['title']) && !empty($_POST['title'])) {
                $upload_dir = "files/";
                $target_file = $upload_dir . basename($_FILES["file"]["name"]);
                $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
                $file_name = rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9);
                $target_file = $upload_dir . $file_name . '.' . $fileType;
                if ($_FILES["file"]["size"] <= 4000000) {
                    if (in_array($fileType, array('pdf', 'jpg', 'gif', 'png', 'bmp', 'doc', 'docx', 'ppt', 'mp3', 'mp4', 'xls', 'xlsx', 'zip', 'rar', 'gz', 'txt'))) {
                        if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
                            $file = array('name' => $target_file, 'size' => formatbytes($target_file, "KB"), 'type' => strtoupper($fileType));
                            $sql = "insert into cmsfiles(`uId`,`file`,`title`,`size`,`type`) value(:uId,:file,:title,:size,:type)";
                            $stmt = $pdo->prepare($sql);
                            $stmt->bindValue(':uId', $_SESSION['userId'], PDO::PARAM_INT);
                            $stmt->bindValue(':file', $file['name'], PDO::PARAM_STR);
                            $stmt->bindValue(':size', $file['size'], PDO::PARAM_STR);
                            $stmt->bindValue(':type', $file['type'], PDO::PARAM_STR);
                            $stmt->bindValue(':title', filter_var($_POST['title'], FILTER_SANITIZE_STRING), PDO::PARAM_STR);
                            $stmt->execute();
                            $stmt = $pdo->query("SELECT LAST_INSERT_ID()");
                            $last_id = $stmt->fetchColumn(0);
                            $error = false;
                        }
                    }
                }
            }
        }
    }
    if ($error) {
        _log('error_upload', 'Avoid incorrect information', 'user id=' . isset($_SESSION['userId']) ? $_SESSION['userId'] : 'null');
        echo 'Error';
        exit;
    } else {
        _log('info_upload', '1 file(s) successfully added to the cms file manager');
        if (ajax()) {
            echo json_encode(array("error" => "0", "title" => $_POST['title'], "size" => $file['size'], "type" => $file['type'], "name" => $file['name'], "id" => $last_id));
            exit;
        } else {
            redirect(BASE_PATH . '/filemanage/', 1);
        }
    }
}
Exemple #20
0
 function math($action, $buffer)
 {
     $ajax = ajax();
     $operators_signs = array('[plus]', 'p', 'm', 'x', 'd');
     $operators = array('p', '+', '-', '*', '/');
     $pre_buffer = $buffer;
     $buffer = $ajax->buffer = $buffer . $action;
     $buffer = str_replace($operators_signs, $operators, $buffer);
     switch ($action) {
         case 'm':
             //minus
         //minus
         case 'p':
             //plus
         //plus
         case 'd':
             //divide
         //divide
         case 'x':
             //times
             break;
         case 'c':
             //clear
             $ajax->buffer = null;
             $ajax->result = 0;
             break;
         case 'e':
             //equal
             $buffer = rtrim($buffer, "e=+-\\/*");
             eval("\$action = ({$buffer});");
             $ajax->result = $action;
             $ajax->buffer = $action;
             break;
         default:
             //number
             //get previous operator used, if not then keep putting numbers together
             $prev = rtrim($pre_buffer, $action);
             $prev = preg_replace("/[0-9]/", '', $prev);
             if (!in_array($prev, $operators_signs)) {
                 $action = $buffer;
             } else {
                 $action = preg_replace("/.+[^0-9]/", '', $buffer);
             }
             $ajax->result = $action;
     }
 }
Exemple #21
0
 function div($num = 0)
 {
     $ajax = ajax();
     $text = array();
     //Some random strings .......
     $text[] = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. ";
     $text[] = "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown ";
     $text[] = "printer took a galley of type and scrambled it to make a type";
     $text[] = "specimen book. It has survived not only five centuries, but also the leap into electronic";
     $text[] = "typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of ";
     $text[] = "Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.";
     $text[] = "it is a long established fact that a reader will be distracted by the readable content of a page when looking at its layout.";
     $text[] = "The point of using Lorem Ipsum is that it has a more-or-less normal distribution of letters, as opposed to using";
     $text[] = "'Content here, content here', making it look like readable English. Many desktop publishing packages and ";
     $text[] = "web page editors now use Lorem Ipsum as their default model text, and a search for 'lorem ipsum' will uncover many";
     $text[] = "web sites still in their infancy. Various versions have evolved over the years, sometimes by accident, sometimes on purpose (injected humour and the like).";
     $ajax->DIV_1 = $text[rand(0, count($text) - 1)];
 }
 public function index()
 {
     $page = I('p', 1);
     //首页幻灯片
     $playerdb = $this->get_flash_xml();
     foreach ($playerdb as $key => $val) {
         if (strpos($val['src'], 'http') === false) {
             $playerdb[$key]['src'] = $uri . $val['src'];
         }
     }
     //首页最新展示产品
     $list['goods'] = D('Goods')->field('goods_id,goods_name,goods_thumb,goods_desc,add_time')->where("goods_thumb!=''")->order('goods_id DESC')->page($page . ',' . CommentModel::LIMIT)->select();
     foreach ($list['goods'] as $k => $v) {
         $list['goods'][$k]['add_time'] = date('Y-m-d', $v['add_time']);
         $list['goods'][$k]['goods_desc'] = mb_substr(strip_tags($v['goods_desc']), 0, 10, 'utf-8');
     }
     $list['imgs'] = $playerdb;
     ajax($list);
 }
Exemple #23
0
 function login($input)
 {
     $result = $this->db->find('user', $input['tel'], 'tel');
     if (empty($result)) {
         ajax(1001, '此用户不存在!');
     }
     if ($result['password'] !== md5(md5($input['password']) . 'fish')) {
         ajax(1003, '密码错误!');
     }
     $result['token'] = md5(uniqid() . rand());
     if ($result['rongToken'] == '') {
         $this->load->library('rc');
         $token = $this->rc->RCgetToken($result);
         $result['rongToken'] = $token['status'] ? $token['code'] : '';
         //失败但是要正常登陆
     }
     $this->db->where('id', $result['id'])->update('user', ['token' => $result['token'], 'type' => 0, 'rongToken' => $result['rongToken']]);
     return $this->getInfo($result);
 }
Exemple #24
0
function gp($param, $flag = 0)
{
    $arr = explode(',', $param);
    // 分解 | key和val
    foreach ($arr as $value) {
        $k = explode('|', $value);
        $v = i($k[0]);
        if ($flag == 0 && $v === '') {
            $flag = isset($key[1]) ? $key[1] : $key[0];
            $tmp = "{$flag} , 不能为空";
            if (IS_AJAX) {
                ajax(0, $tmp, 'Parameter cannot be null');
            }
            err_jump($tmp);
        }
        $params[$k[0]] = $v;
    }
    return count($params) == 1 ? current($params) : $params;
}
 function upload($pdo)
 {
     $error = true;
     if (validRequest()) {
         if (isset($_GET['token'], $_SESSION['token']) && $_GET['token'] == $_SESSION['token']) {
             if (isset($_FILES["file"]) && isset($_POST['title']) && !empty($_POST['title'])) {
                 $upload_dir = "assets/d/" . $_SESSION['username'] . "/";
                 $target_file = $upload_dir . basename($_FILES["file"]["name"]);
                 $fileType = pathinfo($target_file, PATHINFO_EXTENSION);
                 $file_name = rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9) . rand(1, 9);
                 $target_file = $upload_dir . $file_name . ".pdf";
                 if ($_FILES["file"]["size"] <= 4000000) {
                     if ($fileType == "pdf") {
                         if (move_uploaded_file($_FILES["file"]["tmp_name"], $target_file)) {
                             $file = array('name' => $_SESSION['username'] . '_' . $file_name, 'size' => formatbytes($target_file, "KB"));
                             $sql = "insert into `files`(`uId`,`file`,`title`,`size`,`quantity`) values(:uId,:file,:title,'" . $file['size'] . "',0)";
                             $stmt = $pdo->prepare($sql);
                             $stmt->bindValue(':uId', $_SESSION['userId'], PDO::PARAM_INT);
                             $stmt->bindValue(':file', $file['name'], PDO::PARAM_STR);
                             $stmt->bindValue(':title', filter_var($_POST['title'], FILTER_SANITIZE_STRING), PDO::PARAM_STR);
                             $stmt->execute();
                             $stmt = $pdo->query("SELECT LAST_INSERT_ID()");
                             $last_id = $stmt->fetchColumn(0);
                             $error = false;
                         }
                     }
                 }
             }
         }
     }
     if ($error) {
         _log('error_upload', 'Avoid incorrect information', 'user id=' . isset($_SESSION['userId']) ? $_SESSION['userId'] : 'null');
         echo 'Error';
     } else {
         _log('info_upload', '1 file(s) successfully added to the file manager');
         if (ajax()) {
             echo json_encode(array('error' => 0, 'title' => $_POST['title'], 'size' => $file['size'], "id" => $last_id));
             exit;
         } else {
             redirect(BASE_PATH . '/filemanage/', 1);
         }
     }
 }
Exemple #26
0
 function dropdown($selected_value)
 {
     $ajax = ajax();
     switch ($selected_value) {
         case 'classes':
             $data = get_declared_classes();
             $ajax->label_4 = "PHP Classes Loaded";
             break;
         case 'files':
             $data = get_required_files();
             $ajax->label_4 = "PHP Files";
             break;
         case 'ext':
             $data = get_loaded_extensions();
             $ajax->label_4 = "PHP Extensions";
     }
     $data += array('classes' => 'PHP Clases', 'files' => 'PHP Files Loaded', 'ext' => 'PHP Extensions Loaded');
     //propagate data to dropdown
     $ajax->select('dropdown', $data);
 }
Exemple #27
0
 function show_messages($message)
 {
     $ajax = ajax();
     $ajax->process("You are about to see the type of messages you can display on the screen..", 5);
     $ajax->update("msgs", "You are about to see the type of messages you can display on the screen..");
     $ajax->wait(5);
     $ajax->success($message . " Success message...");
     $ajax->update("msgs", " Success message...");
     $ajax->wait(5);
     $ajax->update("msgs", " Warning message...");
     $ajax->warning("Warning message...");
     $ajax->wait(5);
     $ajax->error($message . " Error Message...");
     $ajax->update("msgs", " Error Message...");
     $ajax->wait(5);
     $ajax->process($message . " You can run and display lots of stuff..", 7);
     $ajax->update("msgs", " You can run and display lots of stuff..");
     $ajax->wait(3);
     $ajax->update("msgs", " :) ");
 }
Exemple #28
0
 function call($counter, $count)
 {
     $counter = (int) $counter;
     $count = (int) $count;
     $counter++;
     $ajax = ajax();
     if ($count > 100) {
         $ajax->focus('count');
         $ajax->warning("Too many requests can add overhead to our servers, please try reducing the number.", 5);
         $ajax->count = 30;
         return;
     }
     //update div
     $ajax->div_counter = "Call# {$counter} of {$count}..";
     if ($counter >= $count) {
         $ajax->div_counter = "{$counter} recursive AJAX requests were made.";
     } else {
         //fire call
         $ajax->call("ajax.php?recursive_ajax/call/{$counter}/{$count}");
     }
 }
Exemple #29
0
 /**
  * This function updates second parameter values options
  * eg.
  * $this->buttonText = "Button";
  * $this->fileTypeDesc = "Images";
  */
 function __set($setting, $value)
 {
     //upload directory
     if ($setting == 'target') {
         if ($dir = ajax()->config->uploadify_dir) {
             $value = $dir;
         }
         if (!$value) {
             $value = './';
         }
         if (!is_writable($value)) {
             $ajax = ajax();
             $ajax->error("Uploadify: Target is not writable. Check directory exists and has proper permission, then try again.");
             //remove any pending uploadify tasks
             $this->abort();
             return;
         }
         $this->save('target', $value);
         return;
     }
     /**
      * "fileTypeExts" only deals with client side, but there is a second
      * check in the ajax contoller, save it then we can get it there to make
      * sure we are using  the right extensions.
      * see controlles/uploadify.php
      */
     if ($setting == 'fileTypeExts') {
         $exts = preg_replace(array("/^\\*\\./", "/\\*|\\;/"), '', $value);
         $exts = explode('.', $exts);
         //update extensions
         $this->exts = $exts;
         $this->save('exts', $exts);
     }
     //update options
     $this->options[$setting] = $value;
     //Save to options /second parameter
     $this->set('b', $this->options, $this->_id);
     //parameter, variable
 }
Exemple #30
0
 public function remote($url)
 {
     $ajax = ajax();
     $html = $ajax->remote($url);
     //preg_match("/<head>\n\r\t.+/s", $data, $out);
     $doc = new DOMDocument();
     @$doc->loadHTML($html);
     $nodes = $doc->getElementsByTagName('title');
     //get and display what you need:
     $title = $nodes->item(0)->nodeValue;
     $metas = $doc->getElementsByTagName('meta');
     for ($i = 0; $i < $metas->length; $i++) {
         $meta = $metas->item($i);
         if ($meta->getAttribute('name') == 'description') {
             $description = $meta->getAttribute('content');
         }
         if ($meta->getAttribute('name') == 'keywords') {
             $keywords = $meta->getAttribute('content');
         }
     }
     return array('title' => $title, 'description' => $description, 'keywords' => $keywords);
 }