/** * */ function file_export($export_file) { $skin_zip = $this->stylesdir . '/skin_zip/'; # check if styles folder is writable if (!miss_is_styles_writable()) { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported', 'name' => $export_file))); } # make skin_zip folder to create zip if (!wp_mkdir_p($skin_zip)) { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported', 'name' => $export_file))); } # check if skin_zip folder is writable, if not try to chmod if (!miss_is_writable_dir($skin_zip)) { if (!@chmod($skin_zip, 0777)) { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported', 'name' => $export_file))); } } # get stylesheet contents if ($this->get_contents($export_file)) { $input_data = $this->get_contents($export_file); } else { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported_2', 'name' => $export_file))); } # Set artificially high memory_limit # preg match all RGB colours # preg match all image urls preg_match_all('/url\\(([^\\)]*)\\)/', $input_data, $matches); # loop through all matches and create $images path string array $images = array(); for ($i = 0; $i < count($matches[1]); $i++) { $image_filter = $this->image_filter($matches[1][$i], $export = true); if (isset($image_filter['directory'])) { $images[$i]['directory'] = $image_filter['directory']; } if (isset($image_filter['url'])) { $images[$i]['url'] = $image_filter['url']; } } # if $images array !empty loop thourgh and move to skin_zip if (!empty($images)) { require_once THEME_ADMIN_CLASSES . '/get-image.php'; $get_image = new GetImage(); $get_image_error = array(); $images_to_zip = array(); foreach ($images as $image) { # if we have a dir path first try and copy image if (!empty($image['directory'])) { $path_parts = pathinfo($image['directory']); if (@copy($image['directory'], $skin_zip . $path_parts['basename'])) { $images_to_zip[$path_parts['basename']] = $skin_zip . $path_parts['basename']; @chmod($skin_zip . $path_parts['basename'], 0666); unset($image['url']); } } # get image if (!empty($image['url'])) { $path_parts = pathinfo($image['url']); $get_image->source = $image['url']; $get_image->save_to = $skin_zip; # Use curl if it exists if (function_exists('curl_init') && !ini_get('safe_mode') && !ini_get('open_basedir')) { if ($get_image->download('curl')) { $images_to_zip[$path_parts['basename']] = $skin_zip . $path_parts['basename']; unset($image['url']); } # Use gd if it exists } elseif (function_exists('gd_info')) { if ($get_image->download('gd')) { $images_to_zip[$path_parts['basename']] = $skin_zip . $path_parts['basename']; unset($image['url']); } # Use fread } else { if ($get_image->download('fread')) { $images_to_zip[$path_parts['basename']] = $skin_zip . $path_parts['basename']; unset($image['url']); } } } if (!empty($image['url'])) { $get_image_error[] = $image['url']; } } } # zip file name $zip_name = str_replace('.css', '', $export_file); # preg_replace new image path in stylesheet if $images_to_zip !empty if (!empty($images_to_zip)) { foreach ($images_to_zip as $image => $val) { $new_path = 'url(' . $zip_name . '/' . $image; $patterns = "/url\\((.*\\/){$image}/"; $input_data = @preg_replace($patterns, $new_path, $input_data); } } # write new image paths to stylesheet $css_writable = true; define('PCLZIP_TEMPORARY_DIR', $skin_zip); # create zip file if ($css_writable) { if (!class_exists('PclZip')) { require_once ABSPATH . 'wp-admin/includes/class-pclzip.php'; } $archive = new PclZip($skin_zip . $zip_name . '.zip'); $v_list = $archive->create($skin_zip . $export_file, PCLZIP_OPT_REMOVE_ALL_PATH); if ($v_list != 0) { # if $images_to_zip array !empty add images to zip if ($v_list != 0 && !empty($images_to_zip)) { $archive = new PclZip($skin_zip . $zip_name . '.zip'); $v_list = $archive->add($images_to_zip, PCLZIP_OPT_REMOVE_ALL_PATH, PCLZIP_OPT_ADD_PATH, $zip_name); # error adding images to zip if ($v_list == 0) { die("Error : " . $archive->errorInfo(true)); $get_image_error = array_merge((array) $get_image_error, array_keys($images_to_zip)); } } # couldn't create zip file } else { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported_2', 'name' => $export_file))); } # couldn't write to css file } else { return array('success' => false, 'message' => $this->json_response($args = array('type' => 'not_exported', 'name' => $export_file))); } # if $get_image_error !empty if (!empty($get_image_error)) { foreach ($get_image_error as $image) { $path_parts = pathinfo($image); if ($path_parts['basename'] != 'none') { $image_error[] = '"' . $path_parts['basename'] . '"'; } } if (!empty($image_error)) { $return_zip['message'] = $this->json_response($args = array('type' => 'not_exported_img', 'image_error' => $image_error)); } $return_zip['image_error'] = true; } $return_zip['dl_skin'] = THEME_JS_INIT . '/dl-skin.php'; $return_zip['zip'] = $skin_zip . $zip_name . '.zip'; $return_zip['rmdir'] = $skin_zip; $return_zip['success'] = true; return $return_zip; }
function ondocsave() { include_once admin_ROOT . adminfile . '/include/inc_formtypelist.php'; include_once admin_ROOT . 'public/class_gather.php'; include_once admin_ROOT . 'public/class_downloadimages.php'; $inputclass = $this->fun->accept('inputclass', 'P'); $lng = $this->fun->accept('lng', 'P'); $mid = intval($this->fun->accept('mid', 'P')); $mid = empty($mid) ? 0 : $mid; $tid = intval($this->fun->accept('tid', 'P')); $tid = empty($tid) ? 0 : $tid; if (empty($tid)) { exit($this->lng['article_js_tid_empty']); } $tsn = $this->fun->accept('tsn', 'P'); $color = $this->fun->accept('color', 'P'); if ($color == $this->CON['input_color']) { $color = ''; } $tags = $this->fun->accept('tags', 'P'); $headtitle = $this->fun->accept('headtitle', 'P'); $keywords = $this->fun->accept('keywords', 'P'); $description = $this->fun->accept('description', 'P'); $recommend = $this->fun->accept('recommend', 'P'); if (!empty($recommend)) { $recommend = implode(',', $recommend); } $extid = $this->fun->accept('extid', 'P'); $extid = is_array($extid) ? implode(',', $extid) : 0; $sid = intval($this->fun->accept('sid', 'P')); $sid = empty($sid) ? 0 : $sid; $fgid = intval($this->fun->accept('fgid', 'P')); $fgid = empty($fgid) ? 0 : $fgid; $purview = intval($this->fun->accept('purview', 'P')); $purview = empty($purview) ? 0 : $purview; $click = intval($this->fun->accept('click', 'P')); $click = empty($click) ? 0 : $click; $addtime = $this->fun->accept('addtime', 'P'); $time = time(); $addtime = empty($addtime) ? $time : strtotime($addtime); $islink = $this->fun->accept('islink', 'P'); $islink = empty($islink) ? 0 : $islink; $link = $this->fun->accept('link', 'P'); $ishtml = intval($this->fun->accept('ishtml', 'P')); $ishtml = empty($ishtml) ? 0 : $ishtml; $isorder = intval($this->fun->accept('isorder', 'P')); $isorder = empty($isorder) ? 0 : $isorder; $istemplates = $this->fun->accept('istemplates', 'P'); $istemplates = empty($istemplates) ? 0 : $istemplates; $template = $this->fun->accept('template', 'P'); $filename = $this->fun->accept('filename', 'P'); $ismessage = intval($this->fun->accept('ismessage', 'P')); $ismessage = empty($ismessage) ? 0 : $ismessage; $albumlist = $this->fun->accept('albumlist', 'P'); $picname = $this->fun->accept('picname', 'P'); $filedes = $this->fun->accept('filedes', 'P'); $linkdid = $this->fun->accept('linkdid', 'P'); $donwloadpic = $this->fun->accept('donwloadpic', 'P'); $donwloadpic = empty($donwloadpic) ? 0 : $donwloadpic; $modelatt = $this->get_modelattArray($mid); $modelarray = array(); $modelsysarray = array(); foreach ($modelatt as $key => $value) { if ($value['inputtype'] == 'htmltext') { $value['accept'] = 'html'; } elseif ($value['inputtype'] == 'checkbox') { $value['accept'] = 'checkbox'; } elseif ($value['inputtype'] == 'string' || $value['inputtype'] == 'img' || $value['inputtype'] == 'addon' || $value['inputtype'] == 'video' || $value['inputtype'] == 'select' || $value['inputtype'] == 'radio' || $value['inputtype'] == 'selectinput') { $value['accept'] = 'text'; } elseif ($value['inputtype'] == 'editor' || $value['inputtype'] == 'text') { $value['accept'] = 'editor'; } elseif ($value['inputtype'] == 'int' || $value['inputtype'] == 'float' || $value['inputtype'] == 'decimal') { $value['accept'] = 'int'; } elseif ($value['inputtype'] == 'datetime') { $value['accept'] = 'data'; } if (!$value['lockin'] && !$value['issys']) { $modelarray[] = $value; } else { $modelsysarray[] = $value; } } $sysinstall = null; $sysinstalldb = null; $conent = null; foreach ($modelsysarray as $key => $value) { if ($value['attrname'] == 'content') { continue; } if ($inputclass == 'add') { $sysinstall .= $value['attrname'] . ','; if ($value['accept'] == 'int') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : $valuestr; $sysinstalldb .= "{$valuestr},"; } elseif ($value['accept'] == 'html') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? '' : $this->fun->Text2Html($valuestr); $sysinstalldb .= "'{$valuestr}',"; } elseif ($value['accept'] == 'editor' || $value['accept'] == 'text') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $sysinstalldb .= "'{$valuestr}',"; } elseif ($value['accept'] == 'data') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : strtotime($valuestr); $sysinstalldb .= "{$valuestr},"; } } else { if ($value['accept'] == 'int') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : $valuestr; $sysinstalldb .= $value['attrname'] . "={$valuestr},"; } elseif ($value['accept'] == 'html') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? '' : $this->fun->Text2Html($valuestr); $sysinstalldb .= $value['attrname'] . "='{$valuestr}',"; } elseif ($value['accept'] == 'editor' || $value['accept'] == 'text') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $sysinstalldb .= $value['attrname'] . "='{$valuestr}',"; } elseif ($value['accept'] == 'data') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : strtotime($valuestr); $sysinstalldb .= $value['attrname'] . "={$valuestr},"; } } } $userinstall = null; $userinstalldb = null; foreach ($modelarray as $key => $value) { $userinstall .= $value['attrname'] . ','; if ($value['accept'] == 'int') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : $valuestr; $userinstalldb .= "{$valuestr},"; $userupdatedb .= $value['attrname'] . "={$valuestr},"; } elseif ($value['accept'] == 'html') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? '' : $this->fun->Text2Html($valuestr); $userinstalldb .= "'{$valuestr}',"; $userupdatedb .= $value['attrname'] . "='{$valuestr}',"; } elseif ($value['accept'] == 'editor' || $value['accept'] == 'text') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $userinstalldb .= "'{$valuestr}',"; $userupdatedb .= $value['attrname'] . "='{$valuestr}',"; } elseif ($value['accept'] == 'data') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = empty($valuestr) ? 0 : strtotime($valuestr); $userinstalldb .= "{$valuestr},"; $userupdatedb .= $value['attrname'] . "={$valuestr},"; } elseif ($value['accept'] == 'checkbox') { $valuestr = $this->fun->accept($value['attrname'], 'P'); $valuestr = is_array($valuestr) ? implode(',', $valuestr) : ''; $userinstalldb .= "'{$valuestr}',"; $userupdatedb .= $value['attrname'] . "='{$valuestr}',"; } } $is_keylink = $this->CON['is_keylink']; $is_html = $this->CON['is_html']; $file_htmldir = $this->CON['file_htmldir']; $content = $this->fun->accept('content', 'P'); if ($donwloadpic && !empty($content)) { $gather = new gather(); $temp_pic_content = $this->fun->stripslashes($content); $temp_pic_content = html_entity_decode($temp_pic_content); $images = $gather->imageList($temp_pic_content); if (is_array($images) && count($images) > 0 && !empty($images[0]) && !$this->fun->gb_check($images[0])) { $picsaveDIR = admin_ROOT . $this->CON['upfile_dir']; $showpictrue = true; foreach ($images as $key => $value) { if (empty($value)) { continue; } else { $picpathinfo = parse_url($value); $savepathinfo = parse_url(admin_URL); if ($picpathinfo['host'] == $savepathinfo['host'] || empty($picpathinfo['host'])) { continue; } } $Gimg = new GetImage(); $Gimg->source = $images[$key]; $Gimg->save_to = $picsaveDIR; $Gimg->smalltype = false; $Gfilename = $Gimg->download(); $temp_pic_content = str_replace($images[$key], admin_URL . $this->CON['upfile_dir'] . $Gfilename['filepath'] . $Gfilename['filename'], $temp_pic_content); } $content = addslashes($temp_pic_content); $content = htmlspecialchars($content); } } if (!empty($content)) { $input_isdellink = $this->fun->accept('input_isdellink', 'P'); if ($input_isdellink == 1) { $content = $this->fun->linkclear($content); } if ($is_keylink == 1 && !empty($tags)) { $content = $this->rep_keylink($content, $tags, $lng); } } $input_iskey = $this->CON['input_iskey']; $input_isdes = $this->CON['input_isdes']; $input_isdescription = $this->CON['input_isdescription']; $input_isdescription = empty($input_isdescription) ? 200 : $input_isdescription > 200 ? 200 : $input_isdescription; $input_iskeyword = $this->CON['input_iskeyword']; $input_iskeyword = empty($input_iskeyword) ? 10 : $input_iskeyword > 10 ? 10 : $input_iskeyword; $typeview = $this->get_type($tid); $type_styleid = $typeview['styleid']; $read_templates = $istemplates ? $template : $typeview['readtemplate']; $filenamestyle = $typeview['filenamestyle']; $readnamestyle = $typeview['readnamestyle']; $dirname = $typeview['dirname']; $dirpath = empty($typeview['dirpath']) ? $typeview['dirname'] : $typeview['dirpath'] . '/' . $typeview['dirname']; $aid = $this->esp_adminuserid; $isclass = $this->esp_inputclassid; $isclass = empty($isclass) ? 0 : $isclass; $db_table = db_prefix . 'document'; $db_table1 = db_prefix . 'document_content'; $db_table2 = db_prefix . 'document_attr'; if ($inputclass == 'add') { if (empty($description) && $input_isdescription > 0 && $input_isdes == 1 && !empty($content)) { $description = $this->fun->get_substr($content, 500, true); $description = $this->fun->daddslashes($description, 1); } if (empty($keywords) && $input_iskeyword > 0 && $input_iskey == 1 && !empty($content)) { $keywords = $this->get_keyword($content, $input_iskeyword); $keywords = $this->fun->daddslashes($keywords, 1); } $db_field = $sysinstall . 'lng,pid,mid,aid,tid,extid,sid,fgid,linkdid,isclass,islink,ishtml,ismess,isorder,ktid,purview,istemplates ,isbase,recommend,tsn,color,tags,keywords,description,link,click,addtime,uptime,template,filename,headtitle'; $db_values = $sysinstalldb . "'{$lng}',50,{$mid},{$aid},{$tid},'{$extid}',{$sid},{$fgid},'{$linkdid}',{$isclass},{$islink},{$ishtml},{$ismessage},{$isorder},0,{$purview},{$istemplates},\n\t\t\t\t0,'{$recommend}','{$tsn}','{$color}','{$tags}','{$keywords}','{$description}','{$link}',{$click},{$addtime},{$time},'{$read_templates}','{$filename}','{$headtitle}'"; $this->db->query('INSERT INTO ' . $db_table . ' (' . $db_field . ') VALUES (' . $db_values . ')'); $insert_id = $this->db->insert_id(); if (!empty($content)) { $db_field = 'did,content'; $db_values = "{$insert_id},'{$content}'"; $this->db->query('INSERT INTO ' . $db_table1 . ' (' . $db_field . ') VALUES (' . $db_values . ')'); } if ($userinstall && $userinstalldb) { $db_field = $userinstall . 'did'; $db_values = $userinstalldb . $insert_id; $this->db->query('INSERT INTO ' . $db_table2 . ' (' . $db_field . ') VALUES (' . $db_values . ')'); } if (!empty($albumlist)) { $this->install_pic($insert_id, $albumlist, $picname, $filedes, false); } $htmlid = $this->articlehtml($insert_id); $this->writelog($this->lng['article_add_log'], $this->lng['log_extra_ok'] . ' id=' . $insert_id); if ($htmlid['c'] == 1) { $returmess = $this->lng['article_js_doc_add_html_err2'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 2) { $returmess = $this->lng['filedircreat_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 3) { $returmess = $this->lng['filedir_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 4) { $returmess = $this->lng['article_js_doc_add_html_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 0) { exit('true'); } } elseif ($inputclass == 'edit') { $did = intval($this->fun->accept('did', 'P')); $datid = $this->fun->accept('datid', 'P'); $dcid = $this->fun->accept('dcid', 'P'); $isbase = intval($this->fun->accept('isbase', 'P')); $isbase = empty($isbase) ? 0 : $isbase; if (empty($did)) { exit($this->lng['article_js_doc_add_html_err3']); } $entrance_file = empty($this->CON['entrance_file']) ? 'index' : $this->CON['entrance_file']; $filepath = $this->fun->accept('filepath', 'P'); if ($ishtml == 1 && $is_html == 1 && $islink == 0) { $readfileArray = array('dirname' => $dirname, 'tid' => $tid, 'did' => $did, 'datetime' => date("YmdHis"), 'data' => date("Ymd"), 'y' => date("Y"), 'm' => date("m"), 'd' => date("d")); if ($isbase) { $filename = $entrance_file; } else { $filename = empty($filename) ? $this->get_htmlfilename($readnamestyle, $readfileArray) : $filename; } $filepath = empty($filepath) ? $dirpath : $filepath; } if (!empty($description) && $input_isdescription > 0) { $description = $this->fun->get_substr($description, 500, true); $description = $this->fun->daddslashes($description, 1); } $db_where = 'did=' . $did; $db_set = $sysinstalldb . "aid={$aid},tid={$tid},extid='{$extid}',sid={$sid},fgid={$fgid},linkdid='{$linkdid}',islink={$islink},ishtml={$ishtml},ismess={$ismessage},isorder={$isorder},purview={$purview},istemplates={$istemplates}\n\t\t\t\t,recommend='{$recommend}',tsn='{$tsn}',color='{$color}',tags='{$tags}',keywords='{$keywords}',description='{$description}',link='{$link}',click={$click},addtime={$addtime},uptime={$time},template='{$read_templates}',filename='{$filename}',filepath='{$filepath}',headtitle='{$headtitle}'"; $this->db->query('UPDATE ' . $db_table . ' SET ' . $db_set . ' WHERE ' . $db_where); if (!empty($content)) { if ($dcid) { $db_where = 'did=' . $did . ' AND dcid=' . $dcid; $db_set = "content='{$content}'"; $this->db->query('UPDATE ' . $db_table1 . ' SET ' . $db_set . ' WHERE ' . $db_where); } else { $db_field = 'did,content'; $db_values = "{$did},'{$content}'"; $this->db->query('INSERT INTO ' . $db_table1 . ' (' . $db_field . ') VALUES (' . $db_values . ')'); } } if ($userinstalldb) { if ($datid) { $db_where = 'did=' . $did . ' AND datid=' . $datid; $db_values = substr($userupdatedb, 0, strlen($userupdatedb) - 1); $this->db->query('UPDATE ' . $db_table2 . ' SET ' . $db_values . ' WHERE ' . $db_where); } else { $db_field = $userinstall . 'did'; $db_values = $userinstalldb . $did; $this->db->query('INSERT INTO ' . $db_table2 . ' (' . $db_field . ') VALUES (' . $db_values . ')'); } } $this->install_pic($did, $albumlist, $picname, $filedes); $htmlid = $this->articlehtml($did); $this->dbcache->clearcache('document_' . $did, true); $this->writelog($this->lng['article_edit_log'], $this->lng['log_extra_ok'] . ' id=' . $did); if ($htmlid['c'] == 1) { $returmess = $this->lng['article_js_doc_add_html_err2'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 2) { $returmess = $this->lng['filedircreat_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 3) { $returmess = $this->lng['filedir_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 4) { $returmess = $this->lng['article_js_doc_add_html_err'] . '(' . $htmlid['s'] . ')'; exit($returmess); } elseif ($htmlid['c'] == 0) { exit('true'); } } }
/** * 采集该专辑信息 * 包括专辑封面、专辑标题、其他信息、专辑说明、歌曲列表 * @param array $albumIdArr * @param string $coverDir 专辑封面保存物理路径 * @param string $coverRelativeDir 专辑封面保存到数据库的路径 * @return array */ public function albumInfo($albumIdArr, $coverDir, $coverRelativeDir) { require_once './util/GetImage.class.php'; $ch = curl_init(); curl_setopt($ch, CURLOPT_HEADER, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $albumInfoList = array(); for ($i = 0; $i < count($albumIdArr); $i++) { $albumId = $albumIdArr[$i]; curl_setopt($ch, CURLOPT_URL, 'http://music.baidu.com/album/' . $albumId); $pageData = curl_exec($ch); // 删除回车符,不能删除空格,专辑名、歌曲名、发行公司之间都可能包含空格 $pageData = preg_replace('/[\\n\\r]/', '', $pageData); // 删除其他信息那块包含的 $pageData = str_replace(' ', '', $pageData); // echo $pageData;die; if (empty($pageData)) { continue; } // 百度阻止访问 if (false !== strpos($pageData, 'http://verify.baidu.com/vcode')) { continue; } // 专辑封面 preg_match('/<span class="cover"><img src="([^"]+)" alt="[^"]+" \\/><\\/span>/U', $pageData, $albumCoverMatche); // 下载图片到本地 $albumCoverPath = ''; // 下载头像到本地 if (isset($albumCoverMatche[1])) { $getImage = new GetImage(); if (!!($fileName = $getImage->get($albumCoverMatche[1], $coverDir))) { $albumCoverPath = $coverRelativeDir . $fileName; } } // 专辑标题 preg_match('/<h2 class="album-name">(.*)<\\/h2>/U', $pageData, $albumTitleMatche); // 其他信息 preg_match('/发行时间:([^\\s]+)/', $pageData, $timeMatch); preg_match('/流派:([^\\s]+)/', $pageData, $stylesMatch); preg_match('/发行公司:([^<]+)/', $pageData, $companyMatch); // 专辑说明 preg_match('/<span class="description-all">(.*)<\\/span>/U', $pageData, $descriptionMatch); // 专辑歌曲列表 preg_match_all('/<a href="\\/song\\/([0-9a-z#]+)" title="([^"]+)">[^<]+<\\/a>/iU', $pageData, $albumSongListMatches); foreach ($albumSongListMatches[1] as $k => $v) { $songList[] = array('id' => $albumSongListMatches[1][$k], 'album_id' => $albumId, 'name' => $albumSongListMatches[2][$k]); } $albumInfoList[] = array('album_id' => $albumId, 'album_cover' => $albumCoverPath, 'album_title' => $albumTitleMatche[1], 'time' => isset($timeMatch[1]) ? $timeMatch[1] : '', 'styles' => isset($stylesMatch[1]) ? $stylesMatch[1] : '', 'company' => isset($companyMatch[1]) ? trim($companyMatch[1]) : '', 'description' => isset($descriptionMatch[1]) ? $descriptionMatch[1] : '', 'songList' => $songList); } curl_close($ch); return $albumInfoList; }