public function load() { $queries = $this->path . '/queries.php'; $script = $this->path . '/script.php'; if (file_exists($queries)) { $sql = null; include $queries; if (is_array($sql)) { $this->queries = $sql; } } if (file_exists($script)) { include_once $script; $suffix = str_replace('-', '_', baseName($this->path)); $class = 'Nano_Migrate_Script_' . $suffix; if (class_exists($class, false)) { $reflection = new ReflectionClass($class); if ($reflection->isInstantiable() && $reflection->isSubclassOf('Nano_Migrate_Script')) { $this->script = $reflection->newInstance(); } else { $this->script = Nano_Migrate_ScriptEmpty::instance(); } } else { $this->script = Nano_Migrate_ScriptEmpty::instance(); } } else { $this->script = Nano_Migrate_ScriptEmpty::instance(); } }
public function get_listing($path = '', $page = '') { global $CFG, $OUTPUT; $list = array(); $list['list'] = array(); // the management interface url $list['manage'] = false; // dynamically loading $list['dynload'] = true; // the current path of this list. // set to true, the login link will be removed $list['nologin'] = true; // set to true, the search button will be removed $list['nosearch'] = true; $tree = array(); if (empty($path)) { $buckets = $this->s->listBuckets(); foreach ($buckets as $bucket) { $folder = array('title' => $bucket, 'children' => array(), 'thumbnail' => $OUTPUT->old_icon_url('f/folder-32'), 'path' => $bucket); $tree[] = $folder; } } else { $contents = $this->s->getBucket($path); foreach ($contents as $file) { $info = $this->s->getObjectInfo($path, baseName($file['name'])); $tree[] = array('title' => $file['name'], 'size' => $file['size'], 'date' => userdate($file['time']), 'source' => $path . '/' . $file['name'], 'thumbnail' => $OUTPUT->old_icon_url(file_extension_icon($file['name'], 32))); } } $list['list'] = $tree; return $list; }
static function writeErrorToTempFile($message) { global $configuration; $tmpDir = sys_get_temp_dir(); $tmpFileName = tempnam($tmpDir, "PE-"); file_put_contents($tmpFileName, $message); return baseName($tmpFileName); }
function InitRecordCall($filename, $index, $comment) { //FIXME $user = gs_user_get($_SESSION['sudo_user']['name']); $call = "Channel: SIP/" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "MaxRetries: 0\n" . "WaitTime: 15\n" . "Context: vm-rec-multiple\n" . "Extension: webdialrecord\n" . "Callerid: {$comment} <Aufnahme>\n" . "Setvar: __user_id=" . $_SESSION['sudo_user']['info']['id'] . "\n" . "Setvar: __user_name=" . $_SESSION['sudo_user']['info']['ext'] . "\n" . "Setvar: CHANNEL(language)=" . gs_get_conf('GS_INTL_ASTERISK_LANG', 'de') . "\n" . "Setvar: __is_callfile_origin=1\n" . "Setvar: __callfile_from_user="******"\n" . "Setvar: __record_file=" . $filename . "\n"; $filename = '/tmp/gs-' . $_SESSION['sudo_user']['info']['id'] . '-' . _pack_int(time()) . rand(100, 999) . '.call'; $cf = @fOpen($filename, 'wb'); if (!$cf) { gs_log(GS_LOG_WARNING, 'Failed to write call file "' . $filename . '"'); echo 'Failed to write call file.'; die; } @fWrite($cf, $call, strLen($call)); @fClose($cf); @chmod($filename, 0666); $spoolfile = '/var/spool/asterisk/outgoing/' . baseName($filename); if (!gs_get_conf('GS_INSTALLATION_TYPE_SINGLE')) { $our_host_ids = @gs_get_listen_to_ids(); if (!is_array($our_host_ids)) { $our_host_ids = array(); } $user_is_on_this_host = in_array($_SESSION['sudo_user']['info']['host_id'], $our_host_ids); } else { $user_is_on_this_host = true; } if ($user_is_on_this_host) { # the Asterisk of this user and the web server both run on this host $err = 0; $out = array(); @exec('sudo mv ' . qsa($filename) . ' ' . qsa($spoolfile) . ' 1>>/dev/null 2>>/dev/null', $out, $err); if ($err != 0) { @unlink($filename); gs_log(GS_LOG_WARNING, 'Failed to move call file "' . $filename . '" to "' . '/var/spool/asterisk/outgoing/' . baseName($filename) . '"'); echo 'Failed to move call file.'; die; } } else { $cmd = 'sudo scp -o StrictHostKeyChecking=no -o BatchMode=yes ' . qsa($filename) . ' ' . qsa('root@' . $user['host'] . ':' . $filename); //echo $cmd, "\n"; @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err); @unlink($filename); if ($err != 0) { gs_log(GS_LOG_WARNING, 'Failed to scp call file "' . $filename . '" to ' . $user['host']); echo 'Failed to scp call file.'; die; } //remote_exec( $user['host'], $cmd, 10, $out, $err ); // <-- does not use sudo! $cmd = 'sudo ssh -o StrictHostKeyChecking=no -o BatchMode=yes -l root ' . qsa($user['host']) . ' ' . qsa('mv ' . qsa($filename) . ' ' . qsa($spoolfile)); //echo $cmd, "\n"; @exec($cmd . ' 1>>/dev/null 2>>/dev/null', $out, $err); if ($err != 0) { gs_log(GS_LOG_WARNING, 'Failed to mv call file "' . $filename . '" on ' . $user['host'] . ' to "' . $spoolfile . '"'); echo 'Failed to mv call file on remote host.'; die; } } }
public function __construct($fileidentifier) { try { $this->fullpath = $fileidentifier; $this->name = baseName($fileidentifier); $this->ext = strtolower(preg_replace('/^.*\\./', '', $this->name)); $this->relativePathHash = getFilePathHash($fileidentifier); } catch (Exception $e) { } }
function print_usage($options) { echo 'Usage: ' . baseName(__FILE__) . ' [options]' . "\n\t"; echo '-v : verbose mode - default is to be extremely silent' . "\n\t"; echo '-h : create html table and exit' . "\n\t"; echo '-w : set working directory - default: "/tmp/gen_prompts/' . "\n\t"; echo '-l : select output language(s) - default: "de,en"' . "\n\t"; echo '-e : select database engine - default: "file"' . "\n\t"; echo '-f : use CSV file as source' . "\n\t"; echo '-g : specify voice generator command - default: "mbrola {INFILE} {OUTFILE}"' . "\n\t"; echo '-s : specify output file suffixes - default: ".wav"' . "\n\n"; }
public function uploadFile($local_file, $remote_key = false, $private = true) { if ($private) { $s3_acl = S3::ACL_PRIVATE; } else { $s3_acl = S3::ACL_PUBLIC_READ; } if (!$remote_key) { $remote_key = baseName($local_file); } return $this->s3->putObjectFile($local_file, $this->bucket, $remote_key, $s3_acl); }
function _gs_ami_get_enabled() { $conf_files_enabled = array(); clearStatCache(); $files = glob('/etc/gemeinschaft/asterisk/manager.conf.d-enabled/*.conf'); foreach ($files as $filename) { $filename_basename = baseName($filename); $conf_files_enabled[] = $filename_basename; } unset($files); return $conf_files_enabled; }
public function __construct($exception) { $exceptionClass = get_class($exception); if ($exceptionClass != 'ErrorException') { $this->Message = $exceptionClass . ': ' . $exception->getMessage(); $this->BuildStackTrace($exception); $this->ClassName = $exceptionClass; } else { $this->Message = 'Error: ' . $exception->getMessage(); $this->BuildErrorTrace($exception); } $this->FileName = baseName($exception->getFile()); }
public static function amazonS3Upload($uploadFile, $prefix = "") { if (!$prefix && defined("AMAZON_DEFAULT_PREFIX")) { $prefix = AMAZON_DEFAULT_PREFIX; } $configClass = APP_NAMESPACE . "\\config"; $s3 = $configClass::getAmazonS3(); $out = ""; if ($s3->putObjectFile($uploadFile, AMAZON_BUCKET_NAME, $prefix . baseName($uploadFile), \S3::ACL_PUBLIC_READ)) { $out = AMAZON_BASE_PATH . $prefix . baseName($uploadFile); } return $out; }
public function upload() { if (!empty($this->_upload_dir)) { $this->_bucket_name .= $this->_bucket_name . '/' . $this->_upload_dir; } // アマゾンS3のインスタンス生成 $s3 = new S3($this->_access_key, $this->_secret_key); if (!$s3) { throw new Teamlab_Batch_Exception(sprintf("AWS接続に失敗しました。: %s", $this->_bucket_name)); } // ファイルアップロード if ($s3->putObjectFile($this->_upload_file, $this->_bucket_name, baseName($this->_upload_file), S3::ACL_PUBLIC_READ)) { return true; } else { throw new Teamlab_Batch_Transport_Exception(sprintf("ファイルのアップロードに失敗しました。サーバ情報:%s ファイル名:%s", $this->_bucket_name, baseName($this->_upload_file))); } }
public static function put($file, $type, $name = false) { global $globals; if (!$name) { $name = baseName($file); } if (empty($type)) { $type = 'notype'; } $uri = "{$type}/{$name}"; S3::setAuth($globals['Amazon_access_key'], $globals['Amazon_secret_key']); if (S3::putObjectFile($file, $globals['Amazon_S3_media_bucket'], $uri, S3::ACL_PUBLIC_READ, array(), array("Cache-Control" => "max-age=864000", "Expires" => gmdate("D, d M Y H:i:s T", time() + 864000)))) { //syslog(LOG_NOTICE, "Meneame, uploaded $uri to S3"); return true; } syslog(LOG_NOTICE, "Meneame, failed to upload {$uri} to S3"); return false; }
function fetch_vedio_url($url) { $files = file_get_url($url); $source_url = ""; if (strpos($url, 'www.tudou.com') !== false) { if (strpos($url, '.html')) { preg_match("/,iid: (\\w+)/i", $files, $items); $iid = $items[1]; if (!empty($iid)) { $source_url = "http://www.tudou.com/v/" . $iid . "/v.swf"; } } else { preg_match("/,iid: (\\w+)/i", $files, $items); $iid = $items[1]; if (!empty($iid)) { //$source_url=tudou_get($url); $source_url = "http://www.tudou.com/v/" . $iid . "/v.swf"; } else { $source_url = tudou_get($url); } } } elseif (strpos($url, 'v.ku6.com') !== false) { preg_match("/A.VideoInfo(.*)/i", $files, $context); $context = $context[1]; //匹配网页中的内容\"bigpicpath\" 获取图片 //id:\s*\"([^,]+) 获取 视频ID ,"http://player.ku6.com/refer/$id/v.swf" preg_match("/\"bigpicpath\":\"([^,]+)\"/i", $context, $items); //json的UTF8 js编码 $pattner = array('\\u003a' => ':', '\\u002e' => '.'); $pic = $items[1]; if (!empty($pic)) { preg_match("/id:\\s*\"([^,]+)\"/i", $context, $items); $id = $items[1]; $source_url = "http://player.ku6.com/refer/{$id}/v.swf"; } } elseif (strpos($url, 'v.youku.com') !== false) { // preg_match("/videoId2=(.*)';/i",$files,$items); // $videoId2=trim(str_replace('\'','',$items[1])); // if(!empty($videoId2)) // $source_url="http://player.youku.com/player.php/sid/$videoId2/v.swf"; $source_url = preg_replace("/id_(.*)\\.html(.*)/i", "http://player.youku.com/embed/\${1}", baseName($url)); } return $source_url; }
public static function wp_db_backup_completed(&$args) { $destination_s3 = get_option('wp_db_backup_destination_s3'); if (isset($destination_s3) && $destination_s3 == 1 && get_option('wpdb_dest_amazon_s3_bucket') && get_option('wpdb_dest_amazon_s3_bucket_key') && get_option('wpdb_dest_amazon_s3_bucket_secret')) { try { if (!class_exists('S3')) { require_once 'S3.php'; } // AWS access info if (!defined('awsAccessKey')) { define('awsAccessKey', get_option('wpdb_dest_amazon_s3_bucket_key')); } if (!defined('awsSecretKey')) { define('awsSecretKey', get_option('wpdb_dest_amazon_s3_bucket_secret')); } // Check for CURL if (!extension_loaded('curl') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) { error_log("ERROR: CURL extension not loaded"); } $s3 = new S3(awsAccessKey, awsSecretKey); $bucketName = get_option('wpdb_dest_amazon_s3_bucket'); $result = $s3->listBuckets(); if (get_option('wpdb_dest_amazon_s3_bucket')) { if (in_array(get_option('wpdb_dest_amazon_s3_bucket'), $result)) { if ($s3->putObjectFile($args[1], $bucketName, baseName($args[1]), S3::ACL_PUBLIC_READ)) { error_log("S3::{$args['0']} upload in bucket {$bucketName}"); $args[2] = $args[2] . '<br> Upload Database Backup on s3 bucket ' . $bucketName; } else { error_log("S3::Failed to upload {$args['0']}"); $args[2] = $args[2] . '<br>Failed to upload Database Backup on s3 bucket ' . $bucketName; } } else { error_log("Invalid bucket name or AWS details"); $args[2] = $args[2] . '<br>Invalid bucket name or AWS details'; } } } catch (Exception $e) { // echo ($e->getMessage()); error_log("Invalid AWS details"); } } }
function gs_gen_ivr_pretty($ext, $ivr, $name = 'main', $level = 0) { if (!is_array($ivr)) { return ''; } static $indentstr = ' '; $indent = str_repeat($indentstr, $level * 2); $ret = ''; if (is_array(@$ivr['dp'])) { foreach ($ivr['dp'] as $step) { if (!preg_match('/^([a-z]+)\\s+(.*)/', $step, $m)) { continue; } $cmd = $m[1]; $cmddata = $m[2]; switch ($cmd) { case 'play': $ret .= $indent . "PLAY " . baseName($cmddata) . "\n"; break; case 'app': $ret .= $indent . "APP {$cmddata}\n"; break; case 'hangup': //$ret.= $indent. "(hangup)\n"; break; } } } if (!is_array(@$ivr['options'])) { //$ret.= $indent. "(hangup)\n"; } else { //$ret.= $indent. "(wait)\n"; foreach ($ivr['options'] as $newext => $newivr) { $ret .= $indentstr . $indent . "\n"; //$ret.= $indentstr.$indent. $newext ."\n"; $ret .= $indentstr . $indent . str_pad($newext, 4, ' ') . ' '; $ret2 = gs_gen_ivr_pretty($newext, $newivr, $name . "-" . str_replace(array('#', '*'), array('pound', 'star'), $newext), $level + 1); $ret .= preg_replace('/^[ ]{' . (strLen($indentstr) * 2 + strLen($indent) - 3) . '}/', '', $ret2); } } return $ret; }
function generateXmlCache($xmlFiles, $callback = 'parseDatabaseDefinitionFile') { global $aSkipFiles, $aOptions, $oDbh, $oCache; foreach ($xmlFiles as $fileName) { if (!in_array(baseName($fileName), $aSkipFiles)) { echo " => " . basename($fileName) . ": "; flush(); $oSchema =& MDB2_Schema::factory($oDbh, $aOptions); $result = $oSchema->{$callback}($fileName, true); if (PEAR::isError($result)) { clean_up(); die("Failed\n"); } else { $oCache->save($result, $fileName); echo "Processed"; eol_flush(); } unset($result); } } }
/** * The sole constructor that creates a new URL from supplied location * * @param string $location an URL */ function __construct($location) { $this->location = $location; // Regex the url into components preg_match(self::$regexURL, $location, $matches ); $this->protocol = (strLen(@$matches['proto']) > 0) ? strToLower(@$matches['proto']):null; $this->user = (strLen(@$matches['user']) > 0) ? @$matches['user']:null; $this->password = (strLen(@$matches['haspass']) > 0) ? @$matches['pass']:null; $this->host = (strLen(@$matches['host']) > 0) ? strToLower(@$matches['host']):null; //Should we get concerned on default port? // $this->port = ( ! isSet($matches['port'])) ? getProtoByName($matches['proto']) : $matches['port']; $this->port = (strLen(@$matches['port']) > 0) ? @$matches['port']:null; $this->path = rtrim(@$matches['path'],($this->resource = baseName(@$matches['path']))); //$this->resource = baseName(@$matches['path']); // $this->path = (strLen(@$matches['path']) > 1) ? str_replace('\\', '/', dirName(@$matches['path'])) . '/' : ''; // $this->resource = baseName(@$matches['path']); preg_match('~(?P<ext>\.[^.]*)~',$this->resource,$extmatches); $this->extension = @$extmatches['ext']; $this->ref = (strLen(@$matches['ref']) > 0) ? @$matches['ref']:null; //keep query as an array if (( strLen(@$matches['hasquery']) > 1) ) foreach(explode('&', $matches['query']) as $q) { list($name,$value) = @explode('=', $q, 2); if (strLen($name) > 0) { $this->query[$name] = ($value = urlDecode($value)) ? $value:''; } } else $this->query = null; }
/** * This method is overridden to possibly cache (serialize) the element tree if the caching * is enabled in the package configuration file. * @param string $fileName the absolute file name to parse * @return SDElement the root element of the tree, possibly retrieved from the cache * @throws SDParserException if something goes wrong */ function parse($fileName) { $pkg = Package::getPackageByName('html'); if($pkg->getProperty('cache.parserCache', false)) { $path = $pkg->getProperty('cache.parserCachePath', '/tmp'); $cacheFile = $path . '/' . crc32($fileName) . '_' . baseName($fileName); if(file_exists($cacheFile) && filemtime($cacheFile) >= filemtime($fileName)) { $rv = unSerialize(file_get_contents($cacheFile)); $rv->setDocument($this->doc); return $rv; } else { $rv = parent::parse($fileName); $rv->setDocument(null); flock($fp = fopen($fileName, 'r'), LOCK_EX); file_put_contents($cacheFile, serialize($rv)); flock($fp, LOCK_UN); touch($cacheFile, filemtime($fileName)); $rv->setDocument($this->doc); return $rv; } } else { return parent::parse($fileName); } }
function _find_disk($preferred_device = null) { $devs = array(); if ($preferred_device) { $devs[] = $preferred_device; } $tmp = @glob('/dev/hd?'); if (is_array($tmp)) { foreach ($tmp as $dev) { $devs[] = baseName($dev); } } foreach ($devs as $dev) { $filetype = @fileType('/dev/' . $dev); if ($filetype === 'block') { if (file_exists('/proc/ide/' . $dev . '/media')) { if (trim(@file_get_contents('/proc/ide/' . $dev . '/media')) === 'disk') { return $dev; } } } } return null; }
function minecraftServerDelete($service_id, $filename, $type = "plugins") { global $config; //get the identifier $id = stripAlphaNumeric(getServiceParam($service_id, "id")); if ($id === false) { return "Error: the identifier for this service is not set."; } //if type is current directory, then it's for backups and restrict the extensions if ($type == "." && getExtension($filename) != 'uxbakzip') { return "Error: invalid world backup filename to delete."; } //escape the plugin $filename = escapeFile(baseName($filename)); $relTarget = $type . "/" . $filename; $target = $config['minecraft_path'] . $id . "/" . $relTarget; //unlink plugin (even if jail, the file itself is still stored in the minecraft_path folder if (file_exists($target)) { unlink($target); } //now, delete the symlink from the jail $jail = jailEnabled($service_id); if ($jail) { jailFileDelete($service_id, $relTarget); } }
function setBackup() { global $dbname, $dbh; global $PARAM, $SUBS, $MSG, $MONTHS; if (!is_dir(getAdmSetting('BACKUP_DIR'))) { MkDir(getAdmSetting('BACKUP_DIR'), 0777); } if ($PARAM['upload'] == 1) { global $bckFile, $bckFile_name; if ($bckFile_name == '') { $SUBS['ERROR'] = $MSG[20108]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } else { if (!($UPLOAD = @file($bckFile))) { setLogAndStatus("Reading", $bckFile, 0, "setBackup()", 'READ_UPLOAD'); } $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; $upload = '## ' . $MSG[20109] . date(' d F Y H:i:s') . "\n"; $upload .= "## {$MSG['20110']} {$bckFile_name}\n"; $upload .= join('', $UPLOAD); if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", $filename, 0, "setBackup()", 'OPEN_FILE'); } fwrite($fp, $upload); fclose($fp); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20050"; printPage('_admin_done.htmlt'); return; } } //export database backup if ($PARAM['export'] == 1) { $file = date('d F Y H_i_s'); $filename = getAdmSetting('BACKUP_DIR') . "/{$file}.sql"; if (!($fp = fopen($filename, 'w'))) { setLogAndStatus("Opening", 0, $filename, "setBackup()", 'OPEN_FILE'); } //write comments if any if ($PARAM['bckComments'] != '') { $comments = '##' . ereg_replace("\n", "\n##", $PARAM['bckComments']) . "\n"; fwrite($fp, $comments); } if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 0, $dbname, "setBackup()", 'LIST_TABLES'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $fields = db_list_fields($dbname, $table, $dbh); $columns = db_num_fields($fields); $tablelist = ''; for ($j = 0; $j < $columns; $j++) { if ($columns - $j == 1) { $tablelist .= db_field_name($fields, $j); } else { $tablelist .= db_field_name($fields, $j) . ','; } } $schema = "REPLACE INTO {$table} ({$tablelist}) VALUES ("; $query = "SELECT * FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'SELECT_TABLES'); while ($row = db_fetch_row($result)) { $schema_insert = ''; for ($j = 0; $j < $columns; $j++) { if (!isset($row[$j])) { $schema_insert .= ' NULL,'; } else { $schema_insert .= ' ' . dbQuote($row[$j]) . ','; } } $schema_insert = $schema . ereg_replace(',$', '', $schema_insert); $schema_insert .= ");\r\n"; fwrite($fp, $schema_insert); } $i++; } fclose($fp); // the ZIP thing -------------------- $fp = fopen($filename, "rb"); $data = fread($fp, filesize($filename)); fclose($fp); $name = array(baseName($filename)); $data = array($data); $content = makezip($name, $data); $fp = fopen('./zip/' . basename($filename) . '.ZIP', "wb"); fputs($fp, $content); fclose($fp); // the ZIP thing -------------------- $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20052"; printPage('_admin_done.htmlt'); return; } //prepare for import or delete $backups = opendir(getAdmSetting('BACKUP_DIR')); while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $BCKUPS[eregi_replace('[^a-z0-9]', '_', $file)] = getAdmSetting('BACKUP_DIR') . "/{$file}"; } } closedir($backups); reset($PARAM); while (list($k, $v) = each($PARAM)) { if (ereg('^bck_(.*)$', $k, $R)) { $BACKUPS[] = $R[1]; } } reset($PARAM); //delete backups if ($PARAM['delete'] == 1) { if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } for ($i = 0; $i < count($BACKUPS); $i++) { if (!@unlink($BCKUPS[$BACKUPS[$i]])) { setLogAndStatus("Deleting", $BCKUPS[$BACKUPS[$i]], "setBackup()", 'DEL_BACKUP'); } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20054"; printPage('_admin_done.htmlt'); return; } //import database backup if ($PARAM['import'] == 1) { if (count($BACKUPS) > 1) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20053"; printPage('_admin_done.htmlt'); return; } if (count($BACKUPS) == 0) { $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20008"; printPage('_admin_done.htmlt'); return; } //get backup file $file = fread(fopen($BCKUPS[$BACKUPS[0]], 'r'), filesize($BCKUPS[$BACKUPS[0]])); ////---- [Mrasnika's] Edition 21.03.2002 split_sql_file($BACKUP, $file); //reset tables if (!($res = db_list_tables($dbname, $dbh))) { setLogAndStatus("db_list_tables()", 1, $dbname, "databaseBackup()", 'LIST_TABLES_2'); } $num_tables = db_num_rows($res); $i = 0; while ($i < $num_tables) { $table = db_tablename($res, $i); $query = "DELETE FROM {$dbname}.{$table}"; $result = runQuery($query, 'setBackup()', 'RESET_TABLES'); $i++; } //fill tables while (list($k, $query) = each($BACKUP)) { if (!ereg('^#', $query)) { if (!($result = db_query($query, $dbh))) { setLogAndStatus($query, db_errno($dbh), db_error($dbh), "databaseBackup()", 'RESTORE_DB'); $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20055"; printPage('_admin_done.htmlt'); return; } } } $SUBS['COMMAND'] = $PARAM['cmd'] . "&err=20056"; printPage('_admin_done.htmlt'); return; } $backups = opendir(getAdmSetting('BACKUP_DIR')); $last = 0; while (($file = readdir($backups)) != false) { if (!is_dir($file)) { $date = stat(getAdmSetting('BACKUP_DIR') . "/{$file}"); if ($last < $date[9]) { $month = intval(date('m')); $SUBS['LAST'] = $MSG[20051] . date(' d ', $date[9]) . $MONTHS[$month] . date(' Y H.i.s', $date[9]); } $SUBS['SIZE'] = sprintf('%0.2f KB', $date[7] / 1024); $SUBS['NAME'] = eregi_replace('_', ':', $file); $SUBS['CHECK'] = eregi_replace('[^a-z0-9]', '_', $file); //checkbox name $SUBS['WHERE'] = getAdmSetting('BACKUP_DIR') . "/{$file}"; if (!($BACKUP = @file(getAdmSetting('BACKUP_DIR') . "/{$file}"))) { setLogAndStatus("Reading", 0, getAdmSetting('BACKUP_DIR') . "/{$file}", "setBackup()", 'READ_FILE'); } $comments = ''; //get comments from the beginning of the file for ($i = 0; $i < count($BACKUP); $i++) { if (eregi('^##(.*)$', $BACKUP[$i], $R)) { $comments .= $R[1]; } } if ($comments != '') { $SUBS['COMMENTS'] = ' ' . ereg_replace("\n", '<BR> ', htmlEncode($comments)); $SUBS['COMMENTS'] = ereg_replace('<BR> $', '', $SUBS['COMMENTS']); } else { $SUBS['COMMENTS'] = ''; } $SUBS['BACKUPS'] .= fileParse('_admin_backup_row.htmlt'); } } closedir($backups); if ($PARAM['err'] != '') { $SUBS['ERROR'] = $MSG[$PARAM['err']]; $SUBS['BACKUP_ERROR'] = fileParse('_admin_error.htmlt'); } printPage('_admin_backup.htmlt'); }
/** * Set the model file of one module. If there's an extension file, merge it with the main model file. * * @param string $moduleName the module name * @static * @access public * @return string the model file */ public static function setModelFile($moduleName) { global $app; /* Set the main model file and extension and hook pathes and files. */ $mainModelFile = $app->getModulePath($moduleName) . 'model.php'; $modelExtPath = $app->getModuleExtPath($moduleName, 'model'); $modelHookPath = $modelExtPath . 'hook/'; $extFiles = helper::ls($modelExtPath, '.php'); $hookFiles = helper::ls($modelHookPath, '.php'); /* If no extension files and no hook files, return the main file directly. */ if (empty($extFiles) and empty($hookFiles)) { return $mainModelFile; } /* Else, judge whether needed update or not .*/ $needUpdate = false; $mergedModelFile = $app->getTmpRoot() . 'model' . $app->getPathFix() . $moduleName . '.php'; $lastTime = file_exists($mergedModelFile) ? filemtime($mergedModelFile) : 0; while (!$needUpdate) { foreach ($extFiles as $extFile) { if (filemtime($extFile) > $lastTime) { break 2; } } foreach ($hookFiles as $hookFile) { if (filemtime($hookFile) > $lastTime) { break 2; } } if (is_dir($modelExtPath) and filemtime($modelExtPath) > $lastTime) { break; } if (is_dir($modelHookPath) and filemtime($modelHookPath) > $lastTime) { break; } if (filemtime($mainModelFile) > $lastTime) { break; } return $mergedModelFile; } /* If loaded zend opcache module, turn off cache when create tmp model file to avoid the conflics. */ if (extension_loaded('Zend OPcache')) { ini_set('opcache.enable', 0); } /* Update the cache file. */ $modelClass = $moduleName . 'Model'; $extModelClass = 'ext' . $modelClass; $extTmpModelClass = 'tmpExt' . $modelClass; $modelLines = "<?php\n"; $modelLines .= "helper::import('{$mainModelFile}');\n"; $modelLines .= "class {$extTmpModelClass} extends {$modelClass} \n{\n"; /* Cycle all the extension files. */ foreach ($extFiles as $extFile) { $extLines = self::removeTagsOfPHP($extFile); $modelLines .= $extLines . "\n"; } /* Create the merged model file and import it. */ $replaceMark = '//**//'; // This mark is for replacing code using. $modelLines .= "{$replaceMark}\n}"; /* Unset conflic function for model. */ preg_match_all('/.* function\\s+(\\w+)\\s*\\(.*\\)[^\\{]*\\{/Ui', $modelLines, $functions); $functions = $functions[1]; $conflics = array_count_values($functions); foreach ($conflics as $functionName => $count) { if ($count <= 1) { unset($conflics[$functionName]); } } if ($conflics) { $modelLines = explode("\n", $modelLines); $startDel = false; foreach ($modelLines as $line => $code) { if ($startDel and preg_match('/.* function\\s+(\\w+)\\s*\\(.*\\)/Ui', $code)) { $startDel = false; } if ($startDel) { unset($modelLines[$line]); } else { foreach ($conflics as $functionName => $count) { if ($count <= 1) { continue; } if (preg_match('/.* function\\s+' . $functionName . '\\s*\\(.*\\)/Ui', $code)) { $conflics[$functionName] = $count - 1; $startDel = true; unset($modelLines[$line]); } } } } $modelLines = join("\n", $modelLines); } $tmpMergedModelFile = $app->getTmpRoot() . 'model' . $app->getPathFix() . 'tmp.' . $moduleName . '.php'; if (!@file_put_contents($tmpMergedModelFile, $modelLines)) { die("ERROR: {$tmpMergedModelFile} not writable, please make sure the " . dirname($tmpMergedModelFile) . ' directory exists and writable'); } if (!class_exists($extTmpModelClass)) { include $tmpMergedModelFile; } /* Get hook codes need to merge. */ $hookCodes = array(); foreach ($hookFiles as $hookFile) { $fileName = baseName($hookFile); list($method) = explode('.', $fileName); $hookCodes[$method][] = self::removeTagsOfPHP($hookFile); } /* Cycle the hook methods and merge hook codes. */ $hookedMethods = array_keys($hookCodes); $mainModelCodes = file($mainModelFile); $mergedModelCodes = file($tmpMergedModelFile); foreach ($hookedMethods as $method) { /* Reflection the hooked method to get it's defined position. */ $methodRelfection = new reflectionMethod($extTmpModelClass, $method); $definedFile = $methodRelfection->getFileName(); $startLine = $methodRelfection->getStartLine() . ' '; $endLine = $methodRelfection->getEndLine() . ' '; /* Merge hook codes. */ $oldCodes = $definedFile == $tmpMergedModelFile ? $mergedModelCodes : $mainModelCodes; $oldCodes = join("", array_slice($oldCodes, $startLine - 1, $endLine - $startLine + 1)); $openBrace = strpos($oldCodes, '{'); $newCodes = substr($oldCodes, 0, $openBrace + 1) . "\n" . join("\n", $hookCodes[$method]) . substr($oldCodes, $openBrace + 1); /* Replace it. */ if ($definedFile == $tmpMergedModelFile) { $modelLines = str_replace($oldCodes, $newCodes, $modelLines); } else { $modelLines = str_replace($replaceMark, $newCodes . "\n{$replaceMark}", $modelLines); } } unlink($tmpMergedModelFile); /* Save it. */ $modelLines = str_replace($extTmpModelClass, $extModelClass, $modelLines); file_put_contents($mergedModelFile, $modelLines); return $mergedModelFile; }
private function maintenance($type, $data, $handle = '') { if (!isset($this->b['delete_time']) && !isset($this->b['delete_amount'])) { return true; } $delete = $dir = $files = array(); //get file list switch ($type) { case 'local': $dir = scandir(backup__($data['path']) . '/' . $this->b['_dirname']); break; case 'ftp': $dir = ftp_nlist($handle, '.'); break; case 'ssh': $cmd[] = fpbx_which('ssh'); $cmd[] = '-o StrictHostKeyChecking=no -i'; $cmd[] = $data['key']; $cmd[] = $data['user'] . '\\@' . $data['host']; $cmd[] = '-p ' . $data['port']; $cmd[] = 'ls -1 ' . $data['path'] . '/' . $this->b['_dirname']; exec(implode(' ', $cmd), $dir); unset($cmd); break; case 'awss3': $contents = $handle->getBucket($data['bucket']); foreach ($contents as $file) { $dir[] = $file['name']; } break; } //sanitize file list foreach ($dir as $file) { //dont include the current backup or special items if (in_array($file, array('.', '..', $this->b['_file'])) || !preg_match("/\\d+-\\d+-\\d+(?:-[0-9.]+(?:alpha|beta|rc|RC)?(?:\\d+(?:\\.[^\\.]+)*))?-\\d+.tgz/", $file)) { continue; } $f = explode('-', $file); //remove file sufix $files[$f[2]] = $file; } //sort file list based on backup creation time ksort($files, SORT_NUMERIC); //create delete list based on creation time if (isset($this->b['delete_time']) && $this->b['delete_time']) { $cut_line = strtotime($this->b['delete_time'] . ' ' . $this->b['delete_time_type'] . ' ago'); foreach ($files as $epoch => $file) { if ($epoch < $cut_line) { $delete[$epoch] = $file; } } } //create delete list based on quantity of files if (isset($this->b['delete_amount']) && $this->b['delete_amount']) { for ($i = 0; $i < $this->b['delete_amount']; $i++) { array_pop($files); } $delete = array_merge($files, $delete); } //now delete the actual files foreach ($delete as $key => $file) { switch ($type) { case 'local': unlink(backup__($data['path']) . '/' . $this->b['_dirname'] . '/' . $file); unset($delete[$key]); break; case 'ftp': ftp_delete($handle, $file); unset($delete[$key]); break; case 'awss3': $handle->deleteObject($data['bucket'], baseName($file)); break; case 'ssh': $cmd[] = fpbx_which('ssh'); $cmd[] = '-o StrictHostKeyChecking=no -i'; $cmd[] = $data['key']; $cmd[] = $data['user'] . '\\@' . $data['host']; $cmd[] = '-p ' . $data['port']; $cmd[] = 'rm ' . $data['path'] . '/' . '/' . $this->b['_dirname'] . '/' . $file; exec(implode(' ', $cmd)); unset($delete[$key]); unset($cmd); break; } } }
function init_deal_page_wap($deal_info) { $GLOBALS['tmpl']->assign("page_title", $deal_info['name']); if ($deal_info['seo_title'] != "") { $GLOBALS['tmpl']->assign("seo_title", $deal_info['seo_title']); } if ($deal_info['seo_keyword'] != "") { $GLOBALS['tmpl']->assign("seo_keyword", $deal_info['seo_keyword']); } if ($deal_info['seo_description'] != "") { $GLOBALS['tmpl']->assign("seo_description", $deal_info['seo_description']); } //开启限购后剩余几位 $deal_info['deal_item_count'] = 0; foreach ($deal_info['deal_item_list'] as $k => $v) { // 统计所有真实+虚拟(钱) $deal_info['total_virtual_person'] += $v['virtual_person']; $deal_info['total_virtual_price'] += $v['price'] * $v['virtual_person'] + $v['support_amount']; //统计每个子项目真实+虚拟(钱) $deal_info['deal_item_list'][$k]['person'] = $v['virtual_person'] + $v['support_count']; $deal_info['deal_item_list'][$k]['money'] = $v['price'] * $v['virtual_person'] + $v['support_amount']; $deal_info['deal_item_list'][$k]['cart_url'] = url_wap("cart#index", array("id" => $v['id'])); if ($v['limit_user']) { $deal_info['deal_item_list'][$k]['remain_person'] = $v['limit_user'] - $v['virtual_person'] - $v['support_count']; } $deal_info['deal_item_count']++; } // $deal_info['deal_type']=$GLOBALS['db']->getOne("select name from ".DB_PREFIX."deal_cate where id=".$deal_info['cate_id']); $deal_info['tags_arr'] = preg_split("/[ ,]/", $deal_info['tags']); $deal_info['support_amount_format'] = number_price_format($deal_info['support_amount']); $deal_info['limit_price_format'] = number_price_format($deal_info['limit_price']); $deal_info['total_virtual_price_format'] = number_price_format(intval($deal_info['total_virtual_price'])); $deal_info['remain_days'] = floor(($deal_info['end_time'] - NOW_TIME) / (24 * 3600)); $deal_info['percent'] = round($deal_info['support_amount'] / $deal_info['limit_price'] * 100); //$deal_info['deal_level']=$GLOBALS['db']->getOne("select level from ".DB_PREFIX."deal_level where id=".intval($deal_info['user_level'])); $deal_info['person'] = $deal_info['total_virtual_person'] + $deal_info['support_count']; $deal_info['percent'] = round($deal_info['total_virtual_price'] / $deal_info['limit_price'] * 100); $deal_info['update_url'] = url_wap("deal#update", array("id" => $deal_info['id'])); $deal_info['comment_url'] = url_wap("deal#comment", array("id" => $deal_info['id'])); $deal_info['info_url'] = url_wap("deal#info", array("id" => $deal_info['id'])); if ($deal_info['begin_time'] > NOW_TIME) { $deal_info['status'] = '0'; $deal_info['left_days'] = floor(($deal_info['begin_time'] - NOW_TIME) / (24 * 3600)); } elseif ($deal_info['end_time'] < NOW_TIME && $deal_info['end_time'] > 0) { if ($deal_info['percent'] >= 100) { $deal_info['status'] = '1'; } else { $deal_info['status'] = '2'; } } else { if ($deal_info['end_time'] > 0) { $deal_info['status'] = '3'; } else { $deal_info['status'] = '4'; } } if ($GLOBALS['user_info']) { $is_focus = $GLOBALS['db']->getOne("select count(*) from " . DB_PREFIX . "deal_focus_log where deal_id = " . $deal_info['id'] . " and user_id = " . intval($GLOBALS['user_info']['id'])); $GLOBALS['tmpl']->assign("is_focus", $is_focus); } if ($deal_info['user_id'] > 0) { $deal_user_info = $GLOBALS['db']->getRow("select id,user_name,province,city,intro,login_time from " . DB_PREFIX . "user where id = " . $deal_info['user_id'] . " and is_effect = 1"); if ($deal_user_info) { $deal_user_info['weibo_list'] = $GLOBALS['db']->getAll("select * from " . DB_PREFIX . "user_weibo where user_id = " . $deal_user_info['id']); $deal_user_info['image'] = get_user_avatar($deal_user_info['id'], 'middle'); $deal_info['user_info'] = $deal_user_info; } } if (!empty($deal_info['vedio']) && !preg_match("/http://player.youku.com/embed/i", $deal_info['source_video'])) { $deal_info['source_vedio'] = preg_replace("/id_(.*)\\.html(.*)/i", "http://player.youku.com/embed/\${1}", baseName($deal_info['vedio'])); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set source_vedio='" . $deal_info['source_vedio'] . "' where id=" . $deal_info['id']); } $GLOBALS['tmpl']->assign("deal_info", $deal_info); }
// echo "S3::getAccessControlPolicy(): {$bucketName}: ".print_r($acp, 1); // Update an access control policy ($acp should be the same as the data returned by S3::getAccessControlPolicy()) // $s3->setAccessControlPolicy($bucketName, '', $acp); // $acp = $s3->getAccessControlPolicy($bucketName); // echo "S3::getAccessControlPolicy(): {$bucketName}: ".print_r($acp, 1); // Enable logging for a bucket: // $s3->setBucketLogging($bucketName, 'logbucket', 'prefix'); // if (($logging = $s3->getBucketLogging($bucketName)) !== false) { // echo "S3::getBucketLogging(): Logging for {$bucketName}: ".print_r($contents, 1); // } else { // echo "S3::getBucketLogging(): Logging for {$bucketName} not enabled\n"; // } // Disable bucket logging: // var_dump($s3->disableBucketLogging($bucketName)); // Delete our file if ($s3->deleteObject($bucketName, baseName($uploadFile))) { echo "S3::deleteObject(): Deleted file\n"; // Delete the bucket we created (a bucket has to be empty to be deleted) if ($s3->deleteBucket($bucketName)) { echo "S3::deleteBucket(): Deleted bucket {$bucketName}\n"; } else { echo "S3::deleteBucket(): Failed to delete bucket (it probably isn't empty)\n"; } } else { echo "S3::deleteObject(): Failed to delete file\n"; } } else { echo "S3::putObjectFile(): Failed to copy file\n"; } } else { echo "S3::putBucket(): Unable to create bucket (it may already exist and/or be owned by someone else)\n";
public function investor_edit() { //股权众筹 发起项目编辑 if (!$GLOBALS['user_info']) { app_redirect(url_wap("user#login")); } if (app_conf("INVEST_STATUS") == 1) { showErr("股权众筹已经关闭"); } $ajax = intval($_REQUEST['ajax']); $id = intval($_REQUEST['id']); $GLOBALS['tmpl']->assign("id", $id); $user_name = $GLOBALS['db']->getOne("select user_name from " . DB_PREFIX . "user where id =" . intval($GLOBALS['user_info']['id'])); if ($id > 0) { $deal_item = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal where id = " . $id . " and is_delete = 0 "); if (empty($deal_item)) { showErr("该项目不存在"); } if ($deal_item['user_id'] != intval($GLOBALS['user_info']['id'])) { showErr("您没有该项目的权限!"); } } $is_effect = $deal_item['is_effect']; if ($id > 0 && $is_effect == 1) { showErr("项目已提交,不能更改", $ajax, ""); } if (!empty($deal_item['vedio']) && !preg_match("/http://player.youku.com/embed/i", $deal_item['source_video'])) { $deal_item['source_vedio'] = preg_replace("/id_(.*)\\.html(.*)/i", "http://player.youku.com/embed/\${1}", baseName($deal_item['vedio'])); $GLOBALS['db']->query("update " . DB_PREFIX . "deal set source_vedio='" . $deal_item['source_vedio'] . "' where id=" . $deal_item['id']); } $deal_item['business_create_time'] = to_date($deal_item['business_create_time'], 'Y-m-d'); $deal_item['limit_price'] = number_format($deal_item['limit_price'], 2); $cate = $GLOBALS['db']->getOne("select name from " . DB_PREFIX . "deal_cate where id =" . $deal_item['cate_id']); $GLOBALS['tmpl']->assign("cate", $cate); $GLOBALS['tmpl']->assign("user_name", $user_name); //编辑及管理团队 $stock_list = unserialize($deal_item['stock']); $GLOBALS['tmpl']->assign("stock_list", $stock_list); $unstock_list = unserialize($deal_item['unstock']); $GLOBALS['tmpl']->assign("unstock_list", $unstock_list); //项目历史执行资料 $history_list = unserialize($deal_item['history']); $GLOBALS['tmpl']->assign("history_list", $history_list); $total_history_income = 0; $total_history_out = 0; $total_history = 0; foreach ($history_list as $key => $v) { $total_history_income += floatval($v["info"]["item_income"]); $total_history_out += floatval($v["info"]["item_out"]); $total_history = $total_history_income - $total_history_out; } $GLOBALS['tmpl']->assign("total_history_income", $total_history_income); $GLOBALS['tmpl']->assign("total_history_out", $total_history_out); $GLOBALS['tmpl']->assign("total_history", $total_history); //未来三年内计划 $plan_list = unserialize($deal_item['plan']); $GLOBALS['tmpl']->assign("plan_list", $plan_list); $total_plan_income = 0; $total_plan_out = 0; $total_plan = 0; foreach ($plan_list as $key => $v) { $total_plan_income += floatval($v["info"]["item_income"]); $total_plan_out += floatval($v["info"]["item_out"]); $total_plan = $total_plan_income - $total_plan_out; } $GLOBALS['tmpl']->assign("total_plan_income", $total_plan_income); $GLOBALS['tmpl']->assign("total_plan_out", $total_plan_out); $GLOBALS['tmpl']->assign("total_plan", $total_plan); //项目附件 $attach_list = unserialize($deal_item['attach']); $GLOBALS['tmpl']->assign("attach_list", $attach_list); //资质证明 $audit_data_list = unserialize($deal_item['audit_data']); $GLOBALS['tmpl']->assign("audit_data_list", $audit_data_list); $GLOBALS['tmpl']->assign("deal_item", $deal_item); $GLOBALS['tmpl']->display("investor_edit.html"); }
echo "</tr>\n"; echo "<tr>\n"; echo '<th>', __('Datei'), '</th>', "\n"; echo '<td>'; if ($document) { echo '<input name="doc" type="text" value="' . $document . '"/>'; } else { echo '<input name="file" type="file" />'; } echo "</td>\n"; echo "</tr>\n"; echo "<tr>\n"; echo '<th> </th>', "\n"; echo '<th style="width:350px;">'; if ($file_ok) { echo baseName($_FILES['file']['name']), " (", round((int) $_FILES['file']['size'] / 1024), " kB)\n"; if ($fax_job_id) { echo '', __('wird gesendet.'), ' ID: ', $fax_job_id; } else { echo ' - ', __('Fehler beim Senden'); } } echo "</th>\n"; echo "</tr>\n"; echo "<tr>\n"; echo '<th> </th>', "\n"; echo '<td>'; echo '<button type="submit" title="', __('Senden'), '" class="plain">'; echo '<img src="', GS_URL_PATH, 'crystal-svg/16/act/fileprint.png" alt="', __('Senden'), '" />'; echo '</button>'; echo "</td>\n";
public function isSuite($test, $append = '') { $pathName = $test->getPathname(); $baseName = baseName($pathName); return is_dir($pathName . $append) && !in_array($baseName[0], array('_', '.')); }
/** * get the plugin details, by filename * * @param unknown_type $sFilename */ function getPluginDetails($sFilename) { foreach ($this->_aPluginDetails as $key => $row) { if ($sFilename == baseName($row->sFilename)) { return $row; } } return NULL; }
public function unipdfimport() { $s3Accesskey = Mage::getStoreConfig('imagecdn/amazons3/access_key_id'); $s3Secretkey = Mage::getStoreConfig('imagecdn/amazons3/secret_access_key'); // AWS access info if (!defined('awsAccessKey')) { define('awsAccessKey', $s3Accesskey); } if (!defined('awsSecretKey')) { define('awsSecretKey', $s3Secretkey); } // Check for CURL if (!extension_loaded('curl') && !@dl(PHP_SHLIB_SUFFIX == 'so' ? 'curl.so' : 'php_curl.dll')) { exit("\nERROR: CURL extension not loaded\n\n"); } $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $writeConnection = $resource->getConnection('core_write'); $query = 'SELECT * FROM `unicom_invoice` WHERE pdf_complete = "No"'; $orders = $readConnection->fetchAll($query); foreach ($orders as $order) { if ($order['ship_code']) { $del = 'DEL'; $locpos = strpos($order['ship_code'], $del); if ($locpos === false) { $username = '******'; $password = '******'; } else { $username = '******'; $password = '******'; } $cookie = '/tmp/curl-session'; $postdata = "j_username="******"&j_password="******"{$username}:{$password}"); curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie); curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata); /*$agent = $_SERVER["HTTP_USER_AGENT"]; curl_setopt ($ch, CURLOPT_USERAGENT, $agent);*/ $output = curl_exec($ch); $info = curl_getinfo($ch); curl_close($ch); if ($output) { $pdf = new Zend_Pdf(); $pdf = Zend_Pdf::parse($output); $fs_path = Mage::getBaseDir() . '/media/sales/order/pdf/' . $order['ship_code'] . '.pdf'; $pdf->save($fs_path); $uploadFile = $fs_path; // File to upload, we'll use the S3 class since it exists $bucketName = 'zoffio.invoices'; // Temporary bucket $morders = Mage::getModel('sales/order')->getCollection()->addAttributeToFilter('increment_id', $order['order_id']); foreach ($morders as $morder) { $orderDate = $morder->getCreatedAt(); } $year = date('Y', strtotime($orderDate)); $month = date('m', strtotime($orderDate)); $day = date('d', strtotime($orderDate)); $pdfFile = $year . "/" . $month . "/" . $day . "/" . baseName($uploadFile); // Put our file (also with public read access) $s3->putObjectFile($uploadFile, $bucketName, $pdfFile, S3::ACL_PUBLIC_READ); unlink($uploadFile); if ($order['state_complete'] == 'Yes') { $insertquery = "UPDATE `unicom_invoice` SET pdf_complete = 'Yes' WHERE ship_code = '" . $order['ship_code'] . "'"; $writeConnection->query($insertquery); } } } } }