Пример #1
1
 function loadAppServices($appName = SITENAME)
 {
     if (defined("BASEPATH")) {
         trigger_logikserror("App <b>'" . $appName . "'</b> has already been activated", E_ERROR);
     }
     define("BASEPATH", APPS_FOLDER . $appName . "/");
     define("APPROOT", ROOT . BASEPATH);
     define("WEBAPPROOT", SiteLocation . BASEPATH);
     if (!file_exists(APPROOT)) {
         trigger_logikserror("Site Not Found <b>'" . $appName . "'</b>", E_ERROR);
     }
     $apps_cfg = APPROOT . "apps.cfg";
     if (!file_exists($apps_cfg)) {
         trigger_logikserror("Site <b>'" . $appName . "'</b> Has Not Yet Been Activated (missing apps.cfg).", E_ERROR);
     }
     loadConfigs($apps_cfg);
     loadConfigDir(APPROOT . "config/");
     if (!defined("APPS_CONFIG_FOLDER")) {
         loadConfigs(ROOT . "config/masters/folders.cfg");
     }
     if (defined("LINGUALIZER_DICTIONARIES")) {
         Lingulizer::getInstance()->loadLocaleFile(LINGUALIZER_DICTIONARIES);
     }
     if (!defined("APPS_THEME")) {
         define("APPS_THEME", getConfig("APPS_THEME"));
     }
     if (!defined("APPS_TEMPLATEENGINE")) {
         define("APPS_TEMPLATEENGINE", getConfig("APPS_TEMPLATEENGINE"));
     }
     if (!defined("APPNAME")) {
         define("APPNAME", SITENAME);
     }
     return true;
 }
Пример #2
0
function listAction()
{
    $config = getConfig();
    $columnsName = [];
    foreach ($_GET['columns'] as $column) {
        if (!empty($column['data'])) {
            $columnsName[] = $column['data'];
        }
    }
    $order = $_GET['order'][0];
    $orderColumn = $order['column'];
    $start = intval($_GET['start']);
    $sqlAssoc = ['table' => ['name' => 'item', 'dbname' => 'db_vktest', 'as' => 'i'], 'query' => ['select' => $columnsName, 'from' => 'item', 'order' => ['column' => $columnsName[$orderColumn], 'dir' => $order['dir']], 'start' => $start, 'length' => $_GET['length']]];
    $mysqli = db_mysqli_connect($sqlAssoc['table']['dbname']);
    $rowStore = db_mysqli_query_fetch_store($mysqli, 'SELECT s.countitems FROM store AS s WHERE s.idstore = 1', MYSQLI_ASSOC)[0];
    $sqlQueryes = buildListItemQuery($sqlAssoc, $rowStore['countitems']);
    $rows = db_mysqli_query_fetch_list($mysqli, $sqlQueryes, MYSQLI_ASSOC);
    db_mysqli_close($mysqli);
    //    var_dump($_SESSION);
    //    var_dump($sqlQueryes);
    $_SESSION['list'] = ['lastitem' => $rows[count($rows) - 1], 'firstitem' => $rows[0], 'lastpage' => $start, 'slowQueryType' => $sqlQueryes['slowQueryType']];
    //for cahce before last result
    afterLictAction($sqlAssoc, $rowStore);
    $response = ['recordsTotal' => $rowStore['countitems'], 'recordsFiltered' => $rowStore['countitems'], 'data' => $rows, 'draw' => $_GET['draw'], 'start' => $_GET['start']];
    echo json_encode($response);
}
Пример #3
0
 function editor($fieldname, $content)
 {
     if (!is_file($this->coderoot . '/fckeditor/fckeditor.php')) {
         return '<textarea name="' . $fieldname . '">' . htmlspecialchars($content) . '</textarea>';
     }
     include_once $this->coderoot . '/fckeditor/fckeditor.php';
     if (!class_exists('FCKeditor')) {
         return 'Editor class not found';
     }
     $oFCKeditor = new FCKeditor($fieldname);
     $fckPath = getConfig("fckeditor_path");
     $oFCKeditor->BasePath = $fckPath;
     $oFCKeditor->ToolbarSet = 'Default';
     $oFCKeditor->Value = $content;
     $w = getConfig("fckeditor_width");
     $h = getConfig("fckeditor_height");
     if (isset($_SESSION["fckeditor_height"])) {
         $h = sprintf('%d', $_SESSION["fckeditor_height"]);
     }
     # for version 2.0
     if ($h < 400) {
         $h = 400;
     }
     $oFCKeditor->Height = $h;
     $oFCKeditor->Width = $w;
     return $oFCKeditor->CreateHtml();
 }
Пример #4
0
    public function onAction()
    {
        parent::onAction();
        // TODO proper email sending
        $target = $this->plugin->getData('target');
        $actionResp = getApi()->invoke("/action/{$target['id']}/view.json", EpiRoute::httpGet);
        if ($actionResp['code'] !== 200) {
            return;
        }
        $action = $actionResp['result'];
        $email = getConfig()->get('user')->email;
        $subject = 'You got a new comment on your photo';
        if ($action['type'] == 'comment') {
            $body = <<<BODY
{$action['email']} left a comment on your photo.

====
{$action['value']}
====

See the comment here: {$action['permalink']}
BODY;
        } else {
            $body = <<<BODY
{$action['email']} favorited a photo of yours.

See the favorite here: {$action['permalink']}
BODY;
        }
        $headers = "From: Trovebox Robot <*****@*****.**>\r\n" . "Reply-To: no-reply@trovebox.com\r\n" . 'X-Mailer: Trovebox';
        mail($email, $subject, $body, $headers);
    }
Пример #5
0
/**
 * Return a formatted price for a product for display on product detail pages.
 * Detail pages are defined as those product pages which contain the primary
 * details for a product.
 *
 * @see formatProductPrice
 * @param array $product Array containing the product to format the price for.
 * @param array $options Array of options, passed to formatProductPrice
 * @return string Generated HTML to display the price for the product.
 */
function formatProductDetailsPrice($product, array $options = array())
{
	$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}

	$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
	$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);

	$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
	$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);

	$output = '<span class="ProductDetailsPriceIncTax">';
	$output .= $priceIncTax;
	$output .= getLang('ProductDetailsPriceIncTaxLabel', array(
		'label' => getConfig('taxLabel')
	));
	$output .= '</span> ';
	$output .= '<span class="ProductDetailsPriceExTax">';
	$output .= $priceExTax;
	$output .= getLang('ProductDetailsPriceExTaxLabel', array(
		'label' => getConfig('taxLabel')
	));
	$output  .= '</span>';
	return $output;
}
Пример #6
0
 /**
  * The public interface for instantiating a file system obect.
  * This returns the appropriate type of object by reading the config.
  * Accepts a set of params that must include a type and targetType
  *
  * @param string $type Optional type parameter which defines the type of file system.
  * @return object A file system object that implements FileSystemInterface
  */
 function getFs()
 {
     static $filesystem, $type;
     if ($filesystem) {
         return $filesystem;
     }
     if (func_num_args() == 1) {
         $type = func_get_arg(0);
     }
     // load configs only once
     if (!$type) {
         $type = getConfig()->get('systems')->fileSystem;
     }
     switch ($type) {
         case 'Local':
             $filesystem = new FileSystemLocal();
             break;
         case 'LocalDropbox':
             $filesystem = new FileSystemLocalDropbox();
             break;
         case 'S3':
             $filesystem = new FileSystemS3();
             break;
         case 'S3Dropbox':
             $filesystem = new FileSystemS3Dropbox();
             break;
     }
     if ($filesystem) {
         return $filesystem;
     }
     throw new Exception("FileSystem Provider {$type} does not exist", 404);
 }
 function __construct()
 {
     parent::phplistplugin();
     $this->numcriterias = 2;
     $this->numcriterias = getConfig('simpleattributeselect_numcriterias');
     $GLOBALS['simpleattributeselect_criteriacache'] = array();
 }
 function PHPlistMailer($messageid, $email)
 {
     #  parent::PHPMailer();
     parent::SetLanguage('en', dirname(__FILE__) . '/phpmailer/language/');
     $this->addCustomHeader("X-Mailer: phplist v" . VERSION);
     $this->addCustomHeader("X-MessageID: {$messageid}");
     $this->addCustomHeader("X-ListMember: {$email}");
     $this->addCustomHeader("Precedence: bulk");
     $this->CharSet = getConfig("html_charset");
     if (defined('PHPMAILERHOST') && PHPMAILERHOST != '') {
         //logEvent('Sending email via '.PHPMAILERHOST);
         $this->SMTPAuth = true;
         $this->Helo = getConfig("website");
         $this->Host = PHPMAILERHOST;
         if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '' && isset($GLOBALS['phpmailer_smtppassword']) && $GLOBALS['phpmailer_smtppassword']) {
             $this->Username = $GLOBALS['phpmailer_smtpuser'];
             $this->Password = $GLOBALS['phpmailer_smtppassword'];
         }
         $this->Mailer = "smtp";
     } else {
         #  logEvent('Sending via mail');
         $this->Mailer = "mail";
     }
     //$ip = gethostbyname($this->Host);
     if ($GLOBALS["message_envelope"]) {
         $this->Sender = $GLOBALS["message_envelope"];
         $this->addCustomHeader("Errors-To: " . $GLOBALS["message_envelope"]);
     }
 }
Пример #9
0
 public function __construct()
 {
     $this->config = getConfig()->get();
     $this->db = getDb();
     $this->utility = new Utility();
     $this->user = new User();
 }
Пример #10
0
/**
 * 导入组件,比如import("Lib.File.Image");
 * @author linyh
 * @param $className
 * @return bool 是否成功导入
 */
function import($className)
{
    static $cacheClass;
    if (strstr($className, '.') === false) {
        $className = getConfig("classHash", $className);
    }
    // 检查是否导入过
    if (isset($cacheClass[$className])) {
        return true;
    }
    $sEach = explode(".", $className);
    // 检查是否符合要求
    foreach ($sEach as $v) {
        if (!validateVar($v)) {
            trigger_error("需要导入的路径{$v}不符合变量名定义", E_USER_ERROR);
        }
    }
    // 最后一个点之后的内容大小写不变,其他的都变成小写
    $componentPath = '';
    for ($i = 0; $i < sizeof($sEach) - 1; $i++) {
        $componentPath .= strtolower($sEach[$i]) . '/';
    }
    $componentPath .= $sEach[$i] . ".class.php";
    // 按照物理路径导入
    if (require $componentPath) {
        $cacheClass[$className] = true;
        return true;
    } else {
        trigger_error("需要导入的类{$className}未找到:{$componentPath}", E_USER_WARNING);
        return false;
    }
}
Пример #11
0
 public static function restApiQuery($method, $uri = '', $query = array(), $postfields = array(), $options = array())
 {
     $restApiServer = getConfig()->get('javamonitor-rest')->restApiServer;
     if (empty($restApiServer)) {
         $restApiServer = $_SERVER['HTTP_HOST'];
     }
     $restApiPath = getConfig()->get('javamonitor-rest')->restApiPath;
     $restApiPort = getConfig()->get('javamonitor-rest')->restApiPort;
     $restApiProtocol = getConfig()->get('javamonitor-rest')->restApiProtocol;
     $restApiUrl = $restApiProtocol . "://" . $restApiServer . ":" . $restApiPort . $restApiPath;
     $restApiOptionDefaults = getConfig()->get('javamonitor-rest')->restApiOptionDefaults;
     $restApiPw = getConfig()->get('javamonitor-rest')->restApiPw;
     //print_r($restApiUrl);
     //if ($uri != '') $uri = '/' . $uri;
     // Connect
     $restApiHandle = curl_init();
     //echo "DB operation: $method $uri\n";
     //print_r($query);
     // Compose query
     $queryPw = array('pw' => $restApiPw);
     $options = array(CURLOPT_URL => $restApiUrl . $uri . '?' . http_build_query($query + $queryPw), CURLOPT_CUSTOMREQUEST => $method, CURLOPT_POSTFIELDS => http_build_query($postfields));
     curl_setopt_array($restApiHandle, $options + $restApiOptionDefaults);
     // send request and wait for response
     $response = json_decode(curl_exec($restApiHandle), true);
     //$response =  curl_exec($restApiHandle);
     //If the response is single lined, we turn it into an indexed array
     if (!is_array($response[0])) {
         $response = array($response);
     }
     //echo "Response from DB: \n";
     //print_r($response);
     curl_close($restApiHandle);
     return $response;
 }
 /**
  * 初始化方法
  */
 public function C_start()
 {
     parent::C_start();
     $this->setServiceBean('admin.keywords.service');
     $types = getConfig('system.keywords.type');
     $this->assign('types', $types);
 }
Пример #13
0
 public function __construct($params = null)
 {
     if (isset($params['config'])) {
         $this->config = $params['config'];
     } else {
         $path = dirname(dirname(dirname(__FILE__)));
         $params = parse_ini_file(sprintf('%s/configs/defaults.ini', $path), true);
         if (file_exists($overrideIni = sprintf('%s/configs/override.ini', $path))) {
             $override = parse_ini_file($overrideIni, true);
             foreach ($override as $key => $value) {
                 if (array_key_exists($key, $params)) {
                     if (is_array($value)) {
                         $params[$key] = array_merge((array) $params[$key], $value);
                     } else {
                         $params[$key] = $value;
                     }
                 } else {
                     $params[$key] = $value;
                 }
             }
         }
         $configParams = array($params['epi']['config']);
         if (isset($params['epiConfigParams'])) {
             $configParams = array_merge($configParams, $params['epiConfigParams']);
         }
         EpiConfig::employ($configParams);
         $this->config = getConfig();
     }
     if (isset($params['utility'])) {
         $this->utility = $params['utility'];
     }
     $this->basePath = dirname(dirname(dirname(__FILE__)));
     $this->host = $_SERVER['HTTP_HOST'];
     // TODO this isn't the best idea
 }
Пример #14
0
	/**
	 * Set the panel settings.
	 */
	public function SetPanelSettings()
	{
		if(GetConfig('HomeFeaturedProducts') <= 0) {
			$this->DontDisplay = true;
			return false;
		}

		$GLOBALS['SNIPPETS']['VendorFeaturedItems'] = '';

		if(!getProductReviewsEnabled()) {
			$GLOBALS['HideProductRating'] = "display: none";
		}

		$cVendor = GetClass('ISC_VENDORS');
		$vendor = $cVendor->GetVendor();

		$query = $this->getProductQuery(
			'p.prodvendorid='.(int)$vendor['vendorid'],
			'p.prodvendorfeatured DESC, RAND()',
			getConfig('HomeFeaturedProducts')
		);
		$result = $GLOBALS['ISC_CLASS_DB']->Query($query);

		$GLOBALS['AlternateClass'] = '';
		while($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
			$this->setProductGlobals($row);
			$GLOBALS['SNIPPETS']['VendorFeaturedItems'] .= $GLOBALS['ISC_CLASS_TEMPLATE']->GetSnippet("VendorFeaturedItemsItem");
		}

		$GLOBALS['VendorProductsLink'] = VendorProductsLink($vendor);

		if(!$GLOBALS['SNIPPETS']['VendorFeaturedItems']) {
			$this->DontDisplay = true;
		}
	}
Пример #15
0
function lotto_editLottery()
{
    // We need some globals
    global $MySelf;
    global $DB;
    $formDisable = "";
    if (lotto_getOpenDrawing()) {
        $formDisable = "disabled";
    }
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Deny access to non-lotto-officials.
    if (!$MySelf->isLottoOfficial()) {
        makeNotice("You are not allowed to do this!", "error", "Permission denied");
    }
    $table = new table(2, true);
    $table->addHeader(">> Open new drawing");
    $table->addRow();
    $table->addCol("Number of tickets in draw:");
    $table->addCol("<input type=\"text\" name=\"count\" " . $formDisable . " value=\"30\">");
    //	$newLotto = new table (2);
    $table->addHeaderCentered("<input type=\"submit\" name=\"submit\" " . $formDisable . " value=\"open new drawing\">", array("bold" => true, "colspan" => 2));
    $html = "<h2>Lotto Administration</h2>";
    $html .= "<form action=\"index.php\" method=\"POST\">";
    $html .= "<input type=\"hidden\" name=\"check\" value=\"true\">";
    $html .= "<input type=\"hidden\" name=\"action\" value=\"createDrawing\">";
    $html .= $table->flush();
    $html .= "</form>";
    if (lotto_getOpenDrawing()) {
        $html .= "[<a href=\"index.php?action=drawLotto\">Draw Winner</a>]";
    }
    return $html;
}
 function __construct($config)
 {
     $this->config = $config;
     $this->dbh = new PDO("sqlite:" . getConfig($this->config, 'ftc_data_db', TRUE), NULL, NULL, array(PDO::ATTR_PERSISTENT => TRUE));
     /* FIXME: move to SETUP procedure? */
     $this->dbh->query('CREATE TABLE IF NOT EXISTS storageNodes (id INTEGER PRIMARY KEY AUTOINCREMENT, displayName TEXT, apiUrl TEXT, consumerKey TEXT, consumerSecret TEXT, storageOwner TEXT)');
 }
Пример #17
0
 function PHPlistMailer($messageid, $email)
 {
     #  parent::PHPMailer();
     $this->addCustomHeader("X-Mailer: PHPlist v" . VERSION);
     $this->addCustomHeader("X-MessageID: {$messageid}");
     $this->addCustomHeader("X-ListMember: {$email}");
     $this->addCustomHeader("Precedence: bulk");
     $this->Host = PHPMAILERHOST;
     $this->Helo = getConfig("website");
     $this->CharSet = getConfig("html_charset");
     if (isset($GLOBALS['phpmailer_smtpuser']) && $GLOBALS['phpmailer_smtpuser'] != '') {
         $this->SMTPAuth = true;
         $this->Username = $GLOBALS['phpmailer_smtpuser'];
         $this->Password = $GLOBALS['phpmailer_smtppassword'];
         #        logEvent('Sending authenticated email via '.PHPMAILERHOST);
     }
     $ip = gethostbyname($this->Host);
     if ($GLOBALS["message_envelope"]) {
         $this->Sender = $GLOBALS["message_envelope"];
         $this->addCustomHeader("Errors-To: " . $GLOBALS["message_envelope"]);
     }
     if (!$this->Host || $ip == $this->Host) {
         $this->Mailer = "mail";
         #        logEvent('Sending via mail');
     } else {
         $this->Mailer = "smtp";
         #        logEvent('Sending via smtp');
     }
 }
Пример #18
0
 public function __call($func, $argv)
 {
     if (substr($func, 0, 3) == 'get') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         if (isset($argv[0])) {
             $environment = $argv[0];
         } else {
             $environment = APPLICATION_ENV;
         }
         return getConfig($key, $environment);
     } elseif (substr($func, 0, 3) == 'set') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         $value = Arrays::first($argv);
         if (isset($argv[1])) {
             $environment = $argv[1];
         } else {
             $environment = 'all';
         }
         setConfig($key, $value, $environment);
         return $this;
     } elseif (substr($func, 0, 3) == 'has') {
         $uncamelizeMethod = Inflector::uncamelize(lcfirst(substr($func, 3)));
         $key = Inflector::lower($uncamelizeMethod);
         if (isset($argv[0])) {
             $environment = $argv[0];
         } else {
             $environment = APPLICATION_ENV;
         }
         return null !== getConfig($key, $environment);
     }
 }
Пример #19
0
function rssUserHasContent($userid,$messageid,$frequency) {
	global $tables;
  switch ($frequency) {
    case "weekly":
      $interval = 'interval 7 day';break;
    case "monthly":
      $interval = 'interval 1 month';break;
    case "daily":
    default:
      $interval = 'interval 1 day';break;
  }
  
	$cansend_req = Sql_Query(sprintf('select date_add(last,%s) < now() from %s where userid = %d',
      $interval,$tables["user_rss"],$userid));
	$exists = Sql_Affected_Rows();
	$cansend = Sql_Fetch_Row($cansend_req);
  if (!$exists || $cansend[0]) {
  	# we can send this user as far as the frequency is concerned
    # now check whether there is actually some content

    # check what lists to use. This is the intersection of the lists for the
    # user and the lists for the message
    $lists = array();
    $listsreq = Sql_Query(sprintf('
    	select %s.listid from %s,%s where %s.listid = %s.listid and %s.userid = %d and
      %s.messageid = %d',
      $tables["listuser"],$tables["listuser"],$tables["listmessage"],
			$tables["listuser"],$tables["listmessage"],
      $tables["listuser"],$userid,$tables["listmessage"],$messageid));
   	while ($row = Sql_Fetch_Row($listsreq)) {
    	array_push($lists,$row[0]);
    }
    if (!sizeof($lists))
    	return 0;
    $liststosend = join(",",$lists);
    # request the rss items that match these lists and that have not been sent to this user
    $itemstosend = array();
		$max = sprintf('%d',getConfig("rssmax"));
		if (!$max) {
			$max = 30;
		}

    $itemreq = Sql_Query("select {$tables["rssitem"]}.*
	    from {$tables["rssitem"]} where {$tables["rssitem"]}.list in ($liststosend) order by added desc, list,title limit $max");
    while ($item = Sql_Fetch_Array($itemreq)) {
    	Sql_Query("select * from {$tables["rssitem_user"]} where itemid = {$item["id"]} and userid = $userid");
      if (!Sql_Affected_Rows()) {
				array_push($itemstosend,$item["id"]);
      }
    }
  #  print "<br/>Items to send for user $userid: ".sizeof($itemstosend);
    # if it is less than the treshold return nothing
    $treshold = getConfig("rsstheshold");
    if (sizeof($itemstosend) >= $treshold)
     	return $itemstosend;
    else
      return array();
  }
 	return array();
}
function db_mysqli_query_fetch_list($mysqli, $query, $MYSQLI_TYPE)
{
    $config = getConfig();
    $params = $config['memcache'];
    $memcache = memcache_connect($params['host'], $params['port']);
    $memcacheQueryKey = 'QUERY' . $query['slow'];
    $data = memcache_get($memcache, $memcacheQueryKey);
    if (!empty($data)) {
    } else {
        if (!empty($query['fast'])) {
            $result = mysqli_query($mysqli, $query['fast']);
        } else {
            $result = mysqli_query($mysqli, $query['slow']);
        }
        $data = [];
        while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) {
            $data[] = $row;
        }
        //another proc
        /* $pid = pcntl_fork();
           if ($pid == 0) {*/
        memcache_set($memcache, $memcacheQueryKey, $data, 0, 60 * 10);
        /*    posix_kill(posix_getpid(), SIGTERM);
              }*/
    }
    memcache_close($memcache);
    return $data;
}
Пример #21
0
 public function __construct($params = null)
 {
     if (isset($params['config'])) {
         $config = $params['config'];
     } else {
         $config = getConfig()->get();
     }
     $mediaVersion = $config->defaults->mediaVersion;
     if (isset($config->site->mediaVersion)) {
         $mediaVersion = $config->site->mediaVersion;
     }
     $this->cdnPrefix = $config->site->cdnPrefix;
     $this->docroot = $config->paths->docroot;
     $this->cacheDir = sprintf('%s/assets/cache', $this->docroot);
     $this->cacheDirVersioned = sprintf('/assets/versioned/%s/', $mediaVersion);
     // trailing slash because it's used in a str_replace
     $this->assets = $this->assetsRel = array('js' => array(), 'css' => array());
     $siteMode = $config->site->mode;
     if ($siteMode === 'prod') {
         $this->mode = self::minified;
     } else {
         $this->mode = self::combined;
     }
     $this->types = array('css' => 'text/css', 'gif' => 'image/gif', 'jpg' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'js' => 'text/javascript', 'ico' => 'image/vnd.microsoft.icon', 'png' => 'image/png', 'tiff' => 'image/tiff');
 }
Пример #22
0
 public function doLogin()
 {
     $curlObj = loadClass('zhCurl');
     //获取登陆页
     $loginSite = "https://www.zhihu.com/";
     $loginHtml = $curlObj->getWebPage($loginSite);
     $html = loadClass('parserDom', $loginHtml['content']);
     $xsrf = $html->find('input[name=_xsrf]', 0)->getAttr('value');
     unset($html);
     //获取验证码并从CLI输入
     $captcha = "https://www.zhihu.com/captcha.gif?r=" . time() . rand(200, 999);
     $result = $curlObj->getWebPage($captcha);
     $captchaFile = dirname(__FILE__) . '/../res/login.gif';
     $handle = fopen($captchaFile, 'w+');
     fwrite($handle, $result['content']);
     fclose($handle);
     fwrite(STDOUT, "Pleate check the login.gif in project 'res' foler and enter it:\n");
     $captchaContent = trim(fgets(STDIN));
     $postParam = array('_xsrf' => $xsrf, 'email' => getConfig('zhAccount'), 'password' => getConfig('zhPassword'), 'remember_me' => 'true', 'captcha' => $captchaContent);
     $postUrl = 'https://www.zhihu.com/login/email';
     $result = $curlObj->getWebPage($postUrl, array(CURLOPT_POSTFIELDS => buildParamFromArray($postParam)));
     $loginResult = json_decode($result['content'], TRUE);
     if ($loginResult['r'] == 0) {
         fwrite(STDOUT, "Login Success\n");
     } else {
         fwrite(STDOUT, "Login Failed: {$loginResult['msg']}\n");
     }
     return $xsrf;
 }
Пример #23
0
function showHierarchy()
{
    // Globals!
    global $DB;
    // Get all sorted ranks.
    $Ranks = $DB->query("SELECT DISTINCT name, rankid, rankOrder FROM ranks ORDER by rankOrder ASC");
    while ($rank = $Ranks->fetchRow()) {
        // Get all the users in the current rank.
        $peopleInRank = $DB->query("SELECT DISTINCT username, rank FROM users WHERE rank='{$rank['rankid']}' AND deleted='0' AND canLogin='******' ORDER BY username");
        // Are there people in this rank?
        if ($peopleInRank->numRows() > 0) {
            // Create a temp. table.
            $table = new table(1, true);
            $table->addHeader(">> " . $rank[name]);
            while ($peep = $peopleInRank->fetchRow()) {
                $table->addRow();
                $table->addCol("<a href=\"index.php?action=profile&id=" . usernameToID($peep[username]) . "\">" . ucfirst($peep[username]) . "</a>");
            }
            $html .= $table->flush() . "<br>";
            unset($table);
        }
    }
    $header = "<h2>" . getConfig("sitename") . " - Hierarchy</h2>";
    return $header . $html;
}
Пример #24
0
function deleteEvent()
{
    // is the events module active?
    if (!getConfig("events")) {
        makeNotice("The admin has deactivated the events module.", "warning", "Module not active");
    }
    // Import the globals, as usual.
    global $DB;
    global $MySelf;
    // Are we allowed to be here?
    if (!$MySelf->canDeleteEvents()) {
        makeNotice("You are not allowed to do this!", "error", "Forbidden");
    }
    // Is the ID safe?
    if (!is_numeric($_GET[id]) || $_GET[id] < 0) {
        makeNotice("Invalid ID given!", "error", "Invalid Data");
    }
    // Does the user really want this?
    confirm("Are you sure you want to delete this event?");
    // Ok, then delete it.
    $DB->query("DELETE FROM events WHERE id = '{$_GET['id']}' LIMIT 1");
    if ($DB->affectedRows() == 1) {
        // Inform the people!
        // mailUser();
        makeNotice("The event has been deleted", "notice", "Event deleted", "index.php?action=showevents", "[OK]");
    } else {
        makeNotice("Could not delete the event from the database.", "error", "DB Error", "index.php?action=showevents", "[Cancel]");
    }
}
Пример #25
0
 function editorCodeUpdate($compName, $catName, $newMarkupCode, $newStylesCode, $newJsCode)
 {
     $config = getConfig('../..');
     $compExt = $config[0]['component_extension'];
     $stylesExt = $config[0]['styles_extension'];
     $stylesDir = $config[0]['styles_directory'];
     $compDir = $config[0]['component_directory'];
     $jsDir = $config[0]['js_directory'];
     $jsExt = $config[0]['js_extension'];
     $compPath = '../../' . $compDir . '/' . $catName . '/' . $compName . '.' . $compExt . '';
     file_put_contents($compPath, $newMarkupCode);
     $stylesPath = '../../' . $stylesDir . '/' . $catName . '/_' . $compName . '.' . $stylesExt . '';
     file_put_contents($stylesPath, $newStylesCode);
     if ($newJsCode == "noJs") {
     } else {
         $jsPath = '../../' . $jsDir . '/' . $compName . '.' . $jsExt . '';
         file_put_contents($jsPath, $newJsCode);
     }
     /*        if($codeDest == $compDir){
                 $compName = $compName.'.'.$compExt.'';
             }
             if($codeDest == $stylesDir){
                 $compName = '_'.$compName.'.'.$stylesExt.'';
             }
             if($codeDest == $jsDir){
                 $path = '../../'.$codeDest.'/'.$compName.'.'.$jsExt.'';
                 file_put_contents($path, $newCode);
             }
     
             if($codeDest !== $jsDir) {
                 $path = '../../' . $codeDest . '/' . $catName . '/' . $compName.'';
                 file_put_contents($path, $newCode);
             }*/
 }
 private function _photo()
 {
     require_once SITE_PATH . '/apps/photo/Common/common.php';
     // 热门推荐相册
     $data['IsHotList'] = IsHotList();
     // 照片
     $order = NULL;
     switch ($_GET['order']) {
         case 'new':
             //最新排行
             $order = 'cTime DESC';
             break;
         default:
             //默认热门排行
             $order = 'readCount DESC';
     }
     $map['privacy'] = 1;
     //所有人公开的图片
     //获取配置参数
     $config = getConfig();
     $data['photos'] = D('Photo', 'photo')->where($map)->order($order)->findPage(16);
     $data['photo_preview'] = $config['photo_preview'];
     $this->assign($data);
     $this->display('photo');
 }
Пример #27
0
function lotto_createDrawing()
{
    // The usual susglobals. ;)
    global $DB;
    global $MySelf;
    global $TIMEMARK;
    $count = $_POST[count];
    // is Lotto enabled at all?
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Deny access to non-lotto-officials.
    if (!$MySelf->isLottoOfficial()) {
        makeNotice("You are not allowed to do this!", "error", "Permission denied");
    }
    // We only allow boards greater 1 ticket.
    if (!is_numeric($count) && $count < 1) {
        makeNotice("Invalid count for the new drawing!", "error", "Invaid Count", "index.php?action=editLotto", "[Cancel]");
    }
    // Is there already a drawing opened?
    if (lotto_getOpenDrawing()) {
        makeNotice("You can only have one drawing open at the same time!", "error", "Close other drawing", "index.php?action=editLotto", "[Cancel]");
    }
    $DB->query("INSERT INTO lotto (opened,isOpen) VALUES (?,?)", array($TIMEMARK, "1"));
    if ($DB->affectedRows() != 1) {
        makeNotice("Error creating new drawing in database! Inform admin!", "error", "Internal Error", "index.php?action=editLotto", "[Cancel]");
    }
    // Which ID are we now?
    $drawing = lotto_getOpenDrawing();
    // insert tickets!
    for ($i = 1; $i <= $_POST[count]; $i++) {
        $DB->query("INSERT INTO lotteryTickets (ticket, drawing) VALUES ('{$i}', '{$drawing}')");
    }
    makeNotice("Drawing created, have fun!", "notice", "Here you go.", "index.php?action=lotto", "lotto! LOTTO!");
}
Пример #28
0
function rss_toolkit_channels_combo($id, $all_channels_id = ALL_CHANNELS_ID, $selected = 0, $showDeprecated = false)
{
    $ret = "\t\t<select name=\"{$id}\" id=\"{$id}\">\n" . "\t\t\t<option value=\"" . $all_channels_id . "\"" . (0 == $selected ? " selected=\"selected\"" : "") . ">" . __('All') . "</option>\n";
    $sql = "select " . " c.id, c.title, f.name, f.id  " . " from " . getTable("channels") . " c " . " inner join " . getTable("folders") . " f " . "   on f.id = c.parent ";
    if (hidePrivate()) {
        $sql .= " and not(c.mode & " . RSS_MODE_PRIVATE_STATE . ") ";
    }
    if (false == $showDeprecated) {
        $sql .= " and not(c.mode & " . RSS_MODE_DELETED_STATE . ") ";
    }
    $sql .= " order by " . (getConfig('rss.config.absoluteordering') ? "f.position asc, c.position asc" : "f.name asc, c.title asc");
    $res = rss_query($sql);
    $prev_parent = -1;
    while (list($id_, $title_, $parent_, $parent_id_) = rss_fetch_row($res)) {
        if ($prev_parent != $parent_id_) {
            if ($prev_parent > -1) {
                $ret .= "\t\t\t</optgroup>\n";
            }
            if ($parent_ == "") {
                $parent_ = __('Root');
            }
            $ret .= "\t\t\t<optgroup label=\"{$parent_} /\">\n";
            $prev_parent = $parent_id_;
        }
        if (strlen($title_) > 25) {
            $title_ = substr($title_, 0, 22) . "...";
        }
        $ret .= "\t\t\t\t<option value=\"{$id_}\"" . ($selected == $id_ ? " selected=\"selected\"" : "") . ">{$title_}</option>\n";
    }
    if ($prev_parent != 0) {
        $ret .= "\t\t\t</optgroup>\n";
    }
    $ret .= "\t\t</select>\n";
    return $ret;
}
Пример #29
0
 function checkPasswordStrength($pwd)
 {
     $strength = array("Blank", "Very Weak", "Weak", "Medium", "Strong", "Very Strong");
     $score = 1;
     if (strlen($pwd) < 1) {
         return $strength[0];
     }
     if (strlen($pwd) < 4) {
         return $strength[1];
     }
     if (strlen($pwd) >= getConfig("PWD_MIN_LENGTH")) {
         $score++;
     }
     if (strlen($pwd) >= 12) {
         $score++;
     }
     if (preg_match("/[a-z]/", $pwd) && preg_match("/[A-Z]/", $pwd)) {
         $score++;
     }
     if (preg_match("/[0-9]/", $pwd)) {
         $score++;
     }
     if (preg_match("/.[!,@,#,\$,%,^,&,*,?,_,~,-,£,(,)]/", $pwd)) {
         $score++;
     }
     return $strength[$score];
 }
Пример #30
0
function lotto_checkRatio($drawing)
{
    // We need some globals.
    global $DB;
    global $MySelf;
    $LOTTO_MAX_PERCENT = getConfig("lottoPercent");
    if (!getConfig("lotto")) {
        makeNotice("Your CEO disabled the Lotto module, request denied.", "warning", "Lotto Module Offline");
    }
    // Drawing ID valid?
    numericCheck($drawing);
    // Get current occupied tickets in the playa's name.
    $totalPlayerOwned = $DB->getCol("SELECT COUNT(id) FROM lotteryTickets WHERE owner='" . $MySelf->getID() . "' AND drawing='" . $drawing . "'");
    $totalPlayerOwned = $totalPlayerOwned[0];
    // Get total number of tickets.
    $totalTickets = $DB->getCol("SELECT COUNT(id) FROM lotteryTickets WHERE drawing='" . $drawing . "'");
    $totalTickets = $totalTickets[0];
    // Is there actually a limit requested?
    if (!$LOTTO_MAX_PERCENT) {
        // The sky  is the limit!
        $allowedTickets = $totalTickets;
    } else {
        // Calculate max allowed tickets per person, ceil it.
        $allowedTickets = ceil($totalTickets * $LOTTO_MAX_PERCENT / 100);
    }
    // return allowed tickets.
    return $allowedTickets - $totalPlayerOwned;
}