output.inc.php 1.0 KB

1234567891011121314151617181920212223242526
  1. function downfile($field, $value) {
  2. extract(string2array($this->fields[$field]['setting']));
  3. $list_str = array();
  4. if($value){
  5. $value_arr = explode('|',$value);
  6. $fileurl = $value_arr['0'];
  7. if($fileurl) {
  8. $sel_server = $value_arr['1'] ? explode(',',$value_arr['1']) : '';
  9. $server_list = getcache('downservers','commons');
  10. if(is_array($server_list)) {
  11. foreach($server_list as $_k=>$_v) {
  12. if($value && is_array($sel_server) && in_array($_k,$sel_server)) {
  13. $downloadurl = $_v[siteurl].$fileurl;
  14. if($downloadlink) {
  15. $a_k = urlencode(sys_auth("i=$this->id&s=$_v[siteurl]&m=1&f=$fileurl&d=$downloadtype&modelid=$this->modelid&catid=$this->catid", 'ENCODE', pc_base::load_config('system','auth_key')));
  16. $list_str[] = "<a href='".APP_PATH."index.php?m=content&c=down&a_k={$a_k}' target='_blank'>{$_v[sitename]}</a>";
  17. } else {
  18. $list_str[] = "<a href='{$downloadurl}' target='_blank'>{$_v[sitename]}</a>";
  19. }
  20. }
  21. }
  22. }
  23. return $list_str;
  24. }
  25. }
  26. }