/** * generate project based on template * @param array $services . note: here '/' in each service name is replaced by '__', to avoid dealing with packages * @param string $amfphpEntryPointUrl * @param String absolute url to folder where to put the generated code * @return null */ public function generate($services, $amfphpEntryPointUrl, $targetFolder) { foreach ($services as $service) { $service->name = str_replace('/', '__', $service->name); } $this->services = $services; $this->amfphpEntryPointUrl = $amfphpEntryPointUrl; Amfphp_BackOffice_ClientGenerator_Util::recurseCopy($this->templateFolderUrl, $targetFolder); $it = new RecursiveDirectoryIterator($targetFolder); foreach (new RecursiveIteratorIterator($it) as $file) { if (In_Array(SubStr($file, StrrPos($file, '.') + 1), $this->codeFileExtensions) == true) { $this->fileBeingProcessed = $file; $this->processSourceFile($file); } } }
private function HandleResponse($File, $Data) { if ($File === 'API/SupportedAPIList.json') { $Data = JSON_Decode($Data, true); if (!isset($Data['apilist']['interfaces'])) { return false; } foreach ($Data['apilist']['interfaces'] as $Interface) { $File = __DIR__ . '/API/' . $Interface['name'] . '.json'; $Interface = JSON_Encode($Interface, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . PHP_EOL; if (!File_Exists($File) || StrCmp(File_Get_Contents($File), $Interface) !== 0) { File_Put_Contents($File, $Interface); } } return true; } else { if ($File === 'ClientManifest/steam_client_publicbeta_osx' || $File === 'ClientManifest/steam_cmd_publicbeta_osx') { foreach ($this->ClientArchives as $Archive) { if (Preg_Match('/"' . Str_Replace('.', '\\.', $Archive) . '\\.([a-f0-9]{40})"/m', $Data, $Test) === 1) { $Test = $Test[1]; if (!isset($this->ETags[$Archive]) || $this->ETags[$Archive] !== $Test) { $this->Log('Downloading {lightblue}' . $Archive . '{normal} - checksum: ' . $Test); $this->ETags[$Archive] = $Test; $this->URLsToFetch[] = array('URL' => 'https://steamcdn-a.akamaihd.net/client/' . $Archive . '.' . $Test, 'File' => '.support/' . $Archive); } else { $this->Log('Matched {lightblue}' . $Archive . '{normal}, but we already have it cached'); } } else { $this->Log('{yellow}Failed to find {lightblue}' . $Archive); } } unset($Test); } else { if ($File === 'Random/ValveGroup.json' || $File === 'Random/SteamModerators.json') { LibXML_Use_Internal_Errors(true); $Data = SimpleXML_Load_String($Data); if ($Data === false || empty($Data->members->steamID64)) { return false; } $Data = Array_Values((array) $Data->members->steamID64); Sort($Data); $Data = JSON_Encode($Data, JSON_PRETTY_PRINT); } else { if ($File === 'Scripts/Dota2/heropickerdata.json') { $Data = JSON_Decode($Data, true); $Data = JSON_Encode($Data, JSON_PRETTY_PRINT); } else { if ($File === 'Scripts/Dota2/heropedia.js') { $Data = preg_replace('/\\?v=[0-9]+/', '?v=ayyvalve', $Data); } else { if (SubStr($File, 0, 13) === 'ItemSchemaURL') { $Data = JSON_Decode($Data, true); if (isset($Data['result']['items_game_url'])) { $this->URLsToFetch[] = array('URL' => $Data['result']['items_game_url'], 'File' => str_replace('ItemSchemaURL', 'ItemSchema', $File)); } return true; } else { if (SubStr($File, -4) === '.zip') { $File = __DIR__ . '/' . $File; File_Put_Contents($File, $Data); $Archive = SubStr(StrrChr($File, '/'), 1); if (SHA1_File($File) !== $this->ETags[$Archive]) { $this->Log('{lightred}Checksum mismatch for ' . $Archive); return false; } $this->ExtractClientArchives = true; return true; } else { if (SubStr($File, -5) === '.html') { if (StrrPos($Data, '</html>') === false) { return false; } } } } } } } } } $File = __DIR__ . '/' . $File; $Folder = dirname($File); if (!is_dir($Folder)) { $this->Log('{lightblue}Creating ' . $Folder); mkdir($Folder, 0755, true); } if (File_Exists($File) && StrCmp(File_Get_Contents($File), $Data) === 0) { return false; } File_Put_Contents($File, $Data); return true; }
} #--------------------------------------------------------------------------- $dHostingScheme = Current($dHostingScheme); #--------------------------------------------------------------------------- $Result = $Link->Query(SPrintF("SELECT * FROM `package_variable` WHERE `packageid` = %u", $dHostingScheme['id'])); if (Is_Error($Result)) { return $Link->GetError(); } #--------------------------------------------------------------------------- $dQuotas = MySQL::Result($Result); if (Is_Error($dQuotas)) { return ERROR | @Trigger_Error(500); } #--------------------------------------------------------------------------- foreach ($dQuotas as $dQuota) { $dHostingScheme[SubStr($dQuota['varname'], StrrPos($dQuota['varname'], '_') + 1)] = $dQuota['value']; } #--------------------------------------------------------------------------- $HostingScheme = new Tag('HostingScheme'); #--------------------------------------------------------------------------- $HostingScheme->AddChild(new Tag('ServersGroup', new Tag('Name', 'По умолчанию'))); $HostingScheme->AddChild(new Tag('Name', $dHostingScheme['planname'])); $HostingScheme->AddChild(new Tag('PackageID', $dHostingScheme['planname'])); $HostingScheme->AddChild(new Tag('CostDay', Round($dHostingScheme['price'] / $Course, 2))); $HostingScheme->AddChild(new Tag('CostMonth', $dHostingScheme['price'])); $HostingScheme->AddChild(new Tag('IsReselling', 1)); $HostingScheme->AddChild(new Tag('QuotaDisk', $dHostingScheme['disklimit'])); $HostingScheme->AddChild(new Tag('QuotaSubDomains', (int) @$dHostingScheme['subdom'])); $HostingScheme->AddChild(new Tag('QuotaDBs', (int) @$dHostingScheme['baseuserlimit'])); $HostingScheme->AddChild(new Tag('QuotaFTP', (int) @$dHostingScheme['ftplimit'])); $HostingScheme->AddChild(new Tag('QuotaEmail', (int) @$dHostingScheme['maillimit']));
return ERROR | @Trigger_Error(500); } #------------------------------------------------------------------------------- $UProfile = array('Name' => $ProfileName, 'Attribs' => $Attribs); #------------------------------------------------------------------------------- $Upload = Upload_Get('Document'); #------------------------------------------------------------------------------- switch (ValueOf($Upload)) { case 'error': return ERROR | @Trigger_Error(500); case 'exception': # No more... break; case 'array': #--------------------------------------------------------------------------- $Format = SubStr($Upload['Name'], StrrPos($Upload['Name'], '.') + 1); #--------------------------------------------------------------------------- $UProfile = Array_Merge($UProfile, array('Format' => StrToLower($Format))); break; default: return ERROR | @Trigger_Error(101); } #------------------------------------------------------------------------------- $Answer = array('Status' => 'Ok'); #------------------------------------------------------------------------------- if ($ProfileID) { #----------------------------------------------------------------------------- $IsUpdate = DB_Update('Profiles', $UProfile, array('ID' => $ProfileID)); if (Is_Error($IsUpdate)) { return ERROR | @Trigger_Error(500); }
/** * * @param array $services . note: here '/' in each service name must be replaced by '__', to avoid dealing with packages * @param string $amfphpEntryPointUrl * @return string folder where the data was written */ public function generate($services, $amfphpEntryPointUrl) { $this->services = $services; $this->amfphpEntryPointUrl = $amfphpEntryPointUrl; $dstFolder = 'ClientGenerator/Generated/' . date("Ymd-his-") . get_class($this); Amfphp_BackOffice_ClientGenerator_Util::recurseCopy($this->templateFolderUrl, AMFPHP_BACKOFFICE_ROOTPATH . $dstFolder); $it = new RecursiveDirectoryIterator($dstFolder); foreach (new RecursiveIteratorIterator($it) as $file) { if (In_Array(SubStr($file, StrrPos($file, '.') + 1), $this->codeFileExtensions) == true) { $this->fileBeingProcessed = $file; $this->processSourceFile($file); } } return $dstFolder; }
} else { print "table_taxonomy NOT FOUND! {$table_taxonomy} id: {$id} \n\r <br>"; $clean = CI::model('core')->deleteDataById($table_custom_fields, $q1['id']); } //p ( $q_check ); } } $file_path = MEDIAFILES . 'pictures/original/'; $it = new RecursiveDirectoryIterator($file_path); $display = array('jpeg', 'jpg'); $existing_files_on_hard_drive = array(); $existing_files_on_hard_drive_full = array(); $existing_files_do_be_deleted = array(); $table_media = $cms_db_tables['table_media']; foreach (new RecursiveIteratorIterator($it) as $file) { if (In_Array(SubStr($file, StrrPos($file, '.') + 1), $display) == true) { //echo $file . "<br/> \n"; $bname = basename($file); } $existing_files_on_hard_drive_full[] = $file; $existing_files_on_hard_drive[] = $bname; $q = "select count(id) as qty from {$table_media} where filename='{$bname}' "; //p ( $q ); $q = CI::model('core')->dbQuery($q, md5($q), 'media'); if ($q[0]['qty'] == 0) { //print 'delete: ' . $file; $existing_files_do_be_deleted[] = normalize_path($file, false); } else { //print 'found'; } }