Example #1
1
function makeArticleEasy($article)
{
    log_info($article);
    $conn = getDB();
    $words = explode(" ", $article);
    $outp = "";
    $array = array();
    foreach ($words as $word) {
        $word = str_replace('"', "", $word);
        $word = str_replace("'", "", $word);
        $word = str_replace(" ", "", $word);
        $word = str_replace(".", "", $word);
        $word = str_replace(",", "", $word);
        $word = str_replace(":", "", $word);
        $word = str_replace("\\", "", $word);
        if (empty($word) || strlen($word) < 3) {
            continue;
        }
        $meaning = '';
        $gender = '';
        $partOfSpeech = '';
        //check if the meaning exist in DB
        $result = mysqli_query($conn, "SELECT * FROM words WHERE word = '" . $word . "'");
        if (mysqli_num_rows($result) == 0) {
            // row not found, get from online dicts
            $link = "http://de-en.dict.cc/?s=" . utf8_encode($word);
            $meaning = getMeaningFromOnlinDict($link);
            if (!empty($meaning)) {
                insertWord($conn, $word, $meaning, null, null, 0);
            } else {
                continue;
            }
        } else {
            //take db value
            $row = mysqli_fetch_row($result);
            //var_dump($row);
            $meaning = $row[2];
            $partOfSpeech = $row[3];
            $gender = $row[4];
        }
        if (empty($meaning)) {
            continue;
        }
        //now return as json object
        //     if ($outp != "") {$outp .= ",";}
        $a = new Article();
        $a->word = $word;
        $a->meaning = $meaning;
        array_push($array, $a);
        // $outp .= '{"word":"'  . $word . '",';
        //$outp .= '"meaning":"'  . $meaning . '",';
        //    $outp .= '"meaning":"'  . $meaning. '"}';
        //   $outp .= '"partOfSpeech":"'  . $partOfSpeech . '",';
        //    $outp .= '"gender":"'  . $gender  . '"}';
    }
    //forloop
    //$outp ='{"words":['.$outp.']}';
    echo json_encode($array);
    $conn->close();
}
Example #2
0
 public function onInitExt(InitExtEvent $event)
 {
     global $config, $database;
     if (!is_numeric($config->get_string("db_version"))) {
         $config->set_int("db_version", 2);
     }
     if ($config->get_int("db_version") < 6) {
         // cry :S
     }
     if ($config->get_int("db_version") < 7) {
         if ($database->engine->name == "mysql") {
             $tables = $database->db->MetaTables();
             foreach ($tables as $table) {
                 log_info("upgrade", "converting {$table} to innodb");
                 $database->execute("ALTER TABLE {$table} TYPE=INNODB");
             }
         }
         $config->set_int("db_version", 7);
         log_info("upgrade", "Database at version 7");
     }
     if ($config->get_int("db_version") < 8) {
         // if this fails, don't try again
         $config->set_int("db_version", 8);
         $database->execute($database->engine->scoreql_to_sql("ALTER TABLE images ADD COLUMN locked SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N"));
         log_info("upgrade", "Database at version 8");
     }
 }
 /**
  * search product modal.
  *
  * @param Application $app
  * @param Request     $request
  * @param int         $page_no
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 public function searchProduct(Application $app, Request $request, $page_no = null)
 {
     if (!$request->isXmlHttpRequest()) {
         return null;
     }
     $pageCount = $app['config']['default_page_count'];
     $session = $app['session'];
     if ('POST' === $request->getMethod()) {
         log_info('get search data with parameters ', array('id' => $request->get('id'), 'category_id' => $request->get('category_id')));
         $page_no = 1;
         $searchData = array('id' => $request->get('id'));
         if ($categoryId = $request->get('category_id')) {
             $Category = $app['eccube.repository.category']->find($categoryId);
             $searchData['category_id'] = $Category;
         }
         $session->set('eccube.plugin.related_product.product.search', $searchData);
         $session->set('eccube.plugin.related_product.product.search.page_no', $page_no);
     } else {
         $searchData = (array) $session->get('eccube.plugin.related_product.product.search');
         if (is_null($page_no)) {
             $page_no = intval($session->get('eccube.plugin.related_product.product.search.page_no'));
         } else {
             $session->set('eccube.plugin.related_product.product.search.page_no', $page_no);
         }
     }
     $qb = $app['eccube.repository.product']->getQueryBuilderBySearchDataForAdmin($searchData);
     /** @var \Knp\Component\Pager\Pagination\SlidingPagination $pagination */
     $pagination = $app['paginator']()->paginate($qb, $page_no, $pageCount, array('wrap-queries' => true));
     $paths = array();
     $paths[] = $app['config']['template_admin_realdir'];
     $app['twig.loader']->addLoader(new \Twig_Loader_Filesystem($paths));
     return $app->render('RelatedProduct/Resource/template/admin/modal_result.twig', array('pagination' => $pagination));
 }
Example #4
0
/**
 * Runs when registration form is submitted
 */
function register_submit(Pieform $form, $values)
{
    global $SESSION;
    $result = registration_send_data();
    $data = json_decode($result->data);
    if ($data->status != 1) {
        log_info($result);
        $SESSION->add_error_msg(get_string('registrationfailedtrylater', 'admin', $result->info['http_code']));
    } else {
        set_config('registration_lastsent', time());
        set_config('registration_sendweeklyupdates', $values['sendweeklyupdates']);
        if (get_config('new_registration_policy')) {
            set_config('new_registration_policy', false);
        }
        $SESSION->add_ok_msg(get_string('registrationsuccessfulthanksforregistering', 'admin'));
        $info = '
<h4>' . get_string('datathathavebeensent', 'admin') . '</h4>
<table class="table table-striped table-bordered" id="register-table">
    <thead>
        <tr>
            <th> ' . get_string('Field', 'admin') . '</th>
            <th> ' . get_string('Value', 'admin') . '</th>
        </tr>
    </thead>
    <tbody>
';
        $datasent = registration_data();
        foreach ($datasent as $key => $val) {
            $info .= '<tr><th>' . hsc($key) . '</th><td>' . hsc($val) . "</td></tr>\n";
        }
        $info .= '</tbody></table>';
        $SESSION->add_ok_msg($info, false);
    }
    redirect('/admin/');
}
Example #5
0
 /**
  * 会員情報編集画面.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $Customer = $app->user();
     $LoginCustomer = clone $Customer;
     $app['orm.em']->detach($LoginCustomer);
     $previous_password = $Customer->getPassword();
     $Customer->setPassword($app['config']['default_password']);
     /* @var $builder \Symfony\Component\Form\FormBuilderInterface */
     $builder = $app['form.factory']->createBuilder('entry', $Customer);
     $event = new EventArgs(array('builder' => $builder, 'Customer' => $Customer), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_INITIALIZE, $event);
     /* @var $form \Symfony\Component\Form\FormInterface */
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         log_info('会員編集開始');
         if ($Customer->getPassword() === $app['config']['default_password']) {
             $Customer->setPassword($previous_password);
         } else {
             if ($Customer->getSalt() === null) {
                 $Customer->setSalt($app['eccube.repository.customer']->createSalt(5));
             }
             $Customer->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer));
         }
         $app['orm.em']->flush();
         log_info('会員編集完了');
         $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
         $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_CHANGE_INDEX_COMPLETE, $event);
         return $app->redirect($app->url('mypage_change_complete'));
     }
     $app['security']->getToken()->setUser($LoginCustomer);
     return $app->render('Mypage/change.twig', array('form' => $form->createView()));
 }
 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->task_manager = us($config->getString('task_manager', ''));
     $this->forward_target = us($config->getString('forward_target', ''));
     $this->modules = uv($config->getArray('modules', array()));
     $this->events = uv($config->getArray('events', array()));
     $this->debug_mode = ub($config->getBoolean('debug_mode', FALSE));
     $this->log_enabled = ub($config->getBoolean('log_enabled'));
     $this->log_level = us($config->getString('log_level'));
     $this->log_loggers = uv($config->getArray('log_loggers'));
     // eventsに記載しているイベントのモジュールも読み込む
     if (is_array($this->events)) {
         foreach ($this->events as $event) {
             $pos = strpos($event, "@");
             if ($pos !== FALSE) {
                 $this->modules[] = substr($event, $pos);
             }
         }
     }
     if ($this->getSandbox()->isDebug()) {
         log_info("system, debug, config", "task_manager:" . $this->task_manager, self::TAG);
         log_info("system, debug, config", "forward_target:" . $this->forward_target, self::TAG);
         log_info("system, debug, config", "modules:" . print_r($this->modules, true), self::TAG);
         log_info("system, debug, config", "events:" . print_r($this->events, true), self::TAG);
         log_info("system, debug, config", "debug_mode" . $this->debug_mode, self::TAG);
         log_info("system, debug, config", "log_enabled" . $this->log_enabled, self::TAG);
         log_info("system, debug, config", "log_level" . $this->log_level, self::TAG);
         log_info("system, debug, config", "log_loggers" . print_r($this->log_loggers, true), self::TAG);
     }
 }
function generate_main()
{
    global $categories, $forums;
    global $filter_forum, $filter_topic;
    global $db_prefix;
    global $forum_name, $forum_description;
    //Categories
    $res = mysql_query('SELECT cat_id, cat_title FROM ' . $db_prefix . 'categories order by cat_order');
    while ($row = mysql_fetch_assoc($res)) {
        $cid = $row['cat_id'];
        $categories[$row['cat_id']] = array('title' => $row['cat_title'], 'forums' => array());
    }
    //Forums
    $res = mysql_query('SELECT forum_id, cat_id, forum_name, forum_posts, forum_topics FROM ' . $db_prefix . 'forums ORDER BY forum_order');
    while ($row = mysql_fetch_assoc($res)) {
        $fid = $row['forum_id'];
        if (in_array($fid, $filter_forum)) {
            continue;
        }
        $forums[$fid] = array('cid' => $row['cat_id'], 'title' => $row['forum_name'], 'nposts' => $row['forum_posts'], 'ntopics' => $row['forum_topics'], 'topics' => array());
        $categories[$row['cat_id']]['forums'][] = $fid;
    }
    // Content
    $var = array('categories' => $categories, 'forums' => $forums, 'forum_name' => $forum_name, 'forum_description' => $forum_description);
    $content = template_get($var, 'main.tpl.php');
    write_content('index.html', $content);
    log_info("Index: index.html\n");
}
Example #8
0
 /**
  * 推广连接
  * www.xxx.com/action/Method/站长ID/游戏ID/cpa、cps、。。。/子ID/?ref=url
  * yy.51yx.com/index/tg/12312312/13/2/11/?ref=url
  */
 public function tg()
 {
     $master_id = $_GET[2];
     //站长ID
     $game_id = $_GET[3];
     //游戏ID
     $type = $_GET[4];
     //推广类型 cpa/cps
     $sub_code = $_GET[5];
     //子站长ID
     $ref = $_GET['ref'];
     setcookie(WEBMASTER, $master_id, 0, '/', DOMAIN);
     setcookie(AD_GAME_ID, $game_id, 0, '/', DOMAIN);
     setcookie(SPREAD_TYPE, $type, 0, '/', DOMAIN);
     //CPS 为2	CPA:1   其它:0
     setcookie(SUB_CODE, $sub_code, 0, '/', DOMAIN);
     $ip = getClientIP();
     //记点击日志
     //站长ID,游戏ID,子站长ID,访问IP
     $content = $master_id . ',' . $game_id . ',\'' . $sub_code . '\' ' . $ip;
     @log_info($content, $file = "tg_click_");
     if ($ref) {
         $this->gotourl($ref);
     } else {
         $this->gotourl('/member/register');
     }
     exit;
 }
 public function log($level, &$message) {
     switch ($level) {
         case LogHelper::LEVEL_DEBUG:
             log_debug($message);
             break;
         case LogHelper::LEVEL_INFO:
             log_info($message);
             break;
         case LogHelper::LEVEL_NOTICE:
             log_notice($message);
             break;
         case LogHelper::LEVEL_WARNING:
             log_warn($message);
             break;
         case LogHelper::LEVEL_ERROR:
             log_error($message);
             break;
         case LogHelper::LEVEL_CRITICAL:
             log_critical($message);
             break;
         case LogHelper::LEVEL_ALERT:
             log_alert($message);
             break;
         case LogHelper::LEVEL_EMERGENCY:
             log_emergency($message);
             break;
     }
 }
Example #10
0
function qwp_tmpl_security_check()
{
    global $MODULE_URI, $PAGE, $OP;
    if (qwp_is_passport_module()) {
        return true;
    }
    $acls = C('acls', null);
    if (!$acls) {
        qwp_tmpl_init_security($acls);
    }
    if (!isset($acls['modules'][$MODULE_URI])) {
        return false;
    }
    if ($OP) {
        $path = $MODULE_URI;
        if ($PAGE) {
            $path .= '#' . $PAGE;
        }
        return isset($acls['ops'][$path]) && isset($acls['ops'][$path][$OP]);
    }
    if ($PAGE) {
        return isset($acls['pages'][$MODULE_URI]) && isset($acls['pages'][$MODULE_URI][$PAGE]);
    }
    log_info('security check is passed: ' . $MODULE_URI);
}
Example #11
0
 public function onPageRequest(PageRequestEvent $event)
 {
     global $config, $page, $user;
     if ($event->page_matches("featured_image")) {
         if ($event->get_arg(0) == "set" && $user->check_auth_token()) {
             if ($user->can("edit_feature") && isset($_POST['image_id'])) {
                 $id = int_escape($_POST['image_id']);
                 if ($id > 0) {
                     $config->set_int("featured_id", $id);
                     log_info("featured", "Featured image set to {$id}", "Featured image set");
                     $page->set_mode("redirect");
                     $page->set_redirect(make_link("post/view/{$id}"));
                 }
             }
         }
         if ($event->get_arg(0) == "download") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 $page->set_mode("data");
                 $page->set_type($image->get_mime_type());
                 $page->set_data(file_get_contents($image->get_image_filename()));
             }
         }
         if ($event->get_arg(0) == "view") {
             $image = Image::by_id($config->get_int("featured_id"));
             if (!is_null($image)) {
                 send_event(new DisplayingImageEvent($image, $page));
             }
         }
     }
 }
Example #12
0
 /**
  * 退会画面.
  *
  * @param Application $app
  * @param Request $request
  * @return \Symfony\Component\HttpFoundation\RedirectResponse|\Symfony\Component\HttpFoundation\Response
  */
 public function index(Application $app, Request $request)
 {
     $builder = $app->form();
     $event = new EventArgs(array('builder' => $builder), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_INITIALIZE, $event);
     $form = $builder->getForm();
     $form->handleRequest($request);
     if ($form->isSubmitted() && $form->isValid()) {
         switch ($request->get('mode')) {
             case 'confirm':
                 log_info('退会確認画面表示');
                 return $app->render('Mypage/withdraw_confirm.twig', array('form' => $form->createView()));
             case 'complete':
                 log_info('退会処理開始');
                 /* @var $Customer \Eccube\Entity\Customer */
                 $Customer = $app->user();
                 // 会員削除
                 $email = $Customer->getEmail();
                 // メールアドレスにダミーをセット
                 $Customer->setEmail(Str::random(60) . '@dummy.dummy');
                 $Customer->setDelFlg(Constant::ENABLED);
                 $app['orm.em']->flush();
                 log_info('退会処理完了');
                 $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
                 $app['eccube.event.dispatcher']->dispatch(EccubeEvents::FRONT_MYPAGE_WITHDRAW_INDEX_COMPLETE, $event);
                 // メール送信
                 $app['eccube.service.mail']->sendCustomerWithdrawMail($Customer, $email);
                 // ログアウト
                 $this->getSecurity($app)->setToken(null);
                 log_info('ログアウト完了');
                 return $app->redirect($app->url('mypage_withdraw_complete'));
         }
     }
     return $app->render('Mypage/withdraw.twig', array('form' => $form->createView()));
 }
Example #13
0
 public function receive_event(Event $event)
 {
     global $config, $database, $page, $user;
     if (is_null($this->theme)) {
         $this->theme = get_theme_object($this);
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("admin")) {
         if (!$user->is_admin()) {
             $this->theme->display_permission_denied($page);
         } else {
             send_event(new AdminBuildingEvent($page));
         }
     }
     if ($event instanceof PageRequestEvent && $event->page_matches("admin_utils")) {
         if ($user->is_admin() && $user->check_auth_token()) {
             log_info("admin", "Util: {$_POST['action']}");
             set_time_limit(0);
             $redirect = false;
             switch ($_POST['action']) {
                 case 'delete by query':
                     $this->delete_by_query($_POST['query']);
                     $redirect = true;
                     break;
                 case 'lowercase all tags':
                     $this->lowercase_all_tags();
                     $redirect = true;
                     break;
                 case 'recount tag use':
                     $this->recount_tag_use();
                     $redirect = true;
                     break;
                 case 'purge unused tags':
                     $this->purge_unused_tags();
                     $redirect = true;
                     break;
                 case 'convert to innodb':
                     $this->convert_to_innodb();
                     $redirect = true;
                     break;
                 case 'database dump':
                     $this->dbdump($page);
                     break;
             }
             if ($redirect) {
                 $page->set_mode("redirect");
                 $page->set_redirect(make_link("admin"));
             }
         }
     }
     if ($event instanceof AdminBuildingEvent) {
         $this->theme->display_page($page);
         $this->theme->display_form($page);
     }
     if ($event instanceof UserBlockBuildingEvent) {
         if ($user->is_admin()) {
             $event->add_link("Board Admin", make_link("admin"));
         }
     }
 }
Example #14
0
 public function onDataUpload(DataUploadEvent $event)
 {
     global $database;
     $row = $database->get_row("SELECT * FROM image_bans WHERE hash = :hash", array("hash" => $event->hash));
     if ($row) {
         log_info("image_hash_ban", "Blocked image ({$event->hash})");
         throw new UploadException("Image " . html_escape($row["hash"]) . " has been banned, reason: " . format_text($row["reason"]));
     }
 }
Example #15
0
 /**
  * Class constructor
  *
  * @return	void
  */
 public function __construct()
 {
     log_info("info", "security opened");
     $this->securitytoken_time = time() + 60 * 1;
     $this->securitytoken = "token" . randstring(10);
     // 1min
     $this->urltoken();
     $this->verifyUrl();
 }
Example #16
0
 public function onInitExt($event)
 {
     global $config, $database;
     if ($config->get_int("ext_tips_version") < 1) {
         $database->create_table("tips", "\n\t\t\t\t\tid SCORE_AIPK,\n\t\t\t\t\tenable SCORE_BOOL NOT NULL DEFAULT SCORE_BOOL_N,\n\t\t\t\t\timage TEXT NOT NULL,\n\t\t\t\t\ttext TEXT NOT NULL,\n\t\t\t\t\tINDEX (id)\n\t\t\t\t\t");
         $database->execute("\n\t\t\t\t\tINSERT INTO tips (enable, image, text)\n\t\t\t\t\tVALUES (?, ?, ?)", array("Y", "coins.png", "Do you like this extension? Please support us for developing new ones. <a href=\"https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=8235933\" target=\"_blank\">Donate through paypal</a>."));
         $config->set_int("ext_tips_version", 1);
         log_info("tips", "extension installed");
     }
 }
 public function index(Application $app, Request $request, $id = null)
 {
     $app['orm.em']->getFilters()->enable('incomplete_order_status_hidden');
     // 編集
     if ($id) {
         $Customer = $app['orm.em']->getRepository('Eccube\\Entity\\Customer')->find($id);
         if (is_null($Customer)) {
             throw new NotFoundHttpException();
         }
         // 編集用にデフォルトパスワードをセット
         $previous_password = $Customer->getPassword();
         $Customer->setPassword($app['config']['default_password']);
         // 新規登録
     } else {
         $Customer = $app['eccube.repository.customer']->newCustomer();
         $CustomerAddress = new \Eccube\Entity\CustomerAddress();
         $Customer->setBuyTimes(0);
         $Customer->setBuyTotal(0);
     }
     // 会員登録フォーム
     $builder = $app['form.factory']->createBuilder('admin_customer', $Customer);
     $event = new EventArgs(array('builder' => $builder, 'Customer' => $Customer), $request);
     $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_EDIT_INDEX_INITIALIZE, $event);
     $form = $builder->getForm();
     if ('POST' === $request->getMethod()) {
         $form->handleRequest($request);
         if ($form->isValid()) {
             log_info('会員登録開始', array($Customer->getId()));
             if ($Customer->getId() === null) {
                 $Customer->setSalt($app['eccube.repository.customer']->createSalt(5));
                 $Customer->setSecretKey($app['eccube.repository.customer']->getUniqueSecretKey($app));
                 $CustomerAddress->setName01($Customer->getName01())->setName02($Customer->getName02())->setKana01($Customer->getKana01())->setKana02($Customer->getKana02())->setCompanyName($Customer->getCompanyName())->setZip01($Customer->getZip01())->setZip02($Customer->getZip02())->setZipcode($Customer->getZip01() . $Customer->getZip02())->setPref($Customer->getPref())->setAddr01($Customer->getAddr01())->setAddr02($Customer->getAddr02())->setTel01($Customer->getTel01())->setTel02($Customer->getTel02())->setTel03($Customer->getTel03())->setFax01($Customer->getFax01())->setFax02($Customer->getFax02())->setFax03($Customer->getFax03())->setDelFlg(Constant::DISABLED)->setCustomer($Customer);
                 $app['orm.em']->persist($CustomerAddress);
             }
             if ($Customer->getPassword() === $app['config']['default_password']) {
                 $Customer->setPassword($previous_password);
             } else {
                 if ($Customer->getSalt() === null) {
                     $Customer->setSalt($app['eccube.repository.customer']->createSalt(5));
                 }
                 $Customer->setPassword($app['eccube.repository.customer']->encryptPassword($app, $Customer));
             }
             $app['orm.em']->persist($Customer);
             $app['orm.em']->flush();
             log_info('会員登録完了', array($Customer->getId()));
             $event = new EventArgs(array('form' => $form, 'Customer' => $Customer), $request);
             $app['eccube.event.dispatcher']->dispatch(EccubeEvents::ADMIN_CUSTOMER_EDIT_INDEX_COMPLETE, $event);
             $app->addSuccess('admin.customer.save.complete', 'admin');
             return $app->redirect($app->url('admin_customer_edit', array('id' => $Customer->getId())));
         } else {
             $app->addError('admin.customer.save.failed', 'admin');
         }
     }
     return $app->render('Customer/edit.twig', array('form' => $form->createView(), 'Customer' => $Customer));
 }
Example #18
0
 public function onInitExt(InitExtEvent $event)
 {
     global $config, $database;
     // Create the database tables
     if ($config->get_int("ext_relationships_version") < 1) {
         $database->Execute("ALTER TABLE images ADD parent_id INT NULL, ADD INDEX (parent_id);");
         $database->Execute("ALTER TABLE images ADD has_children BOOL DEFAULT FALSE NOT NULL;");
         $config->set_int("ext_relationships_version", 1);
         log_info("relationships", "extension installed");
     }
 }
 /**
  * 受注マスター表示、検索ボタンクリック時のEvent Fork.
  * 下記の項目を追加する.
  * ・検索結果一覧のコンボボックスに「帳票出力」を追加
  * ・検索結果一覧の上部に「一括帳票出力を追加.
  *
  * @param FilterResponseEvent $event
  */
 public function onRenderAdminOrderPdfBefore(FilterResponseEvent $event)
 {
     log_info('EventLegacy: The Order pdf hook into the order search start');
     if (!$this->app->isGranted('ROLE_ADMIN')) {
         log_info('EventLegacy: You need permission manager to be able to use this function.');
         return;
     }
     $response = $event->getResponse();
     $response->setContent($this->getHtml($response));
     $event->setResponse($response);
     log_info('EventLegacy: The Order pdf hook into the order search end');
 }
Example #20
0
 public function onInitExt(InitExtEvent $event)
 {
     global $config, $database;
     // Create the database tables
     if ($config->get_int("ext_relationships_version") < 1) {
         $database->execute("ALTER TABLE images ADD parent_id INT");
         $database->execute($database->scoreql_to_sql("ALTER TABLE images ADD has_children SCORE_BOOL DEFAULT SCORE_BOOL_N NOT NULL"));
         $database->execute("CREATE INDEX images__parent_id ON images(parent_id)");
         $config->set_int("ext_relationships_version", 1);
         log_info("relationships", "extension installed");
     }
 }
function search($dbpath, $querystring, $offset = 0, $pagesize = 10)
{
    // offset - defines starting point within result set
    // pagesize - defines number of records to retrieve
    // Open the database we're going to search.
    $db = new XapianDatabase($dbpath);
    ### Start of example code.
    // Set up a QueryParser with a stemmer and suitable prefixes
    $queryparser = new XapianQueryParser();
    $queryparser->set_stemmer(new XapianStem("en"));
    $queryparser->set_stemming_strategy(XapianQueryParser::STEM_SOME);
    $queryparser->add_prefix("title", "S");
    $queryparser->add_prefix("description", "XD");
    $queryparser->add_boolean_prefix("material", "XM");
    // And parse the query
    $query = $queryparser->parse_query($querystring);
    ### End of example code.
    // Use an Enquire object on the database to run the query
    $enquire = new XapianEnquire($db);
    $enquire->set_query($query);
    // Set up a spy to inspect the MAKER value at slot 1
    $spy = new XapianValueCountMatchSpy(1);
    $enquire->add_matchspy($spy);
    // Retrieve the matches and compute start and end points
    $matches = $enquire->get_mset($offset, $pagesize);
    $start = $matches->begin();
    $end = $matches->end();
    // Use an array to record the DocIds of each match
    $docids = array();
    while (!$start->equals($end)) {
        // retrieve the document and its data
        $doc = $start->get_document();
        $fields = json_decode($doc->get_data());
        $position = $start->get_rank() + 1;
        // record the docid
        $docid = $start->get_docid();
        $docids[] = $docid;
        // display the results
        printf("%d: #%03d %s\n", $position, $docid, $fields->TITLE);
        // increment MSet iterator and our counter
        $start->next();
    }
    // Parse and display the spy values
    $spy_start = $spy->values_begin();
    $spy_end = $spy->values_end();
    while (!$spy_start->equals($spy_end)) {
        print sprintf("Facet: %s; count: %d\n", $spy_start->get_term(), $spy_start->get_termfreq());
        $spy_start->next();
    }
    // Finally, make sure we log the query and displayed results
    log_info(sprintf("xapian.search:'%s'[%d:%d] = %s", $querystring, $offset, $offset + $pagesize, implode(" ", $docids)));
}
 /**
  * execute exception handlers
  *
  * @param Exception $e     exception to handle
  *
  * @return boolean        TRUE means the exception is handled, otherwise FALSE
  */
 public function handleException($e)
 {
     //        Charcoal_ParamTrait::validateException( 1, $e );
     $this->init();
     foreach ($this->handlers as $handler) {
         log_info("system, debug", "calling exception handler[{$handler}].", "exception");
         $ret = $handler->handleException($e);
         if (b($ret)->isTrue()) {
             return true;
         }
     }
     return false;
 }
 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->use_session = $config->getBoolean('use_session', TRUE);
     $this->sequence = $config->getString('sequence', '');
     $layout_manager = $config->getString('layout_manager');
     $this->setLayoutManager($layout_manager);
     if ($this->getSandbox()->isDebug()) {
         log_info("system,config", "procedure", "use_session:" . $this->use_session);
         log_info("system,config", "procedure", "sequence:" . $this->sequence);
         log_info("system,config", "procedure", "layout_manager:" . $this->layout_manager);
     }
 }
 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $this->_host = $config->getString('host', 'localhost');
     $this->_port = $config->getInteger('port', 11211);
     $this->_weight = $config->getInteger('weight', 100);
     $this->_default_duration = $config->getInteger('default_duration', 0);
     log_debug("system, debug, cache", "cache", "host=[{$this->_host}]");
     log_debug("system, debug, cache", "cache", "port=[{$this->_port}]");
     log_debug("system, debug, cache", "cache", "weight=[{$this->_weight}]");
     log_debug("system, debug, cache", "cache", "default_duration=[{$this->_default_duration}]");
     $this->_memcache->addServer(us($this->_host), ui($this->_port), TRUE, ui($this->_weight));
     log_info("system, debug, cache", "cache", "server added.");
 }
 /**
  * Initialize instance
  *
  * @param Charcoal_Config $config   configuration data
  */
 public function configure($config)
 {
     parent::configure($config);
     $rules_section = $config->getSection('routing rules');
     $patterns = $rules_section->getKeys();
     foreach ($patterns as $pattern) {
         $proc_path = $rules_section->getString($pattern);
         if ($proc_path === NULL) {
             _throw(new Charcoal_RoutingRuleConfigException($pattern, 'can not be NULL'));
         }
         $this->proc_paths[$pattern] = us($proc_path);
     }
     log_info('system,debug,router', "proc_paths:" . print_r($this->proc_paths, true), self::TAG);
 }
Example #26
0
/**
 * Runs when registration form is submitted
 */
function register_submit(Pieform $form, $values)
{
    global $SESSION;
    $result = registration_send_data();
    if ($result->data != '1') {
        log_info($result);
        $SESSION->add_error_msg(get_string('registrationfailedtrylater', 'admin', $result->info['http_code']));
    } else {
        set_config('registration_lastsent', time());
        set_config('registration_sendweeklyupdates', $values['sendweeklyupdates']);
        $SESSION->add_ok_msg(get_string('registrationsuccessfulthanksforregistering', 'admin'));
    }
    redirect('/admin/');
}
 /**
  * execute exception handlers
  *
  * @param Exception $e     exception to handle
  *
  * @return boolean        TRUE means the exception is handled, otherwise FALSE
  */
 public function handleException($e)
 {
     Charcoal_ParamTrait::validateException(1, $e);
     log_info("system, debug", "exception", "handled a framework exception!");
     try {
         /** @var Charcoal_IDebugtraceRenderer $renderer */
         $renderer = $this->getSandbox()->createObject('console', 'debugtrace_renderer', array(), 'Charcoal_IDebugtraceRenderer');
         // Render exception
         $renderer->render($e);
         return TRUE;
     } catch (Exception $e) {
         _catch($e);
         log_info("system, debug", "exception", "debugtrace_renderer creation failed.");
     }
     return FALSE;
 }
Example #28
0
 protected function __construct($domain)
 {
     $settime = 60 * 60 * 24 * 365 * 10;
     //时间修正
     session_name(self::sess_name);
     $k = array_keys($_REQUEST[0]);
     log_info(getClientIP() . "\t  : " . $_COOKIE[session_name()] . "\t " . $k[0] . "\t" . $_COOKIE[SDK] . "\t" . $_COOKIE[SDU] . "\t" . $_COOKIE[SDP]);
     $this->sess_id = isset($_GET['sdsid']) ? trim($_GET['sdsid']) : $_COOKIE[session_name()];
     $this->domain = $domain;
     //		$this->sess_id = isset($_GET['sdsid']) ? trim($_GET['sdsid']) : (empty($_COOKIE[session_name()]) ? $this->gen_sid() : $_COOKIE[session_name()]);
     //		session_id($this->sess_id);
     //		//@setcookie(session_name(),session_id(),time()+$this->sess_time+$settime,'/',$domain);
     //		@setcookie(session_name(),session_id(),time()+900,'/',$domain);
     //		@register_shutdown_function(array($this, 'close'));
     return;
 }
Example #29
0
 /**
  * Event for new hook point.
  *
  * @param TemplateEvent $event
  */
 public function onAdminOrderIndexRender(TemplateEvent $event)
 {
     log_info('Event: Order pdf hook into the order search render start.');
     /**
      * @var \Twig_Environment $twig
      */
     $twig = $this->app['twig'];
     $twigAppend = $twig->getLoader()->getSource('OrderPdf/Resource/template/admin/order_pdf_menu.twig');
     /**
      * @var string twig template
      */
     $twigSource = $event->getSource();
     $twigSource = $this->renderPosition($twigSource, $twigAppend);
     $event->setSource($twigSource);
     log_info('Event: Order pdf hook into the order search render end.');
 }
Example #30
0
 public function view($url = [], $data = [])
 {
     global $config;
     $urltoken = $this->urltoken();
     if (isset($data)) {
         foreach ($data as $key => $value) {
             ${$key} = $value;
         }
     }
     foreach ($url as $value) {
         if (file_exists($config['view'] . "/" . $value . ".php")) {
             include_once $config['view'] . "/" . $value . ".php";
         } else {
             log_info("error", "{$value} not found");
         }
     }
 }