Subversion Repositories SvarDOS

Rev

Rev 812 | Rev 911 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 812 Rev 874
Line 114... Line 114...
114
}
114
}
115
 
115
 
116
 
116
 
117
// is action valid?
117
// is action valid?
118
 
118
 
119
if (($a !== 'search') && ($a !== 'checkup') && ($a !== 'pull')) {
119
if (($a !== 'search') && ($a !== 'checkup') && ($a !== 'pull') && ($a !== 'pullsrc')) {
120
  http_response_code(404);
120
  http_response_code(404);
121
  echo "ERROR: invalid action\r\n";
121
  echo "ERROR: invalid action\r\n";
122
  exit(0);
122
  exit(0);
123
}
123
}
124
 
124
 
Line 131... Line 131...
131
  echo "ERROR: server error, database not found\n";
131
  echo "ERROR: server error, database not found\n";
132
  exit(0);
132
  exit(0);
133
}
133
}
134
 
134
 
135
 
135
 
136
// pull action
136
// pull or pullsrc action (svp / zip)
137
 
137
 
138
if ($a === 'pull') {
138
if (($a === 'pull') || ($a === 'pullsrc')) {
139
  $fname = false;
139
  $fname = false;
140
  if (empty($v)) { // take first version (that's the preferred one)
140
  if (empty($v)) { // take first version (that's the preferred one)
141
    $fname = array_key_first($db[$p]['versions']);
141
    $fname = array_key_first($db[$p]['versions']);
142
  } else {
142
  } else {
143
    // look for a specific version string
143
    // look for a specific version string
Line 147... Line 147...
147
        break;
147
        break;
148
      }
148
      }
149
    }
149
    }
150
  }
150
  }
151
  if (file_exists($fname)) {
151
  if (file_exists($fname)) {
-
 
152
    if ($a === 'pullsrc') { // is it about source?
-
 
153
      $fname = preg_replace('/svp$/', 'zip', $fname); // replace *.svp by *.zip
-
 
154
      if (file_exists($fname)) {
-
 
155
        header('Content-Disposition: attachment; filename="' . $fname);
-
 
156
        header('Content-Type: application/octet-stream');
-
 
157
        readfile($fname);
-
 
158
      } else {
-
 
159
        http_response_code(404);
-
 
160
        echo get_msg('PKG_NO_SRC', $lang) . "\r\n";
-
 
161
      }
-
 
162
    } else {
152
    header('Content-Disposition: attachment; filename="' . $fname);
163
      header('Content-Disposition: attachment; filename="' . $fname);
153
    header('Content-Type: application/octet-stream');
164
      header('Content-Type: application/octet-stream');
154
    readfile($fname);
165
      readfile($fname);
-
 
166
    }
155
  } else {
167
  } else {
156
    http_response_code(404);
168
    http_response_code(404);
157
    echo get_msg('PKG_NOT_FOUND', $lang) . "\r\n";
169
    echo get_msg('PKG_NOT_FOUND', $lang) . "\r\n";
158
  }
170
  }
159
  exit(0);
171
  exit(0);