Exemple #1
0
 /**
  * @var $date datetime
  * @uses the constructor of Order class
  * @return new instance of Order class
  * @author ROUINEB Hamza
  * */
 public function __construct($date)
 {
     $this->date_order = new DateTime();
     $this->date_order->createFromFormat('d/m/y', $date);
     $this->valid = false;
     $this->order_book = new ArrayCollection();
 }
 /**
  * Returns the current timestamp in dd.mm.YYYY - HH:MM:SS format
  * @return string with the current date
  */
 private function getTime()
 {
     //$date = new datetime("now", new DateTimeZone('Europe/Paris'));
     $date = new datetime("now");
     return $date->format("d.m.Y | H:i:s");
     //return date("d.m.Y | H:i:s");
 }
    /**
     * Get all scores generated or changed at given date, limited by limit param
     *
     * @param datetime $_date
     * @param int $_limit
     * @return \Doctrine\Common\Collections\ArrayCollection|null
     */
    public function getScoresByDate(datetime $_date, $_limit = 100)
    {
        $dql = 'SELECT s
                FROM Custom_Entity_Score s
                WHERE (
                  (
                    year(s.created_at) = ?1 AND
                    month(s.created_at) = ?2 AND
                    day(s.created_at) = ?3
                  ) OR
                  (
                    year(s.changed_at) = ?1 AND
                    month(s.changed_at) = ?2 AND
                    day(s.changed_at) = ?3
                  )
                )';

        $em = $this->getEntityManager();
        /** @var $query \Doctrine\ORM\Query */
        $query = $em->createQuery($dql);
        $query->setParameters(
            array(
                1 => $_date->format('Y'), //year
                2 => $_date->format('m'), //month
                3 => $_date->format('d') //day
        ));
        $query->setMaxResults((int) $_limit);

        /** @var $result Custom_Entity_Score */
        $results = $query->getResult();

        return $results;
    }
 /**
  * find the difference between two date
  * 
  * @param datetime $start
  * @param datetime $end
  * 
  * @return string
  */
 public static function diffTime($start, $end)
 {
     if (empty($start) || empty($end)) {
         return;
     }
     $duration = $end->diff($start);
     return $duration->format('%H:%I:%S');
 }
Exemple #5
0
 public function Book($title, $year, $price, $img = '../../img/Small/php.jpg')
 {
     $this->title = $title;
     $this->year = new DateTime();
     $this->year->createFromFormat('d/d/m/y', $year);
     $this->price = $price;
     $this->img = $img;
     $this->authors = new ArrayCollection();
     $this->categories = new ArrayCollection();
 }
Exemple #6
0
 /**
  * Auto generate duration if empty
  *
  * @ORM\PrePersist
  * @ORM\PreUpdate
  * @return Timeslice
  */
 public function updateDurationOnEmpty()
 {
     if (empty($this->duration) && !empty($this->startedAt) && !empty($this->stoppedAt)) {
         $this->duration = abs($this->stoppedAt->getTimestamp() - $this->startedAt->getTimestamp());
     }
     return $this;
 }
Exemple #7
0
 public function getDueDate()
 {
     if (!$this->dueDate) {
         return null;
     }
     return $this->dueDate->format('Y-m-d H:i:s');
 }
 private function getMessageList(Request $request)
 {
     // Build filters
     $filters = array();
     $status = (int) $request->query->get('status');
     if ($status) {
         $filters['status'] = $status;
     }
     if ($request->query->get('date') != '') {
         $filterDate = new \datetime($request->query->get('date'));
         $filters['sentAt'] = (string) $filterDate->format('Y-m-d');
     }
     // Get message list
     $messages = $this->get('doctrine_mongodb')->getRepository('FortyTwoGroupMessengeBundle:Message')->findBy($filters, array('sentAt' => 'DESC'));
     return $messages;
 }
Exemple #9
0
 /**
  * Get pvp_range
  *
  * @return string 
  */
 public function getPvpRange()
 {
     if (!$this->pvp_von || !$this->pvp_bis) {
         return false;
     }
     $datum = $this->pvp_von->format('d.m.Y') . " - " . $this->pvp_bis->format('d.m.Y');
     return $datum;
 }
Exemple #10
0
 /**
  * @param string $format
  * @return null
  */
 public function getExecutionTimeString($format = '%H hours, %I minutes, %S seconds')
 {
     $time = null;
     if ($this->getState() == self::STATE_FINISHED) {
         $time = $this->finishedAt->diff($this->startedAt)->format($format);
     }
     return $time;
 }
Exemple #11
0
 /**
  * Get publishedAtString.
  *
  * @return string
  */
 public function getPublishedAtString()
 {
     setlocale(LC_TIME, 'fr_FR');
     if ($this->publishedAt) {
         return strftime('%d %B %Y', $this->publishedAt->getTimestamp());
     } else {
         return '';
     }
 }
 function testGetDateTimeCached()
 {
     $tz = new DateTimeZone('Europe/Amsterdam');
     $dt1 = new datetime('1985-07-04 01:30:00', $tz);
     $dt2 = new datetime('1986-07-04 01:30:00', $tz);
     $dt1->settimezone($tz);
     $dt2->settimezone($tz);
     $elem = new Sabre_VObject_Property_MultiDateTime('DTSTART');
     $elem->setDateTimes(array($dt1, $dt2));
     $this->assertEquals($elem->getDateTimes(), array($dt1, $dt2));
 }
Exemple #13
0
 public function __construct($time = 'now', $tz = NULL, $format = NULL)
 {
     if (!empty($tz) && !is_object($tz)) {
         $tz = new DateTimeZone($tz);
     }
     try {
         @parent::__construct($time, $tz);
     } catch (Exception $e) {
         echo "Bad date" . $this->format("Y") . "\n";
     }
 }
Exemple #14
0
 public function grabar($fila)
 {
     var_dump($fila);
     $codigo = $fila['_codigo'];
     $titulo = $fila['_titulo'];
     $fecha = datetime::createFromFormat('d-m-Y', $fila['_fechaCurriculo']);
     $fechaTxt = $fecha->format('Y-m-d');
     $sql = "UPDATE estudio " . " SET codigo = '{$codigo}'," . " titulo='{$titulo}'," . " fechaCurriculo='{$fechaTxt}' " . " WHERE id=" . $fila['_id'];
     $resultado = $this->_db->query($sql);
     if ($this->_db->errno) {
         die('Error en la consulta UPDATE' . '<br>' . $sql);
     }
 }
Exemple #15
0
 public function __construct($object = '', $description = '', $location = '')
 {
     $this->setId(-1);
     $this->setObject($object);
     $this->setDescription($description);
     $this->setLocation($location);
     $this->dateStart = new \DateTime();
     $this->dateStart->add(new \DateInterval('P1D'));
     $this->dateStart->setTime($this->dateStart->format('H'), $this->dateStart->format('i') - $this->dateStart->format('i') % 15, $this->dateStart->format('s'));
     $this->dateEnd = new \DateTime();
     $this->dateEnd->add(new \DateInterval('P1DT2H'));
     $this->dateEnd->setTime($this->dateEnd->format('H'), $this->dateEnd->format('i') - $this->dateEnd->format('i') % 15, $this->dateEnd->format('s'));
     $this->participants = new ArrayCollection();
     $this->childs = new ArrayCollection();
 }
Exemple #16
0
 /**
  * @return null
  */
 public function getDateCreated()
 {
     return $this->dateCreated ? $this->dateCreated->format('Y-m-d H:i:s') : null;
 }
Exemple #17
0
 /**
  * Get last update time
  *
  * @return string formatted date
  */
 public function getUpdatedAt()
 {
     return $this->updated_at->format('d M. Y');
 }
Exemple #18
0
         ' . $Account_pseudo . '</a></strong></td>';
                    /* Si on est l'auteur du message, on affiche des liens pour
                       Modérer celui-ci.
                       Les modérateurs pourront aussi le faire, il faudra donc revenir sur
                       ce code un peu plus tard ! */
                    $d = new datetime($Post_Time);
                    if (user_data('Account_ID') == $Post_Createur) {
                        echo '<td id=p_' . $Post_ID . '>Posté à ' . $d->format('H\\hi \\l\\e d M y') . '
         <a href="' . get_link('Poster', 'Guild', array('action' => 'delete', 'p' => $Post_ID)) . '"><span alt="Supprimer" title="Supprimer ce message" >&cross;</span></a>   
         <a href="' . get_link('Poster', 'Guild', array('action' => 'edit', 'p' => $Post_ID)) . '"><span alt="Editer" title="Editer ce message" >&check;</span></a></td></tr>';
                    } else {
                        echo '<td>
         Posté à ' . $d->format('H\\hi \\l\\e d M y') . '
         </td></tr>';
                    }
                    $d = new datetime($Account_Inscription);
                    //Détails sur le Account qui a posté
                    echo '<tr><td>
         <img src="./images/avatars/' . $Account_Avatar . '" alt="" />
         <br />Membre inscrit le ' . $d->format('d/m/Y') . '
         <br />Messages : ' . $Account_Post . '<br />
         Localisation : ' . $Account_localisation . '</td>';
                    //Message
                    echo '<td>' . bb_code($Post_texte) . '
         <br /><hr />' . bb_code($Account_Signature) . '</td></tr>';
                }
                //Fin de la boucle ! \o/
                ?>
</table>

<?php 
 function ausers_format_timestamp_as_date($v)
 {
     // in the right timezone
     global $tzobj;
     if (empty($v)) {
         return '';
     }
     if (empty($tzobj)) {
         $tzobj = amr_getset_timezone();
     }
     // $d = date('Y-m-d H:i:s e', (int) $v) ;
     if (is_numeric($v)) {
         $dt = new datetime('@' . $v);
         $dt->setTimeZone($tzobj);
         /* optional if you want to use your sites formats	
         			$date_format = get_option('date_format'); //wp preloads these
         			$time_format = get_option('time_format');	
         			*/
     } else {
         return $v;
     }
     // we got something that is definitely not a timestamp
     if (!is_object($dt)) {
         $d = $v;
     } else {
         $date_format = 'Y-m-d';
         $time_format = 'H:i';
         //'H:i:s'
         $tz = 'P';
         //e or T or P
         $d = $dt->format($date_format . ' ' . $time_format . ' ' . $tz);
     }
     return $d;
 }
Exemple #20
0
function article_collect($article_id, $sim_orderby = 'score', $sim_showall = 'no')
{
    $art = db_getRow('SELECT * FROM article WHERE id=?', $article_id);
    if (is_null($art)) {
        return null;
    }
    $art['article_id'] = $art['id'];
    $art['id36'] = article_id_to_id36($art['id']);
    $art['blog_links'] = db_getAll("SELECT * FROM article_bloglink WHERE article_id=? ORDER BY linkcreated DESC", $article_id);
    // journos
    $sql = <<<EOT
SELECT j.prettyname, j.ref
    FROM ( journo j INNER JOIN journo_attr attr ON j.id=attr.journo_id )
    WHERE attr.article_id=? AND j.status='a';
EOT;
    $art['journos'] = db_getAll($sql, $article_id);
    $art['byline'] = article_markup_byline($art['byline'], $art['journos']);
    $orginfo = db_getRow("SELECT * FROM organisation WHERE id=?", $art['srcorg']);
    $art['srcorgname'] = $orginfo['prettyname'];
    $art['sop_name'] = $orginfo['sop_name'];
    $art['sop_url'] = $orginfo['sop_url'];
    $art['srcorg_url'] = $orginfo['home_url'];
    $permalink = $art['permalink'];
    $d = new datetime($art['pubdate']);
    $art['pretty_pubdate'] = pretty_date(strtotime($art['pubdate']));
    $art['iso_pubdate'] = $d->format('c');
    $art['buzz'] = BuzzFragment($art);
    /* similar articles */
    if ($sim_orderby == 'date') {
        $ord = 'a.pubdate DESC, s.score DESC';
    } else {
        // 'score'
        $ord = 's.score DESC, a.pubdate DESC';
    }
    $sql = <<<EOT
SELECT a.id,a.title, a.srcorg,a.byline,a.permalink,a.pubdate
    FROM article a INNER JOIN article_similar s ON s.other_id=a.id
    WHERE s.article_id=? and a.status='a'
    ORDER BY {$ord}
EOT;
    /* only the first 10 by default */
    if ($sim_showall != 'yes') {
        $sql .= "   LIMIT 10";
    }
    $sim_arts = db_getAll($sql, $article_id);
    foreach ($sim_arts as &$s) {
        article_augment($s);
    }
    unset($s);
    $art['sim_orderby'] = $sim_orderby;
    $art['sim_showall'] = $sim_showall;
    $art['sim_arts'] = $sim_arts;
    $tags = db_getAll('SELECT tag, freq FROM article_tag WHERE article_id=? ORDER BY freq DESC', $article_id);
    $sorted_tags = array();
    foreach ($tags as $t) {
        $sorted_tags[$t['tag']] = intval($t['freq']);
    }
    ksort($sorted_tags);
    $art['tags'] = $sorted_tags;
    $art['comment_links'] = article_collect_commentlinks($article_id);
    return $art;
}
Exemple #21
0
 /**
  * Get pvr_gueltig_bis
  *
  * @return \DateTime 
  */
 public function getPvrGueltigBis()
 {
     return $this->pvr_gueltig_bis->format('d.m.Y');
 }
    // echo end();
    $t = explode('.', $_FILES['image']['name']);
    $t = end($t);
    $file_ext = strtolower($t);
    $expensions = array("jpg", "jpeg", "png", "jpe");
    if (in_array($file_ext, $expensions) === false) {
        $errors[] = "extension not allowed, please choose a JPG  file.";
    }
    if ($file_size > 2097152) {
        $errors[] = 'File size must be excately 2 MB';
    }
    if (empty($errors) == true) {
        move_uploaded_file($file_tmp, "images/store_images/" . $productCount . ".jpg");
        echo "Success";
    } else {
        print_r($errors);
    }
}
date_default_timezone_set('Asia/Calcutta');
$datetime = new datetime(date('Y/m/d H:i:s'));
$datetime->modify('+1 day');
$enddate = $datetime->format('Y-m-d H:i:s');
$sq = "INSERT INTO products(ProductID,Pname,StartingPrice,SellerID,CategoryID,YearsofUsage,Details) values('" . $productCount . "','" . $title . "','" . $price . "','" . $user . "','" . $category . "','" . $years . "','" . $details . "')";
$sq2 = "INSERT INTO auction(ProductID,EndTime,CurrentPrice) values('" . $productCount . "','" . $enddate . "','" . $price . "')";
if ($conn->query($sq) === TRUE && $conn->query($sq2) === TRUE) {
    echo "New record created successfully";
    header("location: index.php");
} else {
    echo "Error: " . $sq . "<br>" . $conn->error;
}
$conn->close();
Exemple #23
0
 /**
  * Ajax exec cron.
  * 
  * @access public
  * @return void
  */
 public function ajaxExec()
 {
     ignore_user_abort(true);
     set_time_limit(0);
     session_write_close();
     /* Check cron turnon. */
     if (empty($this->config->global->cron)) {
         die;
     }
     /* make cron status to running. */
     $configID = $this->cron->getConfigID();
     $configID = $this->cron->markCronStatus('running', $configID);
     /* Get and parse crons. */
     $crons = $this->cron->getCrons('nostop');
     $parsedCrons = $this->cron->parseCron($crons);
     /* Update last time. */
     $this->cron->changeStatus(key($parsedCrons), 'normal', true);
     $this->loadModel('common');
     $startedTime = time();
     while (true) {
         /* When cron is null then die. */
         if (empty($crons)) {
             break;
         }
         if (empty($parsedCrons)) {
             break;
         }
         if (!$this->cron->getTurnon()) {
             break;
         }
         /* Run crons. */
         $now = new datetime('now');
         $this->common->loadConfigFromDB();
         foreach ($parsedCrons as $id => $cron) {
             $cronInfo = $this->cron->getById($id);
             /* Skip empty and stop cron.*/
             if (empty($cronInfo) or $cronInfo->status == 'stop') {
                 continue;
             }
             /* Skip cron that status is running and run time is less than max. */
             if ($cronInfo->status == 'running' and time() - strtotime($cronInfo->lastTime) < $this->config->cron->maxRunTime) {
                 continue;
             }
             /* Skip cron that last time is more than this cron time. */
             if ($cronInfo->lastTime > $cron['time']->format(DT_DATETIME1)) {
                 die;
             }
             if ($now > $cron['time']) {
                 $this->cron->changeStatus($id, 'running');
                 $parsedCrons[$id]['time'] = $cron['cron']->getNextRunDate();
                 /* Execution command. */
                 $output = '';
                 $return = '';
                 if ($cron['command']) {
                     if (isset($crons[$id]) and $crons[$id]->type == 'zentao') {
                         parse_str($cron['command'], $params);
                         if (isset($params['moduleName']) and isset($params['methodName'])) {
                             $this->app->loadConfig($params['moduleName']);
                             $output = $this->fetch($params['moduleName'], $params['methodName']);
                         }
                     } elseif (isset($crons[$id]) and $crons[$id]->type == 'system') {
                         exec($cron['command'], $output, $return);
                         if ($output) {
                             $output = join("\n", $output);
                         }
                     }
                     /* Save log. */
                     $log = '';
                     $time = $now->format('G:i:s');
                     $log = "{$time} task " . $id . " executed,\ncommand: {$cron['command']}.\nreturn : {$return}.\noutput : {$output}\n";
                     $this->cron->logCron($log);
                     unset($log);
                 }
                 /* Revert cron status. */
                 $this->cron->changeStatus($id, 'normal');
             }
         }
         /* Check whether the task change. */
         $newCrons = $this->cron->getCrons('nostop');
         $changed = $this->cron->checkChange();
         if (count($newCrons) != count($crons) or $changed) {
             $crons = $newCrons;
             $parsedCrons = $this->cron->parseCron($newCrons);
         }
         /* Sleep some seconds. */
         $sleepTime = 60 - (time() - $now->getTimestamp()) % 60;
         sleep($sleepTime);
         /* Break while. */
         if (connection_status() != CONNECTION_NORMAL) {
             break;
         }
         if ((time() - $startedTime) / 3600 / 24 >= $this->config->cron->maxRunDays) {
             break;
         }
     }
     /* Revert cron status to stop. */
     $this->cron->markCronStatus('stop', $configID);
 }
Exemple #24
0
 public function findNextEventsByCategory($category)
 {
     $today = new \datetime();
     $query = $this->createQueryBuilder('e')->where('e.category = :category')->andWhere('e.startDate > :today')->setParameter('category', $category)->setParameter('today', $today->format('Y-m-d'))->orderBy('e.startDate', 'ASC');
     return $query->getQuery()->getResult();
 }
Exemple #25
0
 function getExpectedShippingDate($shippingDate = NULL)
 {
     $products = $this->getProducts();
     $maxShippingSla = 0;
     foreach ($products as $productrecord) {
         $product_id = (int) $productrecord['id_product'];
         $product = new Product($product_id, true, 1);
         if ($maxShippingSla < $product->shipping_sla) {
             $maxShippingSla = $product->shipping_sla;
         }
     }
     $maxShippingSla = $maxShippingSla + $this->getCartCustomizationSLA();
     if (empty($shippingDate)) {
         $shippingDate = new DateTime();
     } else {
         $shippingDate = datetime::createFromFormat("Y-m-d H:i:s", (string) $shippingDate);
     }
     $shippingDate = Tools::getNextWorkingDate($maxShippingSla, $shippingDate);
     return $shippingDate;
 }
Exemple #26
0
    function showIdentityTab() {
        $this->getEnumMappings();
        $this->getAliases();

        $chapter=sprintf(_("SIP Account"));
        $this->showChapter($chapter);

        print "
            <div class='row-fluid'>
                <div class=span12>
                    <table class='table table-condensed table-striped'>
                        <tr>
                            <td style=\"width: 20%\">";
        print _("SIP Address");
        print "</td>
                            <td>sip:$this->account</td>
                        </tr>";
        /*
        print "
        <tr>
        <td>";
        print _("Full Name");
        print "
        </td>
        <td>$this->fullName
        </td>
        </tr>
        ";
        */

        print "
                        <tr>
                            <td>";
        print _("Username");
        print "</td>
                            <td>$this->username</td>
                        </tr>";
        print "
                        <tr>
                            <td>";
        print _("Domain/Realm");
        print "</td>
                            <td>$this->domain</td>
                        </tr>";

        print "
                        <tr>
                            <td>";
        print _("Outbound Proxy");
        print "</td>
                            <td>$this->sip_proxy</td>
                        </tr>
        ";

        if ($this->xcap_root) {
                print "
                    <tr>
                    <td>";
                print _("XCAP Root");
                print "
                </td>
                <td>$this->xcap_root
            </td>
            </tr>
            ";
        }
        print "</table></div></div>";


        if ($this->pstn_access && $this->rpid) {
            $chapter=sprintf(_("PSTN"));
            $this->showChapter($chapter);

            print "
                <div class=row-fluid>
                <div class=span12>
                <table class='table table-condensed table-striped'><tr><td style=\"width: 20%\">";
              print _("Caller-ID");
              print "</td>
              <td>$this->rpid</td>
            </tr>
            ";


        $t=0;
        foreach($this->enums as $e)  {
            $t++;

            $rr=floor($t/2);
            $mod=$t-$rr*2;

            if ($mod ==0) {
                $_class='odd';
            } else {
                $_class='even';
            }

            print "
                <tr>
                <td>";
            print _("Phone Number");
            print "</td>
              <td>$e</td>
            </tr>
            ";
        }

        print "</table></div></div>";
	}
        $chapter=sprintf(_("Aliases"));
        $this->showChapter($chapter);

        print "
        <div class=row-fluid>
        <div class=span12>";
        printf (_("You may create new aliases for incoming calls"));
        printf ("
            </div>
            </div>
        ");

        $t=0;

        print "
        <form class=form-horizontal method=post name=sipsettings onSubmit=\"return checkForm(this)\">
        ";

        foreach($this->aliases as $a)  {
            $t++;

            $rr=floor($t/2);
            $mod=$t-$rr*2;

            if ($mod ==0) {
                $_class='even';
            } else {
                $_class='odd';
            }

            print "
            <div class='control-group $_class'>

              <label for=aliases[] class=control-label>";
                print _("SIP Alias");
                print "
              </label>
              <div class='controls'><input type=text size=35 name=aliases[] value=\"$a\">
              </div>
            </div>
            ";
        }

        print "
        <div class='control-ground $_class'>
          <label for=aliases[] class=control-label>";
            print _("New SIP Alias");
            print "
          </label>";
            print "
          <div class=controls>
            <input type=hidden name=action value=\"set aliases\">
        ";
         print '
             <input name=aliases[] size="35" type="text">
             </div><div class=form-actions>
             <input class="btn" type="submit" value="';
        print _("Save aliases");
        print '" onClick=saveHandler(this)>
              </div>
            </div>
           ';

        print $this->hiddenElements;

        print "
        </form>
        ";

        if (!$this->isEmbedded() && $this->show_tls_section) {

            if ($this->enrollment_url) {
                include($this->enrollment_configuration);

                if (is_array($enrollment)) {
                    $chapter=sprintf(_("TLS Certificate"));
                    $this->showChapter($chapter);
                    print "
                    <tr>
                    <td>";
                    print _("X.509 Format");
                    printf ("
                    </td>
                    <td><a href=%s&action=get_crt>Certificate</a>
                    </td>
                    </tr>
                    ",$this->url);

                    /*
                    print "
                    <tr>
                    <td>";
                    print _("PKCS#12 store format");
                    printf ("
                    </td>
                    <td><a href=%s&action=get_p12>Certificate</a>
                    </td>
                    </tr>
                    <tr>
                      <td height=3 colspan=2></td>
                    </tr>",$this->url);
                    */

                }
            }
        }

        print "
        <form method=post>";

        print "
          <div class=well>
        ";

        if ($this->email) {
            printf (_("Email SIP Account information to %s"),$this->email);
            print "
            <input type=hidden name=action value=\"send email\">
            <button class='btn btn-primary' type=submit>
            <i class=\"icon-envelope icon-white\"> </i> ";
            print _("Send");
            print "</button>";
        }

        if ($this->sip_settings_page && $this->login_type != 'subscriber') {
            print "<p>";
            printf (_("Login using SIP credentials at <a href=%s>%s</a>"),$this->sip_settings_page,$this->sip_settings_page);
            print "</p>";
        }
        print $this->hiddenElements;
        print "
        </div></form>
        ";
        if($this->sip_settings_page) {
            $this->getbalancehistory();

            if (count($this->balance_history) == "0"  || $this->login_type != 'subscriber') {
                print "<form method=post><p>";
                print "<input type=hidden name=action value=\"delete account\">";
                $date1= new datetime($this->Preferences['account_delete_request']);
                $today= new datetime('now');
                if ($this->Preferences['account_delete_request'] && $this->login_type != 'subscriber' ) {
                    print "<p>User made a deletion request on: ";
                    print $this->Preferences['account_delete_request'];
                    print "</p>";
                }

                if ($date1->diff($today)->d >= '2' || $this->Preferences['account_delete_request'] == '' || $this->login_type != 'subscriber' ) {
                    print '<button data-original-title="';
                    print _("Delete request");
                    print "\" data-trigger=\"hover\" data-toggle=\"popover button\" data-content=\"";
                    print " You may request the deletion of your account here. An email confirmation is required to validate the request.\"";
                    print " rel='popover' class='btn btn-warning' type='submit'>";
                    print _("Delete request");
                } else {
                    //print "<button rel='popover' class='btn btn-disabled'disabled type='submit'>";
                    //printf (_("Account remove request is active"));
                    print "A deletion request has been made on: ";
                    print $this->Preferences['account_delete_request'];
                }
                print "</button></p>";
            }

            print $this->hiddenElements;

            print "
            </form>
            ";
        }
    }
Exemple #27
0
 /**
  * Get publishedAtString
  *
  * @return string
  */
 public function getPublishedAtString()
 {
     setlocale(LC_TIME, "fr_FR");
     return strftime('%d %B %Y', $this->publishedAt->getTimestamp());
 }
 /**
  * Get datCadastro
  *
  * @return datetime
  */
 public function getDatCadastro()
 {
     return $this->datCadastro->format('d/m/Y H:i:s');
 }
 function cache_status()
 {
     /* show the cache status and offer to rebuild */
     global $wpdb;
     global $amain;
     $problem = false;
     $now = time();
     $dt = new DateTime('now', $this->tz);
     $nowtxt = date_format($dt, 'D, j M Y G:i e');
     if (is_admin()) {
         if (!($amain = ausers_get_option('amr-users-main'))) {
             $amain = ameta_default_main();
         }
         $wpdb->show_errors();
         $sql = 'SELECT DISTINCT reportid AS "rid", COUNT(reportid) AS "lines" FROM ' . $this->table_name . ' GROUP BY reportid';
         $results = $wpdb->get_results($sql, ARRAY_A);
         /* Now e have a summary of what isin the cache table - rid, lines */
         if (is_wp_error($results)) {
             echo '<h2>' . $results->get_error_message() . '</h2>';
             return false;
         } else {
             if (!empty($results)) {
                 //var_dump($results);  var_dump($amain);
                 foreach ($results as $i => $rpt) {
                     $r = intval(substr($rpt['rid'], 5));
                     /* *** skip the 'users' and take the rest */
                     $summary[$r]['rid'] = $rpt['rid'];
                     $summary[$r]['lines'] = $rpt['lines'] - 2;
                     /* as first two liens are headers anyway*/
                     $summary[$r]['name'] = $amain['names'][intval($r)];
                 }
             } else {
                 echo adb_cache::get_error('nocacheany');
                 // attempt a realtime run  NO!!! Don't do this - for large databases that are failing anyway will be no good.
                 //foreach ($amain['names'] as $i => $name) {
                 //	amr_build_user_data_maybe_cache($i);
                 //}
             }
             $status = ausers_get_option('amr-users-cache-status');
             /* Now pickup the record of starts etc reportid, start   and reportid end*/
             if (!empty($status)) {
                 foreach ($status as $rd => $se) {
                     $r = intval(substr($rd, 5));
                     /* *** skip the 'users' and take the rest */
                     if (empty($se['end'])) {
                         $now = time();
                         $diff = $now - $se['start'];
                         if ($diff > 60 * 5) {
                             $problem = true;
                             $summary[$r]['end'] = __('Taking too long, may have been aborted... delete cache status, try again, check server logs and/or memory limit', 'amr-users');
                             delete_transient('amr_users_cache_' . $r);
                             // so another can run
                         } else {
                             $summary[$r]['end'] = sprintf(__('Started %s', 'amr-users'), human_time_diff($now, $se['start']));
                         }
                         $summary[$r]['time_since'] = __('?', 'amr-users');
                         $summary[$r]['time_taken'] = __('?', 'amr-users');
                         $summary[$r]['peakmem'] = __('?', 'amr-users');
                         $summary[$r]['rid'] = $rd;
                         $r = intval(substr($rd, 5));
                         /* *** skip the 'users' and take the rest */
                         $summary[$r]['name'] = $amain['names'][intval($r)];
                     } else {
                         if (empty($se['end'])) {
                             $summary[$r]['end'] = 'In progress';
                         } else {
                             $datetime = new datetime(date('Y-m-d H:i:s', $se['end']));
                             if (empty($tzobj)) {
                                 $tzobj = amr_getset_timezone();
                             }
                             $datetime->setTimezone($tzobj);
                             $summary[$r]['end'] = $datetime->format('D, j M G:i');
                         }
                         //$summary[$r]['end'] = empty($se['end']) ? 'In progress' : date_i18n('D, j M H:i:s',$se['end']);  /* this is in unix timestamp not "our time" , so just say how long ago */
                         $summary[$r]['start'] = date_i18n('D, j M Y H:i:s', $se['start']);
                         /* this is in unix timestamp not "our time" , so just say how long ago */
                         $dt = new DateTime('now', $this->tz);
                         $nowtxt = date_format($dt, 'D, j M Y G:i e');
                         $summary[$r]['time_since'] = human_time_diff($se['end'], time());
                         /* the time that the last cache ended */
                         $summary[$r]['time_taken'] = $se['end'] - $se['start'];
                         /* the time that the last cache ended */
                         $summary[$r]['peakmem'] = $se['peakmem'];
                         $summary[$r]['headings'] = $se['headings'];
                     }
                 }
             } else {
                 if (!empty($summary)) {
                     foreach ($summary as $rd => $rpt) {
                         $summary[$rd]['time_since'] = $summary[$rd]['time_taken'] = $summary[$rd]['end'] = $summary[$rd]['peakmem'] = '';
                     }
                 }
             }
             if (!empty($summary)) {
                 echo PHP_EOL . '<div class="wrap" style="padding-top: 20px;">' . '<h3>' . $nowtxt . '</h3>' . PHP_EOL . '<table class="widefat" style="width:auto; ">' . '<thead><tr><th>' . __('Report Id', 'amr-users') . '</th><th>' . __('Name', 'amr-users') . '</th><th>' . __('Lines', 'amr-users') . '</th><th style="text-align: right;">' . __('Ended?', 'amr-users') . '</th><th style="text-align: right;">' . __('How long ago?', 'amr-users') . '</th><th style="text-align: right;">' . __('Seconds taken', 'amr-users') . '</th><th style="text-align: right;">' . __('Peak Memory', 'amr-users') . '</th><th style="text-align: right;">' . __('Details', 'amr-users') . '</th></tr></thead>';
                 foreach ($summary as $rd => $rpt) {
                     if (!isset($rpt['headings'])) {
                         $rpt['headings'] = ' ';
                     }
                     if (!isset($rpt['lines'])) {
                         $rpt['lines'] = ' ';
                     }
                     if (isset($rpt['rid'])) {
                         echo '<tr>' . '<td>' . $rpt['rid'] . '</td>' . '<td>' . au_view_link($rpt['name'], $rd, '') . '</td>' . '<td align="right">' . $rpt['lines'] . '</td>' . '<td align="right">' . $rpt['end'] . '</td>' . '<td align="right">' . $rpt['time_since'] . '</td>' . '<td align="right">' . $rpt['time_taken'] . '</td>' . '<td align="right">' . $rpt['peakmem'] . '</td>' . '<td align="right">' . $rpt['headings'] . '</td>' . '</tr>';
                     }
                 }
                 echo PHP_EOL . '</table>' . PHP_EOL . '</div><!-- end wrap -->' . PHP_EOL;
             }
         }
     } else {
         echo '<h3>not admin?</h3>';
     }
     if ($problem) {
         $fun = '<a target="_blank" title="' . __('Link to audio file of the astronauts of Apollo 13 reporting a problem.', 'amr-users') . '" href="http://upload.wikimedia.org/wikipedia/commons/1/12/Apollo13-wehaveaproblem_edit_1.ogg" >' . __('Houston, we have a problem', 'amr-users') . '</a>';
         $text = __('The background job\'s may be having problems.', 'amr-users');
         $text .= '<br />' . __('Delete all the cache records and try again', 'amr-users');
         $text .= '<br />' . __('Check the server logs and your php wordpress memory limit.', 'amr-users');
         $text .= '<br />' . __('The TPC memory usage plugin may be useful to assess whether the problem is memory.', 'amr-users');
         $text = $fun . '<br/>' . $text;
         amr_users_message($text);
     }
 }
Exemple #30
0
 public function getCreated()
 {
     return $this->created->format('Y-m-d H:i:s');
 }