Пример #1
0
 public static function truncateFeedItems()
 {
     Misc::logMotiomera("Start Feed::truncateFeedItems() ", 'info');
     $days = 7;
     if (defined('TRUNCATE_OLDER_THAN')) {
         $days = TRUNCATE_OLDER_THAN;
     }
     global $db;
     $sql = "DELETE FROM " . self::RELATION_TABLE . " WHERE datum < '" . date("Y-m-d", strtotime("-" . $days . "days")) . "%'";
     //string like "strtotime("-7 days"))"
     $db->query($sql);
     Misc::logMotiomera($sql, 'info');
     Misc::logMotiomera("End Feed::truncateFeedItems() ", 'info');
 }
Пример #2
0
#!/bin/php
<?php 
/**
 * Run this script to fix medals week by week
 * Pass two parameters -  year and week
 * php medal_from_cmd.php 2010 37
 */
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
$year = $_SERVER["argv"][1];
$week = $_SERVER["argv"][2];
echo date('Y-m-d h:i:s') . " [INFO] Start medal from command line year: {$year}, week {$week} \n";
Misc::logMotiomera("Start medal from command line year: {$year}, week {$week} ", 'INFO');
Sammanstallning::sammanstallMedaljer($year, $week);
Misc::logMotiomera("End medal from command line \n", 'INFO');
Пример #3
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start:  Cache Rss fedd from mabra.com cron script. \n";
Misc::logMotiomera("Start:  Cache Rss fedd from mabra.com cron script ", 'INFO');
$rss = new RSS();
$rss->getFeed();
Misc::logMotiomera("End Cache Rss fedd from mabra.com cron script \n", 'INFO');
Пример #4
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(ADMIN);
if (!empty($_GET['memberid']) && !empty($_GET['pokal'])) {
    $medlem = Medlem::loadById($_GET['memberid']);
    echo "Manual " . $_GET['pokal'] . "-pokal to " . $medlem->getANamn() . ", id = " . $_GET['memberid'] . " added to from Admin by " . $ADMIN->getANamn() . ", Sammanstallning:::nyPokal()";
    echo "\nSee also the logfile, /usr/local/motiomera/log/motiomera_xxx.log \n\n";
    Misc::logMotiomera($_GET['pokal'] . "-pokal to " . $medlem->getANamn() . ", id = " . $_GET['memberid'] . " added to from Admin by " . $ADMIN->getANamn(), 'INFO');
    Sammanstallning::nyPokal($medlem, $_GET['pokal'], date("Y-m-d"), 0, 1);
} else {
    echo '<h3>Det saknas paramatrar!</h3>';
}
Пример #5
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start medal cron script. \n";
Misc::logMotiomera("Start medal cron script ", 'INFO');
Sammanstallning::sammanstallMedaljer();
Misc::logMotiomera("End medal cron script \n", 'INFO');
Пример #6
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] krillo start. \n";
Misc::logMotiomera("Start krillo cron script ", 'INFO');
//Sammanstallning::sammanstallPokaler();
Misc::logMotiomera("End krillo cron script \n", 'INFO');
echo date('Y-m-d h:i:s') . " [INFO] krillo stop. \n";
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(ADMIN);
if (!empty($_GET['date'])) {
    $date = $_GET['date'];
    if (is_numeric($date) && strlen($date) == 8) {
        echo "This is executed via Foretag::saveAndEndForetagsTavling(" . $date . ") \nSee also the logfile, /usr/local/motiomera/log/motiomera.log \n\n";
        Misc::logMotiomera("Manual start of 'End and save competition data' started from Admin by " . $ADMIN->getANamn() . ", Date: " . $date, 'INFO');
        Foretag::saveAndEndForetagsTavling($date);
    } else {
        echo '<h3>Det verkar vara fel format på datumet!</h3>';
    }
} else {
    echo '<h3>Det saknas paramatrar!</h3>';
}
?>

Пример #8
0
 /**
  * Find all foretag_tillagg orders in status 20. 
  * If kundnummer is set for parent order then copy it and lift to status 30. 
  * The parent is found via the foretag_id 
  *
  * Added by krillo 100225
  */
 public static function liftTillaggOrderStatus()
 {
     Misc::logMotiomera("Start: Order::liftTillaggOrderStatus(), Copy customer numbers from parent orders to foretag_tillagg, status -> 30", 'info');
     global $db;
     $sql = "SELECT id, foretag_id FROM " . self::TABLE . " WHERE typ = 'foretag_tillagg' AND (kundnummer IS NULL OR kundnummer=1) AND orderId <> '' AND orderStatus = 20";
     $ordrar = Order::listByIds($db->valuesAsArray($sql));
     foreach ($ordrar as $order) {
         try {
             $foretag_id = $order->getForetagId();
             $sql = "SELECT kundnummer FROM " . self::TABLE . " WHERE typ = 'foretag' AND orderStatus >= 30 AND foretag_id = {$foretag_id}";
             $kundnummer = $db->value($sql);
             if (!empty($kundnummer)) {
                 $order->setKundnummer($kundnummer);
                 $order->setOrderStatus(self::ORDERSTATUS_CUST_NO);
                 $order->commit();
                 Misc::logMotiomera("Tillaggsorder -> status 30, foretag: " . $order->getForetag()->getNamn() . ", order_id: " . $order->getOrderId() . ",  CustomerId: " . $kundnummer, 'ok');
             } else {
                 Misc::logMotiomera("Customer nbr missing for: " . $order->getForetag()->getNamn() . ", order_id: " . $order->getOrderId(), 'WARNING');
             }
         } catch (Exception $e) {
             Misc::logMotiomera("Problems with order_id: " . $order->getOrderId(), 'error');
         }
     }
     Misc::logMotiomera("End: Order::liftTillaggOrderStatus()", 'info');
 }
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start:  send result email on tuesday cron script. \n";
Misc::logMotiomera("Start:  send result email on tuesday cron script ", 'INFO');
Foretag::foretagsTavlingEndSendEmail();
Misc::logMotiomera("End send result email on tuesday cron script \n", 'INFO');
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start put Faktura-files on FTP cron script. \n";
Misc::logMotiomera("Start put Faktura-files on FTP cron script ", 'INFO');
Foretag::uploadOrderFakturaFilesFTP();
Misc::logMotiomera("End put Faktura-files on FTP cron script \n", 'INFO');
Пример #11
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start put PDF-files on FTP cron script. \n";
Misc::logMotiomera("Start put PDF-files on FTP cron script ", 'INFO');
Foretag::uploadOrderFilesFTP();
Misc::logMotiomera("End put PDF-files on FTP cron script \n", 'INFO');
Пример #12
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start create PDF-files cron script. \n";
Misc::logMotiomera("Start create PDF-files cron script ", 'INFO');
Foretag::skapaFiler();
Misc::logMotiomera("End create PDF-files cron script \n", 'INFO');
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start friday email reminder cron script. \n";
Misc::logMotiomera("Start friday email reminder cron script ", 'INFO');
Foretag::sendRemindAboutSteg();
Misc::logMotiomera("End friday email reminder cron script \n", 'INFO');
Пример #14
0
                    $title = str_replace('#' . $field . '#', $value, $title);
                }
                ob_start();
                eval($yttre_mall_code);
                $resultat[$data['epost']]['text'] = ob_get_clean();
                $resultat[$data['epost']]['subject'] = $title;
            }
        }
        if (count($resultat)) {
            if (DEBUG) {
                echo "- Sending emails about reminder '" . $paminnelse->getNamn() . "': ";
                echo count($resultat) . " email(s).\n";
            }
            foreach ($resultat as $to => $email) {
                if (mail($to, $email['subject'], $email['text'])) {
                    if (DEBUG) {
                        echo "- Sent!\n";
                        echo "--------------------------\n";
                    }
                }
            }
        }
    }
}
if (DEBUG) {
    echo "\n\n";
}
// End code block
// krillo
Misc::logMotiomera("End paminnelse cron script \n", 'INFO');
Пример #15
0
    $paysonMsg = $order->total . ' ' . $paysonMsg;
} else {
    $sumToPay = $order->total;
}
$data = Order::setupPaysonConnection($order->email, $order->fname, $order->lname, $sumToPay, $paysonMsg);
$payResponse = $data['payResponse'];
Misc::logMotiomera(print_r($order, true), 'INFO', 'payson');
$api = $data['api'];
if ($payResponse->getResponseEnvelope()->wasSuccessful()) {
    // Payson Step 3: verify that it suceeded
    Misc::logMotiomera(print_r($payResponse, true), 'INFO', 'payson');
    $token = $payResponse->getToken();
    echo $token;
    //header("Location: " . $api->getForwardPayUrl($payResponse)); //do the redirection to payson
} else {
    Misc::logMotiomera(print_r($payResponse, true), 'ERROR', 'payson');
    throw new UserException("Problem med Payson.se", "Det är något problem med betaltjänsten Payson.se. Prova igen senare.");
}
$paymenttype = 'payson';
$ip = $_SERVER['REMOTE_ADDR'];
$orderPRIV3 = null;
$orderPRIV12 = null;
$orderFRAKT02 = null;
$orderId = '';
if ($order->PRIV3 > 0) {
    echo "inne priv3";
    $orderPRIV3 = Order::__constructOrderWithSameRefId($ordertyp, $medlem, 'PRIV3', 1, $order->channel, $order->campcode, 0, false, $token);
    $orderPRIV3->setCompanyName($order->fname . ' ' . $order->lname);
    $orderPRIV3->setPrice(Order::$campaignCodes['PRIV3']['pris']);
    $orderPRIV3->setQuantity($order->PRIV3);
    $orderPRIV3->setAntal($order->PRIV3);
Пример #16
0
 /**
  * Creates a reclamation PDF and puts it on the FTP
  * Returns true if operation succeds
  * @param int $nbr
  * @return boolean   
  */
 public function sendReclamation($nbr)
 {
     $foretag_id = $this->getId();
     try {
         $fileName = $this->createReclamationPDF($nbr);
         $localFile = FORETAGSFIL_LOCAL_PATH . "/" . $fileName;
         $serverFile = FORETAGSFIL_REMOTE_PATH . "/" . $fileName;
         if (Foretag::uploadFilesFTP('reclamation', $localFile, $serverFile)) {
             Misc::logMotiomera("Reclamation order, {$nbr} pedomerters,  foretag_id: {$foretag_id}", 'ok');
             return true;
         } else {
             return false;
         }
     } catch (Exception $e) {
         Misc::logMotiomera("Problem with reclamation order, {$nbr} pedomerters,  foretag_id: {$foretag_id} " . $e, 'error');
         return false;
     }
 }
Пример #17
0
        //legacy or not used right now
        $maffcode = '';
        //legacy or not used right now
        $medlem = new Medlem($order->email, $order->anamn, $kommun, $order->sex, $order->fname, $order->lname, $kontotyp, $maffcode);
        $medlem->confirm($order->pass);
        $medlem->setAddress($order->street);
        $medlem->setCo($order->co);
        $medlem->setZip($order->zip);
        $medlem->setCity($order->city);
        $medlem->setPhone($order->phone);
        $medlem->setCountry($order->country);
        $medlem->setEpostBekraftad(1);
        //medlem valid
        $medlem->setLevelId(1);
        $foretagsnyckel = $foretag->generateNycklar(1, true, $foretag->getOrderId());
        $medlem->setForetagsnyckel($foretagsnyckel[0]);
        $medlem->commit();
        $medlem->loggaIn($order->email, $order->pass, true);
        //header("Location: " . '/pages/minsida.php?mmForetagsnyckel=' . $foretagsnyckel[0]);
        header("Location: " . '/pages/minsida.php');
    } catch (Exception $e) {
        $msg = $e->getMessage();
        Misc::logMotiomera("Exception -  medlem_foretagskod.php  Params:\n" . print_r($order, true) . "\n CompanyId = {$companyId} \n Foretagsnyckel  \n " . print_r($foretagsnyckel, true) . "\n msg: " . $msg . "\n", 'ERROR');
        $redirPage .= "&msg=" . urlencode($msg);
        header('Location: ' . $redirPage);
    }
} else {
    Misc::logMotiomera("Error action/medlem_foretagskod.php  Fel Verifikationskod! \n Params:\n" . print_r($order, true) . "\n CompanyId = {$companyId} \n Foretagsnyckel  \n " . print_r($foretagsnyckel, true), 'ERROR');
    $redirPage .= "&msg=wrong_code";
    header('Location: ' . $redirPage);
}
Пример #18
0
<?php

require $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(ADMIN);
if (!empty($_GET['year']) && !empty($_GET['weekstart']) && !empty($_GET['weekstop'])) {
    echo "This is executed via Sammanstallning:sammanstallMedaljer(" . $_GET['year'] . ", " . $_GET['weekstart'] . ") \nSee also the logfile, /usr/local/motiomera/log/motiomera.log \n\n";
    Misc::logMotiomera("Manual medalj batch started from Admin by " . $ADMIN->getANamn() . ", " . $_GET['year'] . " from week " . $_GET['weekstart'] . " to week " . $_GET['weekstop'], 'INFO');
    for ($i = $_GET['weekstart']; $i <= $_GET['weekstop']; $i++) {
        Sammanstallning::sammanstallMedaljer($_GET['year'], $i);
    }
} else {
    echo '<h3>Det saknas paramatrar!</h3>';
}
Пример #19
0
 /**
  * Create a member file, put it on the ftp area
  */
 public static function createMemberFile($refId)
 {
     $orderItems = Order::listOrderDataByRefId($refId);
     $orderRefCode = $orderItems[0]['orderRefCode'];
     $medlemId = $orderItems[0]['medlem_id'];
     $orderId = $orderItems[0]['id'];
     $date = $orderItems[0]['skapadDatum'];
     $medlem = Medlem::loadById($medlemId);
     $name = $medlem->getFNamn() . ' ' . $medlem->getENamn();
     $prefix = '';
     $middlefix = 'MEM';
     $filnamn = Misc::setFilnamnAuto($prefix, 'txt', 'member', $middlefix, $name, $orderId);
     $lokalFil = MEDLEMSFIL_LOCAL_PATH . "/" . $filnamn;
     if (file_exists($lokalFil)) {
         Misc::logMotiomera("Couldn't create or save order member file: " . $lokalFil, 'ERROR');
         throw new OrderException(" ERROR - Couldn't create or save order member file: " . $lokalFil, -10);
     } else {
         $msg = "Skicka stegräknare till medlem  - OBS BETALT!\n";
         $msg = "                                  -----------\n\n";
         $msg .= $name . "\n";
         $medlem->getCo() == '' ? $co = $medlem->getCo() . "\n" : ($co = '');
         $msg .= $co;
         $msg .= $medlem->getAddress() . "\n";
         $msg .= $medlem->getZip() . ' ' . $medlem->getCity() . "\n";
         $msg .= $medlem->getCountry() . "\n\n";
         $msg .= "--------------------------------- \n";
         $msg .= "Köpdatum: \n";
         $msg .= $date . " \n\n";
         $msg .= "Artikel: \n";
         foreach ($orderItems as $orderItem) {
             $msg .= $orderItem['item'] . "    " . $orderItem['antal'] . "    " . $orderItem['price'] . "\n";
             $orderIdArray[] = $orderItem['id'];
         }
         $msg .= "\nSumma: \n";
         $msg .= $orderItems[0]['sumMoms'] . "\n\n";
         $fd = fopen($lokalFil, "a");
         if ($fd != false) {
             fwrite($fd, $msg);
             fclose($fd);
             Misc::logMotiomera("Created member-file for " . $name . ",  " . $lokalFil . ", medlemId =  " . $medlemId . ", orderids = " . implode(' ', $orderIdArray), 'OK');
             //update the orderrows with faktura filename
             foreach ($orderItems as $orderItem) {
                 $order = Order::loadById($orderItem['id']);
                 $order->setFilnamnFaktura($filnamn);
                 $order->commit();
             }
             return true;
         } else {
             Misc::logMotiomera("Unable to create member-file for " . $name . ",  " . $lokalFil . ", medlemId =  " . $medlemId . ", orderids = " . implode(' ', $orderIdArray), 'ERROR');
             return false;
         }
     }
 }
Пример #20
0
 /**
  * Gets the image from the submitted url, resizes it and stores it to disk with the name x.jpg.
  * the x is the submitted variable $i
  * Returns true or false wether it succeeds or not
  *
  * @param string $imglink
  * @param int $i
  * @return boolean
  */
 function resizeAndStoreImage($imglink, $i)
 {
     try {
         $filepath = ROOT . self::CACHE_PATH . "/temp.jpg";
         if ($f = curl_init($imglink)) {
             curl_setopt($f, CURLOPT_RETURNTRANSFER, true);
             curl_setopt($f, CURLOPT_HEADER, 0);
             $bild = curl_exec($f);
         }
         $file = fopen($filepath, 'w');
         fwrite($file, $bild);
         fclose($file);
         //resize it before croping it
         list($width, $height) = getimagesize($filepath);
         $ratio = $this->getShrinkRatio($width, $height);
         //find best shrink ratio
         $newwidth = $width * $ratio;
         $newheight = $height * $ratio;
         //keep ratio
         $thumb = imagecreatetruecolor($newwidth, $newheight);
         $source = imagecreatefromjpeg($filepath);
         imagecopyresized($thumb, $source, 0, 0, 0, 0, $newwidth, $newheight, $width, $height);
         imagejpeg($thumb, ROOT . self::CACHE_PATH . "/temp_resized.jpg", 100);
         //crop, put overlay and save
         $image = imagecreatetruecolor(self::IMG_WIDTH, self::IMG_HEIGHT);
         $bg = imagecreatefromjpeg(ROOT . self::CACHE_PATH . "/temp_resized.jpg");
         $overlay = imagecreatefrompng(ROOT . self::CACHE_PATH . "/mask.png");
         imagecopy($image, $bg, 0, 0, 0, 0, self::IMG_WIDTH, self::IMG_HEIGHT);
         imagecopy($image, $overlay, 0, 0, 0, 0, self::IMG_WIDTH, self::IMG_HEIGHT);
         imagejpeg($image, ROOT . self::CACHE_PATH . "/{$i}.jpg", 100);
         return true;
     } catch (Exception $exc) {
         Misc::logMotiomera("RSS->resizeAndStoreImage() something went wrong with the image fetching. " . $exc->getTraceAsString(), 'error');
         return false;
     }
 }
Пример #21
0
 /**
  * This function inserts a medallion in the db
  * Checks if there allready is one for that week, in that case no insert is made
  * Logging to /log/motiomera.log
  *
  * @param Medlem $medlem 
  * @param string $medalj 
  * @param string $ar 
  * @param string $vecka 
  * @param string $steg 
  * @param string $i 
  * @return void
  * @author Aller Internet, Kristian Erendi
  */
 private static function nyMedalj(Medlem $medlem, $medalj, $ar, $vecka, $steg, $i = 0)
 {
     global $db;
     $sql = "SELECT count(*) FROM " . self::MEDALJ_TABLE . " WHERE medlem_id = " . $medlem->getId() . " AND ar = " . $ar . " AND vecka = " . $vecka;
     if ($db->value($sql) == "0") {
         $sql = "INSERT INTO " . self::MEDALJ_TABLE . " VALUES (null, " . $medlem->getId() . ", '{$medalj}', {$steg}, {$vecka}, {$ar});";
         $db->nonquery($sql);
         Misc::logMotiomera("nbr {$i} New medalj for medlemId: " . $medlem->getId() . ", {$medalj}, steg: {$steg}", 'OK');
     } else {
         Misc::logMotiomera("nbr {$i} Duplicate medalj for medlemId: " . $medlem->getId() . ", {$medalj}, steg: {$steg}", 'ERROR');
     }
 }
Пример #22
0
 function Parse($rss_url)
 {
     // Open and load RSS file
     //if ($f = curl_init($rss_url)) {
     /*
           curl_setopt($f, CURLOPT_RETURNTRANSFER, true);
     			curl_setopt($f, CURLOPT_HEADER, 0);
     			$rss_content = curl_exec($f);
     			curl_close($f);
     */
     if ($ch = curl_init()) {
         //$ch = curl_init();
         curl_setopt($ch, CURLOPT_URL, $rss_url);
         curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
         $rss_content = curl_exec($ch);
         curl_close($ch);
         /*
              if($ch = curl_init()){
           echo "curl init success";
           curl_setopt($ch, CURLOPT_URL, "http://mabra.com/feed");
           curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
           $output = curl_exec($ch);
           curl_close($ch);
           echo $output;
         */
         //krillo
         echo "********* lastRSS::Parse({$rss_url}) \n";
         print_r($rss_content);
         //////////////////////////////////////////////////////////////////////////////////
         //fopen till curl 14/8 2008 av magnus
         //////////////////////////////////////////////////////////////////////////////////
         //if ($f = @fopen($rss_url, 'r')) {
         //    $rss_content = '';
         //    while (!feof($f)) {
         //        $rss_content .= fgets($f, 4096);
         //    }
         //    fclose($f);
         //////////////////////////////////////////////////////////////////////////////////
         // Parse document encoding
         $result['encoding'] = $this->my_preg_match("'encoding=[\\'\"](.*?)[\\'\"]'si", $rss_content);
         //krillo
         //echo "result encoding \n";
         //print_r($rss_content);
         // if document codepage is specified, use it
         if ($result['encoding'] != '') {
             $this->rsscp = $result['encoding'];
         } else {
             $this->rsscp = $this->default_cp;
         }
         // This is used in my_preg_match()
         /*// Parse CHANNEL info
         
         			preg_match("'<channel.*?>(.*?)</channel>'si", $rss_content, $out_channel);
         			foreach($this->channeltags as $channeltag)
         			{
         			$temp = $this->my_preg_match("'<$channeltag.*?>(.*?)</$channeltag>'si", $out_channel[1]);
         			if ($temp != '') $result[$channeltag] = $temp; // Set only if not empty
         			} */
         // If date_format is specified and lastBuildDate is valid
         if ($this->date_format != '' && ($timestamp = strtotime($result['lastBuildDate'])) !== -1) {
             // convert lastBuildDate to specified date format
             $result['lastBuildDate'] = date($this->date_format, $timestamp);
         }
         // Parse TEXTINPUT info
         preg_match("'<textinput(|[^>]*[^/])>(.*?)</textinput>'si", $rss_content, $out_textinfo);
         // This a little strange regexp means:
         // Look for tag <textinput> with or without any attributes, but skip truncated version <textinput /> (it's not beggining tag)
         if (isset($out_textinfo[2])) {
             foreach ($this->textinputtags as $textinputtag) {
                 $temp = $this->my_preg_match("'<{$textinputtag}.*?>(.*?)</{$textinputtag}>'si", $out_textinfo[2]);
                 if ($temp != '') {
                     $result['textinput_' . $textinputtag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse IMAGE info
         preg_match("'<image.*?>(.*?)</image>'si", $rss_content, $out_imageinfo);
         if (isset($out_imageinfo[1])) {
             foreach ($this->imagetags as $imagetag) {
                 $temp = $this->my_preg_match("'<{$imagetag}.*?>(.*?)</{$imagetag}>'si", $out_imageinfo[1]);
                 if ($temp != '') {
                     $result['image_' . $imagetag] = $temp;
                 }
                 // Set only if not empty
             }
         }
         // Parse ITEMS
         preg_match_all("'<item(| .*?)>(.*?)</item>'si", $rss_content, $items);
         $rss_items = $items[2];
         $i = 0;
         $result['items'] = array();
         // create array even if there are no items
         foreach ($rss_items as $rss_item) {
             // If number of items is lower then limit: Parse one item
             if ($i < $this->items_limit || $this->items_limit == 0) {
                 foreach ($this->itemtags as $itemtag) {
                     $temp = $this->my_preg_match("'<{$itemtag}.*?>(.*?)</{$itemtag}>'si", $rss_item);
                     if ($temp != '') {
                         $result['items'][$i][$itemtag] = $temp;
                     }
                     // Set only if not empty
                 }
                 // Strip HTML tags and other bullshit from DESCRIPTION
                 if ($this->stripHTML && $result['items'][$i]['description']) {
                     $result['items'][$i]['description'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['description'])));
                 }
                 // Strip HTML tags and other bullshit from TITLE
                 if ($this->stripHTML && $result['items'][$i]['title']) {
                     $result['items'][$i]['title'] = strip_tags($this->unhtmlentities(strip_tags($result['items'][$i]['title'])));
                 }
                 // If date_format is specified and pubDate is valid
                 if ($this->date_format != '' && ($timestamp = strtotime($result['items'][$i]['pubDate'])) !== -1) {
                     // convert pubDate to specified date format
                     $result['items'][$i]['pubDate'] = date($this->date_format, $timestamp);
                 }
                 // Item counter
                 $i++;
             }
         }
         $result['items_count'] = $i;
         return $result;
     } else {
         //krillo
         echo "********* lastRSS::Parse() Could not get a new Curl-session in lastRSS class \n";
         Misc::logMotiomera("Could not get a new Curl-session in lastRSS class", 'error');
         return False;
     }
 }
Пример #23
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start kundnummer cron script. \n";
Misc::logMotiomera("Start kundnummer cron script ", 'INFO');
Order::hamtaNyaKundnummer();
Order::liftTillaggOrderStatus();
Misc::logMotiomera("End kundnummer cron script \n", 'INFO');
Пример #24
0
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start:  truncate feed on mypage cron script. \n";
Misc::logMotiomera("Start:  truncate feed on mypage cron script ", 'INFO');
Feed::truncateFeedItems();
Misc::logMotiomera("End truncate feed on mypage cron script \n", 'INFO');
Пример #25
0
 public static function refreshCache()
 {
     Misc::logMotiomera("Start RSSHandler::refreshCache() ", 'info');
     $rss = new lastRSS();
     $rss->cache_dir = '';
     $rss->cache_time = 0;
     $rss->CDATA = "content";
     /*
     		if (file_exists(ROOT . self::CACHE_PATH . "/rss.php")) {
     			include (ROOT . self::CACHE_PATH . "/rss.php");
     		}
     */
     //krillo
     echo "************* refreshCache lastRSS: ";
     print_r($rss);
     if ($rs = $rss->get(self::RSS_URL)) {
         //krillo
         echo "************* refreshCache : inne i loopen   if (rs = rss->get(self::RSS_URL) \n";
         $cache = "<?php \n\n // Skapad " . date("Y-m-d H:i:s") . "\n\n" . '$rss_cache = array();' . "\n";
         $i = 0;
         //krillo
         echo "************* refreshCache : param rs \n";
         print_r($rs);
         foreach ($rs["items"] as $row) {
             if ($i < self::MAX_ARTICLES) {
                 //krillo
                 echo "****************** refreshCache item {$i} loopen ****************\n";
                 print_r($row);
                 $tmp = split("<br>", $row["description"]);
                 $tmp2 = split('"', $tmp[1]);
                 $img = $tmp2[1];
                 $tmpsource = array(" ", "å", "ä", "ö", "Å", "Ä", "Ö");
                 $tmpreplace = array("%20", "%E5", "%E4", "%F6", "%C5", "%C4", "%D6");
                 $img = str_replace($tmpsource, $tmpreplace, $img);
                 $cache .= '$rss_cache[' . $i . ']["title"] = "' . htmlspecialchars($row["title"]) . '";' . "\n";
                 //remove &nbsp;
                 $tmp[0] = str_replace("&nbsp;", "", $tmp[0]);
                 $cache .= '$rss_cache[' . $i . ']["description"] = "' . htmlspecialchars(strip_tags($tmp[0])) . '";' . "\n";
                 $cache .= '$rss_cache[' . $i . ']["img"] = "' . addslashes($img) . '";' . "\n";
                 $cache .= '$rss_cache[' . $i . ']["link"] = "' . (isset($row["link"]) ? $row["link"] : 'default.html') . '";' . "\n";
                 //krillo
                 echo "rawurlencode(img): " . rawurlencode($img) . '<br>';
                 if (!isset($rss_cache) || $img != $rss_cache[$i]["img"]) {
                     // hämta bild
                     //krillo
                     echo "hämta bild";
                     if ($f = curl_init($img)) {
                         curl_setopt($f, CURLOPT_RETURNTRANSFER, true);
                         curl_setopt($f, CURLOPT_HEADER, 0);
                         $bild = curl_exec($f);
                     }
                     $fil = fopen(ROOT . self::CACHE_PATH . "/{$i}.jpg", 'w');
                     fwrite($fil, $bild);
                     fclose($fil);
                     $bild = new Bild(null, ROOT . self::CACHE_PATH . "/{$i}.jpg");
                     $bild->resize(self::IMG_WIDTH, self::IMG_HEIGHT);
                     $image = imagecreatetruecolor(126, 95);
                     $bg = imagecreatefromjpeg(ROOT . self::CACHE_PATH . "/{$i}.jpg");
                     $overlay = imagecreatefrompng(ROOT . self::CACHE_PATH . "/mask.png");
                     imagecopy($image, $bg, 0, 0, 0, 0, 126, 95);
                     imagecopy($image, $overlay, 0, 0, 0, 0, 126, 95);
                     imagejpeg($image, ROOT . self::CACHE_PATH . "/{$i}.jpg", 90);
                 }
             }
             $i++;
         }
         $cache .= "?>";
         if (!($file = @fopen(ROOT . self::CACHE_PATH . "/rss.php", 'w'))) {
             Misc::logMotiomera("Cache-filen is not writable ", 'error');
             throw new RSSHandlerException("Cache-filen är inte skrivbar", -3);
         }
         fwrite($file, $cache);
         fclose($file);
     } else {
         Misc::logMotiomera("Could not get the RSS from " . self::RSS_URL, 'error');
     }
     Misc::logMotiomera("End RSSHandler::refreshCache() ", 'info');
 }
#!/usr/bin/php
<?php 
define('ROOT', dirname(__FILE__) . "/../public_html");
chdir(ROOT);
require_once ROOT . "/php/init.php";
echo date('Y-m-d h:i:s') . " [INFO] Start:  End and save competition data on monday cron script. \n";
Misc::logMotiomera("Start:  End and save competition data on monday cron script ", 'INFO');
Foretag::saveAndEndForetagsTavling();
Misc::logMotiomera("End end and save competition data on monday cron script \n", 'INFO');
?>

Пример #27
0
                $orderList["reciverCity"] = $foretag->getReciverCity();
                $orderList["reciverEmail"] = $foretag->getReciverEmail();
                $orderList["reciverPhone"] = $foretag->getReciverPhone();
                $orderList["reciverMobile"] = $foretag->getReciverMobile();
                $orderList["reciverCountry"] = $foretag->getReciverCountry();
                break;
            default:
                // pro order   krillo 090604: typ.mm_order is not set when it is an pro order... (old Farm code)
                // $pro_order = $order->getMedlem()->getSenastInloggad() == "0000-00-00 00:00:00" ? false : true;
                // $orderList["pro_order"] = $pro_order;
                break;
        }
        //Use the pushover app to display the purchase on iPhone  krillo 2013-08-20
        $pushover_msg = $orderTyp . ', ' . $orderList["sum"] . ' kr';
        if ($orderTyp != "medlem" && $orderTyp != "medlem_extend") {
            $pushover_msg .= ', ' . $orderList["companyName"];
        }
        curl_setopt_array($ch = curl_init(), array(CURLOPT_RETURNTRANSFER => 1, CURLOPT_URL => "https://api.pushover.net/1/messages.json", CURLOPT_POSTFIELDS => array("token" => "a2xUVS5DE3mpBMDVDZa6X6Qmf2Y4n9", "user" => "uUwaBT3H6g6Fg1RRTmXVgznsGgDWRu", "message" => $pushover_msg)));
        curl_exec($ch);
        curl_close($ch);
        $smarty = new MMSmarty();
        $smarty->assign("pagetitle", "Kvitto");
        $smarty->assign("orderList", $orderList);
        $smarty->assign("orderItemList", $orderItemList);
        $smarty->display('kvitto.tpl');
    } else {
        $msg .= "\n\tNågon försökte ladda kvittosidan igen - avbrutet!";
        Misc::logMotiomera($msg, 'WARN', 'order');
        throw new UserException("Kvittot har gått ut (2)", "Det här kvittots giltighetstid har gått ut och kan därför inte längre visas.");
    }
}
Пример #28
0
require $_SERVER["DOCUMENT_ROOT"] . "/php/init.php";
Security::demand(ADMIN);
if (!empty($_GET['action'])) {
    switch ($_GET['action']) {
        case 'kundnummer':
            echo date('Y-m-d h:i:s') . " [INFO] Start kundnummer from admin by " . $ADMIN->getANamn() . ". See logfile\n";
            Misc::logMotiomera("Start kundnummer from admin by  " . $ADMIN->getANamn(), 'INFO');
            Order::hamtaNyaKundnummer();
            Order::liftTillaggOrderStatus();
            Misc::logMotiomera("End kundnummer from admin \n", 'INFO');
            break;
        case 'pdf':
            echo date('Y-m-d h:i:s') . " [INFO] Start create PDF-files from admin by " . $ADMIN->getANamn() . ". See logfile\n";
            Misc::logMotiomera("Start create PDF-files from admin by " . $ADMIN->getANamn(), 'INFO');
            Foretag::skapaFiler();
            Misc::logMotiomera("End create PDF-files from admin \n", 'INFO');
            break;
        case 'ftp':
            echo date('Y-m-d h:i:s') . " [INFO] Start put PDF-files on FTP from admin by " . $ADMIN->getANamn() . ". See logfile\n";
            Misc::logMotiomera("Start put PDF-files on FTP from admin by " . $ADMIN->getANamn(), 'INFO');
            Foretag::uploadOrderFilesFTP();
            Misc::logMotiomera("End put PDF-files on FTP from admin \n", 'INFO');
            break;
        default:
            echo '<h3>Det är fel paramatrar!</h3>';
            break;
    }
} else {
    echo '<h3>Det saknas paramatrar!</h3>';
}