00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 if (!defined('SOAP_1_2')) {
00031 require_once('class.nusoap.php');
00032 # require_once('/usr/share/php/SOAP/Client.php');
00033 }
00034 require_once('class.em_soap.php');
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 class SC_mod_tools_em_terconnection {
00047 var $wsdlURL;
00048
00049
00050
00051
00052
00053
00054 var $emObj;
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065 function fetchExtension($extKey, $version, $expectedMD5, $mirrorURL) {
00066 $extPath = t3lib_div::strtolower($extKey);
00067 $mirrorURL .= $extPath{0} . '/' . $extPath{1} . '/' . $extPath . '_' . $version . '.t3x';
00068 $t3x = t3lib_div::getURL($mirrorURL, 0, array(TYPO3_user_agent));
00069 $MD5 = md5($t3x);
00070
00071 if($t3x===false) return 'The T3X file could not be fetched. Possible reasons: network problems, allow_url_fopen is off, curl is not enabled in Install tool.';
00072
00073 if($MD5 == $expectedMD5) {
00074
00075 return $this->decodeExchangeData($t3x);
00076 } else {
00077 return 'Error: MD5 hash of downloaded file not as expected:<br />'.$MD5.' != '.$expectedMD5;
00078 }
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089 function fetchTranslation($extKey, $lang, $mirrorURL) {
00090 $extPath = t3lib_div::strtolower($extKey);
00091 $mirrorURL .= $extPath{0} . '/' . $extPath{1} . '/' . $extPath . '-l10n/' . $extPath . '-l10n-' . $lang . '.zip';
00092 $l10n = t3lib_div::getURL($mirrorURL, 0, array(TYPO3_user_agent));
00093
00094 if($l10n !== false) {
00095 return array($l10n);
00096 } else {
00097 return 'Error: Translation could not be fetched.';
00098 }
00099 }
00100
00101
00102
00103
00104
00105
00106
00107
00108 function fetchTranslationStatus($extKey, $mirrorURL) {
00109 $extPath = t3lib_div::strtolower($extKey);
00110 $mirrorURL .= $extPath{0} . '/' . $extPath{1} . '/' . $extPath . '-l10n/' . $extPath . '-l10n.xml';
00111 $remote = t3lib_div::getURL($mirrorURL, 0, array(TYPO3_user_agent));
00112
00113 if($remote !== false) {
00114 $parsed = $this->emObj->xmlhandler->parseL10nXML($remote);
00115 return $parsed['languagePackIndex'];
00116 }
00117
00118 return FALSE;
00119 }
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129 function decodeServerData($externalData) {
00130 $parts = explode(':',$externalData,4);
00131 $dat = base64_decode($parts[2]);
00132
00133 if (ltrim($parts[0])==md5($dat)) {
00134 if ($parts[1]=='gzcompress') {
00135 if (function_exists('gzuncompress')) {
00136 $dat = gzuncompress($dat);
00137 } else return 'Decoding Error: No decompressor available for compressed content. gzuncompress() function is not available!';
00138 }
00139 $listArr = unserialize($dat);
00140
00141 if (is_array($listArr)) {
00142 return $listArr;
00143 } else {
00144 return 'Error: Unserialized information was not an array - strange!';
00145 }
00146 } else return 'Error: MD5 hashes in T3X data did not match!';
00147 }
00148
00149
00150
00151
00152
00153
00154
00155
00156 function decodeExchangeData($str) {
00157 $parts = explode(':',$str,3);
00158 if ($parts[1]=='gzcompress') {
00159 if (function_exists('gzuncompress')) {
00160 $parts[2] = gzuncompress($parts[2]);
00161 } else return 'Decoding Error: No decompressor available for compressed content. gzcompress()/gzuncompress() functions are not available!';
00162 }
00163 if (md5($parts[2]) == $parts[0]) {
00164 $output = unserialize($parts[2]);
00165 if (is_array($output)) {
00166 return array($output,'');
00167 } else return 'Error: Content could not be unserialized to an array. Strange (since MD5 hashes match!)';
00168 } else return 'Error: MD5 mismatch. Maybe the extension file was downloaded and saved as a text file by the browser and thereby corrupted!? (Always select "All" filetype when saving extensions)';
00169 }
00170
00171
00172
00173
00174
00175
00176
00177
00178 function makeUploadDataFromArray($uploadArray) {
00179 if (is_array($uploadArray)) {
00180 $serialized = serialize($uploadArray);
00181 $md5 = md5($serialized);
00182
00183 $content = $md5.':';
00184 $content.= 'gzcompress:';
00185 $content.= gzcompress($serialized);
00186 }
00187 return $content;
00188 }
00189
00190
00191
00192
00193
00194
00195
00196 function uploadToTER($em) {
00197 $uArr = $this->emObj->makeUploadArray($em['extKey'],$em['extInfo']);
00198 if(!is_array($uArr)) return $uArr;
00199
00200
00201 $newVersionBase = $em['extInfo']['EM_CONF']['version'];
00202 switch((string)$em['upload']['mode']) {
00203 case 'new_dev':
00204 $cmd='dev';
00205 break;
00206 case 'new_sub':
00207 $cmd='sub';
00208 break;
00209 case 'new_main':
00210 $cmd='main';
00211 break;
00212 case 'custom':
00213 $newVersionBase = $em['upload']['version'];
00214 case 'latest':
00215 default:
00216 $cmd='';
00217 break;
00218 }
00219 $versionArr = $this->emObj->renderVersion($newVersionBase, $cmd);
00220 $em['version'] = $versionArr['version'];
00221
00222
00223 $dependenciesArr = array ();
00224 $extKeysArr = $uArr['EM_CONF']['constraints']['depends'];
00225
00226 if (is_array($extKeysArr)) {
00227 foreach ($extKeysArr as $extKey => $version) {
00228 if (strlen($extKey)) {
00229 $dependenciesArr[] = array (
00230 'kind' => 'depends',
00231 'extensionKey' => utf8_encode($extKey),
00232 'versionRange' => utf8_encode($version),
00233 );
00234 }
00235 }
00236 }
00237
00238 $extKeysArr = $uArr['EM_CONF']['constraints']['conflicts'];
00239 if (is_array($extKeysArr)) {
00240 foreach ($extKeysArr as $extKey => $version) {
00241 if (strlen($extKey)) {
00242 $dependenciesArr[] = array (
00243 'kind' => 'conflicts',
00244 'extensionKey' => utf8_encode($extKey),
00245 'versionRange' => utf8_encode($version),
00246 );
00247 }
00248 }
00249 }
00250
00251 if (count($dependenciesArr) == 1) {
00252 $dependenciesArr[] = array (
00253 'kind' => 'depends',
00254 'extensionKey' => '',
00255 'versionRange' => '',
00256 );
00257 }
00258
00259
00260
00261 $accountData = array(
00262 'username' => $em['user']['fe_u'],
00263 'password' => $em['user']['fe_p']
00264 );
00265 $extensionData = array (
00266 'extensionKey' => utf8_encode($em['extKey']),
00267 'version' => utf8_encode($em['version']),
00268 'metaData' => array (
00269 'title' => utf8_encode($uArr['EM_CONF']['title']),
00270 'description' => utf8_encode($uArr['EM_CONF']['description']),
00271 'category' => utf8_encode($uArr['EM_CONF']['category']),
00272 'state' => utf8_encode($uArr['EM_CONF']['state']),
00273 'authorName' => utf8_encode($uArr['EM_CONF']['author']),
00274 'authorEmail' => utf8_encode($uArr['EM_CONF']['author_email']),
00275 'authorCompany' => utf8_encode($uArr['EM_CONF']['author_company']),
00276 ),
00277 'technicalData' => array (
00278 'dependencies' => $dependenciesArr,
00279 'loadOrder' => utf8_encode($uArr['EM_CONF']['loadOrder']),
00280 'uploadFolder' => (boolean) intval($uArr['EM_CONF']['uploadfolder']),
00281 'createDirs' => utf8_encode($uArr['EM_CONF']['createDirs']),
00282 'shy' => (boolean) intval($uArr['EM_CONF']['shy']),
00283 'modules' => utf8_encode($uArr['EM_CONF']['module']),
00284 'modifyTables' => utf8_encode($uArr['EM_CONF']['modify_tables']),
00285 'priority' => utf8_encode($uArr['EM_CONF']['priority']),
00286 'clearCacheOnLoad' => (boolean) intval($uArr['EM_CONF']['clearCacheOnLoad']),
00287 'lockType' => utf8_encode($uArr['EM_CONF']['lockType']),
00288 ),
00289 'infoData' => array(
00290 'codeLines' => intval($uArr['misc']['codelines']),
00291 'codeBytes' => intval($uArr['misc']['codebytes']),
00292 'codingGuidelinesCompliance' => utf8_encode($uArr['EM_CONF']['CGLcompliance']),
00293 'codingGuidelinesComplianceNotes' => utf8_encode($uArr['EM_CONF']['CGLcompliance_note']),
00294 'uploadComment' => utf8_encode($em['upload']['comment']),
00295 'techInfo' => $uArr['techInfo'],
00296 ),
00297 );
00298
00299 $filesData = array();
00300 foreach ($uArr['FILES'] as $filename => $infoArr) {
00301 $content = (!defined('SOAP_1_2') && class_exists('soapclient')) ? base64_encode($infoArr['content']) : $infoArr['content'];
00302 $filesData['fileData'][] = array (
00303 'name' => utf8_encode($infoArr['name']),
00304 'size' => intval($infoArr['size']),
00305 'modificationTime' => intval($infoArr['mtime']),
00306 'isExecutable' => intval($infoArr['is_executable']),
00307 'content' => $content,
00308 'contentMD5' => $infoArr['content_md5'],
00309 );
00310 }
00311
00312 $soap = t3lib_div::makeInstance('em_soap');
00313 $soap->init(array('wsdl'=>$this->wsdlURL,'soapoptions'=> array('trace'=>1,'exceptions'=>0)));
00314 $response = $soap->call('uploadExtension', array('accountData' => $accountData, 'extensionData' => $extensionData, 'filesData' => $filesData));
00315
00316 if($response===false) {
00317 switch(true) {
00318 case is_string($soap->error):
00319 return $soap->error;
00320 break;
00321 default:
00322 return $soap->error->faultstring;
00323 }
00324 }
00325
00326 return $response;
00327 }
00328 }
00329
00330 ?>