PHP Formmailer Office365

<?php
require(„phpMailer/PHPMailerAutoload.php“);
$mail = new PHPMailer(true);
$mail->isSMTP();
$mail->Host = ’smtp.office365.com‘;
$mail->Port       = 587;
$mail->SMTPSecure = ‚tls‘;
$mail->SMTPAuth   = true;
$mail->Username = ‚eMAIl@OFFICE365.de‘;
$mail->Password = ‚Office365PW‘;
$mail->SetFrom(‚eMAIl@OFFICE365.de‘, ‚FromEmail‘);
$mail->addAddress(‚mich@elis.info‘, ‚ToEmail‘);
//$mail->SMTPDebug  = 3;
//$mail->Debugoutput = function($str, $level) {echo „debug level $level; message: $str“;}; //$mail->Debugoutput = ‚echo‘;
$mail->IsHTML(true);
$mail->Subject = ‚Here is the subject‘;
$mail->Body    = ‚This is the HTML message body <b>in bold!</b>‘;
$mail->AltBody = ‚This is the body in plain text for non-HTML mail clients‘;
if(!$mail->send()) {
    echo ‚Message could not be sent.‘;
    echo ‚Mailer Error: ‚ . $mail->ErrorInfo;
} else {
    echo ‚Message has been sent‘;
}
?>

Sage2Mysql

Daten aus SAGE (khk) in MYSQL übertragen mittels ODBC.

 

 

<?php

set_time_limit(0);

$conn2 = mysql_connect('localhost','ID','PW');
$db=mysql_select_db('data');


 function querykhk($query)
 {
 global $conn;
 if (!$conn) $conn = odbc_connect('KHK','ID','PW');
 $result=odbc_exec($conn, $query);
 if (!$result) echo "KHK Query Error $query (".odbc_errormsg().")";
 return $result;
 }


 function query($query) 
 {
 global $conn2;
 $result=mysql_query($query);
 if (!$result) {
 echo "Mysql Error $query (".mysql_error().")";
 sleep(10);
 }
 echo mysql_error();
 return $result;

 }



 function read_table($sql,$table)
 {
 global $conn;
 $first=1;
 $reskhk=querykhk($sql);
 
 echo "Open: ".$table." (".$rows.")n";
 while ($ergkhk=odbc_fetch_array($reskhk)) {
 $sc++;
 $cache[]=$ergkhk;
 echo $sc."r";
 }
 echo "Cache Read done ".count($cache)."n";
 echo "Close ODCBC: ".$table."n";
 echo "INSERT Mysql Start: ".$table."n";
 odbc_close($conn);
 
 
 foreach($cache as $ergkhk)
 {
 
 

 $i++;

 $vars='';
 $names='';
 $namesshort='';
 foreach($ergkhk as $name => $value)
 {
 $name=trim(str_replace("'","",$name));
 $value=trim(str_replace("'","",$value)); 
 if (strlen($name)>0) {
 $vars.="'".$value."',";
 $namesshort.="`$name`,";
 if (strpos(" ".$name,'text')>0) $names.="`$name` text NOT NULL,";
 else $names.="`$name` VARCHAR( 255 ) NOT NULL,";
 }
 }

 if ($first==1) {
 query("DROP TABLE `$table`;");
 query("
 CREATE TABLE `shopdata`.`$table` (
 $names
 `last` DATETIME NOT NULL 
 ) ENGINE = MYISAM ;

 ");
 unset($first);
 }
 query("INSERT IGNORE INTO `shopdata`.`$table` ($namesshort `last`) VALUES ($vars now());"); 
 
 }
 echo "Done: ".$table." (".$i.")n";
 }
 

//print_r($_SERVER);
 
if ($_SERVER[argv][1]==1) read_table("SELECT * FROM Auftraege where Vorgang='L'","auftraege");
if ($_SERVER[argv][1]==2) read_table("select * from Kundenkontakt_Ansprechpartner","kundenkontakt_ansprechpartner");
 //Kundennummer,Postleitzahl,Timestamp_Datum,Timestamp_Zeit,E_Mail,Rabattgruppe,Name1,Name2,Strasse,Ort
if ($_SERVER[argv][1]==3) read_table("select Kundennummer,Name1, Name2, Strasse, Ort, Vertreter1, Preisgruppe, Auswertungskennzeichen, Briefcode, Briefanrede, Kurzbezeichnung, Ansprechpartner_Kundennummer, Ansprechpartner_Nummer, Telefon, Telefax, Kundengruppe, Rabattgruppe, Postfach, Zahlungsart, Postleitzahl, Laendercode, E_Mail from Kunden order by Timestamp_Datum DES","kunden");
//, 
if ($_SERVER[argv][1]==4) read_table("Select * FROM Artikel","artikel");
if ($_SERVER[argv][1]==5) read_table('SELECT * FROM "Lieferanten"',"lieferanten");
if ($_SERVER[argv][1]==6) read_table('SELECT * FROM "KundenArtikelSonderpreise"',"kundenartikelsonderpreise");

 
 
?>

PHP Connect auf DB2 ohne Node oder Database Directory

<pre><?php
$conn_string = „DRIVER={IBM DB2 ODBC DRIVER – DB2COPY1};DATABASE=DB;HOSTNAME=SRV;PORT=50300;PROTOCOL=TCPIP;UID=User;PWD=PW;“;
$connect = odbc_connect($conn_string, “, “);

$query = „SELECT * from DWH.LIEFERANT“;

// perform the query
$result = odbc_exec($connect, $query);

while($erg=odbc_fetch_array($result)) {
print_r($erg);
}
?>

HowTo: Accessing Sharepoint Foundationsserver with PHP / Zugriff auf Sharepoint Foundationsserver mit PHP

Ein einfaches Bespiel:

<?php

$authParams = array(„login“ => „DOMAINUSER“, „password“ => „PW“);
$listName = „{LIST ID}“;
$rowLimit = ‚150‘;
$wsdl = „http://sharepoint-server/_vti_bin/Lists.asmx?WSDL&#8220;;
$soapClient = new SoapClient($wsdl, $authParams);
$params = array(‚listName‘ => $listName, ‚rowLimit‘ => $rowLimit);
$rawXMLresponse = null;
try{
$rawXMLresponse = $soapClient->GetListItems($params)->GetListItemsResult->any;
}
catch(SoapFault $fault){
echo ‚Fault code: ‚.$fault->faultcode;
echo ‚Fault string: ‚.$fault->faultstring;
die();
}

$dom = new DOMDocument();
$dom->loadXML($rawXMLresponse);
$results = $dom->getElementsByTagNameNS(„#RowsetSchema“, „*“);

foreach($results as $result){
echo „<hr>“;
foreach ($result->attributes as $attrName => $attrNode)
{
echo $attrName.“:“.$result->getAttribute($attrName).“<br/>“;
}
}

unset($soapClient);

?>

Howto: Script Autoimport Videofiles Mythtv

#!/usr/bin/php
<?

$db=mysql_connect(‚localhost‘,’root‘,’DBPW‘);
mysql_select_db(‚mythconverg‘);
echo mysql_errno() . „: “ . mysql_error(). „n“;

$d = dir(„/home/video/“);
while (false !== ($entry = $d->read())) {
if  ( (substr(strtolower($entry),-4)==‘.avi‘) or (substr(strtolower($entry),-4)==‘.vob‘)  ) {
echo $entry.“n“;
$res=mysql_query(„select * from recorded where basename=’$entry'“);
echo mysql_errno() . „: “ . mysql_error(). „n“;
if (mysql_num_rows($res)==0) {
echo „- not foundn“;
mysql_query(“

INSERT INTO `mythconverg`.`recorded` (
`chanid` ,
`starttime` ,
`endtime` ,
`title` ,
`subtitle` ,
`description` ,
`category` ,
`hostname` ,
`bookmark` ,
`editing` ,
`cutlist` ,
`autoexpire` ,
`commflagged` ,
`recgroup` ,
`recordid` ,
`seriesid` ,
`programid` ,
`lastmodified` ,
`filesize` ,
`stars` ,
`previouslyshown` ,
`originalairdate` ,
`preserve` ,
`findid` ,
`deletepending` ,
`transcoder` ,
`timestretch` ,
`recpriority` ,
`basename` ,
`progstart` ,
`progend` ,
`playgroup` ,
`profile` ,
`duplicate` ,
`transcoded` ,
`watched` ,
`storagegroup`
)
VALUES (
‚13040‘, NOW( ) , NOW( ) , ‚Movies‘, ‚$entry‘, ‚$entry‘, ‚Movie‘, ‚matrix‘, ‚1‘, ‚0‘, ‚0‘, ‚1‘, ‚1‘, ‚Default‘, ’33‘, “, “, NOW( ) , ‚366293748‘, ‚0‘, ‚0‘, ‚0000-00-00‘, ‚0‘, ‚0‘, ‚0‘, ‚0‘, ‚1‘, ‚-99‘, ‚$entry‘, NOW( ) , NOW( ) , ‚Default‘, ‚Default‘, ‚1‘, ‚0‘, ‚0‘, ‚Default‘
);

„);
echo mysql_errno() . „: “ . mysql_error(). „n“;

}
}
}

?>

HowTo: Mythtv Filename / Dateiname

Dateiname aus Aufzeichnungsname erstellen.

#!/usr/bin/php
<?

function allow_text($email)
{
$text=$email;
$chars = „ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-0123456789 „;
// Erlaubte Zeichen
$dummy = 0;
$helper = „“;
for ($i=0;$i<strlen($text);$i++)
{
for ($j=0;$j<strlen($chars);$j++) if ($text[$i]==$chars[$j]) $helper.=$text[                                                                                                 $i];
}

return $helper;
}

$db=mysql_connect(‚localhost‘,’root‘,’DBPW‘);
mysql_select_db(‚mythconverg‘);
echo mysql_errno() . „: “ . mysql_error(). „n“;

$res=mysql_query(„select *,date_format(starttime,’%d.%m.%Y %H:%i‘) as ‚dater‘ fr                                                                                                 om recorded where stars=0“);
echo mysql_num_rows($res);
while($erg=mysql_fetch_array($res))
{
$erg=str_replace(‚:‘,‘-‚,$erg);
$erg[title]=allow_text($erg[title]);
$erg[subtitle]=allow_text($erg[subtitle]);

system( „ln -s /home/video/“.$erg[basename].“ „/home/daten/Videos/“.$erg[tit                                                                                                 le].“ „.$erg[subtitle].“ „.$erg[dater].“.mpg““);
system(„mkdir „/home/daten/VideosSubtitle/“.$erg[title].“““);
system( „ln -s /home/video/“.$erg[basename].“ „/home/daten/VideosSubtitle/“.                                                                                                 $erg[title].“/“.$erg[subtitle].“ „.$erg[dater].“.mpg““);

}
mysql_query(‚update recorded set stars=1 where stars=0‘);

?>

Bloggen auf WordPress.com.

Nach oben ↑