Jump to content

neoson

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

neoson's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Woops, on another topic, I do not like this forum setup, but I digress... Here is a woops in the code I put in which I would like to modify but can't, it should be $a = get_attachments(6); $fp = fopen($a[1]['filename'], 'w'); fwrite($fp, $a[1]['attachment']); fclose($fp);
  2. I seem to be having a difficult time saving the attachments to a folder on the server, all the examples I see show it to the browser, what I need to do is copy the attachment to a separate folder and do some processing on it. So far everything I get, then ftp to my desktop appears corrupt. It works I just can't seem to unzip the zipped attachments, any ideas? My Code: (Not mine, I used examples from the web and put it into a function) function get_attachments($message_number){ global $connection; $structure = imap_fetchstructure($connection, $message_number); $attachments = array(); if(isset($structure->parts) && count($structure->parts)) { for($i = 0; $i < count($structure->parts); $i++) { $attachments[$i] = array( 'is_attachment' => false, 'filename' => '', 'name' => '', 'attachment' => '' ); if($structure->parts[$i]->ifdparameters) { foreach($structure->parts[$i]->dparameters as $object) { if(strtolower($object->attribute) == 'filename') { $attachments[$i]['is_attachment'] = true; $attachments[$i]['filename'] = $object->value; } } } if($structure->parts[$i]->ifparameters) { foreach($structure->parts[$i]->parameters as $object) { if(strtolower($object->attribute) == 'name') { $attachments[$i]['is_attachment'] = true; $attachments[$i]['name'] = $object->value; } } } if($attachments[$i]['is_attachment']) { $attachments[$i]['attachment'] = imap_fetchbody($connection, $message_number, $i+1); if($structure->parts[$i]->encoding == 3) { // 3 = BASE64 $attachments[$i]['attachment'] = base64_decode($attachments[$i]['attachment']); } elseif($structure->parts[$i]->encoding == 4) { // 4 = QUOTED-PRINTABLE $attachments[$i]['attachment'] = quoted_printable_decode($attachments[$i]['attachment']); } } } } return $attachments; } Calling Code: $a = get_attachments(6); $fp = fopen($a[1]['filename'], 'w'); fwrite($fp, $a); fclose($fp);
  3. I have tried it on the cmd line, gives me the same error
  4. It says exactly this "Caught exception: Failed to create COM object `Schedule.Service': Invalid syntax " Even with this code, which I found on a website, I added the try catch: <?php try{ $oSchedule = new COM("Schedule.Service"); $oSchedule->Connect(); $oFolder = $oSchedule->GetFolder("\\"); $oTaskDefinition = $oSchedule->NewTask(0); $RegistrationInfo = $oTaskDefinition->RegistrationInfo; $RegistrationInfo->Description = "Start notepad"; $RegistrationInfo->Author = "Author Name"; define('TASK_SERVICE_ACCOUNT', 5); $oPrincipal = $oTaskDefinition->Principal; $oPrincipal ->LogonType = TASK_SERVICE_ACCOUNT; $oSettings = $oTaskDefinition->Settings; $oSettings->Enabled = true; $oSettings->StartWhenAvailable = true; $oSettings->Hidden = false; define('TRIGGER_TYPE_TIME', 1); $oTrigger = $oTaskDefinition->Triggers->Create(TRIGGER_TYPE_TIME); $iTime = time()+30; $sStartTime = date('Y-m-d', $iTime).'T'.date('H:i:s', $iTime); $iTime += (60*5); $sEndTime = date('Y-m-d', $iTime).'T'.date('H:i:s', $iTime); $oTrigger->StartBoundary = $sStartTime; $oTrigger->EndBoundary = $sEndTime; $oTrigger->ExecutionTimeLimit = "PT5M"; //Five minutes; $oTrigger->Id = "TimeTriggerId"; $oTrigger->Enabled = true; define('ACTION_TYPE_EXEC', 0); $Action = $oTaskDefinition->Actions->Create(ACTION_TYPE_EXEC); $Action->Path = "C:\\Windows\\System32\\notepad.exe"; $empty = new VARIANT(); //Then we use this in the registering of our task: define('TASK_LOGON_GROUP', 4); $oFolder->RegisterTaskDefinition('NotePad', $oTaskDefinition, TASK_CREATE_OR_UPDATE, $empty, $empty, TASK_LOGON_GROUP); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; } ?>
  5. Any one have a way to have php schedule tasks in Windows? I everytime I tried: $schedule = new COM("Schedule.Service"); I get a syntax error, but I can't seem to find a "correct" syntax or any information on it. I need to be able to dynamically schedule weekly, monthly, or daily tasks via php, if there is an easier way I'm open to suggestions. Thanks
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.