Example #1
0
function callOnce($url, $args = null, $method = "post", $withCookie = false, $timeout = CURL_TIMEOUT, $headers = array())
{
    /*{{{*/
    $ch = curl_init();
    if ($method == "post") {
        $data = convert($args);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
        curl_setopt($ch, CURLOPT_POST, 1);
    } else {
        $data = convert($args);
        if ($data) {
            if (stripos($url, "?") > 0) {
                $url .= "&{$data}";
            } else {
                $url .= "?{$data}";
            }
        }
    }
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_TIMEOUT, $timeout);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    if (!empty($headers)) {
        curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
    }
    if ($withCookie) {
        curl_setopt($ch, CURLOPT_COOKIEJAR, $_COOKIE);
    }
    $r = curl_exec($ch);
    curl_close($ch);
    return $r;
}
Example #2
0
function cookContent($articleModule, $page)
{
    global $db_windpost;
    $content = $articleModule->getPageContent($page);
    $articleModule->showError();
    //$content = showface($content);
    $content = str_replace(array(" "), ' ', $content);
    $content = str_replace(array("\n", "\r\n"), '<br />', trim($content, "\r\n \n \r"));
    if ($articleModule->ifAttach && is_array($articleModule->attach)) {
        $aids = attachment($articleModule->content);
    }
    $endAttachs = array();
    foreach ($articleModule->attach as $at) {
        if (in_array($at['attach_id'], $aids)) {
            $content = cmsAttContent($content, $at);
        } elseif ($page == $articleModule->getPageCount()) {
            $endAttachs[] = $at;
        }
    }
    $content = convert($content, $db_windpost);
    foreach ($endAttachs as $value) {
        $html = getAttachHtml($value);
        $content .= $html;
    }
    return $content;
}
	function NetPlayer_LoadFiles ($cd_path) {
	  	//Get Directory to Load
	  	SetValue(NP_ID_CDDIRECTORYPATH, $cd_path);

	  	// Get PlayList
	  	$playlist = array();
	  	NetPlayer_GetPlayList ($cd_path, $playlist);
	  	NetPlayer_CopyCoverFile ($cd_path);

	  	// Leeren der vorher bestehenden Playlist:
		$player = NetPlayer_GetIPSComponentPlayer();
		$player->ClearPlaylist();
	  	$tracklist = "";

	   // Durchlaufen des Playlist-Arrays und anhängen an die Mediaplayer-Instanz-Playlist
	   $idx = 1;
	   foreach($playlist as $data)
	   {
	      IPSLogger_Dbg(__file__, "Add File=".$data);
			$player->AddPlaylist($data);
	      $tracklist.='<tr><td><div id="rc_mp_track'.$idx.'" track="'.$idx.'" class="containerControlTrack">'.convert(basename($data))."</div></td></tr>";
	      $idx++;
	   }
	   SetValue(NP_ID_CDTRACKLISTHTML, $tracklist);
		$player->Play();

	   $Directory = basename($cd_path);
	   SetValue(NP_ID_CDINTERPRET, substr($Directory,0,strpos($Directory, "[")));
	   SetValue(NP_ID_CDALBUM, substr($Directory,strpos($Directory, "[")+1, strpos($Directory, "]")-strpos($Directory, "[")-1));
   }
function generate_xml($tables)
{
    $out = '<?xml version="1.0" ?>' . "\n";
    $out .= '<!-- PHP/ODBC XML export -->' . "\n";
    $out .= '<sql>' . "\n";
    foreach ($tables as $tmp) {
        $name = $tmp[2];
        $cols = $tmp[0];
        $out .= "\t" . '<table title="' . $name . '" >' . "\n";
        for ($i = 0; $i < count($cols); $i++) {
            $col = $cols[$i];
            $str = '';
            if ($col['nn']) {
                $str .= ' nn="nn"';
            }
            if ($col['pk']) {
                $str .= ' pk="pk"';
            }
            if ($col['special']) {
                /* spec */
                $str .= ' special="' . $col['special'] . '"';
            }
            $out .= "\t\t" . '<row' . $str . '>' . "\n";
            $out .= "\t\t\t" . '<title>' . $col['name'] . '</title>' . "\n";
            $out .= "\t\t\t" . '<default>' . $col['default'] . '</default>' . "\n";
            $out .= "\t\t\t" . '<type>' . convert($col['type']) . '</type>' . "\n";
            $out .= "\t\t" . '</row>' . "\n";
        }
        $out .= "\t" . '</table>' . "\n";
    }
    /* pokud tabulka existuje */
    $out .= '</sql>' . "\n";
    echo $out;
}
Example #5
0
 public function test03ToUTF8()
 {
     $this->assertTrue(function_exists('convert'));
     $word = '中文Englis混合' . __FUNCTION__;
     $this->assertEquals($word, convert($word));
     $this->assertEquals($word, convert(iconv('UTF-8', 'GBK', $word)));
 }
Example #6
0
function scanner($path)
{
    global $REGISTERED_MEDIA_EXTENSION, $FROM_DIR, $TO_DIR;
    $handle = opendir($path);
    while ($f = readdir($handle)) {
        if (filetype($path . $f) == 'dir') {
            if ($f != '.' && $f != '..') {
                $dir = $path . $f;
                $new_dir = str_replace($FROM_DIR, $TO_DIR, $dir);
                if (!file_exists($new_dir)) {
                    mkdir($new_dir);
                }
                scanner($path . $f . "/");
            }
        } elseif (filetype($path . $f) == 'file') {
            if (preg_match("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", $f)) {
                $file = $path . $f;
                $file = preg_replace("/\\.(" . $REGISTERED_MEDIA_EXTENSION . ")\$/i", ".mp4", $file);
                if (!file_exists(str_replace($FROM_DIR, $TO_DIR, $file))) {
                    convert($path . $f, str_replace($FROM_DIR, $TO_DIR, $file));
                }
            }
        } else {
            echo "unknown\n";
        }
    }
    closedir($handle);
}
Example #7
0
function postMusic($sUploadedFile, $aFileInfo)
{
    global $oDb;
    global $sFilesPathMp3;
    $sId = $aFileInfo['author'];
    if ($sUploadedFile != "") {
        $sTempFile = $sFilesPathMp3 . $sId . TEMP_FILE_NAME;
        @unlink($sTempFile);
        if (!is_uploaded_file($sUploadedFile)) {
            return false;
        }
        move_uploaded_file($sUploadedFile, $sTempFile);
        if (!convert($sId, $aFileInfo['mp3'])) {
            deleteTempMp3s($sId);
            return false;
        }
        if (!$aFileInfo['mp3']) {
            $oDb->reconnect();
        }
    }
    $aResult = initFile($sId, $aFileInfo['category'], addslashes($aFileInfo['title']), addslashes($aFileInfo['tags']), addslashes($aFileInfo['description']));
    if ($aResult['status'] == SUCCESS_VAL) {
        return $aResult['file'];
    } else {
        return false;
    }
}
/**
 *
 * @ignore
 */
function memory_and_gc($str)
{
    $before = memory_get_usage(true);
    gc_enable();
    $gcs = gc_collect_cycles();
    $after = memory_get_usage(true);
    print "Memory usage at the {$str} : " . convert($before) . ". After GC: " . convert($after) . " and freed {$gcs} variables\n";
}
Example #9
0
function toE164($data)
{
    $line = $data['src'];
    $gibs = $data['gibs'];
    $gibs[3] = convert($gibs[3]);
    $gibs[5] = convert($gibs[5]);
    $line = implode("\t", $gibs);
    return array('src' => $line, 'gibs' => $gibs);
}
Example #10
0
function mb_explode($separator, $string)
{
    $sepEnc = mb_detect_encoding($separator, "GBK, UTF-8");
    $strEnc = mb_detect_encoding($string, "GBK, UTF-8");
    if ($strEnc != $sepEnc) {
        $separator = convert($separator, $sepEnc, $strEnc);
    }
    return explode($separator, $string);
}
Example #11
0
 public function status($x)
 {
     $NR = "<span class='badge badge-warning'>Not Recommended</span>";
     $Re = "<span class='badge badge-info'>Recommended</span>";
     if (convert(disk_total_space($x), FALSE) < 100) {
         return $NR;
     }
     if (convert(disk_total_space($x), FALSE) >= 100) {
         return $Re;
     }
 }
Example #12
0
function im_ali($id, $style = 0)
{
    if ($id) {
        if (!check_name($id) && strtoupper(DT_CHARSET) != 'UTF-8') {
            $id = convert($id, 'GBK', 'UTF-8');
        }
        $id = urlencode($id);
        return '<a href="http://amos.alicdn.com/msg.aw?v=2&uid=' . $id . '&site=cnalichn&s=6&charset=UTF-8" target="_blank" rel="nofollow"><img src="http://amos.alicdn.com/online.aw?v=2&uid=' . $id . '&site=cnalichn&s=6&charset=UTF-8" title="点击旺旺交谈/留言" alt="" align="absmiddle" onerror="this.src=DTPath+\'file/image/ali-off.gif\';" onload="if(this.width>20)this.src=SKPath+\'image/ali-off.gif\';"/></a>';
    }
    return '';
}
Example #13
0
 function processing()
 {
     global $sModule;
     global $sFfmpegPath;
     global $sFilesPathMp3;
     $iFilesCount = getSettingValue($sModule, "processCount");
     if (!is_numeric($iFilesCount)) {
         $iFilesCount = 2;
     }
     $iFailedTimeout = getSettingValue($sModule, "failedTimeout");
     if (!is_numeric($iFailedTimeout)) {
         $iFailedTimeout = 1;
     }
     $iFailedTimeout *= 86400;
     $sDbPrefix = DB_PREFIX . ucfirst($sModule);
     $iCurrentTime = time();
     do {
         //remove all tokens older than 10 minutes
         if (!getResult("DELETE FROM `" . $sDbPrefix . "Tokens` WHERE `Date`<'" . ($iCurrentTime - 600) . "'")) {
             break;
         }
         if (!getResult("UPDATE `" . $sDbPrefix . "Files` SET `Date`='" . $iCurrentTime . "', `Status`='" . STATUS_FAILED . "' WHERE `Status`='" . STATUS_PROCESSING . "' AND `Date`<'" . ($iCurrentTime - $iFailedTimeout) . "'")) {
             break;
         }
         $rResult = getResult("SELECT * FROM `" . $sDbPrefix . "Files` WHERE `Status`='" . STATUS_PENDING . "' ORDER BY `ID` LIMIT " . $iFilesCount);
         if (!$rResult) {
             break;
         }
         for ($i = 0; $i < $rResult->rowCount(); $i++) {
             $aFile = $rResult->fetch();
             if (convert($aFile['ID'])) {
                 $sType = 'bx_sounds';
                 //album counter & cover update
                 if (getSettingValue($sModule, "autoApprove") == TRUE_VAL) {
                     $oAlbum = new BxDolAlbums($sType);
                     $oAlbum->updateObjCounterById($aFile['ID']);
                     if (getParam($oAlbum->sAlbumCoverParam) == 'on') {
                         $oAlbum->updateLastObjById($aFile['ID']);
                     }
                 }
                 $oTag = new BxDolTags();
                 $oTag->reparseObjTags($sType, $aFile['ID']);
                 $oCateg = new BxDolCategories($aFile['Owner']);
                 $oCateg->reparseObjTags($sType, $aFile['ID']);
             } else {
                 if (!getResult("UPDATE `" . $sDbPrefix . "Files` SET `Status`='" . STATUS_FAILED . "' WHERE `ID`='" . $aFile['ID'] . "'")) {
                     break;
                 }
             }
         }
     } while (false);
 }
Example #14
0
function utf8_to_ascii($str = '')
{
    $str_lower = convert($str);
    $chars = array('a' => array('a', 'á', 'à', 'ả', 'ạ', 'ã', 'â', 'ấ', 'ầ', 'ẩ', 'ậ', 'ẫ', 'ă', 'ắ', 'ằ', 'ẳ', 'ặ', 'ẵ'), 'b' => array('b'), 'c' => array('c'), 'd' => array('d', 'đ'), 'e' => array('e', 'é', 'è', 'ẻ', 'ẹ', 'ẽ', 'ê', 'ế', 'ề', 'ể', 'ệ', 'ễ'), 'f' => array('f'), 'g' => array('g'), 'h' => array('h'), 'j' => array('j'), 'k' => array('k'), 'l' => array('l'), 'm' => array('m'), 'n' => array('n'), 'i' => array('i', 'í', 'ì', 'ỉ', 'ị', 'ĩ'), 'o' => array('o', 'ó', 'ò', 'ỏ', 'õ', 'ọ', 'ỡ', 'ơ', 'ớ', 'ờ', 'ở', 'ợ', 'ô', 'ố', 'ồ', 'ổ', 'ộ', 'ỗ'), 'u' => array('u', 'ú', 'ù', 'ủ', 'ũ', 'ụ', 'ú', 'ư', 'ứ', 'ừ', 'ử', 'ữ', 'ự'), 'y' => array('y', 'ý', 'ỳ', 'ỵ', 'ỷ', 'ỹ'), 'q' => array('q'), 'w' => array('w'), 'r' => array('r'), 't' => array('t'), 'p' => array('p'), 's' => array('s'), 'z' => array('z'), 'x' => array('x'), 'v' => array('v'), '-' => array(' '));
    foreach ($chars as $k => $v) {
        foreach ($v as $char) {
            $str_lower = str_replace($char, $k, $str_lower);
        }
    }
    $str_lower = preg_replace('/[^a-z0-9\\s-.]/i', NULL, $str_lower);
    $str_lower = preg_replace('#[-]{1,}#u', '-', $str_lower);
    return trim($str_lower);
}
Example #15
0
function bottles($start)
{
    for ($i = $start; $i > 0; $i--) {
        $current = convert($i);
        $next = convert($i - 1);
        if ($i == 1) {
            print $current . " bottle of beer on the wall. </br>" . $current . " bottle of beer! </br>\r\n\t\t\t\t\t\t  take one down, pass it around, </br> " . $next . " bottles of beer on the wall.</br></br>";
        } elseif ($i == 2) {
            print $current . " bottles of beer on the wall. </br>" . $current . " bottles of beer! </br>\r\n\t\t\t\t\t\t  take one down, pass it around, </br>" . $next . " bottle of beer on the wall. </br></br>";
        } else {
            print $current . " bottles of beer on the wall. </br>" . $current . " bottles of beer! </br>\r\n\t\t\t\t\t\t  take one down, pass it around, </br>" . $next . " bottles of beer on the wall. </br></br>";
        }
    }
}
 function parsePostContent($data)
 {
     list($content, $tpc_shield) = $this->shieldContent($data['content'], $data['ifshield'], $data['groupid']);
     if ($tpc_shield) {
         return $content;
     }
     $content = stripcslashes($content);
     if (strpos($content, "[quote]") !== false && strpos($content, "[/quote]") !== false) {
         $content = preg_replace_callback('/\\[quote\\](.*?)\\[\\/quote\\]/is', array($this, 'parseQuote'), $content);
     }
     $content = preg_replace(array("/\n/is", "/\r\n/is"), "<br />", $content);
     require_once ACLOUD_VERSION_PATH . '/customized/ver.customized.bbscode.php';
     $content = convert($content, $GLOBALS['db_windpost']);
     return $content;
 }
Example #17
0
function im_ali($id, $style = 0)
{
    if ($id) {
        $tb = 0;
        if (substr($id, 0, 3) == 'TB:') {
            $tb = 1;
            $id = substr($id, 3);
        }
        if (!check_name($id) && DT_CHARSET != 'UTF-8') {
            $id = convert($id, 'GBK', 'UTF-8');
        }
        $id = urlencode($id);
        return ($tb ? '<a href="http://www.taobao.com/webww/ww.php?ver=3&touid=' . $id . '&siteid=cntaobao&status=2&charset=UTF-8" target="_blank" rel="nofollow"><img src="http://amos.alicdn.com/realonline.aw?v=2&uid=' . $id . '&site=cntaobao&s=2&charset=UTF-8"' : '<a href="http://amos.alicdn.com/msg.aw?v=2&uid=' . $id . '&site=cnalichn&s=6&charset=UTF-8" target="_blank" rel="nofollow"><img src="http://amos.alicdn.com/online.aw?v=2&uid=' . $id . '&site=cnalichn&s=6&charset=UTF-8"') . ' title="点击旺旺交谈/留言" alt="" align="absmiddle" onerror="this.src=DTPath+\'file/image/ali-off.gif\';" onload="if(this.width>20)this.src=SKPath+\'image/ali-off.gif\';"/></a>';
    }
    return '';
}
Example #18
0
/**
 * Init converting. Execute read and write to files
 * @return nothing
 */
function doit()
{
    $input = 'Input/';
    $output = 'Output/';
    $path = array('1/01.LAS', '1/02.LAS', '20/03.LAS', '20/04.LAS');
    foreach ($path as $f) {
        $file = file($input . $f);
        convert($file);
        if (file_exists($output . $f)) {
            file_put_contents($output . $f, $file);
        } else {
            $dir = substr($f, 0, strpos($f, '/'));
            mkdir($output . $dir, 0777, true);
            file_put_contents($output . $f, $file);
        }
    }
}
Example #19
0
function do_convert($form)
{
    global $maps, $forms, $user, $db, $form_factory;
    if (array_key_exists($form, $maps)) {
        echo "Ignoring {$form}.  Already cached.\n";
    } else {
        if (array_key_exists($form, $forms)) {
            $required = $forms[$form];
            foreach ($required as $req_form) {
                if (!array_key_exists($req_form, $maps)) {
                    do_convert($req_form);
                }
            }
        }
        convert($form);
    }
}
 /**
  * 格式化输出结果
  * @param unknown_type $data
  * @return unknown
  */
 function _cookData($data)
 {
     global $db_bbsurl, $db_windpost;
     $data['url'] = $data['url'] ? $data['url'] : $db_bbsurl . '/notice.php?fid=' . $data['fid'] . '#' . $data['aid'];
     $data['title'] = convert($data['subject'], $db_windpost);
     if ($data['author']) {
         $userService = L::loadClass('userService', 'user');
         $userId = $userService->getUserIdByUserName($data['author']);
         $data['authorurl'] = 'u.php?uid=' . $userId;
     } else {
         $data['authorurl'] = '';
     }
     $data['content'] = convert($data['content'], $db_windpost);
     $data['descrip'] = substrs(strip_tags($data['content']), 100);
     $data['postdate'] = $data['startdate'];
     return $data;
 }
Example #21
0
function _exec()
{
    $urls = array();
    foreach (todays_categories() as $japanese) {
        $book_category = convert($japanese);
        echo "<br/>";
        echo '"' . $book_category . '": [';
        $pattern = '/a href="(.*?)"/';
        preg_match_all($pattern, file_get_html('http://miraitosho.hateblo.jp/entry/2014/04/22/225652')->find("div[id={$book_category}]", 0), $matches);
        foreach ($matches[1] as $url) {
            $html = file_get_html($url);
            $img_url = $html->find('.hatena-fotolife', 0)->src;
            $title = $html->find('.entry-title-link', 0)->innertext;
            echo '{';
            echo '"url": "' . $url . '",';
            echo '"title": "' . $title . '",';
            echo '"img_url": "' . $img_url . '"},';
        }
        echo '],';
    }
}
Example #22
0
function record_activity()
{
    $time_end = microtime(true);
    $time = round($time_end - func_get_arg(0), 4);
    function convert($size)
    {
        $unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
        return @round($size / pow(1024, $i = floor(log($size, 1024))), 2) . ' ' . $unit[$i];
    }
    $peak_usage = convert(memory_get_peak_usage());
    print '<style type="text/css" media="screen">
	#load_stats {
		width:220px;
		font:12px Arial, sans-serif;
	}
	#load_stats h2 {
		margin:0; padding:0;
	}
	#load_stats ul, #load_stats ul li {
		margin:0; padding:0 3px;
	}
	
	#load_stats ul li {
		list-style-type:none;
		position:relative;
		padding-right:75px
	}	
	#load_stats ul li strong {
		position:absolute; left:140px;
	}
	</style>';
    print '<div id="load_stats" style="position:absolute; background-color:#DFD; opacity:0.9; bottom:5px; right:5px; border:1px solid #3B3; text-align:left; padding:5px 5px 5px 5px">
	<h2>Page Load Stats</h2>
	<p>This is just meant to give a general overview of the type of load the server experienced in case something jumps out.</p>
	<ul>
		<li>Elapsed Time: <strong>' . $time . '</strong></li>
		<li>Memory Peak Usage: <strong>' . $peak_usage . '</strong></li>
	</ul>
	</div>';
}
Example #23
0
function convert($xml)
{
    if ($xml instanceof SimpleXMLElement) {
        $children = $xml->children();
        $return = null;
    }
    foreach ($children as $element => $value) {
        if ($value instanceof SimpleXMLElement) {
            $values = (array) $value->children();
            if (count($values) > 0) {
                if (is_array($return[$element])) {
                    foreach ($return[$element] as $k => $v) {
                        if (!is_int($k)) {
                            $return[$element][0][$k] = $v;
                            unset($return[$element][$k]);
                        }
                    }
                    $return[$element][] = convert($value);
                } else {
                    $return[$element] = convert($value);
                }
            } else {
                if (!isset($return[$element])) {
                    $return[$element] = (string) $value;
                } else {
                    if (!is_array($return[$element])) {
                        $return[$element] = array($return[$element], (string) $value);
                    } else {
                        $return[$element][] = (string) $value;
                    }
                }
            }
        }
    }
    if (is_array($return)) {
        return $return;
    } else {
        return false;
    }
}
Example #24
0
 public static function quote($value)
 {
     $format = "'%s'";
     if (is_null($value)) {
         $value = 'NULL';
     } else {
         if ($value instanceof self) {
             $value = strval($value);
         } else {
             if ($value instanceof DateTime) {
                 $value = sprintf($format, $value->format('Y-m-d H:i:s'));
             } else {
                 if (is_string($value)) {
                     $value = sprintf($format, convert($value, 'UTF-8'));
                 } else {
                     $value = sprintf($format, strval($value));
                 }
             }
         }
     }
     return $value;
 }
Example #25
0
function mobile2area($mobile)
{
    if (!is_mobile($mobile)) {
        return 'Unknown';
    }
    $url = 'http://apistore.baidu.com/microservice/mobilephone?tel=' . $mobile;
    $rec = dcurl($url);
    $area = '';
    if (strpos($rec, 'retData') !== false) {
        $tmp = json_decode($rec, true);
        $arr = $tmp['retData'];
        if (isset($arr['supplier'])) {
            $area .= $arr['supplier'] . '-';
        }
        if (isset($arr['province'])) {
            $area .= $arr['province'];
        }
        if (isset($arr['city'])) {
            $area .= $arr['city'];
        }
    }
    return $area ? convert($area, 'UTF-8', DT_CHARSET) : 'Unknown';
}
Example #26
0
 /**
  * 读取分区,根据标志位1/2跳转或再次跳转
  *  * 都在当前
  *  2 分区跳转、位置当前
  *  1* 分区跳转、位置当前(已跳转)
  *  12 分区再跳转、位置当前(已跳转)
  */
 public function readZone()
 {
     $flag = $this->readInt(self::BYTE_FLAG);
     if ($flag === self::FLAG_JUMP_FIRST) {
         $offset = $this->readNumber($this->offset_size);
         $this->seek($offset);
         return $this->readZone();
     } else {
         if ($flag === self::FLAG_JUMP_SENIOR) {
             // 仅分区跳转
             $offset = $this->readNumber($this->offset_size);
             $loc = $this->readLocation();
             $this->seek($offset);
             $zone = $this->readString();
         } else {
             //在当前位置读取
             $zone = $this->readString(chr($flag));
             $loc = $this->readLocation();
         }
     }
     $zone = trim($zone) ? convert(trim($zone), 'UTF-8') : '';
     $loc = trim($loc) ? convert(trim($loc), 'UTF-8') : '';
     return [$zone, $loc];
 }
Example #27
0
function updatecache_i_i($fid, $aidin = null)
{
    global $db, $db_windpost, $timestamp, $forum;
    require_once R_P . 'require/bbscode.php';
    //* include pwCache::getPath(D_P.'data/bbscache/forum_cache.php');
    extract(pwCache::getData(D_P . 'data/bbscache/forum_cache.php', false));
    $sql_where = empty($aidin) ? "fid=" . S::sqlEscape($fid) : "aid IN ({$aidin})";
    $F_ffid = false;
    $aid = $aidcache = 0;
    $aids = '';
    $query = $db->query("SELECT aid,startdate,enddate,content FROM pw_announce WHERE {$sql_where} AND ifopen='1' AND (enddate=0 OR enddate>=" . S::sqlEscape($timestamp) . ") ORDER BY vieworder,startdate DESC");
    while ($rt = $db->fetch_array($query)) {
        if ($rt['startdate'] <= $timestamp) {
            if ($F_ffid) {
                continue;
            } elseif (!$rt['enddate']) {
                $F_ffid = true;
            }
        }
        if (!$aid && $rt['startdate'] <= $timestamp && (!$rt['enddate'] || $rt['enddate'] >= $timestamp)) {
            $aid = $rt['aid'];
            if ($rt['content'] != convert($rt['content'], $db_windpost, 2)) {
                //* $db->update("UPDATE pw_announce SET ifconvert='1' WHERE aid=".S::sqlEscape($aid));
                pwQuery::update('pw_announce', 'aid=:aid', array($aid), array('ifconvert' => 1));
            }
        } else {
            $aids .= ",{$rt['aid']}";
        }
    }
    if ($aids) {
        $aids = substr($aids, 1);
        $aidcache = $timestamp;
    }
    //* $db->update("UPDATE pw_forumdata SET ".S::sqlSingle(array('aid'=>$aid,'aids'=>$aids,'aidcache'=>$aidcache))."WHERE fid=".S::sqlEscape($fid));
    pwQuery::update('pw_forumdata', 'fid=:fid', array($fid), array('aid' => $aid, 'aids' => $aids, 'aidcache' => $aidcache));
}
Example #28
0
 /**
  * 添加文件信息
  * @param  $param array 文件信息
  * @return int 1:上传成功 0:上传失败
  */
 public function addFile($param)
 {
     $ret = array('code' => 0, 'message' => '上传失败');
     if (empty($param)) {
         $ret['message'] = '参数不能为空';
         return $ret;
     }
     $isExist = $this->checkFileExist($param['fileKey']);
     if ($isExist) {
         $ret['message'] = '上传成功';
         return $ret;
     }
     $nowTime = date('Y-m-d H:i:s', time());
     $data = array('fdName' => $param['fileName'], 'fdSize' => $param['fileSize'], 'fdSizeH' => convert($param['fileSize']), 'fdKey' => $param['fileKey'], 'fdUserID' => $param['userID'], 'fdCreate' => $nowTime, 'fdUpdate' => $nowTime);
     $typeID = D('Mime')->getFileTypeByExt(ltrim($param['fileType'], '.'));
     $data['fdTypeID'] = $typeID;
     $res = $this->add($data);
     if ($res) {
         $ret['message'] = '上传成功';
         return $ret;
     } else {
         return $ret;
     }
 }
Example #29
0
function viewread($read, $start_limit)
{
    global $db, $_G, $isGM, $pwSystem, $groupid, $attach_url, $winduid, $tablecolor, $tpc_author, $tpc_buy, $tpc_pid, $tpc_tag, $count, $orderby, $pageinverse, $timestamp, $db_onlinetime, $attachdir, $attachpath, $readcolorone, $readcolortwo, $lpic, $ltitle, $imgpath, $db_ipfrom, $db_showonline, $stylepath, $db_windpost, $db_windpic, $db_signwindcode, $fid, $tid, $pid, $db_md_ifopen, $_MEDALDB, $rewardtype, $db_shield, $db_iftag, $db_readtag, $viewpic;
    global $ping_logs;
    if ($read['istop'] == 'topped') {
        $read['lou'] = $read['floor'];
    } else {
        $read['lou'] = $count - $start_limit;
    }
    $read['jupend'] = $start_limit == $count - 1 ? "<a name=a></a><a name={$read['pid']}></a>" : "<a name={$read['pid']}></a>";
    $tpc_buy = $read['buy'];
    $tpc_pid = $read['pid'];
    $tpc_tag = NULL;
    $tpc_shield = 0;
    $read['ifsign'] < 2 && ($read['content'] = str_replace("\n", "<br />", $read['content']));
    if ($read['anonymous']) {
        $anonymous = !$isGM && $winduid != $read['authorid'] && !$pwSystem['anonyhide'];
        $read['anonymousname'] = $GLOBALS['db_anonymousname'];
    } else {
        $anonymous = false;
        $read['anonymousname'] = $read['username'];
    }
    $read['ipfrom'] = $db_ipfrom == 1 && $_G['viewipfrom'] ? $read['ipfrom'] : '';
    $read['ip'] = $isGM || $pwSystem['viewip'] ? 'IP:' . $read['userip'] : '';
    if ($read['groupid'] && !$anonymous) {
        $read['groupid'] == '-1' && ($read['groupid'] = $read['memberid']);
        !array_key_exists($read['groupid'], (array) $lpic) && ($read['groupid'] = 8);
        $read['lpic'] = $lpic[$read['groupid']];
        $read['level'] = $ltitle[$read['groupid']];
        $read['regdate'] = get_date($read['regdate'], "Y-m-d");
        $read['lastlogin'] = get_date($read['lastvisit'], "Y-m-d");
        $read['rvrc'] = floor($read['rvrc'] / 10);
        $read['author'] = $read['username'];
        $tpc_author = $read['author'];
        if (!empty($GLOBALS['showfield'])) {
            $customdata = $read['customdata'] ? (array) unserialize($read['customdata']) : array();
            $read['customdata'] = array();
            foreach ($customdata as $key => $val) {
                if ($val && in_array($key, $GLOBALS['showfield'])) {
                    $read['customdata'][$key] = $val;
                }
            }
        }
        $read['ontime'] = (int) ($read['onlinetime'] / 3600);
        $read['groupid'] == 6 && ($read['honor'] = '');
        if ($read['groupid'] != 6 && ($read['ifsign'] == 1 || $read['ifsign'] == 3)) {
            global $sign;
            if (!$sign[$read['author']]) {
                global $db_signmoney, $db_signgroup, $tdtime, $db_signcurtype;
                if ($db_signmoney && strpos($db_signgroup, ",{$read['groupid']},") !== false && (!getstatus($read['userstatus'], PW_USERSTATUS_SHOWSIGN) || !$read['starttime'] || $read[$db_signcurtype] < ($tdtime - $read['starttime']) / 86400 * $db_signmoney)) {
                    $read['signature'] = '';
                } else {
                    if ($db_signwindcode && getstatus($read['userstatus'], PW_USERSTATUS_SIGNCHANGE)) {
                        if ($GLOBALS['gp_right'][$read['groupid']]['imgwidth'] && $GLOBALS['gp_right'][$read['groupid']]['imgheight']) {
                            $db_windpic['picwidth'] = $GLOBALS['gp_right'][$read['groupid']]['imgwidth'];
                            $db_windpic['picheight'] = $GLOBALS['gp_right'][$read['groupid']]['imgheight'];
                        }
                        if ($GLOBALS['gp_right'][$read['groupid']]['fontsize']) {
                            $db_windpic['size'] = $GLOBALS['gp_right'][$read['groupid']]['fontsize'];
                        }
                        $read['signature'] = convert($read['signature'], $db_windpic, 2);
                    }
                    $read['signature'] = str_replace("\n", "<br />", $read['signature']);
                }
                $sign[$read['author']] = $read['signature'];
            } else {
                $read['signature'] = $sign[$read['author']];
            }
        } else {
            $read['signature'] = '';
        }
    } else {
        $read['lpic'] = $lpic['2'];
        $read['level'] = $read['digests'] = $read['postnum'] = $read['money'] = $read['currency'] = '*';
        $read['rvrc'] = $read['lastlogin'] = $read['credit'] = $read['regdate'] = '*';
        $read['honor'] = $read['signature'] = $read['micon'] = $read['aliww'] = '';
        if ($anonymous) {
            $read['oicq'] = $read['ip'] = $read['medals'] = $read['ipfrom'] = '';
            $read['author'] = $GLOBALS['db_anonymousname'];
            $read['authorid'] = 0;
            foreach ($GLOBALS['customfield'] as $key => $val) {
                $field = "field_" . (int) $val['id'];
                $read[$field] = '*';
            }
        }
    }
    list($read['face'], , $httpWidth, $httpHeight, , , , $read['facesize']) = showfacedesign($read['micon'], true, 'm');
    if ($httpWidth > 120 || $httpHeight > 120 || $read['facesize'] == '') {
        $read['facesize'] = ' width="120" height="120"';
    }
    list($read['posttime'], $read['postdate']) = getLastDate($read['postdate']);
    $read['mark'] = $read['reward'] = $read['tag'] = NULL;
    if ($read['ifmark']) {
        $ping_logs[$read['pid']] = $read['ifmark'];
    }
    if ($rewardtype != null) {
        if ($read['lou'] == 0 || $read['ifreward'] > 0 || $rewardtype == '0' && $winduid == $GLOBALS['authorid'] && $winduid != $read['authorid']) {
            $read['reward'] = Getrewhtml($read['lou'], $read['ifreward'], $read['pid']);
        }
    }
    if ($read['icon']) {
        $read['icon'] = "<img src=\"{$imgpath}/post/emotion/{$read['icon']}.gif\" align=\"left\" border=\"0\" />";
    } else {
        $read['icon'] = '';
    }
    if ($db_md_ifopen && $read['medals']) {
        $medals = $ifMedalNotExist = '';
        $md_a = explode(',', $read['medals']);
        foreach ($md_a as $key => $value) {
            if ($value && $_MEDALDB[$value]) {
                $medals .= "<a href=\"apps.php?q=medal\" target=\"_blank\"><img src=\"{$_MEDALDB[$value][smallimage]}\" width=\"30\" height=\"30\"  title=\"{$_MEDALDB[$value][name]}\" /></a>";
            } else {
                unset($md_a[$key]);
                $ifMedalNotExist = 1;
            }
        }
        if ($ifMedalNotExist == 1) {
            $newMedalInfo = implode(',', $md_a);
            $userService = L::loadClass('UserService', 'user');
            /* @var $userService PW_UserService */
            $userService->update($read['authorid'], array('medals' => $newMedalInfo));
        }
        $read['medals'] = $medals . '<br />';
    } else {
        $read['medals'] = '';
    }
    $read['leaveword'] && ($read['content'] .= leaveword($read['leaveword'], $read['pid']));
    if ($read['ifshield'] || $read['groupid'] == 6 && $db_shield) {
        if ($read['ifshield'] == 2) {
            $read['content'] = shield('shield_del_article');
            $read['subject'] = '';
            $tpc_shield = 1;
        } else {
            if ($groupid == '3') {
                $read['subject'] = shield('shield_title');
            } else {
                $read['content'] = shield($read['ifshield'] ? 'shield_article' : 'ban_article');
                $read['subject'] = '';
                $tpc_shield = 1;
            }
        }
        $read['icon'] = '';
    }
    if (!$tpc_shield) {
        if ($read['ifwordsfb'] != $GLOBALS['db_wordsfb']) {
            $read['content'] = wordsConvert($read['content'], array('id' => $tpc_pid == 'tpc' ? $tid : $tpc_pid, 'type' => $tpc_pid == 'tpc' ? 'topic' : 'posts', 'code' => $read['ifwordsfb']));
        }
        if ($read['ifconvert'] == 2) {
            $read['content'] = convert($read['content'], $db_windpost);
        } else {
            $tpc_tag && ($read['content'] = relatetag($read['content'], $tpc_tag));
            strpos($read['content'], '[s:') !== false && ($read['content'] = showface($read['content']));
        }
        if ($read['aid'] && $GLOBALS['attachShow']->isShow($read['ifhide'], $tid)) {
            $read += $GLOBALS['attachShow']->parseAttachs($read['pid'], $read['content'], $winduid == $read['authorid']);
        }
    }
    /**
     * convert the post content
     */
    $read['alterinfo'] && ($read['content'] .= "<div id=\"alert_{$read['pid']}\" style=\"color:gray;margin-top:30px\">[ {$read['alterinfo']} ]</div>");
    if ($read['remindinfo']) {
        $remind = explode("\t", $read['remindinfo']);
        $remind[0] = str_replace("\n", "<br />", $remind[0]);
        $remind[2] && ($remind[2] = get_date($remind[2]));
        $read['remindinfo'] = $remind;
    }
    if ($_GET['keyword']) {
        $keywords = explode("|", $_GET['keyword']);
        foreach ($keywords as $key => $value) {
            if ($value) {
                $read['content'] = preg_replace("/(?<=[\\s\"\\]>()]|[-�]|^)(" . preg_quote($value, '/') . ")([.,:;-?!()\\s\"<\\[]|[-�]|\$)/siU", "<u><font color=\"red\">\\1</font></u>\\2", $read['content']);
            }
        }
    }
    //$GLOBALS['foruminfo']['copyctrl'] && $read['content'] = preg_replace("/<br \/>/eis","copyctrl()",$read['content']);
    return $read;
}
Example #30
0
        $seo_title = $subtitle . $seo_delimiter . $seo_title;
    }
    $destoon_task = "moduleid={$moduleid}&html=show&itemid={$itemid}&page={$page}";
    if ($EXT['wap_enable']) {
        $head_mobile = $EXT['wap_url'] . 'index.php?moduleid=' . $moduleid . '&itemid=' . $itemid . ($page > 1 ? '&page=' . $page : '');
    }
    $filename = $total == 1 ? DT_ROOT . '/' . $MOD['moduledir'] . '/' . $fileurl : DT_ROOT . '/' . $MOD['moduledir'] . '/' . itemurl($item, $page);
    if ($total > 1) {
        $pages = showpages($item, $total, $page);
        $content = $contents[$page - 1];
    }
    if ($MOD['keylink']) {
        $content = keylink($content, $moduleid);
    }
    ob_start();
    include template($template, $module);
    $data = ob_get_contents();
    ob_clean();
    if ($DT['pcharset']) {
        $filename = convert($filename, DT_CHARSET, $DT['pcharset']);
    }
    file_put($filename, $data);
    if ($page == 1 && $total > 1) {
        $indexname = DT_ROOT . '/' . $MOD['moduledir'] . '/' . itemurl($item, 0);
        if ($DT['pcharset']) {
            $indexname = convert($indexname, DT_CHARSET, $DT['pcharset']);
        }
        file_copy($filename, $indexname);
    }
}
return true;